Browse Source

删除原始记录同步更新炉次传递单的状态,删除状态的不在同步,修改质检统计增量更新范围

lingpeng.li 1 week ago
parent
commit
187a075298

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

@@ -178,5 +178,8 @@ public class BilletHotsend implements Serializable {
     @ApiModelProperty(value = "牌号")
     private String brandNum;
 
+    @ApiModelProperty(value = "是否从原始记录中删除-- 1代表删除")
+    private Integer deleteStatus;
+
 }
 

+ 43 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetOriginalProductRecord/controller/BilletOriginalProductRecordController.java

@@ -17,6 +17,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateFormatUtils;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.jeecg.common.api.vo.Result;
@@ -103,6 +104,9 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 	@Autowired
 	private IShiftConfigurationService shiftConfigurationService;
 
+	@Autowired
+	private IBilletHotsendBaseService billetHotsendService;
+
 	/**
 	 * 分页列表查询
 	 *
@@ -658,9 +662,41 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 	 */
 	@AutoLog(value = "钢坯生成原始记录-通过id删除")
 	@ApiOperation(value="钢坯生成原始记录-通过id删除", notes="钢坯生成原始记录-通过id删除")
-	@RequiresPermissions("billetOriginalProductRecord:billet_original_product_record:delete")
+//	@RequiresPermissions("billetOriginalProductRecord:billet_original_product_record:delete")
 	@DeleteMapping(value = "/delete")
 	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+		// 查询原始记录
+		BilletOriginalProductRecord record = billetOriginalProductRecordService.getById(id);
+		if (record == null) {
+			return Result.error("数据不存在");
+		}
+
+		String ccmNo = record.getCcmNo();
+		String shift = record.getShift();
+		String shiftGroup = record.getShiftGroup();
+		String heatNo = record.getHeatNo();
+		String recordDateStr = DateFormatUtils.format(record.getCreateTime(), "yyyy-MM-dd");
+
+		// 查询创建时间最新的 BilletHotsend 记录
+		LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
+		queryWrapper.eq(BilletHotsend::getCcmNo, ccmNo)
+				.eq(BilletHotsend::getShift, shift)
+				.eq(BilletHotsend::getShiftGroup, shiftGroup)
+				.eq(BilletHotsend::getHeatNo, heatNo)
+				.orderByDesc(BilletHotsend::getCreateTime)
+				.last("limit 1");
+
+		BilletHotsend hotsend = billetHotsendService.getOne(queryWrapper);
+		if (hotsend != null) {
+			String hotsendDateStr = DateFormatUtils.format(hotsend.getCreateTime(), "yyyy-MM-dd");
+			if (recordDateStr.equals(hotsendDateStr)) {
+				BilletHotsend updateEntity = new BilletHotsend();
+				updateEntity.setId(hotsend.getId());
+				updateEntity.setDeleteStatus(1); // 只更新 deleteStatus 字段
+				billetHotsendService.updateById(updateEntity);
+			}
+		}
+
 		billetOriginalProductRecordService.removeById(id);
 		return Result.OK("删除成功!");
 	}
@@ -1061,6 +1097,12 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		}else {
 			queryWrapper1.between(BilletHotsend::getCreateTime, shiftStartTime, shiftEndTime);
 		}
+		//过滤从原始记录中删除的炉号
+		queryWrapper1.and(wrapper ->
+				wrapper.ne(BilletHotsend::getDeleteStatus, 1)
+						.or()
+						.isNull(BilletHotsend::getDeleteStatus)
+		);
 		queryWrapper1.orderByDesc(BilletHotsend::getCreateTime);
 		List<BilletHotsend> billetHotsendList = billetHotsendBaseService.list(queryWrapper1);
 		if (oConvertUtils.listIsEmpty(billetHotsendList)){

+ 14 - 11
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetOriginalProductRecord/service/impl/BilletOriginalProductRecordServiceImpl.java

@@ -392,18 +392,21 @@ public class BilletOriginalProductRecordServiceImpl extends ServiceImpl<BilletOr
                                 .eq(QualityInspectionStatistics::getChangeShiftId, shift.getId())
                 );
 
-                // 已存在且已交班,跳过
+                // 如果交班时间存在,且从交班时间到当前时间超过30分钟,才跳过;否则仍然重新统计、更新
                 if (existing != null && shift.getChangeShiftTime() != null) {
-                    int dayEndCount = dayStartCount + existing.getClassTotalCount();
-                    BigDecimal dayEndWeight = dayStartWeight.add(existing.getClassTotalWeight());
-                    dayStartCount = dayEndCount;
-                    dayStartWeight = dayEndWeight;
-
-                    int monthEndCount = monthStartCount + existing.getClassTotalCount();
-                    BigDecimal monthEndWeight = monthStartWeight.add(existing.getClassTotalWeight());
-                    monthStartCount = monthEndCount;
-                    monthStartWeight = monthEndWeight;
-                    continue;
+                    long minutesSinceChange = (System.currentTimeMillis() - shift.getChangeShiftTime().getTime()) / (60 * 1000);
+                    if (minutesSinceChange >= 30) {
+                        int dayEndCount = dayStartCount + existing.getClassTotalCount();
+                        BigDecimal dayEndWeight = dayStartWeight.add(existing.getClassTotalWeight());
+                        dayStartCount = dayEndCount;
+                        dayStartWeight = dayEndWeight;
+
+                        int monthEndCount = monthStartCount + existing.getClassTotalCount();
+                        BigDecimal monthEndWeight = monthStartWeight.add(existing.getClassTotalWeight());
+                        monthStartCount = monthEndCount;
+                        monthStartWeight = monthEndWeight;
+                        continue;
+                    }
                 }
 
                 // 新建或更新记录