浏览代码

Merge branch 'master' of http://47.100.37.243:10080/ZHOU/yunsu

sunyadv 5 年之前
父节点
当前提交
4f184906bb

+ 16 - 16
cloud-model/src/main/java/com/hssx/cloudmodel/entity/InjectionMolding.java

@@ -12,7 +12,7 @@ import java.io.Serializable;
  * </p>
  *
  * @author 吴涛涛
- * @since 2019-10-29
+ * @since 2019-11-04
  */
 public class InjectionMolding extends Model<InjectionMolding> {
 
@@ -52,31 +52,31 @@ public class InjectionMolding extends Model<InjectionMolding> {
      * 成品重量(单位:G)
      */
     @TableField("all_weight")
-    private Double allWeight;
+    private String allWeight;
 
     /**
      * 料头重量(单位:G)
      */
     @TableField("head_weight")
-    private Double headWeight;
+    private String headWeight;
 
     /**
      * 最大射胶量(单位:G)
      */
     @TableField("min_shot_weight")
-    private Integer minShotWeight;
+    private String minShotWeight;
 
     /**
      * 最小射胶量(单位:G)
      */
     @TableField("max_shot_weight")
-    private Integer maxShotWeight;
+    private String maxShotWeight;
 
     /**
      * 成型周期
      */
     @TableField("cycle")
-    private Integer cycle;
+    private String cycle;
 
     /**
      * 公模(动模)模温
@@ -143,43 +143,43 @@ public class InjectionMolding extends Model<InjectionMolding> {
         this.machineTonnage = machineTonnage;
     }
 
-    public Double getAllWeight() {
+    public String getAllWeight() {
         return allWeight;
     }
 
-    public void setAllWeight(Double allWeight) {
+    public void setAllWeight(String allWeight) {
         this.allWeight = allWeight;
     }
 
-    public Double getHeadWeight() {
+    public String getHeadWeight() {
         return headWeight;
     }
 
-    public void setHeadWeight(Double headWeight) {
+    public void setHeadWeight(String headWeight) {
         this.headWeight = headWeight;
     }
 
-    public Integer getMinShotWeight() {
+    public String getMinShotWeight() {
         return minShotWeight;
     }
 
-    public void setMinShotWeight(Integer minShotWeight) {
+    public void setMinShotWeight(String minShotWeight) {
         this.minShotWeight = minShotWeight;
     }
 
-    public Integer getMaxShotWeight() {
+    public String getMaxShotWeight() {
         return maxShotWeight;
     }
 
-    public void setMaxShotWeight(Integer maxShotWeight) {
+    public void setMaxShotWeight(String maxShotWeight) {
         this.maxShotWeight = maxShotWeight;
     }
 
-    public Integer getCycle() {
+    public String getCycle() {
         return cycle;
     }
 
-    public void setCycle(Integer cycle) {
+    public void setCycle(String cycle) {
         this.cycle = cycle;
     }
 

+ 2 - 2
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldHistoryServiceImpl.java

@@ -140,7 +140,7 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
         InjectionMolding molding = injectionMoldingMapper.selectOne(new QueryWrapper<InjectionMolding>().eq("mould_id", mould.getId()));
         Integer cycle = 0;
         if(molding != null){
-             cycle = (null == molding.getCycle())?40000:molding.getCycle();
+             cycle = (null == molding.getCycle())?40000:Integer.parseInt(molding.getCycle());
         }else{
              cycle = 40000;
         }
@@ -150,8 +150,8 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
         List<MouldHistoryVO> list = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(time,equipmentNo,maxCycle,minCycle);
         Integer count = 0;
         Map<String, List<MouldHistoryVO>> mapList = list.stream().collect(Collectors.groupingBy(MouldHistoryVO::getTime));
-        MouldHistoryTimeVO vo = new MouldHistoryTimeVO();
         for(Map.Entry<String, List<MouldHistoryVO>> entry:mapList.entrySet()){
+            MouldHistoryTimeVO vo = new MouldHistoryTimeVO();
             vo.setMinCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
             vo.setMaxCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt());
             vo.setAvgCycle((int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/util/CodeGenerator.java

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("change_ip_command");
+        strategy.setInclude("injection_molding");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 1 - 1
cloud-model/src/main/resources/mapper/MouldMapper.xml

@@ -177,7 +177,7 @@
                 AND tbm.equipment_id is not null
                 AND tbm.state != 4
                 AND tbm.project_id is not null
-                tbp.is_delete = 0
+                AND tbp.is_delete = 0
             </if>
             AND tbm.project_id in
             <foreach item="item" index="index" collection="list"

+ 40 - 23
cloud-socket/src/com/js/kbt/socket/UserHandler.java

@@ -96,7 +96,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 		// 校准时间
 		timeCalibration();
 		//验证是否需要切换ip
-		sendChangeIp();
+//		sendChangeIp();
 		System.out.println("收到===" + arg1 + "\n");
 		String equipmentNo = processMsg(arg1);
 		// 以下是配置下行数据
@@ -234,39 +234,41 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 				// 开模时间
 				Date openTime = parseDate(input, start, pos, 6);
 				time.setOpenTime(openTime);
+				logger.info("第"+(pos+1)+"包");
 				if (pos == 0) {
 					time.setTimeCost(0);
 				} else {
+					logger.info("本包开合时间戳--" + openTime.getTime());
 					logger.info("本次开合周期--" + (openTime.getTime() - aHeadOpenTimeLongVal));
 					time.setTimeCost((int) (openTime.getTime() - aHeadOpenTimeLongVal));
 				}
 				mouldHistoryTimeMapper.insertSelective(time);
 				// 处理最后一包周期逻辑
-				if(pos==periodCnt-1){
+				aHeadOpenTimeLongVal = openTime.getTime();
+//				if(pos==periodCnt-1){
 					handleMouldCycleRuntimeLogic(openTime, item);
-				}
+//				}
 				logger.info("mouldHistoryTime数据添加完毕");
-				aHeadOpenTimeLongVal = openTime.getTime();
 				logger.info("上一包数据的开合时间戳--" + aHeadOpenTimeLongVal);
 			}
 		} else {
 			logger.info("本次开合模次数==0");
 		}
 		// 统计该模盒的平均开合周期
-		MouldHistoryExample exp = new MouldHistoryExample();
-		exp.setOrderByClause("id");
-		exp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andRunCntEqualTo(item.getRunCnt());
+//		MouldHistoryExample exp = new MouldHistoryExample();
+//		exp.setOrderByClause("id");
+//		exp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andRunCntEqualTo(item.getRunCnt());
 		// List<MouldHistoryTime> list =
 		// mouldHistoryTimeMapper.selectByEquipmentNoAndThanZero(item.getEquipmentNo());
-		List<MouldHistory> list = mouldHistoryMapper.selectByExample(exp);
-		List<Long> historyIds = new ArrayList<>();
-		historyIds.add(-1L);
-		for (MouldHistory mouldHistory : list) {
-			historyIds.add(mouldHistory.getId());
-		}
+//		List<MouldHistory> list = mouldHistoryMapper.selectByExample(exp);
+//		List<Long> historyIds = new ArrayList<>();
+//		historyIds.add(-1L);
+//		for (MouldHistory mouldHistory : list) {
+//			historyIds.add(mouldHistory.getId());
+//		}
 		MouldHistoryTimeExample mtExp = new MouldHistoryTimeExample();
 		mtExp.setOrderByClause("seq");
-		mtExp.createCriteria().andHistoryIdIn(historyIds);
+		mtExp.createCriteria().andHistoryIdEqualTo(item.getId()).andTimeCostGreaterThan(0);
 		List<MouldHistoryTime> historyList = mouldHistoryTimeMapper.selectByExample(mtExp);
 		int avgTime = 0;
 		int totalTime = 0;
@@ -283,12 +285,12 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 		// }
 		// } else {
 		if (historyList.size() > 1) {
-			for (int j = 0; j < historyList.size() - 1; j++) {
-				totalTime += (historyList.get(j + 1).getOpenTime().getTime()
-						- historyList.get(j).getOpenTime().getTime());
+			for (MouldHistoryTime mouldHistoryTime : historyList) {
+				logger.info("totalTime" + totalTime);
+				totalTime += mouldHistoryTime.getTimeCost();
 			}
 			logger.info("totalTime" + totalTime);
-			avgTime = (int) (totalTime / (historyList.size() - 1));
+			avgTime = (int) (totalTime / historyList.size());
 		}
 		// }
 		logger.info("avgTime-->" + avgTime);
@@ -350,8 +352,11 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 			}
 			if (count > 0) {
 				TbMouldEquipment me = tbMouldEquipmentMapper.selectByExample(meqExp).get(0);
-				me.setIsUse(packet.getIsUse());
-				tbMouldEquipmentMapper.updateByPrimaryKeySelective(me);
+				TbMouldEquipment tme = new TbMouldEquipment();
+				tme.setId(me.getId());
+				tme.setIsUse(packet.getIsUse());
+				tbMouldEquipmentMapper.updateByPrimaryKeySelective(tme);
+				logger.info("将启用中的云模盒改为启用成功==>" + me.getEquipmentNo());
 			}
 			//下发完删除数据
 			mouldDownPacketMapper.deleteByPrimaryKey(packet.getId());
@@ -487,13 +492,18 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 	private void handleMouldCycleRuntimeLogic(Date openTime, MouldHistory item) throws ParseException {
 		System.out.println("开始handleMouldCycleRuntimeLogic逻辑开合时间"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(openTime));
 		MouldCycleRuntime mcr = new MouldCycleRuntime();
-		Integer hours = openTime.getHours();
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		mcr.setDateStr(sdf.format(openTime));
+		Integer hours = openTime.getHours();
 		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:");
 		int housTime = openTime.getHours() - 1;
 		openTime.setHours(housTime);
 		String lastOpenTime = sdf1.format(openTime);
-		Date lastOpenTimeDate = sdf1.parse(lastOpenTime + "59:59");
+		Date lastOpenTimeDate = sdf1.parse(lastOpenTime);
+		//此处直接拼接字符串“59:59”会导致分和秒丢失,所以才去set的方法设置时分秒
+		lastOpenTimeDate.setMinutes(59);
+		lastOpenTimeDate.setSeconds(59);
+		logger.info("当前开合时间减一小时的时间条件:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(lastOpenTimeDate));
 		MouldHistoryTimeExample mExp = new MouldHistoryTimeExample();
 		mExp.setOrderByClause("open_time desc limit 1");
 		mExp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo())
@@ -503,7 +513,6 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 		if (list.size() > 0) {
 			MouldHistory mouldHistory = mouldHistoryMapper.selectByPrimaryKey(list.get(0).getHistoryId());
 			logger.info("本次运行次数: " + item.getRunCnt()+" 上一小时的运行次数:"+mouldHistory.getRunCnt()+" 上一小时的historyId:"+mouldHistory.getId());
-			mcr.setDateStr(sdf.format(openTime));
 			mcr.setEquipmentNo(item.getEquipmentNo());
 			mcr.setRuntime(item.getRunCnt() - mouldHistory.getRunCnt());
 			if (hours == 0) {
@@ -706,6 +715,14 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 	public static void main(String[] args) throws ParseException {
 		// UserHandler h = new UserHandler();
 		// h.timeCalibration();
+		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:");
+		Date date = new Date();
+		String lastOpenTime = sdf1.format(date);
+		System.out.println(lastOpenTime);
+		Date lastOpenTimeDate = sdf1.parse(lastOpenTime);
+		lastOpenTimeDate.setMinutes(59);
+		lastOpenTimeDate.setSeconds(59);
+		System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(lastOpenTimeDate));
 		String a = "00:25:32";
 		SimpleDateFormat s = new SimpleDateFormat("HH:mm:ss");
 		Date d = new Date();

+ 1 - 1
target/classes/main/resources/mapper/MouldMapper.xml

@@ -177,7 +177,7 @@
                 AND tbm.equipment_id is not null
                 AND tbm.state != 4
                 AND tbm.project_id is not null
-                tbp.is_delete = 0
+                AND tbp.is_delete = 0
             </if>
             AND tbm.project_id in
             <foreach item="item" index="index" collection="list"