aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelineMoController.java
@@ -53,8 +53,8 @@ @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { int i = apsGasPipelineMoService.batchInsertGasPipelineMo(file); return toAjax(i); apsGasPipelineMoService.batchInsertGasPipelineMo(file); return toAjax(true); } /** aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelinePredictionController.java
@@ -1,30 +1,22 @@ package com.aps.core.controller.mainPlan; import java.util.List; import com.aps.common.core.utils.poi.ExcelUtil; import com.aps.common.core.web.controller.BaseController; import com.aps.common.core.web.domain.AjaxResult; import com.aps.common.core.web.page.TableDataInfo; import com.aps.core.domain.ApsGasPipelineMo; import com.aps.common.log.annotation.Log; import com.aps.common.log.enums.BusinessType; import com.aps.common.security.annotation.RequiresPermissions; import com.aps.core.domain.ApsGasPipelinePrediction; import com.aps.core.service.IApsGasPipelinePredictionService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.aps.common.log.annotation.Log; import com.aps.common.log.enums.BusinessType; import com.aps.common.security.annotation.RequiresPermissions; import com.aps.common.core.web.controller.BaseController; import com.aps.common.core.web.domain.AjaxResult; import com.aps.common.core.utils.poi.ExcelUtil; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.util.List; /** * 管路手工气体预测数据Controller @@ -61,8 +53,8 @@ @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { int i = apsGasPipelinePredictionService.batchInsertApsGasPipelinePrediction(file); return toAjax(i); apsGasPipelinePredictionService.batchInsertApsGasPipelinePrediction(file); return toAjax(true); } /** * 导出管路手工气体预测数据列表 aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsMaterialProductGroupManagementController.java
@@ -53,8 +53,8 @@ @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { int i = apsMaterialProductGroupManagementService.batchInsertApsMaterialProductGroupManagement(file); return toAjax(i); apsMaterialProductGroupManagementService.batchInsertApsMaterialProductGroupManagement(file); return toAjax(true); } /** * 导出物料产品组数据管理列表 aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipelinePrediction.java
@@ -2,13 +2,19 @@ import com.aps.common.core.annotation.Excel; import com.aps.common.core.web.domain.BaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.data.annotation.Id; import java.math.BigDecimal; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * 管路手工气体预测数据对象 aps_gas_pipeline_prediction @@ -49,4 +55,16 @@ @Schema(description = "数量") private BigDecimal predictQuantity; @JsonIgnore @TableField(exist = false) private String key; public String getKey() { if (key == null) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); key = getFactory() + "##" + getMaterialCode() + "##" + sdf.format(getPredictDate()); } return key; } } aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsMaterialProductGroupManagement.java
@@ -1,7 +1,9 @@ package com.aps.core.domain; import com.aps.common.core.web.domain.BaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -11,14 +13,13 @@ /** * 物料产品组数据管理对象 aps_material_product_group_management * * * @author ruoyi * @date 2025-05-19 */ @Schema(description = "物料产品组数据管理实体类") @Data public class ApsMaterialProductGroupManagement extends BaseEntity { public class ApsMaterialProductGroupManagement extends BaseEntity { private static final long serialVersionUID = 1L; @Id @@ -27,104 +28,113 @@ @Schema(description = "ID") private Long id; /** 适用工厂 参考 aps_factory */ /** * 适用工厂 参考 aps_factory */ @Excel(name = "适用工厂 参考 aps_factory") @Schema(description = "适用工厂 参考 aps_factory") private String factory; /** 料号 */ /** * 料号 */ @Excel(name = "料号") @Schema(description = "料号") private String materialCode; /** 专业 参考 aps_domain */ /** * 专业 参考 aps_domain */ @Excel(name = "专业 参考 aps_domain") @Schema(description = "专业 参考 aps_domain") private String domain; /** 是否为主阶 是/否 */ /** * 是否为主阶 是/否 */ @Excel(name = "是否为主阶 是/否") @Schema(description = "是否为主阶 是/否") private String isMain; /** 料号类别 制造件/采购件 */ @JsonIgnore @TableField(exist = false) private String key; public String getKey() { if (key == null) { key = getFactory() + "##" + getMaterialCode(); } return key; } /** * 料号类别 制造件/采购件 */ @Excel(name = "料号类别 制造件/采购件") @Schema(description = "料号类别 制造件/采购件") private String materialType; public void setId(Long id) { public void setId(Long id) { this.id = id; } public Long getId() { public Long getId() { return id; } public void setFactory(String factory) { public void setFactory(String factory) { this.factory = factory; } public String getFactory() { public String getFactory() { return factory; } public void setMaterialCode(String materialCode) { public void setMaterialCode(String materialCode) { this.materialCode = materialCode; } public String getMaterialCode() { public String getMaterialCode() { return materialCode; } public void setDomain(String domain) { public void setDomain(String domain) { this.domain = domain; } public String getDomain() { public String getDomain() { return domain; } public void setIsMain(String isMain) { public void setIsMain(String isMain) { this.isMain = isMain; } public String getIsMain() { public String getIsMain() { return isMain; } public void setMaterialType(String materialType) { public void setMaterialType(String materialType) { this.materialType = materialType; } public String getMaterialType() { public String getMaterialType() { return materialType; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("factory", getFactory()) .append("materialCode", getMaterialCode()) .append("domain", getDomain()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("isMain", getIsMain()) .append("materialType", getMaterialType()) .toString(); return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("factory", getFactory()) .append("materialCode", getMaterialCode()) .append("domain", getDomain()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("isMain", getIsMain()) .append("materialType", getMaterialType()) .toString(); } } aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipelinePredictionMapper.java
@@ -74,18 +74,13 @@ select id, factory || '##' || material_code || '##' || TO_CHAR(predict_date, 'yyyy-MM') as key from aps_gas_pipeline_prediction where 1 = 0 <if test="!facs.isEmpty()">or factory in <foreach collection="facs" item="item" open="(" separator="," close=")"> <if test="!keys.isEmpty()">or factory || '##' || material_code || '##' || TO_CHAR(predict_date, 'yyyy-MM') in <foreach collection="keys" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="!facs.isEmpty()">or material_code in <foreach collection="codes" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </foreach> </if> </script> """) List<Map<String, Object>> selectByFacOrMaterial(@NotNull Set<String> facs, @NotNull Set<String> codes); List<Map<String, Object>> selectByFacOrMaterial(@NotNull Set<String> keys); } aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsMaterialProductGroupManagementMapper.java
@@ -71,17 +71,12 @@ <script> select distinct factory || '##' || material_code from aps_material_product_group_management where 1 = 0 <if test="!facs.isEmpty()">or factory in <foreach collection="facs" item="item" open="(" separator="," close=")"> <if test="!keys.isEmpty()">or factory || '##' || material_code in <foreach collection="keys" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="!facs.isEmpty()">or material_code in <foreach collection="codes" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </foreach> </if> </script> """) Set<String> selectByFacOrMaterial(@NotNull Set<String> facs, @NotNull Set<String> codes); Set<String> selectByFacOrMaterial(@NotNull Set<String> keys); } aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelinePredictionServiceImpl.java
@@ -22,6 +22,7 @@ import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; /** @@ -112,9 +113,9 @@ int rows = sheet.getLastRowNum(); if (rows > 0) { List<ApsGasPipelinePrediction> list = new ArrayList<>(); Set<String> keys = new HashSet<>(); /*数据列从1开始*/ for (int i = 1; i <= rows; i++) { for (int i = rows; i > 0; --i) { Row row = sheet.getRow(i); if (row.getCell(0) == null) { continue; @@ -137,32 +138,31 @@ item.setCreateTime(DateUtils.getNowDate()); item.setPredictQuantity(new BigDecimal(quantity)); item.setPredictDate(new Timestamp(date.getTime())); list.add(item); if (!keys.contains(item.getKey())) { keys.add(item.getKey()); list.add(item); } } } if (!list.isEmpty()) { List<Map<String, Object>> facCodeKey = apsGasPipelinePredictionMapper.selectByFacOrMaterial( list.stream().map(ApsGasPipelinePrediction::getFactory).collect(Collectors.toSet()), list.stream().map(ApsGasPipelinePrediction::getMaterialCode).collect(Collectors.toSet()) ); List<Map<String, Object>> facCodeKey = apsGasPipelinePredictionMapper.selectByFacOrMaterial(keys); if (!facCodeKey.isEmpty()) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); Iterator<ApsGasPipelinePrediction> it = list.iterator(); while (it.hasNext()) { ApsGasPipelinePrediction item = it.next(); String key = item.getFactory() + "##" + item.getMaterialCode() + "##" + sdf.format(item.getPredictDate()); facCodeKey.stream() .filter(map -> map.get("key").equals(key)) .forEach(row -> { long count = facCodeKey.stream() .filter(map -> map.get("key").equals(item.getKey())) .peek(row -> { item.setId((Long) row.get("id")); item.setCreateBy(null); item.setCreateTime(null); item.setUpdateBy(SecurityUtils.getUsername()); item.setUpdateTime(new Timestamp(System.currentTimeMillis())); apsGasPipelinePredictionMapper.updateById(item); it.remove(); }); }).count(); if (count > 0){ it.remove(); } } } if (!list.isEmpty()) { aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsMaterialProductGroupManagementServiceImpl.java
@@ -123,7 +123,8 @@ List<ApsMaterialProductGroupManagement> list = new ArrayList<>(); /*数据列从1开始*/ for (int i = 1; i <= rows; i++) { Set<String> keys = new HashSet<>(); for (int i = rows; i > 0; --i) { Row row = sheet.getRow(i); if (row.getCell(0) == null) { continue; @@ -149,20 +150,19 @@ item.setIsMain(isMain); item.setCreateBy(SecurityUtils.getUsername()); item.setCreateTime(DateUtils.getNowDate()); list.add(item); if (!keys.contains(item.getKey())) { keys.add(item.getKey()); list.add(item); } } } if (!list.isEmpty()) { Set<String> facCodeKey = apsMaterialProductGroupManagementMapper.selectByFacOrMaterial( list.stream().map(ApsMaterialProductGroupManagement::getFactory).collect(Collectors.toSet()), list.stream().map(ApsMaterialProductGroupManagement::getMaterialCode).collect(Collectors.toSet()) ); Set<String> facCodeKey = apsMaterialProductGroupManagementMapper.selectByFacOrMaterial(keys); if (!facCodeKey.isEmpty()) { Iterator<ApsMaterialProductGroupManagement> it = list.iterator(); while (it.hasNext()) { ApsMaterialProductGroupManagement item = it.next(); String key = item.getFactory() + "##" + item.getMaterialCode(); if (facCodeKey.contains(key)) { if (facCodeKey.contains(item.getKey())) { LambdaUpdateWrapper<ApsMaterialProductGroupManagement> wrapper = new LambdaUpdateWrapper<>(); wrapper.eq(ApsMaterialProductGroupManagement::getFactory, item.getFactory()); wrapper.eq(ApsMaterialProductGroupManagement::getMaterialCode, item.getMaterialCode());