|
@@ -34,7 +34,6 @@ import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
-import java.lang.reflect.Field;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -116,46 +115,20 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
|
|
QueryWrapper<StorageBill> queryWrapper = QueryGenerator.initQueryWrapper(storageBill, req.getParameterMap());
|
|
QueryWrapper<StorageBill> queryWrapper = QueryGenerator.initQueryWrapper(storageBill, req.getParameterMap());
|
|
queryWrapper.in("license_plate", Arrays.asList("堆垛辊道","辊道"));
|
|
queryWrapper.in("license_plate", Arrays.asList("堆垛辊道","辊道"));
|
|
queryWrapper.isNotNull("heat_no");
|
|
queryWrapper.isNotNull("heat_no");
|
|
- queryWrapper.orderByDesc("create_time");
|
|
|
|
- Page<StorageBill> page = new Page<StorageBill>(pageNo, pageSize);
|
|
|
|
|
|
+ // 添加分组条件
|
|
|
|
+ queryWrapper.groupBy("heat_no");
|
|
|
|
+ // 如果需要统计每组的 amount_total 总和,可以添加聚合函数
|
|
|
|
+ queryWrapper.select("GROUP_CONCAT( DISTINCT id ) AS id", "GROUP_CONCAT( DISTINCT ccm_no ) AS ccmNo",
|
|
|
|
+ "GROUP_CONCAT( DISTINCT shift_group ) AS shiftGroup","GROUP_CONCAT( DISTINCT shift ) AS shift",
|
|
|
|
+ "heat_no", "GROUP_CONCAT( DISTINCT steel ) AS steel", "GROUP_CONCAT( DISTINCT spec ) AS spec",
|
|
|
|
+ "GROUP_CONCAT( DISTINCT size ) AS size","GROUP_CONCAT( DISTINCT license_plate ) AS licensePlate",
|
|
|
|
+ "GROUP_CONCAT( DISTINCT btype ) AS btype","GROUP_CONCAT( DISTINCT destination ) AS destination",
|
|
|
|
+ "GROUP_CONCAT( DISTINCT type_config_id ) AS typeConfigId","GROUP_CONCAT( DISTINCT unique_code ) AS uniqueCode",
|
|
|
|
+ "SUM(amount_total) as amountTotal", "GROUP_CONCAT( DISTINCT assembly_number ) AS assemblyNumber", "MAX(create_time) as createTime");
|
|
|
|
+ Page<StorageBill> page = new Page<>(pageNo, pageSize);
|
|
IPage<StorageBill> pageList = storageBillService.page(page, queryWrapper);
|
|
IPage<StorageBill> pageList = storageBillService.page(page, queryWrapper);
|
|
|
|
|
|
- // 分组处理
|
|
|
|
- Map<String, StorageBill> groupedMap = new HashMap<>();
|
|
|
|
- for (StorageBill bill : pageList.getRecords()) {
|
|
|
|
-
|
|
|
|
- String heatNo = bill.getHeatNo();
|
|
|
|
- StorageBill groupedBill = groupedMap.computeIfAbsent(heatNo, k -> new StorageBill());
|
|
|
|
- // 设置 heatNo
|
|
|
|
- groupedBill.setHeatNo(heatNo);
|
|
|
|
- // 对 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());
|
|
|
|
- for (StorageBill bill : groupedMap.values()){
|
|
|
|
|
|
+ for (StorageBill bill : pageList.getRecords()){
|
|
List<String> storageBillIds = Arrays.stream(bill.getId().split(",")).collect(Collectors.toList());
|
|
List<String> storageBillIds = Arrays.stream(bill.getId().split(",")).collect(Collectors.toList());
|
|
String totalBlankOutputStr = "";
|
|
String totalBlankOutputStr = "";
|
|
// 根据装运单ID查询对应的明细,统计总的出坯量
|
|
// 根据装运单ID查询对应的明细,统计总的出坯量
|
|
@@ -203,55 +176,9 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
|
|
}
|
|
}
|
|
bill.setRemarks(totalBlankOutputStr);
|
|
bill.setRemarks(totalBlankOutputStr);
|
|
}
|
|
}
|
|
- 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();
|
|
|
|
- }
|
|
|
|
|
|
+ return Result.OK(pageList);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
@ApiOperation(value="钢坯明细信息-分页列表查询", notes="钢坯明细信息-分页列表查询")
|
|
@ApiOperation(value="钢坯明细信息-分页列表查询", notes="钢坯明细信息-分页列表查询")
|
|
@GetMapping(value = "/details")
|
|
@GetMapping(value = "/details")
|
|
public Result<BilletHotsendDetails> queryPageDetailsList(StorageBill storageBill) {
|
|
public Result<BilletHotsendDetails> queryPageDetailsList(StorageBill storageBill) {
|