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/ApsGasPipelinePredictionServiceImpl.java | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 156 insertions(+), 0 deletions(-)
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelinePredictionServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelinePredictionServiceImpl.java
new file mode 100644
index 0000000..cf3d710
--- /dev/null
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelinePredictionServiceImpl.java
@@ -0,0 +1,156 @@
+package com.aps.core.service.impl;
+
+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.mapper.ApsGasPipelinePredictionMapper;
+import com.aps.core.service.IApsGasPipelinePredictionService;
+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.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁Service涓氬姟灞傚鐞�
+ *
+ * @author ruoyi
+ * @date 2025-05-19
+ */
+@Service
+public class ApsGasPipelinePredictionServiceImpl implements IApsGasPipelinePredictionService
+{
+ @Autowired
+ private ApsGasPipelinePredictionMapper apsGasPipelinePredictionMapper;
+
+ /**
+ * 鏌ヨ绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁
+ *
+ * @param id 绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁涓婚敭
+ * @return 绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁
+ */
+ @Override
+ public ApsGasPipelinePrediction selectApsGasPipelinePredictionById(Long id)
+ {
+ return apsGasPipelinePredictionMapper.selectApsGasPipelinePredictionById(id);
+ }
+
+ /**
+ * 鏌ヨ绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁鍒楄〃
+ *
+ * @param apsGasPipelinePrediction 绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁
+ * @return 绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁
+ */
+ @Override
+ public List<ApsGasPipelinePrediction> selectApsGasPipelinePredictionList(ApsGasPipelinePrediction apsGasPipelinePrediction)
+ {
+ return apsGasPipelinePredictionMapper.selectApsGasPipelinePredictionList(apsGasPipelinePrediction);
+ }
+
+ /**
+ * 鏂板绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁
+ *
+ * @param apsGasPipelinePrediction 绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁
+ * @return 缁撴灉
+ */
+ @Override
+ public int insertApsGasPipelinePrediction(ApsGasPipelinePrediction apsGasPipelinePrediction)
+ {
+ apsGasPipelinePrediction.setCreateTime(DateUtils.getNowDate());
+ return apsGasPipelinePredictionMapper.insertApsGasPipelinePrediction(apsGasPipelinePrediction);
+ }
+
+ /**
+ * 淇敼绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁
+ *
+ * @param apsGasPipelinePrediction 绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁
+ * @return 缁撴灉
+ */
+ @Override
+ public int updateApsGasPipelinePrediction(ApsGasPipelinePrediction apsGasPipelinePrediction)
+ {
+ apsGasPipelinePrediction.setUpdateTime(DateUtils.getNowDate());
+ return apsGasPipelinePredictionMapper.updateApsGasPipelinePrediction(apsGasPipelinePrediction);
+ }
+
+ /**
+ * 鎵归噺鍒犻櫎绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁涓婚敭
+ * @return 缁撴灉
+ */
+ @Override
+ public int deleteApsGasPipelinePredictionByIds(Long[] ids)
+ {
+ return apsGasPipelinePredictionMapper.deleteApsGasPipelinePredictionByIds(ids);
+ }
+
+ /**
+ * 鍒犻櫎绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁淇℃伅
+ *
+ * @param id 绠¤矾鎵嬪伐姘斾綋棰勬祴鏁版嵁涓婚敭
+ * @return 缁撴灉
+ */
+ @Override
+ public int deleteApsGasPipelinePredictionById(Long id)
+ {
+ return apsGasPipelinePredictionMapper.deleteApsGasPipelinePredictionById(id);
+ }
+
+ @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<>();
+
+ /*鏁版嵁鍒椾粠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 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();
+ item.setId(IdUtil.getSnowflakeNextId());
+ item.setFactory(factory);
+ item.setMaterialCode(materialCode);
+ item.setCreateBy(SecurityUtils.getUsername());
+ item.setCreateTime(DateUtils.getNowDate());
+ item.setPredictQuantity(new BigDecimal(quantity));
+ item.setPredictDate(new Timestamp(date.getTime()));
+ list.add(item);
+ }
+ }
+ if (!list.isEmpty()) {
+ apsGasPipelinePredictionMapper.deleteAll();
+ apsGasPipelinePredictionMapper.insert(list);
+ }
+ return list.size();
+ }
+ return 0;
+ }
+}
--
Gitblit v1.9.3