|
@@ -14,6 +14,7 @@ import org.apache.log4j.Logger;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
@@ -23,12 +24,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.js.kbt.mapper.MouldDownPacketMapper;
|
|
import com.js.kbt.mapper.MouldDownPacketMapper;
|
|
import com.js.kbt.mapper.TbMouldEquipmentMapper;
|
|
import com.js.kbt.mapper.TbMouldEquipmentMapper;
|
|
import com.js.kbt.mapper.TbUserMapper;
|
|
import com.js.kbt.mapper.TbUserMapper;
|
|
|
|
+import com.js.kbt.mapper.TimeCalibrationRecordMapper;
|
|
import com.js.kbt.model.MouldDownPacket;
|
|
import com.js.kbt.model.MouldDownPacket;
|
|
import com.js.kbt.model.MouldDownPacketExample;
|
|
import com.js.kbt.model.MouldDownPacketExample;
|
|
import com.js.kbt.model.TbMouldEquipment;
|
|
import com.js.kbt.model.TbMouldEquipment;
|
|
import com.js.kbt.model.TbMouldEquipmentExample;
|
|
import com.js.kbt.model.TbMouldEquipmentExample;
|
|
import com.js.kbt.model.TbUser;
|
|
import com.js.kbt.model.TbUser;
|
|
import com.js.kbt.model.TbUserExample;
|
|
import com.js.kbt.model.TbUserExample;
|
|
|
|
+import com.js.kbt.socket.UserHandler;
|
|
import com.js.kbt.util.CRC16Util;
|
|
import com.js.kbt.util.CRC16Util;
|
|
import com.js.kbt.util.MD5Util;
|
|
import com.js.kbt.util.MD5Util;
|
|
import com.js.kbt.util.ProjectConst;
|
|
import com.js.kbt.util.ProjectConst;
|
|
@@ -51,13 +54,11 @@ public class WeiXinUserInfoController {
|
|
private MouldDownPacketMapper mouldDownPacketMapper;
|
|
private MouldDownPacketMapper mouldDownPacketMapper;
|
|
@Resource
|
|
@Resource
|
|
private TbMouldEquipmentMapper tbMouldEquipmentMapper;
|
|
private TbMouldEquipmentMapper tbMouldEquipmentMapper;
|
|
-
|
|
|
|
-// @Autowired
|
|
|
|
-// private WeiXinPlatformService weiXinPlatformService;
|
|
|
|
|
|
+
|
|
Logger log = Logger.getLogger(WeiXinUserInfoController.class);
|
|
Logger log = Logger.getLogger(WeiXinUserInfoController.class);
|
|
-
|
|
|
|
- @ResponseBody
|
|
|
|
|
|
+
|
|
@RequestMapping("/checkAccountStatus")
|
|
@RequestMapping("/checkAccountStatus")
|
|
|
|
+ @ResponseBody
|
|
public void checkAccountStatus(@RequestParam String openid, HttpServletResponse response) throws IOException{
|
|
public void checkAccountStatus(@RequestParam String openid, HttpServletResponse response) throws IOException{
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
TbUserExample example = new TbUserExample();
|
|
TbUserExample example = new TbUserExample();
|
|
@@ -256,100 +257,84 @@ public class WeiXinUserInfoController {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 云平台下行配置数据包接口
|
|
|
|
- * lowPowerLimit 低电量报警限值:(1 字节,十六进制)如:1e=31
|
|
|
|
- * hotAlarmLimit 热报警限值:(1 字节,十六进制)如:50=80
|
|
|
|
- * isUse:0-停止,1-启动
|
|
|
|
- * equipmentNo 设备编号(可能是多个或者一个)多个以“,”隔开传 如:"123456"(单个),"123456,456878,123589"(多个)
|
|
|
|
- */
|
|
|
|
- @RequestMapping("/setPacket")
|
|
|
|
- public void bindAccount(HttpServletResponse response,Integer isUse,Integer lowPowerLimit,Integer hotAlarmLimit,String equipmentNo) {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- //16进制的转化
|
|
|
|
- String lowPowerLimitStr = Integer.toHexString(lowPowerLimit);
|
|
|
|
- String hotAlarmLimitStr = Integer.toHexString(hotAlarmLimit);
|
|
|
|
- String isUseStr = "0"+Integer.toHexString(isUse);
|
|
|
|
- System.out.println("lowPowerLimit"+lowPowerLimit+"hotAlarmLimit"+hotAlarmLimit);
|
|
|
|
- String setPacketMessage = "";
|
|
|
|
- MouldDownPacket mouldDownPacket = new MouldDownPacket();
|
|
|
|
- MouldDownPacketExample exp = new MouldDownPacketExample();
|
|
|
|
- TbMouldEquipmentExample tExp = new TbMouldEquipmentExample();
|
|
|
|
- String[] split = equipmentNo.split(",");
|
|
|
|
- for (String string : split) {
|
|
|
|
- System.out.println("进来了"+string);
|
|
|
|
- exp.createCriteria().andEquipmentNoEqualTo(string);
|
|
|
|
- tExp.createCriteria().andEquipmentNoEqualTo(string);
|
|
|
|
- TbMouldEquipment equipment = tbMouldEquipmentMapper.selectByExample(tExp).get(0);
|
|
|
|
- equipment.setIsUse(isUse);
|
|
|
|
- equipment.setHillNumber(lowPowerLimit+"%");
|
|
|
|
- equipment.setTemperature(hotAlarmLimit);
|
|
|
|
- //更新云模盒的报警温度和电量
|
|
|
|
- tbMouldEquipmentMapper.updateByPrimaryKey(equipment);
|
|
|
|
- List<MouldDownPacket> list = mouldDownPacketMapper.selectByExample(exp);
|
|
|
|
- if(list.size()>0){
|
|
|
|
- mouldDownPacket = list.get(0);
|
|
|
|
- setPacketMessage = downProcessMsg(lowPowerLimitStr,hotAlarmLimitStr,isUseStr);
|
|
|
|
- mouldDownPacket.setPacketStr(setPacketMessage);
|
|
|
|
- mouldDownPacket.setIsUse(isUse);
|
|
|
|
- mouldDownPacketMapper.updateByPrimaryKey(mouldDownPacket);
|
|
|
|
- }else{
|
|
|
|
- setPacketMessage = downProcessMsg(lowPowerLimitStr,hotAlarmLimitStr,isUseStr);
|
|
|
|
- mouldDownPacket.setEquipmentNo(equipmentNo);
|
|
|
|
- mouldDownPacket.setPacketStr(setPacketMessage);
|
|
|
|
- mouldDownPacket.setIsUse(isUse);
|
|
|
|
- mouldDownPacketMapper.insertSelective(mouldDownPacket);
|
|
|
|
- }
|
|
|
|
- exp.clear();
|
|
|
|
- tExp.clear();
|
|
|
|
- }
|
|
|
|
- msg.data = setPacketMessage;
|
|
|
|
- response.setContentType("application/json");
|
|
|
|
- response.setCharacterEncoding("UTF-8");
|
|
|
|
- try {
|
|
|
|
- response.getWriter().println(msg.toJSONStr());
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+// /**
|
|
|
|
+// * 云平台下行配置数据包接口
|
|
|
|
+// * lowPowerLimit 低电量报警限值:(1 字节,十六进制)如:1e=31
|
|
|
|
+// * hotAlarmLimit 热报警限值:(1 字节,十六进制)如:50=80
|
|
|
|
+// * isUse:0-停止,1-启动
|
|
|
|
+// * equipmentNo 设备编号(可能是多个或者一个)多个以“,”隔开传 如:"123456"(单个),"123456,456878,123589"(多个)
|
|
|
|
+// */
|
|
|
|
+// @RequestMapping(value = "/userInfo", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
|
+// public void bindAccount(HttpServletResponse response,Integer isUse,Integer lowPowerLimit,Integer hotAlarmLimit,String equipmentNo) {
|
|
|
|
+// HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+// //16进制的转化
|
|
|
|
+// String lowPowerLimitStr = Integer.toHexString(lowPowerLimit);
|
|
|
|
+// String hotAlarmLimitStr = Integer.toHexString(hotAlarmLimit);
|
|
|
|
+// String isUseStr = "0"+Integer.toHexString(isUse);
|
|
|
|
+// System.out.println("lowPowerLimit"+lowPowerLimit+"hotAlarmLimit"+hotAlarmLimit);
|
|
|
|
+// String setPacketMessage = "";
|
|
|
|
+// MouldDownPacket mouldDownPacket = new MouldDownPacket();
|
|
|
|
+// MouldDownPacketExample exp = new MouldDownPacketExample();
|
|
|
|
+// TbMouldEquipmentExample tExp = new TbMouldEquipmentExample();
|
|
|
|
+// String[] split = equipmentNo.split(",");
|
|
|
|
+// for (String string : split) {
|
|
|
|
+// System.out.println("进来了"+string);
|
|
|
|
+// exp.createCriteria().andEquipmentNoEqualTo(string);
|
|
|
|
+// tExp.createCriteria().andEquipmentNoEqualTo(string);
|
|
|
|
+// TbMouldEquipment equipment = tbMouldEquipmentMapper.selectByExample(tExp).get(0);
|
|
|
|
+// equipment.setIsUse(isUse);
|
|
|
|
+// equipment.setHillNumber(lowPowerLimit+"");
|
|
|
|
+// equipment.setTemperature(hotAlarmLimit);
|
|
|
|
+// //更新云模盒的报警温度和电量
|
|
|
|
+// tbMouldEquipmentMapper.updateByPrimaryKey(equipment);
|
|
|
|
+// List<MouldDownPacket> list = mouldDownPacketMapper.selectByExample(exp);
|
|
|
|
+// if(list.size()>0){
|
|
|
|
+// mouldDownPacket = list.get(0);
|
|
|
|
+// setPacketMessage = downProcessMsg(lowPowerLimitStr,hotAlarmLimitStr,isUseStr);
|
|
|
|
+// mouldDownPacket.setPacketStr(setPacketMessage);
|
|
|
|
+// mouldDownPacket.setIsUse(isUse);
|
|
|
|
+// mouldDownPacketMapper.updateByPrimaryKey(mouldDownPacket);
|
|
|
|
+// }else{
|
|
|
|
+// setPacketMessage = downProcessMsg(lowPowerLimitStr,hotAlarmLimitStr,isUseStr);
|
|
|
|
+// mouldDownPacket.setEquipmentNo(equipmentNo);
|
|
|
|
+// mouldDownPacket.setPacketStr(setPacketMessage);
|
|
|
|
+// mouldDownPacket.setIsUse(isUse);
|
|
|
|
+// mouldDownPacketMapper.insertSelective(mouldDownPacket);
|
|
|
|
+// }
|
|
|
|
+// exp.clear();
|
|
|
|
+// tExp.clear();
|
|
|
|
+// }
|
|
|
|
+// msg.data = setPacketMessage;
|
|
|
|
+// response.setContentType("application/json");
|
|
|
|
+// response.setCharacterEncoding("UTF-8");
|
|
|
|
+// try {
|
|
|
|
+// response.getWriter().println(msg.toJSONStr());
|
|
|
|
+// } catch (IOException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
|
|
- // 下行配置数据包
|
|
|
|
- private String downProcessMsg(String lowPowerLimit,String hotAlarmLimit,String isUse) {
|
|
|
|
- //"23"不解析
|
|
|
|
- if("23".equals(lowPowerLimit)){
|
|
|
|
- lowPowerLimit="24";
|
|
|
|
- }
|
|
|
|
- if("23".equals(hotAlarmLimit)){
|
|
|
|
- hotAlarmLimit="24";
|
|
|
|
- }
|
|
|
|
- if("23".equals(isUse)){
|
|
|
|
- isUse="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);
|
|
|
|
- return lastPart;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 低位在前的16进制解析
|
|
|
|
- *
|
|
|
|
- * @param rHex
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public static int reverseParseHex(String rHex) {
|
|
|
|
- int size = rHex.length() / 2;
|
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
|
- for (int i = 0; i < size; i++) {
|
|
|
|
- sb.append(rHex.substring((size - i - 1) * 2, (size - i) * 2));
|
|
|
|
- }
|
|
|
|
- String str = sb.toString();
|
|
|
|
- System.out.println("str"+str);
|
|
|
|
- return Integer.parseInt(str, 16);
|
|
|
|
- }
|
|
|
|
|
|
+// // 下行配置数据包
|
|
|
|
+// private String downProcessMsg(String lowPowerLimit,String hotAlarmLimit,String isUse) {
|
|
|
|
+// //"23"不解析
|
|
|
|
+// if("23".equals(lowPowerLimit)){
|
|
|
|
+// lowPowerLimit="24";
|
|
|
|
+// }
|
|
|
|
+// if("23".equals(hotAlarmLimit)){
|
|
|
|
+// hotAlarmLimit="24";
|
|
|
|
+// }
|
|
|
|
+// if("23".equals(isUse)){
|
|
|
|
+// isUse="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);
|
|
|
|
+// return lastPart;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
|
|
// public static byte[] strToByte(String data) {
|
|
// public static byte[] strToByte(String data) {
|
|
// data = data.replace(" ", "");
|
|
// data = data.replace(" ", "");
|