浏览代码

班次实绩

qiangxuan 2 月之前
父节点
当前提交
dc2671f9c8

+ 73 - 14
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/controller/BilletHotsendChangeShiftController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.billet.billetHotsendChangeShift.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -54,6 +55,7 @@ import org.springframework.web.servlet.ModelAndView;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
@@ -498,8 +500,8 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		// 根据铸机号、交班结束时间倒序并不为空,查询交班记录,
 		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, "5")
+				.isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
 				.orderByDesc(BilletHotsendChangeShift::getChangeShiftTime)
-				.ne(BilletHotsendChangeShift::getChangeShiftTime, null)
 				.last("limit 1");
 		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
 		if (billetHotsendChangeShift == null) {
@@ -519,8 +521,8 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		// 根据铸机号、交班结束时间倒序并不为空,查询交班记录,
 		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, "6")
+				.isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
 				.orderByDesc(BilletHotsendChangeShift::getChangeShiftTime)
-				.ne(BilletHotsendChangeShift::getChangeShiftTime, null)
 				.last("limit 1");
 		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
 		if (billetHotsendChangeShift == null) {
@@ -606,7 +608,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 			billetHotsendChangeShift.setShiftHotfeignWeight(totalWeightHotfeign);
 
 			// 班次定尺明细
-			billetHotsendChangeShift.setSizeDetailsList(lengthGroupList);
+			billetHotsendChangeShift.setSizeDetailsList(JSON.toJSONString(lengthGroupList));
 		}
 
 
@@ -658,8 +660,8 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		// 根据铸机号、交班结束时间倒序并不为空,查询交班记录,
 		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, "5")
+				.isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
 				.orderByDesc(BilletHotsendChangeShift::getChangeShiftTime)
-				.ne(BilletHotsendChangeShift::getChangeShiftTime, null)
 				.last("limit 1");
 		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
 		if (billetHotsendChangeShift == null) {
@@ -679,8 +681,8 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		// 根据铸机号、交班结束时间倒序并不为空,查询交班记录,
 		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, "6")
+				.isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
 				.orderByDesc(BilletHotsendChangeShift::getChangeShiftTime)
-				.ne(BilletHotsendChangeShift::getChangeShiftTime, null)
 				.last("limit 1");
 		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
 		if (billetHotsendChangeShift == null) {
@@ -733,7 +735,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 			countAndSet(details, billetHotsendChangeShift, vehicleNumber, "2","stackingAmont");
 			allDetailsList.add(details);
 		}
-		billetHotsendChangeShift.setLiftingBillDetailsList(allDetailsList);
+		billetHotsendChangeShift.setLiftingBillDetailsList(JSON.toJSONString(allDetailsList));
 		billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
 	}
 
@@ -752,8 +754,8 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		// 根据铸机号、交班结束时间倒序并不为空,查询交班记录,
 		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, "5")
+				.isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
 				.orderByDesc(BilletHotsendChangeShift::getChangeShiftTime)
-				.ne(BilletHotsendChangeShift::getChangeShiftTime, null)
 				.last("limit 1");
 		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
 		if (billetHotsendChangeShift == null) {
@@ -778,8 +780,8 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		// 根据铸机号、交班结束时间倒序并不为空,查询交班记录,
 		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, "6")
+				.isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
 				.orderByDesc(BilletHotsendChangeShift::getChangeShiftTime)
-				.ne(BilletHotsendChangeShift::getChangeShiftTime, null)
 				.last("limit 1");
 		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
 		if (billetHotsendChangeShift == null) {
@@ -933,16 +935,72 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		billetHotsendChangeShift.setBlankOutputs(bd.doubleValue());
 
 		// 轧钢棒二明细
-		billetHotsendChangeShift.setRollClubTwoDetails(statisticsDetailsList1);
+		// 按照 size 分组,计算 nums 和 blankOutput 的总和,取每组第一条记录的 ccmNo
+		Map<String, DestinationStatisticsDetails> result1 = statisticsDetailsList1.stream()
+				.collect(Collectors.groupingBy(
+						DestinationStatisticsDetails::getSize,
+						Collectors.collectingAndThen(
+								Collectors.reducing((first, second) -> {
+									DestinationStatisticsDetails combined = new DestinationStatisticsDetails();
+									combined.setSize(first.getSize());
+									combined.setNums(first.getNums() + second.getNums());
+									combined.setBlankOutput(roundToFourDecimals(first.getBlankOutput() + second.getBlankOutput()));
+									combined.setCcmNo(first.getCcmNo());
+									return combined;
+								}),
+								Optional::get
+						)
+				));
+		List<DestinationStatisticsDetails> statisticsDetailsGroup1List = new ArrayList<>(result1.values());
+		billetHotsendChangeShift.setRollClubTwoDetails(JSON.toJSONString(statisticsDetailsGroup1List));
 
 		// 轧钢棒三明细
-		billetHotsendChangeShift.setRollClubThreeDetails(statisticsDetailsList2);
+		// 按照 size 分组,计算 nums 和 blankOutput 的总和,取每组第一条记录的 ccmNo
+		Map<String, DestinationStatisticsDetails> result2 = statisticsDetailsList2.stream()
+				.collect(Collectors.groupingBy(
+						DestinationStatisticsDetails::getSize,
+						Collectors.collectingAndThen(
+								Collectors.reducing((first, second) -> {
+									DestinationStatisticsDetails combined = new DestinationStatisticsDetails();
+									combined.setSize(first.getSize());
+									combined.setNums(first.getNums() + second.getNums());
+									combined.setBlankOutput(roundToFourDecimals(first.getBlankOutput() + second.getBlankOutput()));
+									combined.setCcmNo(first.getCcmNo());
+									return combined;
+								}),
+								Optional::get
+						)
+				));
+		List<DestinationStatisticsDetails> statisticsDetailsGroup2List = new ArrayList<>(result2.values());
+		billetHotsendChangeShift.setRollClubThreeDetails(JSON.toJSONString(statisticsDetailsGroup2List));
 
 		// 轧钢上若明细
-		billetHotsendChangeShift.setRollClubShipDetails(statisticsDetailsList3);
+		// 按照 size 分组,计算 nums 和 blankOutput 的总和,取每组第一条记录的 ccmNo
+		Map<String, DestinationStatisticsDetails> result3 = statisticsDetailsList3.stream()
+				.collect(Collectors.groupingBy(
+						DestinationStatisticsDetails::getSize,
+						Collectors.collectingAndThen(
+								Collectors.reducing((first, second) -> {
+									DestinationStatisticsDetails combined = new DestinationStatisticsDetails();
+									combined.setSize(first.getSize());
+									combined.setNums(first.getNums() + second.getNums());
+									combined.setBlankOutput(roundToFourDecimals(first.getBlankOutput() + second.getBlankOutput()));
+									combined.setCcmNo(first.getCcmNo());
+									return combined;
+								}),
+								Optional::get
+						)
+				));
+		List<DestinationStatisticsDetails> statisticsDetailsGroup3List = new ArrayList<>(result3.values());
+		billetHotsendChangeShift.setRollClubShipDetails(JSON.toJSONString(statisticsDetailsGroup3List));
 		billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
 	}
 
+	private static double roundToFourDecimals(double value) {
+		BigDecimal bd = new BigDecimal(Double.toString(value));
+		bd = bd.setScale(4, RoundingMode.HALF_UP);
+		return bd.doubleValue();
+	}
 
 	/**
 	 * 5号机
@@ -957,6 +1015,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		// 根据铸机号、交班结束时间倒序并不为空,查询交班记录,
 		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, "5")
+				.isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
 				.orderByDesc(BilletHotsendChangeShift::getCreateTime)
 				.last("limit 1");
 		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
@@ -1004,7 +1063,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 			rollClubOneDetailsStatisticsList.add(new DestinationStatisticsDetails(sizeStr, (int) count, totalWeight, ccmNoStr));
 		});
 
-		billetHotsendChangeShift.setRollClubOneDetails(rollClubOneDetailsStatisticsList);
+		billetHotsendChangeShift.setRollClubOneDetails(JSON.toJSONString(rollClubOneDetailsStatisticsList));
 
 		billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
 
@@ -1024,8 +1083,8 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		// 根据铸机号、交班结束时间倒序并不为空,查询交班记录,
 		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, "6")
+				.isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
 				.orderByDesc(BilletHotsendChangeShift::getChangeShiftTime)
-				.ne(BilletHotsendChangeShift::getChangeShiftTime, null)
 				.last("limit 1");
 		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
 		if (billetHotsendChangeShift == null) {
@@ -1074,7 +1133,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 			rollHeightStatisticsDetailsList.add(new DestinationStatisticsDetails(sizeStr, (int) count, totalWeight, ccmNoStr));
 		});
 
-		billetHotsendChangeShift.setRollClubHeightDetails(rollHeightStatisticsDetailsList);
+		billetHotsendChangeShift.setRollClubHeightDetails(JSON.toJSONString(rollHeightStatisticsDetailsList));
 		billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
 
 	}

+ 7 - 19
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/entity/BilletHotsendChangeShift.java

@@ -1,24 +1,19 @@
 package org.jeecg.modules.billet.billetHotsendChangeShift.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.jeecg.modules.billet.rollHeight.entity.DestinationStatisticsDetails;
-import org.jeecg.modules.billet.storageBill.entity.OnDutyLiftingBillDetails;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
-import java.util.List;
 
 /**
  * @Description: 钢坯交班记录
@@ -160,31 +155,24 @@ public class BilletHotsendChangeShift implements Serializable {
 
 
     @ApiModelProperty(value = "轧钢棒一明细")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
-    private List<DestinationStatisticsDetails> rollClubOneDetails;
+    private String rollClubOneDetails;
 
     @ApiModelProperty(value = "轧钢棒二明细")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
-    private List<DestinationStatisticsDetails> rollClubTwoDetails;
+    private String rollClubTwoDetails;
 
     @ApiModelProperty(value = "轧钢棒三明细")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
-    private List<DestinationStatisticsDetails> rollClubThreeDetails;
+    private String rollClubThreeDetails;
 
     @ApiModelProperty(value = "轧钢高线明细")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
-    private List<DestinationStatisticsDetails> rollClubHeightDetails;
+    private String rollClubHeightDetails;
 
     @ApiModelProperty(value = "轧钢上若明细")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
-    private List<DestinationStatisticsDetails> rollClubShipDetails;
+    private String rollClubShipDetails;
 
     // 班组定尺明细
     @ApiModelProperty(value = "班组定尺明细")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
-    private List<DestinationStatisticsDetails> sizeDetailsList;
+    private String sizeDetailsList;
 
     @ApiModelProperty(value = "班次吊运信息")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
-    private List<OnDutyLiftingBillDetails>  liftingBillDetailsList;
+    private String liftingBillDetailsList;
 }

+ 3 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollHeight/entity/DestinationStatisticsDetails.java

@@ -26,4 +26,7 @@ public class DestinationStatisticsDetails {
         this.blankOutput = blankOutput;
         this.ccmNo = ccmNo;
     }
+
+    // 必须有无参构造
+    public DestinationStatisticsDetails() {}
 }

+ 3 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/entity/OnDutyLiftingBillDetails.java

@@ -22,4 +22,7 @@ public class OnDutyLiftingBillDetails {
     private Integer stackingAmont;
 
     private Double AmontWeight;
+    // 生成无参构造方法
+    public OnDutyLiftingBillDetails() {
+    }
 }