Browse Source

热送明细逻辑接口开发

qiangxuan 5 tháng trước cách đây
mục cha
commit
6babf5e3fe

+ 98 - 5
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/controller/StorageBillController.java

@@ -30,10 +30,8 @@ import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.lang.reflect.Field;
+import java.util.*;
 
 /**
  * @Description: 钢坯装运单
@@ -97,8 +95,103 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 		return Result.OK(pageList);
 	}
 
+	@ApiOperation(value="钢坯热送实绩-分页列表查询", notes="钢坯热送实绩-分页列表查询")
+	@GetMapping(value = "/listHotSendSJ")
+	public Result<IPage<StorageBill>> queryHotSendPageSJList(StorageBill storageBill,
+														   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+														   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+														   HttpServletRequest req) {
+		QueryWrapper<StorageBill> queryWrapper = QueryGenerator.initQueryWrapper(storageBill, req.getParameterMap());
+		queryWrapper.in("license_plate", Arrays.asList("堆垛辊道","辊道"));
+		queryWrapper.isNotNull("heat_no");
+		queryWrapper.orderByDesc("create_time");
+		Page<StorageBill> page = new Page<StorageBill>(pageNo, pageSize);
+		IPage<StorageBill> pageList = storageBillService.page(page, queryWrapper);
 
-	@ApiOperation(value="钢坯装运单-分页列表查询", notes="钢坯装运单-分页列表查询")
+		// 分组处理
+		Map<String, StorageBill> groupedMap = new HashMap<>();
+		for (StorageBill bill : pageList.getRecords()) {
+
+			String heatNo = bill.getHeatNo();
+			StorageBill groupedBill = groupedMap.computeIfAbsent(heatNo, k -> new StorageBill());
+
+			// 对 amount_total 求和
+			if (groupedBill.getAmountTotal() == null) {
+				groupedBill.setAmountTotal(bill.getAmountTotal());
+			} else {
+				groupedBill.setAmountTotal(groupedBill.getAmountTotal() + bill.getAmountTotal());
+			}
+			// 合并其他字段值
+			mergeField(groupedBill, bill, "id");
+			handleTimeField(groupedBill, bill, "createTime");
+			handleTimeField(groupedBill, bill, "updateTime");
+			handleTimeField(groupedBill, bill, "dateTime");
+			mergeField(groupedBill, bill, "ccmNo");
+			mergeField(groupedBill, bill, "shiftGroup");
+			mergeField(groupedBill, bill, "shift");
+			mergeField(groupedBill, bill, "steel");
+			mergeField(groupedBill, bill, "spec");
+			mergeField(groupedBill, bill, "size");
+			mergeField(groupedBill, bill, "licensePlate");
+			mergeField(groupedBill, bill, "btype");
+			mergeField(groupedBill, bill, "destination");
+			mergeField(groupedBill, bill, "typeConfigId");
+			mergeField(groupedBill, bill, "uniqueCode");
+			mergeField(groupedBill, bill, "positionNum");
+			mergeField(groupedBill, bill, "assemblyNumber");
+		}
+		// 封装分组后的结果到新的 IPage 对象
+		IPage<StorageBill> groupedPage = new Page<>(pageNo, pageSize, groupedMap.size());
+		groupedPage.setRecords(new ArrayList<>(groupedMap.values()));
+		return Result.OK(groupedPage);
+	}
+
+	private void mergeField(StorageBill groupedBill, StorageBill bill, String fieldName) {
+		try {
+			Field field = StorageBill.class.getDeclaredField(fieldName);
+			field.setAccessible(true);
+			Object value = field.get(bill);
+			if (value != null) {
+				Object groupedValue = field.get(groupedBill);
+				Set<String> valueSet = new HashSet<>();
+				if (groupedValue != null) {
+					String[] existingValues = groupedValue.toString().split(",");
+					valueSet.addAll(Arrays.asList(existingValues));
+				}
+				valueSet.add(value.toString());
+				String newValue = String.join(",", valueSet);
+				field.set(groupedBill, newValue);
+			}
+		} catch (NoSuchFieldException | IllegalAccessException e) {
+			e.printStackTrace();
+		}
+	}
+
+	private void handleTimeField(StorageBill groupedBill, StorageBill bill, String fieldName) {
+		try {
+			Field field = StorageBill.class.getDeclaredField(fieldName);
+			field.setAccessible(true);
+			Object currentValue = field.get(groupedBill);
+			Object newValue = field.get(bill);
+
+			if (currentValue == null) {
+				field.set(groupedBill, newValue);
+			} else {
+				if (newValue instanceof Date && currentValue instanceof Date) {
+					Date currentDate = (Date) currentValue;
+					Date newDate = (Date) newValue;
+					if (newDate.after(currentDate)) {
+						field.set(groupedBill, newDate);
+					}
+				}
+			}
+		} catch (NoSuchFieldException | IllegalAccessException e) {
+			e.printStackTrace();
+		}
+	}
+
+
+	@ApiOperation(value="钢坯明细信息-分页列表查询", notes="钢坯明细信息-分页列表查询")
 	@GetMapping(value = "/details")
 	public Result<BilletHotsendDetails> queryPageDetailsList(StorageBill storageBill) {
 		BilletHotsendDetails pageList = storageBillService.findBilletHotsendDetails(storageBill);

+ 15 - 10
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/impl/StorageBillServiceImpl.java

@@ -55,10 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collectors;
 
@@ -166,6 +163,14 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
     @Override
     public BilletHotsendDetails findBilletHotsendDetails(StorageBill storageBill) {
         BilletHotsendDetails result = new BilletHotsendDetails();
+
+        List<String> idList = Arrays.stream(storageBill.getId().split(","))
+                .collect(Collectors.toList());
+        if (oConvertUtils.listIsEmpty(idList)){
+            log.info("{}{}", "装运单ID为空,装运明细查询失败", JSON.toJSON(storageBill));
+            return null;
+        }
+
         //根据部门orgCode查询部门,需要将职位id进行传递
         BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
         if (oConvertUtils.isEmpty(billetHotsendTypeConfig)){
@@ -173,7 +178,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             return null;
         }
         if ("billet_auto_tmp".equals(billetHotsendTypeConfig.getBelongTable())){
-            List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(new LambdaQueryWrapper<BilletAutoTmp>().eq(BilletAutoTmp::getStorageBillId, storageBill.getId()));
+            List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(new LambdaQueryWrapper<BilletAutoTmp>().in(BilletAutoTmp::getStorageBillId, idList));
             if (oConvertUtils.listIsNotEmpty(billetAutoTmpList)){
                 List<RollClubTwoDetails> rollClubTwoDetailsList = new ArrayList<>();
                 billetAutoTmpList.forEach(x ->{
@@ -186,15 +191,15 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             }
             return result;
         }
-        List<RollClubOneDetails> rollClubOneDetailsList = rollClubOneDetailsService.list(new LambdaQueryWrapper<RollClubOneDetails>().eq(RollClubOneDetails::getStorageBillId, storageBill.getId()));
+        List<RollClubOneDetails> rollClubOneDetailsList = rollClubOneDetailsService.list(new LambdaQueryWrapper<RollClubOneDetails>().in(RollClubOneDetails::getStorageBillId, idList));
         result.setRollClubOneDetailsList(rollClubOneDetailsList);
-        List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(new LambdaQueryWrapper<RollClubTwoDetails>().eq(RollClubTwoDetails::getStorageBillId, storageBill.getId()));
+        List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(new LambdaQueryWrapper<RollClubTwoDetails>().in(RollClubTwoDetails::getStorageBillId, idList));
         result.setRollClubTwoDetailsList(rollClubTwoDetailsList);
-        List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(new LambdaQueryWrapper<RollClubThreeDetails>().eq(RollClubThreeDetails::getStorageBillId, storageBill.getId()));
+        List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(new LambdaQueryWrapper<RollClubThreeDetails>().in(RollClubThreeDetails::getStorageBillId, idList));
         result.setRollClubThreeDetailsList(rollClubThreeDetailsList);
-        List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(new LambdaQueryWrapper<RollOutShippDetails>().eq(RollOutShippDetails::getStorageBillId, storageBill.getId()));
+        List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(new LambdaQueryWrapper<RollOutShippDetails>().in(RollOutShippDetails::getStorageBillId, idList));
         result.setRollOutShippDetailsList(rollOutShippDetailsList);
-        List<RollHeightDetails> rollHeightDetails = rollHeightDetailsService.list(new LambdaQueryWrapper<RollHeightDetails>().eq(RollHeightDetails::getStorageBillId, storageBill.getId()));
+        List<RollHeightDetails> rollHeightDetails = rollHeightDetailsService.list(new LambdaQueryWrapper<RollHeightDetails>().in(RollHeightDetails::getStorageBillId, idList));
         result.setRollHeightDetails(rollHeightDetails);
 
         //        List<StackingDownLogDetails> stackingDownLogDetailsList = new ArrayList<>();