From 2786ed1fe266240fa6216c5dd6a9014481963d24 Mon Sep 17 00:00:00 2001 From: sfd <sun.sunshine@163.com> Date: 星期二, 20 五月 2025 12:38:25 +0800 Subject: [PATCH] Merge branch 'dev' of http://192.168.50.149:8085/r/aps-backend into dev --- aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsMaterialProductGroupManagementServiceImpl.java | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 159 insertions(+), 0 deletions(-) diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsMaterialProductGroupManagementServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsMaterialProductGroupManagementServiceImpl.java new file mode 100644 index 0000000..84aab1d --- /dev/null +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsMaterialProductGroupManagementServiceImpl.java @@ -0,0 +1,159 @@ +package com.aps.core.service.impl; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import cn.hutool.core.util.IdUtil; +import com.aps.common.core.utils.DateUtils; +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 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; + +/** + * 鐗╂枡浜у搧缁勬暟鎹鐞哠ervice涓氬姟灞傚鐞� + * + * @author ruoyi + * @date 2025-05-19 + */ +@Service +public class ApsMaterialProductGroupManagementServiceImpl implements IApsMaterialProductGroupManagementService +{ + @Autowired + private ApsMaterialProductGroupManagementMapper apsMaterialProductGroupManagementMapper; + + /** + * 鏌ヨ鐗╂枡浜у搧缁勬暟鎹鐞� + * + * @param id 鐗╂枡浜у搧缁勬暟鎹鐞嗕富閿� + * @return 鐗╂枡浜у搧缁勬暟鎹鐞� + */ + @Override + public ApsMaterialProductGroupManagement selectApsMaterialProductGroupManagementById(Long id) + { + return apsMaterialProductGroupManagementMapper.selectApsMaterialProductGroupManagementById(id); + } + + /** + * 鏌ヨ鐗╂枡浜у搧缁勬暟鎹鐞嗗垪琛� + * + * @param apsMaterialProductGroupManagement 鐗╂枡浜у搧缁勬暟鎹鐞� + * @return 鐗╂枡浜у搧缁勬暟鎹鐞� + */ + @Override + public List<ApsMaterialProductGroupManagement> selectApsMaterialProductGroupManagementList(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) + { + return apsMaterialProductGroupManagementMapper.selectApsMaterialProductGroupManagementList(apsMaterialProductGroupManagement); + } + + /** + * 鏂板鐗╂枡浜у搧缁勬暟鎹鐞� + * + * @param apsMaterialProductGroupManagement 鐗╂枡浜у搧缁勬暟鎹鐞� + * @return 缁撴灉 + */ + @Override + public int insertApsMaterialProductGroupManagement(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) + { + apsMaterialProductGroupManagement.setCreateTime(DateUtils.getNowDate()); + return apsMaterialProductGroupManagementMapper.insertApsMaterialProductGroupManagement(apsMaterialProductGroupManagement); + } + + /** + * 淇敼鐗╂枡浜у搧缁勬暟鎹鐞� + * + * @param apsMaterialProductGroupManagement 鐗╂枡浜у搧缁勬暟鎹鐞� + * @return 缁撴灉 + */ + @Override + public int updateApsMaterialProductGroupManagement(ApsMaterialProductGroupManagement apsMaterialProductGroupManagement) + { + apsMaterialProductGroupManagement.setUpdateTime(DateUtils.getNowDate()); + return apsMaterialProductGroupManagementMapper.updateApsMaterialProductGroupManagement(apsMaterialProductGroupManagement); + } + + /** + * 鎵归噺鍒犻櫎鐗╂枡浜у搧缁勬暟鎹鐞� + * + * @param ids 闇�瑕佸垹闄ょ殑鐗╂枡浜у搧缁勬暟鎹鐞嗕富閿� + * @return 缁撴灉 + */ + @Override + public int deleteApsMaterialProductGroupManagementByIds(Long[] ids) + { + return apsMaterialProductGroupManagementMapper.deleteApsMaterialProductGroupManagementByIds(ids); + } + + /** + * 鍒犻櫎鐗╂枡浜у搧缁勬暟鎹鐞嗕俊鎭� + * + * @param id 鐗╂枡浜у搧缁勬暟鎹鐞嗕富閿� + * @return 缁撴灉 + */ + @Override + 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寮�濮�*/ + for (int i = 1; i <= rows; 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(); + item.setId(IdUtil.getSnowflakeNextId()); + item.setFactory(factory); + item.setDomain(domain); + item.setMaterialType(materialType); + item.setMaterialCode(materialCode); + item.setIsMain(isMain); + item.setCreateBy(SecurityUtils.getUsername()); + item.setCreateTime(DateUtils.getNowDate()); + list.add(item); + } + } + if (!list.isEmpty()) { + apsMaterialProductGroupManagementMapper.insert(list); + } + return list.size(); + } + return 0; + } +} -- Gitblit v1.9.3