diff --git a/src/main/java/com/bonus/aqgqj/business/backstage/controller/inventory/InventoryCountController.java b/src/main/java/com/bonus/aqgqj/business/backstage/controller/inventory/InventoryCountController.java index 5da2518..d901c48 100644 --- a/src/main/java/com/bonus/aqgqj/business/backstage/controller/inventory/InventoryCountController.java +++ b/src/main/java/com/bonus/aqgqj/business/backstage/controller/inventory/InventoryCountController.java @@ -16,7 +16,8 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -108,6 +109,39 @@ public class InventoryCountController { }); ExportParams exportParams = new ExportParams("工程领退及差缺台账", "工程领退及差缺台账", ExcelType.XSSF); Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ProjectMaterialLedger.class, list); + + // 手动合并工程名称列相同值的单元格 + Sheet sheet = workbook.getSheetAt(0); + int firstRow = sheet.getFirstRowNum() + 1; // 跳过标题行 + int lastRow = sheet.getLastRowNum(); + + if (lastRow > firstRow) { + String currentProName = ""; + int mergeStartRow = firstRow; + + for (int i = firstRow; i <= lastRow; i++) { + Row row = sheet.getRow(i); + if (row != null) { + Cell cell = row.getCell(0); // 假设工程名称在第1列 + if (cell != null) { + String proName = cell.getStringCellValue(); + if (!proName.equals(currentProName)) { + // 如果不是第一行,且当前项目名称与上一个不同,则合并之前的单元格 + if (i > firstRow && mergeStartRow < i - 1) { + sheet.addMergedRegion(new CellRangeAddress(mergeStartRow, i - 1, 0, 0)); + } + currentProName = proName; + mergeStartRow = i; + } + } + } + } + // 合并最后一组相同项目名称的单元格 + if (mergeStartRow < lastRow) { + sheet.addMergedRegion(new CellRangeAddress(mergeStartRow, lastRow, 0, 0)); + } + } + response.setContentType("application/vnd.ms-excel"); response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("工程领退及差缺台账" + ".xlsx", "UTF-8")); ServletOutputStream outputStream = response.getOutputStream(); diff --git a/src/main/java/com/bonus/aqgqj/business/backstage/entity/ProjectMaterialLedger.java b/src/main/java/com/bonus/aqgqj/business/backstage/entity/ProjectMaterialLedger.java index e295064..b0cc43b 100644 --- a/src/main/java/com/bonus/aqgqj/business/backstage/entity/ProjectMaterialLedger.java +++ b/src/main/java/com/bonus/aqgqj/business/backstage/entity/ProjectMaterialLedger.java @@ -4,6 +4,8 @@ import cn.afterturn.easypoi.excel.annotation.Excel; import lombok.Data; import lombok.experimental.Accessors; +import java.math.BigDecimal; + /** * @author : 阮世耀 * @version : 1.0 @@ -25,7 +27,7 @@ public class ProjectMaterialLedger { /** * 工程名称 */ - @Excel(name = "工程名称", width = 70) + @Excel(name = "工程名称", width = 70,needMerge = true) private String proName; /** @@ -71,12 +73,25 @@ public class ProjectMaterialLedger { @Excel(name = "利库量", width = 16) private Double totalLk = 0.00; + /** + * 采购单价 + */ + @Excel(name = "单价", width = 16) + private Double price= 0.00; + /** * 出库量--出库 */ @Excel(name = "出库量", width = 16) private Double totalCk = 0.00; + + /** + * 总价格 + */ + @Excel(name = "总价", width = 16) + private Double totalPrice= 0.00; + /** * 退货量--退库 */ @@ -89,6 +104,12 @@ public class ProjectMaterialLedger { @Excel(name = "差缺量", width = 16) private Double totalDiff = 0.00; + /** + * 差缺总价格 + */ + @Excel(name = "差缺总价", width = 16) + private Double totalDiffPrice= 0.00; + /** * 差缺状态 1-缺货 2-不缺货 */ diff --git a/src/main/java/com/bonus/aqgqj/business/backstage/entity/PurchaseVo.java b/src/main/java/com/bonus/aqgqj/business/backstage/entity/PurchaseVo.java index df160e7..e1d4181 100644 --- a/src/main/java/com/bonus/aqgqj/business/backstage/entity/PurchaseVo.java +++ b/src/main/java/com/bonus/aqgqj/business/backstage/entity/PurchaseVo.java @@ -83,5 +83,10 @@ public class PurchaseVo extends ParentVo { */ private String companyName; + /** + *0-暂存,1-提交 + */ + + private Integer editStatus; } diff --git a/src/main/java/com/bonus/aqgqj/business/backstage/entity/inventory/InventoryCountVo.java b/src/main/java/com/bonus/aqgqj/business/backstage/entity/inventory/InventoryCountVo.java index 3f37e1e..7b0edad 100644 --- a/src/main/java/com/bonus/aqgqj/business/backstage/entity/inventory/InventoryCountVo.java +++ b/src/main/java/com/bonus/aqgqj/business/backstage/entity/inventory/InventoryCountVo.java @@ -52,6 +52,11 @@ public class InventoryCountVo { /**是否预警 1.库存等于0 2.库存大于0*/ private String isWarn; + /** + * 总数量 + */ + private int totalNum; + @Data public static class DataView { /** diff --git a/src/main/java/com/bonus/aqgqj/business/backstage/service/inventory/InventoryCountServiceImpl.java b/src/main/java/com/bonus/aqgqj/business/backstage/service/inventory/InventoryCountServiceImpl.java index badff0d..d90918f 100644 --- a/src/main/java/com/bonus/aqgqj/business/backstage/service/inventory/InventoryCountServiceImpl.java +++ b/src/main/java/com/bonus/aqgqj/business/backstage/service/inventory/InventoryCountServiceImpl.java @@ -84,7 +84,9 @@ public class InventoryCountServiceImpl implements InventoryCountService{ } - return result; + return result.stream() + .sorted(Comparator.comparing(ProjectMaterialLedger::getProId)) + .collect(Collectors.toList()); } @Override @@ -134,7 +136,8 @@ public class InventoryCountServiceImpl implements InventoryCountService{ ledger.setTotalBack(returnRecord.getTotalBack() != null ? returnRecord.getTotalBack() : 0.00); ledger.setTotalCk(outRecord != null ? outRecord.getTotalCk() : 0.00); ledger.setNeedNum(outRecord != null ? outRecord.getNeedNum() : 0.00); - + //设置价格 + ledger.setPrice(outRecord != null ? outRecord.getPrice() : 0.00); // 3.设置工程信息 ledger.setProId(outRecord != null ? outRecord.getProId() : returnRecord.getProId()); ledger.setProName(outRecord != null ? outRecord.getProName() : returnRecord.getProName()); @@ -149,6 +152,10 @@ public class InventoryCountServiceImpl implements InventoryCountService{ // 计算差缺量 = 出库数量 - 退料数量 ledger.setTotalDiff(ledger.getTotalCk() - ledger.getTotalBack()); + ledger.setTotalPrice(Double.parseDouble(String.format("%.2f", ledger.getTotalCk() * ledger.getPrice()))); + double totalDiffPrice = Double.parseDouble(String.format("%.2f", ledger.getTotalDiff() * ledger.getPrice())); + ledger.setTotalDiffPrice(totalDiffPrice == 0 ? 0.0 : totalDiffPrice); + // 5.设置差缺状态 if (ledger.getTotalDiff() > 0) { diff --git a/src/main/resources/mappers/business/backstage/BackApplyMapper.xml b/src/main/resources/mappers/business/backstage/BackApplyMapper.xml index d4f7705..3b36218 100644 --- a/src/main/resources/mappers/business/backstage/BackApplyMapper.xml +++ b/src/main/resources/mappers/business/backstage/BackApplyMapper.xml @@ -179,4 +179,4 @@ and mt.name like concat('%',#{modelModel},'%') - \ No newline at end of file + diff --git a/src/main/resources/mappers/business/backstage/InventoryCountMapper.xml b/src/main/resources/mappers/business/backstage/InventoryCountMapper.xml index 2e67c59..586ecf1 100644 --- a/src/main/resources/mappers/business/backstage/InventoryCountMapper.xml +++ b/src/main/resources/mappers/business/backstage/InventoryCountMapper.xml @@ -11,13 +11,17 @@ SUM(o.cg_num) AS totalCg, SUM(o.lk_num) AS totalLk, SUM(o.need_num) AS needNum, -- 需求数量 - SUM(o.cg_num + o.lk_num) as totalCk -- 总出库数量 + SUM(o.cg_num + o.lk_num) as totalCk, -- 总出库数量 + sct.price as price FROM st_plan_out_details o JOIN st_plan_out spo ON o.out_id = spo.id -- 关联出库表 JOIN bm_project p ON spo.pro_id = p.ID -- 关联工程表 + + left join st_contract_type sct on o.model_id = sct.model_id + where 1=1 @@ -72,8 +76,10 @@ smt.unit_name AS unit, smt.storage_num AS num, smt.dbf_num AS dbfNum, + (IFNULL(smt.storage_num, 0) + IFNULL(smt.dbf_num, 0)) AS totalNum, smt2.name AS `name`, smt3.name AS `type` + FROM st_ma_type smt LEFT JOIN st_ma_type smt2 ON smt.parent_id = smt2.id LEFT JOIN st_ma_type smt3 ON smt2.parent_id = smt3.id @@ -272,4 +278,4 @@ and sba.`code` LIKE CONCAT('%',#{planCode},'%') - \ No newline at end of file + diff --git a/src/main/resources/mappers/business/backstage/PurchaseMapper.xml b/src/main/resources/mappers/business/backstage/PurchaseMapper.xml index 3c05d19..e56578e 100644 --- a/src/main/resources/mappers/business/backstage/PurchaseMapper.xml +++ b/src/main/resources/mappers/business/backstage/PurchaseMapper.xml @@ -83,7 +83,7 @@ - \ No newline at end of file +