Эх сурвалжийг харах

染整线能耗统计功能

wukai 1 сар өмнө
parent
commit
49db12e0bc

+ 1 - 1
jjt-admin/src/test/java/com/jjt/data/EnergyTest.java

@@ -72,7 +72,7 @@ public class EnergyTest {
 
     @Test
     void day() {
-        for (int i = 1; i < 20; i++) {
+        for (int i = 10; i < 23; i++) {
             String d = "2025-04-" + (i < 10 ? "0" + i : i);
             LocalDate localDate = LocalDate.parse(d);
             calcService.calc(localDate);

+ 43 - 32
jjt-biz/src/main/java/com/jjt/elec/controller/ElecPriceController.java

@@ -1,28 +1,24 @@
 package com.jjt.elec.controller;
 
-import java.util.List;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.security.access.prepost.PreAuthorize;
-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.jjt.common.annotation.Log;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.AjaxResult;
+import com.jjt.common.core.page.TableDataInfo;
 import com.jjt.common.enums.BusinessType;
+import com.jjt.common.utils.poi.ExcelUtil;
 import com.jjt.elec.domain.ElecPrice;
 import com.jjt.elec.service.IElecPriceService;
-import com.jjt.common.utils.poi.ExcelUtil;
-import com.jjt.common.core.page.TableDataInfo;
+import com.jjt.ws.service.ITwinWorkshopCalcService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.util.List;
 
 /**
  * 电费价格配置Controller
@@ -30,12 +26,14 @@ import com.jjt.common.core.page.TableDataInfo;
  * @author wukai
  * @date 2025-03-14
  */
-@Api(tags="电费价格配置")
+@Api(tags = "电费价格配置")
 @RestController
 @RequestMapping("/elec/price")
-public class ElecPriceController extends BaseController{
+public class ElecPriceController extends BaseController {
     @Resource
     private IElecPriceService elecPriceService;
+    @Resource
+    private ITwinWorkshopCalcService workshopCalcService;
 
     /**
      * 查询电费价格配置列表
@@ -43,8 +41,7 @@ public class ElecPriceController extends BaseController{
     @ApiOperation("查询电费价格配置列表")
     //@PreAuthorize("@ss.hasPermi('elec:price:list')")
     @GetMapping("/list")
-    public TableDataInfo list(ElecPrice elecPrice)
-    {
+    public TableDataInfo list(ElecPrice elecPrice) {
         startPage();
         List<ElecPrice> list = elecPriceService.selectElecPriceList(elecPrice);
         return getDataTable(list);
@@ -57,8 +54,7 @@ public class ElecPriceController extends BaseController{
     //@PreAuthorize("@ss.hasPermi('elec:price:export')")
     @Log(title = "电费价格配置", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, ElecPrice elecPrice)
-    {
+    public void export(HttpServletResponse response, ElecPrice elecPrice) {
         List<ElecPrice> list = elecPriceService.selectElecPriceList(elecPrice);
         ExcelUtil<ElecPrice> util = new ExcelUtil<ElecPrice>(ElecPrice.class);
         util.exportExcel(response, list, "电费价格配置数据");
@@ -70,8 +66,7 @@ public class ElecPriceController extends BaseController{
     @ApiOperation("获取电费价格配置详细信息")
     //@PreAuthorize("@ss.hasPermi('elec:price:query')")
     @GetMapping(value = "/{priceId}")
-    public AjaxResult getInfo(@PathVariable("priceId") Long priceId)
-    {
+    public AjaxResult getInfo(@PathVariable("priceId") Long priceId) {
         return success(elecPriceService.selectElecPriceByPriceId(priceId));
     }
 
@@ -82,8 +77,7 @@ public class ElecPriceController extends BaseController{
     //@PreAuthorize("@ss.hasPermi('elec:price:add')")
     @Log(title = "电费价格配置", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody ElecPrice elecPrice)
-    {
+    public AjaxResult add(@RequestBody ElecPrice elecPrice) {
         return toAjax(elecPriceService.insertElecPrice(elecPrice));
     }
 
@@ -94,20 +88,37 @@ public class ElecPriceController extends BaseController{
     //@PreAuthorize("@ss.hasPermi('elec:price:edit')")
     @Log(title = "电费价格配置", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody ElecPrice elecPrice)
-    {
+    public AjaxResult edit(@RequestBody ElecPrice elecPrice) {
         return toAjax(elecPriceService.updateElecPrice(elecPrice));
     }
 
+    @ApiOperation("重新统计")
+    @Log(title = "重新统计", businessType = BusinessType.UPDATE)
+    @PostMapping("/calc/{priceMonth}")
+    public AjaxResult calc(@PathVariable String priceMonth) {
+        String date = priceMonth + "-01";
+        LocalDate start = LocalDate.parse(date);
+        LocalDate now = LocalDate.now();
+        LocalDate end = LocalDateTime.now().minusHours(7).minusDays(1).toLocalDate();
+        if (!YearMonth.from(start).equals(YearMonth.from(now))) {
+            end = start.withDayOfMonth(start.lengthOfMonth());
+        }
+        while (!start.isAfter(end)) {
+            System.err.println(start);
+            workshopCalcService.calc(start);
+            start = start.plusDays(1);
+        }
+        return AjaxResult.success();
+    }
+
     /**
      * 删除电费价格配置
      */
     @ApiOperation("删除电费价格配置")
     //@PreAuthorize("@ss.hasPermi('elec:price:remove')")
     @Log(title = "电费价格配置", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{priceIds}")
-    public AjaxResult remove(@PathVariable Long[] priceIds)
-    {
+    @DeleteMapping("/{priceIds}")
+    public AjaxResult remove(@PathVariable Long[] priceIds) {
         return toAjax(elecPriceService.deleteElecPriceByPriceIds(priceIds));
     }
 }

+ 20 - 0
jjt-biz/src/main/java/com/jjt/elec/domain/ElecPrice.java

@@ -61,4 +61,24 @@ public class ElecPrice extends BaseEntity {
     @Excel(name = "尖峰电价")
     private BigDecimal priceSuperPeak;
 
+    /**
+     * 工业水单价
+     */
+    @ApiModelProperty("工业水单价")
+    @Excel(name = "工业水单价")
+    private BigDecimal waterPrice;
+
+    /**
+     * 低亚蒸汽单价
+     */
+    @ApiModelProperty("低亚蒸汽单价")
+    @Excel(name = "低亚蒸汽单价")
+    private BigDecimal lowStreamPrice;
+
+    /**
+     * 中亚蒸汽单价
+     */
+    @ApiModelProperty("中亚蒸汽单价")
+    @Excel(name = "中亚蒸汽单价")
+    private BigDecimal midStreamPrice;
 }

+ 9 - 1
jjt-biz/src/main/java/com/jjt/elec/service/impl/ElecPriceServiceImpl.java

@@ -98,6 +98,10 @@ public class ElecPriceServiceImpl implements IElecPriceService {
 
     /**
      * 根据时间获取时段价格列表
+     * 0-23 表示电价
+     * 100 工业水价
+     * 210 低压蒸汽价
+     * 220 中压蒸汽价
      *
      * @param localDate 时间,只取月份
      * @return 电价
@@ -120,6 +124,9 @@ public class ElecPriceServiceImpl implements IElecPriceService {
         } else {
             result = getPriceByPeriod(period.getSwPeak(), period.getSwFlat(), period.getSwValley(), period.getSwSuperPeak(), priceObj);
         }
+        result.put(100, new Pair<>("water", priceObj.getWaterPrice()));
+        result.put(210, new Pair<>("lowStream", priceObj.getLowStreamPrice()));
+        result.put(220, new Pair<>("midStream", priceObj.getMidStreamPrice()));
         return result;
 
     }
@@ -175,7 +182,8 @@ public class ElecPriceServiceImpl implements IElecPriceService {
 
     /**
      * 根据年月获取价格
-     * @param year 年
+     *
+     * @param year  年
      * @param month 月
      * @return 结果
      */

+ 225 - 0
jjt-biz/src/main/java/com/jjt/ws/controller/TwinRzCalcMonthController.java

@@ -0,0 +1,225 @@
+package com.jjt.ws.controller;
+
+import com.jjt.common.annotation.Log;
+import com.jjt.common.core.controller.BaseController;
+import com.jjt.common.core.domain.AjaxResult;
+import com.jjt.common.enums.BusinessType;
+import com.jjt.common.utils.DateUtils;
+import com.jjt.elec.domain.ElecPrice;
+import com.jjt.elec.service.IElecPriceService;
+import com.jjt.ws.domain.TwinRzCalcMonth;
+import com.jjt.ws.service.ITwinRzCalcMonthService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.poi.ss.usermodel.Cell;
+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.xssf.usermodel.XSSFWorkbook;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * 染整月统计Controller
+ *
+ * @author wukai
+ * @date 2025-04-23
+ */
+@Api(tags = "染整月统计")
+@RestController
+@RequestMapping("/ws/rzMonth")
+public class TwinRzCalcMonthController extends BaseController {
+    @Resource
+    private ITwinRzCalcMonthService twinRzCalcMonthService;
+    @Resource
+    private IElecPriceService elecPriceService;
+
+    /**
+     * 查询染整月统计列表
+     */
+    @ApiOperation("查询染整月统计列表")
+    @GetMapping("/list")
+    public AjaxResult list(TwinRzCalcMonth twinRzCalcMonth) {
+        List<TwinRzCalcMonth> list = twinRzCalcMonthService.selectTwinRzCalcMonthList(twinRzCalcMonth);
+        String para = (String) twinRzCalcMonth.getParams().get("month");
+        int year = Integer.parseInt(para.split("-")[0]);
+        int month = Integer.parseInt(para.split("-")[1]);
+        ElecPrice elecPrice = elecPriceService.selectElecPriceByMonth(year, month);
+        Map<String, Object> result = new HashMap<>(16);
+        result.put("list", getDataTable(list));
+        result.put("price", elecPrice);
+        return AjaxResult.success(result);
+    }
+
+    /**
+     * 导出染整月统计列表
+     */
+    @ApiOperation("导出染整月统计列表")
+    @RequestMapping("/export")
+    public void export(HttpServletResponse response, TwinRzCalcMonth twinRzCalcMonth) {
+        List<TwinRzCalcMonth> list = twinRzCalcMonthService.selectTwinRzCalcMonthList(twinRzCalcMonth);
+        String para = (String) twinRzCalcMonth.getParams().get("month");
+        int year = Integer.parseInt(para.split("-")[0]);
+        int month = Integer.parseInt(para.split("-")[1]);
+        ElecPrice elecPrice = elecPriceService.selectElecPriceByMonth(year, month);
+        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("tpl/yr-energy-month.xlsx"); Workbook wb = new XSSFWorkbook(inputStream); OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
+            Sheet sheet = wb.getSheetAt(0);
+            AtomicInteger colNum = new AtomicInteger(2);
+            int rowNum = 31;
+            list.forEach(vo -> {
+                Cell[] cells = new Cell[rowNum];
+                for (int i = 0; i < rowNum; i++) {
+                    Row row = sheet.getRow(i);
+                    cells[i] = row.getCell(colNum.get());
+                }
+                cells[0].setCellValue(DateUtils.parseDateToStrCN(vo.getDataDate()));
+                cells[1].setCellValue(vo.getQzUse().doubleValue());
+                cells[2].setCellValue(vo.getQzFUse().doubleValue());
+                cells[3].setCellValue(vo.getQzGUse().doubleValue());
+                cells[4].setCellValue(vo.getQzPUse().doubleValue());
+                if (vo.getQzJfUse() != null) {
+                    cells[5].setCellValue(vo.getQzJfUse().doubleValue());
+                }
+                cells[6].setCellValue(vo.getQzPrice().doubleValue());
+
+                cells[7].setCellValue(vo.getHzUse().doubleValue());
+                cells[8].setCellValue(vo.getHzFUse().doubleValue());
+                cells[9].setCellValue(vo.getHzGUse().doubleValue());
+                cells[10].setCellValue(vo.getHzPUse().doubleValue());
+                if (vo.getHzJfUse() != null) {
+                    cells[11].setCellValue(vo.getHzJfUse().doubleValue());
+                }
+                cells[12].setCellValue(vo.getHzPrice().doubleValue());
+
+                cells[13].setCellValue(vo.getYrUse().doubleValue());
+                cells[14].setCellValue(vo.getYrFUse().doubleValue());
+                cells[15].setCellValue(vo.getYrGUse().doubleValue());
+                cells[16].setCellValue(vo.getYrPUse().doubleValue());
+                if (vo.getYrJfUse() != null) {
+                    cells[17].setCellValue(vo.getYrJfUse().doubleValue());
+                }
+                cells[18].setCellValue(vo.getYrPrice().doubleValue());
+                cells[19].setCellValue(vo.getDPrice().doubleValue());
+
+                cells[20].setCellValue(vo.getSUse().doubleValue());
+                cells[21].setCellValue(vo.getSPrice().doubleValue());
+
+                cells[22].setCellValue(vo.getQLowUse().doubleValue());
+                cells[23].setCellValue(vo.getQLowPrice().doubleValue());
+                if (vo.getQMidUse() != null) {
+                    cells[24].setCellValue(vo.getQMidUse().doubleValue());
+                    cells[25].setCellValue(vo.getQMidPrice().doubleValue());
+                }
+
+                cells[26].setCellValue(vo.getTotalPrice().doubleValue());
+                if (vo.getLength() != null) {
+                    cells[27].setCellValue(vo.getLength().doubleValue());
+                }
+                if (vo.getLengthPrice() != null) {
+                    cells[28].setCellValue(vo.getLengthPrice().doubleValue());
+                }
+                if (vo.getWeight() != null) {
+                    cells[29].setCellValue(vo.getWeight().doubleValue());
+                }
+                if (vo.getWeightPrice() != null) {
+                    cells[30].setCellValue(vo.getWeightPrice().doubleValue());
+                }
+                colNum.getAndIncrement();
+            });
+
+            Cell[] cells = new Cell[rowNum];
+            for (int i = 0; i < rowNum; i++) {
+                Row row = sheet.getRow(i);
+                cells[i] = row.getCell(1);
+            }
+
+            cells[2].setCellValue("峰电(kwh/" + elecPrice.getPricePeak() + ")");
+            cells[3].setCellValue("谷电(kwh/" + elecPrice.getPriceValley() + ")");
+            cells[4].setCellValue("平电(kwh/" + elecPrice.getPriceFlat() + ")");
+            cells[5].setCellValue("尖峰(kwh/" + elecPrice.getPriceSuperPeak() + ")");
+
+            cells[8].setCellValue("峰电(kwh/" + elecPrice.getPricePeak() + ")");
+            cells[9].setCellValue("谷电(kwh/" + elecPrice.getPriceValley() + ")");
+            cells[10].setCellValue("平电(kwh/" + elecPrice.getPriceFlat() + ")");
+            cells[11].setCellValue("尖峰(kwh/" + elecPrice.getPriceSuperPeak() + ")");
+
+            cells[14].setCellValue("峰电(kwh/" + elecPrice.getPricePeak() + ")");
+            cells[15].setCellValue("谷电(kwh/" + elecPrice.getPriceValley() + ")");
+            cells[16].setCellValue("平电(kwh/" + elecPrice.getPriceFlat() + ")");
+            cells[17].setCellValue("尖峰(kwh/" + elecPrice.getPriceSuperPeak() + ")");
+
+            cells[20].setCellValue("工业水(m³/" + elecPrice.getWaterPrice().doubleValue() + ")");
+            cells[22].setCellValue("低压蒸汽(GJ/" + elecPrice.getLowStreamPrice().doubleValue() + ")");
+            cells[24].setCellValue("中亚蒸汽(GJ/" + elecPrice.getMidStreamPrice().doubleValue() + ")");
+
+            // 清空response
+            response.reset();
+            // 设置response的Header
+            response.setCharacterEncoding("UTF-8");
+            //Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
+            //attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
+            // filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
+            response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("染整线统计" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
+            response.setContentType("application/octet-stream");
+            wb.write(outputStream);
+            outputStream.flush();
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    /**
+     * 获取染整月统计详细信息
+     */
+    @ApiOperation("获取染整月统计详细信息")
+    @PreAuthorize("@ss.hasPermi('rzMonth:rzMonth:query')")
+    @GetMapping(value = "/{calcId}")
+    public AjaxResult getInfo(@PathVariable("calcId") Long calcId) {
+        return success(twinRzCalcMonthService.selectTwinRzCalcMonthByCalcId(calcId));
+    }
+
+    /**
+     * 新增染整月统计
+     */
+    @ApiOperation("新增染整月统计")
+    @PreAuthorize("@ss.hasPermi('rzMonth:rzMonth:add')")
+    @Log(title = "染整月统计", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TwinRzCalcMonth twinRzCalcMonth) {
+        return toAjax(twinRzCalcMonthService.insertTwinRzCalcMonth(twinRzCalcMonth));
+    }
+
+    /**
+     * 修改染整月统计
+     */
+    @ApiOperation("修改染整月统计")
+    @PreAuthorize("@ss.hasPermi('rzMonth:rzMonth:edit')")
+    @Log(title = "染整月统计", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TwinRzCalcMonth twinRzCalcMonth) {
+        return toAjax(twinRzCalcMonthService.updateTwinRzCalcMonth(twinRzCalcMonth));
+    }
+
+    /**
+     * 删除染整月统计
+     */
+    @ApiOperation("删除染整月统计")
+    @PreAuthorize("@ss.hasPermi('rzMonth:rzMonth:remove')")
+    @Log(title = "染整月统计", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{calcIds}")
+    public AjaxResult remove(@PathVariable Long[] calcIds) {
+        return toAjax(twinRzCalcMonthService.deleteTwinRzCalcMonthByCalcIds(calcIds));
+    }
+}

+ 0 - 99
jjt-biz/src/main/java/com/jjt/ws/controller/TwinWorkshopCalcController.java

@@ -57,105 +57,6 @@ public class TwinWorkshopCalcController extends BaseController {
     }
 
     /**
-     * 查询能源统计列表
-     */
-    @ApiOperation("查询能源统计月报")
-    @GetMapping("/calc/rz")
-    public TableDataInfo calcRz(TwinWorkshopCalc twinWorkshopCalc) {
-        List<MonthCalcVO> list = twinWorkshopCalcService.calcYr(twinWorkshopCalc);
-        return getDataTable(list);
-    }
-
-    @ApiOperation("导出能源统计列表")
-    @RequestMapping("/export/rz")
-    public void exportRz(TwinWorkshopCalc twinWorkshopCalc, HttpServletResponse response) {
-        List<MonthCalcVO> list = twinWorkshopCalcService.calcYr(twinWorkshopCalc);
-        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("tpl/yr-energy-month.xlsx"); Workbook wb = new XSSFWorkbook(inputStream); OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
-            Sheet sheet = wb.getSheetAt(0);
-            AtomicInteger colNum = new AtomicInteger(2);
-            int rowNum = 31;
-            AtomicReference<ElecPrice> elecPrice = new AtomicReference<>(new ElecPrice());
-            list.forEach(vo -> {
-                elecPrice.set(vo.getElecPrice());
-                Cell[] cells = new Cell[rowNum];
-                for (int i = 0; i < rowNum; i++) {
-                    Row row = sheet.getRow(i);
-                    cells[i] = row.getCell(colNum.get());
-                }
-                cells[0].setCellValue(DateUtils.parseDateToStrCN(vo.getDate()));
-                cells[1].setCellValue(vo.getD().getQz().getUse().doubleValue());
-                cells[2].setCellValue(vo.getD().getQz().getFUse().doubleValue());
-                cells[3].setCellValue(vo.getD().getQz().getGUse().doubleValue());
-                cells[4].setCellValue(vo.getD().getQz().getPUse().doubleValue());
-                if (vo.getD().getQz().getJfUse() != null) {
-                    cells[5].setCellValue(vo.getD().getQz().getJfUse().doubleValue());
-                }
-                cells[6].setCellValue(vo.getD().getQz().getPrice().doubleValue());
-
-                cells[7].setCellValue(vo.getD().getHz().getUse().doubleValue());
-                cells[8].setCellValue(vo.getD().getHz().getFUse().doubleValue());
-                cells[9].setCellValue(vo.getD().getHz().getGUse().doubleValue());
-                cells[10].setCellValue(vo.getD().getHz().getPUse().doubleValue());
-                if (vo.getD().getHz().getJfUse() != null) {
-                    cells[11].setCellValue(vo.getD().getHz().getJfUse().doubleValue());
-                }
-                cells[12].setCellValue(vo.getD().getHz().getPrice().doubleValue());
-
-                cells[13].setCellValue(vo.getD().getYr().getUse().doubleValue());
-                cells[14].setCellValue(vo.getD().getYr().getFUse().doubleValue());
-                cells[15].setCellValue(vo.getD().getYr().getGUse().doubleValue());
-                cells[16].setCellValue(vo.getD().getYr().getPUse().doubleValue());
-                if (vo.getD().getYr().getJfUse() != null) {
-                    cells[17].setCellValue(vo.getD().getYr().getJfUse().doubleValue());
-                }
-                cells[18].setCellValue(vo.getD().getYr().getPrice().doubleValue());
-                cells[19].setCellValue(vo.getD().getPrice().doubleValue());
-
-                cells[20].setCellValue(vo.getS().getUse().doubleValue());
-                cells[21].setCellValue(vo.getS().getPrice().doubleValue());
-
-                cells[22].setCellValue(vo.getQ().getLowUse().doubleValue());
-                cells[23].setCellValue(vo.getQ().getLowPrice().doubleValue());
-                cells[24].setCellValue(vo.getQ().getMidUse().doubleValue());
-                cells[25].setCellValue(vo.getQ().getMidPrice().doubleValue());
-
-                cells[26].setCellValue(vo.getPrice().doubleValue());
-                cells[27].setCellValue("");
-                cells[28].setCellValue("");
-                cells[29].setCellValue("");
-                cells[30].setCellValue("");
-                colNum.getAndIncrement();
-            });
-
-            Cell[] cells = new Cell[rowNum];
-            for (int i = 0; i < rowNum; i++) {
-                Row row = sheet.getRow(i);
-                cells[i] = row.getCell(1);
-            }
-
-            cells[2].setCellValue("峰电(kwh/"+elecPrice.get().getPricePeak()+")");
-            cells[3].setCellValue("谷电(kwh/"+elecPrice.get().getPriceValley()+")");
-            cells[4].setCellValue("平电(kwh/"+elecPrice.get().getPriceFlat()+")");
-            cells[5].setCellValue("尖峰(kwh/"+elecPrice.get().getPriceSuperPeak()+")");
-
-            wb.removeSheetAt(1);
-            // 清空response
-            response.reset();
-            // 设置response的Header
-            response.setCharacterEncoding("UTF-8");
-            //Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
-            //attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
-            // filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
-            response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("染整线统计" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
-            response.setContentType("application/octet-stream");
-            wb.write(outputStream);
-            outputStream.flush();
-        } catch (IOException ex) {
-            ex.printStackTrace();
-        }
-    }
-
-    /**
      * 获取能源统计详细信息
      */
     @ApiOperation("获取能源统计详细信息")

+ 286 - 0
jjt-biz/src/main/java/com/jjt/ws/domain/TwinRzCalcMonth.java

@@ -0,0 +1,286 @@
+package com.jjt.ws.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.jjt.common.annotation.Excel;
+import com.jjt.common.core.domain.BaseEntity;
+import com.jjt.elec.domain.ElecPrice;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 染整月统计对象 TWIN_RZ_CALC_MONTH
+ *
+ * @author wukai
+ * @date 2025-04-23
+ */
+@ApiModel(value = "TwinRzCalcMonth", description = "染整月统计")
+@Data
+public class TwinRzCalcMonth extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 统计ID
+     */
+    @ApiModelProperty("统计ID")
+    @TableId
+    private Long calcId;
+
+    /**
+     * 日期
+     */
+    @ApiModelProperty("日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date dataDate;
+
+    /**
+     * 总费用
+     */
+    @ApiModelProperty("总费用")
+    @Excel(name = "总费用")
+    private BigDecimal totalPrice;
+
+    /**
+     * 总米数
+     */
+    @ApiModelProperty("总米数")
+    @Excel(name = "总米数")
+    private BigDecimal length;
+
+    /**
+     * 平均每米价
+     */
+    @ApiModelProperty("平均每米价")
+    @Excel(name = "平均每米价")
+    private BigDecimal lengthPrice;
+
+    /**
+     * 总重量
+     */
+    @ApiModelProperty("总重量")
+    @Excel(name = "总重量")
+    private BigDecimal weight;
+
+    /**
+     * 平均每KG价
+     */
+    @ApiModelProperty("平均每KG价")
+    @Excel(name = "平均每KG价")
+    private BigDecimal weightPrice;
+    /**
+     * 电总用量
+     */
+    @ApiModelProperty("电总用量")
+    @Excel(name = "电总用量")
+    @JsonProperty("dUse")
+    private BigDecimal dUse;
+    /**
+     * 电费
+     */
+    @ApiModelProperty("电费")
+    @Excel(name = "电费")
+    @JsonProperty("dPrice")
+    private BigDecimal dPrice;
+
+    /**
+     * 前整用量
+     */
+    @ApiModelProperty("前整用量")
+    @Excel(name = "前整用量")
+    private BigDecimal qzUse;
+
+    /**
+     * 前整电费
+     */
+    @ApiModelProperty("前整电费")
+    @Excel(name = "前整电费")
+    private BigDecimal qzPrice;
+
+    /**
+     * 前整峰电用量
+     */
+    @ApiModelProperty("前整峰电用量")
+    @Excel(name = "前整峰电用量")
+    private BigDecimal qzFUse;
+
+    /**
+     * 前整谷电用量
+     */
+    @ApiModelProperty("前整谷电用量")
+    @Excel(name = "前整谷电用量")
+    private BigDecimal qzGUse;
+
+    /**
+     * 前整平电用量
+     */
+    @ApiModelProperty("前整平电用量")
+    @Excel(name = "前整平电用量")
+    private BigDecimal qzPUse;
+
+    /**
+     * 前整尖峰用量
+     */
+    @ApiModelProperty("前整尖峰用量")
+    @Excel(name = "前整尖峰用量")
+    private BigDecimal qzJfUse;
+
+    /**
+     * 后整用量
+     */
+    @ApiModelProperty("后整用量")
+    @Excel(name = "后整用量")
+    private BigDecimal hzUse;
+
+    /**
+     * 后整电费
+     */
+    @ApiModelProperty("后整电费")
+    @Excel(name = "后整电费")
+    private BigDecimal hzPrice;
+
+    /**
+     * 后整峰电用量
+     */
+    @ApiModelProperty("后整峰电用量")
+    @Excel(name = "后整峰电用量")
+    private BigDecimal hzFUse;
+
+    /**
+     * 后整谷电用量
+     */
+    @ApiModelProperty("后整谷电用量")
+    @Excel(name = "后整谷电用量")
+    private BigDecimal hzGUse;
+
+    /**
+     * 后整平电用量
+     */
+    @ApiModelProperty("后整平电用量")
+    @Excel(name = "后整平电用量")
+    private BigDecimal hzPUse;
+
+    /**
+     * 后整尖峰用量
+     */
+    @ApiModelProperty("后整尖峰用量")
+    @Excel(name = "后整尖峰用量")
+    private BigDecimal hzJfUse;
+
+    /**
+     * 印染用量
+     */
+    @ApiModelProperty("印染用量")
+    @Excel(name = "印染用量")
+    private BigDecimal yrUse;
+
+    /**
+     * 印染电费
+     */
+    @ApiModelProperty("印染电费")
+    @Excel(name = "印染电费")
+    private BigDecimal yrPrice;
+
+    /**
+     * 印染峰电用量
+     */
+    @ApiModelProperty("印染峰电用量")
+    @Excel(name = "印染峰电用量")
+    private BigDecimal yrFUse;
+
+    /**
+     * 印染谷电用量
+     */
+    @ApiModelProperty("印染谷电用量")
+    @Excel(name = "印染谷电用量")
+    private BigDecimal yrGUse;
+
+    /**
+     * 印染平电用量
+     */
+    @ApiModelProperty("印染平电用量")
+    @Excel(name = "印染平电用量")
+    private BigDecimal yrPUse;
+
+    /**
+     * 印染尖峰用量
+     */
+    @ApiModelProperty("印染尖峰用量")
+    @Excel(name = "印染尖峰用量")
+    private BigDecimal yrJfUse;
+
+    /**
+     * 水费
+     */
+    @ApiModelProperty("水费")
+    @Excel(name = "水费")
+    @JsonProperty("sPrice")
+    private BigDecimal sPrice;
+
+    /**
+     * 水用量
+     */
+    @ApiModelProperty("水用量")
+    @Excel(name = "水用量")
+    @JsonProperty("sUse")
+    private BigDecimal sUse;
+
+    /**
+     * 蒸汽费用
+     */
+    @ApiModelProperty("蒸汽费用")
+    @Excel(name = "蒸汽费用")
+    @JsonProperty("qPrice")
+    private BigDecimal qPrice;
+
+    /**
+     * 低压用量
+     */
+    @ApiModelProperty("低压用量")
+    @Excel(name = "低压用量")
+    @JsonProperty("qLowUse")
+    private BigDecimal qLowUse;
+
+    /**
+     * 低压费用
+     */
+    @ApiModelProperty("低压费用")
+    @Excel(name = "低压费用")
+    @JsonProperty("qLowPrice")
+    private BigDecimal qLowPrice;
+
+    /**
+     * 中亚用量
+     */
+    @ApiModelProperty("中亚用量")
+    @Excel(name = "中亚用量")
+    @JsonProperty("qMidUse")
+    private BigDecimal qMidUse;
+
+    /**
+     * 中亚费用
+     */
+    @ApiModelProperty("中亚费用")
+    @Excel(name = "中亚费用")
+    @JsonProperty("qMidPrice")
+    private BigDecimal qMidPrice;
+
+
+    @ApiModelProperty("电价")
+    private ElecPrice elecPrice;
+
+    public void setPrice() {
+        this.dPrice = qzPrice.add(hzPrice).add(yrPrice);
+        this.qPrice = this.qLowPrice;
+        if (this.qMidPrice != null) {
+            this.qPrice = qPrice.add(this.qMidPrice);
+        }
+        this.totalPrice = dPrice.add(qPrice).add(sPrice);
+    }
+}
+

+ 62 - 0
jjt-biz/src/main/java/com/jjt/ws/mapper/TwinRzCalcMonthMapper.java

@@ -0,0 +1,62 @@
+package com.jjt.ws.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jjt.ws.domain.TwinRzCalcMonth;
+
+/**
+ * 染整月统计Mapper接口
+ * 
+ * @author wukai
+ * @date 2025-04-23
+ */
+public interface TwinRzCalcMonthMapper extends BaseMapper<TwinRzCalcMonth>
+{
+    /**
+     * 查询染整月统计
+     * 
+     * @param calcId 染整月统计主键
+     * @return 染整月统计
+     */
+    public TwinRzCalcMonth selectTwinRzCalcMonthByCalcId(Long calcId);
+
+    /**
+     * 查询染整月统计列表
+     * 
+     * @param twinRzCalcMonth 染整月统计
+     * @return 染整月统计集合
+     */
+    public List<TwinRzCalcMonth> selectTwinRzCalcMonthList(TwinRzCalcMonth twinRzCalcMonth);
+
+    /**
+     * 新增染整月统计
+     * 
+     * @param twinRzCalcMonth 染整月统计
+     * @return 结果
+     */
+    public int insertTwinRzCalcMonth(TwinRzCalcMonth twinRzCalcMonth);
+
+    /**
+     * 修改染整月统计
+     * 
+     * @param twinRzCalcMonth 染整月统计
+     * @return 结果
+     */
+    public int updateTwinRzCalcMonth(TwinRzCalcMonth twinRzCalcMonth);
+
+    /**
+     * 删除染整月统计
+     * 
+     * @param calcId 染整月统计主键
+     * @return 结果
+     */
+    public int deleteTwinRzCalcMonthByCalcId(Long calcId);
+
+    /**
+     * 批量删除染整月统计
+     * 
+     * @param calcIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTwinRzCalcMonthByCalcIds(Long[] calcIds);
+}

+ 72 - 0
jjt-biz/src/main/java/com/jjt/ws/service/ITwinRzCalcMonthService.java

@@ -0,0 +1,72 @@
+package com.jjt.ws.service;
+
+import com.jjt.elec.domain.ElecPrice;
+import com.jjt.ws.domain.TwinRzCalcMonth;
+import com.jjt.ws.domain.TwinWorkshopCalc;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 染整月统计Service接口
+ *
+ * @author wukai
+ * @date 2025-04-23
+ */
+public interface ITwinRzCalcMonthService {
+    /**
+     * 查询染整月统计
+     *
+     * @param calcId 染整月统计主键
+     * @return 染整月统计
+     */
+    public TwinRzCalcMonth selectTwinRzCalcMonthByCalcId(Long calcId);
+
+    /**
+     * 查询染整月统计列表
+     *
+     * @param twinRzCalcMonth 染整月统计
+     * @return 染整月统计集合
+     */
+    public List<TwinRzCalcMonth> selectTwinRzCalcMonthList(TwinRzCalcMonth twinRzCalcMonth);
+
+    /**
+     * 新增染整月统计
+     *
+     * @param twinRzCalcMonth 染整月统计
+     * @return 结果
+     */
+    public int insertTwinRzCalcMonth(TwinRzCalcMonth twinRzCalcMonth);
+
+    /**
+     * 修改染整月统计
+     *
+     * @param twinRzCalcMonth 染整月统计
+     * @return 结果
+     */
+    public int updateTwinRzCalcMonth(TwinRzCalcMonth twinRzCalcMonth);
+
+    /**
+     * 批量删除染整月统计
+     *
+     * @param calcIds 需要删除的染整月统计主键集合
+     * @return 结果
+     */
+    public int deleteTwinRzCalcMonthByCalcIds(Long[] calcIds);
+
+    /**
+     * 删除染整月统计信息
+     *
+     * @param calcId 染整月统计主键
+     * @return 结果
+     */
+    public int deleteTwinRzCalcMonthByCalcId(Long calcId);
+
+    /**
+     * 染整线月统计
+     *
+     * @param date      时间
+     * @param calcList  统计数据
+     */
+    void calc(Date date, List<TwinWorkshopCalc> calcList);
+}

+ 216 - 0
jjt-biz/src/main/java/com/jjt/ws/service/impl/TwinRzCalcMonthServiceImpl.java

@@ -0,0 +1,216 @@
+package com.jjt.ws.service.impl;
+
+import com.jjt.common.utils.DateUtils;
+import com.jjt.elec.domain.ElecPrice;
+import com.jjt.elec.service.IElecPriceService;
+import com.jjt.ws.domain.TwinRzCalcMonth;
+import com.jjt.ws.domain.TwinWorkshopCalc;
+import com.jjt.ws.mapper.TwinRzCalcMonthMapper;
+import com.jjt.ws.service.ITwinRzCalcMonthService;
+import com.jjt.ws.vo.MonthCalcVO;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDate;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 染整月统计Service业务层处理
+ *
+ * @author wukai
+ * @date 2025-04-23
+ */
+@Service
+public class TwinRzCalcMonthServiceImpl implements ITwinRzCalcMonthService {
+    @Resource
+    private TwinRzCalcMonthMapper twinRzCalcMonthMapper;
+    @Resource
+    private IElecPriceService elecPriceService;
+
+    /**
+     * 查询染整月统计
+     *
+     * @param calcId 染整月统计主键
+     * @return 染整月统计
+     */
+    @Override
+    public TwinRzCalcMonth selectTwinRzCalcMonthByCalcId(Long calcId) {
+        return twinRzCalcMonthMapper.selectTwinRzCalcMonthByCalcId(calcId);
+    }
+
+    /**
+     * 查询染整月统计列表
+     *
+     * @param twinRzCalcMonth 染整月统计
+     * @return 染整月统计
+     */
+    @Override
+    public List<TwinRzCalcMonth> selectTwinRzCalcMonthList(TwinRzCalcMonth twinRzCalcMonth) {
+        return twinRzCalcMonthMapper.selectTwinRzCalcMonthList(twinRzCalcMonth);
+    }
+
+    /**
+     * 新增染整月统计
+     *
+     * @param twinRzCalcMonth 染整月统计
+     * @return 结果
+     */
+    @Override
+    public int insertTwinRzCalcMonth(TwinRzCalcMonth twinRzCalcMonth) {
+        return twinRzCalcMonthMapper.insertTwinRzCalcMonth(twinRzCalcMonth);
+    }
+
+    /**
+     * 修改染整月统计
+     *
+     * @param twinRzCalcMonth 染整月统计
+     * @return 结果
+     */
+    @Override
+    public int updateTwinRzCalcMonth(TwinRzCalcMonth twinRzCalcMonth) {
+        LocalDate date = DateUtils.toLocalDate(twinRzCalcMonth.getDataDate());
+        int year = date.getYear();
+        int month = date.getMonthValue();
+        ElecPrice elecPrice = elecPriceService.selectElecPriceByMonth(year, month);
+        if (twinRzCalcMonth.getQMidUse() != null) {
+            twinRzCalcMonth.setQMidPrice(twinRzCalcMonth.getQMidUse().multiply(elecPrice.getMidStreamPrice()));
+        }
+        twinRzCalcMonth.setPrice();
+        if (twinRzCalcMonth.getLength() != null) {
+            BigDecimal lp = twinRzCalcMonth.getTotalPrice().divide(twinRzCalcMonth.getLength(), 6, RoundingMode.HALF_UP);
+            twinRzCalcMonth.setLengthPrice(lp);
+        }
+        if (twinRzCalcMonth.getWeight() != null) {
+            BigDecimal wp = twinRzCalcMonth.getTotalPrice().divide(twinRzCalcMonth.getWeight(), 6, RoundingMode.HALF_UP);
+            twinRzCalcMonth.setWeightPrice(wp);
+        }
+        return twinRzCalcMonthMapper.updateTwinRzCalcMonth(twinRzCalcMonth);
+    }
+
+    /**
+     * 批量删除染整月统计
+     *
+     * @param calcIds 需要删除的染整月统计主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinRzCalcMonthByCalcIds(Long[] calcIds) {
+        return twinRzCalcMonthMapper.deleteTwinRzCalcMonthByCalcIds(calcIds);
+    }
+
+    /**
+     * 删除染整月统计信息
+     *
+     * @param calcId 染整月统计主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinRzCalcMonthByCalcId(Long calcId) {
+        return twinRzCalcMonthMapper.deleteTwinRzCalcMonthByCalcId(calcId);
+    }
+
+    private TwinRzCalcMonth selectExists(Date date) {
+        TwinRzCalcMonth search = new TwinRzCalcMonth();
+        search.setDataDate(date);
+        List<TwinRzCalcMonth> list = selectTwinRzCalcMonthList(search);
+        if (list.size() > 0) {
+            return list.get(0);
+        } else {
+            return search;
+        }
+    }
+
+    /**
+     * 染整线月统计
+     *
+     * @param date     时间
+     * @param calcList 统计数据
+     */
+    @Override
+    public void calc(Date date, List<TwinWorkshopCalc> calcList) {
+        TwinRzCalcMonth vo = selectExists(date);
+        for (TwinWorkshopCalc calc : calcList) {
+            switch (calc.getWsCode()) {
+                case "WS03-D-QZ":
+                    vo.setQzUse(calc.getTotalValue());
+                    vo.setQzPrice(calc.getTotalPrice());
+                    vo.setQzFUse(calc.getPeakValue());
+                    vo.setQzPUse(calc.getFlatValue());
+                    vo.setQzGUse(calc.getValleyValue());
+                    vo.setQzJfUse(calc.getSuperPeakValue());
+                    break;
+                case "WS03-D-HZ":
+                    vo.setHzUse(calc.getTotalValue());
+                    vo.setHzPrice(calc.getTotalPrice());
+                    vo.setHzFUse(calc.getPeakValue());
+                    vo.setHzPUse(calc.getFlatValue());
+                    vo.setHzGUse(calc.getValleyValue());
+                    vo.setHzJfUse(calc.getSuperPeakValue());
+                    break;
+                case "WS03-D-YR":
+                    vo.setYrUse(calc.getTotalValue());
+                    vo.setYrPrice(calc.getTotalPrice());
+                    vo.setYrFUse(calc.getPeakValue());
+                    vo.setYrPUse(calc.getFlatValue());
+                    vo.setYrGUse(calc.getValleyValue());
+                    vo.setYrJfUse(calc.getSuperPeakValue());
+                    break;
+                case "WS03-S-YR":
+                    vo.setSPrice(calc.getTotalPrice());
+                    vo.setSUse(calc.getTotalValue());
+                    break;
+                case "WS03-Q-DY":
+                    vo.setQLowPrice(calc.getTotalPrice());
+                    vo.setQLowUse(calc.getTotalValue());
+                    break;
+                case "WS03-Q-ZY":
+                    if (vo.getQMidUse() != null && vo.getQMidUse().intValue() != 0) {
+                        vo.setQMidPrice(calc.getTotalPrice());
+                        vo.setQMidUse(calc.getTotalValue());
+                    }
+                    break;
+                default:
+            }
+
+        }
+        vo.setPrice();
+        if (vo.getCalcId() != null) {
+            updateTwinRzCalcMonth(vo);
+        } else {
+            insertTwinRzCalcMonth(vo);
+        }
+    }
+
+    private void setWorkshopData(MonthCalcVO.D.DD dd, TwinWorkshopCalc calc) {
+        dd.setUse(calc.getTotalValue());
+        dd.setPrice(calc.getTotalPrice());
+        dd.setFPrice(calc.getPeakUPrice());
+        dd.setFUse(calc.getPeakValue());
+        dd.setPPrice(calc.getFlatUPrice());
+        dd.setPUse(calc.getFlatValue());
+        dd.setGPrice(calc.getValleyUPrice());
+        dd.setGUse(calc.getValleyValue());
+        dd.setJfPrice(calc.getSuperPeakUPrice());
+        dd.setJfUse(calc.getSuperPeakValue());
+    }
+
+    private void setQuarterData(MonthCalcVO.Q q, TwinWorkshopCalc calc, BigDecimal unitPrice, String type) {
+        switch (type) {
+            case "low":
+                q.setLowPrice(calc.getTotalPrice());
+                q.setLowUse(calc.getTotalValue());
+                q.setLowUnitPrice(unitPrice);
+                break;
+            case "mid":
+                q.setMidPrice(calc.getTotalPrice());
+                q.setMidUse(calc.getTotalValue());
+                q.setMidUnitPrice(unitPrice);
+                break;
+            default:
+        }
+    }
+
+}

+ 32 - 13
jjt-biz/src/main/java/com/jjt/ws/service/impl/TwinWorkshopCalcServiceImpl.java

@@ -10,6 +10,7 @@ import com.jjt.ws.domain.TwinWorkshop;
 import com.jjt.ws.domain.TwinWorkshopCalc;
 import com.jjt.ws.domain.TwinWorkshopEnergy;
 import com.jjt.ws.mapper.TwinWorkshopCalcMapper;
+import com.jjt.ws.service.ITwinRzCalcMonthService;
 import com.jjt.ws.service.ITwinWorkshopCalcService;
 import com.jjt.ws.service.ITwinWorkshopService;
 import com.jjt.ws.vo.MonthCalcVO;
@@ -43,6 +44,8 @@ public class TwinWorkshopCalcServiceImpl implements ITwinWorkshopCalcService {
     private ITwinWorkshopService wsService;
     @Resource
     private IElecPriceService elecPriceService;
+    @Resource
+    private ITwinRzCalcMonthService rzCalcMonthService;
 
     /**
      * 查询能源统计
@@ -124,33 +127,47 @@ public class TwinWorkshopCalcServiceImpl implements ITwinWorkshopCalcService {
         List<TwinWorkshopCalc> calcList = new ArrayList<>();
         List<TwinWorkshop> wsList = wsService.selectTwinWorkshopList(new TwinWorkshop());
         //存储能源ID和车间ID关系
-        Map<Long, TwinWorkshopEnergy> wsMap = new HashMap<>(16);
+        Map<Long, TwinWorkshop> wsMap = new HashMap<>(16);
+        //ID-车间
+        Map<Long, TwinWorkshop> wsVoMap = new HashMap<>(16);
         wsList.forEach(ws -> {
             List<TwinWorkshopEnergy> list = wsService.selectTwinWorkshopByWsId(ws.getWsId()).getTwinWorkshopEnergyList();
-            list.forEach(o -> wsMap.put(o.getEnergyId(), o));
+            list.forEach(o -> wsMap.put(o.getEnergyId(), ws));
+            wsVoMap.put(ws.getWsId(), ws);
         });
         //获取统计数据
         List<TwinCalcHourEnergy> energyList = energyService.selectTwinEmpCalcListByDate(date);
         Map<Integer, Pair<String, BigDecimal>> elecPrice = elecPriceService.getPrice(localDate);
         energyList.forEach(obj -> {
             obj.setTeam();
-            TwinWorkshopEnergy energy = wsMap.get(obj.getEnergyId());
-            obj.setWsId(energy.getWsId());
-            switch (energy.getEnergyType()) {
-                case "1"://水
-                    obj.calcPrice(BigDecimal.valueOf(4.7));
-                    break;
-                case "2"://电
+            TwinWorkshop ws = wsMap.get(obj.getEnergyId());
+            obj.setWsId(ws.getWsId());
+            switch (ws.getWsCode()) {
+                case "WS02-D":
+                case "WS03-D-QZ":
+                case "WS03-D-HZ":
+                case "WS03-D-YR":
+                    //电
                     Pair<String, BigDecimal> pair = elecPrice.get(obj.getHour());
                     if (pair != null) {
                         obj.calcPrice(pair.getValue());
                         obj.setType(pair.getKey() + "," + pair.getValue());
                     }
                     break;
-                case "3"://油
-                    // break;
-                case "4"://汽
-                    obj.calcPrice(BigDecimal.valueOf(257));
+                case "WS03-S-YR":
+                    //水
+                    BigDecimal waterPrice = elecPrice.get(100).getValue();
+                    obj.calcPrice(waterPrice);
+                    break;
+                case "WS03-Q-DY":
+                    //低压蒸汽
+                    BigDecimal lowPrice = elecPrice.get(210).getValue();
+                    obj.calcPrice(lowPrice);
+                    break;
+                case "WS03-Q-ZY":
+                    //中亚蒸汽
+                    BigDecimal midPrice = elecPrice.get(220).getValue();
+                    obj.calcPrice(midPrice);
                     break;
                 default:
             }
@@ -175,6 +192,7 @@ public class TwinWorkshopCalcServiceImpl implements ITwinWorkshopCalcService {
 
             TwinWorkshopCalc calc = new TwinWorkshopCalc();
             calc.setWsId(wsId);
+            calc.setWsCode(wsVoMap.get(wsId).getWsCode());
             calc.setDataDate(date);
             BigDecimal totalA = BigDecimal.ZERO;
             BigDecimal totalB = BigDecimal.ZERO;
@@ -245,6 +263,7 @@ public class TwinWorkshopCalcServiceImpl implements ITwinWorkshopCalcService {
                 calcList.forEach(mapper::insertTwinWorkshopCalc);
                 sqlSession.commit();
             }
+            rzCalcMonthService.calc(date, calcList);
         }
         return 1;
     }

+ 21 - 1
jjt-biz/src/main/resources/mapper/elec/ElecPriceMapper.xml

@@ -11,10 +11,21 @@
         <result property="priceValley" column="PRICE_VALLEY"/>
         <result property="priceFlat" column="PRICE_FLAT"/>
         <result property="priceSuperPeak" column="PRICE_SUPER_PEAK"/>
+        <result property="waterPrice" column="WATER_PRICE"/>
+        <result property="lowStreamPrice" column="LOW_STREAM_PRICE"/>
+        <result property="midStreamPrice" column="MID_STREAM_PRICE"/>
     </resultMap>
 
     <sql id="selectElecPriceVo">
-        select PRICE_ID, PRICE_MONTH, PRICE_PEAK, PRICE_VALLEY, PRICE_FLAT, PRICE_SUPER_PEAK
+        select PRICE_ID,
+               PRICE_MONTH,
+               PRICE_PEAK,
+               PRICE_VALLEY,
+               PRICE_FLAT,
+               PRICE_SUPER_PEAK,
+               WATER_PRICE,
+               LOW_STREAM_PRICE,
+               MID_STREAM_PRICE
         from ELEC_PRICE
     </sql>
 
@@ -39,6 +50,9 @@
             <if test="priceValley != null">PRICE_VALLEY,</if>
             <if test="priceFlat != null">PRICE_FLAT,</if>
             <if test="priceSuperPeak != null">PRICE_SUPER_PEAK,</if>
+            <if test="waterPrice != null">WATER_PRICE,</if>
+            <if test="lowStreamPrice != null">LOW_STREAM_PRICE,</if>
+            <if test="midStreamPrice != null">MID_STREAM_PRICE,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="priceMonth != null">#{priceMonth},</if>
@@ -46,6 +60,9 @@
             <if test="priceValley != null">#{priceValley},</if>
             <if test="priceFlat != null">#{priceFlat},</if>
             <if test="priceSuperPeak != null">#{priceSuperPeak},</if>
+            <if test="waterPrice != null">#{waterPrice},</if>
+            <if test="lowStreamPrice != null">#{lowStreamPrice},</if>
+            <if test="midStreamPrice != null">#{midStreamPrice},</if>
         </trim>
     </insert>
 
@@ -57,6 +74,9 @@
             <if test="priceValley != null">PRICE_VALLEY = #{priceValley},</if>
             <if test="priceFlat != null">PRICE_FLAT = #{priceFlat},</if>
             <if test="priceSuperPeak != null">PRICE_SUPER_PEAK = #{priceSuperPeak},</if>
+            <if test="waterPrice != null">WATER_PRICE = #{waterPrice},</if>
+            <if test="lowStreamPrice != null">LOW_STREAM_PRICE = #{lowStreamPrice},</if>
+            <if test="midStreamPrice != null">MID_STREAM_PRICE = #{midStreamPrice},</if>
         </trim>
         where PRICE_ID = #{priceId}
     </update>

+ 220 - 0
jjt-biz/src/main/resources/mapper/ws/TwinRzCalcMonthMapper.xml

@@ -0,0 +1,220 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jjt.ws.mapper.TwinRzCalcMonthMapper">
+
+    <resultMap type="TwinRzCalcMonth" id="TwinRzCalcMonthResult">
+        <result property="calcId"    column="CALC_ID"    />
+        <result property="dataDate"    column="DATA_DATE"    />
+        <result property="totalPrice"    column="TOTAL_PRICE"    />
+        <result property="length"    column="LENGTH"    />
+        <result property="lengthPrice"    column="LENGTH_PRICE"    />
+        <result property="weight"    column="WEIGHT"    />
+        <result property="weightPrice"    column="WEIGHT_PRICE"    />
+        <result property="dUse"    column="D_USE"    />
+        <result property="dPrice"    column="D_PRICE"    />
+        <result property="qzUse"    column="QZ_USE"    />
+        <result property="qzPrice"    column="QZ_PRICE"    />
+        <result property="qzFUse"    column="QZ_F_USE"    />
+        <result property="qzGUse"    column="QZ_G_USE"    />
+        <result property="qzPUse"    column="QZ_P_USE"    />
+        <result property="qzJfUse"    column="QZ_JF_USE"    />
+        <result property="hzUse"    column="HZ_USE"    />
+        <result property="hzPrice"    column="HZ_PRICE"    />
+        <result property="hzFUse"    column="HZ_F_USE"    />
+        <result property="hzGUse"    column="HZ_G_USE"    />
+        <result property="hzPUse"    column="HZ_P_USE"    />
+        <result property="hzJfUse"    column="HZ_JF_USE"    />
+        <result property="yrUse"    column="YR_USE"    />
+        <result property="yrPrice"    column="YR_PRICE"    />
+        <result property="yrFUse"    column="YR_F_USE"    />
+        <result property="yrGUse"    column="YR_G_USE"    />
+        <result property="yrPUse"    column="YR_P_USE"    />
+        <result property="yrJfUse"    column="YR_JF_USE"    />
+        <result property="sPrice"    column="S_PRICE"    />
+        <result property="sUse"    column="S_USE"    />
+        <result property="qPrice"    column="Q_PRICE"    />
+        <result property="qLowUse"    column="Q_LOW_USE"    />
+        <result property="qLowPrice"    column="Q_LOW_PRICE"    />
+        <result property="qMidUse"    column="Q_MID_USE"    />
+        <result property="qMidPrice"    column="Q_MID_PRICE"    />
+    </resultMap>
+
+    <sql id="selectTwinRzCalcMonthVo">
+        select CALC_ID, DATA_DATE, TOTAL_PRICE, LENGTH, LENGTH_PRICE, WEIGHT, WEIGHT_PRICE, D_USE, D_PRICE, QZ_USE, QZ_PRICE, QZ_F_USE, QZ_G_USE, QZ_P_USE, QZ_JF_USE, HZ_USE, HZ_PRICE, HZ_F_USE, HZ_G_USE, HZ_P_USE, HZ_JF_USE, YR_USE, YR_PRICE, YR_F_USE, YR_G_USE, YR_P_USE, YR_JF_USE, S_PRICE, S_USE, Q_PRICE, Q_LOW_USE, Q_LOW_PRICE, Q_MID_USE, Q_MID_PRICE from TWIN_RZ_CALC_MONTH
+    </sql>
+
+    <select id="selectTwinRzCalcMonthList" parameterType="TwinRzCalcMonth" resultMap="TwinRzCalcMonthResult">
+        <include refid="selectTwinRzCalcMonthVo"/>
+        <where>
+            <if test="dataDate != null "> and DATA_DATE = #{dataDate}</if>
+            <if test="totalPrice != null "> and TOTAL_PRICE = #{totalPrice}</if>
+            <if test="length != null "> and LENGTH = #{length}</if>
+            <if test="lengthPrice != null "> and LENGTH_PRICE = #{lengthPrice}</if>
+            <if test="weight != null "> and WEIGHT = #{weight}</if>
+            <if test="weightPrice != null "> and WEIGHT_PRICE = #{weightPrice}</if>
+            <if test="dUse != null "> and D_USE = #{dUse}</if>
+            <if test="dPrice != null "> and D_PRICE = #{dPrice}</if>
+            <if test="qzUse != null "> and QZ_USE = #{qzUse}</if>
+            <if test="qzPrice != null "> and QZ_PRICE = #{qzPrice}</if>
+            <if test="qzFUse != null "> and QZ_F_USE = #{qzFUse}</if>
+            <if test="qzGUse != null "> and QZ_G_USE = #{qzGUse}</if>
+            <if test="qzPUse != null "> and QZ_P_USE = #{qzPUse}</if>
+            <if test="qzJfUse != null "> and QZ_JF_USE = #{qzJfUse}</if>
+            <if test="hzUse != null "> and HZ_USE = #{hzUse}</if>
+            <if test="hzPrice != null "> and HZ_PRICE = #{hzPrice}</if>
+            <if test="hzFUse != null "> and HZ_F_USE = #{hzFUse}</if>
+            <if test="hzGUse != null "> and HZ_G_USE = #{hzGUse}</if>
+            <if test="hzPUse != null "> and HZ_P_USE = #{hzPUse}</if>
+            <if test="hzJfUse != null "> and HZ_JF_USE = #{hzJfUse}</if>
+            <if test="yrUse != null "> and YR_USE = #{yrUse}</if>
+            <if test="yrPrice != null "> and YR_PRICE = #{yrPrice}</if>
+            <if test="yrFUse != null "> and YR_F_USE = #{yrFUse}</if>
+            <if test="yrGUse != null "> and YR_G_USE = #{yrGUse}</if>
+            <if test="yrPUse != null "> and YR_P_USE = #{yrPUse}</if>
+            <if test="yrJfUse != null "> and YR_JF_USE = #{yrJfUse}</if>
+            <if test="sPrice != null "> and S_PRICE = #{sPrice}</if>
+            <if test="sUse != null "> and S_USE = #{sUse}</if>
+            <if test="qPrice != null "> and Q_PRICE = #{qPrice}</if>
+            <if test="qLowUse != null "> and Q_LOW_USE = #{qLowUse}</if>
+            <if test="qLowPrice != null "> and Q_LOW_PRICE = #{qLowPrice}</if>
+            <if test="qMidUse != null "> and Q_MID_USE = #{qMidUse}</if>
+            <if test="qMidPrice != null "> and Q_MID_PRICE = #{qMidPrice}</if>
+            <if test="params.month != null and params.month != ''">
+                and FORMAT(DATA_DATE, 'yyyy-MM') = #{params.month}
+            </if>
+        </where>
+        order by data_date
+    </select>
+
+    <select id="selectTwinRzCalcMonthByCalcId" parameterType="Long" resultMap="TwinRzCalcMonthResult">
+        <include refid="selectTwinRzCalcMonthVo"/>
+        where CALC_ID = #{calcId}
+    </select>
+
+    <insert id="insertTwinRzCalcMonth" parameterType="TwinRzCalcMonth" useGeneratedKeys="true" keyProperty="calcId">
+        insert into TWIN_RZ_CALC_MONTH
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="dataDate != null">DATA_DATE,</if>
+            <if test="totalPrice != null">TOTAL_PRICE,</if>
+            <if test="length != null">LENGTH,</if>
+            <if test="lengthPrice != null">LENGTH_PRICE,</if>
+            <if test="weight != null">WEIGHT,</if>
+            <if test="weightPrice != null">WEIGHT_PRICE,</if>
+            <if test="dUse != null">D_USE,</if>
+            <if test="dPrice != null">D_PRICE,</if>
+            <if test="qzUse != null">QZ_USE,</if>
+            <if test="qzPrice != null">QZ_PRICE,</if>
+            <if test="qzFUse != null">QZ_F_USE,</if>
+            <if test="qzGUse != null">QZ_G_USE,</if>
+            <if test="qzPUse != null">QZ_P_USE,</if>
+            <if test="qzJfUse != null">QZ_JF_USE,</if>
+            <if test="hzUse != null">HZ_USE,</if>
+            <if test="hzPrice != null">HZ_PRICE,</if>
+            <if test="hzFUse != null">HZ_F_USE,</if>
+            <if test="hzGUse != null">HZ_G_USE,</if>
+            <if test="hzPUse != null">HZ_P_USE,</if>
+            <if test="hzJfUse != null">HZ_JF_USE,</if>
+            <if test="yrUse != null">YR_USE,</if>
+            <if test="yrPrice != null">YR_PRICE,</if>
+            <if test="yrFUse != null">YR_F_USE,</if>
+            <if test="yrGUse != null">YR_G_USE,</if>
+            <if test="yrPUse != null">YR_P_USE,</if>
+            <if test="yrJfUse != null">YR_JF_USE,</if>
+            <if test="sPrice != null">S_PRICE,</if>
+            <if test="sUse != null">S_USE,</if>
+            <if test="qPrice != null">Q_PRICE,</if>
+            <if test="qLowUse != null">Q_LOW_USE,</if>
+            <if test="qLowPrice != null">Q_LOW_PRICE,</if>
+            <if test="qMidUse != null">Q_MID_USE,</if>
+            <if test="qMidPrice != null">Q_MID_PRICE,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="dataDate != null">#{dataDate},</if>
+            <if test="totalPrice != null">#{totalPrice},</if>
+            <if test="length != null">#{length},</if>
+            <if test="lengthPrice != null">#{lengthPrice},</if>
+            <if test="weight != null">#{weight},</if>
+            <if test="weightPrice != null">#{weightPrice},</if>
+            <if test="dUse != null">#{dUse},</if>
+            <if test="dPrice != null">#{dPrice},</if>
+            <if test="qzUse != null">#{qzUse},</if>
+            <if test="qzPrice != null">#{qzPrice},</if>
+            <if test="qzFUse != null">#{qzFUse},</if>
+            <if test="qzGUse != null">#{qzGUse},</if>
+            <if test="qzPUse != null">#{qzPUse},</if>
+            <if test="qzJfUse != null">#{qzJfUse},</if>
+            <if test="hzUse != null">#{hzUse},</if>
+            <if test="hzPrice != null">#{hzPrice},</if>
+            <if test="hzFUse != null">#{hzFUse},</if>
+            <if test="hzGUse != null">#{hzGUse},</if>
+            <if test="hzPUse != null">#{hzPUse},</if>
+            <if test="hzJfUse != null">#{hzJfUse},</if>
+            <if test="yrUse != null">#{yrUse},</if>
+            <if test="yrPrice != null">#{yrPrice},</if>
+            <if test="yrFUse != null">#{yrFUse},</if>
+            <if test="yrGUse != null">#{yrGUse},</if>
+            <if test="yrPUse != null">#{yrPUse},</if>
+            <if test="yrJfUse != null">#{yrJfUse},</if>
+            <if test="sPrice != null">#{sPrice},</if>
+            <if test="sUse != null">#{sUse},</if>
+            <if test="qPrice != null">#{qPrice},</if>
+            <if test="qLowUse != null">#{qLowUse},</if>
+            <if test="qLowPrice != null">#{qLowPrice},</if>
+            <if test="qMidUse != null">#{qMidUse},</if>
+            <if test="qMidPrice != null">#{qMidPrice},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTwinRzCalcMonth" parameterType="TwinRzCalcMonth">
+        update TWIN_RZ_CALC_MONTH
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="dataDate != null">DATA_DATE = #{dataDate},</if>
+            <if test="totalPrice != null">TOTAL_PRICE = #{totalPrice},</if>
+            <if test="length != null">LENGTH = #{length},</if>
+            <if test="lengthPrice != null">LENGTH_PRICE = #{lengthPrice},</if>
+            <if test="weight != null">WEIGHT = #{weight},</if>
+            <if test="weightPrice != null">WEIGHT_PRICE = #{weightPrice},</if>
+            <if test="dUse != null">D_USE = #{dUse},</if>
+            <if test="dPrice != null">D_PRICE = #{dPrice},</if>
+            <if test="qzUse != null">QZ_USE = #{qzUse},</if>
+            <if test="qzPrice != null">QZ_PRICE = #{qzPrice},</if>
+            <if test="qzFUse != null">QZ_F_USE = #{qzFUse},</if>
+            <if test="qzGUse != null">QZ_G_USE = #{qzGUse},</if>
+            <if test="qzPUse != null">QZ_P_USE = #{qzPUse},</if>
+            <if test="qzJfUse != null">QZ_JF_USE = #{qzJfUse},</if>
+            <if test="hzUse != null">HZ_USE = #{hzUse},</if>
+            <if test="hzPrice != null">HZ_PRICE = #{hzPrice},</if>
+            <if test="hzFUse != null">HZ_F_USE = #{hzFUse},</if>
+            <if test="hzGUse != null">HZ_G_USE = #{hzGUse},</if>
+            <if test="hzPUse != null">HZ_P_USE = #{hzPUse},</if>
+            <if test="hzJfUse != null">HZ_JF_USE = #{hzJfUse},</if>
+            <if test="yrUse != null">YR_USE = #{yrUse},</if>
+            <if test="yrPrice != null">YR_PRICE = #{yrPrice},</if>
+            <if test="yrFUse != null">YR_F_USE = #{yrFUse},</if>
+            <if test="yrGUse != null">YR_G_USE = #{yrGUse},</if>
+            <if test="yrPUse != null">YR_P_USE = #{yrPUse},</if>
+            <if test="yrJfUse != null">YR_JF_USE = #{yrJfUse},</if>
+            <if test="sPrice != null">S_PRICE = #{sPrice},</if>
+            <if test="sUse != null">S_USE = #{sUse},</if>
+            <if test="qPrice != null">Q_PRICE = #{qPrice},</if>
+            <if test="qLowUse != null">Q_LOW_USE = #{qLowUse},</if>
+            <if test="qLowPrice != null">Q_LOW_PRICE = #{qLowPrice},</if>
+            <if test="qMidUse != null">Q_MID_USE = #{qMidUse},</if>
+            <if test="qMidPrice != null">Q_MID_PRICE = #{qMidPrice},</if>
+        </trim>
+        where CALC_ID = #{calcId}
+    </update>
+
+    <delete id="deleteTwinRzCalcMonthByCalcId" parameterType="Long">
+        delete from TWIN_RZ_CALC_MONTH where CALC_ID = #{calcId}
+    </delete>
+
+    <delete id="deleteTwinRzCalcMonthByCalcIds" parameterType="String">
+        delete from TWIN_RZ_CALC_MONTH where CALC_ID in
+        <foreach item="calcId" collection="array" open="(" separator="," close=")">
+            #{calcId}
+        </foreach>
+    </delete>
+</mapper>

BIN
jjt-biz/src/main/resources/tpl/yr-energy-month.xlsx