aps-common/aps-common-security/src/main/java/com/aps/common/security/utils/DictUtils.java
@@ -1,29 +1,31 @@ package com.aps.common.security.utils; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; import com.alibaba.fastjson2.JSONArray; import com.aps.common.core.constant.CacheConstants; import com.aps.common.core.utils.SpringUtils; import com.aps.common.core.utils.StringUtils; import com.aps.common.redis.service.RedisService; import com.aps.system.api.domain.SysDictData; import org.springframework.util.CollectionUtils; /** * åå ¸å·¥å ·ç±» * * @author ruoyi */ public class DictUtils { public class DictUtils { /** * 设置åå ¸ç¼å * * @param key åæ°é® * @param dictDatas åå ¸æ°æ®å表 */ public static void setDictCache(String key, List<SysDictData> dictDatas) { public static void setDictCache(String key, List<SysDictData> dictDatas) { SpringUtils.getBean(RedisService.class).setCacheObject(getCacheKey(key), dictDatas); } @@ -33,11 +35,9 @@ * @param key åæ°é® * @return dictDatas åå ¸æ°æ®å表 */ public static List<SysDictData> getDictCache(String key) { public static List<SysDictData> getDictCache(String key) { JSONArray arrayCache = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key)); if (StringUtils.isNotNull(arrayCache)) { if (StringUtils.isNotNull(arrayCache)) { return arrayCache.toList(SysDictData.class); } return null; @@ -48,16 +48,14 @@ * * @param key åå ¸é® */ public static void removeDictCache(String key) { public static void removeDictCache(String key) { SpringUtils.getBean(RedisService.class).deleteObject(getCacheKey(key)); } /** * æ¸ ç©ºåå ¸ç¼å */ public static void clearDictCache() { public static void clearDictCache() { Collection<String> keys = SpringUtils.getBean(RedisService.class).keys(CacheConstants.SYS_DICT_KEY + "*"); SpringUtils.getBean(RedisService.class).deleteObject(keys); } @@ -68,8 +66,35 @@ * @param configKey åæ°é® * @return ç¼åé®key */ public static String getCacheKey(String configKey) { public static String getCacheKey(String configKey) { return CacheConstants.SYS_DICT_KEY + configKey; } public static interface CacheValue{ String get(String label); } /** * æ ¹æ®åå ¸ç±»åååå ¸æ ç¾è·ååå ¸å¼ * * @param dictType * @return */ public static CacheValue getCacheValue(String dictType) { List<SysDictData> cacheData = StringUtils.isEmpty(dictType) ? Collections.emptyList() : getDictCache(dictType); return label -> { if (CollectionUtils.isEmpty(cacheData)){ return null; } if(StringUtils.isEmpty(label)){ return null; } return cacheData.stream().filter(item -> Objects.equals(item.getDictLabel(), label)) .findFirst() .map(SysDictData::getDictValue) .orElse(null); }; } } aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsGasPipelineCapacityPlanController.java
@@ -10,8 +10,10 @@ import com.aps.common.security.annotation.RequiresPermissions; import com.aps.common.security.utils.SecurityUtils; import com.aps.core.domain.ApsGasPipelineCapacityPlan; import com.aps.core.domain.ApsShop; import com.aps.core.domain.ApsStandardProcess; import com.aps.core.service.IApsGasPipelineCapacityPlanService; import com.aps.core.service.IApsShopService; import com.aps.core.service.IApsStandardProcessService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Objects; @@ -40,6 +43,9 @@ @Autowired private IApsStandardProcessService apsStandardProcessService; @Autowired private IApsShopService apsShopService; /** * æ¥è¯¢æ°ä½ç®¡è·¯äº§è½è§åå表 */ @@ -53,20 +59,30 @@ apsStandardProcess.setMajor(apsGasPipelineCapacityPlan.getMajor()); apsStandardProcess.setPlant(apsGasPipelineCapacityPlan.getOrgCode()); List<ApsStandardProcess> processList = apsStandardProcessService.selectApsStandardProcessListAll(apsStandardProcess); List<ApsShop> apsShops = apsShopService.findShopByFactory(apsGasPipelineCapacityPlan.getOrgCode()); if (list.isEmpty()) { for (ApsStandardProcess apsStandardProcessTemp : processList) { ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlanTemp = new ApsGasPipelineCapacityPlan(); apsGasPipelineCapacityPlanTemp.setProcessName(apsStandardProcessTemp.getProcessName()); apsGasPipelineCapacityPlanTemp.setOrgCode(apsStandardProcessTemp.getPlant()); apsGasPipelineCapacityPlanTemp.setWorkshop(apsStandardProcessTemp.getWorkShop()); apsGasPipelineCapacityPlanTemp.setWorkshop(apsShops.stream() .filter(shop -> Objects.equals(shop.getShopName(), apsStandardProcessTemp.getWorkShop())) .map(ApsShop::getShopCode) .findFirst() .orElse(null)); list.add(apsGasPipelineCapacityPlanTemp); } } else { list.forEach(item -> { processList.stream().filter(p -> Objects.equals(p.getPlant(), item.getOrgCode())) .filter(p -> Objects.equals(p.getProcessName(), item.getProcessName())) list.forEach(capacityPlan -> { processList.stream().filter(p -> Objects.equals(p.getPlant(), capacityPlan.getOrgCode())) .filter(p -> Objects.equals(p.getMajor(), capacityPlan.getMajor())) .filter(p -> p.getWorkShop() != null) .findFirst().ifPresent(p -> { item.setWorkshop(p.getWorkShop()); capacityPlan.setWorkshop(apsShops.stream() .filter(shop -> Objects.equals(shop.getShopCode(), p.getWorkShop())) .map(ApsShop::getShopName) .findFirst() .orElse(null)); }); }); } @@ -84,15 +100,19 @@ newProcess.add(apsStandardProcessTemp); } } for (ApsStandardProcess processName : newProcess) { for (ApsStandardProcess process : newProcess) { ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlanTemp = new ApsGasPipelineCapacityPlan(); apsGasPipelineCapacityPlanTemp.setProcessName(processName.getProcessName()); apsGasPipelineCapacityPlanTemp.setOrgCode(processName.getPlant()); apsGasPipelineCapacityPlanTemp.setWorkshop(processName.getWorkShop()); apsGasPipelineCapacityPlanTemp.setProcessName(process.getProcessName()); apsGasPipelineCapacityPlanTemp.setOrgCode(process.getPlant()); apsGasPipelineCapacityPlanTemp.setWorkshop(apsShops.stream() .filter(shop -> Objects.equals(shop.getShopName(), process.getWorkShop())) .map(ApsShop::getShopCode) .findFirst() .orElse(null)); list.add(apsGasPipelineCapacityPlanTemp); } } list.sort((a, b) -> a.getProcessName().compareTo(b.getProcessName())); list.sort(Comparator.comparing(ApsGasPipelineCapacityPlan::getProcessName)); return getDataTable(list); } aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsStandardProcessController.java
@@ -7,16 +7,35 @@ 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.security.utils.DictUtils; import com.aps.core.domain.ApsShop; import com.aps.core.domain.ApsStandardProcess; import com.aps.core.service.IApsShopService; import com.aps.core.service.IApsStandardProcessService; import com.aps.system.api.domain.SysDictData; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.SneakyThrows; import org.apache.commons.io.IOUtils; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; /** * æ åå·¥åºController @@ -29,10 +48,12 @@ @Tag(name = "æ åå·¥åº", description = "æ åå·¥åºæ¥å£") @RestController @RequestMapping("/standardProcess") public class ApsStandardProcessController extends BaseController { public class ApsStandardProcessController extends BaseController { @Autowired private IApsStandardProcessService apsStandardProcessService; @Autowired IApsShopService apsShopService; /** * æ¥è¯¢æ åå·¥åºå表 @@ -40,10 +61,19 @@ @Operation(summary = "æ¥è¯¢æ åå·¥åºå表", description = "å页æ¥è¯¢") @RequiresPermissions("aps:standardProcess:list") @GetMapping("/list") public TableDataInfo list(ApsStandardProcess apsStandardProcess) { public TableDataInfo list(ApsStandardProcess apsStandardProcess) { startPage(); List<ApsStandardProcess> list = apsStandardProcessService.selectApsStandardProcessList(apsStandardProcess); List<ApsShop> apsShops = apsShopService.findShopByCodes(list.stream().map(ApsStandardProcess::getWorkShop) .filter(Objects::nonNull) .collect(Collectors.toSet())); list.forEach(temp -> { temp.setWorkShop(apsShops.stream() .filter(tempShop -> Objects.equals(tempShop.getShopCode(), temp.getWorkShop())) .map(ApsShop::getShopName) .findFirst() .orElse(null)); }); return getDataTable(list); } @@ -54,8 +84,7 @@ @RequiresPermissions("aps:standardProcess:export") @Log(title = "æ åå·¥åº", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ApsStandardProcess apsStandardProcess) { public void export(HttpServletResponse response, ApsStandardProcess apsStandardProcess) { List<ApsStandardProcess> list = apsStandardProcessService.selectApsStandardProcessList(apsStandardProcess); ExcelUtil<ApsStandardProcess> util = new ExcelUtil<ApsStandardProcess>(ApsStandardProcess.class); util.exportExcel(response, list, "æ åå·¥åºæ°æ®"); @@ -67,8 +96,7 @@ @Operation(summary = "è·åæ åå·¥åºè¯¦ç»ä¿¡æ¯", description = "æ ¹æ®idè·å") @RequiresPermissions("aps:standardProcess:query") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { public AjaxResult getInfo(@PathVariable("id") Long id) { return success(apsStandardProcessService.selectApsStandardProcessById(id)); } @@ -79,8 +107,7 @@ @RequiresPermissions("aps:standardProcess:add") @Log(title = "æ åå·¥åº", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ApsStandardProcess apsStandardProcess) { public AjaxResult add(@RequestBody ApsStandardProcess apsStandardProcess) { return toAjax(apsStandardProcessService.insertApsStandardProcess(apsStandardProcess)); } @@ -91,8 +118,7 @@ @RequiresPermissions("aps:standardProcess:edit") @Log(title = "æ åå·¥åº", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody ApsStandardProcess apsStandardProcess) { public AjaxResult edit(@RequestBody ApsStandardProcess apsStandardProcess) { return toAjax(apsStandardProcessService.updateApsStandardProcess(apsStandardProcess)); } @@ -103,8 +129,7 @@ @RequiresPermissions("aps:standardProcess:remove") @Log(title = "æ åå·¥åº", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(apsStandardProcessService.deleteApsStandardProcessByIds(ids)); } @@ -112,7 +137,7 @@ * å¯¼å ¥æ åå·¥åºæ°æ® */ @Operation(summary = "å¯¼å ¥æ åå·¥åºæ°æ®", description = "å¢éå¯¼å ¥") @RequiresPermissions("aps:standardProcess:importData") // @RequiresPermissions("aps:standardProcess:importData") @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { ExcelUtil<ApsStandardProcess> util = new ExcelUtil<>(ApsStandardProcess.class); @@ -136,9 +161,72 @@ @Operation(summary = "æ ¹æ®è½¦é´æ¥è¯¢æ åå·¥åºå表", description = "å ¨éæ¥è¯¢") @RequiresPermissions("aps:standardProcess:listByWorkShop") @GetMapping("/listByWorkShop") public TableDataInfo listByWorkShop(ApsStandardProcess apsStandardProcess) { public TableDataInfo listByWorkShop(ApsStandardProcess apsStandardProcess) { List<ApsStandardProcess> list = apsStandardProcessService.selectApsStandardProcessList(apsStandardProcess); return getDataTable(list); } /** * ä¸è½½æ åå·¥åºæ°æ®å¯¼å ¥æ¨¡æ¿ */ @SneakyThrows @Operation(summary = "ä¸è½½æ åå·¥åºæ°æ®å¯¼å ¥æ¨¡æ¿", description = "ä¸è½½æ åå·¥åºæ°æ®å¯¼å ¥æ¨¡æ¿") // @RequiresPermissions("gasPipeline:prediction:template") // @Log(title = "ä¸è½½æ°ä½é¢æµæ°æ®å¯¼å ¥æ¨¡æ¿", businessType = BusinessType.EXPORT) @GetMapping("/template") public ResponseEntity<ByteArrayResource> exportTemplate() { byte[] file = IOUtils.resourceToByteArray("/templates/æ åå·¥åºæ°æ®æ¨¡æ¿v1.0.xlsx"); Workbook workbook = WorkbookFactory.create(new ByteArrayInputStream(file)); Sheet sheet = workbook.getSheet("åå ¸-å·¥å"); List<SysDictData> sysDictDataList = DictUtils.getDictCache("aps_factory"); boolean changed = false; if (sysDictDataList != null) { for (int i = 0; i < sysDictDataList.size(); i++) { Row row = sheet.createRow(i + 1); row.createCell(0).setCellValue(sysDictDataList.get(i).getDictValue()); row.createCell(1).setCellValue(sysDictDataList.get(i).getDictLabel()); } sheet = workbook.getSheet("åå ¸-车é´"); List<ApsShop> shops = apsShopService.findAllShops(); for (int i = 0; i < shops.size(); i++) { Row row = sheet.createRow(i + 1); ApsShop shop = shops.get(i); row.createCell(0).setCellValue(sysDictDataList .stream() .filter(d -> d.getDictValue().equals(shop.getPlantCode())) .map(SysDictData::getDictLabel) .findFirst() .orElse(null)); row.createCell(1).setCellValue(shops.get(i).getShopCode()); row.createCell(2).setCellValue(shops.get(i).getShopName()); } changed = true; } sheet = workbook.getSheet("åå ¸-ä¸ä¸"); sysDictDataList = DictUtils.getDictCache("aps_domain"); if (sysDictDataList != null) { for (int i = 0; i < sysDictDataList.size(); i++) { Row row = sheet.createRow(i + 1); row.createCell(0).setCellValue(sysDictDataList.get(i).getDictValue()); row.createCell(1).setCellValue(sysDictDataList.get(i).getDictLabel()); } changed = true; } if (changed) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); workbook.write(baos); file = baos.toByteArray(); } workbook.close(); ByteArrayResource resource = new ByteArrayResource(file); return ResponseEntity.ok() .header("Access-Control-Expose-Headers", HttpHeaders.CONTENT_DISPOSITION) .header(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment;filename=%s", URLEncoder.encode("æ°ä½é¢æµæ°æ®æ¨¡æ¿.xlsx", StandardCharsets.UTF_8))) .header(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") .contentLength(file.length) .body(resource); } } aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelineMoController.java
@@ -7,13 +7,19 @@ 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.security.utils.DictUtils; import com.aps.core.domain.ApsGasPipelineMo; import com.aps.core.service.IApsGasPipelineMoService; import com.aps.system.api.domain.SysDictData; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.SneakyThrows; import org.apache.commons.io.IOUtils; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.http.HttpHeaders; @@ -21,6 +27,8 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; @@ -56,7 +64,7 @@ @Operation(summary = "å¯¼å ¥ç®¡è·¯æå·¥æ°ä½å·¥åæ°æ®", description = "æ¹éå¯¼å ¥") @Log(title = "å¯¼å ¥ç®¡è·¯æå·¥æ°ä½å·¥åæ°æ®", businessType = BusinessType.IMPORT) @RequiresPermissions("gasPipeline:mo:import") // @RequiresPermissions("gasPipeline:mo:import") @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { @@ -135,6 +143,20 @@ @GetMapping("/template") public ResponseEntity<ByteArrayResource> exportTemplate() { byte[] file = IOUtils.resourceToByteArray("/templates/æ°ä½å·¥åæ°æ®æ¨¡æ¿v1.0.xlsx"); Workbook workbook = WorkbookFactory.create(new ByteArrayInputStream(file)); Sheet sheet = workbook.getSheet("åå ¸-ç产åºå°"); List<SysDictData> sysDictDataList = DictUtils.getDictCache("aps_factory"); if (sysDictDataList != null) { for (int i = 0; i < sysDictDataList.size(); i++) { Row row = sheet.createRow(i + 1); row.createCell(0).setCellValue(sysDictDataList.get(i).getDictValue()); row.createCell(1).setCellValue(sysDictDataList.get(i).getDictLabel()); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); workbook.write(baos); file = baos.toByteArray(); } workbook.close(); ByteArrayResource resource = new ByteArrayResource(file); return ResponseEntity.ok() .header("Access-Control-Expose-Headers", HttpHeaders.CONTENT_DISPOSITION) aps-modules/aps-core/src/main/java/com/aps/core/controller/mainPlan/ApsGasPipelinePredictionController.java
@@ -7,23 +7,28 @@ 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.security.utils.DictUtils; import com.aps.core.domain.ApsGasPipelinePrediction; import com.aps.core.domain.ApsMaterialProductGroupManagement; import com.aps.core.service.IApsGasPipelinePredictionService; import com.aps.system.api.domain.SysDictData; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.SneakyThrows; import org.apache.commons.io.IOUtils; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.InputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; @@ -57,7 +62,7 @@ @Operation(summary = "å¯¼å ¥æå·¥æ°ä½é¢æµæ°æ®", description = "æ¹éå¯¼å ¥") @Log(title = "å¯¼å ¥æå·¥æ°ä½é¢æµæ°æ®", businessType = BusinessType.IMPORT) @RequiresPermissions("gasPipeline:prediction:import") // @RequiresPermissions("gasPipeline:prediction:import") @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { @@ -75,6 +80,20 @@ @GetMapping("/template") public ResponseEntity<ByteArrayResource> exportTemplate() { byte[] file = IOUtils.resourceToByteArray("/templates/æ°ä½é¢æµæ°æ®æ¨¡æ¿v1.0.xlsx"); Workbook workbook = WorkbookFactory.create(new ByteArrayInputStream(file)); Sheet sheet = workbook.getSheet("åå ¸-ç产åºå°"); List<SysDictData> sysDictDataList = DictUtils.getDictCache("aps_factory"); if (sysDictDataList != null) { for (int i = 0; i < sysDictDataList.size(); i++) { Row row = sheet.createRow(i + 1); row.createCell(0).setCellValue(sysDictDataList.get(i).getDictValue()); row.createCell(1).setCellValue(sysDictDataList.get(i).getDictLabel()); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); workbook.write(baos); file = baos.toByteArray(); } workbook.close(); ByteArrayResource resource = new ByteArrayResource(file); return ResponseEntity.ok() .header("Access-Control-Expose-Headers", HttpHeaders.CONTENT_DISPOSITION) aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipelineMo.java
@@ -11,6 +11,7 @@ import java.math.BigDecimal; import java.sql.Timestamp; import java.util.Date; /** * 管路æå·¥æ°ä½å·¥åæ°æ®å¯¹è±¡ aps_gas_pipeline_mo @@ -49,66 +50,10 @@ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "计åå®å·¥æ¥æ", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") @Schema(description = "计åå®å·¥æ¥æ") private Timestamp planEnd; private Date planEnd; /** æ°é */ @Excel(name = "æ°é") @Schema(description = "æ°é") private BigDecimal quantity; public void setId(Long id) { this.id = id; } public Long getId() { return id; } public void setMo(String mo) { this.mo = mo; } public String getMo() { return mo; } public void setFactory(String factory) { this.factory = factory; } public String getFactory() { return factory; } public void setMaterialCode(String materialCode) { this.materialCode = materialCode; } public String getMaterialCode() { return materialCode; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("mo", getMo()) .append("factory", getFactory()) .append("materialCode", getMaterialCode()) .append("planEnd", getPlanEnd()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .toString(); } } aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipelinePrediction.java
@@ -12,6 +12,7 @@ import java.math.BigDecimal; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -48,7 +49,7 @@ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "颿µæ¥æ", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") @Schema(description = "颿µæ¥æ") private Timestamp predictDate; private Date predictDate; /** æ°é */ @Excel(name = "æ°é") aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsStandardProcess.java
@@ -2,9 +2,13 @@ import com.aps.common.core.annotation.Excel; import com.aps.common.core.web.domain.BaseEntity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.springframework.data.annotation.Id; import java.math.BigDecimal; @@ -20,6 +24,10 @@ { private static final long serialVersionUID = 1L; @Id @TableId(type = IdType.AUTO) /** 主é®id */ @JsonFormat(shape = JsonFormat.Shape.STRING) /** 主é®id */ @Schema(description = "主é®id", type = "Long") private Long id; aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsShopMapper.java
@@ -1,8 +1,13 @@ package com.aps.core.mapper; import java.util.List; import java.util.Set; import com.aps.core.domain.ApsShop; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; import org.jetbrains.annotations.NotNull; /** * 车é´Mapperæ¥å£ @@ -11,7 +16,7 @@ * @date 2025-04-14 */ @Mapper public interface ApsShopMapper public interface ApsShopMapper extends BaseMapper<ApsShop> { /** * æ¥è¯¢è½¦é´ @@ -60,4 +65,32 @@ * @return ç»æ */ public int deleteApsShopByIds(String[] ids); @Select(""" <script> select * from aps_shop where 1 = 0 <if test="!codes.isEmpty()"> or shop_name in <foreach collection="names" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </script> """) List<ApsShop> selectApsByName(@NotNull Set<String> names); @Select("select * from aps_shop where plant_code = #{orgCode}") List<ApsShop> selectApsByFactory(String orgCode); @Select(""" <script> select * from aps_shop where 1 = 0 <if test="!codes.isEmpty()"> or shop_code in <foreach collection="codes" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </script> """) List<ApsShop> selectByCodes(Set<String> codes); } aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsStandardProcessMapper.java
@@ -1,6 +1,7 @@ package com.aps.core.mapper; import com.aps.core.domain.ApsStandardProcess; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import java.util.List; @@ -10,7 +11,7 @@ * @author hjy * @date 2025-04-23 */ public interface ApsStandardProcessMapper public interface ApsStandardProcessMapper extends BaseMapper<ApsStandardProcess> { /** * æ¥è¯¢æ åå·¥åº aps-modules/aps-core/src/main/java/com/aps/core/service/IApsShopService.java
@@ -1,7 +1,10 @@ package com.aps.core.service; import java.util.List; import java.util.Set; import com.aps.core.domain.ApsShop; import org.jetbrains.annotations.NotNull; /** * 车é´Serviceæ¥å£ @@ -58,4 +61,10 @@ * @return ç»æ */ public int deleteApsShopById(String id); List<ApsShop> findAllShops(); List<ApsShop> findShopByFactory(String orgCode); List<ApsShop> findShopByCodes(@NotNull Set<String> collect); } aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelineMoServiceImpl.java
@@ -2,25 +2,18 @@ import cn.hutool.core.util.IdUtil; import com.aps.common.core.utils.DateUtils; import com.aps.common.core.utils.poi.ExcelUtil; import com.aps.common.security.utils.DictUtils; import com.aps.common.security.utils.SecurityUtils; import com.aps.core.domain.ApsGasPipelineMo; import com.aps.core.mapper.ApsGasPipelineMoMapper; import com.aps.core.service.IApsGasPipelineMoService; import io.micrometer.common.util.StringUtils; import lombok.SneakyThrows; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; import java.util.List; /** @@ -108,49 +101,21 @@ @Transactional(rollbackFor = Exception.class) @Override public int batchInsertGasPipelineMo(MultipartFile file) { Workbook workbook = WorkbookFactory.create(file.getInputStream()); Sheet sheet = workbook.getSheetAt(0); int rows = sheet.getLastRowNum(); if (rows > 0) { List<ApsGasPipelineMo> list = new ArrayList<>(); /*æ°æ®åä»1å¼å§*/ for (int i = 1; i <= rows; i++) { Row row = sheet.getRow(i); if (row.getCell(0) == null){ continue; } String mo = row.getCell(0).getStringCellValue(); if (StringUtils.isEmpty(mo)){ continue; } String factory = row.getCell(1).getStringCellValue(); String materialNum = row.getCell(2).getStringCellValue(); double quantity = row.getCell(3).getNumericCellValue(); Date planEnd = row.getCell(4).getDateCellValue(); if (StringUtils.isNotBlank(factory) && StringUtils.isNotBlank(materialNum) && planEnd != null) { ApsGasPipelineMo apsGasPipelineMo = new ApsGasPipelineMo(); apsGasPipelineMo.setMo(mo); apsGasPipelineMo.setMaterialCode(materialNum); ExcelUtil<ApsGasPipelineMo> util = new ExcelUtil<>(ApsGasPipelineMo.class); List<ApsGasPipelineMo> tempList = util.importExcel(file.getInputStream()); DictUtils.CacheValue cacheValue = DictUtils.getCacheValue("aps_factory"); tempList.forEach(apsGasPipelineMo -> { apsGasPipelineMo.setId(IdUtil.getSnowflakeNextId()); apsGasPipelineMo.setFactory(factory); apsGasPipelineMo.setFactory(cacheValue.get(apsGasPipelineMo.getFactory())); apsGasPipelineMo.setCreateBy(SecurityUtils.getUsername()); apsGasPipelineMo.setCreateTime(DateUtils.getNowDate()); apsGasPipelineMo.setQuantity(new BigDecimal(quantity)); apsGasPipelineMo.setPlanEnd(new Timestamp(planEnd.getTime())); list.add(apsGasPipelineMo); } } if (!list.isEmpty()) { apsGasPipelineMoMapper.deleteAll(); apsGasPipelineMoMapper.insert(list); } return list.size(); } return 0; }); if (!tempList.isEmpty()) { apsGasPipelineMoMapper.deleteAll(); apsGasPipelineMoMapper.insert(tempList); } return tempList.size(); } } aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelinePredictionServiceImpl.java
@@ -2,27 +2,19 @@ import cn.hutool.core.util.IdUtil; import com.aps.common.core.utils.DateUtils; import com.aps.common.core.utils.poi.ExcelUtil; import com.aps.common.security.utils.DictUtils; import com.aps.common.security.utils.SecurityUtils; import com.aps.core.domain.ApsGasPipelinePrediction; import com.aps.core.domain.ApsMaterialProductGroupManagement; import com.aps.core.mapper.ApsGasPipelinePredictionMapper; import com.aps.core.service.IApsGasPipelinePredictionService; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import io.micrometer.common.util.StringUtils; import lombok.SneakyThrows; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.math.BigDecimal; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; /** @@ -107,43 +99,27 @@ @SneakyThrows @Override public int batchInsertApsGasPipelinePrediction(MultipartFile file) { Workbook workbook = WorkbookFactory.create(file.getInputStream()); Sheet sheet = workbook.getSheetAt(0); int rows = sheet.getLastRowNum(); if (rows > 0) { List<ApsGasPipelinePrediction> list = new ArrayList<>(); ExcelUtil<ApsGasPipelinePrediction> util = new ExcelUtil<>(ApsGasPipelinePrediction.class); List<ApsGasPipelinePrediction> list = util.importExcel(file.getInputStream()); DictUtils.CacheValue cacheValue = DictUtils.getCacheValue("aps_factory"); Set<String> keys = new HashSet<>(); /*æ°æ®è¡ä»1å¼å§*/ for (int i = rows; i > 0; --i) { Row row = sheet.getRow(i); if (row.getCell(0) == null) { continue; } String materialCode = row.getCell(0).getStringCellValue(); if (StringUtils.isEmpty(materialCode)) { continue; } String factory = row.getCell(1).getStringCellValue(); double quantity = row.getCell(2).getNumericCellValue(); Date date = row.getCell(3).getDateCellValue(); if (StringUtils.isNotBlank(factory) && date != null) { ApsGasPipelinePrediction item = new ApsGasPipelinePrediction(); list.forEach(item -> { item.setId(IdUtil.getSnowflakeNextId()); item.setFactory(factory); item.setMaterialCode(materialCode); item.setFactory(cacheValue.get(item.getFactory())); item.setCreateBy(SecurityUtils.getUsername()); item.setCreateTime(DateUtils.getNowDate()); item.setPredictQuantity(new BigDecimal(quantity)); item.setPredictDate(new Timestamp(date.getTime())); }); Collections.reverse(list); list = list.stream().filter(item -> { item.setKey(null); if (!keys.contains(item.getKey())) { keys.add(item.getKey()); list.add(item); return true; } } } return false; }).collect(Collectors.toList()); if (!list.isEmpty()) { List<Map<String, Object>> facCodeKey = apsGasPipelinePredictionMapper.selectByFacOrMaterial(keys); if (!facCodeKey.isEmpty()) { @@ -172,7 +148,5 @@ } } return list.size(); } return 0; } } aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsMaterialProductGroupManagementServiceImpl.java
@@ -1,27 +1,22 @@ package com.aps.core.service.impl; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.*; import java.util.stream.Collectors; import cn.hutool.core.util.IdUtil; import com.aps.common.core.utils.DateUtils; import com.aps.common.core.utils.poi.ExcelUtil; import com.aps.common.security.utils.DictUtils; import com.aps.common.security.utils.SecurityUtils; import com.aps.core.domain.ApsGasPipelinePrediction; import com.aps.core.domain.ApsMaterialProductGroupManagement; import com.aps.core.mapper.ApsMaterialProductGroupManagementMapper; import com.aps.core.service.IApsMaterialProductGroupManagementService; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import io.micrometer.common.util.StringUtils; import lombok.SneakyThrows; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.sql.Timestamp; import java.util.*; import java.util.stream.Collectors; /** * ç©æäº§åç»æ°æ®ç®¡çServiceä¸å¡å±å¤ç @@ -30,8 +25,7 @@ * @date 2025-05-19 */ @Service public class ApsMaterialProductGroupManagementServiceImpl implements IApsMaterialProductGroupManagementService { public class ApsMaterialProductGroupManagementServiceImpl implements IApsMaterialProductGroupManagementService { @Autowired private ApsMaterialProductGroupManagementMapper apsMaterialProductGroupManagementMapper; @@ -42,8 +36,7 @@ * @return ç©æäº§åç»æ°æ®ç®¡ç */ @Override public ApsMaterialProductGroupManagement selectApsMaterialProductGroupManagementById(Long id) { public ApsMaterialProductGroupManagement selectApsMaterialProductGroupManagementById(Long id) { return apsMaterialProductGroupManagementMapper.selectApsMaterialProductGroupManagementById(id); } @@ -54,8 +47,7 @@ * @return ç©æäº§åç»æ°æ®ç®¡ç */ @Override public List<ApsMaterialProductGroupManagement> selectApsMaterialProductGroupManagementList(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) { public List<ApsMaterialProductGroupManagement> selectApsMaterialProductGroupManagementList(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) { return apsMaterialProductGroupManagementMapper.selectApsMaterialProductGroupManagementList(apsMaterialProductGroupManagement); } @@ -66,8 +58,7 @@ * @return ç»æ */ @Override public int insertApsMaterialProductGroupManagement(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) { public int insertApsMaterialProductGroupManagement(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) { apsMaterialProductGroupManagement.setId(IdUtil.getSnowflakeNextId()); apsMaterialProductGroupManagement.setCreateBy(SecurityUtils.getUsername()); apsMaterialProductGroupManagement.setCreateTime(DateUtils.getNowDate()); @@ -81,8 +72,7 @@ * @return ç»æ */ @Override public int updateApsMaterialProductGroupManagement(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) { public int updateApsMaterialProductGroupManagement(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) { apsMaterialProductGroupManagement.setUpdateTime(DateUtils.getNowDate()); apsMaterialProductGroupManagement.setUpdateBy(SecurityUtils.getUsername()); return apsMaterialProductGroupManagementMapper.updateApsMaterialProductGroupManagement(apsMaterialProductGroupManagement); @@ -95,8 +85,7 @@ * @return ç»æ */ @Override public int deleteApsMaterialProductGroupManagementByIds(Long[] ids) { public int deleteApsMaterialProductGroupManagementByIds(Long[] ids) { return apsMaterialProductGroupManagementMapper.deleteApsMaterialProductGroupManagementByIds(ids); } @@ -107,55 +96,37 @@ * @return ç»æ */ @Override public int deleteApsMaterialProductGroupManagementById(Long id) { public int deleteApsMaterialProductGroupManagementById(Long id) { return apsMaterialProductGroupManagementMapper.deleteApsMaterialProductGroupManagementById(id); } @SneakyThrows @Override public int batchInsertApsMaterialProductGroupManagement(MultipartFile file) { Workbook workbook = WorkbookFactory.create(file.getInputStream()); Sheet sheet = workbook.getSheetAt(0); int rows = sheet.getLastRowNum(); if (rows > 0) { List<ApsMaterialProductGroupManagement> list = new ArrayList<>(); /*æ°æ®è¡ä»1å¼å§*/ ExcelUtil<ApsMaterialProductGroupManagement> util = new ExcelUtil<>(ApsMaterialProductGroupManagement.class); List<ApsMaterialProductGroupManagement> list = util.importExcel(file.getInputStream()); DictUtils.CacheValue cacheValue = DictUtils.getCacheValue("aps_factory"); DictUtils.CacheValue cacheDomain = DictUtils.getCacheValue("aps_domain"); Set<String> keys = new HashSet<>(); for (int i = rows; i > 0; --i) { Row row = sheet.getRow(i); if (row.getCell(0) == null) { continue; } String materialCode = row.getCell(0).getStringCellValue(); if (StringUtils.isEmpty(materialCode)){ continue; } String materialType = row.getCell(1).getStringCellValue(); String domain = row.getCell(2).getStringCellValue(); String isMain = row.getCell(3).getStringCellValue(); String factory = row.getCell(4).getStringCellValue(); if (StringUtils.isNotBlank(materialType) && StringUtils.isNotBlank(domain) && StringUtils.isNotBlank(isMain) && StringUtils.isNotBlank(factory)) { ApsMaterialProductGroupManagement item = new ApsMaterialProductGroupManagement(); list.forEach(item -> { item.setId(IdUtil.getSnowflakeNextId()); item.setFactory(factory); item.setDomain(domain); item.setMaterialType(materialType); item.setMaterialCode(materialCode); item.setIsMain(isMain); item.setDomain(cacheDomain.get(item.getDomain())); item.setFactory(cacheValue.get(item.getFactory())); item.setCreateBy(SecurityUtils.getUsername()); item.setCreateTime(DateUtils.getNowDate()); }); Collections.reverse(list); list = list.stream() .filter(item -> { item.setKey(null); if (!keys.contains(item.getKey())) { keys.add(item.getKey()); list.add(item); return true; } } } return false; }) .collect(Collectors.toList()); if (!list.isEmpty()) { Set<String> facCodeKey = apsMaterialProductGroupManagementMapper.selectByFacOrMaterial(keys); if (!facCodeKey.isEmpty()) { @@ -168,6 +139,7 @@ wrapper.eq(ApsMaterialProductGroupManagement::getMaterialCode, item.getMaterialCode()); item.setCreateBy(null); item.setCreateTime(null); item.setId(null); item.setUpdateBy(SecurityUtils.getUsername()); item.setUpdateTime(new Timestamp(System.currentTimeMillis())); apsMaterialProductGroupManagementMapper.update(item, wrapper); @@ -181,7 +153,6 @@ } } return list.size(); } return 0; } } aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlate/ApsPlateProcessShopStatServiceImpl.java
@@ -147,6 +147,7 @@ // æ¥è¯¢ç¸å ³æ°æ® ApsPlatePlan platePlan = new ApsPlatePlan(); platePlan.setPlant(plant); log.info("å¼å§æ§è¡é£é计å大表"); List<ApsPlatePlan> planList = apsPlatePlanMapper.selectApsPlatePlanList(platePlan); ApsShop apsShop = new ApsShop(); @@ -160,9 +161,11 @@ List<ApsStandardProcess> shopProcesses = standardProcessMapper.selectApsStandardProcessList(process); if (!planList.isEmpty() && !shopList.isEmpty() && !shopProcesses.isEmpty()) { // å¼å§ä¹åå å 餿æå岿°æ® log.info("é£é计å大表ï¼å 餿æå岿°æ®"); apsPlateProcessStatMapper.deleteAll(); apsPlateProcessShopStatMapper.deleteAll(); log.info("é£é计åå¤§è¡¨ï¼æ¨ç®åæé£éå·¥åºè®¡åå®å·¥æ¥æå计åå¼å·¥æ¶é´"); List<ApsPlateProcessStat> statList =apsPlateProcessStatService.computePlateProcessStat(); // æå»ºè½¦é´åç§°å°å·¥åºåç§°çæ å° Map<String, List<String>> shopToProcessNames = shopProcesses.stream().filter(x -> null!=x.getWorkShop()) @@ -170,30 +173,38 @@ Collectors.mapping(ApsStandardProcess::getProcessName, Collectors.toList()) )); // æ¹éæå ¥ç»è®¡æ°æ® log.info("é£é计å大表ï¼è®¡ç®æ¯ä¸ªå·¥å䏿¯ä¸ªè½¦é´çå¼å§ãç»ææ¶é´"); List<ApsPlateProcessShopStat> statsToInsert = new ArrayList<>(); for (ApsPlatePlan plan : planList) { for (ApsShop shop : shopList) { log.info("é£é计å大表ï¼è®¡ç®å·¥åï¼"+plan.getDocumentNumber()); ApsPlateProcessShopStat stat = createShopStat(plan, shop, shopToProcessNames, statList); statsToInsert.add(stat); } } log.info("é£é计åå¤§è¡¨ï¼æ¹éä¿åå·¥åºå¼å·¥åå®å·¥æ¶é´"); List<List<ApsPlateProcessStat>> processStatBatchList = ListUtil.split(statList, 1000); processStatBatchList.forEach(batch -> apsPlateProcessStatMapper.batchInsertPlateStat(batch)); log.info("é£é计åå¤§è¡¨ï¼æ¹éä¿åå·¥å-è½¦é´æ¶é´ä¿¡æ¯"); List<List<ApsPlateProcessShopStat>> shopStatBatchList = ListUtil.split(statsToInsert, 1000); shopStatBatchList.forEach(batch -> apsPlateProcessShopStatMapper.batchInsert(batch)); }else { if(shopProcesses.isEmpty()){ log.error("é£é计åå¤§è¡¨ï¼æªæ¾å°æ åå·¥åºæ°æ®ï¼"); throw new RuntimeException("æªæ¾å°æ åå·¥åºæ°æ®ï¼"); } if(shopList.isEmpty()){ log.error("é£é计åå¤§è¡¨ï¼æªæ¾å°è½¦é´æ°æ®ï¼"); throw new RuntimeException("æªæ¾å°è½¦é´æ°æ®ï¼"); } if(planList.isEmpty()){ log.error("é£é计åå¤§è¡¨ï¼æªæ¾å°å·¥åæ°æ®ï¼"); throw new RuntimeException("æªæ¾å°å·¥åæ°æ®ï¼"); } } log.info("é£é计å大表ï¼å®æ"); } /** @@ -253,7 +264,7 @@ } } } catch (Exception e) { log.error("computer error:"+ JSONObject.toJSONString(stat)); log.error("é£é计å大表 error:"+ JSONObject.toJSONString(stat)); throw new RuntimeException("计ç®è½¦é´ç»è®¡æ°æ®å¼å¸¸ï¼"); } return stat; aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsShopServiceImpl.java
@@ -1,9 +1,13 @@ package com.aps.core.service.impl; import java.util.List; import java.util.Set; import com.aps.common.core.utils.DateUtils; import com.aps.common.core.utils.uuid.IdUtils; import com.aps.common.security.utils.SecurityUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.aps.core.mapper.ApsShopMapper; @@ -97,4 +101,19 @@ { return apsShopMapper.deleteApsShopById(id); } @Override public List<ApsShop> findAllShops() { return apsShopMapper.selectList(new QueryWrapper<>()); } @Override public List<ApsShop> findShopByFactory(String orgCode) { return apsShopMapper.selectApsByFactory(orgCode); } @Override public List<ApsShop> findShopByCodes(@NotNull Set<String> codes) { return apsShopMapper.selectByCodes(codes); } } aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsStandardProcessServiceImpl.java
@@ -1,14 +1,20 @@ package com.aps.core.service.impl; import com.aps.common.core.utils.DateUtils; import com.aps.common.core.utils.StringUtils; import com.aps.common.security.utils.DictUtils; import com.aps.common.security.utils.SecurityUtils; import com.aps.core.domain.ApsShop; import com.aps.core.domain.ApsStandardProcess; import com.aps.core.mapper.ApsShopMapper; import com.aps.core.mapper.ApsStandardProcessMapper; import com.aps.core.service.IApsStandardProcessService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; /** * æ åå·¥åºServiceä¸å¡å±å¤ç @@ -17,10 +23,12 @@ * @date 2025-04-23 */ @Service public class ApsStandardProcessServiceImpl implements IApsStandardProcessService { public class ApsStandardProcessServiceImpl implements IApsStandardProcessService { @Autowired private ApsStandardProcessMapper apsStandardProcessMapper; @Autowired private ApsShopMapper apsShopMapper; /** * æ¥è¯¢æ åå·¥åº @@ -29,8 +37,7 @@ * @return æ åå·¥åº */ @Override public ApsStandardProcess selectApsStandardProcessById(Long id) { public ApsStandardProcess selectApsStandardProcessById(Long id) { return apsStandardProcessMapper.selectApsStandardProcessById(id); } @@ -41,8 +48,7 @@ * @return æ åå·¥åº */ @Override public List<ApsStandardProcess> selectApsStandardProcessList(ApsStandardProcess apsStandardProcess) { public List<ApsStandardProcess> selectApsStandardProcessList(ApsStandardProcess apsStandardProcess) { return apsStandardProcessMapper.selectApsStandardProcessList(apsStandardProcess); } @@ -53,8 +59,7 @@ * @return ç»æ */ @Override public int insertApsStandardProcess(ApsStandardProcess apsStandardProcess) { public int insertApsStandardProcess(ApsStandardProcess apsStandardProcess) { apsStandardProcess.setCreateTime(DateUtils.getNowDate()); apsStandardProcess.setCreateBy(SecurityUtils.getUsername()); return apsStandardProcessMapper.insertApsStandardProcess(apsStandardProcess); @@ -67,8 +72,7 @@ * @return ç»æ */ @Override public int updateApsStandardProcess(ApsStandardProcess apsStandardProcess) { public int updateApsStandardProcess(ApsStandardProcess apsStandardProcess) { apsStandardProcess.setUpdateTime(DateUtils.getNowDate()); apsStandardProcess.setUpdateBy(SecurityUtils.getUsername()); return apsStandardProcessMapper.updateApsStandardProcess(apsStandardProcess); @@ -81,8 +85,7 @@ * @return ç»æ */ @Override public int deleteApsStandardProcessByIds(Long[] ids) { public int deleteApsStandardProcessByIds(Long[] ids) { return apsStandardProcessMapper.deleteApsStandardProcessByIds(ids); } @@ -93,13 +96,13 @@ * @return ç»æ */ @Override public int deleteApsStandardProcessById(Long id) { public int deleteApsStandardProcessById(Long id) { return apsStandardProcessMapper.deleteApsStandardProcessById(id); } /** * å¯¼å ¥æ°æ® * * @param tempList * @return true/false */ @@ -107,11 +110,26 @@ public boolean importData(List<ApsStandardProcess> tempList) { try { if (!tempList.isEmpty()) { DictUtils.CacheValue cacheFactory = DictUtils.getCacheValue("aps_factory"); DictUtils.CacheValue cacheDomain = DictUtils.getCacheValue("aps_domain"); List<ApsShop> shops = apsShopMapper.selectApsByName(tempList.stream() .map(ApsStandardProcess::getWorkShop) .filter(StringUtils::isNotEmpty) .collect(Collectors.toSet())); tempList.forEach(temp->{ temp.setCreateBy(SecurityUtils.getUsername()); temp.setCreateTime(DateUtils.getNowDate()); apsStandardProcessMapper.insertApsStandardProcess(temp); temp.setMajor(cacheDomain.get(temp.getMajor())); temp.setPlant(cacheFactory.get(temp.getPlant())); temp.setWorkShop(shops.stream() .filter(shop -> Objects.equals(shop.getShopName(), temp.getWorkShop())) .filter(shop -> Objects.equals(shop.getPlantCode(), temp.getPlant())) .map(ApsShop::getShopCode) .findFirst() .orElse(null)); }); apsStandardProcessMapper.insert(tempList); } } catch (Exception e) { e.printStackTrace(); aps-modules/aps-core/src/main/resources/templates/±ê×¼¹¤ÐòÊý¾ÝÄ£°åv1.0.xlsxBinary files differ
aps-modules/aps-core/src/main/resources/templates/ÆøÌ幤µ¥Êý¾ÝÄ£°åv1.0.xlsxBinary files differ
aps-modules/aps-core/src/main/resources/templates/ÆøÌåÔ¤²âÊý¾ÝÄ£°åv1.0.xlsxBinary files differ