From 3423bb9ee5b25d270a00763b69ed73970d790f63 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期二, 18 二月 2025 16:43:43 +0800
Subject: [PATCH] update
---
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcMttrInfoMapper.java | 24 +
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcMttrInfoService.java | 37 ++
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java | 42 ++
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcRepairInfoMapper.xml | 20 +
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcRepairInfoServiceImpl.java | 53 +++
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcRepairInfo.java | 13
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/api/controller/SystemApiController.java | 7
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FileUtils.java | 2
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDownTimeController.java | 2
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDownTimeMapper.xml | 20 +
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcMttrInfo.java | 91 +++++
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDownTime.java | 9
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDepartMapper.xml | 18
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/FileUtils.java | 189 +++++++++++
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java | 2
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcRepairInfoController.java | 2
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDownTimeMapper.java | 17 +
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcMttrInfoMapper.xml | 30 +
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcMttrInfoController.java | 77 ++++
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDownTimeServiceImpl.java | 70 ++++
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcMttrInfoVo.java | 20 +
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcRepairInfoMapper.java | 18 +
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcMttrInfoServiceImpl.java | 142 ++++++++
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOeeInfo.java | 2
24 files changed, 869 insertions(+), 38 deletions(-)
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDownTimeController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDownTimeController.java
index 4a3e494..7dc5aaa 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDownTimeController.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDownTimeController.java
@@ -170,7 +170,7 @@
@AutoLog(value = "璁惧鏁呴殰鍋滄満鏃堕暱琛�-璁$畻MTBF")
@ApiOperation(value = "璁惧鏁呴殰鍋滄満鏃堕暱琛�-璁$畻MTBF", notes = "璁惧鏁呴殰鍋滄満鏃堕暱琛�-璁$畻MTBF")
@PostMapping(value = "/computeMtbf")
- public Result<?> computeMtbf(@RequestBody String month) {
+ public Result<?> computeMtbf(@RequestParam(name = "month", required = true) String month) {
mdcDownTimeService.computeMtbf(month);
return Result.OK("璁$畻鎴愬姛锛�");
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcMttrInfoController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcMttrInfoController.java
new file mode 100644
index 0000000..85e7d42
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcMttrInfoController.java
@@ -0,0 +1,77 @@
+package org.jeecg.modules.mdc.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.mdc.entity.MdcMttrInfo;
+import org.jeecg.modules.mdc.entity.MdcOeeInfo;
+import org.jeecg.modules.mdc.service.IMdcMttrInfoService;
+import org.jeecg.modules.mdc.vo.MdcMttrInfoVo;
+import org.jeecg.modules.mdc.vo.MdcOeeInfoVo;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @Description: 璁惧鏁呴殰缁翠慨琛�
+ * @Author: lius
+ * @Date: 2025-02-18
+ */
+@Slf4j
+@Api(tags = "璁惧鏁呴殰缁翠慨琛�")
+@RestController
+@RequestMapping("/mdc/mdcMttrInfo")
+public class MdcMttrInfoController extends JeecgController<MdcMttrInfo, IMdcMttrInfoService> {
+
+ @Resource
+ private IMdcMttrInfoService mdcMttrInfoService;
+
+ /**
+ * 鍒嗛〉鍒楄〃鏌ヨ
+ *
+ * @param mdcMttrInfoVo
+ * @param pageNo
+ * @param pageSize
+ * @param req
+ * @return
+ */
+ @AutoLog(value = "璁惧鏁呴殰缁翠慨琛�-鍒嗛〉鍒楄〃鏌ヨ")
+ @ApiOperation(value = "璁惧鏁呴殰缁翠慨琛�-鍒嗛〉鍒楄〃鏌ヨ", notes = "璁惧鏁呴殰缁翠慨琛�-鍒嗛〉鍒楄〃鏌ヨ")
+ @GetMapping(value = "/list")
+ public Result<?> queryPageList(MdcMttrInfoVo mdcMttrInfoVo,
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+ HttpServletRequest req) {
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+ String userId = user.getId();
+ Page<MdcMttrInfo> page = new Page<MdcMttrInfo>(pageNo, pageSize);
+ IPage<MdcMttrInfo> pageList = mdcMttrInfoService.pageList(userId, page, mdcMttrInfoVo, req);
+ return Result.OK(pageList);
+ }
+
+ /**
+ * 瀵煎嚭excel
+ *
+ * @param request
+ * @param mdcMttrInfoVo
+ */
+ @RequestMapping(value = "/exportXls")
+ public ModelAndView exportXls(HttpServletRequest request, MdcMttrInfoVo mdcMttrInfoVo) {
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+ String userId = user.getId();
+ return mdcMttrInfoService.exportXls(userId, mdcMttrInfoVo);
+ }
+
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcRepairInfoController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcRepairInfoController.java
index 24415f6..9d600fb 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcRepairInfoController.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcRepairInfoController.java
@@ -170,7 +170,7 @@
@AutoLog(value = "璁惧缁翠慨鏃堕暱琛�-璁$畻MTTR")
@ApiOperation(value = "璁惧缁翠慨鏃堕暱琛�-璁$畻MTTR", notes = "璁惧缁翠慨鏃堕暱琛�-璁$畻MTTR")
@PostMapping(value = "/computeMttr")
- public Result<?> computeMttr(@RequestBody String month) {
+ public Result<?> computeMttr(@RequestParam(name = "month", required = true) String month) {
mdcRepairInfoService.computeMttr(month);
return Result.OK("璁$畻鎴愬姛锛�");
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDownTime.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDownTime.java
index 907be2f..6e1c804 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDownTime.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDownTime.java
@@ -10,6 +10,7 @@
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
+import java.math.BigDecimal;
/**
* @Description: 璁惧鏁呴殰鍋滄満鏃堕暱琛�
@@ -38,10 +39,10 @@
@ApiModelProperty(value = "鏃ユ湡")
private String theDate;
/**
- * 鏁呴殰鍋滄満鏃堕暱(min)
+ * 鏁呴殰鍋滄満鏃堕暱(hour)
*/
- @Excel(name = "鏁呴殰鍋滄満鏃堕暱(min)", width = 15)
- @ApiModelProperty(value = "鏁呴殰鍋滄満鏃堕暱(min)")
- private Integer downLong;
+ @Excel(name = "鏁呴殰鍋滄満鏃堕暱(hour)", width = 15)
+ @ApiModelProperty(value = "鏁呴殰鍋滄満鏃堕暱(hour)")
+ private BigDecimal downLong;
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcMttrInfo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcMttrInfo.java
new file mode 100644
index 0000000..1c37128
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcMttrInfo.java
@@ -0,0 +1,91 @@
+package org.jeecg.modules.mdc.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecg.common.system.base.entity.JeecgEntity;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author Lius
+ * @date 2025/2/7 9:31
+ */
+@Data
+@TableName("mdc_mttr_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "mdc_mttr_info瀵硅薄", description = "璁惧鏁呴殰缁翠慨琛�")
+public class MdcMttrInfo extends JeecgEntity implements Serializable {
+
+ private static final long serialVersionUID = -4164370727294921773L;
+
+ /**
+ * 璁惧缂栧彿
+ */
+ @Excel(name = "璁惧缂栧彿", width = 15)
+ @ApiModelProperty(value = "璁惧缂栧彿")
+ private String equipmentId;
+
+ /**
+ * 鏃ユ湡
+ */
+ @Excel(name = "鏃ユ湡", width = 15)
+ @ApiModelProperty(value = "鏃ユ湡")
+ private String theDate;
+
+ /**
+ * 鏃ュ巻鏃堕棿
+ */
+ @Excel(name = "鏃ュ巻鏃堕棿", width = 15)
+ @ApiModelProperty(value = "鏃ュ巻鏃堕棿(hour)")
+ private BigDecimal calendarLong = BigDecimal.ZERO;
+
+ /**
+ * 鎬绘晠闅滃仠鏈烘椂闂�
+ */
+ @Excel(name = "鎬绘晠闅滃仠鏈烘椂闂�", width = 15)
+ @ApiModelProperty(value = "鎬绘晠闅滃仠鏈烘椂闂�(hour)")
+ private BigDecimal totalDownLong = BigDecimal.ZERO;
+
+ /**
+ * 鎬绘晠闅滄鏁�
+ */
+ @Excel(name = "鎬绘晠闅滄鏁�", width = 15)
+ @ApiModelProperty(value = "鎬绘晠闅滄鏁�")
+ private Integer totalDownCount = 0;
+
+ /**
+ * MTBF
+ */
+ @Excel(name = "MTBF", width = 15)
+ @ApiModelProperty(value = "MTBF(hour)")
+ private BigDecimal mtbf = BigDecimal.ZERO;
+
+ /**
+ * 鎬荤淮淇椂闂�
+ */
+ @Excel(name = "鎬荤淮淇椂闂�", width = 15)
+ @ApiModelProperty(value = "鎬荤淮淇椂闂�(hour)")
+ private BigDecimal totalRepairLong = BigDecimal.ZERO;
+
+ /**
+ * 鎬荤淮淇鏁�
+ */
+ @Excel(name = "鎬荤淮淇鏁�", width = 15)
+ @ApiModelProperty(value = "鎬荤淮淇鏁�")
+ private Integer totalRepairCount = 0;
+
+ /**
+ * MTTR
+ */
+ @Excel(name = "MTTR", width = 15)
+ @ApiModelProperty(value = "MTTR(hour)")
+ private BigDecimal mttr = BigDecimal.ZERO;
+
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOeeInfo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOeeInfo.java
index 4cdb420..6832055 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOeeInfo.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOeeInfo.java
@@ -24,6 +24,8 @@
@ApiModel(value = "mdc_oee_info瀵硅薄", description = "OEE琛�")
public class MdcOeeInfo extends JeecgEntity implements Serializable {
+ private static final long serialVersionUID = -1029070983514140912L;
+
/**
* 璁惧缂栧彿
*/
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcRepairInfo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcRepairInfo.java
index 29b6a52..42d92b7 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcRepairInfo.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcRepairInfo.java
@@ -10,6 +10,7 @@
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
+import java.math.BigDecimal;
/**
* @Description: 璁惧缁翠慨鏃堕暱琛�
@@ -30,18 +31,18 @@
*/
@Excel(name = "璁惧缂栧彿", width = 15)
@ApiModelProperty(value = "璁惧缂栧彿")
- private java.lang.String equipmentId;
+ private String equipmentId;
/**
* 鏃ユ湡
*/
@Excel(name = "鏃ユ湡", width = 15)
@ApiModelProperty(value = "鏃ユ湡")
- private java.lang.String theDate;
+ private String theDate;
/**
- * 缁翠慨鏃堕暱(min)
+ * 缁翠慨鏃堕暱(hour)
*/
- @Excel(name = "缁翠慨鏃堕暱(min)", width = 15)
- @ApiModelProperty(value = "缁翠慨鏃堕暱(min)")
- private java.lang.Integer repairLong;
+ @Excel(name = "缁翠慨鏃堕暱(hour)", width = 15)
+ @ApiModelProperty(value = "缁翠慨鏃堕暱(hour)")
+ private BigDecimal repairLong;
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDownTimeMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDownTimeMapper.java
index fedf22d..eaa509a 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDownTimeMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDownTimeMapper.java
@@ -7,6 +7,8 @@
import org.jeecg.modules.mdc.entity.MdcDownTime;
import org.jeecg.modules.mdc.vo.MdcDownTimeVo;
+import java.math.BigDecimal;
+
/**
* @Description: 璁惧鏁呴殰鍋滄満鏃堕暱琛�
* @Author: Lius
@@ -23,4 +25,19 @@
*/
IPage<MdcDownTime> pageList(Page<MdcDownTime> page, @Param("mdcDownTimeVo") MdcDownTimeVo mdcDownTimeVo);
+ /**
+ * 鏌ヨ褰撴湀鎬绘晠闅滃仠鏈烘椂闂�
+ *
+ * @param month
+ * @return
+ */
+ BigDecimal findTotalDownLong(@Param("month") String month);
+
+ /**
+ * 鏌ヨ褰撴湀鎬绘晠闅滃仠鏈烘鏁�
+ *
+ * @param month
+ * @return
+ */
+ Integer findTotalDownCount(@Param("month") String month);
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcMttrInfoMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcMttrInfoMapper.java
new file mode 100644
index 0000000..6d1af92
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcMttrInfoMapper.java
@@ -0,0 +1,24 @@
+package org.jeecg.modules.mdc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.mdc.entity.MdcMttrInfo;
+import org.jeecg.modules.mdc.vo.MdcMttrInfoVo;
+
+/**
+ * @author Lius
+ * @date 2025/2/18 13:53
+ */
+public interface MdcMttrInfoMapper extends BaseMapper<MdcMttrInfo> {
+
+ /**
+ * 鍒嗛〉鍒楄〃
+ *
+ * @param page
+ * @param mdcMttrInfoVo
+ * @return
+ */
+ IPage<MdcMttrInfo> pageList(Page<MdcMttrInfo> page, @Param("mdcMttrInfoVo") MdcMttrInfoVo mdcMttrInfoVo);
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcRepairInfoMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcRepairInfoMapper.java
index 5ec663f..ea0694c 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcRepairInfoMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcRepairInfoMapper.java
@@ -7,6 +7,8 @@
import org.jeecg.modules.mdc.entity.MdcRepairInfo;
import org.jeecg.modules.mdc.vo.MdcRepairInfoVo;
+import java.math.BigDecimal;
+
/**
* @Description: 璁惧缁翠慨鏃堕暱琛�
* @Author: Lius
@@ -22,4 +24,20 @@
* @return
*/
IPage<MdcRepairInfo> pageList(Page<MdcRepairInfo> page, @Param("mdcRepairInfoVo") MdcRepairInfoVo mdcRepairInfoVo);
+
+ /**
+ * 鏌ヨ褰撴湀鎬荤淮淇椂闂�
+ *
+ * @param month
+ * @return
+ */
+ BigDecimal findTotalRepairLong(@Param("month") String month);
+
+ /**
+ * 鏌ヨ褰撴湀鎬荤淮淇鏁�
+ *
+ * @param month
+ * @return
+ */
+ Integer findTotalRepairCount(@Param("month") String month);
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDownTimeMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDownTimeMapper.xml
index aa4344b..c0d4bb3 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDownTimeMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDownTimeMapper.xml
@@ -27,4 +27,24 @@
</where>
ORDER BY the_date DESC, equipment_id ASC
</select>
+
+ <!--鏌ヨ褰撴湀鎬绘晠闅滃仠鏈烘椂闂�-->
+ <select id="findTotalDownLong" resultType="java.math.BigDecimal">
+ SELECT
+ SUM(down_long)
+ FROM
+ mdc_down_time
+ WHERE
+ the_date LIKE CONCAT(#{month}, '%')
+ </select>
+
+ <!--鏌ヨ褰撴湀鎬绘晠闅滃仠鏈烘鏁�-->
+ <select id="findTotalDownCount" resultType="java.lang.Integer">
+ SELECT
+ COUNT(down_long)
+ FROM
+ mdc_down_time
+ WHERE
+ the_date LIKE CONCAT(#{month}, '%')
+ </select>
</mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcMttrInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcMttrInfoMapper.xml
new file mode 100644
index 0000000..5280753
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcMttrInfoMapper.xml
@@ -0,0 +1,30 @@
+<?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="org.jeecg.modules.mdc.mapper.MdcMttrInfoMapper">
+
+ <!--鍒嗛〉鍒楄〃-->
+ <select id="pageList" resultType="org.jeecg.modules.mdc.entity.MdcMttrInfo">
+ SELECT
+ *
+ FROM
+ mdc_mttr_info
+ <where>
+ <if test="MdcMttrInfoVo.equipmentId != null and MdcMttrInfoVo.equipmentId != ''">
+ AND equipment_id = #{ MdcMttrInfoVo.equipmentId }
+ </if>
+ <if test="MdcMttrInfoVo.startTime != null and MdcMttrInfoVo.startTime != ''">
+ AND the_date >= #{ MdcMttrInfoVo.startTime }
+ </if>
+ <if test="MdcMttrInfoVo.endTime != null and MdcMttrInfoVo.endTime != ''">
+ AND the_date <= #{MdcMttrInfoVo.endTime }
+ </if>
+ <if test="MdcMttrInfoVo.equipmentIdList != null and MdcMttrInfoVo.equipmentIdList.size() > 0 ">
+ AND equipment_id IN
+ <foreach collection="MdcMttrInfoVo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
+ #{ id }
+ </foreach>
+ </if>
+ </where>
+ ORDER BY the_date DESC, equipment_id ASC
+ </select>
+</mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcRepairInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcRepairInfoMapper.xml
index 8531fc7..c44cf58 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcRepairInfoMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcRepairInfoMapper.xml
@@ -27,4 +27,24 @@
</where>
ORDER BY the_date DESC, equipment_id ASC
</select>
+
+ <!--鏌ヨ褰撴湀鎬荤淮淇椂闂�-->
+ <select id="findTotalRepairLong" resultType="java.math.BigDecimal">
+ SELECT
+ SUM(repair_long)
+ FROM
+ mdc_repair_info
+ WHERE
+ the_date LIKE CONCAT(#{month}, '%')
+ </select>
+
+ <!--鏌ヨ褰撴湀鎬荤淮淇鏁�-->
+ <select id="findTotalRepairCount" resultType="java.lang.Integer">
+ SELECT
+ COUNT(repair_long)
+ FROM
+ mdc_repair_info
+ WHERE
+ the_date LIKE CONCAT(#{month}, '%')
+ </select>
</mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcMttrInfoService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcMttrInfoService.java
new file mode 100644
index 0000000..7c2cb78
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcMttrInfoService.java
@@ -0,0 +1,37 @@
+package org.jeecg.modules.mdc.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.mdc.entity.MdcMttrInfo;
+import org.jeecg.modules.mdc.vo.MdcMttrInfoVo;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author Lius
+ * @date 2025/2/18 13:48
+ */
+public interface IMdcMttrInfoService extends IService<MdcMttrInfo> {
+
+ /**
+ * 鍒嗛〉鍒楄〃
+ *
+ * @param userId
+ * @param page
+ * @param mdcMttrInfoVo
+ * @param req
+ * @return
+ */
+ IPage<MdcMttrInfo> pageList(String userId, Page<MdcMttrInfo> page, MdcMttrInfoVo mdcMttrInfoVo, HttpServletRequest req);
+
+ /**
+ * 瀵煎嚭
+ *
+ * @param userId
+ * @param mdcMttrInfoVo
+ * @return
+ */
+ ModelAndView exportXls(String userId, MdcMttrInfoVo mdcMttrInfoVo);
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java
index c9c68b1..87eac22 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java
@@ -29,10 +29,14 @@
import javax.annotation.Resource;
import java.io.File;
import java.net.InetAddress;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* @author Lius
@@ -77,7 +81,7 @@
@Resource
private IMdcPassLogService mdcPassLogService;
- private static final String TYPE = "01";
+ private static final String TYPE = "18";
@Resource
private SqlExecutor sqlExecutor;
@@ -107,16 +111,22 @@
// 鏂囦欢璺緞
String locFilePath = localFilePath + TYPE + today + String.format("%06d", sequenceNumber) + ".xml";
- FileWriter writer = new FileWriter(locFilePath);
- writer.writeLines(sqlList);
+// FileWriter writer = new FileWriter(locFilePath);
+// writer.writeLines(sqlList);
+ String listSql = String.join("\n", sqlList);
+ try {
+ FileUtils.fileWriterSql(locFilePath, listSql);
+ } catch (Exception e) {
+ throw new JeecgBootException("鏁版嵁鍐欏叆鏂囦欢澶辫触锛�");
+ }
// step.4 鎺ㄩ�佺綉闂�
// step.4.1 娴嬭瘯鏈嶅姟鍣ㄨ繛閫氭��
- boolean ping = NetUtil.ping(host + ":" + port);
+ /* boolean ping = NetUtil.ping(host + ":" + port);
if (!ping) {
FileUtil.del(locFilePath);
throw new JeecgBootException("鏈嶅姟鍣ㄨ繛鎺ワ細 " + host + ":" + port + " 寮傚父锛�");
- }
+ }*/
// step.4.2 鑾峰彇token
String token = "";
@@ -167,12 +177,19 @@
objectName.setDestination(host);
objectName.setResult("澶辫触");
// 鏈湴鏂囦欢璺緞
- String loFilePath = localFilePath + "\\" + file.getName();
+ String loFilePath = localFilePath + file.getName();
// 鐩爣鏂囦欢璺緞
- String servicePathName = servicePath + "\\" + file.getName();
+ String servicePathName = servicePath + file.getName();
String result = FileClient.uploadFile(host, port, token, file.getName(), servicePathName, loFilePath, addressUploadFile);
if ("鎴愬姛".equals(result)) {
- FileUtil.del(loFilePath);
+ if (sequenceNumber == 1) {
+ // 鍒犻櫎鏄ㄦ棩澶囦唤鏂囦欢澶逛腑鍘嗗彶鏂囦欢
+ FileUtil.clean(newFilePath);
+ }
+ // 鎴愬姛涔嬪悗灏嗘枃浠跺浠借蛋
+ FileUtil.move(new File(locFilePath), new File(newFilePath + fileName), true);
+// FileUtil.copy(locFilePath, newFilePath + fileName, true);
+// FileUtil.del(loFilePath);
objectName.setResult("鎴愬姛");
SyslogClient.sendClient(logIp, Integer.valueOf(logPort), objectName.toString());
} else {
@@ -203,7 +220,7 @@
File[] files = FileUtil.ls(localFilePath);
for (File file : files) {
if (file.isFile()) {
- String loFilePath = localFilePath + "\\" + file.getName();
+ String loFilePath = localFilePath + file.getName();
FileReader fileReader = new FileReader(loFilePath);
String sqlList = fileReader.readString();
try {
@@ -211,8 +228,13 @@
} catch (Exception e) {
throw new JeecgBootException("鎵цsql澶辫触锛�");
}
+ if (Integer.parseInt(file.getName().substring(file.getName().length() - 10, file.getName().length() - 4)) == 1) {
+ // 鍒犻櫎鍘嗗彶鏂囦欢
+ FileUtil.clean(newFilePath);
+ }
+
// 澶囦唤
- FileUtil.move(new File(loFilePath), new File(newFilePath + "\\" + file.getName()), true);
+ FileUtil.move(new File(loFilePath), new File(newFilePath + file.getName()), true);
}
}
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDownTimeServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDownTimeServiceImpl.java
index ba7b735..c988419 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDownTimeServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDownTimeServiceImpl.java
@@ -8,10 +8,14 @@
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.mdc.entity.MdcDownTime;
+import org.jeecg.modules.mdc.entity.MdcEquipment;
+import org.jeecg.modules.mdc.entity.MdcMttrInfo;
import org.jeecg.modules.mdc.entity.MdcOeeInfo;
import org.jeecg.modules.mdc.mapper.MdcDownTimeMapper;
import org.jeecg.modules.mdc.service.IMdcDownTimeService;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
+import org.jeecg.modules.mdc.service.IMdcMttrInfoService;
+import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.vo.MdcDownTimeVo;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -22,6 +26,10 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -36,6 +44,9 @@
@Resource
private IMdcEquipmentService mdcEquipmentService;
+
+ @Resource
+ private IMdcMttrInfoService mdcMttrInfoService;
@Override
public IPage<MdcDownTime> pageList(String userId, Page<MdcDownTime> page, MdcDownTimeVo mdcDownTimeVo, HttpServletRequest req) {
@@ -160,6 +171,65 @@
*/
@Override
public void computeMtbf(String month) {
+ /*
+ 璁惧骞冲潎鏁呴殰闂撮殧鏈�(MTBF) = (鏃ュ巻鏃堕棿 - 鎬绘晠闅滃仠鏈烘椂闂�) / 鎬绘晠闅滄鏁�
+ */
+ // step.1
+ List<MdcMttrInfo> mdcMttrInfos = mdcMttrInfoService.list(new LambdaQueryWrapper<MdcMttrInfo>().eq(MdcMttrInfo::getTheDate, month));
+ DateTimeFormatter df = DateTimeFormatter.ofPattern(DateUtils.STR_DATE);
+ LocalDate parse = LocalDate.parse(month + "-01", df);
+ int calendarLong = parse.lengthOfMonth() * 24;
+ if (mdcMttrInfos != null && !mdcMttrInfos.isEmpty()) {
+ for (MdcMttrInfo mdcMttrInfo : mdcMttrInfos) {
+ // 鏃ュ巻鏃堕棿
+ mdcMttrInfo.setCalendarLong(new BigDecimal(calendarLong));
+ // 鎬绘晠闅滃仠鏈烘椂闂�
+ BigDecimal totalDownLong = this.baseMapper.findTotalDownLong(month);
+ if (totalDownLong != null) {
+ mdcMttrInfo.setTotalDownLong(totalDownLong);
+ }
+ // 鎬绘晠闅滄鏁�
+ Integer totalDownCount = this.baseMapper.findTotalDownCount(month);
+ if (totalDownLong != null) {
+ mdcMttrInfo.setTotalDownCount(totalDownCount);
+ }
+ // MTBF
+ if (mdcMttrInfo.getTotalDownCount() != 0) {
+ BigDecimal mtbf = (mdcMttrInfo.getCalendarLong().subtract(mdcMttrInfo.getTotalDownLong())).divide(new BigDecimal(mdcMttrInfo.getTotalDownCount()), 4, RoundingMode.HALF_UP);
+ mdcMttrInfo.setMtbf(mtbf);
+ }
+ }
+ mdcMttrInfoService.updateBatchById(mdcMttrInfos);
+ } else {
+ List<MdcEquipment> equipmentList = mdcEquipmentService.list();
+ if (equipmentList != null && !equipmentList.isEmpty()) {
+ List<MdcMttrInfo> mmi = new ArrayList<>();
+ for (MdcEquipment mdcEquipment : equipmentList) {
+ MdcMttrInfo mdcMttrInfo = new MdcMttrInfo();
+ mdcMttrInfo.setEquipmentId(mdcEquipment.getEquipmentId());
+ mdcMttrInfo.setTheDate(month);
+ // 鏃ュ巻鏃堕棿
+ mdcMttrInfo.setCalendarLong(new BigDecimal(calendarLong));
+ // 鎬绘晠闅滃仠鏈烘椂闂�
+ BigDecimal totalDownLong = this.baseMapper.findTotalDownLong(month);
+ if (totalDownLong != null) {
+ mdcMttrInfo.setTotalDownLong(totalDownLong);
+ }
+ // 鎬绘晠闅滄鏁�
+ Integer totalDownCount = this.baseMapper.findTotalDownCount(month);
+ if (totalDownLong != null) {
+ mdcMttrInfo.setTotalDownCount(totalDownCount);
+ }
+ // MTBF
+ if (mdcMttrInfo.getTotalDownCount() != 0) {
+ BigDecimal mtbf = (mdcMttrInfo.getCalendarLong().subtract(mdcMttrInfo.getTotalDownLong())).divide(new BigDecimal(mdcMttrInfo.getTotalDownCount()), 4, RoundingMode.HALF_UP);
+ mdcMttrInfo.setMtbf(mtbf);
+ }
+ mmi.add(mdcMttrInfo);
+ }
+ mdcMttrInfoService.saveBatch(mmi);
+ }
+ }
}
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcMttrInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcMttrInfoServiceImpl.java
new file mode 100644
index 0000000..883f3d9
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcMttrInfoServiceImpl.java
@@ -0,0 +1,142 @@
+package org.jeecg.modules.mdc.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.mdc.entity.MdcMttrInfo;
+import org.jeecg.modules.mdc.entity.MdcOeeInfo;
+import org.jeecg.modules.mdc.mapper.MdcMttrInfoMapper;
+import org.jeecg.modules.mdc.service.IMdcEquipmentService;
+import org.jeecg.modules.mdc.service.IMdcMttrInfoService;
+import org.jeecg.modules.mdc.vo.MdcMttrInfoVo;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Lius
+ * @date 2025/2/18 13:52
+ */
+@Service
+public class MdcMttrInfoServiceImpl extends ServiceImpl<MdcMttrInfoMapper, MdcMttrInfo> implements IMdcMttrInfoService {
+
+ @Resource
+ private IMdcEquipmentService mdcEquipmentService;
+
+ /**
+ * 鍒嗛〉鍒楄〃
+ *
+ * @param userId
+ * @param page
+ * @param mdcMttrInfoVo
+ * @param req
+ * @return
+ */
+ @Override
+ public IPage<MdcMttrInfo> pageList(String userId, Page<MdcMttrInfo> page, MdcMttrInfoVo mdcMttrInfoVo, HttpServletRequest req) {
+ List<String> equipmentIds = new ArrayList<>();
+ if (StringUtils.isNotEmpty(mdcMttrInfoVo.getParentId()) && StringUtils.isEmpty(mdcMttrInfoVo.getEquipmentId())) {
+ if ("2".equals(mdcMttrInfoVo.getTypeTree())) {
+ //閮ㄩ棬灞傜骇
+ equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcMttrInfoVo.getParentId());
+ } else {
+ //浜х嚎灞傜骇
+ equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcMttrInfoVo.getParentId());
+ }
+ } else if (StringUtils.isNotEmpty(mdcMttrInfoVo.getEquipmentId())) {
+ //鍗曞彴璁惧淇℃伅
+ mdcMttrInfoVo.setEquipmentIdList(Collections.singletonList(mdcMttrInfoVo.getEquipmentId()));
+ } else {
+ //鏌ヨ鐢ㄦ埛鎷ユ湁鐨勬墍鏈夎澶囦俊鎭�
+ if ("2".equals(mdcMttrInfoVo.getTypeTree())) {
+ //閮ㄩ棬灞傜骇
+ equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null);
+ } else {
+ //浜х嚎灞傜骇
+ equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null);
+ }
+ }
+
+ if (mdcMttrInfoVo.getEquipmentIdList() == null || mdcMttrInfoVo.getEquipmentIdList().isEmpty()) {
+ mdcMttrInfoVo.setEquipmentIdList(equipmentIds);
+ }
+
+ if (mdcMttrInfoVo.getEquipmentIdList() == null || mdcMttrInfoVo.getEquipmentIdList().isEmpty()) {
+ return null;
+ }
+ return this.baseMapper.pageList(page, mdcMttrInfoVo);
+ }
+
+ /**
+ * 瀵煎嚭
+ *
+ * @param userId
+ * @param mdcMttrInfoVo
+ * @return
+ */
+ @Override
+ public ModelAndView exportXls(String userId, MdcMttrInfoVo mdcMttrInfoVo) {
+ LambdaQueryWrapper<MdcMttrInfo> queryWrapper = new LambdaQueryWrapper<>();
+ List<String> equipmentIds = new ArrayList<>();
+ if (StringUtils.isNotEmpty(mdcMttrInfoVo.getParentId()) && StringUtils.isEmpty(mdcMttrInfoVo.getEquipmentId())) {
+ if ("2".equals(mdcMttrInfoVo.getTypeTree())) {
+ //閮ㄩ棬灞傜骇
+ equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcMttrInfoVo.getParentId());
+ } else {
+ //浜х嚎灞傜骇
+ equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcMttrInfoVo.getParentId());
+ }
+ } else if (StringUtils.isNotEmpty(mdcMttrInfoVo.getEquipmentId())) {
+ //鍗曞彴璁惧淇℃伅
+ mdcMttrInfoVo.setEquipmentIdList(Collections.singletonList(mdcMttrInfoVo.getEquipmentId()));
+ } else {
+ //鏌ヨ鐢ㄦ埛鎷ユ湁鐨勬墍鏈夎澶囦俊鎭�
+ if ("2".equals(mdcMttrInfoVo.getTypeTree())) {
+ //閮ㄩ棬灞傜骇
+ equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null);
+ } else {
+ //浜х嚎灞傜骇
+ equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null);
+ }
+ }
+
+ if (mdcMttrInfoVo.getEquipmentIdList() == null || mdcMttrInfoVo.getEquipmentIdList().isEmpty()) {
+ mdcMttrInfoVo.setEquipmentIdList(equipmentIds);
+ }
+
+ if (mdcMttrInfoVo.getEquipmentIdList() == null || mdcMttrInfoVo.getEquipmentIdList().isEmpty()) {
+ return null;
+ } else {
+ queryWrapper.in(MdcMttrInfo::getEquipmentId, mdcMttrInfoVo.getEquipmentIdList());
+ }
+ if (StringUtils.isNotEmpty(mdcMttrInfoVo.getEquipmentId())) {
+ queryWrapper.eq(MdcMttrInfo::getEquipmentId, mdcMttrInfoVo.getEquipmentId());
+ }
+ if (StringUtils.isNotEmpty(mdcMttrInfoVo.getStartTime()) && StringUtils.isNotEmpty(mdcMttrInfoVo.getEndTime())) {
+ queryWrapper.between(MdcMttrInfo::getTheDate, mdcMttrInfoVo.getStartTime(), mdcMttrInfoVo.getEndTime());
+ }
+ queryWrapper.orderByDesc(MdcMttrInfo::getTheDate).orderByDesc(MdcMttrInfo::getEquipmentId);
+ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+ List<MdcMttrInfo> mdcMttrInfos = this.baseMapper.selectList(queryWrapper);
+ // 瀵煎嚭鏂囦欢鍚嶇О
+ mv.addObject(NormalExcelConstants.FILE_NAME, "璁惧MTTR琛�");
+ mv.addObject(NormalExcelConstants.CLASS, MdcMttrInfo.class);
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+ mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("璁惧MTTR琛ㄦ暟鎹�", "瀵煎嚭浜�:" + user.getRealname(), "璁惧MTTR"));
+ //update-end---author:wangshuai ---date:20211227 for锛歔JTC-116]瀵煎嚭浜哄啓姝讳簡------------
+ mv.addObject(NormalExcelConstants.DATA_LIST, mdcMttrInfos);
+ return mv;
+ }
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcRepairInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcRepairInfoServiceImpl.java
index 2b8efde..ddb71d0 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcRepairInfoServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcRepairInfoServiceImpl.java
@@ -7,10 +7,12 @@
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.mdc.entity.MdcDownTime;
+import org.jeecg.modules.mdc.entity.MdcEquipment;
+import org.jeecg.modules.mdc.entity.MdcMttrInfo;
import org.jeecg.modules.mdc.entity.MdcRepairInfo;
import org.jeecg.modules.mdc.mapper.MdcRepairInfoMapper;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
+import org.jeecg.modules.mdc.service.IMdcMttrInfoService;
import org.jeecg.modules.mdc.service.IMdcRepairInfoService;
import org.jeecg.modules.mdc.vo.MdcRepairInfoVo;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -22,6 +24,8 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -36,6 +40,9 @@
@Resource
private IMdcEquipmentService mdcEquipmentService;
+
+ @Resource
+ private IMdcMttrInfoService mdcMttrInfoService;
/**
* 鍒嗛〉鍒楄〃
@@ -169,6 +176,48 @@
*/
@Override
public void computeMttr(String month) {
-
+ /*
+ 璁惧骞冲潎淇悊鏃堕棿(MTTR) = 鎬荤淮淇椂闂� / 鎬荤淮淇鏁�
+ */
+ List<MdcMttrInfo> mdcMttrInfos = mdcMttrInfoService.list(new LambdaQueryWrapper<MdcMttrInfo>().eq(MdcMttrInfo::getTheDate, month));
+ if (mdcMttrInfos != null && !mdcMttrInfos.isEmpty()) {
+ for (MdcMttrInfo mdcMttrInfo : mdcMttrInfos) {
+ // 鎬荤淮淇椂闂�
+ BigDecimal totalRepairLong = this.baseMapper.findTotalRepairLong(month);
+ mdcMttrInfo.setTotalRepairLong(totalRepairLong);
+ // 鎬荤淮淇鏁�
+ Integer totalRepairCount = this.baseMapper.findTotalRepairCount(month);
+ mdcMttrInfo.setTotalRepairCount(totalRepairCount);
+ // MTTR
+ if (mdcMttrInfo.getTotalRepairCount() != 0) {
+ BigDecimal mttr = mdcMttrInfo.getTotalRepairLong().divide(new BigDecimal(mdcMttrInfo.getTotalDownCount()), 4, RoundingMode.HALF_UP);
+ mdcMttrInfo.setMttr(mttr);
+ }
+ }
+ mdcMttrInfoService.updateBatchById(mdcMttrInfos);
+ } else {
+ List<MdcEquipment> equipmentList = mdcEquipmentService.list();
+ if (equipmentList != null && !equipmentList.isEmpty()) {
+ List<MdcMttrInfo> mmi = new ArrayList<>();
+ for (MdcEquipment mdcEquipment : equipmentList) {
+ MdcMttrInfo mdcMttrInfo = new MdcMttrInfo();
+ mdcMttrInfo.setEquipmentId(mdcEquipment.getEquipmentId());
+ mdcMttrInfo.setTheDate(month);
+ // 鎬荤淮淇椂闂�
+ BigDecimal totalRepairLong = this.baseMapper.findTotalRepairLong(month);
+ mdcMttrInfo.setTotalRepairLong(totalRepairLong);
+ // 鎬荤淮淇鏁�
+ Integer totalRepairCount = this.baseMapper.findTotalRepairCount(month);
+ mdcMttrInfo.setTotalRepairCount(totalRepairCount);
+ // MTTR
+ if (mdcMttrInfo.getTotalRepairCount() != 0) {
+ BigDecimal mttr = mdcMttrInfo.getTotalRepairLong().divide(new BigDecimal(mdcMttrInfo.getTotalDownCount()), 4, RoundingMode.HALF_UP);
+ mdcMttrInfo.setMttr(mttr);
+ }
+ mmi.add(mdcMttrInfo);
+ }
+ mdcMttrInfoService.saveBatch(mmi);
+ }
+ }
}
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/FileUtils.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/FileUtils.java
new file mode 100644
index 0000000..f71389c
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/FileUtils.java
@@ -0,0 +1,189 @@
+package org.jeecg.modules.mdc.util;
+
+import cn.hutool.core.date.DateUtil;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * Created by YangBin on 2017/9/15.
+ */
+public class FileUtils {
+ private static final long MAX_FILE_SIZE = 10*1024*1024;
+ /**
+ * 鑾峰彇鏈嶅姟鍣ㄤ复鏃惰矾寰�
+ *
+ * @param request
+ * @return */
+ public static String serverTempPath(HttpServletRequest request) {
+ String fsep = System.getProperty("file.separator");
+ String path = request.getSession().getServletContext().getRealPath("");
+ if (path.lastIndexOf(fsep) == path.length() - 1) {
+ path += "upload" + fsep +"voucher"+ fsep ;
+ } else {
+ path += fsep + "upload" + fsep +"voucher"+ fsep ;
+ }
+ return path;
+ }
+
+ public static String serverTempPathIntactReg(HttpServletRequest request) {
+ String fsep = System.getProperty("file.separator");
+ String path = request.getSession().getServletContext().getRealPath("");
+ if (path.lastIndexOf(fsep) == path.length() - 1) {
+ path += "upload" + fsep +"log"+ fsep +"error"+ fsep ;
+ } else {
+ path += fsep + "upload" + fsep +"log"+ fsep +"error"+ fsep;
+ }
+ return path;
+ }
+
+ public static String serverTempPathProcess(HttpServletRequest request) {
+ String fsep = System.getProperty("file.separator");
+ String path = request.getSession().getServletContext().getRealPath("");
+ if (path.lastIndexOf(fsep) == path.length() - 1) {
+ path += "upload" + fsep +"process"+ fsep ;
+ } else {
+ path += fsep + "upload" + fsep +"process"+ fsep ;
+ }
+ return path;
+ }
+
+ public static String changeFileFormatKb(String flow) {
+ BigDecimal flows = new BigDecimal(flow);
+ if (flows.compareTo(new BigDecimal(0)) > 0 && flows.compareTo(new BigDecimal(1024)) < 0) {//灏忎簬1M
+ return flows.toString() + "B";
+ } else if(flows.compareTo(new BigDecimal(1024)) >= 0){
+ BigDecimal result = flows.divide(new BigDecimal(1024),2,BigDecimal.ROUND_HALF_UP);
+ return result.toString() + "KB";
+ } else {
+ return "0";
+ }
+ }
+
+
+ /**
+ * 寰楀埌椤圭洰鏍圭洰褰曚笅鐨勭粷瀵硅矾寰勶紙纾佺洏鐨勭墿鐞嗚矾寰勶級
+ * @param request
+ * @param newPath
+ * @return
+ */
+ public static String getFilePath(HttpServletRequest request, String newPath) {
+ String fsep = System.getProperty("file.separator");
+ String path = request.getSession().getServletContext().getRealPath("/upload");
+ path += fsep + newPath;
+ return path;
+ }
+
+ /**
+ * 寰楀埌椤圭洰鏍圭洰褰曚笅鐨勭浉瀵硅矾寰� 锛堢浉瀵逛簬椤圭洰涓烘牴璺緞锛�
+ * @param newPath
+ * @return
+ */
+ public static String getRelativePath(String newPath) {
+ return "/upload/" + newPath;
+ }
+
+
+ /**
+ * 鏂规硶涓�:浣跨敤 FileWriter 鍐欐枃浠�
+ * @param filepath 鏂囦欢鐩綍
+ * @param content 寰呭啓鍏ュ唴瀹�
+ * @throws IOException
+ */
+ public static void fileWriterSql(String filepath, String content) throws IOException {
+ OutputStreamWriter outputStreamWriter = null;
+ try {
+ File file = new File(filepath);
+ if (!file.exists()){
+ file.createNewFile();
+ }
+ FileOutputStream outputStream = new FileOutputStream(file);
+ if (outputStream != null){
+ outputStreamWriter = new OutputStreamWriter(outputStream, "utf-8");
+ outputStreamWriter.write(content);
+ outputStreamWriter.flush();
+ }
+ }
+ catch (IOException e) {
+ e.getMessage();
+ }
+ finally {
+ try {
+ if (outputStreamWriter != null){
+ outputStreamWriter.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /*
+ File file=new File(filepath);
+ Writer writer = new OutputStreamWriter(new FileOutputStream(file.getAbsoluteFile()), "UTF-8");
+ writer.append(content);
+ */
+ }
+
+ /**
+ * 鏂囦欢澶у皬鏅鸿兘杞崲
+ * 浼氬皢鏂囦欢澶у皬杞崲涓烘渶澶ф弧瓒冲崟浣�
+ * @param size锛堟枃浠跺ぇ灏忥紝鍗曚綅涓築锛�
+ * @return 鏂囦欢澶у皬
+ */
+ public static String formatFileSize(Long size) {
+ String sizeName = null;
+ if(1024*1024 > size && size >= 1024 ) {
+ sizeName = String.format("%.2f",size.doubleValue()/1024) + "KB";
+ }else if(1024*1024*1024 > size && size >= 1024*1024 ) {
+ sizeName = String.format("%.2f",size.doubleValue()/(1024*1024)) + "MB";
+ }else if(size >= 1024*1024*1024 ) {
+ sizeName = String.format("%.2f",size.doubleValue()/(1024*1024*1024)) + "GB";
+ }else {
+ sizeName = size.toString() + "B";
+ }
+ return sizeName;
+ }
+
+ /**
+ * 涓婁紶鏂囦欢宸ュ叿绫�
+ * @param userPic
+ * @param path
+ * @param fileName
+ * @return
+ */
+ public static boolean uploadFile(MultipartFile userPic, String path, String fileName) {
+ Long fileSize = userPic.getSize();
+ if(fileSize > MAX_FILE_SIZE) {
+ return false;
+ }
+ File targetFile = new File(path, fileName);
+ if(!targetFile.exists()){
+ targetFile.mkdirs();
+ }
+ try {
+ userPic.transferTo(targetFile);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+// /**
+// * 閲嶅懡鍚嶆枃浠跺悕 鍔犲叆鏃堕棿鎴�
+// * @param fileName
+// * @return
+// */
+// public static String newFileName(String fileName) {
+// String suffix = fileName.substring(fileName.lastIndexOf('.'));
+// String dateStr = "_"+ DateUtil.format(new Date(), DateUtil.STR_DATE_TIME_FULL);
+// String nameFile = fileName.substring(0, fileName.indexOf("."));
+// //鏂版枃浠跺悕
+// return nameFile + dateStr + suffix;
+// }
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java
index 7f495ba..57bb625 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java
@@ -22,7 +22,7 @@
SqlRunner runner = new SqlRunner(sqlSession.getConnection());
runner.run(sql);
} catch (Exception e) {
- e.printStackTrace();
+// e.printStackTrace();
throw new RuntimeException("Error executing SQL: " + sql, e);
}
}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcMttrInfoVo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcMttrInfoVo.java
new file mode 100644
index 0000000..8fd0ab0
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcMttrInfoVo.java
@@ -0,0 +1,20 @@
+package org.jeecg.modules.mdc.vo;
+
+import lombok.Data;
+import org.jeecg.modules.mdc.entity.MdcMttrInfo;
+
+import java.util.List;
+
+/**
+ * @author Lius
+ * @date 2025/2/18 13:50
+ */
+@Data
+public class MdcMttrInfoVo extends MdcMttrInfo {
+ private String startTime;
+ private String endTime;
+ private String parentId;
+ private String typeTree;
+ private List<String> equipmentIdList;
+ private String equipmentIds;
+}
diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/api/controller/SystemApiController.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/api/controller/SystemApiController.java
index 3e078e8..538f2c5 100644
--- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/api/controller/SystemApiController.java
+++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/api/controller/SystemApiController.java
@@ -867,16 +867,16 @@
String token = JwTUtil.sign(appId, pwd);
return new TokenResp("200", "璁よ瘉鎴愬姛", token);
} else {
- return new TokenResp("", "瀵嗙爜閿欒", null);
+ return new TokenResp("101", "瀵嗙爜閿欒", null);
}
} else {
- return new TokenResp("", "璐﹀彿閿欒", null);
+ return new TokenResp("101", "璐﹀彿閿欒", null);
}
}
@PostMapping(value = "/fileUpload")
public RespData uploadFiles(HttpServletRequest request) {
-
+ log.info("涓婁紶鎺ュ彛璋冪敤寮�濮�");
FileDetail fileDetail = new FileDetail();
try {
request.setCharacterEncoding("UTF-8");
@@ -940,6 +940,7 @@
e.printStackTrace();
}
}
+ log.info("涓婁紶鎺ュ彛璋冪敤缁撴潫");
return new RespData("200", "鏂囦欢涓婁紶鎴愬姛");
}
diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDepartMapper.xml b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDepartMapper.xml
index 40e5d7e..7f58a96 100644
--- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDepartMapper.xml
+++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDepartMapper.xml
@@ -73,13 +73,13 @@
and del_flag='0'
</select>
- <select id="getDepartTreeByParentId" parameterType="String" resultType="org.jeecg.common.system.vo.SelectTreeModel">
- select
- id as "key",
- depart_name as "title",
- parent_id as parentId
- from sys_depart
- where parent_id = #{parentId}
- and del_flag='0'
- </select>
+<!-- <select id="getDepartTreeByParentId" parameterType="String" resultType="org.jeecg.common.system.vo.SelectTreeModel">-->
+<!-- select-->
+<!-- id as "key",-->
+<!-- depart_name as "title",-->
+<!-- parent_id as parentId-->
+<!-- from sys_depart-->
+<!-- where parent_id = #{parentId}-->
+<!-- and del_flag='0'-->
+<!-- </select>-->
</mapper>
\ No newline at end of file
diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FileUtils.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FileUtils.java
index e15701c..3a9b2e2 100644
--- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FileUtils.java
+++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FileUtils.java
@@ -110,7 +110,7 @@
}
FileOutputStream outputStream = new FileOutputStream(file);
if (outputStream != null) {
- outputStreamWriter = new OutputStreamWriter(outputStream, "utf-8");
+ outputStreamWriter = new OutputStreamWriter(outputStream, "UTF-8");
outputStreamWriter.write(content);
outputStreamWriter.flush();
}
--
Gitblit v1.9.3