Commit 46c282bd authored by jichao's avatar jichao

改bug

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