|
|
@@ -3,6 +3,8 @@ package com.jjt.calc.controller;
|
|
|
import com.jjt.calc.domain.TwinCalcStop;
|
|
|
import com.jjt.calc.service.ITwinCalcStopService;
|
|
|
import com.jjt.calc.vo.StopCalcVO;
|
|
|
+import com.jjt.calc.vo.StopDetail;
|
|
|
+import com.jjt.calc.vo.StopVO;
|
|
|
import com.jjt.calc.vo.TpsVO;
|
|
|
import com.jjt.common.annotation.Log;
|
|
|
import com.jjt.common.core.controller.BaseController;
|
|
|
@@ -12,9 +14,9 @@ import com.jjt.common.core.page.TableDataInfo;
|
|
|
import com.jjt.common.enums.BusinessType;
|
|
|
import com.jjt.common.utils.poi.ExcelUtil;
|
|
|
import com.jjt.utils.Tools;
|
|
|
+import com.jjt.utils.TrendAnalysis;
|
|
|
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;
|
|
|
@@ -42,14 +44,130 @@ public class TwinCalcStopController extends BaseController {
|
|
|
* 查询停机数据统计列表
|
|
|
*/
|
|
|
@ApiOperation("查询停机数据统计列表")
|
|
|
- @PreAuthorize("@ss.hasPermi('calc:calcStop:list')")
|
|
|
@GetMapping("/list")
|
|
|
public TableDataInfo list(TwinCalcStop twinCalcStop) {
|
|
|
- startPage();
|
|
|
List<TwinCalcStop> list = twinCalcStopService.selectTwinCalcStopList(twinCalcStop);
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("故障停机统计")
|
|
|
+ @GetMapping("/gz-stop")
|
|
|
+ public AjaxResult gzStop(TwinCalcStop twinCalcStop) {
|
|
|
+ Date d;
|
|
|
+ if (twinCalcStop.getRemark() != null && !twinCalcStop.getRemark().isEmpty()) {
|
|
|
+ try {
|
|
|
+ int days = Integer.parseInt(twinCalcStop.getRemark());
|
|
|
+ d = new Date(System.currentTimeMillis() - (long) days * 24 * 60 * 60 * 1000);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 如果转换失败,则使用默认的90天
|
|
|
+ d = new Date(System.currentTimeMillis() - 90L * 24 * 60 * 60 * 1000);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ d = new Date(System.currentTimeMillis() - 90L * 24 * 60 * 60 * 1000);
|
|
|
+ }
|
|
|
+ twinCalcStop.setWorkDay(d);
|
|
|
+ List<StopDetail> list = twinCalcStopService.selectTwinCalcStopDetailList(twinCalcStop);
|
|
|
+ List<StopVO> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ //按照deviceId分组
|
|
|
+ Map<Long, List<StopDetail>> deviceGroup = list.stream().collect(Collectors.groupingBy(StopDetail::getDeviceId, LinkedHashMap::new, Collectors.toList()));
|
|
|
+
|
|
|
+ // 统计各种趋势结果的数量
|
|
|
+ Map<String, Long> trendCounts = new HashMap<>();
|
|
|
+ trendCounts.put("明显上升", 0L);
|
|
|
+ trendCounts.put("上升", 0L);
|
|
|
+ trendCounts.put("平稳", 0L);
|
|
|
+ trendCounts.put("下降", 0L);
|
|
|
+ trendCounts.put("明显下降", 0L);
|
|
|
+
|
|
|
+ deviceGroup.forEach((deviceId, dataList) -> {
|
|
|
+ if (dataList.size() < 3) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Integer> times = dataList.stream()
|
|
|
+ .map(StopDetail::getTimes)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ StopVO vo = new StopVO();
|
|
|
+ vo.setDeviceId(deviceId);
|
|
|
+ vo.setDeviceName(dataList.get(0).getDeviceName());
|
|
|
+ vo.setList(dataList);
|
|
|
+ vo.setDataNum(times.size());
|
|
|
+ TrendAnalysis.analysisDetail(vo, times);
|
|
|
+ // 更新趋势计数
|
|
|
+ trendCounts.put(vo.getResult(), trendCounts.get(vo.getResult()) + 1);
|
|
|
+
|
|
|
+ vo.setResult(vo.getResult());
|
|
|
+ resultList.add(vo);
|
|
|
+ });
|
|
|
+
|
|
|
+ Map<String, Object> statistics = new HashMap<>();
|
|
|
+ statistics.put("totalDevices", resultList.size());
|
|
|
+ statistics.put("trendCounts", trendCounts);
|
|
|
+ resultList.get(0).setAdditionalInfo(statistics);
|
|
|
+
|
|
|
+ resultList.sort(Comparator.comparing(StopVO::getDeviceId));
|
|
|
+ return success(resultList).put("statistics", statistics);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("断纱停机统计")
|
|
|
+ @GetMapping("/ds-stop")
|
|
|
+ public AjaxResult dsStop(TwinCalcStop twinCalcStop) {
|
|
|
+ Date d;
|
|
|
+ if (twinCalcStop.getRemark() != null && !twinCalcStop.getRemark().isEmpty()) {
|
|
|
+ try {
|
|
|
+ int days = Integer.parseInt(twinCalcStop.getRemark());
|
|
|
+ d = new Date(System.currentTimeMillis() - (long) days * 24 * 60 * 60 * 1000);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 如果转换失败,则使用默认的90天
|
|
|
+ d = new Date(System.currentTimeMillis() - 90L * 24 * 60 * 60 * 1000);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ d = new Date(System.currentTimeMillis() - 90L * 24 * 60 * 60 * 1000);
|
|
|
+ }
|
|
|
+ twinCalcStop.setWorkDay(d);
|
|
|
+ List<StopDetail> list = twinCalcStopService.selectTwinCalcStopDetailList(twinCalcStop);
|
|
|
+ List<StopVO> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ //按照deviceId分组
|
|
|
+ Map<Long, List<StopDetail>> deviceGroup = list.stream().collect(Collectors.groupingBy(StopDetail::getDeviceId, LinkedHashMap::new, Collectors.toList()));
|
|
|
+
|
|
|
+ // 统计各种趋势结果的数量
|
|
|
+ Map<String, Long> trendCounts = new HashMap<>();
|
|
|
+ trendCounts.put("明显上升", 0L);
|
|
|
+ trendCounts.put("上升", 0L);
|
|
|
+ trendCounts.put("平稳", 0L);
|
|
|
+ trendCounts.put("下降", 0L);
|
|
|
+ trendCounts.put("明显下降", 0L);
|
|
|
+
|
|
|
+ deviceGroup.forEach((deviceId, dataList) -> {
|
|
|
+ if (dataList.size() < 3) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Integer> times = dataList.stream()
|
|
|
+ .map(StopDetail::getTimes)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ StopVO vo = new StopVO();
|
|
|
+ vo.setDeviceId(deviceId);
|
|
|
+ vo.setDeviceName(dataList.get(0).getDeviceName());
|
|
|
+ vo.setList(dataList);
|
|
|
+ vo.setDataNum(times.size());
|
|
|
+ TrendAnalysis.analysisDetail(vo, times);
|
|
|
+ // 更新趋势计数
|
|
|
+ trendCounts.put(vo.getResult(), trendCounts.get(vo.getResult()) + 1);
|
|
|
+
|
|
|
+ vo.setResult(vo.getResult());
|
|
|
+ resultList.add(vo);
|
|
|
+ });
|
|
|
+
|
|
|
+ Map<String, Object> statistics = new HashMap<>();
|
|
|
+ statistics.put("totalDevices", resultList.size());
|
|
|
+ statistics.put("trendCounts", trendCounts);
|
|
|
+ resultList.get(0).setAdditionalInfo(statistics);
|
|
|
+
|
|
|
+ resultList.sort(Comparator.comparing(StopVO::getDeviceId));
|
|
|
+ return success(resultList).put("statistics", statistics);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("停机统计")
|
|
|
@GetMapping("/calc")
|
|
|
public R calc(TwinCalcStop twinCalcStop) {
|
|
|
@@ -153,7 +271,6 @@ public class TwinCalcStopController extends BaseController {
|
|
|
* 导出停机数据统计列表
|
|
|
*/
|
|
|
@ApiOperation("导出停机数据统计列表")
|
|
|
- @PreAuthorize("@ss.hasPermi('calc:calcStop:export')")
|
|
|
@Log(title = "停机数据统计", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
public void export(HttpServletResponse response, TwinCalcStop twinCalcStop) {
|
|
|
@@ -166,7 +283,7 @@ public class TwinCalcStopController extends BaseController {
|
|
|
* 获取停机数据统计详细信息
|
|
|
*/
|
|
|
@ApiOperation("获取停机数据统计详细信息")
|
|
|
- @PreAuthorize("@ss.hasPermi('calc:calcStop:query')")
|
|
|
+ //@PreAuthorize("@ss.hasPermi('calc:calcStop:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
return success(twinCalcStopService.selectTwinCalcStopById(id));
|
|
|
@@ -176,7 +293,7 @@ public class TwinCalcStopController extends BaseController {
|
|
|
* 新增停机数据统计
|
|
|
*/
|
|
|
@ApiOperation("新增停机数据统计")
|
|
|
- @PreAuthorize("@ss.hasPermi('calc:calcStop:add')")
|
|
|
+ //@PreAuthorize("@ss.hasPermi('calc:calcStop:add')")
|
|
|
@Log(title = "停机数据统计", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
public AjaxResult add(@RequestBody TwinCalcStop twinCalcStop) {
|
|
|
@@ -187,7 +304,7 @@ public class TwinCalcStopController extends BaseController {
|
|
|
* 修改停机数据统计
|
|
|
*/
|
|
|
@ApiOperation("修改停机数据统计")
|
|
|
- @PreAuthorize("@ss.hasPermi('calc:calcStop:edit')")
|
|
|
+ //@PreAuthorize("@ss.hasPermi('calc:calcStop:edit')")
|
|
|
@Log(title = "停机数据统计", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
public AjaxResult edit(@RequestBody TwinCalcStop twinCalcStop) {
|
|
|
@@ -198,7 +315,7 @@ public class TwinCalcStopController extends BaseController {
|
|
|
* 删除停机数据统计
|
|
|
*/
|
|
|
@ApiOperation("删除停机数据统计")
|
|
|
- @PreAuthorize("@ss.hasPermi('calc:calcStop:remove')")
|
|
|
+ //@PreAuthorize("@ss.hasPermi('calc:calcStop:remove')")
|
|
|
@Log(title = "停机数据统计", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|