wukai 3 сар өмнө
parent
commit
5df805b92e
27 өөрчлөгдсөн 2476 нэмэгдсэн , 8 устгасан
  1. 191 4
      jjt-admin/src/test/java/com/jjt/data/PrintingTest.java
  2. 111 0
      jjt-biz/src/main/java/com/jjt/biz/controller/TwinDeviceAllController.java
  3. 113 0
      jjt-biz/src/main/java/com/jjt/biz/controller/TwinDeviceYhjController.java
  4. 72 0
      jjt-biz/src/main/java/com/jjt/biz/domain/TwinDeviceAll.java
  5. 43 0
      jjt-biz/src/main/java/com/jjt/biz/domain/TwinDeviceYhj.java
  6. 62 0
      jjt-biz/src/main/java/com/jjt/biz/mapper/TwinDeviceAllMapper.java
  7. 62 0
      jjt-biz/src/main/java/com/jjt/biz/mapper/TwinDeviceYhjMapper.java
  8. 60 0
      jjt-biz/src/main/java/com/jjt/biz/service/ITwinDeviceAllService.java
  9. 60 0
      jjt-biz/src/main/java/com/jjt/biz/service/ITwinDeviceYhjService.java
  10. 86 0
      jjt-biz/src/main/java/com/jjt/biz/service/impl/TwinDeviceAllServiceImpl.java
  11. 86 0
      jjt-biz/src/main/java/com/jjt/biz/service/impl/TwinDeviceYhjServiceImpl.java
  12. 113 0
      jjt-biz/src/main/java/com/jjt/calc/controller/TwinCalcDayYhjController.java
  13. 113 0
      jjt-biz/src/main/java/com/jjt/calc/controller/TwinCalcHourYhjController.java
  14. 1 4
      jjt-biz/src/main/java/com/jjt/calc/controller/TwinCalcStopController.java
  15. 82 0
      jjt-biz/src/main/java/com/jjt/calc/domain/TwinCalcDayYhj.java
  16. 78 0
      jjt-biz/src/main/java/com/jjt/calc/domain/TwinCalcHourYhj.java
  17. 64 0
      jjt-biz/src/main/java/com/jjt/calc/mapper/TwinCalcDayYhjMapper.java
  18. 72 0
      jjt-biz/src/main/java/com/jjt/calc/mapper/TwinCalcHourYhjMapper.java
  19. 67 0
      jjt-biz/src/main/java/com/jjt/calc/service/ITwinCalcDayYhjService.java
  20. 75 0
      jjt-biz/src/main/java/com/jjt/calc/service/ITwinCalcHourYhjService.java
  21. 163 0
      jjt-biz/src/main/java/com/jjt/calc/service/impl/TwinCalcDayYhjServiceImpl.java
  22. 273 0
      jjt-biz/src/main/java/com/jjt/calc/service/impl/TwinCalcHourYhjServiceImpl.java
  23. 43 0
      jjt-biz/src/main/java/com/jjt/task/YhjTask.java
  24. 101 0
      jjt-biz/src/main/resources/mapper/biz/TwinDeviceAllMapper.xml
  25. 70 0
      jjt-biz/src/main/resources/mapper/biz/TwinDeviceYhjMapper.xml
  26. 120 0
      jjt-biz/src/main/resources/mapper/calc/TwinCalcDayYhjMapper.xml
  27. 95 0
      jjt-biz/src/main/resources/mapper/calc/TwinCalcHourYhjMapper.xml

+ 191 - 4
jjt-admin/src/test/java/com/jjt/data/PrintingTest.java

@@ -3,8 +3,17 @@ package com.jjt.data;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import com.jjt.JjtApplication;
+import com.jjt.biz.domain.TwinDeviceYhj;
+import com.jjt.biz.service.ITwinDeviceYhjService;
+import com.jjt.calc.domain.TwinCalcHourYhj;
+import com.jjt.calc.mapper.TwinCalcHourYhjMapper;
+import com.jjt.calc.service.ITwinCalcDayYhjService;
+import com.jjt.calc.service.ITwinCalcHourYhjService;
 import com.jjt.common.utils.DateUtils;
 import com.jjt.utils.IotService;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -12,7 +21,6 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.jdbc.core.JdbcTemplate;
 
 import javax.annotation.Resource;
 import java.io.FileOutputStream;
@@ -21,9 +29,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneOffset;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -33,6 +39,186 @@ import java.util.concurrent.atomic.AtomicInteger;
 public class PrintingTest {
     @Resource
     private IotService iotService;
+    @Resource
+    private SqlSessionFactory factory;
+    @Resource
+    private ITwinDeviceYhjService yhjService;
+    @Resource
+    private ITwinCalcHourYhjService calcHourYhjService;
+    @Resource
+    private ITwinCalcDayYhjService calcDayYhjService;
+
+    public static void main(String[] args) {
+        Integer[] lines = {1, 2, 3, 4, 5, 6, 7, 8};
+        List<String> lists = new ArrayList<>();
+        String[] fields = {"Formula_data_set_1", "Formula_data_act_5"};
+        String device = "yhj_line%s_PLC1.%s";
+        for (int i = 0; i < lines.length; i++) {
+            for (String field : fields) {
+                String tmp = String.format(device, lines[i], field);
+                lists.add(tmp);
+            }
+        }
+
+        System.err.println(lists);
+    }
+
+    @Test
+    void day() {
+        String day = "2025-03-02";
+        LocalDate localDate = LocalDate.parse(day);
+        calcDayYhjService.day(localDate);
+    }
+
+    @Test
+    void t2() {
+        iotService.setToken();
+        String st = "2025-03-02";
+        String ed = "2025-03-06";
+        LocalDate localDate = LocalDate.parse(st);
+        LocalDate endDate = LocalDate.parse(ed);
+        LocalDateTime start = LocalDateTime.of(localDate, LocalTime.MIN);
+        LocalDateTime end = LocalDateTime.of(endDate, LocalTime.MIN).plusHours(23);
+        LocalDateTime curr = LocalDateTime.now();
+        if (end.isAfter(curr)) {
+            end = curr.minusHours(1);
+        }
+        do {
+            int i = start.getHour();
+            System.err.println(start.toLocalDate().toString() + "\t" + i);
+            calcHourYhjService.calc(start, start.plusHours(1));
+//            if (i == 6) {
+//                dayService.day(start.toLocalDate());
+//            }
+            start = start.plusHours(1);
+        } while (!start.isAfter(end));
+//        calcHourYhjService.calc();
+
+    }
+
+    @Test
+    void t1() {
+        iotService.setToken();
+        List<TwinDeviceYhj> list = yhjService.selectTwinDeviceYhjList(new TwinDeviceYhj());
+        List<TwinCalcHourYhj> calcList = new ArrayList<>();
+        //  使用设备编码作为Map的key, 使用设备对象本身作为Map的value, 如果有重复的key,保留现有的value
+        Map<String, TwinDeviceYhj> yhjMap = new HashMap<>();
+        List<String> fieldList = new ArrayList<>();
+        String prefix = "root.tl.suxi";
+        String[] fields = {"Formula_data_set_1", "Formula_data_act_5"};
+        for (TwinDeviceYhj yhj : list) {
+            for (String field : fields) {
+                String tmp = yhj.getDeviceCode() + "." + field;
+                fieldList.add(tmp);
+                yhjMap.put(prefix + "." + tmp, yhj);
+            }
+        }
+        String sql = "select %s from " + prefix + " where time>%s and time <=%s";
+
+        sql = String.format(sql, String.join(",", fieldList), "2025-03-02T00:00:00", "2025-03-02T01:00:00");
+        JSONObject jsonObject = iotService.query(sql);
+        JSONObject data = jsonObject.getJSONObject("data");
+        JSONArray columnNames = data.getJSONArray("columnNames");
+        JSONArray values = data.getJSONArray("values");
+        JSONArray timestamps = data.getJSONArray("timestamps");
+        //记录上一次记录的值
+        Integer[] last = new Integer[columnNames.size()];
+        //记录最后一次的值,防中间有数,后面没数
+        Integer[] over = new Integer[columnNames.size()];
+        //当前记录值
+        Integer[] total = new Integer[columnNames.size()];
+        //记录第一次记录的值,如果清0,则记录清零时刻的值
+        Integer[] first = new Integer[columnNames.size()];
+        //记录统计值
+        Integer[] curr = new Integer[columnNames.size()];
+        for (int i = 0; i < values.size(); i++) {
+            JSONArray da = values.getJSONArray(i);
+            da.toList(Integer.class).toArray(curr);
+            if (i == 0) {
+                cloneArray(curr, last);
+                cloneArray(curr, first);
+                cloneArray(curr, over);
+                continue;
+            }
+            for (int j = 0; j < columnNames.size(); j++) {
+                String name = columnNames.getStr(j);
+                if (name.contains("Formula_data_set_1")) {
+                    //如果是版距,则需要记录变化
+                    if (curr[j] != null && last[j] != null && curr[j].intValue() != last[j].intValue()) {
+                        //这里要用j+1才行
+                        calc(j + 1, last, first, total);
+                        combo(calcList, yhjMap.get(name), last[j], total[j + 1]);
+                        total[j + 1] = 0;
+                    }
+                }
+                if (name.contains("Formula_data_act_5")) {
+                    //如果是米长,则需要记录是否清0
+                    //如果当前值为小于上一个,且上一个值不为0,则计算
+                    //因为会出现数据波动,停机再启动之后的第一个点不为0,为0.00几几几的
+                    if (curr[j] != null && last[j] != null && curr[j] < last[j] && last[j] != 0) {
+                        calc(j, last, first, total);
+                        cloneArray(curr, first);
+                    }
+                }
+            }
+            //将本次的值,设为上一条记录了
+            cloneArray(curr, last);
+            cloneArray(curr, over);
+            cloneArrayFirst(curr, first);
+        }
+        for (int j = 0; j < columnNames.size(); j++) {
+            String name = columnNames.getStr(j);
+            if (name.contains("Formula_data_set_1")) {
+                calc(j + 1, over, first, total);
+                combo(calcList, yhjMap.get(name), over[j], total[j + 1]);
+            }
+        }
+
+        try (SqlSession sqlSession = factory.openSession(ExecutorType.BATCH, false)) {
+            if (calcList.size() > 0) {
+                TwinCalcHourYhjMapper mapper = sqlSession.getMapper(TwinCalcHourYhjMapper.class);
+                calcList.forEach(mapper::insertTwinCalcHourYhj);
+                sqlSession.commit();
+            }
+        }
+        System.err.println(total);
+    }
+
+    void cloneArrayFirst(Integer[] arr, Integer[] target) {
+        for (int i = 0; i < arr.length; i++) {
+            if (arr[i] != null && target[i] == null) {
+                target[i] = arr[i];
+            }
+        }
+    }
+
+    void cloneArray(Integer[] arr, Integer[] target) {
+        for (int i = 0; i < arr.length; i++) {
+            if (arr[i] != null) {
+                target[i] = arr[i];
+            }
+        }
+    }
+
+    void combo(List<TwinCalcHourYhj> calcList, TwinDeviceYhj yhj, Integer distance, Integer length) {
+        if (distance != null && length != null) {
+            TwinCalcHourYhj calcHourYhj = new TwinCalcHourYhj();
+            calcHourYhj.setDeviceId(yhj.getDeviceId());
+            calcHourYhj.setDistance(distance);
+            calcHourYhj.setLength(length);
+            calcList.add(calcHourYhj);
+        }
+    }
+
+    void calc(int j, Integer[] last, Integer[] first, Integer[] total) {
+        if (last[j] != null && first[j] != null) {
+            if (total[j] == null) {
+                total[j] = 0;
+            }
+            total[j] += (last[j] - first[j]);
+        }
+    }
+
 
     /**
      * 印花设备数据
@@ -42,6 +228,7 @@ public class PrintingTest {
         iotService.setToken();
         Integer[] lines = {1, 2, 3, 4, 5, 6, 7, 8};
         List<String[]>[] lists = new ArrayList[8];
+        String[] fields = {"Formula_data_set_1", "Formula_data_act_5"};
         for (int i = 0; i < lines.length; i++) {
             String table = "root.tl.suxi.yhj_line" + lines[i] + "_PLC1";
             lists[i] = new ArrayList<>();

+ 111 - 0
jjt-biz/src/main/java/com/jjt/biz/controller/TwinDeviceAllController.java

@@ -0,0 +1,111 @@
+package com.jjt.biz.controller;
+
+import java.util.List;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.jjt.common.annotation.Log;
+import com.jjt.common.core.controller.BaseController;
+import com.jjt.common.core.domain.AjaxResult;
+import com.jjt.common.enums.BusinessType;
+import com.jjt.biz.domain.TwinDeviceAll;
+import com.jjt.biz.service.ITwinDeviceAllService;
+import com.jjt.common.utils.poi.ExcelUtil;
+
+/**
+ * 全厂设备管理Controller
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+@Api(tags="全厂设备管理")
+@RestController
+@RequestMapping("/biz/all")
+public class TwinDeviceAllController extends BaseController{
+    @Resource
+    private ITwinDeviceAllService twinDeviceAllService;
+
+    /**
+     * 查询全厂设备管理列表
+     */
+    @ApiOperation("查询全厂设备管理列表")
+    @PreAuthorize("@ss.hasPermi('biz:all:list')")
+    @GetMapping("/list")
+    public AjaxResult list(TwinDeviceAll twinDeviceAll)
+    {
+        List<TwinDeviceAll> list = twinDeviceAllService.selectTwinDeviceAllList(twinDeviceAll);
+        return success(list);
+    }
+
+    /**
+     * 导出全厂设备管理列表
+     */
+    @ApiOperation("导出全厂设备管理列表")
+    @PreAuthorize("@ss.hasPermi('biz:all:export')")
+    @Log(title = "全厂设备管理", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TwinDeviceAll twinDeviceAll)
+    {
+        List<TwinDeviceAll> list = twinDeviceAllService.selectTwinDeviceAllList(twinDeviceAll);
+        ExcelUtil<TwinDeviceAll> util = new ExcelUtil<TwinDeviceAll>(TwinDeviceAll.class);
+        util.exportExcel(response, list, "全厂设备管理数据");
+    }
+
+    /**
+     * 获取全厂设备管理详细信息
+     */
+    @ApiOperation("获取全厂设备管理详细信息")
+    @PreAuthorize("@ss.hasPermi('biz:all:query')")
+    @GetMapping(value = "/{deviceId}")
+    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
+    {
+        return success(twinDeviceAllService.selectTwinDeviceAllByDeviceId(deviceId));
+    }
+
+    /**
+     * 新增全厂设备管理
+     */
+    @ApiOperation("新增全厂设备管理")
+    @PreAuthorize("@ss.hasPermi('biz:all:add')")
+    @Log(title = "全厂设备管理", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TwinDeviceAll twinDeviceAll)
+    {
+        return toAjax(twinDeviceAllService.insertTwinDeviceAll(twinDeviceAll));
+    }
+
+    /**
+     * 修改全厂设备管理
+     */
+    @ApiOperation("修改全厂设备管理")
+    @PreAuthorize("@ss.hasPermi('biz:all:edit')")
+    @Log(title = "全厂设备管理", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TwinDeviceAll twinDeviceAll)
+    {
+        return toAjax(twinDeviceAllService.updateTwinDeviceAll(twinDeviceAll));
+    }
+
+    /**
+     * 删除全厂设备管理
+     */
+    @ApiOperation("删除全厂设备管理")
+    @PreAuthorize("@ss.hasPermi('biz:all:remove')")
+    @Log(title = "全厂设备管理", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{deviceIds}")
+    public AjaxResult remove(@PathVariable Long[] deviceIds)
+    {
+        return toAjax(twinDeviceAllService.deleteTwinDeviceAllByDeviceIds(deviceIds));
+    }
+}

+ 113 - 0
jjt-biz/src/main/java/com/jjt/biz/controller/TwinDeviceYhjController.java

@@ -0,0 +1,113 @@
+package com.jjt.biz.controller;
+
+import java.util.List;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.jjt.common.annotation.Log;
+import com.jjt.common.core.controller.BaseController;
+import com.jjt.common.core.domain.AjaxResult;
+import com.jjt.common.enums.BusinessType;
+import com.jjt.biz.domain.TwinDeviceYhj;
+import com.jjt.biz.service.ITwinDeviceYhjService;
+import com.jjt.common.utils.poi.ExcelUtil;
+import com.jjt.common.core.page.TableDataInfo;
+
+/**
+ * 印花机设备管理Controller
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+@Api(tags="印花机设备管理")
+@RestController
+@RequestMapping("/biz/yhj")
+public class TwinDeviceYhjController extends BaseController{
+    @Resource
+    private ITwinDeviceYhjService twinDeviceYhjService;
+
+    /**
+     * 查询印花机设备管理列表
+     */
+    @ApiOperation("查询印花机设备管理列表")
+    @PreAuthorize("@ss.hasPermi('biz:yhj:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TwinDeviceYhj twinDeviceYhj)
+    {
+        startPage();
+        List<TwinDeviceYhj> list = twinDeviceYhjService.selectTwinDeviceYhjList(twinDeviceYhj);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出印花机设备管理列表
+     */
+    @ApiOperation("导出印花机设备管理列表")
+    @PreAuthorize("@ss.hasPermi('biz:yhj:export')")
+    @Log(title = "印花机设备管理", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TwinDeviceYhj twinDeviceYhj)
+    {
+        List<TwinDeviceYhj> list = twinDeviceYhjService.selectTwinDeviceYhjList(twinDeviceYhj);
+        ExcelUtil<TwinDeviceYhj> util = new ExcelUtil<TwinDeviceYhj>(TwinDeviceYhj.class);
+        util.exportExcel(response, list, "印花机设备管理数据");
+    }
+
+    /**
+     * 获取印花机设备管理详细信息
+     */
+    @ApiOperation("获取印花机设备管理详细信息")
+    @PreAuthorize("@ss.hasPermi('biz:yhj:query')")
+    @GetMapping(value = "/{deviceId}")
+    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
+    {
+        return success(twinDeviceYhjService.selectTwinDeviceYhjByDeviceId(deviceId));
+    }
+
+    /**
+     * 新增印花机设备管理
+     */
+    @ApiOperation("新增印花机设备管理")
+    @PreAuthorize("@ss.hasPermi('biz:yhj:add')")
+    @Log(title = "印花机设备管理", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TwinDeviceYhj twinDeviceYhj)
+    {
+        return toAjax(twinDeviceYhjService.insertTwinDeviceYhj(twinDeviceYhj));
+    }
+
+    /**
+     * 修改印花机设备管理
+     */
+    @ApiOperation("修改印花机设备管理")
+    @PreAuthorize("@ss.hasPermi('biz:yhj:edit')")
+    @Log(title = "印花机设备管理", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TwinDeviceYhj twinDeviceYhj)
+    {
+        return toAjax(twinDeviceYhjService.updateTwinDeviceYhj(twinDeviceYhj));
+    }
+
+    /**
+     * 删除印花机设备管理
+     */
+    @ApiOperation("删除印花机设备管理")
+    @PreAuthorize("@ss.hasPermi('biz:yhj:remove')")
+    @Log(title = "印花机设备管理", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{deviceIds}")
+    public AjaxResult remove(@PathVariable Long[] deviceIds)
+    {
+        return toAjax(twinDeviceYhjService.deleteTwinDeviceYhjByDeviceIds(deviceIds));
+    }
+}

+ 72 - 0
jjt-biz/src/main/java/com/jjt/biz/domain/TwinDeviceAll.java

@@ -0,0 +1,72 @@
+package com.jjt.biz.domain;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.jjt.common.annotation.Excel;
+import com.jjt.common.core.domain.TreeEntity;
+
+/**
+ * 全厂设备管理对象 TWIN_DEVICE_ALL
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+@ApiModel(value = "TwinDeviceAll", description = "全厂设备管理")
+@Data
+public class TwinDeviceAll extends TreeEntity{
+    private static final long serialVersionUID = 1L;
+
+    /** ID */
+    @ApiModelProperty("ID")
+    @TableId
+    private Long deviceId;
+
+    /** 排序号 */
+    @ApiModelProperty("排序号")
+    @Excel(name = "排序号")
+    private String sortNum;
+
+    /** 设备名称 */
+    @ApiModelProperty("设备名称")
+    @Excel(name = "设备名称")
+    private String deviceName;
+
+    /** 设备编码 */
+    @ApiModelProperty("设备编码")
+    @Excel(name = "设备编码")
+    private String deviceCode;
+
+    /** 设备路径 */
+    @ApiModelProperty("设备路径")
+    @Excel(name = "设备路径")
+    private String devicePath;
+
+    /** 创建人 */
+    @ApiModelProperty("创建人")
+    @Excel(name = "创建人")
+    private String createdBy;
+
+    /** 创建时间 */
+    @ApiModelProperty("创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date createdTime;
+
+    /** 更新人 */
+    @ApiModelProperty("更新人")
+    @Excel(name = "更新人")
+    private String updatedBy;
+
+    /** 更新时间 */
+    @ApiModelProperty("更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date updatedTime;
+
+}

+ 43 - 0
jjt-biz/src/main/java/com/jjt/biz/domain/TwinDeviceYhj.java

@@ -0,0 +1,43 @@
+package com.jjt.biz.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.jjt.common.annotation.Excel;
+import com.jjt.common.core.domain.BaseEntity;
+
+/**
+ * 印花机设备管理对象 TWIN_DEVICE_YHJ
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+@ApiModel(value = "TwinDeviceYhj", description = "印花机设备管理")
+@Data
+public class TwinDeviceYhj extends BaseEntity{
+    private static final long serialVersionUID = 1L;
+
+    /** ID */
+    @ApiModelProperty("ID")
+    @TableId
+    private Long deviceId;
+
+    /** 设备名称 */
+    @ApiModelProperty("设备名称")
+    @Excel(name = "设备名称")
+    private String deviceName;
+
+    /** 设备编码 */
+    @ApiModelProperty("设备编码")
+    @Excel(name = "设备编码")
+    private String deviceCode;
+
+    /** 设备路径 */
+    @ApiModelProperty("设备路径")
+    @Excel(name = "设备路径")
+    private String devicePath;
+
+}

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

@@ -0,0 +1,62 @@
+package com.jjt.biz.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jjt.biz.domain.TwinDeviceAll;
+
+/**
+ * 全厂设备管理Mapper接口
+ * 
+ * @author wukai
+ * @date 2025-03-06
+ */
+public interface TwinDeviceAllMapper extends BaseMapper<TwinDeviceAll>
+{
+    /**
+     * 查询全厂设备管理
+     * 
+     * @param deviceId 全厂设备管理主键
+     * @return 全厂设备管理
+     */
+    public TwinDeviceAll selectTwinDeviceAllByDeviceId(Long deviceId);
+
+    /**
+     * 查询全厂设备管理列表
+     * 
+     * @param twinDeviceAll 全厂设备管理
+     * @return 全厂设备管理集合
+     */
+    public List<TwinDeviceAll> selectTwinDeviceAllList(TwinDeviceAll twinDeviceAll);
+
+    /**
+     * 新增全厂设备管理
+     * 
+     * @param twinDeviceAll 全厂设备管理
+     * @return 结果
+     */
+    public int insertTwinDeviceAll(TwinDeviceAll twinDeviceAll);
+
+    /**
+     * 修改全厂设备管理
+     * 
+     * @param twinDeviceAll 全厂设备管理
+     * @return 结果
+     */
+    public int updateTwinDeviceAll(TwinDeviceAll twinDeviceAll);
+
+    /**
+     * 删除全厂设备管理
+     * 
+     * @param deviceId 全厂设备管理主键
+     * @return 结果
+     */
+    public int deleteTwinDeviceAllByDeviceId(Long deviceId);
+
+    /**
+     * 批量删除全厂设备管理
+     * 
+     * @param deviceIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTwinDeviceAllByDeviceIds(Long[] deviceIds);
+}

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

@@ -0,0 +1,62 @@
+package com.jjt.biz.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jjt.biz.domain.TwinDeviceYhj;
+
+/**
+ * 印花机设备管理Mapper接口
+ * 
+ * @author wukai
+ * @date 2025-03-06
+ */
+public interface TwinDeviceYhjMapper extends BaseMapper<TwinDeviceYhj>
+{
+    /**
+     * 查询印花机设备管理
+     * 
+     * @param deviceId 印花机设备管理主键
+     * @return 印花机设备管理
+     */
+    public TwinDeviceYhj selectTwinDeviceYhjByDeviceId(Long deviceId);
+
+    /**
+     * 查询印花机设备管理列表
+     * 
+     * @param twinDeviceYhj 印花机设备管理
+     * @return 印花机设备管理集合
+     */
+    public List<TwinDeviceYhj> selectTwinDeviceYhjList(TwinDeviceYhj twinDeviceYhj);
+
+    /**
+     * 新增印花机设备管理
+     * 
+     * @param twinDeviceYhj 印花机设备管理
+     * @return 结果
+     */
+    public int insertTwinDeviceYhj(TwinDeviceYhj twinDeviceYhj);
+
+    /**
+     * 修改印花机设备管理
+     * 
+     * @param twinDeviceYhj 印花机设备管理
+     * @return 结果
+     */
+    public int updateTwinDeviceYhj(TwinDeviceYhj twinDeviceYhj);
+
+    /**
+     * 删除印花机设备管理
+     * 
+     * @param deviceId 印花机设备管理主键
+     * @return 结果
+     */
+    public int deleteTwinDeviceYhjByDeviceId(Long deviceId);
+
+    /**
+     * 批量删除印花机设备管理
+     * 
+     * @param deviceIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTwinDeviceYhjByDeviceIds(Long[] deviceIds);
+}

+ 60 - 0
jjt-biz/src/main/java/com/jjt/biz/service/ITwinDeviceAllService.java

@@ -0,0 +1,60 @@
+package com.jjt.biz.service;
+
+import java.util.List;
+import com.jjt.biz.domain.TwinDeviceAll;
+
+/**
+ * 全厂设备管理Service接口
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+public interface ITwinDeviceAllService {
+    /**
+     * 查询全厂设备管理
+     *
+     * @param deviceId 全厂设备管理主键
+     * @return 全厂设备管理
+     */
+    public TwinDeviceAll selectTwinDeviceAllByDeviceId(Long deviceId);
+
+    /**
+     * 查询全厂设备管理列表
+     *
+     * @param twinDeviceAll 全厂设备管理
+     * @return 全厂设备管理集合
+     */
+    public List<TwinDeviceAll> selectTwinDeviceAllList(TwinDeviceAll twinDeviceAll);
+
+    /**
+     * 新增全厂设备管理
+     *
+     * @param twinDeviceAll 全厂设备管理
+     * @return 结果
+     */
+    public int insertTwinDeviceAll(TwinDeviceAll twinDeviceAll);
+
+    /**
+     * 修改全厂设备管理
+     *
+     * @param twinDeviceAll 全厂设备管理
+     * @return 结果
+     */
+    public int updateTwinDeviceAll(TwinDeviceAll twinDeviceAll);
+
+    /**
+     * 批量删除全厂设备管理
+     *
+     * @param deviceIds 需要删除的全厂设备管理主键集合
+     * @return 结果
+     */
+    public int deleteTwinDeviceAllByDeviceIds(Long[] deviceIds);
+
+    /**
+     * 删除全厂设备管理信息
+     *
+     * @param deviceId 全厂设备管理主键
+     * @return 结果
+     */
+    public int deleteTwinDeviceAllByDeviceId(Long deviceId);
+}

+ 60 - 0
jjt-biz/src/main/java/com/jjt/biz/service/ITwinDeviceYhjService.java

@@ -0,0 +1,60 @@
+package com.jjt.biz.service;
+
+import java.util.List;
+import com.jjt.biz.domain.TwinDeviceYhj;
+
+/**
+ * 印花机设备管理Service接口
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+public interface ITwinDeviceYhjService {
+    /**
+     * 查询印花机设备管理
+     *
+     * @param deviceId 印花机设备管理主键
+     * @return 印花机设备管理
+     */
+    public TwinDeviceYhj selectTwinDeviceYhjByDeviceId(Long deviceId);
+
+    /**
+     * 查询印花机设备管理列表
+     *
+     * @param twinDeviceYhj 印花机设备管理
+     * @return 印花机设备管理集合
+     */
+    public List<TwinDeviceYhj> selectTwinDeviceYhjList(TwinDeviceYhj twinDeviceYhj);
+
+    /**
+     * 新增印花机设备管理
+     *
+     * @param twinDeviceYhj 印花机设备管理
+     * @return 结果
+     */
+    public int insertTwinDeviceYhj(TwinDeviceYhj twinDeviceYhj);
+
+    /**
+     * 修改印花机设备管理
+     *
+     * @param twinDeviceYhj 印花机设备管理
+     * @return 结果
+     */
+    public int updateTwinDeviceYhj(TwinDeviceYhj twinDeviceYhj);
+
+    /**
+     * 批量删除印花机设备管理
+     *
+     * @param deviceIds 需要删除的印花机设备管理主键集合
+     * @return 结果
+     */
+    public int deleteTwinDeviceYhjByDeviceIds(Long[] deviceIds);
+
+    /**
+     * 删除印花机设备管理信息
+     *
+     * @param deviceId 印花机设备管理主键
+     * @return 结果
+     */
+    public int deleteTwinDeviceYhjByDeviceId(Long deviceId);
+}

+ 86 - 0
jjt-biz/src/main/java/com/jjt/biz/service/impl/TwinDeviceAllServiceImpl.java

@@ -0,0 +1,86 @@
+package com.jjt.biz.service.impl;
+
+import java.util.List;
+import org.springframework.stereotype.Service;
+import com.jjt.biz.mapper.TwinDeviceAllMapper;
+import com.jjt.biz.domain.TwinDeviceAll;
+import com.jjt.biz.service.ITwinDeviceAllService;
+import javax.annotation.Resource;
+
+/**
+ * 全厂设备管理Service业务层处理
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+@Service
+public class TwinDeviceAllServiceImpl implements ITwinDeviceAllService {
+    @Resource
+    private TwinDeviceAllMapper twinDeviceAllMapper;
+
+    /**
+     * 查询全厂设备管理
+     *
+     * @param deviceId 全厂设备管理主键
+     * @return 全厂设备管理
+     */
+    @Override
+    public TwinDeviceAll selectTwinDeviceAllByDeviceId(Long deviceId) {
+        return twinDeviceAllMapper.selectTwinDeviceAllByDeviceId(deviceId);
+    }
+
+    /**
+     * 查询全厂设备管理列表
+     *
+     * @param twinDeviceAll 全厂设备管理
+     * @return 全厂设备管理
+     */
+    @Override
+    public List<TwinDeviceAll> selectTwinDeviceAllList(TwinDeviceAll twinDeviceAll) {
+        return twinDeviceAllMapper.selectTwinDeviceAllList(twinDeviceAll);
+    }
+
+    /**
+     * 新增全厂设备管理
+     *
+     * @param twinDeviceAll 全厂设备管理
+     * @return 结果
+     */
+    @Override
+    public int insertTwinDeviceAll(TwinDeviceAll twinDeviceAll) {
+            return twinDeviceAllMapper.insertTwinDeviceAll(twinDeviceAll);
+    }
+
+    /**
+     * 修改全厂设备管理
+     *
+     * @param twinDeviceAll 全厂设备管理
+     * @return 结果
+     */
+    @Override
+    public int updateTwinDeviceAll(TwinDeviceAll twinDeviceAll) {
+        return twinDeviceAllMapper.updateTwinDeviceAll(twinDeviceAll);
+    }
+
+    /**
+     * 批量删除全厂设备管理
+     *
+     * @param deviceIds 需要删除的全厂设备管理主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinDeviceAllByDeviceIds(Long[] deviceIds) {
+        return twinDeviceAllMapper.deleteTwinDeviceAllByDeviceIds(deviceIds);
+    }
+
+    /**
+     * 删除全厂设备管理信息
+     *
+     * @param deviceId 全厂设备管理主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinDeviceAllByDeviceId(Long deviceId) {
+        return twinDeviceAllMapper.deleteTwinDeviceAllByDeviceId(deviceId);
+    }
+}

+ 86 - 0
jjt-biz/src/main/java/com/jjt/biz/service/impl/TwinDeviceYhjServiceImpl.java

@@ -0,0 +1,86 @@
+package com.jjt.biz.service.impl;
+
+import java.util.List;
+import org.springframework.stereotype.Service;
+import com.jjt.biz.mapper.TwinDeviceYhjMapper;
+import com.jjt.biz.domain.TwinDeviceYhj;
+import com.jjt.biz.service.ITwinDeviceYhjService;
+import javax.annotation.Resource;
+
+/**
+ * 印花机设备管理Service业务层处理
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+@Service
+public class TwinDeviceYhjServiceImpl implements ITwinDeviceYhjService {
+    @Resource
+    private TwinDeviceYhjMapper twinDeviceYhjMapper;
+
+    /**
+     * 查询印花机设备管理
+     *
+     * @param deviceId 印花机设备管理主键
+     * @return 印花机设备管理
+     */
+    @Override
+    public TwinDeviceYhj selectTwinDeviceYhjByDeviceId(Long deviceId) {
+        return twinDeviceYhjMapper.selectTwinDeviceYhjByDeviceId(deviceId);
+    }
+
+    /**
+     * 查询印花机设备管理列表
+     *
+     * @param twinDeviceYhj 印花机设备管理
+     * @return 印花机设备管理
+     */
+    @Override
+    public List<TwinDeviceYhj> selectTwinDeviceYhjList(TwinDeviceYhj twinDeviceYhj) {
+        return twinDeviceYhjMapper.selectTwinDeviceYhjList(twinDeviceYhj);
+    }
+
+    /**
+     * 新增印花机设备管理
+     *
+     * @param twinDeviceYhj 印花机设备管理
+     * @return 结果
+     */
+    @Override
+    public int insertTwinDeviceYhj(TwinDeviceYhj twinDeviceYhj) {
+            return twinDeviceYhjMapper.insertTwinDeviceYhj(twinDeviceYhj);
+    }
+
+    /**
+     * 修改印花机设备管理
+     *
+     * @param twinDeviceYhj 印花机设备管理
+     * @return 结果
+     */
+    @Override
+    public int updateTwinDeviceYhj(TwinDeviceYhj twinDeviceYhj) {
+        return twinDeviceYhjMapper.updateTwinDeviceYhj(twinDeviceYhj);
+    }
+
+    /**
+     * 批量删除印花机设备管理
+     *
+     * @param deviceIds 需要删除的印花机设备管理主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinDeviceYhjByDeviceIds(Long[] deviceIds) {
+        return twinDeviceYhjMapper.deleteTwinDeviceYhjByDeviceIds(deviceIds);
+    }
+
+    /**
+     * 删除印花机设备管理信息
+     *
+     * @param deviceId 印花机设备管理主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinDeviceYhjByDeviceId(Long deviceId) {
+        return twinDeviceYhjMapper.deleteTwinDeviceYhjByDeviceId(deviceId);
+    }
+}

+ 113 - 0
jjt-biz/src/main/java/com/jjt/calc/controller/TwinCalcDayYhjController.java

@@ -0,0 +1,113 @@
+package com.jjt.calc.controller;
+
+import java.util.List;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.jjt.common.annotation.Log;
+import com.jjt.common.core.controller.BaseController;
+import com.jjt.common.core.domain.AjaxResult;
+import com.jjt.common.enums.BusinessType;
+import com.jjt.calc.domain.TwinCalcDayYhj;
+import com.jjt.calc.service.ITwinCalcDayYhjService;
+import com.jjt.common.utils.poi.ExcelUtil;
+import com.jjt.common.core.page.TableDataInfo;
+
+/**
+ * 印花机日统计数据Controller
+ *
+ * @author wukai
+ * @date 2025-03-07
+ */
+@Api(tags="印花机日统计数据")
+@RestController
+@RequestMapping("/calc/dayYhj")
+public class TwinCalcDayYhjController extends BaseController{
+    @Resource
+    private ITwinCalcDayYhjService twinCalcDayYhjService;
+
+    /**
+     * 查询印花机日统计数据列表
+     */
+    @ApiOperation("查询印花机日统计数据列表")
+    @PreAuthorize("@ss.hasPermi('calc:dayYhj:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TwinCalcDayYhj twinCalcDayYhj)
+    {
+        startPage();
+        List<TwinCalcDayYhj> list = twinCalcDayYhjService.selectTwinCalcDayYhjList(twinCalcDayYhj);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出印花机日统计数据列表
+     */
+    @ApiOperation("导出印花机日统计数据列表")
+    @PreAuthorize("@ss.hasPermi('calc:dayYhj:export')")
+    @Log(title = "印花机日统计数据", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TwinCalcDayYhj twinCalcDayYhj)
+    {
+        List<TwinCalcDayYhj> list = twinCalcDayYhjService.selectTwinCalcDayYhjList(twinCalcDayYhj);
+        ExcelUtil<TwinCalcDayYhj> util = new ExcelUtil<TwinCalcDayYhj>(TwinCalcDayYhj.class);
+        util.exportExcel(response, list, "印花机日统计数据数据");
+    }
+
+    /**
+     * 获取印花机日统计数据详细信息
+     */
+    @ApiOperation("获取印花机日统计数据详细信息")
+    @PreAuthorize("@ss.hasPermi('calc:dayYhj:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(twinCalcDayYhjService.selectTwinCalcDayYhjById(id));
+    }
+
+    /**
+     * 新增印花机日统计数据
+     */
+    @ApiOperation("新增印花机日统计数据")
+    @PreAuthorize("@ss.hasPermi('calc:dayYhj:add')")
+    @Log(title = "印花机日统计数据", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TwinCalcDayYhj twinCalcDayYhj)
+    {
+        return toAjax(twinCalcDayYhjService.insertTwinCalcDayYhj(twinCalcDayYhj));
+    }
+
+    /**
+     * 修改印花机日统计数据
+     */
+    @ApiOperation("修改印花机日统计数据")
+    @PreAuthorize("@ss.hasPermi('calc:dayYhj:edit')")
+    @Log(title = "印花机日统计数据", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TwinCalcDayYhj twinCalcDayYhj)
+    {
+        return toAjax(twinCalcDayYhjService.updateTwinCalcDayYhj(twinCalcDayYhj));
+    }
+
+    /**
+     * 删除印花机日统计数据
+     */
+    @ApiOperation("删除印花机日统计数据")
+    @PreAuthorize("@ss.hasPermi('calc:dayYhj:remove')")
+    @Log(title = "印花机日统计数据", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(twinCalcDayYhjService.deleteTwinCalcDayYhjByIds(ids));
+    }
+}

+ 113 - 0
jjt-biz/src/main/java/com/jjt/calc/controller/TwinCalcHourYhjController.java

@@ -0,0 +1,113 @@
+package com.jjt.calc.controller;
+
+import java.util.List;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.jjt.common.annotation.Log;
+import com.jjt.common.core.controller.BaseController;
+import com.jjt.common.core.domain.AjaxResult;
+import com.jjt.common.enums.BusinessType;
+import com.jjt.calc.domain.TwinCalcHourYhj;
+import com.jjt.calc.service.ITwinCalcHourYhjService;
+import com.jjt.common.utils.poi.ExcelUtil;
+import com.jjt.common.core.page.TableDataInfo;
+
+/**
+ * 印花机1小时统计数据Controller
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+@Api(tags="印花机1小时统计数据")
+@RestController
+@RequestMapping("/calc/calcYhj")
+public class TwinCalcHourYhjController extends BaseController{
+    @Resource
+    private ITwinCalcHourYhjService twinCalcHourYhjService;
+
+    /**
+     * 查询印花机1小时统计数据列表
+     */
+    @ApiOperation("查询印花机1小时统计数据列表")
+    @PreAuthorize("@ss.hasPermi('calc:calcYhj:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TwinCalcHourYhj twinCalcHourYhj)
+    {
+        startPage();
+        List<TwinCalcHourYhj> list = twinCalcHourYhjService.selectTwinCalcHourYhjList(twinCalcHourYhj);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出印花机1小时统计数据列表
+     */
+    @ApiOperation("导出印花机1小时统计数据列表")
+    @PreAuthorize("@ss.hasPermi('calc:calcYhj:export')")
+    @Log(title = "印花机1小时统计数据", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TwinCalcHourYhj twinCalcHourYhj)
+    {
+        List<TwinCalcHourYhj> list = twinCalcHourYhjService.selectTwinCalcHourYhjList(twinCalcHourYhj);
+        ExcelUtil<TwinCalcHourYhj> util = new ExcelUtil<TwinCalcHourYhj>(TwinCalcHourYhj.class);
+        util.exportExcel(response, list, "印花机1小时统计数据数据");
+    }
+
+    /**
+     * 获取印花机1小时统计数据详细信息
+     */
+    @ApiOperation("获取印花机1小时统计数据详细信息")
+    @PreAuthorize("@ss.hasPermi('calc:calcYhj:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(twinCalcHourYhjService.selectTwinCalcHourYhjById(id));
+    }
+
+    /**
+     * 新增印花机1小时统计数据
+     */
+    @ApiOperation("新增印花机1小时统计数据")
+    @PreAuthorize("@ss.hasPermi('calc:calcYhj:add')")
+    @Log(title = "印花机1小时统计数据", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TwinCalcHourYhj twinCalcHourYhj)
+    {
+        return toAjax(twinCalcHourYhjService.insertTwinCalcHourYhj(twinCalcHourYhj));
+    }
+
+    /**
+     * 修改印花机1小时统计数据
+     */
+    @ApiOperation("修改印花机1小时统计数据")
+    @PreAuthorize("@ss.hasPermi('calc:calcYhj:edit')")
+    @Log(title = "印花机1小时统计数据", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TwinCalcHourYhj twinCalcHourYhj)
+    {
+        return toAjax(twinCalcHourYhjService.updateTwinCalcHourYhj(twinCalcHourYhj));
+    }
+
+    /**
+     * 删除印花机1小时统计数据
+     */
+    @ApiOperation("删除印花机1小时统计数据")
+    @PreAuthorize("@ss.hasPermi('calc:calcYhj:remove')")
+    @Log(title = "印花机1小时统计数据", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(twinCalcHourYhjService.deleteTwinCalcHourYhjByIds(ids));
+    }
+}

+ 1 - 4
jjt-biz/src/main/java/com/jjt/calc/controller/TwinCalcStopController.java

@@ -51,10 +51,7 @@ public class TwinCalcStopController extends BaseController {
         return getDataTable(list);
     }
 
-    /**
-     * 查询停机数据统计列表
-     */
-    @ApiOperation("查询停机数据统计列表")
+    @ApiOperation("停机统计")
     @GetMapping("/calc")
     public R calc(TwinCalcStop twinCalcStop) {
 //        PageDomain pageDomain = TableSupport.buildPageRequest();

+ 82 - 0
jjt-biz/src/main/java/com/jjt/calc/domain/TwinCalcDayYhj.java

@@ -0,0 +1,82 @@
+package com.jjt.calc.domain;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.jjt.common.annotation.Excel;
+import com.jjt.common.core.domain.BaseEntity;
+
+/**
+ * 印花机日统计数据对象 TWIN_CALC_DAY_YHJ
+ *
+ * @author wukai
+ * @date 2025-03-07
+ */
+@ApiModel(value = "TwinCalcDayYhj", description = "印花机日统计数据")
+@Data
+public class TwinCalcDayYhj extends BaseEntity{
+    private static final long serialVersionUID = 1L;
+
+    /** ID */
+    @ApiModelProperty("ID")
+    @TableId
+    private Long id;
+
+    /** 时间 */
+    @ApiModelProperty("时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date time;
+
+    /** 设备ID */
+    @ApiModelProperty("设备ID")
+    @Excel(name = "设备ID")
+    private Long deviceId;
+
+    /** 自然天统计长度 */
+    @ApiModelProperty("自然天统计长度")
+    @Excel(name = "自然天统计长度")
+    private Integer dayLength;
+
+    /** 自然天统计重量 */
+    @ApiModelProperty("自然天统计重量")
+    @Excel(name = "自然天统计重量")
+    private BigDecimal dayWeight;
+
+    /** 总米长 */
+    @ApiModelProperty("总米长")
+    @Excel(name = "总米长")
+    private Integer length;
+
+    /** 总重量 */
+    @ApiModelProperty("总重量")
+    @Excel(name = "总重量")
+    private BigDecimal weight;
+
+    /** A班米长 */
+    @ApiModelProperty("A班米长")
+    @Excel(name = "A班米长")
+    private Integer lengthA;
+
+    /** A班重量 */
+    @ApiModelProperty("A班重量")
+    @Excel(name = "A班重量")
+    private BigDecimal weightA;
+
+    /** B班米长 */
+    @ApiModelProperty("B班米长")
+    @Excel(name = "B班米长")
+    private Integer lengthB;
+
+    /** B班重量 */
+    @ApiModelProperty("B班重量")
+    @Excel(name = "B班重量")
+    private BigDecimal weightB;
+
+}

+ 78 - 0
jjt-biz/src/main/java/com/jjt/calc/domain/TwinCalcHourYhj.java

@@ -0,0 +1,78 @@
+package com.jjt.calc.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jjt.common.annotation.Excel;
+import com.jjt.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 印花机1小时统计数据对象 TWIN_CALC_HOUR_YHJ
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+@ApiModel(value = "TwinCalcHourYhj", description = "印花机1小时统计数据")
+@Data
+public class TwinCalcHourYhj extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    @ApiModelProperty("ID")
+    @TableId
+    private Long id;
+
+    /**
+     * 日期
+     */
+    @ApiModelProperty("日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date dataDate;
+
+    /**
+     * 小时;0-23
+     */
+    @ApiModelProperty("小时;0-23")
+    @Excel(name = "小时;0-23")
+    private Integer hour;
+
+    /**
+     * 设备ID
+     */
+    @ApiModelProperty("设备ID")
+    @Excel(name = "设备ID")
+    private Long deviceId;
+
+    /**
+     * 织造米数
+     */
+    @ApiModelProperty("织造米数")
+    @Excel(name = "织造米数")
+    private Integer length;
+
+    /**
+     * 版距
+     */
+    @ApiModelProperty("版距")
+    @Excel(name = "版距")
+    private Integer distance;
+    @ApiModelProperty("班组")
+    private String team;
+
+    public void setTeam() {
+        if (this.hour >= 7 && this.hour < 19) {
+            //A班
+            this.team = "A";
+        } else {
+            //B班
+            this.team = "B";
+        }
+    }
+}

+ 64 - 0
jjt-biz/src/main/java/com/jjt/calc/mapper/TwinCalcDayYhjMapper.java

@@ -0,0 +1,64 @@
+package com.jjt.calc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jjt.calc.domain.TwinCalcDayYhj;
+
+import java.util.List;
+
+/**
+ * 印花机日统计数据Mapper接口
+ *
+ * @author wukai
+ * @date 2025-03-07
+ */
+public interface TwinCalcDayYhjMapper extends BaseMapper<TwinCalcDayYhj> {
+    /**
+     * 查询印花机日统计数据
+     *
+     * @param id 印花机日统计数据主键
+     * @return 印花机日统计数据
+     */
+    public TwinCalcDayYhj selectTwinCalcDayYhjById(Long id);
+
+    /**
+     * 查询印花机日统计数据列表
+     *
+     * @param twinCalcDayYhj 印花机日统计数据
+     * @return 印花机日统计数据集合
+     */
+    public List<TwinCalcDayYhj> selectTwinCalcDayYhjList(TwinCalcDayYhj twinCalcDayYhj);
+
+    /**
+     * 新增印花机日统计数据
+     *
+     * @param twinCalcDayYhj 印花机日统计数据
+     * @return 结果
+     */
+    public int insertTwinCalcDayYhj(TwinCalcDayYhj twinCalcDayYhj);
+
+    /**
+     * 修改印花机日统计数据
+     *
+     * @param twinCalcDayYhj 印花机日统计数据
+     * @return 结果
+     */
+    public int updateTwinCalcDayYhj(TwinCalcDayYhj twinCalcDayYhj);
+
+    /**
+     * 删除印花机日统计数据
+     *
+     * @param id 印花机日统计数据主键
+     * @return 结果
+     */
+    public int deleteTwinCalcDayYhjById(Long id);
+
+    /**
+     * 批量删除印花机日统计数据
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTwinCalcDayYhjByIds(Long[] ids);
+
+    void delete4date(String date);
+}

+ 72 - 0
jjt-biz/src/main/java/com/jjt/calc/mapper/TwinCalcHourYhjMapper.java

@@ -0,0 +1,72 @@
+package com.jjt.calc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jjt.calc.domain.TwinCalcHourYhj;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 印花机1小时统计数据Mapper接口
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+public interface TwinCalcHourYhjMapper extends BaseMapper<TwinCalcHourYhj> {
+    /**
+     * 查询印花机1小时统计数据
+     *
+     * @param id 印花机1小时统计数据主键
+     * @return 印花机1小时统计数据
+     */
+    public TwinCalcHourYhj selectTwinCalcHourYhjById(Long id);
+
+    /**
+     * 查询印花机1小时统计数据列表
+     *
+     * @param twinCalcHourYhj 印花机1小时统计数据
+     * @return 印花机1小时统计数据集合
+     */
+    public List<TwinCalcHourYhj> selectTwinCalcHourYhjList(TwinCalcHourYhj twinCalcHourYhj);
+
+    /**
+     * 新增印花机1小时统计数据
+     *
+     * @param twinCalcHourYhj 印花机1小时统计数据
+     * @return 结果
+     */
+    public int insertTwinCalcHourYhj(TwinCalcHourYhj twinCalcHourYhj);
+
+    /**
+     * 修改印花机1小时统计数据
+     *
+     * @param twinCalcHourYhj 印花机1小时统计数据
+     * @return 结果
+     */
+    public int updateTwinCalcHourYhj(TwinCalcHourYhj twinCalcHourYhj);
+
+    /**
+     * 删除印花机1小时统计数据
+     *
+     * @param id 印花机1小时统计数据主键
+     * @return 结果
+     */
+    public int deleteTwinCalcHourYhjById(Long id);
+
+    /**
+     * 批量删除印花机1小时统计数据
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTwinCalcHourYhjByIds(Long[] ids);
+
+    /**
+     * 按时间和小时删除数据
+     *
+     * @param date 时间
+     * @param hour 小时
+     */
+    void deleteTwinCalcHourYhj(@Param("date") Date date, @Param("hour") int hour);
+}

+ 67 - 0
jjt-biz/src/main/java/com/jjt/calc/service/ITwinCalcDayYhjService.java

@@ -0,0 +1,67 @@
+package com.jjt.calc.service;
+
+import java.time.LocalDate;
+import java.util.List;
+import com.jjt.calc.domain.TwinCalcDayYhj;
+
+/**
+ * 印花机日统计数据Service接口
+ *
+ * @author wukai
+ * @date 2025-03-07
+ */
+public interface ITwinCalcDayYhjService {
+    /**
+     * 查询印花机日统计数据
+     *
+     * @param id 印花机日统计数据主键
+     * @return 印花机日统计数据
+     */
+    public TwinCalcDayYhj selectTwinCalcDayYhjById(Long id);
+
+    /**
+     * 查询印花机日统计数据列表
+     *
+     * @param twinCalcDayYhj 印花机日统计数据
+     * @return 印花机日统计数据集合
+     */
+    public List<TwinCalcDayYhj> selectTwinCalcDayYhjList(TwinCalcDayYhj twinCalcDayYhj);
+
+    /**
+     * 新增印花机日统计数据
+     *
+     * @param twinCalcDayYhj 印花机日统计数据
+     * @return 结果
+     */
+    public int insertTwinCalcDayYhj(TwinCalcDayYhj twinCalcDayYhj);
+
+    /**
+     * 修改印花机日统计数据
+     *
+     * @param twinCalcDayYhj 印花机日统计数据
+     * @return 结果
+     */
+    public int updateTwinCalcDayYhj(TwinCalcDayYhj twinCalcDayYhj);
+
+    /**
+     * 批量删除印花机日统计数据
+     *
+     * @param ids 需要删除的印花机日统计数据主键集合
+     * @return 结果
+     */
+    public int deleteTwinCalcDayYhjByIds(Long[] ids);
+
+    /**
+     * 删除印花机日统计数据信息
+     *
+     * @param id 印花机日统计数据主键
+     * @return 结果
+     */
+    public int deleteTwinCalcDayYhjById(Long id);
+    /**
+     * 统计指定日期的数据
+     *
+     * @param localDate 日期
+     */
+    void day(LocalDate localDate);
+}

+ 75 - 0
jjt-biz/src/main/java/com/jjt/calc/service/ITwinCalcHourYhjService.java

@@ -0,0 +1,75 @@
+package com.jjt.calc.service;
+
+import com.jjt.calc.domain.TwinCalcHourYhj;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 印花机1小时统计数据Service接口
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+public interface ITwinCalcHourYhjService {
+    /**
+     * 查询印花机1小时统计数据
+     *
+     * @param id 印花机1小时统计数据主键
+     * @return 印花机1小时统计数据
+     */
+    public TwinCalcHourYhj selectTwinCalcHourYhjById(Long id);
+
+    /**
+     * 查询印花机1小时统计数据列表
+     *
+     * @param twinCalcHourYhj 印花机1小时统计数据
+     * @return 印花机1小时统计数据集合
+     */
+    public List<TwinCalcHourYhj> selectTwinCalcHourYhjList(TwinCalcHourYhj twinCalcHourYhj);
+
+    /**
+     * 新增印花机1小时统计数据
+     *
+     * @param twinCalcHourYhj 印花机1小时统计数据
+     * @return 结果
+     */
+    public int insertTwinCalcHourYhj(TwinCalcHourYhj twinCalcHourYhj);
+
+    /**
+     * 修改印花机1小时统计数据
+     *
+     * @param twinCalcHourYhj 印花机1小时统计数据
+     * @return 结果
+     */
+    public int updateTwinCalcHourYhj(TwinCalcHourYhj twinCalcHourYhj);
+
+    /**
+     * 批量删除印花机1小时统计数据
+     *
+     * @param ids 需要删除的印花机1小时统计数据主键集合
+     * @return 结果
+     */
+    public int deleteTwinCalcHourYhjByIds(Long[] ids);
+
+    /**
+     * 删除印花机1小时统计数据信息
+     *
+     * @param id 印花机1小时统计数据主键
+     * @return 结果
+     */
+    public int deleteTwinCalcHourYhjById(Long id);
+
+    /**
+     * 统计上一时段数据
+     */
+    void last();
+
+    /**
+     * 按指定时间统计
+     *
+     * @param start 开始时间
+     * @param end   结束时间
+     */
+    void calc(LocalDateTime start, LocalDateTime end);
+}

+ 163 - 0
jjt-biz/src/main/java/com/jjt/calc/service/impl/TwinCalcDayYhjServiceImpl.java

@@ -0,0 +1,163 @@
+package com.jjt.calc.service.impl;
+
+import com.jjt.calc.domain.TwinCalcDayYhj;
+import com.jjt.calc.domain.TwinCalcHourYhj;
+import com.jjt.calc.mapper.TwinCalcDayYhjMapper;
+import com.jjt.calc.mapper.TwinCalcHourYhjMapper;
+import com.jjt.calc.service.ITwinCalcDayYhjService;
+import com.jjt.common.utils.DateUtils;
+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.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 印花机日统计数据Service业务层处理
+ *
+ * @author wukai
+ * @date 2025-03-07
+ */
+@Service
+public class TwinCalcDayYhjServiceImpl implements ITwinCalcDayYhjService {
+    @Resource
+    private TwinCalcDayYhjMapper twinCalcDayYhjMapper;
+    @Resource
+    private TwinCalcHourYhjMapper hourYhjMapper;
+    @Resource
+    private SqlSessionFactory factory;
+
+    /**
+     * 查询印花机日统计数据
+     *
+     * @param id 印花机日统计数据主键
+     * @return 印花机日统计数据
+     */
+    @Override
+    public TwinCalcDayYhj selectTwinCalcDayYhjById(Long id) {
+        return twinCalcDayYhjMapper.selectTwinCalcDayYhjById(id);
+    }
+
+    /**
+     * 查询印花机日统计数据列表
+     *
+     * @param twinCalcDayYhj 印花机日统计数据
+     * @return 印花机日统计数据
+     */
+    @Override
+    public List<TwinCalcDayYhj> selectTwinCalcDayYhjList(TwinCalcDayYhj twinCalcDayYhj) {
+        return twinCalcDayYhjMapper.selectTwinCalcDayYhjList(twinCalcDayYhj);
+    }
+
+    /**
+     * 新增印花机日统计数据
+     *
+     * @param twinCalcDayYhj 印花机日统计数据
+     * @return 结果
+     */
+    @Override
+    public int insertTwinCalcDayYhj(TwinCalcDayYhj twinCalcDayYhj) {
+        return twinCalcDayYhjMapper.insertTwinCalcDayYhj(twinCalcDayYhj);
+    }
+
+    /**
+     * 修改印花机日统计数据
+     *
+     * @param twinCalcDayYhj 印花机日统计数据
+     * @return 结果
+     */
+    @Override
+    public int updateTwinCalcDayYhj(TwinCalcDayYhj twinCalcDayYhj) {
+        return twinCalcDayYhjMapper.updateTwinCalcDayYhj(twinCalcDayYhj);
+    }
+
+    /**
+     * 批量删除印花机日统计数据
+     *
+     * @param ids 需要删除的印花机日统计数据主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinCalcDayYhjByIds(Long[] ids) {
+        return twinCalcDayYhjMapper.deleteTwinCalcDayYhjByIds(ids);
+    }
+
+    /**
+     * 删除印花机日统计数据信息
+     *
+     * @param id 印花机日统计数据主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinCalcDayYhjById(Long id) {
+        return twinCalcDayYhjMapper.deleteTwinCalcDayYhjById(id);
+    }
+
+    /**
+     * 统计指定日期的数据
+     * 需要统计2种类型,1.按班组统计 2.按自然日统计
+     *
+     * @param localDate 日期
+     */
+    @Override
+    public void day(LocalDate localDate) {
+        //先删除当前日期数据
+        twinCalcDayYhjMapper.delete4date(localDate.toString());
+        //1.先按班组统计
+        TwinCalcHourYhj search = new TwinCalcHourYhj();
+        Map<String, Object> params = new HashMap<>(16);
+        LocalDateTime st = LocalDateTime.of(localDate, LocalTime.MIN).plusHours(7);
+        LocalDateTime ed = st.plusHours(23);
+        params.put("sTime", DateUtils.toDate(st));
+        params.put("eTime", DateUtils.toDate(ed));
+        search.setParams(params);
+        List<TwinCalcHourYhj> list = hourYhjMapper.selectTwinCalcHourYhjList(search);
+        //设置班组
+        list.forEach(TwinCalcHourYhj::setTeam);
+        //先按ID分组
+        Map<Long, List<TwinCalcHourYhj>> calcMap = list.stream().collect(Collectors.groupingBy(TwinCalcHourYhj::getDeviceId, LinkedHashMap::new, Collectors.toList()));
+        Map<Long, TwinCalcDayYhj> resultMap = new HashMap<>(16);
+        for (Long deviceId : calcMap.keySet()) {
+            //按班组统计
+            Map<String, Integer> calcTeam = calcMap.get(deviceId).stream().collect(Collectors.groupingBy(TwinCalcHourYhj::getTeam, Collectors.reducing(0, TwinCalcHourYhj::getLength, Integer::sum)));
+            TwinCalcDayYhj calc = new TwinCalcDayYhj();
+            calc.setDeviceId(deviceId);
+            calc.setTime(DateUtils.toDate(localDate));
+            calc.setLengthA(calcTeam.get("A"));
+            calc.setLengthB(calcTeam.get("B"));
+            calc.setLength(calcTeam.get("A") + calcTeam.get("B"));
+            resultMap.put(deviceId, calc);
+        }
+
+        //按自然日统计
+        search = new TwinCalcHourYhj();
+        params = new HashMap<>(16);
+        params.put("beginDataDate", localDate.toString());
+        params.put("endDataDate", localDate.toString());
+        search.setParams(params);
+        list = hourYhjMapper.selectTwinCalcHourYhjList(search);
+        List<TwinCalcDayYhj> yhjList = new ArrayList<>();
+        //按ID分组统计
+        Map<Long, Integer> calcDay = list.stream().collect(Collectors.groupingBy(TwinCalcHourYhj::getDeviceId, Collectors.reducing(0, TwinCalcHourYhj::getLength, Integer::sum)));
+        for (Long deviceId : calcMap.keySet()) {
+            TwinCalcDayYhj calc = resultMap.get(deviceId);
+            calc.setDayLength(calcDay.get(deviceId));
+            yhjList.add(calc);
+        }
+
+        try (SqlSession sqlSession = factory.openSession(ExecutorType.BATCH, false)) {
+            if (yhjList.size() > 0) {
+                TwinCalcDayYhjMapper mapper = sqlSession.getMapper(TwinCalcDayYhjMapper.class);
+                yhjList.forEach(mapper::insertTwinCalcDayYhj);
+                sqlSession.commit();
+            }
+        }
+
+    }
+}

+ 273 - 0
jjt-biz/src/main/java/com/jjt/calc/service/impl/TwinCalcHourYhjServiceImpl.java

@@ -0,0 +1,273 @@
+package com.jjt.calc.service.impl;
+
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import com.jjt.biz.domain.TwinDeviceYhj;
+import com.jjt.biz.service.ITwinDeviceYhjService;
+import com.jjt.calc.domain.TwinCalcHourYhj;
+import com.jjt.calc.mapper.TwinCalcHourYhjMapper;
+import com.jjt.calc.service.ITwinCalcHourYhjService;
+import com.jjt.common.utils.DateUtils;
+import com.jjt.utils.IotService;
+import com.jjt.utils.Tools;
+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.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.*;
+
+/**
+ * 印花机1小时统计数据Service业务层处理
+ *
+ * @author wukai
+ * @date 2025-03-06
+ */
+@Service
+public class TwinCalcHourYhjServiceImpl implements ITwinCalcHourYhjService {
+    @Resource
+    private TwinCalcHourYhjMapper twinCalcHourYhjMapper;
+    @Resource
+    private IotService iotService;
+    @Resource
+    private SqlSessionFactory factory;
+    @Resource
+    private ITwinDeviceYhjService yhjService;
+
+    /**
+     * 查询印花机1小时统计数据
+     *
+     * @param id 印花机1小时统计数据主键
+     * @return 印花机1小时统计数据
+     */
+    @Override
+    public TwinCalcHourYhj selectTwinCalcHourYhjById(Long id) {
+        return twinCalcHourYhjMapper.selectTwinCalcHourYhjById(id);
+    }
+
+    /**
+     * 查询印花机1小时统计数据列表
+     *
+     * @param twinCalcHourYhj 印花机1小时统计数据
+     * @return 印花机1小时统计数据
+     */
+    @Override
+    public List<TwinCalcHourYhj> selectTwinCalcHourYhjList(TwinCalcHourYhj twinCalcHourYhj) {
+        return twinCalcHourYhjMapper.selectTwinCalcHourYhjList(twinCalcHourYhj);
+    }
+
+    /**
+     * 新增印花机1小时统计数据
+     *
+     * @param twinCalcHourYhj 印花机1小时统计数据
+     * @return 结果
+     */
+    @Override
+    public int insertTwinCalcHourYhj(TwinCalcHourYhj twinCalcHourYhj) {
+        return twinCalcHourYhjMapper.insertTwinCalcHourYhj(twinCalcHourYhj);
+    }
+
+    /**
+     * 修改印花机1小时统计数据
+     *
+     * @param twinCalcHourYhj 印花机1小时统计数据
+     * @return 结果
+     */
+    @Override
+    public int updateTwinCalcHourYhj(TwinCalcHourYhj twinCalcHourYhj) {
+        return twinCalcHourYhjMapper.updateTwinCalcHourYhj(twinCalcHourYhj);
+    }
+
+    /**
+     * 批量删除印花机1小时统计数据
+     *
+     * @param ids 需要删除的印花机1小时统计数据主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinCalcHourYhjByIds(Long[] ids) {
+        return twinCalcHourYhjMapper.deleteTwinCalcHourYhjByIds(ids);
+    }
+
+    /**
+     * 删除印花机1小时统计数据信息
+     *
+     * @param id 印花机1小时统计数据主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTwinCalcHourYhjById(Long id) {
+        return twinCalcHourYhjMapper.deleteTwinCalcHourYhjById(id);
+    }
+
+    /**
+     * 统计上一时段数据
+     */
+    @Override
+    public void last() {
+        LocalDateTime ldt = Tools.currWholeTime();
+        //上一个小时
+        ldt = ldt.minusHours(1);
+        //开始时间需要向前取一秒
+        LocalDateTime start = ldt;
+        LocalDateTime end = ldt.plusHours(1);
+        calc(start, end);
+    }
+
+    /**
+     * 按指定时间统计
+     *
+     * @param start 开始时间
+     * @param end   结束时间
+     */
+    @Override
+    public void calc(LocalDateTime start, LocalDateTime end) {
+        Long startTime = start.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+        Long endTime = end.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+        deleteTwinCalcHourYhj(DateUtils.toDate(start.toLocalDate()), start.getHour());
+        List<TwinDeviceYhj> list = yhjService.selectTwinDeviceYhjList(new TwinDeviceYhj());
+        List<TwinCalcHourYhj> calcList = new ArrayList<>();
+        //  使用设备编码作为Map的key, 使用设备对象本身作为Map的value, 如果有重复的key,保留现有的value
+        Map<String, TwinDeviceYhj> yhjMap = new HashMap<>(16);
+        List<String> fieldList = new ArrayList<>();
+        String prefix = "root.tl.suxi";
+        String[] fields = {"Formula_data_set_1", "Formula_data_act_5"};
+        for (TwinDeviceYhj yhj : list) {
+            for (String field : fields) {
+                String tmp = yhj.getDeviceCode() + "." + field;
+                fieldList.add(tmp);
+                yhjMap.put(prefix + "." + tmp, yhj);
+            }
+        }
+        String sql = "select %s from " + prefix + " where time>%s and time <=%s";
+
+        sql = String.format(sql, String.join(",", fieldList), startTime, endTime);
+        JSONObject jsonObject = iotService.query(sql);
+        JSONObject data = jsonObject.getJSONObject("data");
+        JSONArray columnNames = data.getJSONArray("columnNames");
+        JSONArray values = data.getJSONArray("values");
+        JSONArray timestamps = data.getJSONArray("timestamps");
+        //记录上一次记录的值
+        Integer[] last = new Integer[columnNames.size()];
+        //记录最后一次的值,防中间有数,后面没数
+        Integer[] over = new Integer[columnNames.size()];
+        //当前记录值
+        Integer[] total = new Integer[columnNames.size()];
+        //记录第一次记录的值,如果清0,则记录清零时刻的值
+        Integer[] first = new Integer[columnNames.size()];
+        //记录统计值
+        Integer[] curr = new Integer[columnNames.size()];
+        for (int i = 0; i < values.size(); i++) {
+            JSONArray da = values.getJSONArray(i);
+            da.toList(Integer.class).toArray(curr);
+            if (i == 0) {
+                cloneArray(curr, last);
+                cloneArray(curr, first);
+                cloneArray(curr, over);
+                continue;
+            }
+            for (int j = 0; j < columnNames.size(); j++) {
+                String name = columnNames.getStr(j);
+                if (name.contains("Formula_data_set_1")) {
+                    //如果是版距,则需要记录变化
+                    if (curr[j] != null && last[j] != null && curr[j].intValue() != last[j].intValue()) {
+                        //这里要用j+1才行
+                        calcLength(j + 1, last, first, total);
+                        combo(calcList, start, yhjMap.get(name), last[j], total[j + 1]);
+                        total[j + 1] = 0;
+                    }
+                }
+                if (name.contains("Formula_data_act_5")) {
+                    //如果是米长,则需要记录是否清0
+                    //如果当前值为小于上一个,且上一个值不为0,则计算
+                    //因为会出现数据波动,停机再启动之后的第一个点不为0,为0.00几几几的
+                    if (curr[j] != null && last[j] != null && curr[j] < last[j] && last[j] != 0) {
+                        calcLength(j, last, first, total);
+                        cloneArray(curr, first);
+                    }
+                }
+            }
+            //将本次的值,设为上一条记录了
+            cloneArray(curr, last);
+            cloneArray(curr, over);
+            cloneArrayFirst(curr, first);
+        }
+        for (int j = 0; j < columnNames.size(); j++) {
+            String name = columnNames.getStr(j);
+            if (name.contains("Formula_data_set_1")) {
+                calcLength(j + 1, over, first, total);
+                combo(calcList, start, yhjMap.get(name), over[j], total[j + 1]);
+            }
+        }
+
+        try (SqlSession sqlSession = factory.openSession(ExecutorType.BATCH, false)) {
+            if (calcList.size() > 0) {
+                TwinCalcHourYhjMapper mapper = sqlSession.getMapper(TwinCalcHourYhjMapper.class);
+                calcList.forEach(mapper::insertTwinCalcHourYhj);
+                sqlSession.commit();
+            }
+        }
+    }
+
+    /**
+     * 按时间和小时删除数据
+     *
+     * @param date 时间
+     * @param hour 小时
+     */
+    public void deleteTwinCalcHourYhj(Date date, int hour) {
+        twinCalcHourYhjMapper.deleteTwinCalcHourYhj(date, hour);
+    }
+
+    /**
+     * 初始值,如果当前值不为空,并且原来值为空
+     */
+    void cloneArrayFirst(Integer[] arr, Integer[] target) {
+        for (int i = 0; i < arr.length; i++) {
+            if (arr[i] != null && target[i] == null) {
+                target[i] = arr[i];
+            }
+        }
+    }
+
+    /**
+     * 复制数组,如果当前值不为空
+     */
+    void cloneArray(Integer[] arr, Integer[] target) {
+        for (int i = 0; i < arr.length; i++) {
+            if (arr[i] != null) {
+                target[i] = arr[i];
+            }
+        }
+    }
+
+    /**
+     * 组合入库数据
+     */
+    void combo(List<TwinCalcHourYhj> calcList, LocalDateTime start, TwinDeviceYhj yhj, Integer distance, Integer length) {
+        if (distance != null && length != null) {
+            TwinCalcHourYhj calc = new TwinCalcHourYhj();
+            calc.setDeviceId(yhj.getDeviceId());
+            calc.setDataDate(DateUtils.toDate(start.toLocalDate()));
+            calc.setHour(start.getHour());
+            calc.setDistance(distance);
+            calc.setLength(length);
+            calcList.add(calc);
+        }
+    }
+
+    /**
+     * 计算米长
+     */
+    void calcLength(int j, Integer[] last, Integer[] first, Integer[] total) {
+        if (last[j] != null && first[j] != null) {
+            if (total[j] == null) {
+                total[j] = 0;
+            }
+            total[j] += (last[j] - first[j]);
+        }
+    }
+}

+ 43 - 0
jjt-biz/src/main/java/com/jjt/task/YhjTask.java

@@ -0,0 +1,43 @@
+package com.jjt.task;
+
+import com.jjt.calc.service.ITwinCalcDayService;
+import com.jjt.calc.service.ITwinCalcDayYhjService;
+import com.jjt.calc.service.ITwinCalcHourService;
+import com.jjt.calc.service.ITwinCalcHourYhjService;
+import com.jjt.common.utils.DateUtils;
+import com.jjt.emp.service.ITwinEmpCalcService;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.time.LocalDate;
+
+/**
+ * 统计定时任务
+ *
+ * @author wukai
+ * @date 2025-1-17 23:27:26
+ */
+@Component("yhj")
+public class YhjTask {
+    @Resource
+    private ITwinCalcHourYhjService yhjService;
+    @Resource
+    private ITwinCalcDayYhjService dayService;
+
+    /**
+     * 统计上一时段数据
+     */
+    public void last() {
+        yhjService.last();
+    }
+
+    /**
+     * 统计昨日数据
+     */
+
+    public void day() {
+        LocalDate localDate = LocalDate.now().minusDays(1);
+        dayService.day(localDate);
+    }
+
+}

+ 101 - 0
jjt-biz/src/main/resources/mapper/biz/TwinDeviceAllMapper.xml

@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jjt.biz.mapper.TwinDeviceAllMapper">
+    
+    <resultMap type="TwinDeviceAll" id="TwinDeviceAllResult">
+        <result property="deviceId"    column="DEVICE_ID"    />
+        <result property="parentId"    column="PARENT_ID"    />
+        <result property="sortNum"    column="SORT_NUM"    />
+        <result property="deviceName"    column="DEVICE_NAME"    />
+        <result property="deviceCode"    column="DEVICE_CODE"    />
+        <result property="devicePath"    column="DEVICE_PATH"    />
+        <result property="createdBy"    column="CREATED_BY"    />
+        <result property="createdTime"    column="CREATED_TIME"    />
+        <result property="updatedBy"    column="UPDATED_BY"    />
+        <result property="updatedTime"    column="UPDATED_TIME"    />
+        <result property="remark"    column="REMARK"    />
+    </resultMap>
+
+    <sql id="selectTwinDeviceAllVo">
+        select DEVICE_ID, PARENT_ID, SORT_NUM, DEVICE_NAME, DEVICE_CODE, DEVICE_PATH, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, REMARK from TWIN_DEVICE_ALL
+    </sql>
+
+    <select id="selectTwinDeviceAllList" parameterType="TwinDeviceAll" resultMap="TwinDeviceAllResult">
+        <include refid="selectTwinDeviceAllVo"/>
+        <where>  
+            <if test="parentId != null "> and PARENT_ID = #{parentId}</if>
+            <if test="sortNum != null  and sortNum != ''"> and SORT_NUM = #{sortNum}</if>
+            <if test="deviceName != null  and deviceName != ''"> and DEVICE_NAME like concat('%', #{deviceName}, '%')</if>
+            <if test="deviceCode != null  and deviceCode != ''"> and DEVICE_CODE like concat('%', #{deviceCode}, '%')</if>
+            <if test="devicePath != null  and devicePath != ''"> and DEVICE_PATH = #{devicePath}</if>
+            <if test="createdBy != null  and createdBy != ''"> and CREATED_BY = #{createdBy}</if>
+            <if test="createdTime != null "> and CREATED_TIME = #{createdTime}</if>
+            <if test="updatedBy != null  and updatedBy != ''"> and UPDATED_BY = #{updatedBy}</if>
+            <if test="updatedTime != null "> and UPDATED_TIME = #{updatedTime}</if>
+            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
+        </where>
+    </select>
+    
+    <select id="selectTwinDeviceAllByDeviceId" parameterType="Long" resultMap="TwinDeviceAllResult">
+        <include refid="selectTwinDeviceAllVo"/>
+        where DEVICE_ID = #{deviceId}
+    </select>
+
+    <insert id="insertTwinDeviceAll" parameterType="TwinDeviceAll" useGeneratedKeys="true" keyProperty="deviceId">
+        insert into TWIN_DEVICE_ALL
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="parentId != null">PARENT_ID,</if>
+            <if test="sortNum != null">SORT_NUM,</if>
+            <if test="deviceName != null">DEVICE_NAME,</if>
+            <if test="deviceCode != null">DEVICE_CODE,</if>
+            <if test="devicePath != null">DEVICE_PATH,</if>
+            <if test="createdBy != null">CREATED_BY,</if>
+            <if test="createdTime != null">CREATED_TIME,</if>
+            <if test="updatedBy != null">UPDATED_BY,</if>
+            <if test="updatedTime != null">UPDATED_TIME,</if>
+            <if test="remark != null">REMARK,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="parentId != null">#{parentId},</if>
+            <if test="sortNum != null">#{sortNum},</if>
+            <if test="deviceName != null">#{deviceName},</if>
+            <if test="deviceCode != null">#{deviceCode},</if>
+            <if test="devicePath != null">#{devicePath},</if>
+            <if test="createdBy != null">#{createdBy},</if>
+            <if test="createdTime != null">#{createdTime},</if>
+            <if test="updatedBy != null">#{updatedBy},</if>
+            <if test="updatedTime != null">#{updatedTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateTwinDeviceAll" parameterType="TwinDeviceAll">
+        update TWIN_DEVICE_ALL
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="parentId != null">PARENT_ID = #{parentId},</if>
+            <if test="sortNum != null">SORT_NUM = #{sortNum},</if>
+            <if test="deviceName != null">DEVICE_NAME = #{deviceName},</if>
+            <if test="deviceCode != null">DEVICE_CODE = #{deviceCode},</if>
+            <if test="devicePath != null">DEVICE_PATH = #{devicePath},</if>
+            <if test="createdBy != null">CREATED_BY = #{createdBy},</if>
+            <if test="createdTime != null">CREATED_TIME = #{createdTime},</if>
+            <if test="updatedBy != null">UPDATED_BY = #{updatedBy},</if>
+            <if test="updatedTime != null">UPDATED_TIME = #{updatedTime},</if>
+            <if test="remark != null">REMARK = #{remark},</if>
+        </trim>
+        where DEVICE_ID = #{deviceId}
+    </update>
+
+    <delete id="deleteTwinDeviceAllByDeviceId" parameterType="Long">
+        delete from TWIN_DEVICE_ALL where DEVICE_ID = #{deviceId}
+    </delete>
+
+    <delete id="deleteTwinDeviceAllByDeviceIds" parameterType="String">
+        delete from TWIN_DEVICE_ALL where DEVICE_ID in 
+        <foreach item="deviceId" collection="array" open="(" separator="," close=")">
+            #{deviceId}
+        </foreach>
+    </delete>
+</mapper>

+ 70 - 0
jjt-biz/src/main/resources/mapper/biz/TwinDeviceYhjMapper.xml

@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jjt.biz.mapper.TwinDeviceYhjMapper">
+    
+    <resultMap type="TwinDeviceYhj" id="TwinDeviceYhjResult">
+        <result property="deviceId"    column="DEVICE_ID"    />
+        <result property="deviceName"    column="DEVICE_NAME"    />
+        <result property="deviceCode"    column="DEVICE_CODE"    />
+        <result property="devicePath"    column="DEVICE_PATH"    />
+        <result property="remark"    column="REMARK"    />
+    </resultMap>
+
+    <sql id="selectTwinDeviceYhjVo">
+        select DEVICE_ID, DEVICE_NAME, DEVICE_CODE, DEVICE_PATH, REMARK from TWIN_DEVICE_YHJ
+    </sql>
+
+    <select id="selectTwinDeviceYhjList" parameterType="TwinDeviceYhj" resultMap="TwinDeviceYhjResult">
+        <include refid="selectTwinDeviceYhjVo"/>
+        <where>  
+            <if test="deviceName != null  and deviceName != ''"> and DEVICE_NAME like concat('%', #{deviceName}, '%')</if>
+            <if test="deviceCode != null  and deviceCode != ''"> and DEVICE_CODE like concat('%', #{deviceCode}, '%')</if>
+            <if test="devicePath != null  and devicePath != ''"> and DEVICE_PATH like concat('%', #{devicePath}, '%')</if>
+        </where>
+    </select>
+    
+    <select id="selectTwinDeviceYhjByDeviceId" parameterType="Long" resultMap="TwinDeviceYhjResult">
+        <include refid="selectTwinDeviceYhjVo"/>
+        where DEVICE_ID = #{deviceId}
+    </select>
+
+    <insert id="insertTwinDeviceYhj" parameterType="TwinDeviceYhj" useGeneratedKeys="true" keyProperty="deviceId">
+        insert into TWIN_DEVICE_YHJ
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="deviceName != null">DEVICE_NAME,</if>
+            <if test="deviceCode != null">DEVICE_CODE,</if>
+            <if test="devicePath != null">DEVICE_PATH,</if>
+            <if test="remark != null">REMARK,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="deviceName != null">#{deviceName},</if>
+            <if test="deviceCode != null">#{deviceCode},</if>
+            <if test="devicePath != null">#{devicePath},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateTwinDeviceYhj" parameterType="TwinDeviceYhj">
+        update TWIN_DEVICE_YHJ
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="deviceName != null">DEVICE_NAME = #{deviceName},</if>
+            <if test="deviceCode != null">DEVICE_CODE = #{deviceCode},</if>
+            <if test="devicePath != null">DEVICE_PATH = #{devicePath},</if>
+            <if test="remark != null">REMARK = #{remark},</if>
+        </trim>
+        where DEVICE_ID = #{deviceId}
+    </update>
+
+    <delete id="deleteTwinDeviceYhjByDeviceId" parameterType="Long">
+        delete from TWIN_DEVICE_YHJ where DEVICE_ID = #{deviceId}
+    </delete>
+
+    <delete id="deleteTwinDeviceYhjByDeviceIds" parameterType="String">
+        delete from TWIN_DEVICE_YHJ where DEVICE_ID in 
+        <foreach item="deviceId" collection="array" open="(" separator="," close=")">
+            #{deviceId}
+        </foreach>
+    </delete>
+</mapper>

+ 120 - 0
jjt-biz/src/main/resources/mapper/calc/TwinCalcDayYhjMapper.xml

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jjt.calc.mapper.TwinCalcDayYhjMapper">
+
+    <resultMap type="TwinCalcDayYhj" id="TwinCalcDayYhjResult">
+        <result property="id" column="ID"/>
+        <result property="time" column="TIME"/>
+        <result property="deviceId" column="DEVICE_ID"/>
+        <result property="dayLength" column="DAY_LENGTH"/>
+        <result property="dayWeight" column="DAY_WEIGHT"/>
+        <result property="length" column="LENGTH"/>
+        <result property="weight" column="WEIGHT"/>
+        <result property="lengthA" column="LENGTH_A"/>
+        <result property="weightA" column="WEIGHT_A"/>
+        <result property="lengthB" column="LENGTH_B"/>
+        <result property="weightB" column="WEIGHT_B"/>
+        <result property="remark" column="REMARK"/>
+    </resultMap>
+
+    <sql id="selectTwinCalcDayYhjVo">
+        select ID,
+               TIME,
+               DEVICE_ID,
+               DAY_LENGTH,
+               DAY_WEIGHT,
+               LENGTH,
+               WEIGHT,
+               LENGTH_A,
+               WEIGHT_A,
+               LENGTH_B,
+               WEIGHT_B,
+               REMARK
+        from TWIN_CALC_DAY_YHJ
+    </sql>
+
+    <select id="selectTwinCalcDayYhjList" parameterType="TwinCalcDayYhj" resultMap="TwinCalcDayYhjResult">
+        <include refid="selectTwinCalcDayYhjVo"/>
+        <where>
+            <if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
+                and TIME between #{params.beginTime} and #{params.endTime}
+            </if>
+            <if test="deviceId != null ">and DEVICE_ID = #{deviceId}</if>
+            <if test="dayLength != null ">and DAY_LENGTH = #{dayLength}</if>
+            <if test="dayWeight != null ">and DAY_WEIGHT = #{dayWeight}</if>
+        </where>
+    </select>
+
+    <select id="selectTwinCalcDayYhjById" parameterType="Long" resultMap="TwinCalcDayYhjResult">
+        <include refid="selectTwinCalcDayYhjVo"/>
+        where ID = #{id}
+    </select>
+
+    <insert id="insertTwinCalcDayYhj" parameterType="TwinCalcDayYhj">
+        insert into TWIN_CALC_DAY_YHJ
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="time != null">TIME,</if>
+            <if test="deviceId != null">DEVICE_ID,</if>
+            <if test="dayLength != null">DAY_LENGTH,</if>
+            <if test="dayWeight != null">DAY_WEIGHT,</if>
+            <if test="length != null">LENGTH,</if>
+            <if test="weight != null">WEIGHT,</if>
+            <if test="lengthA != null">LENGTH_A,</if>
+            <if test="weightA != null">WEIGHT_A,</if>
+            <if test="lengthB != null">LENGTH_B,</if>
+            <if test="weightB != null">WEIGHT_B,</if>
+            <if test="remark != null">REMARK,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="time != null">#{time},</if>
+            <if test="deviceId != null">#{deviceId},</if>
+            <if test="dayLength != null">#{dayLength},</if>
+            <if test="dayWeight != null">#{dayWeight},</if>
+            <if test="length != null">#{length},</if>
+            <if test="weight != null">#{weight},</if>
+            <if test="lengthA != null">#{lengthA},</if>
+            <if test="weightA != null">#{weightA},</if>
+            <if test="lengthB != null">#{lengthB},</if>
+            <if test="weightB != null">#{weightB},</if>
+            <if test="remark != null">#{remark},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTwinCalcDayYhj" parameterType="TwinCalcDayYhj">
+        update TWIN_CALC_DAY_YHJ
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="time != null">TIME = #{time},</if>
+            <if test="deviceId != null">DEVICE_ID = #{deviceId},</if>
+            <if test="dayLength != null">DAY_LENGTH = #{dayLength},</if>
+            <if test="dayWeight != null">DAY_WEIGHT = #{dayWeight},</if>
+            <if test="length != null">LENGTH = #{length},</if>
+            <if test="weight != null">WEIGHT = #{weight},</if>
+            <if test="lengthA != null">LENGTH_A = #{lengthA},</if>
+            <if test="weightA != null">WEIGHT_A = #{weightA},</if>
+            <if test="lengthB != null">LENGTH_B = #{lengthB},</if>
+            <if test="weightB != null">WEIGHT_B = #{weightB},</if>
+            <if test="remark != null">REMARK = #{remark},</if>
+        </trim>
+        where ID = #{id}
+    </update>
+
+    <delete id="deleteTwinCalcDayYhjById" parameterType="Long">
+        delete
+        from TWIN_CALC_DAY_YHJ
+        where ID = #{id}
+    </delete>
+
+    <delete id="deleteTwinCalcDayYhjByIds" parameterType="String">
+        delete from TWIN_CALC_DAY_YHJ where ID in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+    <delete id="delete4date" parameterType="String">
+        DELETE
+        from TWIN_CALC_DAY_YHJ
+        WHERE TIME = #{date}
+    </delete>
+</mapper>

+ 95 - 0
jjt-biz/src/main/resources/mapper/calc/TwinCalcHourYhjMapper.xml

@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jjt.calc.mapper.TwinCalcHourYhjMapper">
+
+    <resultMap type="TwinCalcHourYhj" id="TwinCalcHourYhjResult">
+        <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="distance" column="DISTANCE"/>
+        <result property="remark" column="REMARK"/>
+    </resultMap>
+
+    <sql id="selectTwinCalcHourYhjVo">
+        select ID, DATA_DATE, HOUR, DEVICE_ID, LENGTH, DISTANCE, REMARK
+        from TWIN_CALC_HOUR_YHJ
+    </sql>
+
+    <select id="selectTwinCalcHourYhjList" parameterType="TwinCalcHourYhj" resultMap="TwinCalcHourYhjResult">
+        <include refid="selectTwinCalcHourYhjVo"/>
+        <where>
+            <if test="params.beginDataDate != null and params.beginDataDate != '' and params.endDataDate != null and params.endDataDate != ''">
+                and DATA_DATE between #{params.beginDataDate} and #{params.endDataDate}
+            </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="distance != null ">and DISTANCE = #{distance}</if>
+            <if test="remark != null  and remark != ''">and REMARK = #{remark}</if>
+            <if test="params.sTime != null and params.eTime != null">
+                and DATEADD(hour, HOUR, DATA_DATE) between #{params.sTime} and #{params.eTime}
+            </if>
+        </where>
+    </select>
+
+    <select id="selectTwinCalcHourYhjById" parameterType="Long" resultMap="TwinCalcHourYhjResult">
+        <include refid="selectTwinCalcHourYhjVo"/>
+        where ID = #{id}
+    </select>
+
+    <insert id="insertTwinCalcHourYhj" parameterType="TwinCalcHourYhj">
+        insert into TWIN_CALC_HOUR_YHJ
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="dataDate != null">DATA_DATE,</if>
+            <if test="hour != null">HOUR,</if>
+            <if test="deviceId != null">DEVICE_ID,</if>
+            <if test="length != null">LENGTH,</if>
+            <if test="distance != null">DISTANCE,</if>
+            <if test="remark != null">REMARK,</if>
+        </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="distance != null">#{distance},</if>
+            <if test="remark != null">#{remark},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTwinCalcHourYhj" parameterType="TwinCalcHourYhj">
+        update TWIN_CALC_HOUR_YHJ
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="dataDate != null">DATA_DATE = #{dataDate},</if>
+            <if test="hour != null">HOUR = #{hour},</if>
+            <if test="deviceId != null">DEVICE_ID = #{deviceId},</if>
+            <if test="length != null">LENGTH = #{length},</if>
+            <if test="distance != null">DISTANCE = #{distance},</if>
+            <if test="remark != null">REMARK = #{remark},</if>
+        </trim>
+        where ID = #{id}
+    </update>
+
+    <delete id="deleteTwinCalcHourYhjById" parameterType="Long">
+        delete
+        from TWIN_CALC_HOUR_YHJ
+        where ID = #{id}
+    </delete>
+
+    <delete id="deleteTwinCalcHourYhjByIds" parameterType="String">
+        delete from TWIN_CALC_HOUR_YHJ where ID in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+    <delete id="deleteTwinCalcHourYhj">
+        delete
+        from TWIN_CALC_HOUR_YHJ
+        where DATA_DATE = #{date}
+          and hour = #{hour}
+    </delete>
+</mapper>