diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java index c51a19c6..1163023b 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java @@ -1,15 +1,12 @@ package com.zt.plat.module.qms.resource.material.controller.admin; -import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationSaveReqVO; -import com.zt.plat.module.qms.resource.material.controller.vo.export.MaterialHazardousLedgerExportVO; import com.zt.plat.module.qms.resource.material.controller.vo.query.MaterialInfomationQueryVO; import com.zt.plat.module.qms.resource.material.controller.vo.resp.MaterialInfomationLedgerRespVO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; import com.zt.plat.module.qms.resource.material.service.MaterialInfomationService; -import com.zt.plat.module.qms.resource.material.utils.ComplexExcelUtils; import org.springframework.web.bind.annotation.*; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -42,7 +39,6 @@ import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*; @RestController @RequestMapping("/qms/resource/material-infomation") @Validated -@DeptDataPermissionIgnore(enable = "true") public class MaterialInfomationController implements BusinessControllerMarker { @@ -129,344 +125,19 @@ public class MaterialInfomationController implements BusinessControllerMarker { return success(pageResult); } - @GetMapping("/export-hazardous-ledger") + @GetMapping("/export-ledger") @Operation(summary = "导出危化品台账") - public void exportHazardousLedger(HttpServletResponse response) throws IOException { + public void exportHazardousLedger(@Valid MaterialInfomationPageReqVO pageReqVO, HttpServletResponse response) throws IOException { - ArrayList exportVOS = getLedgerExportVOS(); - - // 3. 导出 Excel - ComplexExcelUtils.writeHazardousLedger( - response, "危险化学品管理台账.xls", "危险化学品管理台账", exportVOS - - ); - } - - private ArrayList getLedgerExportVOS() { - ArrayList exportVOS = new ArrayList<>(); - // 造测试数据 - for (int i = 0; i < 10; i++) { - MaterialHazardousLedgerExportVO vo = new MaterialHazardousLedgerExportVO(); - vo.setSerialNo(i + 1); - vo.setCompany("云铜检测"); - - // 根据序号设置不同的化学品信息 - switch (i) { - case 0: - vo.setName("乙炔"); - vo.setSubstance("气体"); - vo.setHazardFeature("易燃易爆"); - vo.setEnglishName("Acetylene"); - vo.setAlias("电石气"); - vo.setHazardCategory("易燃气体,类别 1\n化学不稳定性气体,类别 A\n加压气体"); - vo.setIsToxic("否"); - vo.setCasNo("74-86-2"); - vo.setUnNo("1001"); - vo.setHazardCode("21024"); - vo.setTotalQuantity("0"); - vo.setChemStoreLocation("0"); - vo.setChemQuantity("0"); - vo.setChemSpec("0"); - vo.setChemUseLocation("0"); - vo.setChemUse("0"); - vo.setCompStoreLocation("219 原子吸收室"); - vo.setCompQuantity("0"); - vo.setCompSpec("40L/瓶"); - vo.setCompUseLocation("原子吸收室"); - vo.setCompUse("原子吸收仪器使用"); - vo.setTrialStoreLocation("0"); - vo.setTrialQuantity("0"); - vo.setTrialSpec("0"); - vo.setTrialUseLocation("0"); - vo.setTrialUse("0"); - vo.setIsExplosive(""); - vo.setIsPoisonous(""); - vo.setRemark(""); - break; - case 1: - vo.setName("氩 [压缩的或液化的]"); - vo.setSubstance("气体"); - vo.setHazardFeature("容器遇到高温爆炸"); - vo.setEnglishName("argon, compressed or liquefied"); - vo.setAlias("/"); - vo.setHazardCategory("加压气体"); - vo.setIsToxic("否"); - vo.setCasNo("7440-37-1"); - vo.setUnNo("1006"); - vo.setHazardCode("22011"); - vo.setTotalQuantity("1"); - vo.setChemStoreLocation("0"); - vo.setChemQuantity("0"); - vo.setChemSpec("0"); - vo.setChemUseLocation("0"); - vo.setChemUse("0"); - vo.setCompStoreLocation("114 气体室"); - vo.setCompQuantity("1"); - vo.setCompSpec("40L/瓶"); - vo.setCompUseLocation("分析岗"); - vo.setCompUse("原子荧光仪器、ICP、定氧仪使用"); - vo.setTrialStoreLocation("0"); - vo.setTrialQuantity("0"); - vo.setTrialSpec("0"); - vo.setTrialUseLocation("0"); - vo.setTrialUse("0"); - vo.setIsExplosive(""); - vo.setIsPoisonous(""); - vo.setRemark(""); - break; - case 2: - vo.setName("乙醇 [无水]"); - vo.setSubstance("液体"); - vo.setHazardFeature("易燃易爆"); - vo.setEnglishName("alcohol anhydrous;ethanol;ethyl alcohol"); - vo.setAlias("无水酒精"); - vo.setHazardCategory("易燃液体,类别 2"); - vo.setIsToxic("否"); - vo.setCasNo("64-17-5"); - vo.setUnNo("1170"); - vo.setHazardCode("32061"); - vo.setTotalQuantity("29.66"); - vo.setChemStoreLocation("0"); - vo.setChemQuantity("0"); - vo.setChemSpec("0"); - vo.setChemUseLocation("0"); - vo.setChemUse("0"); - vo.setCompStoreLocation("104 试剂室"); - vo.setCompQuantity("29"); - vo.setCompSpec("2500mL/瓶"); - vo.setCompUseLocation("分析岗"); - vo.setCompUse("用于天平擦拭及铜精矿中铅、氯的测定"); - vo.setTrialStoreLocation("137 试剂室"); - vo.setTrialQuantity("0.66"); - vo.setTrialSpec("AR2500mL/瓶"); - vo.setTrialUseLocation("天平室"); - vo.setTrialUse("清洁仪器设备用"); - vo.setIsExplosive(""); - vo.setIsPoisonous(""); - vo.setRemark(""); - break; - case 3: - vo.setName("硼氢化钾"); - vo.setSubstance("固体"); - vo.setHazardFeature("有毒有害、易燃易爆"); - vo.setEnglishName("Potassium borohydride"); - vo.setAlias("氢硼化钾"); - vo.setHazardCategory("遇水放出易燃气体的物质和混合物,类别 1\n急性毒性 - 经口,类别 3\n急性毒性 - 经皮,类别 3"); - vo.setIsToxic("否"); - vo.setCasNo("13762-51-1"); - vo.setUnNo("1870"); - vo.setHazardCode("43045"); - vo.setTotalQuantity("5"); - vo.setChemStoreLocation("106 危化品室"); - vo.setChemQuantity("5"); - vo.setChemSpec("AR100g/瓶"); - vo.setChemUseLocation("样品消解室"); - vo.setChemUse("分析砷使用"); - vo.setCompStoreLocation("0"); - vo.setCompQuantity("0"); - vo.setCompSpec("0"); - vo.setCompUseLocation("0"); - vo.setCompUse("0"); - vo.setTrialStoreLocation("0"); - vo.setTrialQuantity("0"); - vo.setTrialSpec("0"); - vo.setTrialUseLocation("0"); - vo.setTrialUse("0"); - vo.setIsExplosive("易制爆"); - vo.setIsPoisonous(""); - vo.setRemark(""); - break; - case 4: - vo.setName("高氯酸 [含酸 50%~72%]"); - vo.setSubstance("液体"); - vo.setHazardFeature("腐蚀、易燃易爆"); - vo.setEnglishName("Perchloric Acid"); - vo.setAlias("/"); - vo.setHazardCategory("氧化性液体,类别 1\n皮肤腐蚀/刺激,类别 1A\n严重眼损伤/眼刺激,类别 1"); - vo.setIsToxic("否"); - vo.setCasNo("7601-90-3"); - vo.setUnNo("1873"); - vo.setHazardCode("51015"); - vo.setTotalQuantity("32"); - vo.setChemStoreLocation("106 危化品室"); - vo.setChemQuantity("28"); - vo.setChemSpec("AR500mL/瓶"); - vo.setChemUseLocation("样品消解室"); - vo.setChemUse("分析铜使用"); - vo.setCompStoreLocation("104 试剂室"); - vo.setCompQuantity("4"); - vo.setCompSpec("GR500mL/瓶"); - vo.setCompUseLocation("分析岗"); - vo.setCompUse("溶样时作为氧化剂加入使用"); - vo.setTrialStoreLocation("0"); - vo.setTrialQuantity("0"); - vo.setTrialSpec("0"); - vo.setTrialUseLocation("0"); - vo.setTrialUse("0"); - vo.setIsExplosive("易制爆"); - vo.setIsPoisonous(""); - vo.setRemark(""); - break; - case 5: - vo.setName("过氧化氢溶液 [含量>8%]"); - vo.setSubstance("液体"); - vo.setHazardFeature("腐蚀、易燃易爆"); - vo.setEnglishName("Hydrogen Peroxide"); - vo.setAlias("/"); - vo.setHazardCategory("(1) 含量≥60%\n氧化性液体,类别 1\n皮肤腐蚀/刺激,类别 1A\n严重眼损伤/眼刺激,类别 1\n特异性靶器官毒性--一次接触,类别 3(呼吸道刺激)\n(2) 20%≤含量<60%\n氧化性液体,类别 2\n皮肤腐蚀/刺激,类别 1A\n严重眼损伤/眼刺激,类别 1\n特异性靶器官毒性--一次接触,类别 3(呼吸道刺激)"); - vo.setIsToxic("否"); - vo.setCasNo("7722-84-1"); - vo.setUnNo("2014"); - vo.setHazardCode("51001"); - vo.setTotalQuantity("13"); - vo.setChemStoreLocation("0"); - vo.setChemQuantity("0"); - vo.setChemSpec("0"); - vo.setChemUseLocation("0"); - vo.setChemUse("0"); - vo.setCompStoreLocation("0"); - vo.setCompQuantity("0"); - vo.setCompSpec("0"); - vo.setCompUseLocation("0"); - vo.setCompUse("0"); - vo.setTrialStoreLocation("137 试剂室"); - vo.setTrialQuantity("13"); - vo.setTrialSpec("AR500mL/瓶"); - vo.setTrialUseLocation("分金室"); - vo.setTrialUse("火试金分析用"); - vo.setIsExplosive("易制爆"); - vo.setIsPoisonous(""); - vo.setRemark(""); - break; - case 6: - vo.setName("硝酸"); - vo.setSubstance("液体"); - vo.setHazardFeature("腐蚀、强氧化性"); - vo.setEnglishName("Nitric Acid"); - vo.setAlias("硝镪水"); - vo.setHazardCategory("氧化性液体,类别 3\n皮肤腐蚀/刺激,类别 1A\n严重眼损伤/眼刺激,类别 1"); - vo.setIsToxic("否"); - vo.setCasNo("7697-37-2"); - vo.setUnNo("2031"); - vo.setHazardCode("81002"); - vo.setTotalQuantity("50"); - vo.setChemStoreLocation("106 危化品室"); - vo.setChemQuantity("30"); - vo.setChemSpec("AR500mL/瓶"); - vo.setChemUseLocation("样品消解室"); - vo.setChemUse("分析铜、铅、锌使用"); - vo.setCompStoreLocation("104 试剂室"); - vo.setCompQuantity("15"); - vo.setCompSpec("GR500mL/瓶"); - vo.setCompUseLocation("分析岗"); - vo.setCompUse("溶样使用"); - vo.setTrialStoreLocation("137 试剂室"); - vo.setTrialQuantity("5"); - vo.setTrialSpec("AR500mL/瓶"); - vo.setTrialUseLocation("分金室"); - vo.setTrialUse("火试金分析用"); - vo.setIsExplosive(""); - vo.setIsPoisonous(""); - vo.setRemark(""); - break; - case 7: - vo.setName("盐酸"); - vo.setSubstance("液体"); - vo.setHazardFeature("腐蚀、刺激性"); - vo.setEnglishName("Hydrochloric Acid"); - vo.setAlias("氢氯酸"); - vo.setHazardCategory("皮肤腐蚀/刺激,类别 1A\n严重眼损伤/眼刺激,类别 1\n特异性靶器官毒性 - 一次接触,类别 3(呼吸道刺激)"); - vo.setIsToxic("否"); - vo.setCasNo("7647-01-0"); - vo.setUnNo("1789"); - vo.setHazardCode("81013"); - vo.setTotalQuantity("80"); - vo.setChemStoreLocation("106 危化品室"); - vo.setChemQuantity("50"); - vo.setChemSpec("AR500mL/瓶"); - vo.setChemUseLocation("样品消解室"); - vo.setChemUse("分析铜、铁使用"); - vo.setCompStoreLocation("104 试剂室"); - vo.setCompQuantity("25"); - vo.setCompSpec("GR500mL/瓶"); - vo.setCompUseLocation("分析岗"); - vo.setCompUse("溶样使用"); - vo.setTrialStoreLocation("137 试剂室"); - vo.setTrialQuantity("5"); - vo.setTrialSpec("AR500mL/瓶"); - vo.setTrialUseLocation("分金室"); - vo.setTrialUse("火试金分析用"); - vo.setIsExplosive(""); - vo.setIsPoisonous(""); - vo.setRemark(""); - break; - case 8: - vo.setName("硫酸"); - vo.setSubstance("液体"); - vo.setHazardFeature("腐蚀、强氧化性"); - vo.setEnglishName("Sulfuric Acid"); - vo.setAlias("硫镪水"); - vo.setHazardCategory("皮肤腐蚀/刺激,类别 1A\n严重眼损伤/眼刺激,类别 1"); - vo.setIsToxic("否"); - vo.setCasNo("7664-93-9"); - vo.setUnNo("1830"); - vo.setHazardCode("91007"); - vo.setTotalQuantity("60"); - vo.setChemStoreLocation("106 危化品室"); - vo.setChemQuantity("40"); - vo.setChemSpec("AR500mL/瓶"); - vo.setChemUseLocation("样品消解室"); - vo.setChemUse("分析硫使用"); - vo.setCompStoreLocation("104 试剂室"); - vo.setCompQuantity("15"); - vo.setCompSpec("GR500mL/瓶"); - vo.setCompUseLocation("分析岗"); - vo.setCompUse("溶样使用"); - vo.setTrialStoreLocation("137 试剂室"); - vo.setTrialQuantity("5"); - vo.setTrialSpec("AR500mL/瓶"); - vo.setTrialUseLocation("分金室"); - vo.setTrialUse("火试金分析用"); - vo.setIsExplosive(""); - vo.setIsPoisonous(""); - vo.setRemark(""); - break; - case 9: - vo.setName("氢氟酸"); - vo.setSubstance("液体"); - vo.setHazardFeature("腐蚀、剧毒"); - vo.setEnglishName("Hydrofluoric Acid"); - vo.setAlias("氟化氢"); - vo.setHazardCategory("皮肤腐蚀/刺激,类别 1A\n急性毒性 - 经皮,类别 2\n急性毒性 - 吸入,类别 2"); - vo.setIsToxic("否"); - vo.setCasNo("7664-39-3"); - vo.setUnNo("1790"); - vo.setHazardCode("81016"); - vo.setTotalQuantity("25"); - vo.setChemStoreLocation("106 危化品室"); - vo.setChemQuantity("20"); - vo.setChemSpec("AR500mL/瓶"); - vo.setChemUseLocation("样品消解室"); - vo.setChemUse("分析硅使用"); - vo.setCompStoreLocation("104 试剂室"); - vo.setCompQuantity("5"); - vo.setCompSpec("GR500mL/瓶"); - vo.setCompUseLocation("分析岗"); - vo.setCompUse("溶样使用"); - vo.setTrialStoreLocation("0"); - vo.setTrialQuantity("0"); - vo.setTrialSpec("0"); - vo.setTrialUseLocation("0"); - vo.setTrialUse("0"); - vo.setIsExplosive(""); - vo.setIsPoisonous(""); - vo.setRemark("剧毒化学品,双人双锁管理"); - break; - } - - exportVOS.add(vo); - } - return exportVOS; +// ArrayList exportVOS = getLedgerExportVOS(); + // 暂时只获取危化品台账 + pageReqVO.setHazardous(1); + PageResult pageResult = materialInfomationService.getMaterialInventoryLedgerPage(pageReqVO); +// // 3. 导出 Excel +// ComplexExcelUtils.writeHazardousLedger( +// response, "危险化学品管理台账.xls", "危险化学品管理台账", exportVOS +// +// ); } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundController.java index 9fad38a8..e90f5576 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundController.java @@ -15,23 +15,19 @@ import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryO import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundSaveReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.export.MaterialConsumeStatisticsExportVO; -import com.zt.plat.module.qms.resource.material.controller.vo.export.MaterialHazardousLedgerExportVO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDO; import com.zt.plat.module.qms.resource.material.service.MaterialInventoryOutboundService; -import com.zt.plat.module.qms.resource.material.utils.ComplexExcelUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; -import org.jspecify.annotations.NonNull; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/export/MaterialHazardousLedgerExportVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/export/MaterialHazardousLedgerExportVO.java deleted file mode 100644 index bf96d184..00000000 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/export/MaterialHazardousLedgerExportVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.zt.plat.module.qms.resource.material.controller.vo.export; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 物料危化品台账导出VO") -@Data -//@ExcelIgnoreUnannotated -public class MaterialHazardousLedgerExportVO { - // 基础信息 - private Integer serialNo; // 序号 - private String company; // 单位 - private String name; // 名称 - private String substance; // 物质 json - private String hazardFeature; // 危险特性 json - private String englishName; // 英文名 json - private String alias; // 别名 json - private String hazardCategory; // 危险类别 json - private String isToxic; // 是否剧毒 json - private String casNo; // CAS 号 json - private String unNo; // UN 号 json - private String hazardCode; // 危规号 json - - // 储存情况 - 合计 - private String totalQuantity; // 储存量合计 (瓶) - - // 化学分析室 - private String chemStoreLocation; // 存放地点 - private String chemQuantity; // 储存量 (瓶) - private String chemSpec; // 规格 - private String chemUseLocation; // 使用地点 json - private String chemUse; // 用途 json - - // 综合分析室 - private String compStoreLocation; // 存放地点 - private String compQuantity; // 储存量 (瓶) - private String compSpec; // 规格 - private String compUseLocation; // 使用地点 - private String compUse; // 用途 - - // 试金分析室 - private String trialStoreLocation; // 存放地点 - private String trialQuantity; // 储存量 (瓶) - private String trialSpec; // 规格 - private String trialUseLocation; // 使用地点 - private String trialUse; // 用途 - - // 其他 - private String isExplosive; // 易制爆 - private String isPoisonous; // 易制毒 - private String remark; // 备注 -} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/export/MaterialLedgerExportVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/export/MaterialLedgerExportVO.java new file mode 100644 index 00000000..4dc637a4 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/export/MaterialLedgerExportVO.java @@ -0,0 +1,62 @@ +package com.zt.plat.module.qms.resource.material.controller.vo.export; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - 物料危化品台账导出VO") +@Data +@ExcelIgnoreUnannotated +public class MaterialLedgerExportVO { + // 基础信息 + // @ExcelProperty(value = "序号", index = 0) + private Integer serialNo; + @ExcelProperty(value = "单位") + private String companyName; + @ExcelProperty(value = "名称") + private String productName; + @ExcelProperty(value = "物质") + private String substance; + @ExcelProperty(value = "危险特性") + private String hazardFeature; + @ExcelProperty(value = "英文名") + private String englishName; + @ExcelProperty(value = "别名") + private String alias; + @ExcelProperty(value = "危险类别") + private String hazardCategory; + @ExcelProperty(value = "是否剧毒") + private String isToxic; + @ExcelProperty(value = "CAS 号") + private String casNo; + @ExcelProperty(value = "UN 号") + private String unNo; + @ExcelProperty(value = "危规号") + private String hazardCode; + + // 储存情况 - 合计 + @ExcelProperty(value = "储存量合计") + private String inventoryQuantity; + + @ExcelProperty("部门") + private String departmentName; + @ExcelProperty(value = "存放地点") + private String locationName; + @ExcelProperty(value = "储存量") + private String departmentInventoryQuantity; + @ExcelProperty(value = "规格") + private String specification; + @ExcelProperty(value = "使用地点") + private String useLocation; + @ExcelProperty(value = "用途") + private String use; + + // 其他 + @ExcelProperty(value = "易制爆") + private String isExplosive; + @ExcelProperty(value = "易制毒") + private String isPoisonous; + @ExcelProperty(value = "备注") + private String remark; +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/resp/MaterialInfomationLedgerRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/resp/MaterialInfomationLedgerRespVO.java index c4284e71..87e25723 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/resp/MaterialInfomationLedgerRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/resp/MaterialInfomationLedgerRespVO.java @@ -1,13 +1,12 @@ package com.zt.plat.module.qms.resource.material.controller.vo.resp; +import cn.hutool.json.JSONObject; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; -import com.zt.plat.module.qms.core.aspect.annotation.Dict; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.math.BigDecimal; -import java.time.LocalDate; import java.time.LocalDateTime; @Schema(description = "管理后台 - 物料台账 Response VO") @@ -19,21 +18,21 @@ public class MaterialInfomationLedgerRespVO { @ExcelProperty("物料大类id") private Long productId; - @Schema(description = "物料大类") - @ExcelProperty("物料大类") + @Schema(description = "物料名称") + @ExcelProperty("物料名称") private String productName; @Schema(description = "物料大类编码") @ExcelProperty("物料大类编码") private String productCode; - @Schema(description = "工段上级部门id") - @ExcelProperty("工段上级部门id") - private Long superiorDepartmentId; + @Schema(description = "公司id") + @ExcelProperty("公司id") + private Long companyId; - @Schema(description = "工段上级部门") - @ExcelProperty("工段上级部门") - private String superiorDepartmentName; + @Schema(description = "公司 - 取上级部门") + @ExcelProperty("单位") + private String companyName; @Schema(description = "库存数量") @ExcelProperty("库存数量") @@ -53,15 +52,15 @@ public class MaterialInfomationLedgerRespVO { @Schema(description = "工段部门id") @ExcelProperty("工段部门id") - private Long assignDepartmentId; + private Long departmentId; @Schema(description = "工段分配部门名称") @ExcelProperty("工段分配部门名称") - private String assignDepartmentName; + private String departmentName; @Schema(description = "工段部门库存数量") @ExcelProperty("工段部门库存数量") - private BigDecimal assignDepartmentInventoryQuantity; + private BigDecimal departmentInventoryQuantity; @Schema(description = "存放位置", example = "13603") @ExcelProperty("存放位置") @@ -93,7 +92,7 @@ public class MaterialInfomationLedgerRespVO { @Schema(description = "大类其他配置") @ExcelProperty("大类其他配置") - private String productCustomConfig; + private JSONObject productCustomConfig; @Schema(description = "备注") @ExcelProperty("备注") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java index cc8baeeb..bc81cbd1 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java @@ -230,16 +230,20 @@ public interface MaterialInfomationMapper extends BaseMapperX selectInventoryLedgerPage(MaterialInfomationPageReqVO pageReqVO) { + default PageResult selectInventoryLedgerPage(MaterialInfomationPageReqVO reqVO) { MPJLambdaWrapper wrapper = new MPJLambdaWrapperX() .select(MaterialInfomationDO::getProductId) - .selectAs(MaterialInfomationDO::getDeptId, MaterialInfomationLedgerRespVO::getAssignDepartmentId) + .selectAs(MaterialInfomationDO::getDeptId, MaterialInfomationLedgerRespVO::getDepartmentId) .select(MaterialInfomationDO::getLocationId) - .selectCount(MaterialInfomationDO::getId, MaterialInfomationLedgerRespVO::getAssignDepartmentInventoryQuantity) + .selectCount(MaterialInfomationDO::getId, MaterialInfomationLedgerRespVO::getDepartmentInventoryQuantity) + .innerJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialInfomationDO::getProductId) + .eqIfExists(MaterialProductDO::getHazardous, reqVO.getHazardous()) + .eq(MaterialInfomationDO::getUsageStatus, 0) + .likeIfExists(MaterialProductDO::getName, reqVO.getName()) .groupBy(MaterialInfomationDO::getProductId, MaterialInfomationDO::getDeptId, MaterialInfomationDO::getLocationId); - return selectJoinPage(pageReqVO, MaterialInfomationLedgerRespVO.class, wrapper); + return selectJoinPage(reqVO, MaterialInfomationLedgerRespVO.class, wrapper); } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java index 6c0e2dd2..a22f7549 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java @@ -1,6 +1,7 @@ package com.zt.plat.module.qms.resource.material.service; import cn.hutool.core.collection.CollUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -26,14 +27,12 @@ import com.zt.plat.module.system.api.dept.DeptApi; import com.zt.plat.module.system.api.dept.dto.DeptRespDTO; import groovy.util.logging.Slf4j; import jakarta.annotation.Resource; -import org.jspecify.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import java.math.BigDecimal; import java.time.LocalDate; -import java.time.LocalDateTime; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -376,19 +375,19 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService private void calculateSuperiorDepartmentInventory(List list) { // 按上级部门 ID 分组,统计每个上级部门的总库存 Map superiorDeptInventoryMap = list.stream() - .filter(item -> item.getSuperiorDepartmentId() != null) + .filter(item -> item.getCompanyId() != null) .collect(Collectors.groupingBy( - MaterialInfomationLedgerRespVO::getSuperiorDepartmentId, + MaterialInfomationLedgerRespVO::getCompanyId, Collectors.reducing( BigDecimal.ZERO, - MaterialInfomationLedgerRespVO::getAssignDepartmentInventoryQuantity, + MaterialInfomationLedgerRespVO::getDepartmentInventoryQuantity, BigDecimal::add ) )); // 将累加结果设置到每条记录中 list.forEach(item -> { - BigDecimal totalInventory = superiorDeptInventoryMap.get(item.getSuperiorDepartmentId()); + BigDecimal totalInventory = superiorDeptInventoryMap.get(item.getCompanyId()); item.setInventoryQuantity(totalInventory != null ? totalInventory : BigDecimal.ZERO); }); } @@ -409,42 +408,37 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService private void enrichDepartmentInfo(List list) { // 部门信息 - List deptIds = list.stream().map(MaterialInfomationLedgerRespVO::getAssignDepartmentId).toList(); + List deptIds = list.stream().map(MaterialInfomationLedgerRespVO::getDepartmentId).toList(); CommonResult> deptListResult = deptApi.getDeptList(deptIds); List deptList = deptListResult.getData(); if (CollUtil.isEmpty(deptList)) return; Map deptMap = deptList.stream().collect(Collectors.toMap(DeptRespDTO::getId, Function.identity())); list.forEach(item -> { - DeptRespDTO dept = deptMap.get(item.getAssignDepartmentId()); - item.setAssignDepartmentName(dept.getName()); + DeptRespDTO dept = deptMap.get(item.getDepartmentId()); + item.setDepartmentName(dept.getName()); }); - log.info("[enrichDepartmentInfo] 部门信息:{}", deptList); List deptPrnIds = deptList.stream().map(DeptRespDTO::getParentId).toList(); - log.info("[enrichDepartmentInfo] 父级部门ID:{}", deptPrnIds); - CommonResult dept1 = deptApi.getDept(deptPrnIds.get(0)); - log.info("[enrichDepartmentInfo] 父级部门:{}", dept1.getData()); CommonResult> deptPrnListResult = deptApi.getDeptList(deptPrnIds); List deptPrnList = deptPrnListResult.getData(); - log.info("[enrichDepartmentInfo] 父级部门信息:{}", deptPrnList); if (CollUtil.isEmpty(deptPrnList)) return; Map deptPrnMap = deptPrnList.stream().collect(Collectors.toMap(DeptRespDTO::getId, Function.identity())); list.forEach(item -> { - DeptRespDTO dept = deptMap.get(item.getAssignDepartmentId()); + DeptRespDTO dept = deptMap.get(item.getDepartmentId()); DeptRespDTO deptPrn = deptPrnMap.get(dept.getParentId()); - item.setSuperiorDepartmentId(deptPrn.getId()).setSuperiorDepartmentName(deptPrn.getName()); + item.setCompanyId(deptPrn.getId()).setCompanyName(deptPrn.getName()); }); } private void enrichProductInfo(List list) { List productIds = list.stream().map(MaterialInfomationLedgerRespVO::getProductId).toList(); List productList = materialProductService.getMaterialProductListByPdtIds(productIds); - if (CollUtil.isEmpty(productList)) return ; + if (CollUtil.isEmpty(productList)) return; Map productMap = productList.stream().collect(Collectors.toMap(MaterialProductDO::getId, Function.identity())); list.forEach(item -> { MaterialProductDO productDO = productMap.get(item.getProductId()); item.setProductName(productDO.getName()) .setProductCode(productDO.getCode()) - .setProductCustomConfig(productDO.getCustomConfig()); + .setProductCustomConfig(JSONUtil.parseObj(productDO.getCustomConfig())); }); } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/utils/ComplexExcelUtils.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/utils/ComplexExcelUtils.java index da2d8ace..b193c964 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/utils/ComplexExcelUtils.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/utils/ComplexExcelUtils.java @@ -2,7 +2,7 @@ package com.zt.plat.module.qms.resource.material.utils; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; -import com.zt.plat.module.qms.resource.material.controller.vo.export.MaterialHazardousLedgerExportVO; +import com.zt.plat.module.qms.resource.material.controller.vo.export.MaterialLedgerExportVO; import com.zt.plat.module.qms.resource.material.handler.excel.MaterialHazardousLedgerHeadHandler; import com.zt.plat.module.qms.resource.material.handler.excel.MaterialHazardousLedgerStyleHandler; import jakarta.servlet.http.HttpServletResponse; @@ -15,9 +15,9 @@ import java.util.List; public class ComplexExcelUtils { public static void writeHazardousLedger(HttpServletResponse response, String filename, String sheetName, - List dataList) throws IOException { + List dataList) throws IOException { // 创建 ExcelWriter - EasyExcel.write(response.getOutputStream(), MaterialHazardousLedgerExportVO.class) + EasyExcel.write(response.getOutputStream(), MaterialLedgerExportVO.class) .autoCloseStream(false) .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 注册自定义表头处理器