Prechádzať zdrojové kódy

修改计算周期方法

5 rokov pred
rodič
commit
680e582be8

+ 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;
     }
 

+ 1 - 1
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;
         }

+ 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"

+ 18 - 16
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,17 +234,19 @@ 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){
+//				if(pos==periodCnt-1){
 					handleMouldCycleRuntimeLogic(openTime, item);
-				}
+//				}
 				logger.info("mouldHistoryTime数据添加完毕");
 				aHeadOpenTimeLongVal = openTime.getTime();
 				logger.info("上一包数据的开合时间戳--" + aHeadOpenTimeLongVal);
@@ -253,22 +255,21 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 			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).andTimeCostGreaterThan(0);
+		mtExp.createCriteria().andHistoryIdEqualTo(item.getId()).andTimeCostGreaterThan(0);
 		List<MouldHistoryTime> historyList = mouldHistoryTimeMapper.selectByExample(mtExp);
-		
 		int avgTime = 0;
 		int totalTime = 0;
 		// if (historyList.size() == 1) {
@@ -285,6 +286,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 		// } else {
 		if (historyList.size() > 1) {
 			for (MouldHistoryTime mouldHistoryTime : historyList) {
+				logger.info("totalTime" + totalTime);
 				totalTime += mouldHistoryTime.getTimeCost();
 			}
 			logger.info("totalTime" + totalTime);
@@ -490,8 +492,9 @@ 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);
@@ -506,7 +509,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) {

+ 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"