|
@@ -1,6 +1,7 @@
|
|
|
package org.jeecg.modules.billet.billetOriginalProductRecord.controller;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -569,6 +570,7 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
|
|
|
billetOriginalProductRecordDetails.setBilletOriginalProductRecordList(billetOriginalProductRecordList);
|
|
|
billetOriginalProductRecordDetails.setSizeInfo(billetHotsendChangeShift.getSizeInfo());
|
|
|
billetOriginalProductRecordDetails.setContent(billetHotsendChangeShift.getContent());
|
|
|
+ billetOriginalProductRecordDetails.setConfirmStatus(billetHotsendChangeShift.getConfirmStatus());
|
|
|
return Result.OK(billetOriginalProductRecordDetails);
|
|
|
}
|
|
|
|
|
@@ -991,6 +993,175 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
|
|
|
return heatsActualsInfoList;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value="钢坯堆垛原始生产记录查询", notes="钢坯原始堆垛生产记录查询")
|
|
|
+ @GetMapping(value = "/queryBilletStackRecordByCcmNo")
|
|
|
+ public Result<List<BilletOriginalHeatNoDetail>> queryBilletStackRecordByCcmNo(@RequestParam(name="ccmNo", required = false) String ccmNo,
|
|
|
+ @RequestParam(name="changeShiftId", required = false) String changeShiftId,
|
|
|
+ @RequestParam(name="queryType") String queryType) {
|
|
|
+ List<BilletOriginalHeatNoDetail> billetOriginalHeatNoDetailList = new ArrayList<>();
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift;
|
|
|
+ if ("1".equals(queryType)){
|
|
|
+ String classShiftGroup = String.format("class:shift:group:%s", ccmNo); // 班组
|
|
|
+ String classShift = String.format("class:shift:%s",ccmNo); // 班别
|
|
|
+ String shift = !oConvertUtils.getString(redisTemplate.opsForValue().get(classShift)).isEmpty() ? oConvertUtils.getString(redisTemplate.opsForValue().get(classShift)) : "";
|
|
|
+ String shiftGroup = !oConvertUtils.getString(redisTemplate.opsForValue().get(classShiftGroup)).isEmpty() ? oConvertUtils.getString(redisTemplate.opsForValue().get(classShiftGroup)) : "";
|
|
|
+
|
|
|
+ if (oConvertUtils.isEmpty(shiftGroup) || oConvertUtils.isEmpty(shift)){
|
|
|
+ return Result.error("班组班别获取为空,钢坯堆垛原始生产记录查询失败!");
|
|
|
+ }
|
|
|
+ // 根据ccmNo、shift、shiftGroup查询最新的交班记录
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
|
|
|
+ .eq(BilletHotsendChangeShift::getShift, shift)
|
|
|
+ .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
|
|
|
+ .isNull(BilletHotsendChangeShift::getChangeShiftTime)
|
|
|
+ .orderByDesc(BilletHotsendChangeShift::getCreateTime)
|
|
|
+ .last("limit 1");
|
|
|
+ billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
|
|
|
+ if (billetHotsendChangeShift == null){
|
|
|
+ log.info("{}{}", "钢坯堆垛原始生产记录,交班记录为空!", ccmNo + "失败时间:" + new Date());
|
|
|
+ return Result.error("交班信息为空,钢坯堆垛原始生产记录查询失败!");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ billetHotsendChangeShift = billetHotsendChangeShiftService.getById(changeShiftId);
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<BilletOriginalProductRecord> queryWrapper3 = new QueryWrapper<>();
|
|
|
+ queryWrapper3.eq("ccm_no", ccmNo)
|
|
|
+ .eq("shift", billetHotsendChangeShift.getShift())
|
|
|
+ .eq("shift_group", billetHotsendChangeShift.getShiftGroup());
|
|
|
+ if ("1".equals(queryType)){
|
|
|
+ queryWrapper3.between("create_time", billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+ }else {
|
|
|
+ queryWrapper3.between("create_time", billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
|
|
|
+ }
|
|
|
+ // 通过铸机号、班组、班别、交班开始时间 查询钢坯堆垛生产原始记录
|
|
|
+ List<BilletOriginalProductRecord> billetOriginalProductRecordList = billetOriginalProductRecordService.list(queryWrapper3);
|
|
|
+ if (oConvertUtils.listIsEmpty(billetOriginalProductRecordList)){
|
|
|
+ return Result.OK(billetOriginalHeatNoDetailList);
|
|
|
+ }
|
|
|
+ billetOriginalProductRecordList.forEach(x -> {
|
|
|
+ BilletOriginalHeatNoDetail billetOriginalHeatNoDetail = new BilletOriginalHeatNoDetail();
|
|
|
+ billetOriginalHeatNoDetail.setCcmNo(x.getCcmNo());
|
|
|
+ billetOriginalHeatNoDetail.setHeatNo(x.getHeatNo());
|
|
|
+ billetOriginalHeatNoDetail.setBrandNum(x.getGrade());
|
|
|
+ billetOriginalHeatNoDetail.setShiftGroup(x.getShiftGroup());
|
|
|
+ billetOriginalHeatNoDetail.setShift(x.getShift());
|
|
|
+ if (oConvertUtils.isNotEmpty(x.getStackLength())){
|
|
|
+ billetOriginalHeatNoDetail.setStackLength(x.getStackLength());
|
|
|
+ String stackLengthJson = x.getStackLength();
|
|
|
+ JSONArray jsonArray = JSON.parseArray(stackLengthJson);
|
|
|
+ // 初始化总数和总重
|
|
|
+ int totalCount = 0;
|
|
|
+ double totalWeight = 0.0d;
|
|
|
+ // 遍历 JSON 数组计算总数和总重
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject item = jsonArray.getJSONObject(i);
|
|
|
+ // 获取 stackingCount 字段并累加到总数
|
|
|
+ int count = item.getIntValue("stackingCount");
|
|
|
+ // 如果 stackingCount 为 0,跳过该项
|
|
|
+ if (count == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ totalCount += count;
|
|
|
+ // 获取 stackingWeight 字段并累加到总重
|
|
|
+ double weight = item.getDoubleValue("stackingWeight");
|
|
|
+ totalWeight += weight;
|
|
|
+ }
|
|
|
+ // 使用 DecimalFormat 四舍五入 保留四位小数
|
|
|
+ DecimalFormat df = new DecimalFormat("#.####");
|
|
|
+ String formattedWeight = df.format(totalWeight);
|
|
|
+ double roundedWeight = Double.parseDouble(formattedWeight);
|
|
|
+ billetOriginalHeatNoDetail.setAmountTotal(totalCount);
|
|
|
+ billetOriginalHeatNoDetail.setBlankOutput(roundedWeight);
|
|
|
+ }
|
|
|
+ billetOriginalHeatNoDetailList.add(billetOriginalHeatNoDetail);
|
|
|
+ });
|
|
|
+
|
|
|
+ return Result.OK(billetOriginalHeatNoDetailList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="所有钢坯堆垛信息查询", notes="所有钢坯堆垛信息查询")
|
|
|
+ @GetMapping(value = "/queryBilletStackInfoByCcmNo")
|
|
|
+ public Result<List<Map<String, Object>>> queryBilletStackInfoByCcmNo(@RequestParam(name="ccmNo", required = true) String ccmNo,
|
|
|
+ @RequestParam(name="typeConfigId", required = true) String typeConfigId) {
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 查询所有可能的位置,并按layer和address排序(低layer优先,address从1到9)
|
|
|
+ List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = stackingAndLoadingVehiclesMapper.selectList(
|
|
|
+ new QueryWrapper<StackingAndLoadingVehicles>()
|
|
|
+ .eq("ccm_no", ccmNo)
|
|
|
+ .eq("type_config_id", typeConfigId)
|
|
|
+ .isNotNull("heat_no") // 添加 heatNo 不为 null 的条件
|
|
|
+ .isNotNull("size") // 添加 size 不为 null 的条件
|
|
|
+ .isNotNull("billet_nos")); // 添加 billetNos 不为 null 的条件
|
|
|
+ if (oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)){
|
|
|
+ return Result.OK(resultList);
|
|
|
+ }
|
|
|
+ // 根据 heatNo 分组
|
|
|
+ Map<String, List<StackingAndLoadingVehicles>> heatNoGroupMap = stackingAndLoadingVehiclesList.stream()
|
|
|
+ .collect(Collectors.groupingBy(StackingAndLoadingVehicles::getHeatNo));
|
|
|
+
|
|
|
+ // 处理每个炉号分组
|
|
|
+ for (Map.Entry<String, List<StackingAndLoadingVehicles>> heatNoEntry : heatNoGroupMap.entrySet()) {
|
|
|
+ String heatNo = heatNoEntry.getKey();
|
|
|
+ List<StackingAndLoadingVehicles> heatNoItems = heatNoEntry.getValue();
|
|
|
+
|
|
|
+ // 根据 size 进一步分组
|
|
|
+ Map<String, List<StackingAndLoadingVehicles>> sizeGroupMap = heatNoItems.stream()
|
|
|
+ .collect(Collectors.groupingBy(StackingAndLoadingVehicles::getSize));
|
|
|
+
|
|
|
+ // 初始化炉号总数量和总重量
|
|
|
+ int totalCount = 0;
|
|
|
+ BigDecimal totalWeight = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ // 构建明细列表
|
|
|
+ JSONArray detailsArray = new JSONArray();
|
|
|
+
|
|
|
+ // 处理每个 size 分组
|
|
|
+ for (Map.Entry<String, List<StackingAndLoadingVehicles>> sizeEntry : sizeGroupMap.entrySet()) {
|
|
|
+ String size = sizeEntry.getKey();
|
|
|
+ List<StackingAndLoadingVehicles> sizeItems = sizeEntry.getValue();
|
|
|
+
|
|
|
+ // 计算该 size 的数量(记录数)
|
|
|
+ int sizeCount = sizeItems.size();
|
|
|
+
|
|
|
+ // 计算单根重量:size/1000 * 4 * 0.2265
|
|
|
+ BigDecimal sizeValue = new BigDecimal(size);
|
|
|
+ BigDecimal singleWeight = sizeValue.divide(BigDecimal.valueOf(1000), 10, RoundingMode.HALF_UP)
|
|
|
+ .multiply(BigDecimal.valueOf(4))
|
|
|
+ .multiply(BigDecimal.valueOf(0.2265));
|
|
|
+
|
|
|
+ // 计算该 size 的总重量
|
|
|
+ BigDecimal sizeTotalWeight = singleWeight.multiply(BigDecimal.valueOf(sizeCount))
|
|
|
+ .setScale(4, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ // 更新炉号总数量和总重量
|
|
|
+ totalCount += sizeCount;
|
|
|
+ totalWeight = totalWeight.add(sizeTotalWeight);
|
|
|
+
|
|
|
+ // 添加明细项
|
|
|
+ JSONObject detail = new JSONObject();
|
|
|
+ detail.put("stackingCount", sizeCount);
|
|
|
+ detail.put("stackingLength", size);
|
|
|
+ detail.put("stackingWeight", sizeTotalWeight.toString());
|
|
|
+ detailsArray.add(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建结果项
|
|
|
+ Map<String, Object> resultItem = new LinkedHashMap<>();
|
|
|
+ resultItem.put("heatNo", heatNo);
|
|
|
+ resultItem.put("totalCount", totalCount);
|
|
|
+ resultItem.put("totalWeight", totalWeight.setScale(4, RoundingMode.HALF_UP).toString());
|
|
|
+ resultItem.put("details", detailsArray);
|
|
|
+
|
|
|
+ resultList.add(resultItem);
|
|
|
+ }
|
|
|
+ return Result.OK(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private List<Map<String, Object>> handleStorageBillPrintHotCharge(List<StorageBillPrint> storageBillPrintList, String heatNo) {
|
|
|
List<Map<String, Object>> hotChargeList = new ArrayList<>();
|
|
|
List<Map<String, Object>> finalResult = new ArrayList<>();
|