diff --git a/lzbi-module/pom.xml b/lzbi-module/pom.xml index daa10ca..60c1075 100644 --- a/lzbi-module/pom.xml +++ b/lzbi-module/pom.xml @@ -52,7 +52,6 @@ 3.3.2 - diff --git a/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiMonthPlanBillMasterService.java b/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiMonthPlanBillMasterService.java index 8c6ce22..0eafad2 100644 --- a/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiMonthPlanBillMasterService.java +++ b/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiMonthPlanBillMasterService.java @@ -244,31 +244,6 @@ public class DcBusiMonthPlanBillMasterService extends ServiceImpl subList = dcBusiMonthPlanBillSubMapper.selectDcBusiMonthPlanBillSubList(subParams); - DcBusiTargetDraftMonth dcBusiTargetDraftMonth; - for (int i = 0, len = subList.size(); i < len; i++) { - dcBusiTargetDraftMonth = new DcBusiTargetDraftMonth(); - dcBusiTargetDraftMonth.setCompanyId(master.getCompanyId()); - dcBusiTargetDraftMonth.setOrgId(master.getOragnizeId()); - dcBusiTargetDraftMonth.setFieldCode(subList.get(i).getFieldCode()); - dcBusiTargetDraftMonth.setAssetCode(subList.get(i).getAssetCode()); - dcBusiTargetDraftMonth.setTargetCode(subList.get(i).getTargetCode()); - dcBusiTargetDraftMonth.setCountYear(subList.get(i).getDateYear()); - dcBusiTargetDraftMonth.setCountMonth(subList.get(i).getDateMonth()); - List dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth); - // 如果底稿表数据不为空,则减去计划值 - if (!CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) { - dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0); - dcBusiTargetDraftMonth.setValPlan(dcBusiTargetDraftMonth.getValPlan().subtract(subList.get(i).getPlanValue())); - dcBusiTargetDraftMonthMapper.updateDcBusiTargetDraftMonth(dcBusiTargetDraftMonth); - } - } - } master.setUpdatedBy(SecurityUtils.getUsername()); master.setCreatedTime(DateUtils.getNowDate()); master.setBillNo(billNo); diff --git a/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java b/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java index 0028614..3d4d466 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java @@ -6,24 +6,26 @@ import com.alibaba.excel.write.metadata.WriteSheet; import com.lzbi.common.config.RuoYiConfig; import com.lzbi.common.core.controller.BaseController; import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.draft.domain.req.ProductionDailySheetReq; import com.lzbi.draft.entity.req.TargetDraftMonthReportReq; import com.lzbi.draft.entity.vo.TargetDraftMonthReportVO; import com.lzbi.draft.service.ReportService; import com.lzbi.task.domain.*; import com.lzbi.task.service.WorkParamReadService; +import io.swagger.v3.oas.annotations.parameters.RequestBody; import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.session.SqlSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -195,4 +197,14 @@ public class ReportController extends BaseController { public List getThourWeather(@Validated ReadQueryReq readQueryReq) { return workParamReadService.getThourWeather(readQueryReq); } + + @PostMapping("/upload/production/daily") + public AjaxResult uploadProductionDaily(MultipartFile file) { + return reportService.uploadProductionDaily(file); + } + + @PostMapping("/save/production/daily") + public AjaxResult saveProductionDaily(@RequestBody List list) { + return reportService.saveProductionDaily(list); + } } diff --git a/lzbi-module/src/main/java/com/lzbi/draft/domain/req/ProductionDailySheetReq.java b/lzbi-module/src/main/java/com/lzbi/draft/domain/req/ProductionDailySheetReq.java new file mode 100644 index 0000000..4297d05 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/draft/domain/req/ProductionDailySheetReq.java @@ -0,0 +1,27 @@ +package com.lzbi.draft.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ProductionDailySheetReq { + + /** + * sheet页序号 + */ + private int index; + /** + * sheet页名称 + */ + private String name; + /** + * 数据 + */ + private List> data; + +} diff --git a/lzbi-module/src/main/java/com/lzbi/draft/domain/vo/ProductionDailySheetVO.java b/lzbi-module/src/main/java/com/lzbi/draft/domain/vo/ProductionDailySheetVO.java new file mode 100644 index 0000000..f0d1ffe --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/draft/domain/vo/ProductionDailySheetVO.java @@ -0,0 +1,27 @@ +package com.lzbi.draft.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ProductionDailySheetVO { + + /** + * sheet页序号 + */ + private int index; + /** + * sheet页名称 + */ + private String name; + /** + * 数据 + */ + private List> data; + +} diff --git a/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java b/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java index a59ceb9..d67c002 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java @@ -1,17 +1,31 @@ package com.lzbi.draft.service; import com.alibaba.fastjson2.JSONObject; +import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.draft.domain.req.ProductionDailySheetReq; +import com.lzbi.draft.domain.vo.ProductionDailySheetVO; import com.lzbi.draft.entity.dto.TargetDraftMonthReportValueDTO; import com.lzbi.draft.entity.req.TargetDraftMonthReportReq; import com.lzbi.draft.entity.vo.TargetDraftMonthReportVO; import com.lzbi.draft.mapper.DcBusiTargetDraftDayMapper; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.IteratorUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -65,4 +79,62 @@ public class ReportService { return list; } + public AjaxResult uploadProductionDaily(MultipartFile file) { + List list = new ArrayList<>(); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + XSSFWorkbook hssfWorkbook = new XSSFWorkbook(inputStream); + int numberOfSheets = hssfWorkbook.getNumberOfSheets(); + DataFormatter formatter = new DataFormatter(); + for (int j = 0; j < numberOfSheets; j++) { + XSSFSheet sheetAt = hssfWorkbook.getSheetAt(j); + String sheetName = sheetAt.getSheetName(); + //获取数据总行数 + int rows = sheetAt.getPhysicalNumberOfRows(); + List> data = new ArrayList<>(); + //每行数据处理 + for (int i = 0; i < rows; i++) { + //获取一行数据 + XSSFRow row = sheetAt.getRow(i); + if (null != row) { + List cells = IteratorUtils.toList(row.cellIterator()); + List cellList = new ArrayList<>(); + for (int i1 = 0, len1 = cells.size(); i1 < len1; i1++) { + cellList.add(formatter.formatCellValue(cells.get(i1))); + } + data.add(cellList); + } + } + list.add(new ProductionDailySheetVO(j, sheetName, data)); + } + return AjaxResult.success(list); + } catch (Exception e) { + log.error("文件解析异常", e); + return AjaxResult.error(); + } finally { + try { + if (null != inputStream) { + inputStream.close(); + } + } catch (IOException e) { + log.error("文件解析异常", e); + } + } + } + + public AjaxResult saveProductionDaily(List list) { + if (CollectionUtils.isEmpty(list)) { + return AjaxResult.error("请选择需要保存的热源数据"); + } + for (ProductionDailySheetReq productionDailySheetReq : list) { + String name = productionDailySheetReq.getName(); + if (name.contains("(") && name.contains(")")) { + + } else { + return AjaxResult.error("所选sheet页中存在非热源数据"); + } + } + return null; + } }