0d28b43b 张雷

feat(module-inspection): 优化巡检计划和任务查询接口

- 新增巡检计划分页查询接口和相关实现
- 重构巡检任务分页查询接口,增加异常状态筛选功能
-优化巡检点历史数据查询接口,采用多线程提高查询效率
- 更新实体类和 Mapper接口以支持新功能
1 个父辈 31442ef8
正在显示 17 个修改的文件 包含 139 行增加64 行删除
......@@ -19,7 +19,6 @@ import com.skua.core.service.IFactoryInfoService;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.algorithm.handle.IAlarmLimitCustomService;
import com.skua.modules.algorithm.service.ISysAlgorithmLibraryService;
import com.skua.modules.algorithm.service.ISysAlgorithmStatisticsLibraryService;
import com.skua.modules.algorithm.vo.SysAlgorithmStatisticsLibraryVO;
import com.skua.modules.algorithm.vo.SysAlgorithmStatisticsResultChartsVO;
......@@ -27,7 +26,6 @@ import com.skua.modules.algorithm.vo.SysAlgorithmStatisticsResultNumberVO;
import com.skua.modules.algorithm.vo.SysAlgorithmStatisticsResultVO;
import com.skua.modules.flow.utils.ObjectUtil;
import com.skua.modules.flow.utils.StringUtil;
import com.skua.modules.system.datestandard.service.ISysMonitorMetricInfoService;
import com.skua.modules.system.entity.SysDepart;
import com.skua.modules.system.entity.SysFactoryInfo;
import com.skua.modules.system.service.ISysDepartService;
......@@ -45,7 +43,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.NumberFormat;
......@@ -76,8 +73,6 @@ public class ScreenDataController {
@Autowired
private ISysFactoryInfoService sysFactoryInfoService;
@Autowired
public ISysAlgorithmLibraryService sysAlgorithmLibraryService;
@Autowired
private IDataCountDayService dataCountDayService;
@Autowired
private ISysFactoryDeviceService sysFactoryDeviceService;
......@@ -134,17 +129,13 @@ public class ScreenDataController {
/**
* app水量情况
*
* @param departId
* @param req
* @return
*/
@AutoLog(value = "app水量情况")
@ApiOperation(value = "app水量情况", notes = "app水量情况")
@GetMapping(value = "/getAppSlqk")
public Result<Map<String, Object>> getAppSlqk(String departId,
HttpServletRequest req) {
public Result<Map<String, Object>> getAppSlqk(String departId) {
Result<Map<String, Object>> result = new Result<Map<String, Object>>();
Map<String, Object> resultMap = new HashMap<String, Object>();
NumberFormat numberFormat = NumberFormat.getInstance();
......@@ -188,7 +179,6 @@ public class ScreenDataController {
Double monthSl = Double.parseDouble(monthMap.get("JSLL").toString());
resultMap.put("本月累计水量", numberFormat.format(monthSl / 10000));
}
//上月累计水量
String lastMonthStartDate = DateUtils.getLastMonthOfMonth(DateUtils.getTodayOrMonthDate("month")) + "-01";
String lastMonthEndDate = DateUtils.getLastDayOfMonth(DateUtils.getLastMonthOfMonth(DateUtils.getTodayOrMonthDate("month")));
......@@ -204,7 +194,6 @@ public class ScreenDataController {
String hb = numberFormat.format((monthSl - lastMonthSl) / 10000);
resultMap.put("环比上月", hb);
}
}
result.setSuccess(true);
result.setResult(resultMap);
......@@ -213,17 +202,13 @@ public class ScreenDataController {
/**
* 今日水量情况
*
* @param departId
* @param req
* @return
*/
@AutoLog(value = "今日水量情况")
@ApiOperation(value = "今日水量情况", notes = "今日水量情况")
@GetMapping(value = "/getTodaySl")
public Result<Map<String, Object>> getTodaySl(String departId,
HttpServletRequest req) {
public Result<Map<String, Object>> getTodaySl(String departId) {
Result<Map<String, Object>> result = new Result<Map<String, Object>>();
Map<String, Object> resultMap = new HashMap<String, Object>();
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
......@@ -246,20 +231,15 @@ public class ScreenDataController {
return result;
}
/**
* 今日水量情况
*
* @param req GZGSDH
* @return
*/
@AutoLog(value = "各子公司电耗")
@ApiOperation(value = "各子公司电耗", notes = "各子公司电耗")
@PostMapping(value = "/getFactoryDH")
public Result<Map<String, Object>> getFactoryDH(@RequestBody JSONObject jsonObject,
HttpServletRequest req) {
public Result<Map<String, Object>> getFactoryDH(@RequestBody JSONObject jsonObject) {
Result<Map<String, Object>> result = new Result<Map<String, Object>>();
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
//将jsonObject转sysAlgorithmStatisticsLibraryVO对象
......@@ -329,7 +309,6 @@ public class ScreenDataController {
}
}
resultMap.put("d", dList.size());
resultMap.put("z", zList.size());
resultMap.put("g", gList.size());
......@@ -342,32 +321,23 @@ public class ScreenDataController {
result.setSuccess(true);
result.setResult(resultMap);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* 今日水量情况
*
* @param req GZGSYH
* @param req GLDSYH
* @return
*/
@AutoLog(value = "各子公司吨水药耗")
@ApiOperation(value = "各子公司吨水药耗", notes = "各子公司吨水药耗")
@PostMapping(value = "/getFactoryYH")
public Result getFactoryYH(@RequestBody JSONObject jsonObject,
HttpServletRequest req) {
public Result getFactoryYH(@RequestBody JSONObject jsonObject) {
Result result = new Result();
//将jsonObject转sysAlgorithmStatisticsLibraryVO对象
SysAlgorithmStatisticsLibraryVO sysAlgorithmStatisticsLibraryVO = JSONObject.toJavaObject(jsonObject, SysAlgorithmStatisticsLibraryVO.class);
QueryWrapper<SysDepart> sysDepartQueryWrapper = new QueryWrapper<>();
......@@ -433,50 +403,39 @@ public class ScreenDataController {
newVo.setUnit(unit);
number.put(replace, newVo);
}
}
resultMap.put("number", number);
resultList.add(resultMap);
}
result.setResult(resultList);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* @param departId
* @param req
* @return
*/
@AutoLog(value = "数字指挥中心-运行负荷率分析")
@ApiOperation(value = "数字指挥中心-运行负荷率分析", notes = "数字指挥中心-运行负荷率分析")
@GetMapping(value = "/factoryFhl")
public Result<Map<String, Object>> factoryFhl(String departId, String month,
HttpServletRequest req) {
public Result<Map<String, Object>> factoryFhl(String departId, String month) {
Result<Map<String, Object>> result = new Result<Map<String, Object>>();
Map<String, Object> resultMap = new HashMap<String, Object>();
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
if (org.apache.commons.lang3.StringUtils.isEmpty(departId)) {
if (ConvertUtils.isEmpty(departId)) {
departId = BaseContextHandler.getDeparts();
QueryWrapper<SysDepart> sysDepartQueryWrapper = new QueryWrapper<>();
sysDepartQueryWrapper.eq("del_flag", 1).eq("depart_type", 1).in("id", Lists.newArrayList(departId.split(",")))
.select("id,depart_name");
List<Map<String, Object>> departMapList = sysDepartService.listMaps(sysDepartQueryWrapper);
departId = departMapList.stream().map(map ->
String.valueOf(map.get("id"))
).collect(Collectors.joining(","));
// QueryWrapper<SysDepart> sysDepartQueryWrapper = new QueryWrapper<>();
// sysDepartQueryWrapper.eq("del_flag", 1).eq("depart_type", 1).in("id", Lists.newArrayList(departId.split(",")))
// .select("id,depart_name");
// List<Map<String, Object>> departMapList = sysDepartService.listMaps(sysDepartQueryWrapper);
// departId = departMapList.stream().map(map ->
// String.valueOf(map.get("id"))
// ).collect(Collectors.joining(","));
}
String thisMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
String startDate = DateUtils.getTodayOrMonthDate("day") + " 00:00:00";
List<Map<String, Object>> fhlMaps = screenDataService.beforeTodayAvgFhl(departId, month, masterDB);
//如果是当月,处理水量加上当天小时数据和实时数据
if (!CollectionUtil.isEmpty(fhlMaps)) {
......
......@@ -43,7 +43,6 @@ public class InspectionPlanController {
* @param inspectionPlan 巡检计划对象
* @param pageNo 页码
* @param pageSize 每页大小
* @param req
* @author Xie Chao,2021-08-11 13:56
*/
@AutoLog(value = "巡检计划-分页列表查询")
......@@ -51,14 +50,11 @@ public class InspectionPlanController {
@GetMapping(value = "/list")
public Result<IPage<InspectionPlan>> queryPageList(InspectionPlan inspectionPlan,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Result<IPage<InspectionPlan>> result = new Result<>();
try {
inspectionPlan.setDelFlag(0);
QueryWrapper<InspectionPlan> queryWrapper = QueryGenerator.initQueryWrapper(inspectionPlan, req.getParameterMap());
Page<InspectionPlan> page = new Page<>(pageNo, pageSize);
IPage<InspectionPlan> pageList = inspectionPlanService.page(page, queryWrapper);
IPage<InspectionPlan> pageList = inspectionPlanService.getPage(page, inspectionPlan);
result.setSuccess(true);
result.setResult(pageList);
} catch (Exception e) {
......
......@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* <pre>
......@@ -64,7 +65,30 @@ public class InspectionTaskController {
inspectionTaskVO.setEndTime(inspectionTaskVO.getEndTime() + " 23:59:59");
}
Page<InspectionTask> page = new Page<>(pageNo, pageSize);
QueryWrapper isExceptionQueryWrapper = new QueryWrapper();
isExceptionQueryWrapper.eq("itdtfc.choice_state","0");
isExceptionQueryWrapper.groupBy("itfc.inspection_task_id");
List<String> isExceptionInspectionTaskIdList = inspectionTaskService.getIsExceptionInspectionTask(isExceptionQueryWrapper);
IPage<InspectionTask> pageList = inspectionTaskService.getPage(page, inspectionTaskVO);
List<InspectionTask> inspectionTaskList = pageList.getRecords();
List<String> inspectionTaskIdList = inspectionTaskList.stream().map(InspectionTask::getId).collect(Collectors.toList());
if (inspectionTaskIdList.size() == 0){
result.setSuccess(true);
result.setResult(pageList);
return result;
}
if (StringUtils.isBlank(inspectionTaskVO.getIsException())) {
isExceptionQueryWrapper.in("itfc.inspection_task_id", inspectionTaskIdList);
isExceptionInspectionTaskIdList = inspectionTaskService.getIsExceptionInspectionTask(isExceptionQueryWrapper);
}
for (InspectionTask inspectionTask : inspectionTaskList) {
if (isExceptionInspectionTaskIdList.contains(inspectionTask.getId())){
inspectionTask.setIsException("true");
}else{
inspectionTask.setIsException("false");
}
}
pageList.setRecords(inspectionTaskList);
result.setSuccess(true);
result.setResult(pageList);
return result;
......@@ -72,6 +96,32 @@ public class InspectionTaskController {
/**
* <pre>
* 实体字段翻译为数据库表字段
* </pre>
* @param entityField
* @return
* @author Li Yuanyuan, 2024年3月27日 下午5:57:18
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
private String getDatabaseFieldToEntity(String entityField) {
String dataBaseField = "";
if("inspectionCycleStartDate".equals(entityField)) {
dataBaseField = "inspection_cycle_start_date";
}
if("taskStartTime".equals(entityField)) {
dataBaseField = "task_start_time";
}
if("taskEndTime".equals(entityField)) {
dataBaseField = "task_end_time";
}
if("taskState".equals(entityField)) {
dataBaseField = "task_state";
}
return dataBaseField;
}
/**
* <pre>
* 通过巡检任务id删除对象
* </pre>
*
......
package com.skua.modules.inspection.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.skua.core.aspect.annotation.Dict;
......@@ -112,4 +113,8 @@ public class InspectionPlan {
@ApiModelProperty(value = "计划任务类型")
@Dict(dicCode = "inspection_plan_type")
private String inspectionPlanType;
/**关联设备数量*/
@TableField(exist = false)
private String equipCount;
}
......
......@@ -151,8 +151,12 @@ public class InspectionTask {
@ApiModelProperty(value = "删除标识(0:删除,1:有效)")
private String delFlag;
/**巡检类型:设备、工艺、其他*/
@TableField(exist=false)
@Dict(dicCode = "inspection_plan_type")
private String inspectionPlanType;
/**是否异常*/
@TableField(exist = false)
private String isException;
}
......
......@@ -22,7 +22,7 @@ import java.util.Date;
//@Accessors(chain = true)
@ApiModel(value="inspection_task_point对象", description="巡检任务-巡检点")
public class InspectionTaskPoint {
/**主键*/
@TableId(type = IdType.ID_WORKER_STR)
@ApiModelProperty(value = "主键")
......@@ -103,4 +103,13 @@ public class InspectionTaskPoint {
@Excel(name = "排序", width = 15)
@ApiModelProperty(value = "排序")
private String sort;
/**巡检点状态(0:未运行,1启用,2维修中)*/
private String pointStatus;
/**打卡时间*/
@Excel(name = "打卡时间", width = 20, 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 Date clockStatusTime;
}
......
......@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface InspectionPlanMapper extends BaseMapper<InspectionPlan> {
List<InspectionPlan> getPage(@Param("departId") String departId, @Param("planName") String planName, @Param("inspectionPlanType") String inspectionPlanType);
}
......
......@@ -34,4 +34,14 @@ public interface InspectionTaskMapper extends BaseMapper<InspectionTask> {
Map<String, Object> getEquipmentInfo(@Param(Constants.WRAPPER)QueryWrapper queryWrapper);
List<InspectionTask> getList(@Param("inspectionTaskVO") InspectionTaskVO inspectionTaskVO);
@Select("SELECT" +
" itfc.inspection_task_id as inspectionTaskId " +
" FROM " +
" inspection_task_fill_content itfc " +
" LEFT JOIN inspection_task_fill_choice itdtfc ON itdtfc.id = itfc.fill_content " +
" AND itdtfc.inspection_fill_id = itfc.inspection_fill_id " +
" AND itdtfc.inspection_task_id = itfc.inspection_task_id " +
" ${ew.customSqlSegment}")
List<Map<String, Object>> getIsExceptionInspectionTask(@Param(Constants.WRAPPER)QueryWrapper queryWrapper);
}
......
......@@ -2,4 +2,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.skua.modules.inspection.mapper.InspectionPlanMapper">
</mapper>
\ No newline at end of file
<select id="getPage" resultType="com.skua.modules.inspection.entity.InspectionPlan">
select * from inspection_plan p
where p.del_flag = '0'
<if test="departId!=null and departId!=''">
AND p.depart_id = #{departId}
</if>
<if test="planName!=null and planName!=''">
AND p.plan_name like CONCAT('%',#{planName},'%')
</if>
<if test="inspectionPlanType!=null and inspectionPlanType!=''">
AND p.inspection_plan_type = #{inspectionPlanType}
</if>
order by p.create_time desc
</select>
</mapper>
......
package com.skua.modules.inspection.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.inspection.entity.InspectionPlan;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.inspection.vo.InspectionPlanVO;
......@@ -18,4 +20,6 @@ public interface IInspectionPlanService extends IService<InspectionPlan> {
Map<String,Object> getInspectionPlanById(String planId);
Map<String,Object> checkEditInspectionPlan(String planId,String planStartDate,String planTaskStartTime);
IPage<InspectionPlan> getPage(Page<InspectionPlan> page, InspectionPlan inspectionPlan);
}
......
......@@ -17,7 +17,7 @@ public interface IInspectionTaskFillContentService extends IService<InspectionTa
List<Map<String, Object>> getInspectionPointHistoryByTaskId(String taskId);
List<Map<String, Object>> getInspectionHistoryFillGroupByInspectionPointId(String taskId, String inspectionPointId);
Map<String,List<Map<String, Object>>> getInspectionHistoryFillGroupByInspectionPointId(String taskId, String inspectionPointId);
List<Map<String, Object>> getInspectionHistoryByTaskId(String taskId);
......
......@@ -39,4 +39,6 @@ public interface IInspectionTaskService extends IService<InspectionTask> {
boolean checkInspectionTriggerEquipQr(String equipmentInfoId, String code);
IPage<InspectionTask> getPage(Page<InspectionTask> page, InspectionTaskVO inspectionTaskVO);
List<String> getIsExceptionInspectionTask(QueryWrapper isExceptionQueryWrapper);
}
......
......@@ -2,6 +2,7 @@ package com.skua.modules.inspection.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.skua.core.util.ConvertUtils;
......@@ -155,4 +156,12 @@ public class InspectionPlanServiceImpl extends ServiceImpl<InspectionPlanMapper,
}
return resultMap;
}
@Override
public IPage<InspectionPlan> getPage(Page<InspectionPlan> page, InspectionPlan inspectionPlan) {
List<InspectionPlan> list = baseMapper.getPage(inspectionPlan.getDepartId(),inspectionPlan.getPlanName(),inspectionPlan.getInspectionPlanType());
page.setRecords(list);
page.setTotal(list.size());
return page;
}
}
......
......@@ -33,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import static org.apache.commons.beanutils.BeanUtils.populate;
......@@ -797,6 +798,13 @@ public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper,
return page;
}
@Override
public List<String> getIsExceptionInspectionTask(QueryWrapper queryWrapper) {
List<Map<String,Object>> isExceptionInspectionTaskMap = this.baseMapper.getIsExceptionInspectionTask(queryWrapper);
List<String> inspectionTaskIdList = isExceptionInspectionTaskMap.stream().map(map -> com.skua.core.util.ConvertUtils.getString(map.get("inspectionTaskId"))).collect(Collectors.toList());
return inspectionTaskIdList;
}
public List<Map<String, Object>> correctionInspectionTrack(List<Map<String, Object>> pointList) throws Exception {
List<Map<String, Object>> resultList;
String url = "http://api.map.baidu.com/rectify/v1/track";
......
......@@ -165,4 +165,7 @@ public class InspectionTaskVO {
/**计划任务类型*/
private String inspectionPlanType;
/**是否异常*/
private String isException;
}
......
......@@ -75,7 +75,7 @@ public class MybatisInterceptor implements Interceptor {
add("ajh_supplier_manage");
add("ajh_meeting_attend");
add("equipment_sparepart_supplies_allot");
// add("ajh_rectification_info");
add("alarm_custom_rule_repository");
add("alarm_rule_config_public_templete");//放行报警配置公共模板表
//算法库相关表过滤权限
add("sys_algorithm_database_info");
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!