3 Commits e8e8a5d7f3 ... 6764693bdb

Author SHA1 Message Date
  wukai 6764693bdb 取消权限 1 week ago
  wukai 94e5ddaa2e 修改规格小时统计 1 week ago
  wukai a086aaecae 解决小小BUG 1 week ago

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

@@ -21,7 +21,7 @@ import java.time.LocalTime;
  * 印花机
  */
 @SpringBootTest(classes = JjtApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("devp")
+//@ActiveProfiles("devp")
 public class EnergyTest {
     @Resource
     private IotService iotService;
@@ -74,8 +74,8 @@ public class EnergyTest {
 
     @Test
     void day() {
-        for (int i = 10; i < 23; i++) {
-            String d = "2025-04-" + (i < 10 ? "0" + i : i);
+        for (int i = 7; i < 11; i++) {
+            String d = "2025-08-" + (i < 10 ? "0" + i : i);
             LocalDate localDate = LocalDate.parse(d);
             calcService.calc(localDate);
         }

+ 10 - 0
jjt-admin/src/test/java/com/jjt/rz/RzCalcTest.java

@@ -1,6 +1,7 @@
 package com.jjt.rz;
 
 import com.jjt.JjtApplication;
+import com.jjt.calc.service.ITwinCalcHourYhjService;
 import com.jjt.ws.domain.TwinRzCalcMonth;
 import com.jjt.ws.service.ITwinRzCalcMonthService;
 import org.junit.jupiter.api.Test;
@@ -22,6 +23,14 @@ import java.util.*;
 public class RzCalcTest {
     @Resource
     private ITwinRzCalcMonthService rzCalcMonthService;
+    @Resource
+    private ITwinCalcHourYhjService twinCalcHourYhjService;
+
+    @Test
+    public void bl() {
+        //  补录印花线数据
+        twinCalcHourYhjService.calc2Curr();
+    }
 
     @Test
     public void test() {
@@ -32,6 +41,7 @@ public class RzCalcTest {
         List<TwinRzCalcMonth> list = rzCalcMonthService.selectTwinRzCalcMonthList(calcMonth);
         list.size();
     }
+
     private static final Random random = new Random();
     private static final int SCALE = 2; // 保留小数位数
     private static final double DEVIATION_PERCENT = 0.25; // 波动幅度30%

+ 2 - 2
jjt-admin/src/test/java/com/jjt/wk/EmpCalcTest.java

@@ -34,9 +34,9 @@ public class EmpCalcTest {
 
     @Test
     public void test() {
-        String s = "2025-07-20";
+        String s = "2025-08-10";
         Date date = DateUtils.parseDate(s);
-        empCalcService.calcNew(date);
+        empCalcService.calc(date);
     }
 
     @Test

+ 6 - 6
jjt-biz/src/main/java/com/jjt/biz/controller/TwinDeviceController.java

@@ -34,7 +34,7 @@ public class TwinDeviceController extends BaseController {
      * 查询设备管理列表
      */
     @ApiOperation("查询设备管理列表")
-    @PreAuthorize("@ss.hasPermi('biz:device:list')")
+    //@PreAuthorize("@ss.hasPermi('biz:device:list')")
     @GetMapping("/list")
     public TableDataInfo list(TwinDevice twinDevice) {
         startPage();
@@ -46,7 +46,7 @@ public class TwinDeviceController extends BaseController {
      * 导出设备管理列表
      */
     @ApiOperation("导出设备管理列表")
-    @PreAuthorize("@ss.hasPermi('biz:device:export')")
+    //@PreAuthorize("@ss.hasPermi('biz:device:export')")
     @Log(title = "设备管理", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, TwinDevice twinDevice) {
@@ -59,7 +59,7 @@ public class TwinDeviceController extends BaseController {
      * 获取设备管理详细信息
      */
     @ApiOperation("获取设备管理详细信息")
-    @PreAuthorize("@ss.hasPermi('biz:device:query')")
+    //@PreAuthorize("@ss.hasPermi('biz:device:query')")
     @GetMapping(value = "/{deviceId}")
     public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
         return success(twinDeviceService.selectTwinDeviceByDeviceId(deviceId));
@@ -69,7 +69,7 @@ public class TwinDeviceController extends BaseController {
      * 新增设备管理
      */
     @ApiOperation("新增设备管理")
-    @PreAuthorize("@ss.hasPermi('biz:device:add')")
+    //@PreAuthorize("@ss.hasPermi('biz:device:add')")
     @Log(title = "设备管理", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody TwinDevice twinDevice) {
@@ -80,7 +80,7 @@ public class TwinDeviceController extends BaseController {
      * 修改设备管理
      */
     @ApiOperation("修改设备管理")
-    @PreAuthorize("@ss.hasPermi('biz:device:edit')")
+    //@PreAuthorize("@ss.hasPermi('biz:device:edit')")
     @Log(title = "设备管理", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody TwinDevice twinDevice) {
@@ -91,7 +91,7 @@ public class TwinDeviceController extends BaseController {
      * 删除设备管理
      */
     @ApiOperation("删除设备管理")
-    @PreAuthorize("@ss.hasPermi('biz:device:remove')")
+    //@PreAuthorize("@ss.hasPermi('biz:device:remove')")
     @Log(title = "设备管理", businessType = BusinessType.DELETE)
     @DeleteMapping("/{deviceIds}")
     public AjaxResult remove(@PathVariable Long[] deviceIds) {

+ 38 - 33
jjt-biz/src/main/java/com/jjt/calc/controller/TwinCalcHourSpecController.java

@@ -1,28 +1,24 @@
 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.calc.domain.TwinCalcHourSpec;
+import com.jjt.calc.service.ITwinCalcHourSpecService;
 import com.jjt.common.annotation.Log;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.AjaxResult;
+import com.jjt.common.core.page.TableDataInfo;
 import com.jjt.common.enums.BusinessType;
-import com.jjt.calc.domain.TwinCalcHourSpec;
-import com.jjt.calc.service.ITwinCalcHourSpecService;
+import com.jjt.common.utils.StringUtils;
 import com.jjt.common.utils.poi.ExcelUtil;
-import com.jjt.common.core.page.TableDataInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 按配方1小时统计数据Controller
@@ -30,10 +26,10 @@ import com.jjt.common.core.page.TableDataInfo;
  * @author wukai
  * @date 2025-01-18
  */
-@Api(tags="按配方1小时统计数据")
+@Api(tags = "按配方1小时统计数据")
 @RestController
 @RequestMapping("/calc/calcSpec")
-public class TwinCalcHourSpecController extends BaseController{
+public class TwinCalcHourSpecController extends BaseController {
     @Resource
     private ITwinCalcHourSpecService twinCalcHourSpecService;
 
@@ -43,9 +39,23 @@ public class TwinCalcHourSpecController extends BaseController{
     @ApiOperation("查询按配方1小时统计数据列表")
     @PreAuthorize("@ss.hasPermi('calc:calcSpec:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TwinCalcHourSpec twinCalcHourSpec)
-    {
+    public TableDataInfo list(TwinCalcHourSpec twinCalcHourSpec) {
         startPage();
+        if (StringUtils.isNotEmpty(twinCalcHourSpec.getRemark())) {
+            String[] hours = twinCalcHourSpec.getRemark().split("-");
+            int start = Integer.parseInt(hours[0]);
+            int end = Integer.parseInt(hours[1]);
+            Map<String, Object> params = twinCalcHourSpec.getParams();
+            if (params == null) {
+                params = new HashMap<>();
+            }
+            String query = "(hour >= " + start + " and hour < " + end + ")";
+            if (start > end) {
+                query = "(hour >= " + start + " or hour < " + end + ")";
+            }
+            params.put("query", query);
+            twinCalcHourSpec.setParams(params);
+        }
         List<TwinCalcHourSpec> list = twinCalcHourSpecService.selectTwinCalcHourSpecList(twinCalcHourSpec);
         return getDataTable(list);
     }
@@ -57,8 +67,7 @@ public class TwinCalcHourSpecController extends BaseController{
     @PreAuthorize("@ss.hasPermi('calc:calcSpec:export')")
     @Log(title = "按配方1小时统计数据", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, TwinCalcHourSpec twinCalcHourSpec)
-    {
+    public void export(HttpServletResponse response, TwinCalcHourSpec twinCalcHourSpec) {
         List<TwinCalcHourSpec> list = twinCalcHourSpecService.selectTwinCalcHourSpecList(twinCalcHourSpec);
         ExcelUtil<TwinCalcHourSpec> util = new ExcelUtil<TwinCalcHourSpec>(TwinCalcHourSpec.class);
         util.exportExcel(response, list, "按配方1小时统计数据数据");
@@ -70,8 +79,7 @@ public class TwinCalcHourSpecController extends BaseController{
     @ApiOperation("获取按配方1小时统计数据详细信息")
     @PreAuthorize("@ss.hasPermi('calc:calcSpec:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(twinCalcHourSpecService.selectTwinCalcHourSpecById(id));
     }
 
@@ -82,8 +90,7 @@ public class TwinCalcHourSpecController extends BaseController{
     @PreAuthorize("@ss.hasPermi('calc:calcSpec:add')")
     @Log(title = "按配方1小时统计数据", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TwinCalcHourSpec twinCalcHourSpec)
-    {
+    public AjaxResult add(@RequestBody TwinCalcHourSpec twinCalcHourSpec) {
         return toAjax(twinCalcHourSpecService.insertTwinCalcHourSpec(twinCalcHourSpec));
     }
 
@@ -94,8 +101,7 @@ public class TwinCalcHourSpecController extends BaseController{
     @PreAuthorize("@ss.hasPermi('calc:calcSpec:edit')")
     @Log(title = "按配方1小时统计数据", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TwinCalcHourSpec twinCalcHourSpec)
-    {
+    public AjaxResult edit(@RequestBody TwinCalcHourSpec twinCalcHourSpec) {
         return toAjax(twinCalcHourSpecService.updateTwinCalcHourSpec(twinCalcHourSpec));
     }
 
@@ -105,9 +111,8 @@ public class TwinCalcHourSpecController extends BaseController{
     @ApiOperation("删除按配方1小时统计数据")
     @PreAuthorize("@ss.hasPermi('calc:calcSpec:remove')")
     @Log(title = "按配方1小时统计数据", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(twinCalcHourSpecService.deleteTwinCalcHourSpecByIds(ids));
     }
 }

+ 1 - 1
jjt-biz/src/main/java/com/jjt/utils/AsyncYhjService.java

@@ -88,7 +88,7 @@ public class AsyncYhjService {
         String sql = "select %s from " + yhj.getDevicePath() + " where time>%s and time <=%s";
 
         sql = String.format(sql, String.join(",", fields), startTime, endTime);
-            JSONObject jsonObject = iotService.query(sql);
+        JSONObject jsonObject = iotService.query(sql);
         JSONObject data = jsonObject.getJSONObject("data");
         JSONArray columnNames = data.getJSONArray("columnNames");
         JSONArray values = data.getJSONArray("values");

+ 9 - 3
jjt-biz/src/main/resources/mapper/calc/TwinCalcHourSpecMapper.xml

@@ -36,7 +36,11 @@
     <select id="selectTwinCalcHourSpecList" parameterType="TwinCalcHourSpec" resultMap="TwinCalcHourSpecResult">
         <include refid="selectTwinCalcHourSpecVo"/>
         <where>
-            <if test="dataDate != null ">and FORMAT(DATEADD(hour, HOUR - 7, DATA_DATE), 'yyyy-MM-dd') = #{dataDate}</if>
+            <if test="dataDate != null ">
+                and (
+                (DATA_DATE = #{dataDate} AND HOUR >= 7) OR (DATA_DATE = DATEADD(DAY, 1, #{dataDate}) AND HOUR &lt; 7)
+                )
+            </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>
@@ -45,16 +49,18 @@
             <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 DATEADD(hour, HOUR, DATA_DATE) between #{params.sTime} and #{params.eTime}
             </if>
+            <if test="params.query != null and params.query != ''">
+                and ${params.query}
+            </if>
             <if test="params.month != null and params.month!=''">
                 and FORMAT(DATEADD(hour, HOUR - 7, DATA_DATE), 'yyyy-MM') = #{params.month}
                 and hour=23
             </if>
         </where>
-        order by DATEADD(hour, HOUR, DATA_DATE)
+        order by data_date,device_id, hour
     </select>
 
     <select id="selectTwinCalcHourSpecById" parameterType="Long" resultMap="TwinCalcHourSpecResult">

+ 1 - 1
jjt-biz/src/main/resources/mapper/wkEmp/TwinWkEmpRotaMapper.xml

@@ -46,7 +46,7 @@
             <if test="empTeam != null  and empTeam != ''">and EMP_TEAM = #{empTeam}</if>
             <if test="inTime != null ">and IN_TIME = #{inTime}</if>
             <if test="outTime != null ">and OUT_TIME = #{outTime}</if>
-            <if test="devices != null  and devices != ''">and DEVICES = #{devices}</if>
+            <if test="devices != null  and devices != ''">and concat(',',DEVICES,',') like concat('%,', #{devices}, ',%')</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>