diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/service/ConfigWarehouseLocationService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/service/ConfigWarehouseLocationService.java index 2fce44c5..b9a91529 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/service/ConfigWarehouseLocationService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/service/ConfigWarehouseLocationService.java @@ -71,4 +71,12 @@ public interface ConfigWarehouseLocationService { PageResult getConfigWarehouseLocationPage(ConfigWarehouseLocationPageReqVO pageReqVO); List selectListWithPermission(ConfigWarehouseLocationPageReqVO pageReqVO); + + /** + * 获得存放位置列表 + * + * @param ids id集合 + * @return 存放位置列表 + */ + List getListByIds(List ids); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/service/ConfigWarehouseLocationServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/service/ConfigWarehouseLocationServiceImpl.java index 3431627f..d96556bb 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/service/ConfigWarehouseLocationServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/service/ConfigWarehouseLocationServiceImpl.java @@ -178,4 +178,10 @@ public class ConfigWarehouseLocationServiceImpl implements ConfigWarehouseLocati public List selectListWithPermission(ConfigWarehouseLocationPageReqVO pageReqVO) { return configWarehouseLocationMapper.selectListWithPermission(pageReqVO); } + + @Override + public List getListByIds(List ids) { + + return configWarehouseLocationMapper.selectByIds(ids); + } } \ 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/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 62da82c4..c51a19c6 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 @@ -4,9 +4,12 @@ import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIg 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; @@ -17,7 +20,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Operation; -import jakarta.validation.constraints.*; import jakarta.validation.*; import jakarta.servlet.http.*; import java.util.*; @@ -118,4 +120,353 @@ public class MaterialInfomationController implements BusinessControllerMarker { BeanUtils.toBean(list, MaterialInfomationRespVO.class)); } + @GetMapping("/inventory-ledger-page") + @Operation(summary = "物料台账") + public CommonResult> getMaterialInventoryLedgerPage(@Valid MaterialInfomationPageReqVO pageReqVO) { + // 暂时只获取危化品台账 + pageReqVO.setHazardous(1); + PageResult pageResult = materialInfomationService.getMaterialInventoryLedgerPage(pageReqVO); + return success(pageResult); + } + + @GetMapping("/export-hazardous-ledger") + @Operation(summary = "导出危化品台账") + public void exportHazardousLedger(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; + } + } \ 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 e90f5576..9fad38a8 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,19 +15,23 @@ 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 new file mode 100644 index 00000000..bf96d184 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/export/MaterialHazardousLedgerExportVO.java @@ -0,0 +1,53 @@ +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/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 new file mode 100644 index 00000000..c4284e71 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/resp/MaterialInfomationLedgerRespVO.java @@ -0,0 +1,106 @@ +package com.zt.plat.module.qms.resource.material.controller.vo.resp; + +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") +@Data +@ExcelIgnoreUnannotated +public class MaterialInfomationLedgerRespVO { + + @Schema(description = "物料大类id", example = "2691") + @ExcelProperty("物料大类id") + private Long productId; + + @Schema(description = "物料大类") + @ExcelProperty("物料大类") + private String productName; + + @Schema(description = "物料大类编码") + @ExcelProperty("物料大类编码") + private String productCode; + + @Schema(description = "工段上级部门id") + @ExcelProperty("工段上级部门id") + private Long superiorDepartmentId; + + @Schema(description = "工段上级部门") + @ExcelProperty("工段上级部门") + private String superiorDepartmentName; + + @Schema(description = "库存数量") + @ExcelProperty("库存数量") + private BigDecimal inventoryQuantity; + + @Schema(description = "批次id", example = "2703") + @ExcelProperty("批次id") + private Long batchId; + + @Schema(description = "批次编号") + @ExcelProperty("批次编号") + private String batchNo; + + @Schema(description = "工段id") + @ExcelProperty("工段id") + private Long gongduanId; + + @Schema(description = "工段部门id") + @ExcelProperty("工段部门id") + private Long assignDepartmentId; + + @Schema(description = "工段分配部门名称") + @ExcelProperty("工段分配部门名称") + private String assignDepartmentName; + + @Schema(description = "工段部门库存数量") + @ExcelProperty("工段部门库存数量") + private BigDecimal assignDepartmentInventoryQuantity; + + @Schema(description = "存放位置", example = "13603") + @ExcelProperty("存放位置") + private Long locationId; + + @Schema(description = "存放位置编码") + @ExcelProperty("存放位置编码") + private String locationCode; + + @Schema(description = "存放位置") + @ExcelProperty("存放位置") + private String locationName; + + @Schema(description = "规格") + @ExcelProperty("规格") + private String specification; + + @Schema(description = "型号") + @ExcelProperty("型号") + private String modelNo; + + @Schema(description = "制造商") + @ExcelProperty("制造商") + private String manufacturer; + + @Schema(description = "单位") + @ExcelProperty("单位") + private String unit; + + @Schema(description = "大类其他配置") + @ExcelProperty("大类其他配置") + private String productCustomConfig; + + @Schema(description = "备注") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ 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/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 c72da809..cc8baeeb 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 @@ -12,10 +12,10 @@ import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceProductDO; 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.query.MaterialInfomationQueryVO; +import com.zt.plat.module.qms.resource.material.controller.vo.resp.MaterialInfomationLedgerRespVO; import com.zt.plat.module.qms.resource.material.dal.dataobject.*; import org.apache.ibatis.annotations.Mapper; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -229,4 +229,17 @@ public interface MaterialInfomationMapper extends BaseMapperX selectInventoryLedgerPage(MaterialInfomationPageReqVO pageReqVO) { + MPJLambdaWrapper wrapper = new MPJLambdaWrapperX() + .select(MaterialInfomationDO::getProductId) + .selectAs(MaterialInfomationDO::getDeptId, MaterialInfomationLedgerRespVO::getAssignDepartmentId) + .select(MaterialInfomationDO::getLocationId) + .selectCount(MaterialInfomationDO::getId, MaterialInfomationLedgerRespVO::getAssignDepartmentInventoryQuantity) + .groupBy(MaterialInfomationDO::getProductId, + MaterialInfomationDO::getDeptId, + MaterialInfomationDO::getLocationId); + + return selectJoinPage(pageReqVO, 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/handler/excel/MaterialHazardousLedgerHeadHandler.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/handler/excel/MaterialHazardousLedgerHeadHandler.java new file mode 100644 index 00000000..d994cd6c --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/handler/excel/MaterialHazardousLedgerHeadHandler.java @@ -0,0 +1,94 @@ +package com.zt.plat.module.qms.resource.material.handler.excel; + +import com.alibaba.excel.write.handler.RowWriteHandler; +import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +import com.alibaba.excel.write.metadata.holder.WriteTableHolder; +import org.apache.poi.ss.usermodel.Row; + +public class MaterialHazardousLedgerHeadHandler implements RowWriteHandler { + + @Override + public void afterRowDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Integer relativeRowIndex, Boolean isHead) { + /*if (!isHead || relativeRowIndex != 0) { + return; + } + + var sheet = writeSheetHolder.getSheet(); + + // 第一行:大标题 + var titleRow = sheet.getRow(0); + var titleCell = titleRow.createCell(0); + titleCell.setCellValue("云铜检测危化品管理台账"); + + // 第二行:基础信息和储存情况 + var row2 = sheet.getRow(1); + var baseInfoCell = row2.createCell(0); + baseInfoCell.setCellValue("基础信息"); + + var storageInfoCell = row2.createCell(13); + storageInfoCell.setCellValue("储存情况"); + + // 第三行:详细表头 + var row3 = sheet.getRow(2); + String[] headers = {"序号", "单位", "名称", "物质", "危险特性", "英文名", "别名", + "危险类别", "是否剧毒", "CAS 号", "UN 号", "危规号", + "储存量合计", "化学分析室", "", "", "", "", + "综合分析室", "", "", "", "", + "试金分析室", "", "", "", "", + "易制爆", "易制毒", "备注"}; + + for (int i = 0; i < headers.length; i++) { + var cell = row3.createCell(i); + cell.setCellValue(headers[i]); + }*/ + // 只在写入表头的第 0 行时执行 + if (!isHead || relativeRowIndex != 0) { + return; + } + + var sheet = writeSheetHolder.getSheet(); + + // 1. 处理第 0 行(大标题) + var titleRow = sheet.getRow(0); + if (titleRow == null) { + titleRow = sheet.createRow(0); + } + var titleCell = titleRow.createCell(0); + titleCell.setCellValue("云铜检测危化品管理台账"); + + // 2. 处理第 1 行(基础信息、储存情况、易制爆、易制毒、备注) + var row2 = sheet.getRow(1); + if (row2 == null) { + row2 = sheet.createRow(1); + } + // 基础信息 (A列) + row2.createCell(0).setCellValue("基础信息"); + // 储存情况 (N列,即索引13) + row2.createCell(13).setCellValue("储存情况"); + // 易制爆 (AC列,索引28) + row2.createCell(28).setCellValue("易制爆"); + // 易制毒 (AD列,索引29) + row2.createCell(29).setCellValue("易制毒"); + // 备注 (AE列,索引30) + row2.createCell(30).setCellValue("备注"); + + // 3. 处理第 2 行(详细列头) + var row3 = sheet.getRow(2); + if (row3 == null) { + row3 = sheet.createRow(2); + } + String[] headers = { + "序号", "单位", "名称", "物质", "危险特性", "英文名", "别名", + "危险类别", "是否剧毒", "CAS 号", "UN 号", "危规号", + "储存量合计", "化学分析室", "", "", "", "", + "综合分析室", "", "", "", "", + "试金分析室", "", "", "", "", + "", "", "" // 易制爆、易制毒、备注在第二行已设置,这里留空 + }; + + for (int i = 0; i < headers.length; i++) { + var cell = row3.createCell(i); + cell.setCellValue(headers[i]); + } + } +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/handler/excel/MaterialHazardousLedgerStyleHandler.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/handler/excel/MaterialHazardousLedgerStyleHandler.java new file mode 100644 index 00000000..a8c3c1b0 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/handler/excel/MaterialHazardousLedgerStyleHandler.java @@ -0,0 +1,41 @@ +package com.zt.plat.module.qms.resource.material.handler.excel; + +import com.alibaba.excel.write.handler.SheetWriteHandler; +import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; +import org.apache.poi.ss.util.CellRangeAddress; + +public class MaterialHazardousLedgerStyleHandler implements SheetWriteHandler { + @Override + public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { + + var sheet = writeSheetHolder.getSheet(); + + // 合并大标题(第一行 A:AE,如果备注列需要可扩展到 AE) + sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 30)); + + // 基础信息:只合并第二行 A2:M2 + sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 12)); + + // 储存情况:只合并第二行 N2:AB2(避开 AC、AD、AE) + sheet.addMergedRegion(new CellRangeAddress(1, 1, 13, 27)); + + // 化学分析室:合并第三行 N3:R3 + sheet.addMergedRegion(new CellRangeAddress(2, 2, 13, 17)); + + // 综合分析室:合并第三行 S3:W3 + sheet.addMergedRegion(new CellRangeAddress(2, 2, 18, 22)); + + // 试金分析室:合并第三行 X3:AB3 + sheet.addMergedRegion(new CellRangeAddress(2, 2, 23, 27)); + + // 易制爆:合并第二行到第三行的 AC 列 (AC2:AC3) + sheet.addMergedRegion(new CellRangeAddress(1, 2, 28, 28)); + + // 易制毒:合并第二行到第三行的 AD 列 (AD2:AD3) + sheet.addMergedRegion(new CellRangeAddress(1, 2, 29, 29)); + + // 备注:合并第二行到第三行的 AE 列 (AE2:AE3) + sheet.addMergedRegion(new CellRangeAddress(1, 2, 30, 30)); + } +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java index eee28320..729f0afc 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java @@ -44,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import java.math.BigDecimal; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; @@ -527,7 +528,6 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { if (CollUtil.isEmpty(importList)) throw new ServiceException(1_032_160_000, "导入数据不能为空"); log.info("导入数据:{}", importList); List successBatchNos = new ArrayList<>(); - Map failureBatches = new LinkedHashMap<>(); // 检验 for (MaterialBatchImportExcelVO batch : importList) { if (StrUtil.isEmpty(batch.getProductCode())) throw new ServiceException(1_032_160_000, "物料编码不能为空"); @@ -552,10 +552,12 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { } // 获取供应商 Set supplierNames = importList.stream().map(MaterialBatchImportExcelVO::getSupplier).filter(Objects::nonNull).collect(Collectors.toSet()); + List suppliers; + Map supplierDOMapByName = Map.of(); if (CollUtil.isNotEmpty(supplierNames)) { - List suppliers = supplierService.getSuppliersByNames(new ArrayList<>(supplierNames)); + suppliers = supplierService.getSuppliersByNames(new ArrayList<>(supplierNames)); if (CollUtil.isEmpty(suppliers)) throw new ServiceException(1_032_160_000, "未找到对应的供应商"); - Map supplierDOMapByName = suppliers.stream().collect(Collectors.toMap(SupplierDO::getName, Function.identity())); + supplierDOMapByName = suppliers.stream().collect(Collectors.toMap(SupplierDO::getName, Function.identity())); if (supplierNames.size() != suppliers.size()) { List notFoundNames = new ArrayList<>(); for (String supplierName : supplierNames) { @@ -568,11 +570,39 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { } } } + // 保存批次 + Map finalSupplierDOMapByName = supplierDOMapByName; + List batchDOS = importList.stream().map(importBat -> { + MaterialProductDO productDO = productDOMapByCode.get(importBat.getProductCode()); + LocalDate manufacturerDate = importBat.getManufacturerDate(); + MaterialBatchDO batchDO = new MaterialBatchDO() + .setParentId(0L) + .setProductId(productDO.getId()) + .setBatchNo(sequenceUtil.genCode(MaterialConstants.SEQUENCE_BATCH_KEY)) + .setInboundQuantity(importBat.getInboundQuantity()) + .setRemaineQuantity(importBat.getInboundQuantity()) + .setAcceptanceStatus(MaterialAcceptStatus.not_accepted.name()) + .setSubmitStatus(0) + .setManufacturerDate(manufacturerDate) + .setLocation(importBat.getLocation()) + .setRemark(importBat.getRemark()); + SupplierDO supplierDO = finalSupplierDOMapByName.get(importBat.getSupplier()); + batchDO.setSupplierId(supplierDO == null ? null : supplierDO.getId()); + // 处理到期日期 + LocalDate importDueDate = importBat.getDueDate(); + Integer due = productDO.getDue(); + if (importDueDate != null) { + batchDO.setDueDate(importDueDate); + } else if (manufacturerDate != null && due != null){ + batchDO.setDueDate(manufacturerDate.plusDays(due)); + } + successBatchNos.add(batchDO.getBatchNo()); + return batchDO; + }).toList(); + materialBatchMapper.insertBatch(batchDOS); return new MaterialBatchImportRespVO() .setSuccessBatchNos(successBatchNos) - .setFailureBatches(failureBatches) - .setSuccessCount(successBatchNos.size()) - .setFailureCount(failureBatches.size()); + .setSuccessCount(successBatchNos.size()); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java index 3c29389e..f2693854 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java @@ -10,6 +10,7 @@ import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomation 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.query.MaterialInfomationQueryVO; +import com.zt.plat.module.qms.resource.material.controller.vo.resp.MaterialInfomationLedgerRespVO; import com.zt.plat.module.qms.resource.material.dal.dataobject.*; import jakarta.validation.*; import com.zt.plat.framework.common.pojo.PageResult; @@ -214,4 +215,12 @@ public interface MaterialInfomationService { //查询需要“期间核查”的物料列表 List getListNeedByRule(JSONObject params); + + /** + * 获取物料库存台账 + * + * @param pageReqVO 分页参数 + * @return 物料库存台账 + */ + PageResult getMaterialInventoryLedgerPage(@Valid MaterialInfomationPageReqVO pageReqVO); } \ 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 22c519ae..6c0e2dd2 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 @@ -5,8 +5,11 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.exception.ServiceException; +import com.zt.plat.framework.common.pojo.CommonResult; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigWarehouseLocationDO; +import com.zt.plat.module.qms.business.config.service.ConfigWarehouseLocationService; import com.zt.plat.module.qms.core.code.SequenceUtil; import com.zt.plat.module.qms.enums.AdjustType; import com.zt.plat.module.qms.enums.LockType; @@ -15,11 +18,15 @@ import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomation 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.query.MaterialInfomationQueryVO; +import com.zt.plat.module.qms.resource.material.controller.vo.resp.MaterialInfomationLedgerRespVO; import com.zt.plat.module.qms.resource.material.dal.dataobject.*; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInfomationMapper; import com.zt.plat.module.qms.resource.material.enums.MaterialInfomationOrigin; +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; @@ -51,6 +58,10 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService private SequenceUtil sequenceUtil; @Autowired private MaterialProductService materialProductService; + @Autowired + private DeptApi deptApi; + @Autowired + private ConfigWarehouseLocationService configWarehouseLocationService; @Override public MaterialInfomationRespVO createMaterialInfomation(MaterialInfomationSaveReqVO createReqVO) { @@ -340,4 +351,100 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService public List getListNeedByRule(JSONObject params) { return materialInfomationMapper.getListNeedByRule(params); } + + @Override + public PageResult getMaterialInventoryLedgerPage(MaterialInfomationPageReqVO pageReqVO) { + // 获取主信息 + PageResult result = materialInfomationMapper.selectInventoryLedgerPage(pageReqVO); + List list = result.getList(); + if (CollUtil.isEmpty(list)) return result; + // 大类信息 + enrichProductInfo(list); + + // 部门信息(包括上级部门) + enrichDepartmentInfo(list); + + // 存放位置信息 + enrichLocationInfo(list); + + // 累加上级部门库存数量 + calculateSuperiorDepartmentInventory(list); + + return result.setList(list); + } + + private void calculateSuperiorDepartmentInventory(List list) { + // 按上级部门 ID 分组,统计每个上级部门的总库存 + Map superiorDeptInventoryMap = list.stream() + .filter(item -> item.getSuperiorDepartmentId() != null) + .collect(Collectors.groupingBy( + MaterialInfomationLedgerRespVO::getSuperiorDepartmentId, + Collectors.reducing( + BigDecimal.ZERO, + MaterialInfomationLedgerRespVO::getAssignDepartmentInventoryQuantity, + BigDecimal::add + ) + )); + + // 将累加结果设置到每条记录中 + list.forEach(item -> { + BigDecimal totalInventory = superiorDeptInventoryMap.get(item.getSuperiorDepartmentId()); + item.setInventoryQuantity(totalInventory != null ? totalInventory : BigDecimal.ZERO); + }); + } + + private void enrichLocationInfo(List list) { + // 存放位置信息 + List locationIds = list.stream().map(MaterialInfomationLedgerRespVO::getLocationId).toList(); + if (CollUtil.isEmpty(locationIds)) return; + List locationDOS = configWarehouseLocationService.getListByIds(locationIds); + if (CollUtil.isEmpty(locationDOS)) return; + Map locationMap = locationDOS.stream().collect(Collectors.toMap(ConfigWarehouseLocationDO::getId, Function.identity())); + list.forEach(item -> { + ConfigWarehouseLocationDO locationDO = locationMap.get(item.getLocationId()); + item.setLocationName(locationDO.getName()) + .setLocationCode(locationDO.getCode()); + }); + } + + private void enrichDepartmentInfo(List list) { + // 部门信息 + List deptIds = list.stream().map(MaterialInfomationLedgerRespVO::getAssignDepartmentId).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()); + }); + 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 deptPrn = deptPrnMap.get(dept.getParentId()); + item.setSuperiorDepartmentId(deptPrn.getId()).setSuperiorDepartmentName(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 ; + 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()); + }); + } } \ 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/MaterialProductService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java index 65999bc7..9fbb4a7c 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java @@ -9,7 +9,6 @@ import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO import jakarta.validation.Valid; import java.util.List; -import java.util.Set; /** * 物料大类 Service 接口 diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java index 8e80d3f3..4a5d3627 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java @@ -11,11 +11,9 @@ import com.zt.plat.framework.common.pojo.CommonResult; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; -import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX; import com.zt.plat.module.infra.api.businessfile.dto.BusinessFileWithUrlRespDTO; import com.zt.plat.module.qms.common.service.BusinessFileService; import com.zt.plat.module.qms.core.constant.DataTypeConstant; -import com.zt.plat.module.qms.enums.QmsCommonConstant; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductSaveReqVO; 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 new file mode 100644 index 00000000..da2d8ace --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/utils/ComplexExcelUtils.java @@ -0,0 +1,36 @@ +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.handler.excel.MaterialHazardousLedgerHeadHandler; +import com.zt.plat.module.qms.resource.material.handler.excel.MaterialHazardousLedgerStyleHandler; +import jakarta.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.List; + +public class ComplexExcelUtils { + public static void writeHazardousLedger(HttpServletResponse response, + String filename, String sheetName, + List dataList) throws IOException { + // 创建 ExcelWriter + EasyExcel.write(response.getOutputStream(), MaterialHazardousLedgerExportVO.class) + .autoCloseStream(false) + .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + // 注册自定义表头处理器 + .registerWriteHandler(new MaterialHazardousLedgerHeadHandler()) + // 注册自定义样式处理器 + .registerWriteHandler(new MaterialHazardousLedgerStyleHandler()) + .sheet(sheetName) + .doWrite(dataList); + + // 设置响应头 + response.addHeader("Content-Disposition", "attachment;filename=" + + URLEncoder.encode(filename, StandardCharsets.UTF_8)); + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); + } + +}