|
@@ -4,9 +4,12 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
@@ -24,6 +27,8 @@ import org.jeecg.modules.billetHotsendConfig.entity.BilletHotsendTypeConfig;
|
|
import org.jeecg.modules.billetHotsendConfig.service.IBilletHotsendTypeConfigService;
|
|
import org.jeecg.modules.billetHotsendConfig.service.IBilletHotsendTypeConfigService;
|
|
import org.jeecg.modules.billetLiftingBill.entity.BilletLiftingBill;
|
|
import org.jeecg.modules.billetLiftingBill.entity.BilletLiftingBill;
|
|
import org.jeecg.modules.billetLiftingBill.service.IBilletLiftingBillService;
|
|
import org.jeecg.modules.billetLiftingBill.service.IBilletLiftingBillService;
|
|
|
|
+import org.jeecg.modules.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
|
|
|
|
+import org.jeecg.modules.billetOriginalProductRecord.service.IBilletOriginalProductRecordService;
|
|
import org.jeecg.modules.connConfig.configMqtt.mapper.ConfigMqttMapper;
|
|
import org.jeecg.modules.connConfig.configMqtt.mapper.ConfigMqttMapper;
|
|
import org.jeecg.modules.operateLog.entity.OperateLog;
|
|
import org.jeecg.modules.operateLog.entity.OperateLog;
|
|
import org.jeecg.modules.operateLog.service.IOperateLogService;
|
|
import org.jeecg.modules.operateLog.service.IOperateLogService;
|
|
@@ -65,6 +70,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -130,6 +136,8 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
|
|
private IRollDeputyCrossService rollDeputyCrossService;
|
|
private IRollDeputyCrossService rollDeputyCrossService;
|
|
@Autowired
|
|
@Autowired
|
|
private IRollDeputyCrossDetailsService rollDeputyCrossDetailsService;
|
|
private IRollDeputyCrossDetailsService rollDeputyCrossDetailsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBilletOriginalProductRecordService billetOriginalProductRecordService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 自动化新增 5号机 直轧棒1 6号机 高线
|
|
* 自动化新增 5号机 直轧棒1 6号机 高线
|
|
@@ -264,6 +272,77 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
|
|
billetHotsendDetailsVo.setRollClubCommonList(rollClubCommonLists);
|
|
billetHotsendDetailsVo.setRollClubCommonList(rollClubCommonLists);
|
|
log.info("C端自动化数据转换,{}新增参数:{}", operationMsg, JSON.toJSONString(billetHotsendDetailsVo));
|
|
log.info("C端自动化数据转换,{}新增参数:{}", operationMsg, JSON.toJSONString(billetHotsendDetailsVo));
|
|
saveBilletRodLineCommom(billetHotsendDetailsVo);
|
|
saveBilletRodLineCommom(billetHotsendDetailsVo);
|
|
|
|
+
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
+
|
|
|
|
+ for (RollClubCommon rollClubCommonOne : rollClubCommonLists) {
|
|
|
|
+ try {
|
|
|
|
+ // 1. 查询对应的钢坯原始生产记录(按 create_time 倒序,取最新一条)
|
|
|
|
+ QueryWrapper<BilletOriginalProductRecord> queryWrapperB = new QueryWrapper<>();
|
|
|
|
+ queryWrapperB.eq("ccm_no", rollClubCommonOne.getCcmNo())
|
|
|
|
+ .eq("shift", rollClubCommonOne.getShift())
|
|
|
|
+ .eq("shift_group", rollClubCommonOne.getShiftGroup())
|
|
|
|
+ .eq("heat_no", rollClubCommonOne.getHeatNo())
|
|
|
|
+ .orderByDesc("create_time");
|
|
|
|
+
|
|
|
|
+ BilletOriginalProductRecord one = billetOriginalProductRecordService.getOne(queryWrapperB, false);
|
|
|
|
+ if (one == null) {
|
|
|
|
+ log.warn("未找到原始生产记录,heatNo: {}", rollClubCommonOne.getHeatNo());
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 2. 解析 JSON 字段 rollClubOneDetails
|
|
|
|
+ String detailsJson = one.getRollClubOneDetails();
|
|
|
|
+ Map<String, Object> detailsMap;
|
|
|
|
+
|
|
|
|
+ if (detailsJson != null && !detailsJson.trim().isEmpty()) {
|
|
|
|
+ detailsMap = objectMapper.readValue(detailsJson, new TypeReference<Map<String, Object>>() {});
|
|
|
|
+ } else {
|
|
|
|
+ // 初始化结构
|
|
|
|
+ detailsMap = new HashMap<>();
|
|
|
|
+ detailsMap.put("lengthGroupCount", new HashMap<String, Integer>());
|
|
|
|
+ detailsMap.put("directRollingTotalWeight", 0.0);
|
|
|
|
+ detailsMap.put("directRollingTotalCount", 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 3. 当前定尺(size)和重量(billetWeight)
|
|
|
|
+ String size = rollClubCommonOne.getSize();
|
|
|
|
+ Double billetWeight = rollClubCommonOne.getBilletWeight();
|
|
|
|
+
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
+ Map<String, Integer> lengthGroupCount = (Map<String, Integer>) detailsMap.get("lengthGroupCount");
|
|
|
|
+
|
|
|
|
+ // 4. 更新定尺支数
|
|
|
|
+ lengthGroupCount.put(size, lengthGroupCount.getOrDefault(size, 0) + 1);
|
|
|
|
+ detailsMap.put("lengthGroupCount", lengthGroupCount);
|
|
|
|
+
|
|
|
|
+ // 5. 累加重量
|
|
|
|
+ double totalWeight = ((Number) detailsMap.getOrDefault("directRollingTotalWeight", 0.0)).doubleValue();
|
|
|
|
+ double addedWeight = (billetWeight != null ? billetWeight : 0.0);
|
|
|
|
+
|
|
|
|
+ BigDecimal updatedWeight = BigDecimal.valueOf(totalWeight)
|
|
|
|
+ .add(BigDecimal.valueOf(addedWeight))
|
|
|
|
+ .setScale(4, RoundingMode.HALF_UP);
|
|
|
|
+
|
|
|
|
+ detailsMap.put("directRollingTotalWeight", updatedWeight.doubleValue());
|
|
|
|
+
|
|
|
|
+ // 6. 累加支数
|
|
|
|
+ int totalCount = ((Number) detailsMap.getOrDefault("directRollingTotalCount", 0)).intValue();
|
|
|
|
+ detailsMap.put("directRollingTotalCount", totalCount + 1);
|
|
|
|
+
|
|
|
|
+ // 7. 写回 JSON 并保存
|
|
|
|
+ Integer originalAmount = one.getAmount();
|
|
|
|
+ // 累加 amount 字段
|
|
|
|
+ one.setAmount((originalAmount != null ? originalAmount : 0) + 1);
|
|
|
|
+
|
|
|
|
+ one.setRollClubOneDetails(objectMapper.writeValueAsString(detailsMap));
|
|
|
|
+ billetOriginalProductRecordService.updateById(one);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("处理 rollClubOneDetails 异常,heatNo: {}, size: {}, 错误: {}",
|
|
|
|
+ rollClubCommonOne.getHeatNo(), rollClubCommonOne.getSize(), e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
log.info("C端自动化操作结果,{}新增成功:{}", operationMsg, billetNos);
|
|
log.info("C端自动化操作结果,{}新增成功:{}", operationMsg, billetNos);
|
|
}
|
|
}
|
|
/**
|
|
/**
|