Commit 46c282bd authored by jichao's avatar jichao

改bug

parent 533d6f68
...@@ -11,6 +11,7 @@ import org.rcisoft.mqttclient.MqttClient; ...@@ -11,6 +11,7 @@ import org.rcisoft.mqttclient.MqttClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import tk.mybatis.mapper.entity.Example;
import java.util.List; import java.util.List;
...@@ -40,9 +41,14 @@ public class ZhnyLineRunner implements CommandLineRunner { ...@@ -40,9 +41,14 @@ public class ZhnyLineRunner implements CommandLineRunner {
} }
private void searchProject() { private void searchProject() {
List<BusProject> list = projectRepository.selectAll(); Example example = new Example(BusProject.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("receiveData", 1);
List<BusProject> list = projectRepository.selectByExample(example);
list.forEach(busProject -> { list.forEach(busProject -> {
rcRedisService.set("proId-" + busProject.getProId(), busProject.getReceiveData().toString()); rcRedisService.set("proId-" + busProject.getProId(), busProject.getReceiveData().toString());
// list中放入需要接收数据的proId
// rcRedisService.setList("proIds", busProject.getProId());
}); });
} }
} }
......
...@@ -297,7 +297,13 @@ public class BusDeviceServiceImpl implements BusDeviceService { ...@@ -297,7 +297,13 @@ public class BusDeviceServiceImpl implements BusDeviceService {
@Override @Override
public Integer update(String devNum, Integer errorNum) { public Integer update(String devNum, Integer errorNum) {
return null; BusDevice busDevice = new BusDevice();
busDevice.setDevNum(devNum);
busDevice.setErrorNum(errorNum);
Example example = new Example(BusDevice.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("devNum", devNum);
return busDeviceRepository.updateByExampleSelective(busDevice, example);
} }
private byte[] createExcel(String devNums) throws IOException { private byte[] createExcel(String devNums) throws IOException {
......
...@@ -6,6 +6,7 @@ package org.rcisoft.business.device.inspection.controller; ...@@ -6,6 +6,7 @@ package org.rcisoft.business.device.inspection.controller;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo; import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo;
import org.rcisoft.business.device.inspection.service.InspectionService; import org.rcisoft.business.device.inspection.service.InspectionService;
...@@ -70,7 +71,7 @@ public class InspectionController { ...@@ -70,7 +71,7 @@ public class InspectionController {
//先获取数据库数据 //先获取数据库数据
deviceList = inspectionService.listAllInspectionInfomatinByProIdAndDevNum(proId, devNum,mon); deviceList = inspectionService.listAllInspectionInfomatinByProIdAndDevNum(proId, devNum,mon);
//通过项目id获取对应的名称组拼成文件名 //通过项目id获取对应的名称组拼成文件名
String filename = devNum + "-"+ mon + "巡检记录.xls"; String filename = devNum + "-" + (StringUtils.isEmpty(mon) ? "" : mon + "-") + "巡检记录.xls";
//创建excel生成对象 //创建excel生成对象
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
......
...@@ -35,7 +35,7 @@ public interface BusTeamRepository extends BaseMapper<BusTeam>{ ...@@ -35,7 +35,7 @@ public interface BusTeamRepository extends BaseMapper<BusTeam>{
* *
*/ */
@Select("<script>select a.*,b.* from bus_team a,sys_principal b where a.pri_id =b.pri_id " + @Select("<script>select a.*,b.* from bus_team a,sys_principal b where a.pri_id =b.pri_id " +
" and team_type = #{teamType} order by a.ONLINE_DATE desc" " and team_type = #{teamType} order by a.CREATE_DATE desc"
+ "</script>") + "</script>")
List<Map<String,Object>> queryBusTeams(@Param("teamType") String teamType); List<Map<String,Object>> queryBusTeams(@Param("teamType") String teamType);
......
...@@ -6,6 +6,7 @@ import org.rcisoft.core.entity.IdNotDataEntity; ...@@ -6,6 +6,7 @@ import org.rcisoft.core.entity.IdNotDataEntity;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
/** /**
* Created with liuzhichao on 2018-4-18 17:25:08. * Created with liuzhichao on 2018-4-18 17:25:08.
...@@ -38,5 +39,7 @@ public class BusTeam implements Serializable { ...@@ -38,5 +39,7 @@ public class BusTeam implements Serializable {
private BigDecimal area; private BigDecimal area;
private Integer teamNumber; private Integer teamNumber;
private Date createDate;
} }
...@@ -20,7 +20,7 @@ public interface BusDeviceParamRepository extends BaseMapper<BusDeviceParam> { ...@@ -20,7 +20,7 @@ public interface BusDeviceParamRepository extends BaseMapper<BusDeviceParam> {
* @return * @return
*/ */
@Select("<script>select a.*,b.PARAM_NM,b.PARAM_CODE,b.P_SOURCE from bus_device_param a,bus_devicetp_param b where a.PARAM_CODE = b.PARAM_CODE" + @Select("<script>select a.*,b.PARAM_NM,b.PARAM_CODE,b.P_SOURCE from bus_device_param a,bus_devicetp_param b where a.PARAM_CODE = b.PARAM_CODE" +
" and b.PRO_ID = #{pro_id} and a.DEV_NUM = #{dev_num}" + " and b.PRO_ID = #{pro_id} and a.DEV_NUM = #{dev_num} order by b.PARAM_CODE" +
"</script>") "</script>")
List<Map<String,Object>> detail(Map<String,Object> map); List<Map<String,Object>> detail(Map<String,Object> map);
......
...@@ -7,6 +7,7 @@ import lombok.NoArgsConstructor; ...@@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import java.util.Date;
/** /**
* Created by JiChao on 2018/5/17. * Created by JiChao on 2018/5/17.
...@@ -25,6 +26,7 @@ public class BusSaving { ...@@ -25,6 +26,7 @@ public class BusSaving {
private String qualification; private String qualification;
private String tm; private String tm;
private String performance; private String performance;
private Date createDate;
// private String type; // private String type;
// private String proId; // private String proId;
......
...@@ -122,17 +122,23 @@ public class BusDeviceTpServiceImpl implements BusDeviceTpService { ...@@ -122,17 +122,23 @@ public class BusDeviceTpServiceImpl implements BusDeviceTpService {
int line = 1; int line = 1;
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
String suffixName = fileName.substring(fileName.lastIndexOf(".")); String suffixName = fileName.substring(fileName.lastIndexOf("."));
// 查找之前的image文件
BusDeviceTp busDeviceTp1 = new BusDeviceTp();
busDeviceTp1.setDevTpId(devTpId);
BusDeviceTp busDeviceTp2 = busDeviceTpRepository.selectOne(busDeviceTp1);
String devTpImg = busDeviceTp2.getDevTpImg();
//文件路径 //文件路径
String savePath = filepath + devTpId + suffixName; String uuid = UUID.randomUUID().toString();
File saveFile = new File(savePath); String savePath = filepath + uuid + suffixName;
File saveFile = new File(filepath + devTpImg);
if(saveFile.exists()){ if(saveFile.exists()){
saveFile.delete(); saveFile.delete();
} }
try{ try{
FileUtils.copyInputStreamToFile(file.getInputStream(), saveFile); FileUtils.copyInputStreamToFile(file.getInputStream(), new File(savePath));
BusDeviceTp busDeviceTp = new BusDeviceTp(); BusDeviceTp busDeviceTp = new BusDeviceTp();
busDeviceTp.setDevTpId(devTpId); busDeviceTp.setDevTpId(devTpId);
busDeviceTp.setDevTpImg(devTpId + suffixName); busDeviceTp.setDevTpImg(uuid + suffixName);
merge(busDeviceTp); merge(busDeviceTp);
line = 1; line = 1;
}catch(Exception e){ }catch(Exception e){
......
...@@ -113,7 +113,7 @@ public class BusProjectServiceImpl implements BusProjectService { ...@@ -113,7 +113,7 @@ public class BusProjectServiceImpl implements BusProjectService {
//新增项目成功后,添加项目能耗标准、24小时的能耗价格 //新增项目成功后,添加项目能耗标准、24小时的能耗价格
if(line>0){ if(line>0){
// redis添加新的内容 // redis添加新的内容
rcRedisService.set("proId-" + busProject.getProId(), "0"); // rcRedisService.setList("proIds" + busProject.getProId(), "0");
// refer表新增4条记录,用于前台展示的参数,不可删除 // refer表新增4条记录,用于前台展示的参数,不可删除
this.saveRefer(busProject.getProId()); this.saveRefer(busProject.getProId());
//能耗标准 //能耗标准
...@@ -215,7 +215,7 @@ public class BusProjectServiceImpl implements BusProjectService { ...@@ -215,7 +215,7 @@ public class BusProjectServiceImpl implements BusProjectService {
criteria.andEqualTo("proId", busProject.getProId()); criteria.andEqualTo("proId", busProject.getProId());
line = projectRepository.deleteByExample(example); line = projectRepository.deleteByExample(example);
// 删除redis中对应的proId // 删除redis中对应的proId
rcRedisService.remove("proId-" + busProject.getProId()); rcRedisService.removeList("proIds", busProject.getProId());
}else{ }else{
message = "ID为空,删除失败"; message = "ID为空,删除失败";
} }
...@@ -288,9 +288,14 @@ public class BusProjectServiceImpl implements BusProjectService { ...@@ -288,9 +288,14 @@ public class BusProjectServiceImpl implements BusProjectService {
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("proId", proId); criteria.andEqualTo("proId", proId);
int result = projectRepository.updateByExampleSelective(busProject, example); int result = projectRepository.updateByExampleSelective(busProject, example);
if (result > 0) if (result > 0) {
// 更新redis // 更新redis
rcRedisService.set("proId-" + proId, String.valueOf(receiveData)); if (receiveData == 0)
rcRedisService.removeList("proIds", proId);
else
rcRedisService.setList("proIds", proId);
}
// rcRedisService.set("proId-" + proId, String.valueOf(receiveData));
return result; return result;
} }
......
...@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -29,6 +30,7 @@ public class BusSavingServiceImpl implements BusSavingService { ...@@ -29,6 +30,7 @@ public class BusSavingServiceImpl implements BusSavingService {
public Integer save(BusSaving busSaving) { public Integer save(BusSaving busSaving) {
String id = UUID.randomUUID().toString().replaceAll("-", ""); String id = UUID.randomUUID().toString().replaceAll("-", "");
busSaving.setId(id); busSaving.setId(id);
busSaving.setCreateDate(new Date());
return busSavingRepository.insertSelective(busSaving); return busSavingRepository.insertSelective(busSaving);
} }
...@@ -53,7 +55,7 @@ public class BusSavingServiceImpl implements BusSavingService { ...@@ -53,7 +55,7 @@ public class BusSavingServiceImpl implements BusSavingService {
@Override @Override
public List<BusSaving> findAllByPagination(PageUtil<BusSaving> paginationUtility) { public List<BusSaving> findAllByPagination(PageUtil<BusSaving> paginationUtility) {
Example example = new Example(BusSaving.class); Example example = new Example(BusSaving.class);
example.orderBy("TM desc"); example.setOrderByClause("CREATE_DATE desc");
return busSavingRepository.selectByExample(example); return busSavingRepository.selectByExample(example);
// return busSavingRepository.selectAll(); // return busSavingRepository.selectAll();
} }
......
...@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
...@@ -39,6 +40,7 @@ public class BusTeamServiceImpl implements BusTeamService { ...@@ -39,6 +40,7 @@ public class BusTeamServiceImpl implements BusTeamService {
@Override @Override
public PersistModel save(BusTeam busTeam){ public PersistModel save(BusTeam busTeam){
int line = 0; int line = 0;
busTeam.setCreateDate(new Date());
// 验重 // 验重
Integer repeat = this.repeat(busTeam); Integer repeat = this.repeat(busTeam);
if (repeat > 0) if (repeat > 0)
......
...@@ -390,7 +390,7 @@ public class OverViewServiceImpl implements OverViewService { ...@@ -390,7 +390,7 @@ public class OverViewServiceImpl implements OverViewService {
if (total.compareTo(new BigDecimal(0)) == 0) if (total.compareTo(new BigDecimal(0)) == 0)
energyCountMVo.setPercent(total + "%"); energyCountMVo.setPercent(total + "%");
else else
energyCountMVo.setPercent(energyCountMVo.getEnergy().divide(total, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)) + "%"); energyCountMVo.setPercent(energyCountMVo.getEnergy().multiply(new BigDecimal(100)).divide(total, 2, BigDecimal.ROUND_HALF_UP) + "%");
} }
} }
return list; return list;
......
...@@ -175,7 +175,9 @@ public class SystemServiceImpl implements SystemService { ...@@ -175,7 +175,9 @@ public class SystemServiceImpl implements SystemService {
@Override @Override
public String selectDataByCache(String proId) { public String selectDataByCache(String proId) {
return redisServiceImpl.get(proId); String newData = redisServiceImpl.get(proId);
String oldData = redisServiceImpl.get(proId + "-old");
return "{\"newData\":" + newData + ",\"oldData\":" + oldData + "}";
} }
@Override @Override
...@@ -188,8 +190,8 @@ public class SystemServiceImpl implements SystemService { ...@@ -188,8 +190,8 @@ public class SystemServiceImpl implements SystemService {
devNum = devNum.split(proId + "_")[1]; devNum = devNum.split(proId + "_")[1];
} }
paramStatus.setDevNum(devNum); paramStatus.setDevNum(devNum);
// 默认都设为关闭状态 // 默认都设为掉线状态
paramStatus.setStatus(0); paramStatus.setStatus(2);
}); });
return list; return list;
} }
...@@ -204,8 +206,8 @@ public class SystemServiceImpl implements SystemService { ...@@ -204,8 +206,8 @@ public class SystemServiceImpl implements SystemService {
} }
if (!proId.equals("")) { if (!proId.equals("")) {
// 根据proId得到redis中的数据 // 根据proId得到redis中的数据
String newData = this.selectDataByCache(proId); String newData = redisServiceImpl.get(proId);
String oldData = this.selectDataByCache(proId + "-old"); String oldData = redisServiceImpl.get(proId + "-old");
// 循环list,根据param查询数据,新的-旧的 > 0.003:认为是开启状态 // 循环list,根据param查询数据,新的-旧的 > 0.003:认为是开启状态
JSONObject newJson = JSON.parseObject(newData); JSONObject newJson = JSON.parseObject(newData);
JSONObject oldJson = JSON.parseObject(oldData); JSONObject oldJson = JSON.parseObject(oldData);
...@@ -253,7 +255,7 @@ public class SystemServiceImpl implements SystemService { ...@@ -253,7 +255,7 @@ public class SystemServiceImpl implements SystemService {
paramStatus.setStatus(1); paramStatus.setStatus(1);
} }
} else { } else {
paramStatus.setStatus(0); paramStatus.setStatus(2);
} }
} }
} }
......
...@@ -345,7 +345,7 @@ public class UserServiceImpl implements UserService { ...@@ -345,7 +345,7 @@ public class UserServiceImpl implements UserService {
public int resetPassWord(String userId, String needUserId) { public int resetPassWord(String userId, String needUserId) {
int flag = 0; int flag = 0;
SysUser sysUser = userRepository.selectByPrimaryKey(userId); SysUser sysUser = userRepository.selectByPrimaryKey(userId);
if (UserTpConstant.TP_SUPER_ADMIN.equals(sysUser.getUserTp())){ if (UserTpConstant.TP_SUPER_ADMIN.equals(sysUser.getUserTp()) || UserTpConstant.TP_ADMIN.equals(sysUser.getUserTp())){
SysUser needSysUser = userRepository.selectByPrimaryKey(needUserId); SysUser needSysUser = userRepository.selectByPrimaryKey(needUserId);
needSysUser.setUserPwd(passwordEncoder.encode(UserPassWordConstant.PASSWORD)); needSysUser.setUserPwd(passwordEncoder.encode(UserPassWordConstant.PASSWORD));
userRepository.updateByPrimaryKeySelective(needSysUser); userRepository.updateByPrimaryKeySelective(needSysUser);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<result column="TEAM_TYPE" jdbcType="VARCHAR" property="teamType"/> <result column="TEAM_TYPE" jdbcType="VARCHAR" property="teamType"/>
<result column="area" jdbcType="DECIMAL" property="area"/> <result column="area" jdbcType="DECIMAL" property="area"/>
<result column="teamNumber" jdbcType="INTEGER" property="teamNumber"/> <result column="teamNumber" jdbcType="INTEGER" property="teamNumber"/>
<result column="createDate" jdbcType="TIMESTAMP" property="CREATE_DATE"/>
</resultMap> </resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>--> <!--<cache type="${corePackag!}.util.RedisCache"/>-->
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<result column="QUALIFICATION" jdbcType="VARCHAR" property="qualification"/> <result column="QUALIFICATION" jdbcType="VARCHAR" property="qualification"/>
<result column="TM" jdbcType="VARCHAR" property="tm"/> <result column="TM" jdbcType="VARCHAR" property="tm"/>
<result column="PERFORMANCE" jdbcType="VARCHAR" property="performance"/> <result column="PERFORMANCE" jdbcType="VARCHAR" property="performance"/>
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate"/>
<!--<result column="TYPE" jdbcType="VARCHAR" property="type"/>--> <!--<result column="TYPE" jdbcType="VARCHAR" property="type"/>-->
<!--<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/>--> <!--<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/>-->
</resultMap> </resultMap>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment