Переглянути джерело

改了一堆乱七八糟的东西

dongjh 4 місяців тому
батько
коміт
20ed4d5dc8
31 змінених файлів з 645 додано та 99 видалено
  1. 6 6
      jeecg-boot-base-core/src/main/java/org/jeecg/common/util/IpUtils.java
  2. 1 1
      module_base/src/main/java/org/jeecg/modules/elecfeeBase/controller/ElecfeeBaseController.java
  3. 1 1
      module_base/src/main/java/org/jeecg/modules/elecfeeRatio/controller/ElecfeeRatioController.java
  4. 7 7
      module_base/src/main/java/org/jeecg/modules/sysAutoCodePart/controller/SysAutoCodePartController.java
  5. 7 7
      module_base/src/main/java/org/jeecg/modules/sysAutoCodeResult/controller/SysAutoCodeResultController.java
  6. 7 7
      module_base/src/main/java/org/jeecg/modules/sysAutoCodeRule/controller/SysAutoCodeRuleController.java
  7. 7 7
      module_base/src/main/java/org/jeecg/modules/sysUploadFile/controller/SysUploadFileController.java
  8. 38 9
      module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheck/controller/CmmsSpotcheckController.java
  9. 35 14
      module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/controller/CmmsSpotcheckTitemController.java
  10. 25 16
      module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/entity/CmmsSpotcheckTitem.java
  11. 33 0
      module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/entity/CmmsSpotcheckTitemVo.java
  12. 7 0
      module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/mapper/CmmsSpotcheckTitemMapper.java
  13. 57 1
      module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/mapper/xml/CmmsSpotcheckTitemMapper.xml
  14. 31 1
      module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/service/ICmmsSpotcheckTitemService.java
  15. 75 1
      module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/service/impl/CmmsSpotcheckTitemServiceImpl.java
  16. 40 4
      module_ems/src/main/java/org/jeecg/modules/kafka/consumer/TestConsumer.java
  17. 1 1
      module_ems/src/main/java/org/jeecg/modules/kafka/controller/TestController.java
  18. 2 0
      module_tpm/src/main/java/org/jeecg/modules/Statistics/entity/Statistics.java
  19. 10 0
      module_tpm/src/main/java/org/jeecg/modules/Statistics/mapper/StatisticsMapper.java
  20. 17 0
      module_tpm/src/main/java/org/jeecg/modules/Statistics/mapper/xml/StatisticsMapper.xml
  21. 3 0
      module_tpm/src/main/java/org/jeecg/modules/Statistics/vo/StatisticsVo.java
  22. 30 11
      module_tpm/src/main/java/org/jeecg/modules/collectdata/controller/CollectdataController.java
  23. 2 1
      module_tpm/src/main/java/org/jeecg/modules/collectdata/entity/Collectdata.java
  24. 37 0
      module_tpm/src/main/java/org/jeecg/modules/collectdata/entity/CollectdataVo.java
  25. 25 0
      module_tpm/src/main/java/org/jeecg/modules/collectdata/service/ICollectdataService.java
  26. 74 0
      module_tpm/src/main/java/org/jeecg/modules/collectdata/service/impl/CollectdataServiceImpl.java
  27. 8 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/mapper/EquipmentHealthSectionMapper.java
  28. 11 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/mapper/xml/EquipmentHealthSectionMapper.xml
  29. 1 0
      module_tpm/src/main/java/org/jeecg/modules/equipmentStatus/service/impl/EquipmentStatusServiceImpl.java
  30. 4 2
      module_tpm/src/main/java/org/jeecg/modules/healthStatistics/controller/HealthStatisticsController.java
  31. 43 2
      module_tpm/src/main/java/org/jeecg/modules/healthStatistics/service/Impl/HealthStatisticsServiceImpl.java

+ 6 - 6
jeecg-boot-base-core/src/main/java/org/jeecg/common/util/IpUtils.java

@@ -9,7 +9,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * IP地址
- * 
+ *
  * @Author scott
  * @email jeecgos@163.com
  * @Date 2019年01月14日
@@ -19,7 +19,7 @@ public class IpUtils {
 
 	/**
 	 * 获取IP地址
-	 * 
+	 *
 	 * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
 	 * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
 	 */
@@ -27,7 +27,7 @@ public class IpUtils {
     	String ip = null;
         try {
             ip = request.getHeader("x-forwarded-for");
-            if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
+            if ( StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
                 ip = request.getHeader("Proxy-Client-IP");
             }
             if (StringUtils.isEmpty(ip) || ip.length() == 0 ||CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
@@ -45,15 +45,15 @@ public class IpUtils {
         } catch (Exception e) {
         	logger.error("IPUtils ERROR ", e);
         }
-        
+
 //        //使用代理,则获取第一个IP地址
 //        if(StringUtils.isEmpty(ip) && ip.length() > 15) {
 //			if(ip.indexOf(",") > 0) {
 //				ip = ip.substring(0, ip.indexOf(","));
 //			}
 //		}
-        
+
         return ip;
     }
-	
+
 }

+ 1 - 1
module_base/src/main/java/org/jeecg/modules/elecfeeBase/controller/ElecfeeBaseController.java

@@ -42,7 +42,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
  * @Date:   2024-01-23
  * @Version: V1.0
  */
-@Api(tags="基本电费")
+//@Api(tags="基本电费")
 @RestController
 @RequestMapping("/elecfeeBase/elecfeeBase")
 @Slf4j

+ 1 - 1
module_base/src/main/java/org/jeecg/modules/elecfeeRatio/controller/ElecfeeRatioController.java

@@ -42,7 +42,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
  * @Date:   2024-01-23
  * @Version: V1.0
  */
-@Api(tags="力调系数")
+//@Api(tags="力调系数")
 @RestController
 @RequestMapping("/elecfeeRatio/elecfeeRatio")
 @Slf4j

+ 7 - 7
module_base/src/main/java/org/jeecg/modules/sysAutoCodePart/controller/SysAutoCodePartController.java

@@ -42,14 +42,14 @@ import org.jeecg.common.aspect.annotation.AutoLog;
  * @Date:   2024-01-10
  * @Version: V1.0
  */
-@Api(tags="ems_sys_auto_code_part")
+//@Api(tags="ems_sys_auto_code_part")
 @RestController
 @RequestMapping("/sysAutoCodePart/sysAutoCodePart")
 @Slf4j
 public class SysAutoCodePartController extends JeecgController<SysAutoCodePart, ISysAutoCodePartService> {
 	@Autowired
 	private ISysAutoCodePartService sysAutoCodePartService;
-	
+
 	/**
 	 * 分页列表查询
 	 *
@@ -71,7 +71,7 @@ public class SysAutoCodePartController extends JeecgController<SysAutoCodePart,
 		IPage<SysAutoCodePart> pageList = sysAutoCodePartService.page(page, queryWrapper);
 		return Result.OK(pageList);
 	}
-	
+
 	/**
 	 *   添加
 	 *
@@ -86,7 +86,7 @@ public class SysAutoCodePartController extends JeecgController<SysAutoCodePart,
 		sysAutoCodePartService.save(sysAutoCodePart);
 		return Result.OK("添加成功!");
 	}
-	
+
 	/**
 	 *  编辑
 	 *
@@ -101,7 +101,7 @@ public class SysAutoCodePartController extends JeecgController<SysAutoCodePart,
 		sysAutoCodePartService.updateById(sysAutoCodePart);
 		return Result.OK("编辑成功!");
 	}
-	
+
 	/**
 	 *   通过id删除
 	 *
@@ -116,7 +116,7 @@ public class SysAutoCodePartController extends JeecgController<SysAutoCodePart,
 		sysAutoCodePartService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
+
 	/**
 	 *  批量删除
 	 *
@@ -131,7 +131,7 @@ public class SysAutoCodePartController extends JeecgController<SysAutoCodePart,
 		this.sysAutoCodePartService.removeByIds(Arrays.asList(ids.split(",")));
 		return Result.OK("批量删除成功!");
 	}
-	
+
 	/**
 	 * 通过id查询
 	 *

+ 7 - 7
module_base/src/main/java/org/jeecg/modules/sysAutoCodeResult/controller/SysAutoCodeResultController.java

@@ -42,14 +42,14 @@ import org.jeecg.common.aspect.annotation.AutoLog;
  * @Date:   2024-01-10
  * @Version: V1.0
  */
-@Api(tags="ems_sys_auto_code_result")
+//@Api(tags="ems_sys_auto_code_result")
 @RestController
 @RequestMapping("/sysAutoCodeResult/sysAutoCodeResult")
 @Slf4j
 public class SysAutoCodeResultController extends JeecgController<SysAutoCodeResult, ISysAutoCodeResultService> {
 	@Autowired
 	private ISysAutoCodeResultService sysAutoCodeResultService;
-	
+
 	/**
 	 * 分页列表查询
 	 *
@@ -71,7 +71,7 @@ public class SysAutoCodeResultController extends JeecgController<SysAutoCodeResu
 		IPage<SysAutoCodeResult> pageList = sysAutoCodeResultService.page(page, queryWrapper);
 		return Result.OK(pageList);
 	}
-	
+
 	/**
 	 *   添加
 	 *
@@ -86,7 +86,7 @@ public class SysAutoCodeResultController extends JeecgController<SysAutoCodeResu
 		sysAutoCodeResultService.save(sysAutoCodeResult);
 		return Result.OK("添加成功!");
 	}
-	
+
 	/**
 	 *  编辑
 	 *
@@ -101,7 +101,7 @@ public class SysAutoCodeResultController extends JeecgController<SysAutoCodeResu
 		sysAutoCodeResultService.updateById(sysAutoCodeResult);
 		return Result.OK("编辑成功!");
 	}
-	
+
 	/**
 	 *   通过id删除
 	 *
@@ -116,7 +116,7 @@ public class SysAutoCodeResultController extends JeecgController<SysAutoCodeResu
 		sysAutoCodeResultService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
+
 	/**
 	 *  批量删除
 	 *
@@ -131,7 +131,7 @@ public class SysAutoCodeResultController extends JeecgController<SysAutoCodeResu
 		this.sysAutoCodeResultService.removeByIds(Arrays.asList(ids.split(",")));
 		return Result.OK("批量删除成功!");
 	}
-	
+
 	/**
 	 * 通过id查询
 	 *

+ 7 - 7
module_base/src/main/java/org/jeecg/modules/sysAutoCodeRule/controller/SysAutoCodeRuleController.java

@@ -42,14 +42,14 @@ import org.jeecg.common.aspect.annotation.AutoLog;
  * @Date:   2024-01-10
  * @Version: V1.0
  */
-@Api(tags="ems_sys_auto_code_rule")
+//@Api(tags="ems_sys_auto_code_rule")
 @RestController
 @RequestMapping("/sysAutoCodeRule/sysAutoCodeRule")
 @Slf4j
 public class SysAutoCodeRuleController extends JeecgController<SysAutoCodeRule, ISysAutoCodeRuleService> {
 	@Autowired
 	private ISysAutoCodeRuleService sysAutoCodeRuleService;
-	
+
 	/**
 	 * 分页列表查询
 	 *
@@ -71,7 +71,7 @@ public class SysAutoCodeRuleController extends JeecgController<SysAutoCodeRule,
 		IPage<SysAutoCodeRule> pageList = sysAutoCodeRuleService.page(page, queryWrapper);
 		return Result.OK(pageList);
 	}
-	
+
 	/**
 	 *   添加
 	 *
@@ -86,7 +86,7 @@ public class SysAutoCodeRuleController extends JeecgController<SysAutoCodeRule,
 		sysAutoCodeRuleService.save(sysAutoCodeRule);
 		return Result.OK("添加成功!");
 	}
-	
+
 	/**
 	 *  编辑
 	 *
@@ -101,7 +101,7 @@ public class SysAutoCodeRuleController extends JeecgController<SysAutoCodeRule,
 		sysAutoCodeRuleService.updateById(sysAutoCodeRule);
 		return Result.OK("编辑成功!");
 	}
-	
+
 	/**
 	 *   通过id删除
 	 *
@@ -116,7 +116,7 @@ public class SysAutoCodeRuleController extends JeecgController<SysAutoCodeRule,
 		sysAutoCodeRuleService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
+
 	/**
 	 *  批量删除
 	 *
@@ -131,7 +131,7 @@ public class SysAutoCodeRuleController extends JeecgController<SysAutoCodeRule,
 		this.sysAutoCodeRuleService.removeByIds(Arrays.asList(ids.split(",")));
 		return Result.OK("批量删除成功!");
 	}
-	
+
 	/**
 	 * 通过id查询
 	 *

+ 7 - 7
module_base/src/main/java/org/jeecg/modules/sysUploadFile/controller/SysUploadFileController.java

@@ -42,14 +42,14 @@ import org.jeecg.common.aspect.annotation.AutoLog;
  * @Date:   2024-01-09
  * @Version: V1.0
  */
-@Api(tags="ems_sys_upload_file")
+//@Api(tags="ems_sys_upload_file")
 @RestController
 @RequestMapping("/sysUploadFile/sysUploadFile")
 @Slf4j
 public class SysUploadFileController extends JeecgController<SysUploadFile, ISysUploadFileService> {
 	@Autowired
 	private ISysUploadFileService sysUploadFileService;
-	
+
 	/**
 	 * 分页列表查询
 	 *
@@ -71,7 +71,7 @@ public class SysUploadFileController extends JeecgController<SysUploadFile, ISys
 		IPage<SysUploadFile> pageList = sysUploadFileService.page(page, queryWrapper);
 		return Result.OK(pageList);
 	}
-	
+
 	/**
 	 *   添加
 	 *
@@ -86,7 +86,7 @@ public class SysUploadFileController extends JeecgController<SysUploadFile, ISys
 		sysUploadFileService.save(sysUploadFile);
 		return Result.OK("添加成功!");
 	}
-	
+
 	/**
 	 *  编辑
 	 *
@@ -101,7 +101,7 @@ public class SysUploadFileController extends JeecgController<SysUploadFile, ISys
 		sysUploadFileService.updateById(sysUploadFile);
 		return Result.OK("编辑成功!");
 	}
-	
+
 	/**
 	 *   通过id删除
 	 *
@@ -116,7 +116,7 @@ public class SysUploadFileController extends JeecgController<SysUploadFile, ISys
 		sysUploadFileService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
+
 	/**
 	 *  批量删除
 	 *
@@ -131,7 +131,7 @@ public class SysUploadFileController extends JeecgController<SysUploadFile, ISys
 		this.sysUploadFileService.removeByIds(Arrays.asList(ids.split(",")));
 		return Result.OK("批量删除成功!");
 	}
-	
+
 	/**
 	 * 通过id查询
 	 *

+ 38 - 9
module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheck/controller/CmmsSpotcheckController.java

@@ -11,6 +11,8 @@ 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.query.QueryGenerator;
+import org.jeecg.common.system.util.JwtUtil;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.cmmsSpotcheck.convert.CmmsSpotcheckConvert;
 import org.jeecg.modules.cmmsSpotcheck.dto.CmmsSpotcheckAddDTO;
 import org.jeecg.modules.cmmsSpotcheck.entity.CmmsSpotcheck;
@@ -112,14 +114,26 @@ public class CmmsSpotcheckController extends JeecgController<CmmsSpotcheck, ICmm
 	@ApiOperation(value="设备点检-添加", notes="设备点检-添加")
 	//@RequiresPermissions("org.jeecg.modules:ems_cmms_spotcheck:add")
 	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody CmmsSpotcheckAddDTO dto) {
+	public Result<String> add(@RequestBody CmmsSpotcheckAddDTO dto, HttpServletRequest req) {
 		CmmsSpotcheck cmmsSpotcheck = CmmsSpotcheckConvert.INSTANCE.convert(dto);
 		cmmsSpotcheckService.save(cmmsSpotcheck);
+		String userName = JwtUtil.getUserNameByToken(req);
 
 		/** 设备点检-点检项信息 */
 		if(dto.getCmmsSpotcheckTitemList()!=null && dto.getCmmsSpotcheckTitemList().size()>0){
-			List<CmmsSpotcheckTitem> titemList1 = dto.getCmmsSpotcheckTitemList().parallelStream().map(i->i.setSpotcheckid(cmmsSpotcheck.getId())).collect(Collectors.toList());
-			titemService.saveBatch(titemList1);
+//			List<CmmsSpotcheckTitem> titemList1 = dto.getCmmsSpotcheckTitemList().parallelStream().map(i->(i.setSpotcheckid(cmmsSpotcheck.getId()))).collect(Collectors.toList());
+			if (dto.getCmmsSpotcheckTitemList() != null && dto.getCmmsSpotcheckTitemList().size() > 0) {
+				for (int i = 0; i < dto.getCmmsSpotcheckTitemList().size(); i++) {
+					dto.getCmmsSpotcheckTitemList().get(i).setSpotcheckid(cmmsSpotcheck.getId());
+
+					//如果点检结果为异常,将异常状态改为"0"待处理
+					if ("1".equals(dto.getCmmsSpotcheckTitemList().get(i).getIresult())) {
+						dto.getCmmsSpotcheckTitemList().get(i).setUnusualstatus("0");
+						dto.getCmmsSpotcheckTitemList().get(i).setHandleuser(userName);
+					}
+				}
+				titemService.saveBatch(dto.getCmmsSpotcheckTitemList());
+			}
 		}
 		/** 图片 */
 		if(dto.getFiles()!=null && dto.getFiles().size()>0){
@@ -140,19 +154,34 @@ public class CmmsSpotcheckController extends JeecgController<CmmsSpotcheck, ICmm
 	@ApiOperation(value="设备点检-编辑", notes="设备点检-编辑")
 	//@RequiresPermissions("org.jeecg.modules:ems_cmms_spotcheck:edit")
 	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody CmmsSpotcheckAddDTO dto) {
+	public Result<String> edit(@RequestBody CmmsSpotcheckAddDTO dto, HttpServletRequest req) {
 		CmmsSpotcheck cmmsSpotcheck = CmmsSpotcheckConvert.INSTANCE.convert(dto);
+		String userName = JwtUtil.getUserNameByToken(req);
+
+		// 修改时,设备名称不换,所以点检项不换,不需要删除
+//		LambdaQueryWrapper<CmmsSpotcheckTitem> titemLambdaQueryWrapper = new LambdaQueryWrapper<>();
+//		titemLambdaQueryWrapper.eq(CmmsSpotcheckTitem::getSpotcheckid,dto.getId());
+//		titemService.remove(titemLambdaQueryWrapper);
 
-		LambdaQueryWrapper<CmmsSpotcheckTitem> titemLambdaQueryWrapper = new LambdaQueryWrapper<>();
-		titemLambdaQueryWrapper.eq(CmmsSpotcheckTitem::getSpotcheckid,dto.getId());
-		titemService.remove(titemLambdaQueryWrapper);
 		LambdaQueryWrapper<SysUploadFile> uploadFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
 		uploadFileLambdaQueryWrapper.eq(SysUploadFile::getRelid,dto.getId());
 		sysUploadFileService.remove(uploadFileLambdaQueryWrapper);
 
 		if(dto.getCmmsSpotcheckTitemList()!=null && dto.getCmmsSpotcheckTitemList().size()>0){
-			List<CmmsSpotcheckTitem> titemList1 = dto.getCmmsSpotcheckTitemList().parallelStream().map(i->i.setSpotcheckid(cmmsSpotcheck.getId())).collect(Collectors.toList());
-			titemService.saveBatch(titemList1);
+//			List<CmmsSpotcheckTitem> titemList1 = dto.getCmmsSpotcheckTitemList().parallelStream().map(i->i.setSpotcheckid(cmmsSpotcheck.getId())).collect(Collectors.toList());
+			if (dto.getCmmsSpotcheckTitemList() != null && dto.getCmmsSpotcheckTitemList().size() > 0) {
+				for (int i = 0; i < dto.getCmmsSpotcheckTitemList().size(); i++) {
+					dto.getCmmsSpotcheckTitemList().get(i).setSpotcheckid(cmmsSpotcheck.getId());
+
+					//如果点检结果为异常,将异常状态改为"0"待处理
+					if ("1".equals(dto.getCmmsSpotcheckTitemList().get(i).getIresult())) {
+						dto.getCmmsSpotcheckTitemList().get(i).setUnusualstatus("0");
+						dto.getCmmsSpotcheckTitemList().get(i).setHandleuser(userName);
+						dto.getCmmsSpotcheckTitemList().get(i).setItime(DateUtils.getDate());
+					}
+				}
+				titemService.updateBatchById(dto.getCmmsSpotcheckTitemList());
+			}
 		}
 		if(dto.getFiles()!=null && dto.getFiles().size()>0){
 			List<SysUploadFile> files1 = dto.getFiles().stream().map(i->i.setRelid(cmmsSpotcheck.getId())).collect(Collectors.toList());

+ 35 - 14
module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/controller/CmmsSpotcheckTitemController.java

@@ -12,7 +12,9 @@ import javax.servlet.http.HttpServletResponse;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.cmmsInspectTcontentItem.entity.CmmsInspectTcontentItem;
 import org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitem;
+import org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitemVo;
 import org.jeecg.modules.cmmsSpotcheckTitem.service.ICmmsSpotcheckTitemService;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -49,7 +51,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 public class CmmsSpotcheckTitemController extends JeecgController<CmmsSpotcheckTitem, ICmmsSpotcheckTitemService> {
 	@Autowired
 	private ICmmsSpotcheckTitemService cmmsSpotcheckTitemService;
-	
+
 	/**
 	 * 分页列表查询
 	 *
@@ -62,16 +64,17 @@ public class CmmsSpotcheckTitemController extends JeecgController<CmmsSpotcheckT
 	//@AutoLog(value = "设备点检-点检项-分页列表查询")
 	@ApiOperation(value="设备点检-点检项-分页列表查询", notes="设备点检-点检项-分页列表查询")
 	@GetMapping(value = "/list")
-	public Result<IPage<CmmsSpotcheckTitem>> queryPageList(CmmsSpotcheckTitem cmmsSpotcheckTitem,
-								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-								   HttpServletRequest req) {
-		QueryWrapper<CmmsSpotcheckTitem> queryWrapper = QueryGenerator.initQueryWrapper(cmmsSpotcheckTitem, req.getParameterMap());
-		Page<CmmsSpotcheckTitem> page = new Page<CmmsSpotcheckTitem>(pageNo, pageSize);
-		IPage<CmmsSpotcheckTitem> pageList = cmmsSpotcheckTitemService.page(page, queryWrapper);
-		return Result.OK(pageList);
+	public Result<IPage<CmmsSpotcheckTitemVo>> queryPageList(CmmsSpotcheckTitemVo cmmsSpotcheckTitem,
+							 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+							 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															 HttpServletRequest req) {
+		QueryWrapper<CmmsSpotcheckTitemVo> queryWrapper = QueryGenerator.initQueryWrapper(cmmsSpotcheckTitem, req.getParameterMap());
+		Page<CmmsSpotcheckTitemVo> page = new Page<CmmsSpotcheckTitemVo>(pageNo, pageSize);
+		List pageList = cmmsSpotcheckTitemService.getItemList(page, cmmsSpotcheckTitem);
+		page.setRecords(pageList);
+		return Result.OK(page);
 	}
-	
+
 	/**
 	 *   添加
 	 *
@@ -86,7 +89,7 @@ public class CmmsSpotcheckTitemController extends JeecgController<CmmsSpotcheckT
 		cmmsSpotcheckTitemService.save(cmmsSpotcheckTitem);
 		return Result.OK("添加成功!");
 	}
-	
+
 	/**
 	 *  编辑
 	 *
@@ -101,7 +104,7 @@ public class CmmsSpotcheckTitemController extends JeecgController<CmmsSpotcheckT
 		cmmsSpotcheckTitemService.updateById(cmmsSpotcheckTitem);
 		return Result.OK("编辑成功!");
 	}
-	
+
 	/**
 	 *   通过id删除
 	 *
@@ -116,7 +119,7 @@ public class CmmsSpotcheckTitemController extends JeecgController<CmmsSpotcheckT
 		cmmsSpotcheckTitemService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
+
 	/**
 	 *  批量删除
 	 *
@@ -131,7 +134,7 @@ public class CmmsSpotcheckTitemController extends JeecgController<CmmsSpotcheckT
 		this.cmmsSpotcheckTitemService.removeByIds(Arrays.asList(ids.split(",")));
 		return Result.OK("批量删除成功!");
 	}
-	
+
 	/**
 	 * 通过id查询
 	 *
@@ -174,4 +177,22 @@ public class CmmsSpotcheckTitemController extends JeecgController<CmmsSpotcheckT
         return super.importExcel(request, response, CmmsSpotcheckTitem.class);
     }
 
+	 /**
+	  *   author: dzc
+	  *   version: 1.0
+	  *   des: 异常项目查询 确认
+	  *   date: 2024/1/26
+	  */
+	 @AutoLog(value = "设备点检-异常点检查询-确认")
+	 @ApiOperation(value="设备点检-异常点检查询-确认", notes="设备点检-异常点检查询-确认")
+	 //@RequiresPermissions("org.jeecg.modules:cmms_inspect_tcontent_item:add")
+	 @PostMapping(value = "/confirm")
+	 public Result<String> confirm(@RequestBody CmmsSpotcheckTitem cmmsSpotcheckTitem, HttpServletRequest req) {
+		 boolean b = cmmsSpotcheckTitemService.confirm(cmmsSpotcheckTitem, req);
+		 if (b) {
+			 return Result.OK("操作成功!");
+		 }
+		 return Result.error("操作失败!");
+	 }
+
 }

+ 25 - 16
module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/entity/CmmsSpotcheckTitem.java

@@ -117,24 +117,33 @@ public class CmmsSpotcheckTitem implements Serializable {
 	/**异常状态:0待处理、1已确认、2已报修*/
 	@Excel(name = "异常状态:0待处理、1已确认、2已报修", width = 15)
     @ApiModelProperty(value = "异常状态:0待处理、1已确认、2已报修")
+    @Dict(dicCode = "abnormalItems_status")
     private java.lang.String unusualstatus;
-	/**创建人*/
-    @ApiModelProperty(value = "创建人")
-    private java.lang.String createBy;
-	/**创建日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
-    @ApiModelProperty(value = "创建日期")
-    private java.util.Date createTime;
-	/**更新人*/
-    @ApiModelProperty(value = "更新人")
-    private java.lang.String updateBy;
-	/**更新日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    /**确认事由*/
+    @Excel(name = "确认事由", width = 15)
+    @ApiModelProperty(value = "确认事由")
+    private java.lang.String confirmcontent;
+    /**确认人*/
+    @Excel(name = "确认人", width = 15)
+    @ApiModelProperty(value = "确认人")
+    private java.lang.String confirmuser;
+    /**确认时间*/
+    @Excel(name = "确认时间", width = 15, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "确认时间")
+    private java.util.Date confirmtime;
+    /**转报修人*/
+    @Excel(name = "转报修人", width = 15)
+    @ApiModelProperty(value = "转报修人")
+    private java.lang.String reportuser;
+    /**转报修时间*/
+    @Excel(name = "转报修时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
-    @ApiModelProperty(value = "更新日期")
-    private java.util.Date updateTime;
-	/**所属部门*/
+    @ApiModelProperty(value = "转报修时间")
+    private java.util.Date reporttime;
+    /**所属部门*/
     @ApiModelProperty(value = "所属部门")
     private java.lang.String sysOrgCode;
 }

+ 33 - 0
module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/entity/CmmsSpotcheckTitemVo.java

@@ -0,0 +1,33 @@
+package org.jeecg.modules.cmmsSpotcheckTitem.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+@Data
+public class CmmsSpotcheckTitemVo extends CmmsSpotcheckTitem {
+
+    /**设备id*/
+    @Excel(name = "设备id")
+    @ApiModelProperty(value = "设备id")
+    private java.lang.String equipmentid;
+    /**设备编号*/
+    @Excel(name = "设备编号")
+    @ApiModelProperty(value = "设备编号")
+    private java.lang.String equipmentcode;
+    @Excel(name = "设备名称")
+    @ApiModelProperty(value = "设备名称")
+    private java.lang.String equipmentname;
+    /**安装地点*/
+    @Excel(name = "安装地点")
+    @ApiModelProperty(value = "安装地点")
+    private java.lang.String address;
+    /**点检编号*/
+    @Excel(name = "点检编号")
+    @ApiModelProperty(value = "点检编号")
+    private java.lang.String contentcode;
+    /**点检名称*/
+    @Excel(name = "点检内容名称")
+    @ApiModelProperty(value = "点检内容名称")
+    private java.lang.String contentname;
+}

+ 7 - 0
module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/mapper/CmmsSpotcheckTitemMapper.java

@@ -2,9 +2,12 @@ package org.jeecg.modules.cmmsSpotcheckTitem.mapper;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.cmmsInspectTcontentItem.entity.CmmsInspectTcontentItemVo;
 import org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitem;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitemVo;
 
 /**
  * @Description: 设备点检-点检项
@@ -14,4 +17,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface CmmsSpotcheckTitemMapper extends BaseMapper<CmmsSpotcheckTitem> {
 
+    List<CmmsSpotcheckTitemVo> getItemList(@Param("page") Page<CmmsSpotcheckTitemVo> page, @Param("spotcheckTitemVo") CmmsSpotcheckTitemVo spotcheckTitemVo);
+
+    boolean updateStatusBySpotcheckId(@Param("status") String status,@Param("spotcheckid") String spotcheckid);
+
 }

+ 57 - 1
module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/mapper/xml/CmmsSpotcheckTitemMapper.xml

@@ -2,4 +2,60 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.cmmsSpotcheckTitem.mapper.CmmsSpotcheckTitemMapper">
 
-</mapper>
+    <resultMap id="itemResult" type="org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitemVo">
+        <result property="id"    column="id"    />
+        <result property="spotcheckid"    column="spotcheckid"    />
+        <result property="contitemtid"    column="contitemtid"    />
+        <result property="spotcheckcontid"    column="spotcheckcontid"    />
+        <result property="spotcheckitemid"    column="spotcheckitemid"    />
+        <result property="itemcode"    column="itemcode"    />
+        <result property="itemname"    column="itemname"    />
+        <result property="equipmenttreeid"    column="equipmenttreeid"    />
+        <result property="itemtype"    column="itemtype"    />
+        <result property="conditions"    column="conditions"    />
+        <result property="tag"    column="tag"    />
+        <result property="iresult"    column="iresult"    />
+        <result property="itag"    column="itag"    />
+        <result property="iremark"    column="iremark"    />
+        <result property="istatus"    column="istatus"    />
+        <result property="itime"    column="itime"    />
+        <result property="refervalue"    column="refervalue"    />
+        <result property="ifile"    column="ifile"    />
+        <result property="handleuser"    column="handleuser"    />
+        <result property="unusualstatus"    column="unusualstatus"    />
+        <result property="confirmcontent"    column="confirmcontent"    />
+        <result property="confirmuser"    column="confirmuser"    />
+        <result property="confirmtime"    column="confirmtime"    />
+        <result property="reportuser"    column="reportuser"    />
+        <result property="reporttime"    column="reporttime"    />
+
+        <result property="equipmentcode"    column="equipmentcode"    />
+        <result property="equipmentname"    column="equipmentname"    />
+        <result property="address"    column="address"    />
+        <result property="contentcode"    column="contentcode"    />
+        <result property="contentname"    column="contentname"    />
+    </resultMap>
+
+    <select id="getItemList" parameterType="org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitemVo" resultMap="itemResult">
+        select i.id, i.spotcheckid, i.contitemtid, i.spotcheckcontid, i.spotcheckitemid, i.itemcode, i.itemname,
+        i.equipmenttreeid, i.itemtype, i.conditions, i.tag, i.iresult, i.itag, i.iremark, i.istatus, i.itime,
+        i.refervalue, i.ifile, i.handleuser, i.unusualstatus, i.confirmcontent, i.confirmuser, i.confirmtime,
+        i.reportuser, i.reporttime, e.equipmentcode, e.equipmentname, e.address, t.contentcode, t.contentname
+        from cmms_spotcheck_titem as i
+        left join cmms_spotcheck t on t.id = i.spotcheckid
+        left join tpm_equipment e on t.equipmentid = e.id
+        where i.iresult = '1'
+        <if test="spotcheckTitemVo.equipmentid != null and spotcheckTitemVo.equipmentid != ''">
+            and t.equipmentid=#{CmmsSpotcheckTitemVo.equipmentid}
+        </if>
+        <if test="spotcheckTitemVo.contentname != null and spotcheckTitemVo.contentname != ''">
+            and t.contentname like concat('%',#{CmmsSpotcheckTitemVo.contentname},'%')
+        </if>
+        order by i.itime desc
+    </select>
+
+    <update id="updateStatusBySpotcheckId" parameterType="java.lang.String">
+        update cmms_spotcheck set resule = #{resule} where id = #{spotcheckid}
+    </update>
+
+</mapper>

+ 31 - 1
module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/service/ICmmsSpotcheckTitemService.java

@@ -1,7 +1,13 @@
 package org.jeecg.modules.cmmsSpotcheckTitem.service;
 
-import org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.cmmsRepair.entity.CmmsRepairVo;
+import org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitem;
+import org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitemVo;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 
 /**
  * @Description: 设备点检-点检项
@@ -11,4 +17,28 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ICmmsSpotcheckTitemService extends IService<CmmsSpotcheckTitem> {
 
+    /**
+     * 查询
+     * @param page
+     * @param cmmsSpotcheckTitem
+     * @return
+     */
+    List<CmmsSpotcheckTitemVo> getItemList(Page<CmmsSpotcheckTitemVo> page, CmmsSpotcheckTitemVo cmmsSpotcheckTitem);
+
+    /**
+     * 异常点检 确认
+     * @param cmmsSpotcheckTitem
+     * @param req
+     * @return
+     */
+    boolean confirm(CmmsSpotcheckTitem cmmsSpotcheckTitem, HttpServletRequest req);
+
+    /**
+     * 异常点检 转报修
+     * @param cmmsRepair
+     * @param req
+     * @return
+     */
+    boolean transrepair(CmmsRepairVo cmmsRepair, HttpServletRequest req);
+
 }

+ 75 - 1
module_cmms/src/main/java/org/jeecg/modules/cmmsSpotcheckTitem/service/impl/CmmsSpotcheckTitemServiceImpl.java

@@ -1,11 +1,24 @@
 package org.jeecg.modules.cmmsSpotcheckTitem.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.system.util.JwtUtil;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.cmmsInspectTcontentItem.entity.CmmsInspectTcontentItem;
+import org.jeecg.modules.cmmsRepair.entity.CmmsRepairVo;
+import org.jeecg.modules.cmmsRepair.service.ICmmsRepairService;
 import org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitem;
+import org.jeecg.modules.cmmsSpotcheckTitem.entity.CmmsSpotcheckTitemVo;
 import org.jeecg.modules.cmmsSpotcheckTitem.mapper.CmmsSpotcheckTitemMapper;
 import org.jeecg.modules.cmmsSpotcheckTitem.service.ICmmsSpotcheckTitemService;
+import org.jeecg.modules.util.AutoCodeUtil;
+import org.jeecg.modules.util.UserConstants;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 
 /**
  * @Description: 设备点检-点检项
@@ -16,4 +29,65 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class CmmsSpotcheckTitemServiceImpl extends ServiceImpl<CmmsSpotcheckTitemMapper, CmmsSpotcheckTitem> implements ICmmsSpotcheckTitemService {
 
+    @Autowired
+    private CmmsSpotcheckTitemMapper mapper;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private AutoCodeUtil autoCodeUtil;
+    @Autowired
+    @SuppressWarnings("all")
+    private ICmmsRepairService repairService;
+
+    /**
+     * 异常点检查询
+     * @param page
+     * @param cmmsSpotcheckTitem
+     * @return
+     */
+    @Override
+    public List<CmmsSpotcheckTitemVo> getItemList(Page<CmmsSpotcheckTitemVo> page, CmmsSpotcheckTitemVo cmmsSpotcheckTitem) {
+        return mapper.getItemList(page, cmmsSpotcheckTitem);
+    }
+
+    /**
+     * 异常点检-确认
+     * @param cmmsSpotcheckTitem
+     * @param req
+     * @return
+     */
+    @Override
+    public boolean confirm(CmmsSpotcheckTitem cmmsSpotcheckTitem, HttpServletRequest req) {
+        String userName = JwtUtil.getUserNameByToken(req);
+        cmmsSpotcheckTitem.setUnusualstatus("1");
+        return this.updateById(cmmsSpotcheckTitem);
+    }
+
+    /**
+     * 异常点检-转报修
+     * @param cmmsRepair
+     * @param req
+     * @return
+     */
+    @Override
+    public boolean transrepair(CmmsRepairVo cmmsRepair, HttpServletRequest req) {
+        String userName = JwtUtil.getUserNameByToken(req);
+        CmmsSpotcheckTitem cmmsSpotcheckTitem = new CmmsSpotcheckTitem();
+        cmmsSpotcheckTitem.setId(cmmsRepair.getRelid());
+        cmmsSpotcheckTitem.setUnusualstatus("2");
+
+        if (cmmsRepair.getRepaircode() == null || "".equals(cmmsRepair.getRepaircode())){
+            cmmsRepair.setRepaircode(autoCodeUtil.genSerialCode(UserConstants.CMMSREPAIR_CODE, null));
+        }
+
+        if(ObjectUtil.isEmpty(cmmsRepair.getStatus()) && ObjectUtil.isEmpty(cmmsRepair.getRepairstatus())){
+            cmmsRepair.setStatus("0");
+            cmmsRepair.setRepairstatus("0");
+        }
+
+        boolean b1 = repairService.addCmmsRepair(cmmsRepair);
+        boolean b2 = this.updateById(cmmsSpotcheckTitem);
+        return b1 && b2;
+    }
+
 }

+ 40 - 4
module_ems/src/main/java/org/jeecg/modules/kafka/consumer/TestConsumer.java

@@ -3,10 +3,14 @@ package org.jeecg.modules.kafka.consumer;
 import lombok.extern.slf4j.Slf4j;
 import net.sf.json.JSONObject;
 import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.collectdata.dao.CollectdataRepository;
 import org.jeecg.modules.collectdata.entity.Collectdata;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.index.Index;
+import org.springframework.data.mongodb.core.index.IndexOperations;
 import org.springframework.kafka.annotation.KafkaListener;
 import org.springframework.kafka.support.Acknowledgment;
 import org.springframework.stereotype.Component;
@@ -40,20 +44,52 @@ public class TestConsumer {
 
         // 提交(用来标记一条消息已经消费完成,即将从消息队列里移除。)
         ack.acknowledge();
-        saveDataR(record);
+
+        String yearmonth = DateUtils.getDate("yyyyMM");
+        String collectionName = "data_" + yearmonth;
+
+        // 检查月度集合是否存在,不存在则创建
+        boolean exists = mongoTemplate.collectionExists(collectionName);
+        if (!exists) {
+            mongoTemplate.createCollection(collectionName);
+        }
+
+        saveData(record, collectionName);
+
+        // 月度集合不存在,创建完表后,创建索引
+        if (!exists) {
+            createIndex(collectionName);
+        }
+
+        // 不知道当时为啥用这个方法,因为无法指定集合名称,改成上面的方法
+        // saveDataR(record);
+    }
+
+    /**
+     * 创建mongodb的索引
+     */
+    private void createIndex(String collectionName) {
+        // 步骤 1: 创建一个Mongodb索引
+        IndexOperations indexOps = mongoTemplate.indexOps(collectionName);
+        // 创建一个设备编号的索引
+        Index indexEquipmentcode = new Index().on("equipmentcode", Sort.Direction.ASC).named(collectionName + "_equipmentcode");
+        indexOps.ensureIndex(indexEquipmentcode);
+        // 创建一个记录时间的索引
+        Index indexLogtime = new Index().on("logtime", Sort.Direction.ASC).named(collectionName + "_logtime");
+        indexOps.ensureIndex(indexLogtime);
     }
 
     /**
      * 保存数据(通过mongoTemplate保存)
      * @param record kafka记录
      */
-    private void saveData(ConsumerRecord<?, ?> record) {
+    private void saveData(ConsumerRecord<?, ?> record, String collectionName) {
         JSONObject cd = JSONObject.fromObject(record.value());
 
         String equipmentcode = record.topic().replace("thing___", "").replace("___property", "");
         Map<String,Object> map = new HashMap<>();
         map.put("logid", cd.get("id"));
-        map.put("logtime", record.timestamp());
+        map.put("logtime", new Date(record.timestamp()));
         map.put("version", cd.get("version"));
         map.put("equipmentcode", equipmentcode);
         map.put("method", cd.get("method"));
@@ -65,7 +101,7 @@ public class TestConsumer {
         }
         map.put("properties", map1);
 
-        mongoTemplate.insert(map, "tpmcollectdata");
+        mongoTemplate.insert(map, collectionName);
     }
 
     /**

+ 1 - 1
module_ems/src/main/java/org/jeecg/modules/kafka/controller/TestController.java

@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 
-@Api(tags="kafka")
+//@Api(tags="kafka")
 @RestController
 @RequestMapping("/kafka/test")
 public class TestController {

+ 2 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/entity/Statistics.java

@@ -17,6 +17,8 @@ public class Statistics implements Serializable {
     private java.lang.String equipmentid;
     /**设备名称*/
     private java.lang.String equipmentname;
+    /** 设备编号 */
+    private String equipmentcode;
     /**时间*/
     private java.util.Date logtime;
     /**点位值*/

+ 10 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/mapper/StatisticsMapper.java

@@ -73,4 +73,14 @@ public interface StatisticsMapper extends BaseMapper<Statistics> {
                                                 @Param("equipmentid") String equipmentid,
                                                 @Param("day") String day);
 
+    /**
+     * 依据状态、日期查询 保养、巡检工单
+     *
+     * @param day 日期
+     * @param status 状态
+     * @return 分析统计
+     */
+    public List<Statistics> selectDevOpsByDayAndStatus(@Param("day") String day,
+                                                       @Param("status") String status);
+
 }

+ 17 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/mapper/xml/StatisticsMapper.xml

@@ -8,6 +8,7 @@
         <result property="tagname"    column="tagname"    />
         <result property="equipmentid"    column="equipmentid"    />
         <result property="equipmentname"    column="equipmentname"    />
+        <result property="equipmentcode"    column="equipmentcode"    />
         <result property="logtime"    column="logtime"    />
         <result property="tagvalue"    column="tagvalue"    />
         <result property="tagvalue2"    column="tagvalue2"    />
@@ -23,6 +24,7 @@
     <resultMap type="org.jeecg.modules.Statistics.vo.StatisticsVo" id="TpmStatisticsResult">
         <result property="equipmentid"    column="equipmentid"    />
         <result property="equipmentname"    column="equipmentname"    />
+        <result property="equipmentcode"    column="equipmentcode"    />
         <result property="year"    column="year"    />
         <result property="month"    column="month"    />
         <result property="week"    column="week"    />
@@ -75,4 +77,19 @@
         order by id asc
     </select>
 
+    <!--依据状态、日期查询 保养、巡检工单-->
+    <select id="selectDevOpsByDayAndStatus" resultMap="StatisticsResult">
+        select a.equipmentname, a.equipmentcode, a.logtime, a.tagname
+        from (
+            select inspectname as equipmentname, inspectcode as equipmentcode, create_time as logtime, '巡检工单' as tagname
+            from cmms_inspect
+            where status=#{status} and DATE_FORMAT(create_time, '%Y-%m-%d')= #{day}
+            union
+            select upkeepname as equipmentname, upkeepcode as equipmentcode, create_time as logtime, '保养工单' as tagname
+            from cmms_upkeep
+            where status=#{status} and DATE_FORMAT(create_time, '%Y-%m-%d')= #{day}
+        ) as a
+        order by a.logtime desc;
+    </select>
+
 </mapper>

+ 3 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/vo/StatisticsVo.java

@@ -13,6 +13,9 @@ public class StatisticsVo {
     /** 设备名称 */
     private String equipmentname;
 
+    /** 设备编号 */
+    private String equipmentcode;
+
     /** 所属年*/
     private Long year;
 

+ 30 - 11
module_tpm/src/main/java/org/jeecg/modules/collectdata/controller/CollectdataController.java

@@ -1,10 +1,14 @@
 package org.jeecg.modules.collectdata.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 org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.collectdata.dao.CollectdataRepository;
 import org.jeecg.modules.collectdata.entity.Collectdata;
+import org.jeecg.modules.collectdata.entity.CollectdataVo;
+import org.jeecg.modules.collectdata.service.ICollectdataService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -13,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.jeecg.common.api.vo.Result;
 
+import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
 import java.util.Date;
 import java.util.HashMap;
@@ -30,8 +35,31 @@ public class CollectdataController {
     private MongoTemplate mongoTemplate;
     @Autowired
     private CollectdataRepository repository;
+    @Autowired
+    private ICollectdataService collectdataService;
 
 
+    /**
+     * mongodb=分页列表查询
+     *
+     * @param collectdata
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    //@AutoLog(value = "mongodb-分页列表查询")
+    @ApiOperation(value="mongodb-分页列表查询", notes="mongodb-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<Collectdata>> queryPageList(CollectdataVo collectdata,
+                                                    @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+                                                    @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+                                                    HttpServletRequest req) {
+        Page<Collectdata> page = new Page<Collectdata>(pageNo, pageSize);
+        List<Collectdata> list = collectdataService.getPageList(page, collectdata);
+        page.setRecords(list);
+        return Result.OK(page);
+    }
 
     @ApiOperation(value="测试mongodb-插入", notes="测试mongodb-插入")
     @GetMapping("/insert")
@@ -55,15 +83,6 @@ public class CollectdataController {
         return Result.OK("存入成功");
     }
 
-    @ApiOperation(value="测试mongodb-依据设备编号查询", notes="测试mongodb-依据设备编号查询")
-    @GetMapping("/querybycode")
-    public Result<?> query(@RequestParam(name="equipmentcode") String equipmentcode) {
-//        List<Collectdata> list = repository.findByEquipmentcode(equipmentcode);
-        List<Collectdata> list = repository.findByEquipmentcode(equipmentcode);
-
-        return Result.OK(list);
-    }
-
     @ApiOperation(value="测试mongodb-依据设备编号、日期查询", notes="测试mongodb-依据设备编号、日期查询")
     @GetMapping("/querybycodeanddate")
     public Result<?> querybycodeanddate(@RequestParam(name="equipmentcode") String equipmentcode,
@@ -90,7 +109,7 @@ public class CollectdataController {
             e.printStackTrace();
         }
 
-        List<Collectdata> list = repository.findByEquipmentcodeAndLogtimeBetween(equipmentcode, bdate, edate);
+        List<Collectdata> list = collectdataService.getListByEquipmentcode(equipmentcode, bdate, edate);
 
         return Result.OK(list);
     }
@@ -120,7 +139,7 @@ public class CollectdataController {
             e.printStackTrace();
         }
 
-        List<Collectdata> list = repository.findByLogtimeBetween(bdate, edate);
+        List<Collectdata> list = collectdataService.getListByEquipmentcode(null, bdate, edate);
 
         return Result.OK(list);
     }

+ 2 - 1
module_tpm/src/main/java/org/jeecg/modules/collectdata/entity/Collectdata.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.collectdata.entity;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.mongodb.DBObject;
 import lombok.Data;
 import org.springframework.data.mongodb.core.mapping.Document;
 import org.springframework.format.annotation.DateTimeFormat;
@@ -9,7 +10,7 @@ import javax.persistence.Id;
 import java.util.Date;
 
 @Data
-@Document("tpmcollectdata")
+@Document("data_202501")
 public class Collectdata {
 
     @Id

+ 37 - 0
module_tpm/src/main/java/org/jeecg/modules/collectdata/entity/CollectdataVo.java

@@ -0,0 +1,37 @@
+package org.jeecg.modules.collectdata.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.mongodb.DBObject;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.persistence.Id;
+import java.util.Date;
+
+@Data
+public class CollectdataVo {
+
+    public String id;
+
+    public Long logid;
+
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    public Date logtime;
+
+    public String version;
+
+    public String equipmentcode;
+
+    public String method;
+
+    public DBObject properties;
+
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    public Date starttime;
+
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    public Date endtime;
+}

+ 25 - 0
module_tpm/src/main/java/org/jeecg/modules/collectdata/service/ICollectdataService.java

@@ -1,10 +1,35 @@
 package org.jeecg.modules.collectdata.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.jeecg.modules.collectdata.entity.Collectdata;
+import org.jeecg.modules.collectdata.entity.CollectdataVo;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
 import java.util.List;
 
 public interface ICollectdataService {
 
+    /**
+     * 获取每个设备的最新一条信息
+     * @return
+     */
     List<Collectdata> getLatestDataPerGroup();
+
+    /**
+     * 查询某设备一段时间的数据
+     * @param equipmentcode
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Collectdata> getListByEquipmentcode(String equipmentcode, Date startTime, Date endTime);
+
+    /**
+     * 分页查询
+     * @param page
+     * @param collectdata
+     * @return
+     */
+    List<Collectdata> getPageList(Page<Collectdata> page, CollectdataVo collectdata);
 }

+ 74 - 0
module_tpm/src/main/java/org/jeecg/modules/collectdata/service/impl/CollectdataServiceImpl.java

@@ -1,15 +1,27 @@
 package org.jeecg.modules.collectdata.service.impl;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import nonapi.io.github.classgraph.utils.LogNode;
+import nonapi.io.github.classgraph.utils.StringUtils;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.collectdata.entity.Collectdata;
+import org.jeecg.modules.collectdata.entity.CollectdataVo;
 import org.jeecg.modules.collectdata.service.ICollectdataService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.aggregation.Aggregation;
 import org.springframework.data.mongodb.core.aggregation.AggregationResults;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Service
 public class CollectdataServiceImpl implements ICollectdataService {
@@ -17,6 +29,7 @@ public class CollectdataServiceImpl implements ICollectdataService {
     @Autowired
     private MongoTemplate mongoTemplate;
 
+
     /**
      * 获取每个设备的最新一条信息
      * @return
@@ -31,4 +44,65 @@ public class CollectdataServiceImpl implements ICollectdataService {
         AggregationResults<Collectdata> aggregatedPage = mongoTemplate.aggregate(aggregation, "equipmentcode", Collectdata.class);
         return aggregatedPage.getMappedResults();
     }
+
+    /**
+     * 查询某设备一段时间的数据
+     * @param equipmentcode
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    @Override
+    public List<Collectdata> getListByEquipmentcode(String equipmentcode, Date startTime, Date endTime) {
+        if (startTime == null || endTime == null) {
+            return null;
+        }
+
+        // 条件
+        Criteria criteria = new Criteria();
+        String collectionName = "data_" + DateUtils.formatDate("yyyyMM");
+        if (equipmentcode != null && !equipmentcode.isEmpty()) {
+            criteria.and("equipmentcode").is(equipmentcode);
+        }
+        criteria.andOperator(Criteria.where("logtime").gte(startTime), Criteria.where("logtime").lte(endTime));
+        Query query = new Query();
+        query.addCriteria(criteria);
+        List<Collectdata> collectdataList = mongoTemplate.find(query, Collectdata.class, collectionName);
+
+        return collectdataList;
+    }
+
+    /**
+     * 分页查询
+     * @param page
+     * @param collectdata
+     * @return
+     */
+    @Override
+    public List<Collectdata> getPageList(Page<Collectdata> page, CollectdataVo collectdata) {
+        // 不允许开始、结束日期都为空
+        if (collectdata.getStarttime() == null || collectdata.getEndtime() == null) {
+            return null;
+        }
+
+        // 条件
+        Criteria criteria = new Criteria();
+        if (collectdata.getEquipmentcode() != null && !collectdata.getEquipmentcode().isEmpty()) {
+            criteria.and("equipmentcode").is(collectdata.getEquipmentcode());
+        }
+        String collectionName = "data_" + DateUtils.formatDate(collectdata.getStarttime(), "yyyyMM");
+        criteria.andOperator(Criteria.where("logtime").gte(collectdata.getStarttime()), Criteria.where("logtime").lte(collectdata.getEndtime()));
+        Query query = new Query();
+        query.addCriteria(criteria);
+        // 总数
+        long total = mongoTemplate.count(query, Collectdata.class, collectionName);
+        // 分页
+        query.with(PageRequest.of((int) page.getCurrent() - 1, (int) page.getSize(),
+        // 排序
+        Sort.by(Sort.Direction.ASC, "logtime")));
+        List<Collectdata> collectdataList = mongoTemplate.find(query, Collectdata.class, collectionName);
+
+        page.setTotal(total);
+        return collectdataList;
+    }
 }

+ 8 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/mapper/EquipmentHealthSectionMapper.java

@@ -34,4 +34,12 @@ public interface EquipmentHealthSectionMapper extends BaseMapper<EquipmentHealth
      * @return
      */
     public List<EquipmentHealthSection> selectStatusByDay(@Param("day") String day);
+
+    /**
+     * 按日期、状态查询
+     * @param day 日期
+     * @param status 状态
+     * @return
+     */
+    public List<EquipmentHealthSection> selectByDayAndStatus(@Param("day") String day, @Param("status") String status);
 }

+ 11 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentHealthSection/mapper/xml/EquipmentHealthSectionMapper.xml

@@ -142,4 +142,15 @@
         ) as o
     </select>
 
+    <!--按日期、状态查询-->
+    <select id="selectByDayAndStatus" resultMap="EquipmentHealthSectionResult">
+        select o.equipmentid, t.equipmentname, t.equipmentcode, sum(o.duration) as duration
+        from tpm_equipment_health_section as o
+        left join tpm_equipment as t
+            on o.equipmentid=t.id
+        where o.day= #{day} and o.status=#{status}
+        group by o.equipmentid
+        order by o.equipmentid asc
+    </select>
+
 </mapper>

+ 1 - 0
module_tpm/src/main/java/org/jeecg/modules/equipmentStatus/service/impl/EquipmentStatusServiceImpl.java

@@ -35,6 +35,7 @@ public class EquipmentStatusServiceImpl extends ServiceImpl<EquipmentStatusMappe
 
     @Autowired
     ICollectdataService collectdataService;
+
     /**
      * 获取设备当天的总用电量
      * @param day 日期

+ 4 - 2
module_tpm/src/main/java/org/jeecg/modules/healthStatistics/controller/HealthStatisticsController.java

@@ -4,12 +4,15 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.healthStatistics.service.IHealthStatisticsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Date;
+
 /**
  * @Description: 设备健康统计
  * @Author: jeecg-boot
@@ -33,8 +36,7 @@ public class HealthStatisticsController {
     @ApiOperation(value="设备健康统计-健康概况", notes="设备健康统计-健康概况")
     @GetMapping(value = "/dashboard")
     public Result dashboardStatistics() {
-//        String day = DateUtils.formatDate();
-        String day="2024-10-01";
+        String day = DateUtils.formatDate(new Date());
         Result rtn = healthStatisticsService.DashboardStatistics(day);
         return rtn;
     }

+ 43 - 2
module_tpm/src/main/java/org/jeecg/modules/healthStatistics/service/Impl/HealthStatisticsServiceImpl.java

@@ -1,10 +1,13 @@
 package org.jeecg.modules.healthStatistics.service.Impl;
 
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.Statistics.entity.Statistics;
+import org.jeecg.modules.Statistics.mapper.StatisticsMapper;
 import org.jeecg.modules.equipmentHealth.entity.EquipmentHealth;
 import org.jeecg.modules.equipmentHealth.mapper.EquipmentHealthMapper;
 import org.jeecg.modules.equipmentHealthSection.entity.EquipmentHealthSection;
 import org.jeecg.modules.equipmentHealthSection.mapper.EquipmentHealthSectionMapper;
+import org.jeecg.modules.equipmentOnoffSection.entity.EquipmentOnoffSection;
 import org.jeecg.modules.healthStatistics.service.IHealthStatisticsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -24,6 +27,9 @@ public class HealthStatisticsServiceImpl implements IHealthStatisticsService {
     @Autowired
     private EquipmentHealthSectionMapper equipmentHealthSectionMapper;
 
+    @Autowired
+    private StatisticsMapper statisticsMapper;
+
     /**
      * 健康概况信息获取
      * @param day
@@ -91,14 +97,49 @@ public class HealthStatisticsServiceImpl implements IHealthStatisticsService {
                 monthSectionList.add(section);
             }
         }
-//        // 按日期、状态、设备分组查询
-//        List<EquipmentHealthSection> daySectionList = equipmentHealthSectionMapper.selectStatusByDay(day);
+        // 按日期、状态、设备分组查询
+        // List<EquipmentHealthSection> daySectionList = equipmentHealthSectionMapper.selectStatusByDay(day);
+
+        // 重点关注设备
+        List<EquipmentHealthSection> healthSectionList = equipmentHealthSectionMapper.selectByDayAndStatus(day, "3");
+        String equipmentInfo = "今日无需要重点关注的设备!";
+        if (healthSectionList != null && healthSectionList.size() > 0) {
+            equipmentInfo = "";
+            int rows = 0;
+            for (EquipmentHealthSection section : healthSectionList) {
+                equipmentInfo += "<b>" + section.getEquipmentname() + "(" + section.getEquipmentcode() + ")</b>" + "设备检测异常,异常时长:" +
+                        section.getDuration() + "分钟。<br />";
+                rows++;
+                if (rows > 5) {
+                    equipmentInfo += "......";
+                    break;
+                }
+            }
+        }
+
+        // 日常运维提醒
+        List<Statistics> statisticsList = statisticsMapper.selectDevOpsByDayAndStatus(day, "0");
+        String devopsInfo = "今日无运维提醒!";
+        if (statisticsList != null && statisticsList.size() > 0) {
+            devopsInfo = "";
+            int rows = 0;
+            for (Statistics statistics : statisticsList) {
+                devopsInfo += "<b>" + statistics.getTagname() + ":</b>" + statistics.getEquipmentname() + "(" + statistics.getEquipmentcode() + ")<br />";
+                rows++;
+                if (rows > 8) {
+                    devopsInfo += "......";
+                    break;
+                }
+            }
+        }
 
         HashMap map = new HashMap();
         map.put("healthList", healthList);
         map.put("yearSectionList", yearSectionList);
         map.put("monthSectionList", monthSectionList);
         map.put("days", days);
+        map.put("equipmentInfo", equipmentInfo);
+        map.put("devopsInfo", devopsInfo);
 
         return Result.OK(map);
     }