Kaynağa Gözat

增加能耗日报和月报

wukai 5 ay önce
ebeveyn
işleme
c0a34d85bf
40 değiştirilmiş dosya ile 1145 ekleme ve 696 silme
  1. 190 10
      ruoyi-admin/src/main/java/com/ruoyi/biz/controller/ApiController.java
  2. 5 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/controller/DataController.java
  3. 4 1
      ruoyi-admin/src/main/java/com/ruoyi/biz/controller/DemoController.java
  4. 0 127
      ruoyi-admin/src/main/java/com/ruoyi/biz/controller/TwinDeviceSpecController.java
  5. 116 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/controller/TwinWorkshopCalcController.java
  6. 13 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/domain/TwinCalcHourEnergy.java
  7. 0 102
      ruoyi-admin/src/main/java/com/ruoyi/biz/domain/TwinDeviceSpec.java
  8. 3 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/domain/TwinEmpCalc.java
  9. 57 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/domain/TwinWorkshopCalc.java
  10. 7 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/mapper/TwinCalcDayMapper.java
  11. 0 61
      ruoyi-admin/src/main/java/com/ruoyi/biz/mapper/TwinDeviceSpecMapper.java
  12. 79 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/mapper/TwinWorkshopCalcMapper.java
  13. 7 1
      ruoyi-admin/src/main/java/com/ruoyi/biz/mapper/TwinWorkshopMapper.java
  14. 10 1
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinCalcDayService.java
  15. 19 10
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinCalcHourEnergyService.java
  16. 0 61
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinDeviceSpecService.java
  17. 88 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinWorkshopCalcService.java
  18. 18 10
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinWorkshopService.java
  19. 8 8
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/AsyncServiceImpl.java
  20. 11 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinCalcDayServiceImpl.java
  21. 48 26
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinCalcHourEnergyServiceImpl.java
  22. 0 90
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinDeviceSpecServiceImpl.java
  23. 4 2
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinEmpCalcServiceImpl.java
  24. 177 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinWorkshopCalcServiceImpl.java
  25. 11 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinWorkshopServiceImpl.java
  26. 10 0
      ruoyi-admin/src/main/java/com/ruoyi/biz/task/TwinTask.java
  27. 5 0
      ruoyi-admin/src/main/resources/mapper/biz/TwinCalcDayMapper.xml
  28. 9 6
      ruoyi-admin/src/main/resources/mapper/biz/TwinCalcHourEnergyMapper.xml
  29. 33 30
      ruoyi-admin/src/main/resources/mapper/biz/TwinCalcHourSpecMapper.xml
  30. 0 80
      ruoyi-admin/src/main/resources/mapper/biz/TwinDeviceSpecMapper.xml
  31. 6 0
      ruoyi-admin/src/main/resources/mapper/biz/TwinEmpCalcMapper.xml
  32. 85 0
      ruoyi-admin/src/main/resources/mapper/biz/TwinWorkshopCalcMapper.xml
  33. 60 23
      ruoyi-admin/src/main/resources/mapper/biz/TwinWorkshopMapper.xml
  34. 6 12
      ruoyi-admin/src/main/resources/templates/biz/calcEnergy/add.html
  35. 16 20
      ruoyi-admin/src/main/resources/templates/biz/calcEnergy/calcEnergy.html
  36. 9 15
      ruoyi-admin/src/main/resources/templates/biz/calcEnergy/edit.html
  37. BIN
      ruoyi-admin/src/main/resources/tpl/energy-day.xlsx
  38. BIN
      ruoyi-admin/src/main/resources/tpl/energy-month.xlsx
  39. BIN
      ruoyi-admin/src/main/resources/tpl/productivity-day.xlsx
  40. 31 0
      ruoyi-admin/src/test/java/com/jjt/CalcSpecTest.java

+ 190 - 10
ruoyi-admin/src/main/java/com/ruoyi/biz/controller/ApiController.java

@@ -762,7 +762,7 @@ public class ApiController extends BaseController {
                 int ssr = rowNum;
                 for (TwinEmpCalc calc : list) {
                     Row row = sheet.createRow(rowNum);
-                    Cell[] cells = new Cell[9];
+                    Cell[] cells = new Cell[10];
                     for (int i = 0; i < cells.length; i++) {
                         cells[i] = row.createCell(i);
                     }
@@ -774,16 +774,17 @@ public class ApiController extends BaseController {
                         ef = ef.add(calc.getEfficiency());
                     }
 //                    cells[3].setCellValue();
-                    cells[4].setCellValue(calc.getMick());
-                    cells[5].setCellValue(calc.getDensity().setScale(2, RoundingMode.HALF_UP).doubleValue());
-                    cells[5].setCellStyle(p2);
-                    cells[6].setCellValue(calc.getLength().doubleValue());
+                    cells[4].setCellValue(calc.getHeight().setScale(2, RoundingMode.HALF_UP).doubleValue());
+                    cells[5].setCellValue(calc.getMick());
+                    cells[6].setCellValue(calc.getDensity().setScale(2, RoundingMode.HALF_UP).doubleValue());
+                    cells[6].setCellStyle(p2);
+                    cells[7].setCellValue(calc.getLength().doubleValue());
                     len = len.add(calc.getLength());
                     if (calc.getPrice() != null) {
                         BigDecimal totalPrice = calc.getTotalPrice().setScale(2, RoundingMode.HALF_UP);
                         total = total.add(totalPrice);
-                        cells[7].setCellValue(calc.getPrice().doubleValue());
-                        cells[8].setCellValue(totalPrice.doubleValue());
+                        cells[8].setCellValue(calc.getPrice().doubleValue());
+                        cells[9].setCellValue(totalPrice.doubleValue());
                     }
                     rowNum++;
                 }
@@ -793,7 +794,7 @@ public class ApiController extends BaseController {
                     sheet.addMergedRegion(new CellRangeAddress(ssr, eer, 2, 2));
                 }
             }
-            Cell[] cells = new Cell[9];
+            Cell[] cells = new Cell[10];
             Row row = sheet.createRow(rowNum);
             for (int i = 0; i < cells.length; i++) {
                 cells[i] = row.createCell(i);
@@ -804,8 +805,8 @@ public class ApiController extends BaseController {
             cells[1].setCellValue("合计");
             cells[2].setCellValue(avgEf.doubleValue());
             cells[2].setCellStyle(bkp);
-            cells[6].setCellValue(len.doubleValue());
-            cells[8].setCellValue(total.doubleValue());
+            cells[7].setCellValue(len.doubleValue());
+            cells[9].setCellValue(total.doubleValue());
             rowNum++;
 
             int er = rowNum - 1;
@@ -1242,4 +1243,183 @@ public class ApiController extends BaseController {
             ex.printStackTrace();
         }
     }
+
+    @Resource
+    private ITwinCalcHourEnergyService energyService;
+    @Resource
+    private ITwinWorkshopService wsService;
+    @Resource
+    private ITwinWorkshopCalcService calcService;
+
+    @ApiOperation("导出能耗日报")
+    @GetMapping("/export/energy-day")
+    @CrossOrigin(origins = "*")
+    public void energyDayExport(String date, HttpServletResponse response) throws ParseException {
+        LocalDate localDate = LocalDate.parse(date);
+        TwinWorkshop workshop = wsService.selectTwinWorkshopByWsCode("WS_01");
+        List<TwinWorkshopCalc> calcs = calcService.selectTwinWorkshopCalcListByDate(workshop.getWsId(), DateUtils.parseDate(date));
+        if (calcs.size() == 0) {
+            return;
+        }
+        TwinWorkshopCalc calc = calcs.get(0);
+        List<TwinCalcDay> calcDayList = twinCalcDayService.selectTwinCalcDayListByTime(DateUtils.toDate(localDate), DateUtils.toDate(localDate));
+
+        double kwhA = calcDayList.stream().mapToDouble(d -> d.getKwhA().doubleValue()).sum();
+        double kwhB = calcDayList.stream().mapToDouble(d -> d.getKwhB().doubleValue()).sum();
+        double kwh = kwhA + kwhB;
+        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("tpl/energy-day.xlsx"); XSSFWorkbook wb = new XSSFWorkbook(inputStream); OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
+            CreationHelper creationHelper = wb.getCreationHelper();
+            CellStyle percentStyle = wb.createCellStyle();
+            percentStyle.setDataFormat(creationHelper.createDataFormat().getFormat("0.00%"));
+            percentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+            CellStyle p2 = wb.createCellStyle();
+            p2.setDataFormat(wb.createDataFormat().getFormat("0.00"));
+            XSSFCellStyle bk = wb.createCellStyle();
+            bk.setFillForegroundColor(IndexedColors.LIGHT_ORANGE.getIndex());
+            bk.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+
+            Sheet sheet = wb.getSheetAt(0);
+            Cell title = sheet.getRow(0).getCell(0);
+            title.setCellValue("经编车间能耗日报(" + date + ")");
+            Cell cell2 = sheet.getRow(1).getCell(1);
+            cell2.setCellValue(calc.getAValue().add(calc.getBValue()).doubleValue());
+            Cell cell3 = sheet.getRow(2).getCell(1);
+            cell3.setCellValue(calc.getAValue().doubleValue());
+            Cell cell4 = sheet.getRow(3).getCell(1);
+            cell4.setCellValue(calc.getBValue().doubleValue());
+            Cell cell5 = sheet.getRow(4).getCell(1);
+            cell5.setCellValue(kwh);
+            Cell cell6 = sheet.getRow(5).getCell(1);
+            cell6.setCellValue(kwhA);
+            Cell cell7 = sheet.getRow(6).getCell(1);
+            cell7.setCellValue(kwhB);
+            Sheet bSheet = wb.getSheetAt(1);
+            AtomicInteger rowNum = new AtomicInteger(2);
+            calcDayList.stream().sorted(Comparator.comparing(TwinCalcDay::getKwh).reversed()).forEach(d -> {
+                Row row = bSheet.createRow(rowNum.get());
+                Cell[] cells = new Cell[4];
+                for (int i = 0; i < cells.length; i++) {
+                    cells[i] = row.createCell(i);
+                }
+
+                cells[0].setCellValue(d.getDeviceId());
+                cells[1].setCellValue(d.getKwh().doubleValue());
+                cells[2].setCellValue(d.getKwhA().doubleValue());
+                cells[3].setCellValue(d.getKwhB().doubleValue());
+
+                rowNum.getAndIncrement();
+            });
+
+            // 清空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("车间能耗日报" + localDate + ".xlsx", "UTF-8"));
+            response.setContentType("application/octet-stream");
+            wb.write(outputStream);
+            outputStream.flush();
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    @ApiOperation("导出能耗月报")
+    @GetMapping("/export/energy-month")
+    @CrossOrigin(origins = "*")
+    public void energyMonthExport(String date, HttpServletResponse response) throws ParseException {
+        date = date.substring(0, 7);
+
+        TwinWorkshop workshop = wsService.selectTwinWorkshopByWsCode("WS_01");
+        List<TwinWorkshopCalc> shopList = calcService.selectTwinWorkshopCalcListByMonth(workshop.getWsId(), date);
+        Map<Date, TwinWorkshopCalc> shopMap = shopList.stream().collect(Collectors.toMap(TwinWorkshopCalc::getDataDate, o -> o));
+        List<TwinCalcDay> dayList = twinCalcDayService.selectTwinCalcDayListByMonth(date);
+        Map<Date, List<TwinCalcDay>> dayMap = dayList.stream().collect(Collectors.groupingBy(o -> o.getTime(), LinkedHashMap::new, Collectors.toList()));
+        Set<Date> allSet = new TreeSet<>();
+        allSet.addAll(shopMap.keySet());
+        allSet.addAll(dayMap.keySet());
+        double allA = shopList.stream().mapToDouble(d -> d.getAValue().doubleValue()).sum();
+        double allB = shopList.stream().mapToDouble(d -> d.getBValue().doubleValue()).sum();
+        double all = allA + allB;
+        double kwhA = dayList.stream().mapToDouble(d -> d.getKwhA().doubleValue()).sum();
+        double kwhB = dayList.stream().mapToDouble(d -> d.getKwhB().doubleValue()).sum();
+        double kwh = kwhA + kwhB;
+
+
+        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("tpl/energy-month.xlsx"); XSSFWorkbook wb = new XSSFWorkbook(inputStream); OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
+            CreationHelper creationHelper = wb.getCreationHelper();
+            CellStyle percentStyle = wb.createCellStyle();
+            percentStyle.setDataFormat(creationHelper.createDataFormat().getFormat("0.00%"));
+            percentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+            CellStyle p2 = wb.createCellStyle();
+            p2.setDataFormat(wb.createDataFormat().getFormat("0.00"));
+            XSSFCellStyle bk = wb.createCellStyle();
+            bk.setFillForegroundColor(IndexedColors.LIGHT_ORANGE.getIndex());
+            bk.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+
+            Sheet sheet = wb.getSheetAt(0);
+            Cell title = sheet.getRow(0).getCell(0);
+            title.setCellValue("经编车间能耗月报(" + date + ")");
+            Cell cell2 = sheet.getRow(1).getCell(1);
+            cell2.setCellValue(all);
+            Cell cell3 = sheet.getRow(2).getCell(1);
+            cell3.setCellValue(allA);
+            Cell cell4 = sheet.getRow(3).getCell(1);
+            cell4.setCellValue(allB);
+            Cell cell5 = sheet.getRow(4).getCell(1);
+            cell5.setCellValue(kwh);
+            Cell cell6 = sheet.getRow(5).getCell(1);
+            cell6.setCellValue(kwhA);
+            Cell cell7 = sheet.getRow(6).getCell(1);
+            cell7.setCellValue(kwhB);
+            Sheet bSheet = wb.getSheetAt(1);
+            Cell bTitle = sheet.getRow(0).getCell(0);
+            bTitle.setCellValue("月度能耗趋势(" + date + ")");
+            AtomicInteger rowNum = new AtomicInteger(3);
+
+            for (Date day : allSet) {
+                TwinWorkshopCalc shopCalc = shopMap.get(day);
+                List<TwinCalcDay> calcDayList = dayMap.get(day);
+                Row row = bSheet.createRow(rowNum.get());
+                Cell[] cells = new Cell[7];
+                for (int i = 0; i < cells.length; i++) {
+                    cells[i] = row.createCell(i);
+                }
+                double aaa = calcDayList.stream().mapToDouble(d -> d.getKwhA().doubleValue()).sum();
+                double bbb = calcDayList.stream().mapToDouble(d -> d.getKwhB().doubleValue()).sum();
+                double ttt = aaa + bbb;
+                cells[0].setCellValue(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, day));
+                if (shopCalc != null) {
+                    cells[1].setCellValue(shopCalc.getAValue().add(shopCalc.getBValue()).doubleValue());
+                    cells[2].setCellValue(shopCalc.getAValue().doubleValue());
+                    cells[3].setCellValue(shopCalc.getBValue().doubleValue());
+                }
+                cells[4].setCellValue(ttt);
+                cells[5].setCellValue(aaa);
+                cells[6].setCellValue(bbb);
+
+                rowNum.getAndIncrement();
+            }
+
+            dayList.stream().sorted(Comparator.comparing(TwinCalcDay::getKwh).reversed()).forEach(d -> {
+
+            });
+
+            // 清空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("车间能耗月报" + date + ".xlsx", "UTF-8"));
+            response.setContentType("application/octet-stream");
+            wb.write(outputStream);
+            outputStream.flush();
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+    }
 }

+ 5 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/controller/DataController.java

@@ -53,6 +53,8 @@ public class DataController extends BaseController {
             Long endTime = end.toInstant(ZoneOffset.of("+8")).toEpochMilli();
             String sql = "DELETE FROM TWIN_CALC_HOUR WHERE DATA_DATE=? AND HOUR=?";
             jdbcTemplate.update(sql, date, sp);
+            sql = "DELETE FROM TWIN_CALC_HOUR_SPEC WHERE DATA_DATE=? AND HOUR=?";
+            jdbcTemplate.update(sql, date, sp);
             sql = "DELETE FROM TWIN_RECORD_ALARMS WHERE START_TIME<=? AND END_TIME>=?";
             jdbcTemplate.update(sql, new Date(startTime), new Date(endTime));
             sql = "DELETE FROM TWIN_PAN_HEAD_INFO WHERE RECORD_TIME>=? AND RECORD_TIME<=?";
@@ -81,6 +83,9 @@ public class DataController extends BaseController {
                 jdbcTemplate.update(sql, new Date(startTime), new Date(endTime));
                 sql = "DELETE FROM TWIN_PAN_HEAD_INFO WHERE RECORD_TIME>=? AND RECORD_TIME<=?";
                 jdbcTemplate.update(sql, new Date(startTime), new Date(endTime));
+
+                String sql1 = "DELETE FROM TWIN_CALC_HOUR_SPEC WHERE DATA_DATE=? AND HOUR=?";
+                jdbcTemplate.update(sql1, date, i);
                 taskService.calc(date, i);
             }
             sld = sld.plusDays(1);

+ 4 - 1
ruoyi-admin/src/main/java/com/ruoyi/biz/controller/DemoController.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.ruoyi.biz.domain.TwinDevice;
 import com.ruoyi.biz.service.ITwinDeviceService;
 import com.ruoyi.biz.service.ITwinEmpCalcService;
+import com.ruoyi.biz.service.ITwinWorkshopCalcService;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.R;
@@ -33,6 +34,8 @@ public class DemoController extends BaseController {
     private JdbcTemplate jdbcTemplate;
     @Resource
     private ITwinEmpCalcService twinEmpCalcService;
+    @Resource
+    private ITwinWorkshopCalcService calcService;
 
     private R<Map> usual(String data) {
         try {
@@ -47,7 +50,7 @@ public class DemoController extends BaseController {
 
     @GetMapping("/calc")
     public AjaxResult calc(String date) {
-        return toAjax(twinEmpCalcService.calc(DateUtils.parseDate(date)));
+        return toAjax(calcService.calc(DateUtils.parseDate(date)));
     }
 
     @ApiOperation("在线设备")

+ 0 - 127
ruoyi-admin/src/main/java/com/ruoyi/biz/controller/TwinDeviceSpecController.java

@@ -1,127 +0,0 @@
-package com.ruoyi.biz.controller;
-
-import java.util.List;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import com.ruoyi.common.annotation.Log;
-import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.biz.domain.TwinDeviceSpec;
-import com.ruoyi.biz.service.ITwinDeviceSpecService;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.page.TableDataInfo;
-
-/**
- * 设备规格记录Controller
- * 
- * @author ruoyi
- * @date 2024-12-19
- */
-@Controller
-@RequestMapping("/biz/spec")
-public class TwinDeviceSpecController extends BaseController
-{
-    private String prefix = "biz/spec";
-
-    @Autowired
-    private ITwinDeviceSpecService twinDeviceSpecService;
-
-    @RequiresPermissions("biz:spec:view")
-    @GetMapping()
-    public String spec()
-    {
-        return prefix + "/spec";
-    }
-
-    /**
-     * 查询设备规格记录列表
-     */
-    @RequiresPermissions("biz:spec:list")
-    @PostMapping("/list")
-    @ResponseBody
-    public TableDataInfo list(TwinDeviceSpec twinDeviceSpec)
-    {
-        startPage();
-        List<TwinDeviceSpec> list = twinDeviceSpecService.selectTwinDeviceSpecList(twinDeviceSpec);
-        return getDataTable(list);
-    }
-
-    /**
-     * 导出设备规格记录列表
-     */
-    @RequiresPermissions("biz:spec:export")
-    @Log(title = "设备规格记录", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    @ResponseBody
-    public AjaxResult export(TwinDeviceSpec twinDeviceSpec)
-    {
-        List<TwinDeviceSpec> list = twinDeviceSpecService.selectTwinDeviceSpecList(twinDeviceSpec);
-        ExcelUtil<TwinDeviceSpec> util = new ExcelUtil<TwinDeviceSpec>(TwinDeviceSpec.class);
-        return util.exportExcel(list, "设备规格记录数据");
-    }
-
-    /**
-     * 新增设备规格记录
-     */
-    @GetMapping("/add")
-    public String add()
-    {
-        return prefix + "/add";
-    }
-
-    /**
-     * 新增保存设备规格记录
-     */
-    @RequiresPermissions("biz:spec:add")
-    @Log(title = "设备规格记录", businessType = BusinessType.INSERT)
-    @PostMapping("/add")
-    @ResponseBody
-    public AjaxResult addSave(TwinDeviceSpec twinDeviceSpec)
-    {
-        return toAjax(twinDeviceSpecService.insertTwinDeviceSpec(twinDeviceSpec));
-    }
-
-    /**
-     * 修改设备规格记录
-     */
-    @RequiresPermissions("biz:spec:edit")
-    @GetMapping("/edit/{specId}")
-    public String edit(@PathVariable("specId") Long specId, ModelMap mmap)
-    {
-        TwinDeviceSpec twinDeviceSpec = twinDeviceSpecService.selectTwinDeviceSpecBySpecId(specId);
-        mmap.put("twinDeviceSpec", twinDeviceSpec);
-        return prefix + "/edit";
-    }
-
-    /**
-     * 修改保存设备规格记录
-     */
-    @RequiresPermissions("biz:spec:edit")
-    @Log(title = "设备规格记录", businessType = BusinessType.UPDATE)
-    @PostMapping("/edit")
-    @ResponseBody
-    public AjaxResult editSave(TwinDeviceSpec twinDeviceSpec)
-    {
-        return toAjax(twinDeviceSpecService.updateTwinDeviceSpec(twinDeviceSpec));
-    }
-
-    /**
-     * 删除设备规格记录
-     */
-    @RequiresPermissions("biz:spec:remove")
-    @Log(title = "设备规格记录", businessType = BusinessType.DELETE)
-    @PostMapping( "/remove")
-    @ResponseBody
-    public AjaxResult remove(String ids)
-    {
-        return toAjax(twinDeviceSpecService.deleteTwinDeviceSpecBySpecIds(ids));
-    }
-}

+ 116 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/controller/TwinWorkshopCalcController.java

@@ -0,0 +1,116 @@
+package com.ruoyi.biz.controller;
+
+import com.ruoyi.biz.domain.TwinWorkshopCalc;
+import com.ruoyi.biz.service.ITwinWorkshopCalcService;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 能源统计Controller
+ *
+ * @author ruoyi
+ * @date 2024-12-26
+ */
+@Controller
+@RequestMapping("/biz/calcWs")
+public class TwinWorkshopCalcController extends BaseController {
+    private String prefix = "biz/calcWs";
+
+    @Resource
+    private ITwinWorkshopCalcService twinWorkshopCalcService;
+
+    @RequiresPermissions("biz:calcEnergy:view")
+    @GetMapping()
+    public String calcEnergy() {
+        return prefix + "/calcEnergy";
+    }
+
+    /**
+     * 查询能源统计列表
+     */
+    @RequiresPermissions("biz:calcEnergy:list")
+    @PostMapping("/list")
+    @ResponseBody
+    public TableDataInfo list(TwinWorkshopCalc twinWorkshopCalc) {
+        startPage();
+        List<TwinWorkshopCalc> list = twinWorkshopCalcService.selectTwinWorkshopCalcList(twinWorkshopCalc);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出能源统计列表
+     */
+    @RequiresPermissions("biz:calcEnergy:export")
+    @Log(title = "能源统计", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    @ResponseBody
+    public AjaxResult export(TwinWorkshopCalc twinWorkshopCalc) {
+        List<TwinWorkshopCalc> list = twinWorkshopCalcService.selectTwinWorkshopCalcList(twinWorkshopCalc);
+        ExcelUtil<TwinWorkshopCalc> util = new ExcelUtil<TwinWorkshopCalc>(TwinWorkshopCalc.class);
+        return util.exportExcel(list, "能源统计数据");
+    }
+
+    /**
+     * 新增能源统计
+     */
+    @GetMapping("/add")
+    public String add() {
+        return prefix + "/add";
+    }
+
+    /**
+     * 新增保存能源统计
+     */
+    @RequiresPermissions("biz:calcEnergy:add")
+    @Log(title = "能源统计", businessType = BusinessType.INSERT)
+    @PostMapping("/add")
+    @ResponseBody
+    public AjaxResult addSave(TwinWorkshopCalc twinWorkshopCalc) {
+        return toAjax(twinWorkshopCalcService.insertTwinWorkshopCalc(twinWorkshopCalc));
+    }
+
+    /**
+     * 修改能源统计
+     */
+    @RequiresPermissions("biz:calcEnergy:edit")
+    @GetMapping("/edit/{calcId}")
+    public String edit(@PathVariable("calcId") Long calcId, ModelMap mmap) {
+        TwinWorkshopCalc twinWorkshopCalc = twinWorkshopCalcService.selectTwinWorkshopCalcByCalcId(calcId);
+        mmap.put("twinWorkshopCalc", twinWorkshopCalc);
+        return prefix + "/edit";
+    }
+
+    /**
+     * 修改保存能源统计
+     */
+    @RequiresPermissions("biz:calcEnergy:edit")
+    @Log(title = "能源统计", businessType = BusinessType.UPDATE)
+    @PostMapping("/edit")
+    @ResponseBody
+    public AjaxResult editSave(TwinWorkshopCalc twinWorkshopCalc) {
+        return toAjax(twinWorkshopCalcService.updateTwinWorkshopCalc(twinWorkshopCalc));
+    }
+
+    /**
+     * 删除能源统计
+     */
+    @RequiresPermissions("biz:calcEnergy:remove")
+    @Log(title = "能源统计", businessType = BusinessType.DELETE)
+    @PostMapping("/remove")
+    @ResponseBody
+    public AjaxResult remove(String ids) {
+        return toAjax(twinWorkshopCalcService.deleteTwinWorkshopCalcByCalcIds(ids));
+    }
+}

+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/domain/TwinCalcHourEnergy.java

@@ -54,5 +54,18 @@ public class TwinCalcHourEnergy extends BaseEntity {
     @Excel(name = "统计数据")
     @ApiModelProperty("统计数据")
     private BigDecimal dataValue;
+    @ApiModelProperty("班组")
+    private String team;
+    @ApiModelProperty("车间ID")
+    private Long wsId;
 
+    public void setTeam() {
+        if (this.hour >= 7 && this.hour < 19) {
+            //A班
+            this.team = "A";
+        } else {
+            //B班
+            this.team = "B";
+        }
+    }
 }

+ 0 - 102
ruoyi-admin/src/main/java/com/ruoyi/biz/domain/TwinDeviceSpec.java

@@ -1,102 +0,0 @@
-package com.ruoyi.biz.domain;
-
-import java.math.BigDecimal;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import com.ruoyi.common.annotation.Excel;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import com.ruoyi.common.core.domain.BaseEntity;
-
-/**
- * 设备规格记录对象 twin_device_spec
- *
- * @author ruoyi
- * @date 2024-12-19
- */
-@ApiModel(value = "ITwinDeviceSpec", description = "设备规格记录")
-public class TwinDeviceSpec extends BaseEntity
-{
-    private static final long serialVersionUID = 1L;
-
-    /** 统计ID */
-    private Long specId;
-
-    /** 规格 */
-    @Excel(name = "规格")
-    @ApiModelProperty("规格")
-    private String spec;
-
-    /** 米克重 */
-    @Excel(name = "米克重")
-    @ApiModelProperty("米克重")
-    private Integer mick;
-
-    /** 密度 */
-    @Excel(name = "密度")
-    @ApiModelProperty("密度")
-    private BigDecimal density;
-
-    /** 机台号 */
-    @Excel(name = "机台号")
-    @ApiModelProperty("机台号")
-    private Long deviceId;
-
-    public void setSpecId(Long specId)
-    {
-        this.specId = specId;
-    }
-
-    public Long getSpecId()
-    {
-        return specId;
-    }
-    public void setSpec(String spec)
-    {
-        this.spec = spec;
-    }
-
-    public String getSpec()
-    {
-        return spec;
-    }
-    public void setMick(Integer mick)
-    {
-        this.mick = mick;
-    }
-
-    public Integer getMick()
-    {
-        return mick;
-    }
-    public void setDensity(BigDecimal density)
-    {
-        this.density = density;
-    }
-
-    public BigDecimal getDensity()
-    {
-        return density;
-    }
-    public void setDeviceId(Long deviceId)
-    {
-        this.deviceId = deviceId;
-    }
-
-    public Long getDeviceId()
-    {
-        return deviceId;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("specId", getSpecId())
-            .append("spec", getSpec())
-            .append("mick", getMick())
-            .append("density", getDensity())
-            .append("deviceId", getDeviceId())
-            .append("createTime", getCreateTime())
-            .toString();
-    }
-}

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/domain/TwinEmpCalc.java

@@ -69,6 +69,9 @@ public class TwinEmpCalc extends BaseEntity {
     @ApiModelProperty("规格")
     private String spec;
 
+    @ApiModelProperty("毛高")
+    private BigDecimal height;
+
     /**
      * 米克重
      */

+ 57 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/domain/TwinWorkshopCalc.java

@@ -0,0 +1,57 @@
+package com.ruoyi.biz.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 能源统计对象 twin_workshop_calc
+ *
+ * @author ruoyi
+ * @date 2024-12-26
+ */
+@ApiModel(value = "ITwinWorkshopCalc", description = "能源统计")
+@Data
+public class TwinWorkshopCalc extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 统计ID
+     */
+    private Long calcId;
+
+    /**
+     * 日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
+    @ApiModelProperty("日期")
+    private Date dataDate;
+
+    /**
+     * 设备ID
+     */
+    @Excel(name = "设备ID")
+    @ApiModelProperty("车间ID")
+    private Long wsId;
+
+    /**
+     * A班统计
+     */
+    @Excel(name = "A班统计")
+    @ApiModelProperty("A班统计")
+    private BigDecimal aValue;
+
+    /**
+     * B班统计
+     */
+    @Excel(name = "B班统计")
+    @ApiModelProperty("B班统计")
+    private BigDecimal bValue;
+}

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/mapper/TwinCalcDayMapper.java

@@ -77,4 +77,11 @@ public interface TwinCalcDayMapper {
      * @param date
      */
     void delete4date(Date date);
+    /**
+     * 按月度查询
+     *
+     * @param month 月份
+     * @return 结果
+     */
+    List<TwinCalcDay> selectTwinCalcDayListByMonth(String month);
 }

+ 0 - 61
ruoyi-admin/src/main/java/com/ruoyi/biz/mapper/TwinDeviceSpecMapper.java

@@ -1,61 +0,0 @@
-package com.ruoyi.biz.mapper;
-
-import java.util.List;
-import com.ruoyi.biz.domain.TwinDeviceSpec;
-
-/**
- * 设备规格记录Mapper接口
- * 
- * @author ruoyi
- * @date 2024-12-19
- */
-public interface TwinDeviceSpecMapper 
-{
-    /**
-     * 查询设备规格记录
-     * 
-     * @param specId 设备规格记录主键
-     * @return 设备规格记录
-     */
-    public TwinDeviceSpec selectTwinDeviceSpecBySpecId(Long specId);
-
-    /**
-     * 查询设备规格记录列表
-     * 
-     * @param twinDeviceSpec 设备规格记录
-     * @return 设备规格记录集合
-     */
-    public List<TwinDeviceSpec> selectTwinDeviceSpecList(TwinDeviceSpec twinDeviceSpec);
-
-    /**
-     * 新增设备规格记录
-     * 
-     * @param twinDeviceSpec 设备规格记录
-     * @return 结果
-     */
-    public int insertTwinDeviceSpec(TwinDeviceSpec twinDeviceSpec);
-
-    /**
-     * 修改设备规格记录
-     * 
-     * @param twinDeviceSpec 设备规格记录
-     * @return 结果
-     */
-    public int updateTwinDeviceSpec(TwinDeviceSpec twinDeviceSpec);
-
-    /**
-     * 删除设备规格记录
-     * 
-     * @param specId 设备规格记录主键
-     * @return 结果
-     */
-    public int deleteTwinDeviceSpecBySpecId(Long specId);
-
-    /**
-     * 批量删除设备规格记录
-     * 
-     * @param specIds 需要删除的数据主键集合
-     * @return 结果
-     */
-    public int deleteTwinDeviceSpecBySpecIds(String[] specIds);
-}

+ 79 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/mapper/TwinWorkshopCalcMapper.java

@@ -0,0 +1,79 @@
+package com.ruoyi.biz.mapper;
+
+import com.ruoyi.biz.domain.TwinWorkshopCalc;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 能源统计Mapper接口
+ *
+ * @author ruoyi
+ * @date 2024-12-26
+ */
+public interface TwinWorkshopCalcMapper {
+    /**
+     * 查询能源统计
+     *
+     * @param calcId 能源统计主键
+     * @return 能源统计
+     */
+    public TwinWorkshopCalc selectTwinWorkshopCalcByCalcId(Long calcId);
+
+    /**
+     * 查询能源统计列表
+     *
+     * @param twinWorkshopCalc 能源统计
+     * @return 能源统计集合
+     */
+    public List<TwinWorkshopCalc> selectTwinWorkshopCalcList(TwinWorkshopCalc twinWorkshopCalc);
+
+    /**
+     * 新增能源统计
+     *
+     * @param twinWorkshopCalc 能源统计
+     * @return 结果
+     */
+    public int insertTwinWorkshopCalc(TwinWorkshopCalc twinWorkshopCalc);
+
+    /**
+     * 修改能源统计
+     *
+     * @param twinWorkshopCalc 能源统计
+     * @return 结果
+     */
+    public int updateTwinWorkshopCalc(TwinWorkshopCalc twinWorkshopCalc);
+
+    /**
+     * 删除能源统计
+     *
+     * @param calcId 能源统计主键
+     * @return 结果
+     */
+    public int deleteTwinWorkshopCalcByCalcId(Long calcId);
+
+    /**
+     * 批量删除能源统计
+     *
+     * @param calcIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTwinWorkshopCalcByCalcIds(String[] calcIds);
+
+    /**
+     * 按日期删除
+     *
+     * @param date
+     */
+    void deleteTwinWorkshopCalcByDate(Date date);
+
+    /**
+     * 按月查询
+     *
+     * @param wsId  wsid
+     * @param month 月份
+     * @return 结果
+     */
+    List<TwinWorkshopCalc> selectTwinWorkshopCalcListByMonth(@Param("wsId") Long wsId, @Param("month") String month);
+}

+ 7 - 1
ruoyi-admin/src/main/java/com/ruoyi/biz/mapper/TwinWorkshopMapper.java

@@ -92,5 +92,11 @@ public interface TwinWorkshopMapper
      * @return 结果
      */
     public int updateTwinWorkshopEnergy(TwinWorkshopEnergy twinWorkshopEnergy);
-
+    /**
+     * 查询车间管理
+     *
+     * @param wsCode 车间编码
+     * @return 车间管理
+     */
+    TwinWorkshop selectTwinWorkshopByWsCode(String wsCode);
 }

+ 10 - 1
ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinCalcDayService.java

@@ -68,7 +68,8 @@ public interface ITwinCalcDayService {
      * @param ed 结束日期
      * @return 列表
      */
-    List<TwinCalcDay> selectTwinCalcDayListByTime(Date sd,Date ed);
+    List<TwinCalcDay> selectTwinCalcDayListByTime(Date sd, Date ed);
+
     /**
      * 查询指定日期及之后的数据
      *
@@ -95,4 +96,12 @@ public interface ITwinCalcDayService {
      * @return 当日数据 7:00至第二天7点(不含)
      */
     TwinCalcDay calcToday();
+
+    /**
+     * 按月度查询
+     *
+     * @param month 月份
+     * @return 结果
+     */
+    List<TwinCalcDay> selectTwinCalcDayListByMonth(String month);
 }

+ 19 - 10
ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinCalcHourEnergyService.java

@@ -1,19 +1,20 @@
 package com.ruoyi.biz.service;
 
-import java.util.List;
 import com.ruoyi.biz.domain.TwinCalcHourEnergy;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * 能源1小时统计数据Service接口
- * 
+ *
  * @author ruoyi
  * @date 2024-12-24
  */
-public interface ITwinCalcHourEnergyService 
-{
+public interface ITwinCalcHourEnergyService {
     /**
      * 查询能源1小时统计数据
-     * 
+     *
      * @param autoId 能源1小时统计数据主键
      * @return 能源1小时统计数据
      */
@@ -21,7 +22,7 @@ public interface ITwinCalcHourEnergyService
 
     /**
      * 查询能源1小时统计数据列表
-     * 
+     *
      * @param twinCalcHourEnergy 能源1小时统计数据
      * @return 能源1小时统计数据集合
      */
@@ -29,7 +30,7 @@ public interface ITwinCalcHourEnergyService
 
     /**
      * 新增能源1小时统计数据
-     * 
+     *
      * @param twinCalcHourEnergy 能源1小时统计数据
      * @return 结果
      */
@@ -37,7 +38,7 @@ public interface ITwinCalcHourEnergyService
 
     /**
      * 修改能源1小时统计数据
-     * 
+     *
      * @param twinCalcHourEnergy 能源1小时统计数据
      * @return 结果
      */
@@ -45,7 +46,7 @@ public interface ITwinCalcHourEnergyService
 
     /**
      * 批量删除能源1小时统计数据
-     * 
+     *
      * @param autoIds 需要删除的能源1小时统计数据主键集合
      * @return 结果
      */
@@ -53,9 +54,17 @@ public interface ITwinCalcHourEnergyService
 
     /**
      * 删除能源1小时统计数据信息
-     * 
+     *
      * @param autoId 能源1小时统计数据主键
      * @return 结果
      */
     public int deleteTwinCalcHourEnergyByAutoId(Long autoId);
+
+    /**
+     * 按时间查询
+     *
+     * @param parseDate 时间
+     * @return 结果
+     */
+    List<TwinCalcHourEnergy> selectTwinEmpCalcListByDate(Date parseDate);
 }

+ 0 - 61
ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinDeviceSpecService.java

@@ -1,61 +0,0 @@
-package com.ruoyi.biz.service;
-
-import java.util.List;
-import com.ruoyi.biz.domain.TwinDeviceSpec;
-
-/**
- * 设备规格记录Service接口
- * 
- * @author ruoyi
- * @date 2024-12-19
- */
-public interface ITwinDeviceSpecService 
-{
-    /**
-     * 查询设备规格记录
-     * 
-     * @param specId 设备规格记录主键
-     * @return 设备规格记录
-     */
-    public TwinDeviceSpec selectTwinDeviceSpecBySpecId(Long specId);
-
-    /**
-     * 查询设备规格记录列表
-     * 
-     * @param twinDeviceSpec 设备规格记录
-     * @return 设备规格记录集合
-     */
-    public List<TwinDeviceSpec> selectTwinDeviceSpecList(TwinDeviceSpec twinDeviceSpec);
-
-    /**
-     * 新增设备规格记录
-     * 
-     * @param twinDeviceSpec 设备规格记录
-     * @return 结果
-     */
-    public int insertTwinDeviceSpec(TwinDeviceSpec twinDeviceSpec);
-
-    /**
-     * 修改设备规格记录
-     * 
-     * @param twinDeviceSpec 设备规格记录
-     * @return 结果
-     */
-    public int updateTwinDeviceSpec(TwinDeviceSpec twinDeviceSpec);
-
-    /**
-     * 批量删除设备规格记录
-     * 
-     * @param specIds 需要删除的设备规格记录主键集合
-     * @return 结果
-     */
-    public int deleteTwinDeviceSpecBySpecIds(String specIds);
-
-    /**
-     * 删除设备规格记录信息
-     * 
-     * @param specId 设备规格记录主键
-     * @return 结果
-     */
-    public int deleteTwinDeviceSpecBySpecId(Long specId);
-}

+ 88 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinWorkshopCalcService.java

@@ -0,0 +1,88 @@
+package com.ruoyi.biz.service;
+
+import com.ruoyi.biz.domain.TwinWorkshopCalc;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 能源统计Service接口
+ *
+ * @author ruoyi
+ * @date 2024-12-26
+ */
+public interface ITwinWorkshopCalcService {
+    /**
+     * 查询能源统计
+     *
+     * @param calcId 能源统计主键
+     * @return 能源统计
+     */
+    public TwinWorkshopCalc selectTwinWorkshopCalcByCalcId(Long calcId);
+
+    /**
+     * 查询能源统计列表
+     *
+     * @param twinWorkshopCalc 能源统计
+     * @return 能源统计集合
+     */
+    public List<TwinWorkshopCalc> selectTwinWorkshopCalcList(TwinWorkshopCalc twinWorkshopCalc);
+
+    /**
+     * 新增能源统计
+     *
+     * @param twinWorkshopCalc 能源统计
+     * @return 结果
+     */
+    public int insertTwinWorkshopCalc(TwinWorkshopCalc twinWorkshopCalc);
+
+    /**
+     * 修改能源统计
+     *
+     * @param twinWorkshopCalc 能源统计
+     * @return 结果
+     */
+    public int updateTwinWorkshopCalc(TwinWorkshopCalc twinWorkshopCalc);
+
+    /**
+     * 批量删除能源统计
+     *
+     * @param calcIds 需要删除的能源统计主键集合
+     * @return 结果
+     */
+    public int deleteTwinWorkshopCalcByCalcIds(String calcIds);
+
+    /**
+     * 删除能源统计信息
+     *
+     * @param calcId 能源统计主键
+     * @return 结果
+     */
+    public int deleteTwinWorkshopCalcByCalcId(Long calcId);
+
+    /**
+     * 能源日统计
+     *
+     * @param date 日期
+     * @return 结果
+     */
+    int calc(Date date);
+
+    /**
+     * 根据日期查询
+     *
+     * @param wsId wsid
+     * @param date 日期
+     * @return 结果
+     */
+    List<TwinWorkshopCalc> selectTwinWorkshopCalcListByDate(Long wsId, Date date);
+
+    /**
+     * 按月查询
+     *
+     * @param wsId wsid
+     * @param date 月份
+     * @return 结果
+     */
+    List<TwinWorkshopCalc> selectTwinWorkshopCalcListByMonth(Long wsId, String date);
+}

+ 18 - 10
ruoyi-admin/src/main/java/com/ruoyi/biz/service/ITwinWorkshopService.java

@@ -1,27 +1,35 @@
 package com.ruoyi.biz.service;
 
-import java.util.List;
 import com.ruoyi.biz.domain.TwinWorkshop;
 
+import java.util.List;
+
 /**
  * 车间管理Service接口
- * 
+ *
  * @author ruoyi
  * @date 2024-12-23
  */
-public interface ITwinWorkshopService 
-{
+public interface ITwinWorkshopService {
     /**
      * 查询车间管理
-     * 
+     *
      * @param wsId 车间管理主键
      * @return 车间管理
      */
     public TwinWorkshop selectTwinWorkshopByWsId(Long wsId);
 
     /**
+     * 查询车间管理
+     *
+     * @param wsCode 车间编码
+     * @return 车间管理
+     */
+    public TwinWorkshop selectTwinWorkshopByWsCode(String wsCode);
+
+    /**
      * 查询车间管理列表
-     * 
+     *
      * @param twinWorkshop 车间管理
      * @return 车间管理集合
      */
@@ -29,7 +37,7 @@ public interface ITwinWorkshopService
 
     /**
      * 新增车间管理
-     * 
+     *
      * @param twinWorkshop 车间管理
      * @return 结果
      */
@@ -37,7 +45,7 @@ public interface ITwinWorkshopService
 
     /**
      * 修改车间管理
-     * 
+     *
      * @param twinWorkshop 车间管理
      * @return 结果
      */
@@ -45,7 +53,7 @@ public interface ITwinWorkshopService
 
     /**
      * 批量删除车间管理
-     * 
+     *
      * @param wsIds 需要删除的车间管理主键集合
      * @return 结果
      */
@@ -53,7 +61,7 @@ public interface ITwinWorkshopService
 
     /**
      * 删除车间管理信息
-     * 
+     *
      * @param wsId 车间管理主键
      * @return 结果
      */

+ 8 - 8
ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/AsyncServiceImpl.java

@@ -179,7 +179,7 @@ public class AsyncServiceImpl {
         //盘头记录
         List<TwinPanHeadInfo> panHeadInfo = new ArrayList<>();
 
-        for (int i = 0; i < timestamps.size(); i++) {
+        for (int i = 0; i < values.size(); i++) {
             JSONArray da = values.getJSONArray(i);
             //0-data2,1-data37,2-data38,3-data39,4-data42,5-data-43,6data-44
             //当前时间数据
@@ -187,7 +187,7 @@ public class AsyncServiceImpl {
             int[] currPan = {da.getInt(fieldList.indexOf("Capacity_data_15")), da.getInt(fieldList.indexOf("Capacity_data_16")), da.getInt(fieldList.indexOf("Capacity_data_17")),
                     da.getInt(fieldList.indexOf("Capacity_data_18")), da.getInt(fieldList.indexOf("Capacity_data_19"))};
             int curr48 = da.getInt(7);
-            int speed = da.getInt(fieldList.indexOf("Capacity_data_1"));
+            float speed = da.getFloat(fieldList.indexOf("Capacity_data_1"));
 
             if (i == 0) {
                 //第一次数据是上次最后一条,只做记录用,不做处理
@@ -202,8 +202,8 @@ public class AsyncServiceImpl {
                 continue;
             }
 
-            if (speed == 0) {
-                //如果转速等于0,表示停机
+            if (speed == 0f) {
+                //如果转速等于0,表示停机
                 total[4]++;
             }
 
@@ -240,7 +240,9 @@ public class AsyncServiceImpl {
             //复制数组,设置last值为当前值
             last = curr.clone();
             lastPanHead = currPan.clone();
-            lastMkz = da.getInt(8);
+            if (da.getInt(8) != 0) {
+                lastMkz = da.getInt(8);
+            }
             lastFk = da.getFloat(9);
             lastHeight = da.getFloat(fieldList.indexOf("Formula_data_15"));
             last48 = curr48;
@@ -256,9 +258,7 @@ public class AsyncServiceImpl {
         //计算电量
         total[1] = endKwh - startKwh;
 
-        //存入最后一条记录的停机状态
-//        CacheUtils.put(Constants.IOT_TOKEN, table, values.getJSONArray(values.size() - 1));
-        long openTime = (endTime - startTime) / 1000 + 1;
+        long openTime = (endTime - startTime) / 1000 - 1;
         if (openTime < total[4]) {
             total[4] = openTime;
         }

+ 11 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinCalcDayServiceImpl.java

@@ -363,4 +363,15 @@ public class TwinCalcDayServiceImpl implements ITwinCalcDayService {
         return calcDay;
     }
 
+    /**
+     * 按月度查询
+     *
+     * @param month 月份
+     * @return 结果
+     */
+    @Override
+    public List<TwinCalcDay> selectTwinCalcDayListByMonth(String month) {
+        return twinCalcDayMapper.selectTwinCalcDayListByMonth(month);
+    }
+
 }

+ 48 - 26
ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinCalcHourEnergyServiceImpl.java

@@ -1,94 +1,116 @@
 package com.ruoyi.biz.service.impl;
 
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.ruoyi.biz.mapper.TwinCalcHourEnergyMapper;
 import com.ruoyi.biz.domain.TwinCalcHourEnergy;
+import com.ruoyi.biz.mapper.TwinCalcHourEnergyMapper;
 import com.ruoyi.biz.service.ITwinCalcHourEnergyService;
+import com.ruoyi.biz.tools.Tools;
 import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.utils.DateUtils;
+import javafx.util.Pair;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 能源1小时统计数据Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2024-12-24
  */
 @Service
-public class TwinCalcHourEnergyServiceImpl implements ITwinCalcHourEnergyService 
-{
-    @Autowired
+public class TwinCalcHourEnergyServiceImpl implements ITwinCalcHourEnergyService {
+    @Resource
     private TwinCalcHourEnergyMapper twinCalcHourEnergyMapper;
 
     /**
      * 查询能源1小时统计数据
-     * 
+     *
      * @param autoId 能源1小时统计数据主键
      * @return 能源1小时统计数据
      */
     @Override
-    public TwinCalcHourEnergy selectTwinCalcHourEnergyByAutoId(Long autoId)
-    {
+    public TwinCalcHourEnergy selectTwinCalcHourEnergyByAutoId(Long autoId) {
         return twinCalcHourEnergyMapper.selectTwinCalcHourEnergyByAutoId(autoId);
     }
 
     /**
      * 查询能源1小时统计数据列表
-     * 
+     *
      * @param twinCalcHourEnergy 能源1小时统计数据
      * @return 能源1小时统计数据
      */
     @Override
-    public List<TwinCalcHourEnergy> selectTwinCalcHourEnergyList(TwinCalcHourEnergy twinCalcHourEnergy)
-    {
+    public List<TwinCalcHourEnergy> selectTwinCalcHourEnergyList(TwinCalcHourEnergy twinCalcHourEnergy) {
         return twinCalcHourEnergyMapper.selectTwinCalcHourEnergyList(twinCalcHourEnergy);
     }
 
     /**
      * 新增能源1小时统计数据
-     * 
+     *
      * @param twinCalcHourEnergy 能源1小时统计数据
      * @return 结果
      */
     @Override
-    public int insertTwinCalcHourEnergy(TwinCalcHourEnergy twinCalcHourEnergy)
-    {
+    public int insertTwinCalcHourEnergy(TwinCalcHourEnergy twinCalcHourEnergy) {
         return twinCalcHourEnergyMapper.insertTwinCalcHourEnergy(twinCalcHourEnergy);
     }
 
     /**
      * 修改能源1小时统计数据
-     * 
+     *
      * @param twinCalcHourEnergy 能源1小时统计数据
      * @return 结果
      */
     @Override
-    public int updateTwinCalcHourEnergy(TwinCalcHourEnergy twinCalcHourEnergy)
-    {
+    public int updateTwinCalcHourEnergy(TwinCalcHourEnergy twinCalcHourEnergy) {
         return twinCalcHourEnergyMapper.updateTwinCalcHourEnergy(twinCalcHourEnergy);
     }
 
     /**
      * 批量删除能源1小时统计数据
-     * 
+     *
      * @param autoIds 需要删除的能源1小时统计数据主键
      * @return 结果
      */
     @Override
-    public int deleteTwinCalcHourEnergyByAutoIds(String autoIds)
-    {
+    public int deleteTwinCalcHourEnergyByAutoIds(String autoIds) {
         return twinCalcHourEnergyMapper.deleteTwinCalcHourEnergyByAutoIds(Convert.toStrArray(autoIds));
     }
 
     /**
      * 删除能源1小时统计数据信息
-     * 
+     *
      * @param autoId 能源1小时统计数据主键
      * @return 结果
      */
     @Override
-    public int deleteTwinCalcHourEnergyByAutoId(Long autoId)
-    {
+    public int deleteTwinCalcHourEnergyByAutoId(Long autoId) {
         return twinCalcHourEnergyMapper.deleteTwinCalcHourEnergyByAutoId(autoId);
     }
+
+    /**
+     * 按时间查询
+     *
+     * @param date 时间
+     * @return 结果
+     */
+    @Override
+    public List<TwinCalcHourEnergy> selectTwinEmpCalcListByDate(Date date) {
+        LocalDate localDate = DateUtils.toLocalDate(date);
+        //计算统计时间
+        Pair<Date, Date> pair = Tools.calcDay(localDate);
+        Date sTime = pair.getKey();
+        Date eTime = pair.getValue();
+        TwinCalcHourEnergy hour = new TwinCalcHourEnergy();
+        Map<String, Object> params = new HashMap<>(16);
+        params.put("sTime", sTime);
+        params.put("eTime", eTime);
+        hour.setParams(params);
+        return selectTwinCalcHourEnergyList(hour);
+    }
 }

+ 0 - 90
ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinDeviceSpecServiceImpl.java

@@ -1,90 +0,0 @@
-package com.ruoyi.biz.service.impl;
-
-import com.ruoyi.biz.domain.TwinDeviceSpec;
-import com.ruoyi.biz.mapper.TwinDeviceSpecMapper;
-import com.ruoyi.biz.service.ITwinDeviceSpecService;
-import com.ruoyi.common.core.text.Convert;
-import com.ruoyi.common.utils.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * 设备规格记录Service业务层处理
- *
- * @author ruoyi
- * @date 2024-12-19
- */
-@Service
-public class TwinDeviceSpecServiceImpl implements ITwinDeviceSpecService {
-    @Autowired
-    private TwinDeviceSpecMapper twinDeviceSpecMapper;
-
-    /**
-     * 查询设备规格记录
-     *
-     * @param specId 设备规格记录主键
-     * @return 设备规格记录
-     */
-    @Override
-    public TwinDeviceSpec selectTwinDeviceSpecBySpecId(Long specId) {
-        return twinDeviceSpecMapper.selectTwinDeviceSpecBySpecId(specId);
-    }
-
-    /**
-     * 查询设备规格记录列表
-     *
-     * @param twinDeviceSpec 设备规格记录
-     * @return 设备规格记录
-     */
-    @Override
-    public List<TwinDeviceSpec> selectTwinDeviceSpecList(TwinDeviceSpec twinDeviceSpec) {
-        return twinDeviceSpecMapper.selectTwinDeviceSpecList(twinDeviceSpec);
-    }
-
-    /**
-     * 新增设备规格记录
-     *
-     * @param twinDeviceSpec 设备规格记录
-     * @return 结果
-     */
-    @Override
-    public int insertTwinDeviceSpec(TwinDeviceSpec twinDeviceSpec) {
-        twinDeviceSpec.setCreateTime(DateUtils.getNowDate());
-        return twinDeviceSpecMapper.insertTwinDeviceSpec(twinDeviceSpec);
-    }
-
-    /**
-     * 修改设备规格记录
-     *
-     * @param twinDeviceSpec 设备规格记录
-     * @return 结果
-     */
-    @Override
-    public int updateTwinDeviceSpec(TwinDeviceSpec twinDeviceSpec) {
-        return twinDeviceSpecMapper.updateTwinDeviceSpec(twinDeviceSpec);
-    }
-
-    /**
-     * 批量删除设备规格记录
-     *
-     * @param specIds 需要删除的设备规格记录主键
-     * @return 结果
-     */
-    @Override
-    public int deleteTwinDeviceSpecBySpecIds(String specIds) {
-        return twinDeviceSpecMapper.deleteTwinDeviceSpecBySpecIds(Convert.toStrArray(specIds));
-    }
-
-    /**
-     * 删除设备规格记录信息
-     *
-     * @param specId 设备规格记录主键
-     * @return 结果
-     */
-    @Override
-    public int deleteTwinDeviceSpecBySpecId(Long specId) {
-        return twinDeviceSpecMapper.deleteTwinDeviceSpecBySpecId(specId);
-    }
-}

+ 4 - 2
ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinEmpCalcServiceImpl.java

@@ -156,17 +156,19 @@ public class TwinEmpCalcServiceImpl implements ITwinEmpCalcService {
             for (int i = 0; i < devices.length; i++) {
                 Long deviceId = devices[i];
                 List<TwinCalcHourSpec> specs = specHourMap.get(deviceId + "-" + team);
-                //按密度和米克重分组统计
-                Map<String, BigDecimal> resultMap = specs.stream().collect(Collectors.groupingBy(t -> t.getDensity() + "-" + t.getMick(), Collectors.reducing(BigDecimal.ZERO, TwinCalcHourSpec::getLength, BigDecimal::add)));
+                //按密度和米克重、毛高分组统计
+                Map<String, BigDecimal> resultMap = specs.stream().collect(Collectors.groupingBy(t -> t.getDensity() + "-" + t.getMick() + "-" + t.getHeight(), Collectors.reducing(BigDecimal.ZERO, TwinCalcHourSpec::getLength, BigDecimal::add)));
                 for (String ss : resultMap.keySet()) {
                     String[] temp = ss.split("-");
                     BigDecimal density = new BigDecimal(temp[0]).setScale(2, RoundingMode.HALF_UP);
                     Integer mick = Integer.parseInt(temp[1]);
+                    BigDecimal height = new BigDecimal(temp[2]).setScale(2, RoundingMode.HALF_UP);
                     TwinCalcDay td = calcMap.get(deviceId);
                     TwinEmpCalc calc = new TwinEmpCalc();
                     calc.setDeviceId(deviceId);
                     calc.setEfficiency(td.getEfficiencyA());
                     calc.setEmpDate(td.getTime());
+                    calc.setHeight(height);
                     BigDecimal length = resultMap.get(ss);
                     if (!flag) {
                         calc.setEfficiency(td.getEfficiencyB());

+ 177 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinWorkshopCalcServiceImpl.java

@@ -0,0 +1,177 @@
+package com.ruoyi.biz.service.impl;
+
+import com.ruoyi.biz.domain.TwinCalcHourEnergy;
+import com.ruoyi.biz.domain.TwinWorkshop;
+import com.ruoyi.biz.domain.TwinWorkshopCalc;
+import com.ruoyi.biz.domain.TwinWorkshopEnergy;
+import com.ruoyi.biz.mapper.TwinWorkshopCalcMapper;
+import com.ruoyi.biz.service.ITwinCalcHourEnergyService;
+import com.ruoyi.biz.service.ITwinWorkshopCalcService;
+import com.ruoyi.biz.service.ITwinWorkshopService;
+import com.ruoyi.common.core.text.Convert;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 能源统计Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2024-12-26
+ */
+@Service
+public class TwinWorkshopCalcServiceImpl implements ITwinWorkshopCalcService {
+    @Resource
+    private TwinWorkshopCalcMapper twinWorkshopCalcMapper;
+
+    /**
+     * 查询能源统计
+     *
+     * @param calcId 能源统计主键
+     * @return 能源统计
+     */
+    @Override
+    public TwinWorkshopCalc selectTwinWorkshopCalcByCalcId(Long calcId) {
+        return twinWorkshopCalcMapper.selectTwinWorkshopCalcByCalcId(calcId);
+    }
+
+    /**
+     * 查询能源统计列表
+     *
+     * @param twinWorkshopCalc 能源统计
+     * @return 能源统计
+     */
+    @Override
+    public List<TwinWorkshopCalc> selectTwinWorkshopCalcList(TwinWorkshopCalc twinWorkshopCalc) {
+        return twinWorkshopCalcMapper.selectTwinWorkshopCalcList(twinWorkshopCalc);
+    }
+
+    /**
+     * 新增能源统计
+     *
+     * @param twinWorkshopCalc 能源统计
+     * @return 结果
+     */
+    @Override
+    public int insertTwinWorkshopCalc(TwinWorkshopCalc twinWorkshopCalc) {
+        return twinWorkshopCalcMapper.insertTwinWorkshopCalc(twinWorkshopCalc);
+    }
+
+    /**
+     * 修改能源统计
+     *
+     * @param twinWorkshopCalc 能源统计
+     * @return 结果
+     */
+    @Override
+    public int updateTwinWorkshopCalc(TwinWorkshopCalc twinWorkshopCalc) {
+        return twinWorkshopCalcMapper.updateTwinWorkshopCalc(twinWorkshopCalc);
+    }
+
+    /**
+     * 批量删除能源统计
+     *
+     * @param calcIds 需要删除的能源统计主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinWorkshopCalcByCalcIds(String calcIds) {
+        return twinWorkshopCalcMapper.deleteTwinWorkshopCalcByCalcIds(Convert.toStrArray(calcIds));
+    }
+
+    /**
+     * 删除能源统计信息
+     *
+     * @param calcId 能源统计主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinWorkshopCalcByCalcId(Long calcId) {
+        return twinWorkshopCalcMapper.deleteTwinWorkshopCalcByCalcId(calcId);
+    }
+
+    @Resource
+    private ITwinCalcHourEnergyService energyService;
+    @Resource
+    private SqlSessionFactory factory;
+    @Resource
+    private ITwinWorkshopService wsService;
+
+    /**
+     * 能源日统计
+     *
+     * @param date 日期
+     */
+    @Override
+    public int calc(Date date) {
+        //先删除
+        twinWorkshopCalcMapper.deleteTwinWorkshopCalcByDate(date);
+        List<TwinWorkshopCalc> calcList = new ArrayList<>();
+        List<TwinWorkshop> wsList = wsService.selectTwinWorkshopList(new TwinWorkshop());
+        Map<Long, Long> wsMap = new HashMap<>(16);
+        wsList.forEach(ws -> {
+            List<TwinWorkshopEnergy> list = wsService.selectTwinWorkshopByWsId(ws.getWsId()).getTwinWorkshopEnergyList();
+            list.forEach(o -> wsMap.put(o.getEnergyId(), ws.getWsId()));
+        });
+        //获取统计数据
+        List<TwinCalcHourEnergy> energyList = energyService.selectTwinEmpCalcListByDate(date);
+        energyList.forEach(obj -> {
+            obj.setTeam();
+            obj.setWsId(wsMap.get(obj.getEnergyId()));
+        });
+        //先按ID分组
+        Map<Long, List<TwinCalcHourEnergy>> calcMap = energyList.stream().collect(Collectors.groupingBy(o -> o.getWsId(), LinkedHashMap::new, Collectors.toList()));
+        for (Long wsId : calcMap.keySet()) {
+            //按班组统计
+            Map<String, BigDecimal> resultMap = calcMap.get(wsId).stream().collect(Collectors.groupingBy(TwinCalcHourEnergy::getTeam, Collectors.reducing(BigDecimal.ZERO, TwinCalcHourEnergy::getDataValue, BigDecimal::add)));
+            TwinWorkshopCalc calc = new TwinWorkshopCalc();
+            calc.setWsId(wsId);
+            calc.setDataDate(date);
+            calc.setAValue(resultMap.get("A"));
+            calc.setBValue(resultMap.get("B"));
+            calcList.add(calc);
+
+        }
+        if (calcList.size() > 0) {
+            try (SqlSession sqlSession = factory.openSession(ExecutorType.BATCH, false)) {
+                TwinWorkshopCalcMapper mapper = sqlSession.getMapper(TwinWorkshopCalcMapper.class);
+                calcList.forEach(mapper::insertTwinWorkshopCalc);
+                sqlSession.commit();
+            }
+        }
+        return 1;
+    }
+
+    /**
+     * 根据日期查询
+     *
+     * @param wsId wsid
+     * @param date 日期
+     * @return 结果
+     */
+    @Override
+    public List<TwinWorkshopCalc> selectTwinWorkshopCalcListByDate(Long wsId, Date date) {
+        TwinWorkshopCalc search = new TwinWorkshopCalc();
+        search.setWsId(wsId);
+        search.setDataDate(date);
+        return selectTwinWorkshopCalcList(search);
+    }
+
+    /**
+     * 按月查询
+     *
+     * @param wsId wsid
+     * @param month 月份
+     * @return 结果
+     */
+    @Override
+    public List<TwinWorkshopCalc> selectTwinWorkshopCalcListByMonth(Long wsId, String month) {
+        return twinWorkshopCalcMapper.selectTwinWorkshopCalcListByMonth(wsId,month);
+    }
+}

+ 11 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/service/impl/TwinWorkshopServiceImpl.java

@@ -39,6 +39,17 @@ public class TwinWorkshopServiceImpl implements ITwinWorkshopService {
     }
 
     /**
+     * 查询车间管理
+     *
+     * @param wsCode 车间编码
+     * @return 车间管理
+     */
+    @Override
+    public TwinWorkshop selectTwinWorkshopByWsCode(String wsCode) {
+        return twinWorkshopMapper.selectTwinWorkshopByWsCode(wsCode);
+    }
+
+    /**
      * 查询车间管理列表
      *
      * @param twinWorkshop 车间管理

+ 10 - 0
ruoyi-admin/src/main/java/com/ruoyi/biz/task/TwinTask.java

@@ -29,6 +29,8 @@ public class TwinTask {
     private JdbcTemplate jdbcTemplate;
     @Resource
     private ITwinEmpCalcService empCalcService;
+    @Resource
+    private ITwinWorkshopCalcService wsCalcService;
 
     /**
      * 计算上一个小时数据
@@ -67,6 +69,14 @@ public class TwinTask {
     }
 
     /**
+     * 能源日统计
+     */
+    public void energy() {
+        LocalDate localDate = LocalDate.now().minusDays(1);
+        wsCalcService.calc(DateUtils.toDate(localDate));
+    }
+
+    /**
      * 清理数据
      *
      * @param day 天数

+ 5 - 0
ruoyi-admin/src/main/resources/mapper/biz/TwinCalcDayMapper.xml

@@ -122,6 +122,11 @@
         <if test="ed != null ">and time&lt;=#{ed}</if>
         order by time
     </select>
+    <select id="selectTwinCalcDayListByMonth" resultMap="TwinCalcDayResult">
+        <include refid="selectTwinCalcDayVo"/>
+        where DATE_FORMAT(time, '%Y-%m') = #{month}
+        order by time
+    </select>
 
     <insert id="insertTwinCalcDay" parameterType="TwinCalcDay" useGeneratedKeys="true" keyProperty="id">
         insert into twin_calc_day

+ 9 - 6
ruoyi-admin/src/main/resources/mapper/biz/TwinCalcHourEnergyMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.biz.mapper.TwinCalcHourEnergyMapper">
-    
+
     <resultMap type="TwinCalcHourEnergy" id="TwinCalcHourEnergyResult">
         <result property="autoId"    column="AUTO_ID"    />
         <result property="dataDate"    column="DATA_DATE"    />
@@ -19,20 +19,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectTwinCalcHourEnergyList" parameterType="TwinCalcHourEnergy" resultMap="TwinCalcHourEnergyResult">
         <include refid="selectTwinCalcHourEnergyVo"/>
-        <where>  
+        <where>
             <if test="dataDate != null "> and DATA_DATE = #{dataDate}</if>
             <if test="hour != null "> and HOUR = #{hour}</if>
             <if test="energyId != null "> and ENERGY_ID = #{energyId}</if>
             <if test="dataValue != null "> and DATA_VALUE = #{dataValue}</if>
             <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
+            <if test="params.sTime != null and params.eTime != null">
+                and DATE_ADD(data_date, INTERVAL `HOUR` HOUR) between #{params.sTime} and #{params.eTime}
+            </if>
         </where>
     </select>
-    
+
     <select id="selectTwinCalcHourEnergyByAutoId" parameterType="Long" resultMap="TwinCalcHourEnergyResult">
         <include refid="selectTwinCalcHourEnergyVo"/>
         where AUTO_ID = #{autoId}
     </select>
-        
+
     <insert id="insertTwinCalcHourEnergy" parameterType="TwinCalcHourEnergy" useGeneratedKeys="true" keyProperty="autoId">
         insert into twin_calc_hour_energy
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -68,10 +71,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteTwinCalcHourEnergyByAutoIds" parameterType="String">
-        delete from twin_calc_hour_energy where AUTO_ID in 
+        delete from twin_calc_hour_energy where AUTO_ID in
         <foreach item="autoId" collection="array" open="(" separator="," close=")">
             #{autoId}
         </foreach>
     </delete>
 
-</mapper>
+</mapper>

+ 33 - 30
ruoyi-admin/src/main/resources/mapper/biz/TwinCalcHourSpecMapper.xml

@@ -1,40 +1,41 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.biz.mapper.TwinCalcHourSpecMapper">
 
     <resultMap type="TwinCalcHourSpec" id="TwinCalcHourSpecResult">
-        <result property="id"    column="ID"    />
-        <result property="dataDate"    column="DATA_DATE"    />
-        <result property="hour"    column="HOUR"    />
-        <result property="deviceId"    column="DEVICE_ID"    />
-        <result property="length"    column="LENGTH"    />
-        <result property="spec"    column="SPEC"    />
-        <result property="mick"    column="MICK"    />
-        <result property="height"    column="HEIGHT"    />
-        <result property="density"    column="DENSITY"    />
-        <result property="price"    column="PRICE"    />
-        <result property="remark"    column="REMARK"    />
+        <result property="id" column="ID"/>
+        <result property="dataDate" column="DATA_DATE"/>
+        <result property="hour" column="HOUR"/>
+        <result property="deviceId" column="DEVICE_ID"/>
+        <result property="length" column="LENGTH"/>
+        <result property="spec" column="SPEC"/>
+        <result property="mick" column="MICK"/>
+        <result property="height" column="HEIGHT"/>
+        <result property="density" column="DENSITY"/>
+        <result property="price" column="PRICE"/>
+        <result property="remark" column="REMARK"/>
     </resultMap>
 
     <sql id="selectTwinCalcHourSpecVo">
-        select ID, DATA_DATE, HOUR, DEVICE_ID, LENGTH,HEIGHT, SPEC, MICK, DENSITY, PRICE, REMARK from twin_calc_hour_spec
+        select ID, DATA_DATE, HOUR, DEVICE_ID, LENGTH, HEIGHT, SPEC, MICK, DENSITY, PRICE, REMARK
+        from twin_calc_hour_spec
     </sql>
 
     <select id="selectTwinCalcHourSpecList" parameterType="TwinCalcHourSpec" resultMap="TwinCalcHourSpecResult">
         <include refid="selectTwinCalcHourSpecVo"/>
         <where>
-            <if test="dataDate != null "> and DATA_DATE = #{dataDate}</if>
-            <if test="hour != null "> and HOUR = #{hour}</if>
-            <if test="deviceId != null "> and DEVICE_ID = #{deviceId}</if>
-            <if test="length != null "> and LENGTH = #{length}</if>
-            <if test="height != null "> and height = #{height}</if>
-            <if test="spec != null  and spec != ''"> and SPEC = #{spec}</if>
-            <if test="mick != null "> and MICK = #{mick}</if>
-            <if test="density != null "> and DENSITY = #{density}</if>
-            <if test="price != null "> and PRICE = #{price}</if>
-            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
+            <if test="dataDate != null ">and DATA_DATE = #{dataDate}</if>
+            <if test="hour != null ">and HOUR = #{hour}</if>
+            <if test="deviceId != null ">and DEVICE_ID = #{deviceId}</if>
+            <if test="length != null ">and LENGTH = #{length}</if>
+            <if test="height != null ">and height = #{height}</if>
+            <if test="spec != null  and spec != ''">and SPEC = #{spec}</if>
+            <if test="mick != null ">and MICK = #{mick}</if>
+            <if test="density != null ">and DENSITY = #{density}</if>
+            <if test="price != null ">and PRICE = #{price}</if>
+            <if test="remark != null  and remark != ''">and REMARK = #{remark}</if>
             <if test="params.sTime != null and params.eTime != null">
                 and DATE_ADD(data_date, INTERVAL `HOUR` HOUR) between #{params.sTime} and #{params.eTime}
             </if>
@@ -53,25 +54,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="hour != null">HOUR,</if>
             <if test="deviceId != null">DEVICE_ID,</if>
             <if test="length != null">LENGTH,</if>
-            <if test="height != null "> HEIGHT,</if>
+            <if test="height != null ">HEIGHT,</if>
             <if test="spec != null">SPEC,</if>
             <if test="mick != null">MICK,</if>
             <if test="density != null">DENSITY,</if>
             <if test="price != null">PRICE,</if>
             <if test="remark != null">REMARK,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="dataDate != null">#{dataDate},</if>
             <if test="hour != null">#{hour},</if>
             <if test="deviceId != null">#{deviceId},</if>
             <if test="length != null">#{length},</if>
-            <if test="height != null "> #{height},</if>
+            <if test="height != null ">#{height},</if>
             <if test="spec != null">#{spec},</if>
             <if test="mick != null">#{mick},</if>
             <if test="density != null">#{density},</if>
             <if test="price != null">#{price},</if>
             <if test="remark != null">#{remark},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateTwinCalcHourSpec" parameterType="TwinCalcHourSpec">
@@ -81,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="hour != null">HOUR = #{hour},</if>
             <if test="deviceId != null">DEVICE_ID = #{deviceId},</if>
             <if test="length != null">LENGTH = #{length},</if>
-            <if test="height != null "> HEIGHT = #{height},</if>
+            <if test="height != null ">HEIGHT = #{height},</if>
             <if test="spec != null">SPEC = #{spec},</if>
             <if test="mick != null">MICK = #{mick},</if>
             <if test="density != null">DENSITY = #{density},</if>
@@ -92,7 +93,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteTwinCalcHourSpecById" parameterType="Long">
-        delete from twin_calc_hour_spec where ID = #{id}
+        delete
+        from twin_calc_hour_spec
+        where ID = #{id}
     </delete>
 
     <delete id="deleteTwinCalcHourSpecByIds" parameterType="String">

+ 0 - 80
ruoyi-admin/src/main/resources/mapper/biz/TwinDeviceSpecMapper.xml

@@ -1,80 +0,0 @@
-<?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.ruoyi.biz.mapper.TwinDeviceSpecMapper">
-
-    <resultMap type="TwinDeviceSpec" id="TwinDeviceSpecResult">
-        <result property="specId"    column="SPEC_ID"    />
-        <result property="spec"    column="SPEC"    />
-        <result property="mick"    column="MICK"    />
-        <result property="density"    column="DENSITY"    />
-        <result property="deviceId"    column="DEVICE_ID"    />
-        <result property="createTime"    column="CREATE_TIME"    />
-    </resultMap>
-
-    <sql id="selectTwinDeviceSpecVo">
-        SELECT * FROM (SELECT SPEC_ID, SPEC, MICK, DENSITY, DEVICE_ID, CREATE_TIME
-        FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY DEVICE_ID ORDER BY CREATE_TIME DESC) AS RN
-              FROM twin_device_spec) T
-        WHERE RN = 1 ORDER BY CREATE_TIME DESC ) T1
-    </sql>
-
-    <select id="selectTwinDeviceSpecList" parameterType="TwinDeviceSpec" resultMap="TwinDeviceSpecResult">
-        <include refid="selectTwinDeviceSpecVo"/>
-        <where>
-            <if test="spec != null  and spec != ''"> and SPEC = #{spec}</if>
-            <if test="mick != null "> and MICK = #{mick}</if>
-            <if test="density != null "> and DENSITY = #{density}</if>
-            <if test="deviceId != null "> and DEVICE_ID = #{deviceId}</if>
-            <if test="createTime != null "> and CREATE_TIME = #{createTime}</if>
-        </where>
-    </select>
-
-    <select id="selectTwinDeviceSpecBySpecId" parameterType="Long" resultMap="TwinDeviceSpecResult">
-        <include refid="selectTwinDeviceSpecVo"/>
-        where SPEC_ID = #{specId}
-    </select>
-
-    <insert id="insertTwinDeviceSpec" parameterType="TwinDeviceSpec" useGeneratedKeys="true" keyProperty="specId">
-        insert into twin_device_spec
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="spec != null">SPEC,</if>
-            <if test="mick != null">MICK,</if>
-            <if test="density != null">DENSITY,</if>
-            <if test="deviceId != null">DEVICE_ID,</if>
-            <if test="createTime != null">CREATE_TIME,</if>
-         </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="spec != null">#{spec},</if>
-            <if test="mick != null">#{mick},</if>
-            <if test="density != null">#{density},</if>
-            <if test="deviceId != null">#{deviceId},</if>
-            <if test="createTime != null">#{createTime},</if>
-         </trim>
-    </insert>
-
-    <update id="updateTwinDeviceSpec" parameterType="TwinDeviceSpec">
-        update twin_device_spec
-        <trim prefix="SET" suffixOverrides=",">
-            <if test="spec != null">SPEC = #{spec},</if>
-            <if test="mick != null">MICK = #{mick},</if>
-            <if test="density != null">DENSITY = #{density},</if>
-            <if test="deviceId != null">DEVICE_ID = #{deviceId},</if>
-            <if test="createTime != null">CREATE_TIME = #{createTime},</if>
-        </trim>
-        where SPEC_ID = #{specId}
-    </update>
-
-    <delete id="deleteTwinDeviceSpecBySpecId" parameterType="Long">
-        delete from twin_device_spec where SPEC_ID = #{specId}
-    </delete>
-
-    <delete id="deleteTwinDeviceSpecBySpecIds" parameterType="String">
-        delete from twin_device_spec where SPEC_ID in
-        <foreach item="specId" collection="array" open="(" separator="," close=")">
-            #{specId}
-        </foreach>
-    </delete>
-
-</mapper>

+ 6 - 0
ruoyi-admin/src/main/resources/mapper/biz/TwinEmpCalcMapper.xml

@@ -13,6 +13,7 @@
         <result property="efficiency" column="EFFICIENCY"/>
         <result property="spec" column="SPEC"/>
         <result property="mick" column="MICK"/>
+        <result property="height"    column="HEIGHT"    />
         <result property="density" column="DENSITY"/>
         <result property="length" column="LENGTH"/>
         <result property="price" column="PRICE"/>
@@ -30,6 +31,7 @@
                MICK,
                DENSITY,
                LENGTH,
+               HEIGHT,
                PRICE,
                TOTAL_PRICE
         from twin_emp_calc
@@ -47,6 +49,7 @@
             <if test="mick != null ">and MICK = #{mick}</if>
             <if test="density != null ">and DENSITY = #{density}</if>
             <if test="length != null ">and LENGTH = #{length}</if>
+            <if test="height != null ">and height = #{height}</if>
             <if test="price != null ">and PRICE = #{price}</if>
             <if test="totalPrice != null ">and TOTAL_PRICE = #{totalPrice}</if>
         </where>
@@ -75,6 +78,7 @@
             <if test="mick != null">MICK,</if>
             <if test="density != null">DENSITY,</if>
             <if test="length != null">LENGTH,</if>
+            <if test="height != null ">HEIGHT,</if>
             <if test="price != null">PRICE,</if>
             <if test="totalPrice != null">TOTAL_PRICE,</if>
         </trim>
@@ -88,6 +92,7 @@
             <if test="mick != null">#{mick},</if>
             <if test="density != null">#{density},</if>
             <if test="length != null">#{length},</if>
+            <if test="height != null ">#{height},</if>
             <if test="price != null">#{price},</if>
             <if test="totalPrice != null">#{totalPrice},</if>
         </trim>
@@ -105,6 +110,7 @@
             <if test="mick != null">MICK = #{mick},</if>
             <if test="density != null">DENSITY = #{density},</if>
             <if test="length != null">LENGTH = #{length},</if>
+            <if test="height != null ">HEIGHT = #{height},</if>
             <if test="price != null">PRICE = #{price},</if>
             <if test="totalPrice != null">TOTAL_PRICE = #{totalPrice},</if>
         </trim>

+ 85 - 0
ruoyi-admin/src/main/resources/mapper/biz/TwinWorkshopCalcMapper.xml

@@ -0,0 +1,85 @@
+<?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.ruoyi.biz.mapper.TwinWorkshopCalcMapper">
+
+    <resultMap type="TwinWorkshopCalc" id="TwinWorkshopCalcResult">
+        <result property="calcId" column="CALC_ID"/>
+        <result property="dataDate" column="DATA_DATE"/>
+        <result property="wsId" column="WS_ID"/>
+        <result property="aValue" column="A_VALUE"/>
+        <result property="bValue" column="B_VALUE"/>
+    </resultMap>
+
+    <sql id="selectTwinWorkshopCalcVo">
+        select CALC_ID, DATA_DATE, WS_ID, A_VALUE, B_VALUE
+        from twin_workshop_calc
+    </sql>
+
+    <select id="selectTwinWorkshopCalcList" parameterType="TwinWorkshopCalc" resultMap="TwinWorkshopCalcResult">
+        <include refid="selectTwinWorkshopCalcVo"/>
+        <where>
+            <if test="dataDate != null ">and DATA_DATE = #{dataDate}</if>
+            <if test="wsId != null ">and WS_ID = #{wsId}</if>
+            <if test="aValue != null ">and A_VALUE = #{aValue}</if>
+            <if test="bValue != null ">and B_VALUE = #{bValue}</if>
+        </where>
+    </select>
+
+    <select id="selectTwinWorkshopCalcByCalcId" parameterType="Long" resultMap="TwinWorkshopCalcResult">
+        <include refid="selectTwinWorkshopCalcVo"/>
+        where CALC_ID = #{calcId}
+    </select>
+    <select id="selectTwinWorkshopCalcListByMonth" resultMap="TwinWorkshopCalcResult">
+        <include refid="selectTwinWorkshopCalcVo"/>
+        where ws_id=#{wsId} and DATE_FORMAT(DATA_DATE, '%Y-%m') = #{month}
+        order by DATA_DATE
+    </select>
+
+    <insert id="insertTwinWorkshopCalc" parameterType="TwinWorkshopCalc" useGeneratedKeys="true" keyProperty="calcId">
+        insert into twin_workshop_calc
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="dataDate != null">DATA_DATE,</if>
+            <if test="wsId != null">WS_ID,</if>
+            <if test="aValue != null">A_VALUE,</if>
+            <if test="bValue != null">B_VALUE,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="dataDate != null">#{dataDate},</if>
+            <if test="wsId != null">#{wsId},</if>
+            <if test="aValue != null">#{aValue},</if>
+            <if test="bValue != null">#{bValue},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTwinWorkshopCalc" parameterType="TwinWorkshopCalc">
+        update twin_workshop_calc
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="dataDate != null">DATA_DATE = #{dataDate},</if>
+            <if test="wsId != null">WS_ID = #{wsId},</if>
+            <if test="aValue != null">A_VALUE = #{aValue},</if>
+            <if test="bValue != null">B_VALUE = #{bValue},</if>
+        </trim>
+        where CALC_ID = #{calcId}
+    </update>
+
+    <delete id="deleteTwinWorkshopCalcByCalcId" parameterType="Long">
+        delete
+        from twin_workshop_calc
+        where CALC_ID = #{calcId}
+    </delete>
+
+    <delete id="deleteTwinWorkshopCalcByCalcIds" parameterType="String">
+        delete from twin_workshop_calc where CALC_ID in
+        <foreach item="calcId" collection="array" open="(" separator="," close=")">
+            #{calcId}
+        </foreach>
+    </delete>
+    <delete id="deleteTwinWorkshopCalcByDate">
+        delete
+        from twin_workshop_calc
+        where data_date = #{date}
+    </delete>
+
+</mapper>

+ 60 - 23
ruoyi-admin/src/main/resources/mapper/biz/TwinWorkshopMapper.xml

@@ -5,48 +5,79 @@
 <mapper namespace="com.ruoyi.biz.mapper.TwinWorkshopMapper">
 
     <resultMap type="TwinWorkshop" id="TwinWorkshopResult">
-        <result property="wsId"    column="WS_ID"    />
-        <result property="wsCode"    column="WS_CODE"    />
-        <result property="wsName"    column="WS_NAME"    />
-        <result property="remark"    column="REMARK"    />
+        <result property="wsId" column="WS_ID"/>
+        <result property="wsCode" column="WS_CODE"/>
+        <result property="wsName" column="WS_NAME"/>
+        <result property="remark" column="REMARK"/>
     </resultMap>
 
     <resultMap id="TwinWorkshopTwinWorkshopEnergyResult" type="TwinWorkshop" extends="TwinWorkshopResult">
-        <collection property="twinWorkshopEnergyList" notNullColumn="sub_ENERGY_ID" javaType="java.util.List" resultMap="TwinWorkshopEnergyResult" />
+        <collection property="twinWorkshopEnergyList" notNullColumn="sub_ENERGY_ID" javaType="java.util.List"
+                    resultMap="TwinWorkshopEnergyResult"/>
     </resultMap>
 
     <resultMap type="TwinWorkshopEnergy" id="TwinWorkshopEnergyResult">
-        <result property="energyId"    column="sub_ENERGY_ID"    />
-        <result property="wsId"    column="sub_WS_ID"    />
-        <result property="energyName"    column="sub_ENERGY_NAME"    />
-        <result property="energyType"    column="sub_ENERGY_TYPE"    />
-        <result property="energyPath"    column="sub_ENERGY_PATH"    />
-        <result property="energyCode"    column="sub_ENERGY_CODE"    />
-        <result property="coefficient"    column="sub_COEFFICIENT"    />
-        <result property="remark"    column="sub_REMARK"    />
+        <result property="energyId" column="sub_ENERGY_ID"/>
+        <result property="wsId" column="sub_WS_ID"/>
+        <result property="energyName" column="sub_ENERGY_NAME"/>
+        <result property="energyType" column="sub_ENERGY_TYPE"/>
+        <result property="energyPath" column="sub_ENERGY_PATH"/>
+        <result property="energyCode" column="sub_ENERGY_CODE"/>
+        <result property="coefficient" column="sub_COEFFICIENT"/>
+        <result property="remark" column="sub_REMARK"/>
     </resultMap>
 
     <sql id="selectTwinWorkshopVo">
-        select WS_ID, WS_CODE, WS_NAME, REMARK from twin_workshop
+        select WS_ID, WS_CODE, WS_NAME, REMARK
+        from twin_workshop
     </sql>
 
     <select id="selectTwinWorkshopList" parameterType="TwinWorkshop" resultMap="TwinWorkshopResult">
         <include refid="selectTwinWorkshopVo"/>
         <where>
-            <if test="wsCode != null  and wsCode != ''"> and WS_CODE = #{wsCode}</if>
-            <if test="wsName != null  and wsName != ''"> and WS_NAME like concat('%', #{wsName}, '%')</if>
-            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
+            <if test="wsCode != null  and wsCode != ''">and WS_CODE = #{wsCode}</if>
+            <if test="wsName != null  and wsName != ''">and WS_NAME like concat('%', #{wsName}, '%')</if>
+            <if test="remark != null  and remark != ''">and REMARK = #{remark}</if>
         </where>
     </select>
 
     <select id="selectTwinWorkshopByWsId" parameterType="Long" resultMap="TwinWorkshopTwinWorkshopEnergyResult">
-        select a.WS_ID, a.WS_CODE, a.WS_NAME, a.REMARK,
-               b.ENERGY_ID as sub_ENERGY_ID, b.WS_ID as sub_WS_ID, b.ENERGY_NAME as sub_ENERGY_NAME, b.ENERGY_TYPE as sub_ENERGY_TYPE, b.ENERGY_PATH as sub_ENERGY_PATH,b.COEFFICIENT as sub_COEFFICIENT,b.ENERGY_CODE as sub_ENERGY_CODE, b.REMARK as sub_REMARK
+        select a.WS_ID,
+               a.WS_CODE,
+               a.WS_NAME,
+               a.REMARK,
+               b.ENERGY_ID   as sub_ENERGY_ID,
+               b.WS_ID       as sub_WS_ID,
+               b.ENERGY_NAME as sub_ENERGY_NAME,
+               b.ENERGY_TYPE as sub_ENERGY_TYPE,
+               b.ENERGY_PATH as sub_ENERGY_PATH,
+               b.COEFFICIENT as sub_COEFFICIENT,
+               b.ENERGY_CODE as sub_ENERGY_CODE,
+               b.REMARK      as sub_REMARK
         from twin_workshop a
                  left join twin_workshop_energy b on b.WS_ID = a.WS_ID
         where a.WS_ID = #{wsId}
     </select>
 
+    <select id="selectTwinWorkshopByWsCode" parameterType="String" resultMap="TwinWorkshopTwinWorkshopEnergyResult">
+        select a.WS_ID,
+               a.WS_CODE,
+               a.WS_NAME,
+               a.REMARK,
+               b.ENERGY_ID   as sub_ENERGY_ID,
+               b.WS_ID       as sub_WS_ID,
+               b.ENERGY_NAME as sub_ENERGY_NAME,
+               b.ENERGY_TYPE as sub_ENERGY_TYPE,
+               b.ENERGY_PATH as sub_ENERGY_PATH,
+               b.COEFFICIENT as sub_COEFFICIENT,
+               b.ENERGY_CODE as sub_ENERGY_CODE,
+               b.REMARK      as sub_REMARK
+        from twin_workshop a
+                 left join twin_workshop_energy b on b.WS_ID = a.WS_ID
+        where a.WS_CODE = #{wsCode}
+
+    </select>
+
     <insert id="insertTwinWorkshop" parameterType="TwinWorkshop" useGeneratedKeys="true" keyProperty="wsId">
         insert into twin_workshop
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -85,7 +116,9 @@
     </update>
 
     <delete id="deleteTwinWorkshopByWsId" parameterType="Long">
-        delete from twin_workshop where WS_ID = #{wsId}
+        delete
+        from twin_workshop
+        where WS_ID = #{wsId}
     </delete>
 
     <delete id="deleteTwinWorkshopByWsIds" parameterType="String">
@@ -103,13 +136,17 @@
     </delete>
 
     <delete id="deleteTwinWorkshopEnergyByWsId" parameterType="Long">
-        delete from twin_workshop_energy where WS_ID = #{wsId}
+        delete
+        from twin_workshop_energy
+        where WS_ID = #{wsId}
     </delete>
 
     <insert id="batchTwinWorkshopEnergy">
-        insert into twin_workshop_energy( ENERGY_ID, WS_ID, ENERGY_NAME, ENERGY_TYPE, ENERGY_PATH,COEFFICIENT, ENERGY_CODE, REMARK) values
+        insert into twin_workshop_energy( ENERGY_ID, WS_ID, ENERGY_NAME, ENERGY_TYPE, ENERGY_PATH,COEFFICIENT,
+        ENERGY_CODE, REMARK) values
         <foreach item="item" index="index" collection="list" separator=",">
-            ( #{item.energyId}, #{item.wsId}, #{item.energyName}, #{item.energyType}, #{item.energyPath}, #{item.coefficient}, #{item.energyCode}, #{item.remark})
+            ( #{item.energyId}, #{item.wsId}, #{item.energyName}, #{item.energyType}, #{item.energyPath},
+            #{item.coefficient}, #{item.energyCode}, #{item.remark})
         </foreach>
     </insert>
 

+ 6 - 12
ruoyi-admin/src/main/resources/templates/biz/calcEnergy/add.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
 <head>
-    <th:block th:include="include :: header('新增能源1小时统计数据')" />
+    <th:block th:include="include :: header('新增能源统计')" />
     <th:block th:include="include :: datetimepicker-css" />
 </head>
 <body class="white-bg">
@@ -17,27 +17,21 @@
                 </div>
             </div>
             <div class="form-group">    
-                <label class="col-sm-3 control-label">小时;0-23:</label>
-                <div class="col-sm-8">
-                    <input name="hour" class="form-control" type="text">
-                </div>
-            </div>
-            <div class="form-group">    
                 <label class="col-sm-3 control-label">设备ID:</label>
                 <div class="col-sm-8">
                     <input name="energyId" class="form-control" type="text">
                 </div>
             </div>
             <div class="form-group">    
-                <label class="col-sm-3 control-label">统计数据:</label>
+                <label class="col-sm-3 control-label">A班统计:</label>
                 <div class="col-sm-8">
-                    <input name="dataValue" class="form-control" type="text">
+                    <input name="aValue" class="form-control" type="text">
                 </div>
             </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label">备注:</label>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">B班统计:</label>
                 <div class="col-sm-8">
-                    <textarea name="remark" class="form-control"></textarea>
+                    <input name="bValue" class="form-control" type="text">
                 </div>
             </div>
         </form>

+ 16 - 20
ruoyi-admin/src/main/resources/templates/biz/calcEnergy/calcEnergy.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
 <head>
-    <th:block th:include="include :: header('能源1小时统计数据列表')" />
+    <th:block th:include="include :: header('能源统计列表')" />
 </head>
 <body class="gray-bg">
      <div class="container-div">
@@ -15,16 +15,16 @@
                                 <input type="text" class="time-input" placeholder="请选择日期" name="dataDate"/>
                             </li>
                             <li>
-                                <label>小时;0-23:</label>
-                                <input type="text" name="hour"/>
-                            </li>
-                            <li>
                                 <label>设备ID:</label>
                                 <input type="text" name="energyId"/>
                             </li>
                             <li>
-                                <label>统计数据:</label>
-                                <input type="text" name="dataValue"/>
+                                <label>A班统计:</label>
+                                <input type="text" name="aValue"/>
+                            </li>
+                            <li>
+                                <label>B班统计:</label>
+                                <input type="text" name="bValue"/>
                             </li>
                             <li>
                                 <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
@@ -67,13 +67,13 @@
                 updateUrl: prefix + "/edit/{id}",
                 removeUrl: prefix + "/remove",
                 exportUrl: prefix + "/export",
-                modalName: "能源1小时统计数据",
+                modalName: "能源统计",
                 columns: [{
                     checkbox: true
                 },
                 {
-                    field: 'autoId',
-                    title: 'ID',
+                    field: 'calcId',
+                    title: '统计ID',
                     visible: false
                 },
                 {
@@ -81,28 +81,24 @@
                     title: '日期'
                 },
                 {
-                    field: 'hour',
-                    title: '小时;0-23'
-                },
-                {
                     field: 'energyId',
                     title: '设备ID'
                 },
                 {
-                    field: 'dataValue',
-                    title: '统计数据'
+                    field: 'aValue',
+                    title: 'A班统计'
                 },
                 {
-                    field: 'remark',
-                    title: '备注'
+                    field: 'bValue',
+                    title: 'B班统计'
                 },
                 {
                     title: '操作',
                     align: 'center',
                     formatter: function(value, row, index) {
                         var actions = [];
-                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.autoId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
-                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.autoId + '\')"><i class="fa fa-remove"></i>删除</a>');
+                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.calcId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
+                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.calcId + '\')"><i class="fa fa-remove"></i>删除</a>');
                         return actions.join('');
                     }
                 }]

+ 9 - 15
ruoyi-admin/src/main/resources/templates/biz/calcEnergy/edit.html

@@ -1,44 +1,38 @@
 <!DOCTYPE html>
 <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
 <head>
-    <th:block th:include="include :: header('修改能源1小时统计数据')" />
+    <th:block th:include="include :: header('修改能源统计')" />
     <th:block th:include="include :: datetimepicker-css" />
 </head>
 <body class="white-bg">
     <div class="wrapper wrapper-content animated fadeInRight ibox-content">
-        <form class="form-horizontal m" id="form-calcEnergy-edit" th:object="${twinCalcHourEnergy}">
-            <input name="autoId" th:field="*{autoId}" type="hidden">
+        <form class="form-horizontal m" id="form-calcEnergy-edit" th:object="${twinWorkshopCalc}">
+            <input name="calcId" th:field="*{calcId}" type="hidden">
             <div class="form-group">    
                 <label class="col-sm-3 control-label">日期:</label>
                 <div class="col-sm-8">
                     <div class="input-group date">
-                        <input name="dataDate" th:value="${#dates.format(twinCalcHourEnergy.dataDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
+                        <input name="dataDate" th:value="${#dates.format(twinWorkshopCalc.dataDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                         <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                     </div>
                 </div>
             </div>
             <div class="form-group">    
-                <label class="col-sm-3 control-label">小时;0-23:</label>
-                <div class="col-sm-8">
-                    <input name="hour" th:field="*{hour}" class="form-control" type="text">
-                </div>
-            </div>
-            <div class="form-group">    
                 <label class="col-sm-3 control-label">设备ID:</label>
                 <div class="col-sm-8">
                     <input name="energyId" th:field="*{energyId}" class="form-control" type="text">
                 </div>
             </div>
             <div class="form-group">    
-                <label class="col-sm-3 control-label">统计数据:</label>
+                <label class="col-sm-3 control-label">A班统计:</label>
                 <div class="col-sm-8">
-                    <input name="dataValue" th:field="*{dataValue}" class="form-control" type="text">
+                    <input name="aValue" th:field="*{aValue}" class="form-control" type="text">
                 </div>
             </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label">备注:</label>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">B班统计:</label>
                 <div class="col-sm-8">
-                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
+                    <input name="bValue" th:field="*{bValue}" class="form-control" type="text">
                 </div>
             </div>
         </form>

BIN
ruoyi-admin/src/main/resources/tpl/energy-day.xlsx


BIN
ruoyi-admin/src/main/resources/tpl/energy-month.xlsx


BIN
ruoyi-admin/src/main/resources/tpl/productivity-day.xlsx


+ 31 - 0
ruoyi-admin/src/test/java/com/jjt/CalcSpecTest.java

@@ -0,0 +1,31 @@
+package com.jjt;
+
+import com.ruoyi.RuoYiApplication;
+import com.ruoyi.biz.service.ITaskService;
+import com.ruoyi.biz.service.ITwinEmpCalcService;
+import com.ruoyi.common.utils.DateUtils;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import javax.annotation.Resource;
+import java.time.LocalDate;
+
+/**
+ * DataProcess$
+ *
+ * @author wukai
+ * @date 2024/5/7 11:49
+ */
+@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class CalcSpecTest {
+    @Resource
+    private ITwinEmpCalcService empCalcService;
+
+    @Test
+    void test() {
+        LocalDate localDate = LocalDate.now().minusDays(2);
+        empCalcService.calc(DateUtils.toDate(localDate));
+    }
+
+
+}