|
@@ -82,9 +82,9 @@ public class MouldEquipmentServiceImpl extends ServiceImpl<MouldEquipmentMapper,
|
|
//修改设备
|
|
//修改设备
|
|
MouldEquipment mouldEqu = mouldEquipmentMapper.selectById(mouldEquipment.getId());
|
|
MouldEquipment mouldEqu = mouldEquipmentMapper.selectById(mouldEquipment.getId());
|
|
MouldEquipment m = mouldEquipmentMapper.selectOne(new QueryWrapper<MouldEquipment>().eq("equipment_no", mouldEquipment.getEquipmentNo()));
|
|
MouldEquipment m = mouldEquipmentMapper.selectOne(new QueryWrapper<MouldEquipment>().eq("equipment_no", mouldEquipment.getEquipmentNo()));
|
|
- if (mouldEqu.getEquipmentNo().equals(mouldEquipment.getEquipmentNo()) || m==null) {
|
|
|
|
|
|
+ if (mouldEqu.getEquipmentNo().equals(mouldEquipment.getEquipmentNo()) || m == null) {
|
|
mouldEquipmentMapper.updateById(mouldEquipment);
|
|
mouldEquipmentMapper.updateById(mouldEquipment);
|
|
- } else{
|
|
|
|
|
|
+ } else {
|
|
msg.setError("当前设备编号已存在,请重新输入其他模具编号");
|
|
msg.setError("当前设备编号已存在,请重新输入其他模具编号");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -99,14 +99,23 @@ public class MouldEquipmentServiceImpl extends ServiceImpl<MouldEquipmentMapper,
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
//16进制的转化
|
|
//16进制的转化
|
|
String lowPowerLimitStr = Integer.toHexString(mouldEquipment.getLowPowerLimit());
|
|
String lowPowerLimitStr = Integer.toHexString(mouldEquipment.getLowPowerLimit());
|
|
- if(lowPowerLimitStr.length()==1){
|
|
|
|
- lowPowerLimitStr = "0"+lowPowerLimitStr;
|
|
|
|
|
|
+ if (lowPowerLimitStr.length() == 1) {
|
|
|
|
+ lowPowerLimitStr = "0" + lowPowerLimitStr;
|
|
|
|
+ }
|
|
|
|
+ String freeInterval = Integer.toHexString(mouldEquipment.getFreeInterval());
|
|
|
|
+ if (freeInterval.length() == 1) {
|
|
|
|
+ freeInterval = "0" + freeInterval;
|
|
}
|
|
}
|
|
|
|
+ String workInterval = Integer.toHexString(mouldEquipment.getWorkInterval());
|
|
|
|
+ if (workInterval.length() == 1) {
|
|
|
|
+ workInterval = "0" + workInterval;
|
|
|
|
+ }
|
|
|
|
+ String.format("%04d", mouldEquipment.getThreshold());
|
|
String hotAlarmLimitStr = Integer.toHexString(mouldEquipment.getHotAlarmLimit());
|
|
String hotAlarmLimitStr = Integer.toHexString(mouldEquipment.getHotAlarmLimit());
|
|
- if(hotAlarmLimitStr.length()==1){
|
|
|
|
- hotAlarmLimitStr = "0"+hotAlarmLimitStr;
|
|
|
|
|
|
+ if (hotAlarmLimitStr.length() == 1) {
|
|
|
|
+ hotAlarmLimitStr = "0" + hotAlarmLimitStr;
|
|
}
|
|
}
|
|
- String isUseStr = "0"+Integer.toHexString(mouldEquipment.getIsUse());
|
|
|
|
|
|
+ String isUseStr = "0" + Integer.toHexString(mouldEquipment.getIsUse());
|
|
//判断是不是超级管理员,是才可操作
|
|
//判断是不是超级管理员,是才可操作
|
|
if (user.getParentId() == 0) {
|
|
if (user.getParentId() == 0) {
|
|
//修改设备
|
|
//修改设备
|
|
@@ -116,32 +125,34 @@ public class MouldEquipmentServiceImpl extends ServiceImpl<MouldEquipmentMapper,
|
|
for (String str : split) {
|
|
for (String str : split) {
|
|
packet = mouldDownPacketMapper.selectOne(new QueryWrapper<MouldDownPacket>().eq("equipment_no", str));
|
|
packet = mouldDownPacketMapper.selectOne(new QueryWrapper<MouldDownPacket>().eq("equipment_no", str));
|
|
MouldEquipment equipment = new MouldEquipment();
|
|
MouldEquipment equipment = new MouldEquipment();
|
|
- if(1 == mouldEquipment.getIsUse()){
|
|
|
|
|
|
+ if (1 == mouldEquipment.getIsUse()) {
|
|
//启用中
|
|
//启用中
|
|
equipment.setIsUse(2);
|
|
equipment.setIsUse(2);
|
|
- }else if(0 == mouldEquipment.getIsUse()){
|
|
|
|
|
|
+ } else if (0 == mouldEquipment.getIsUse()) {
|
|
//停用中
|
|
//停用中
|
|
equipment.setIsUse(3);
|
|
equipment.setIsUse(3);
|
|
}
|
|
}
|
|
equipment.setEquipmentNo(mouldEquipment.getEquipmentNo());
|
|
equipment.setEquipmentNo(mouldEquipment.getEquipmentNo());
|
|
- equipment.setHillNumber(mouldEquipment.getLowPowerLimit()+"");
|
|
|
|
|
|
+ equipment.setHillNumber(mouldEquipment.getLowPowerLimit() + "");
|
|
equipment.setTemperature(mouldEquipment.getHotAlarmLimit());
|
|
equipment.setTemperature(mouldEquipment.getHotAlarmLimit());
|
|
- mouldEquipmentMapper.update(equipment,new QueryWrapper<MouldEquipment>().eq("equipment_no",str));
|
|
|
|
- if(packet != null){
|
|
|
|
|
|
+ mouldEquipmentMapper.update(equipment, new QueryWrapper<MouldEquipment>().eq("equipment_no", str));
|
|
|
|
+ if (packet != null) {
|
|
//已经存在更新下发数据包
|
|
//已经存在更新下发数据包
|
|
MouldDownPacket mouldDownPacket = new MouldDownPacket();
|
|
MouldDownPacket mouldDownPacket = new MouldDownPacket();
|
|
mouldDownPacket.setId(packet.getId());
|
|
mouldDownPacket.setId(packet.getId());
|
|
- setPacketMessage = downProcessMsg(lowPowerLimitStr,hotAlarmLimitStr,isUseStr); mouldDownPacket.setPacketStr(setPacketMessage);
|
|
|
|
|
|
+ setPacketMessage = downProcessMsg(lowPowerLimitStr, hotAlarmLimitStr, isUseStr, freeInterval, workInterval);
|
|
mouldDownPacket.setPacketStr(setPacketMessage);
|
|
mouldDownPacket.setPacketStr(setPacketMessage);
|
|
mouldDownPacket.setIsUse(mouldEquipment.getIsUse());
|
|
mouldDownPacket.setIsUse(mouldEquipment.getIsUse());
|
|
mouldDownPacket.setEquipmentNo(str);
|
|
mouldDownPacket.setEquipmentNo(str);
|
|
|
|
+ mouldDownPacket.setThreshold(workInterval);
|
|
mouldDownPacketMapper.updateById(mouldDownPacket);
|
|
mouldDownPacketMapper.updateById(mouldDownPacket);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
MouldDownPacket mouldDownPacket = new MouldDownPacket();
|
|
MouldDownPacket mouldDownPacket = new MouldDownPacket();
|
|
- setPacketMessage = downProcessMsg(lowPowerLimitStr,hotAlarmLimitStr,isUseStr); mouldDownPacket.setPacketStr(setPacketMessage);
|
|
|
|
|
|
+ setPacketMessage = downProcessMsg(lowPowerLimitStr, hotAlarmLimitStr, isUseStr, freeInterval, workInterval);
|
|
mouldDownPacket.setPacketStr(setPacketMessage);
|
|
mouldDownPacket.setPacketStr(setPacketMessage);
|
|
mouldDownPacket.setIsUse(mouldEquipment.getIsUse());
|
|
mouldDownPacket.setIsUse(mouldEquipment.getIsUse());
|
|
mouldDownPacket.setEquipmentNo(str);
|
|
mouldDownPacket.setEquipmentNo(str);
|
|
|
|
+ mouldDownPacket.setThreshold(workInterval);
|
|
mouldDownPacketMapper.insert(mouldDownPacket);
|
|
mouldDownPacketMapper.insert(mouldDownPacket);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -438,24 +449,36 @@ public class MouldEquipmentServiceImpl extends ServiceImpl<MouldEquipmentMapper,
|
|
}
|
|
}
|
|
|
|
|
|
// 下行配置数据包
|
|
// 下行配置数据包
|
|
- private String downProcessMsg(String lowPowerLimit,String hotAlarmLimit,String isUse) {
|
|
|
|
|
|
+ private String downProcessMsg(String lowPowerLimit, String hotAlarmLimit, String isUse, String freeInterval, String workInterval) {
|
|
//"23"不解析
|
|
//"23"不解析
|
|
- if("23".equals(lowPowerLimit)){
|
|
|
|
- lowPowerLimit="24";
|
|
|
|
|
|
+ if ("23".equals(lowPowerLimit)) {
|
|
|
|
+ lowPowerLimit = "24";
|
|
}
|
|
}
|
|
- if("23".equals(hotAlarmLimit)){
|
|
|
|
- hotAlarmLimit="24";
|
|
|
|
|
|
+ if ("23".equals(hotAlarmLimit)) {
|
|
|
|
+ hotAlarmLimit = "24";
|
|
}
|
|
}
|
|
- if("23".equals(isUse)){
|
|
|
|
- isUse="24";
|
|
|
|
|
|
+ if ("23".equals(freeInterval)) {
|
|
|
|
+ freeInterval = "24";
|
|
}
|
|
}
|
|
- String ret = "FA AF 00 07 "+isUse+" 1e 78 "+lowPowerLimit+" "+hotAlarmLimit+" 00 3C";
|
|
|
|
- ret = ret.replaceAll(" ", "");
|
|
|
|
- String crcCode = CRC16Util.getCRC(ret);
|
|
|
|
- System.out.println("ret===>"+ret);
|
|
|
|
- String lastPart = (ret + crcCode).replaceAll("23", "24").replaceAll(" ", "");
|
|
|
|
- System.out.println("lastPart===>"+lastPart);
|
|
|
|
|
|
+ if ("23".equals(workInterval)) {
|
|
|
|
+ workInterval = "24";
|
|
|
|
+ }
|
|
|
|
+ if ("23".equals(isUse)) {
|
|
|
|
+ isUse = "24";
|
|
|
|
+ }
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ //FAAF0007021e781e50003C
|
|
|
|
+ sb.append("FAAF0007");
|
|
|
|
+ sb.append(isUse);
|
|
|
|
+ sb.append(workInterval);
|
|
|
|
+ sb.append(freeInterval);
|
|
|
|
+ sb.append(lowPowerLimit);
|
|
|
|
+ sb.append(hotAlarmLimit);
|
|
|
|
+ sb.append("003C");
|
|
|
|
+ String crcCode = CRC16Util.getCRC(sb.toString());
|
|
|
|
+ System.out.println("ret===>" + sb.toString());
|
|
|
|
+ String lastPart = (sb.toString() + crcCode).replaceAll("23", "24").replaceAll(" ", "");
|
|
|
|
+ System.out.println("lastPart===>" + lastPart);
|
|
return lastPart;
|
|
return lastPart;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|