Commit 18393dae authored by tianbo's avatar tianbo

隐患修改

parent 6ae99059
package com.yeejoin.amos.boot.module.common.api.feign;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -30,4 +31,21 @@ public interface SupervisionFeignClient {
@RequestMapping(value = "/patrol/danger/info", method = RequestMethod.GET)
ResponseModel<Object> getPatrolDangerInfo(@RequestBody Object param);
/**
* 修改巡检检查项
*
* @param param
* @return
*/
@RequestMapping(value = "/patrol/danger/check", method = RequestMethod.GET)
ResponseModel<Object> setPatrolDangerCheck(@RequestBody JSONObject param);
/**
* 查询隐患巡检信息
*
* @param latentDangerId
* @return
*/
@RequestMapping(value = "/{latentDangerId}", method = RequestMethod.GET)
ResponseModel<Object> getLatentDangerPatrolInfo(@PathVariable Long latentDangerId);
}
package com.yeejoin.amos.latentdanger.business.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
......@@ -17,6 +18,7 @@ import com.yeejoin.amos.latentdanger.business.util.CommonResponseUtil;
import com.yeejoin.amos.latentdanger.business.util.FileHelper;
import com.yeejoin.amos.latentdanger.business.vo.DangerTimeAxisVo;
import com.yeejoin.amos.latentdanger.core.common.response.DangerListResponse;
import com.yeejoin.amos.latentdanger.dao.entity.LatentDanger;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -126,7 +128,7 @@ public class LatentDangerController extends BaseController {
@GetMapping(value = "/detail")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public CommonResponse detail(@ApiParam(value = "任务Id", required = true) @RequestParam String id,
@ApiParam(value = "是否完成", required = true) @RequestParam boolean isFinish) {
@ApiParam(value = "是否完成") @RequestParam(required = false) boolean isFinish) {
try {
AgencyUserModel user = getUserInfo();
if (ObjectUtils.isEmpty(user)) {
......@@ -142,7 +144,7 @@ public class LatentDangerController extends BaseController {
@ApiOperation(value = "隐患执行记录", notes = "隐患执行记录")
@GetMapping(value = "/listFlowRecord")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public CommonResponse listFlowRecord(@ApiParam(value = "隐患编号", required = true) @RequestParam Long id) {
public CommonResponse listFlowRecord(@ApiParam(value = "隐患id", required = true) @RequestParam Long id) {
try {
AgencyUserModel user = getUserInfo();
if (ObjectUtils.isEmpty(user)) {
......@@ -267,7 +269,7 @@ public class LatentDangerController extends BaseController {
if (ObjectUtils.isEmpty(user)) {
return CommonResponseUtil.failure("登录过期,请重新登录");
}
Page<DangerListResponse> result = iLatentDangerService.listDanger(pageParam);
IPage<LatentDanger> result = iLatentDangerService.listDanger(pageParam);
return CommonResponseUtil.success(result);
}
......
......@@ -68,5 +68,5 @@ public interface LatentDangerMapper extends BaseMapper<LatentDanger> {
void updateCheckInputDangerState(@Param("id") Long id, @Param("code") int code);
LatentDangerBo getbyBusinessKey(@Param("businessKey") String businessKey);
LatentDangerBo getByBusinessKey(@Param("businessKey") String businessKey);
}
......@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
......@@ -17,7 +19,6 @@ import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieModel;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.amos.latentdanger.business.constants.Constants;
import com.yeejoin.amos.latentdanger.business.dao.mapper.LatentDangerFlowRecordMapper;
......@@ -72,7 +73,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
......@@ -102,6 +102,9 @@ import java.util.stream.Collectors;
import static com.yeejoin.amos.latentdanger.business.util.RandomUtil.buildOrderNo;
import static org.typroject.tyboot.core.foundation.context.RequestContext.getProduct;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.PageImpl;
//import com.yeejoin.amos.latentdanger.business.feign.Business;
//import com.yeejoin.amos.latentdanger.business.feign.EquipFeign;
......@@ -158,6 +161,9 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
@Value("${workflow.process.definition.key}")
private String workflowProcessDefinitionKey;
@Autowired
private RedisUtils redisUtils;
@Transactional(rollbackFor = Exception.class)
@Override
public CommonResponse saveNormal(LatentDangerNormalParam latentDangerDto, String userId, String userRealName, String departmentId, String departmentName, String companyId, String orgCode, RoleBo role) {
......@@ -223,8 +229,6 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
if (ValidationUtil.isEmpty(bizTypeEnum)) {
return CommonResponseUtil.failure("业务类型有误");
}
// 根据业务类型填充隐患等级枚举 TODO aop
// fillLatentDangerLevelEnum(bizTypeEnum);
List<LatentDanger> dangerList = Lists.newArrayList();
for (LatentDangerDto param : latentDangerDtoList) {
......@@ -267,11 +271,15 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
JSONObject flowJson = new JSONObject();
flowJson.put("photoUrls", Joiner.on(",").join(param.getPhotoUrl()));
// 第一次保存隐患提交记录
LatentDangerFlowRecord inputRecord = saveFlowRecord(instance.getString("id"), "提交隐患", userId, departmentId,
flowJson, latentDanger.getId(), role, LatentDangerExecuteTypeEnum.填写隐患完成.getName(),
latentDanger.getRemark());
if (ValidationUtil.isEmpty(param.getId())) {
// 第一次保存隐患提交记录
LatentDangerFlowRecord inputRecord = saveFlowRecord(instance.getString("id"), "提交隐患", userId, departmentId,
flowJson, latentDanger.getId(), role, LatentDangerExecuteTypeEnum.填写隐患完成.getName(),
latentDanger.getRemark());
latentDanger.setCurrentFlowRecordId(inputRecord.getId());
latentDanger.setInstanceId(instance.getString("id"));
latentDangerMapper.updateById(latentDanger);
}
// TODO 业务自己保存
// if (LatentDangerTypeEnum.计划检查.getCode().equals(latentDangerBo.getDangerType())
// || LatentDangerTypeEnum.无计划检查.getCode().equals(latentDangerBo.getDangerType())) {
......@@ -287,13 +295,8 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
// latentDangerPatrolMapper.save(latentDangerPatrolBo);
// }
latentDanger.setCurrentFlowRecordId(inputRecord.getId());
latentDanger.setInstanceId(instance.getString("id"));
latentDangerMapper.updateById(latentDanger);
// TODO 使用远程调用替换
// LatentDangerPatrolBo patrolBo = latentDangerPatrolMapper.getByDangerId(latentDanger.getId());
// LatentDangerPatrolBo patrolBo = new LatentDangerPatrolBo();
// sendMessage(latentDanger, LatentDangerExecuteTypeEnum.填写隐患完成, patrolBo,
// "巡检隐患排查与治理", this.getNextExecuteUsers(latentDanger.getInstanceId()), userRealName, departmentName);
try {
......@@ -645,6 +648,8 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
@Override
public CommonResponse detail(String id, String userId, boolean isFinish) {
LatentDanger danger = this.baseMapper.selectById(id);
// danger.getDangerState()
JSONObject jsonObject;
if (isFinish) {
jsonObject = remoteWorkFlowService.queryFinishTaskDetail(id);
......@@ -653,16 +658,23 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
}
JSONObject task = jsonObject.getJSONObject("data");
LatentDangerBo latentDangerBo = latentDangerMapper.getbyBusinessKey(task.getString("businessKey"));
LatentDangerBo latentDangerBo = latentDangerMapper.getByBusinessKey(task.getString("businessKey"));
// LatentDangerBo latentDangerBo = latentDangerMapper.getByBusinessKey("20210923163838164");
LatentDangerDetailVo detailVo = new LatentDangerDetailVo();
if (latentDangerBo != null) {
detailVo.setDangerId(latentDangerBo.getId());
detailVo.setId(latentDangerBo.getId());
detailVo.setBizId(latentDangerBo.getBizId());
detailVo.setDangerType(latentDangerBo.getDangerType());
LatentDangerTypeEnum dangerTypeEnum = LatentDangerTypeEnum.getByCode(latentDangerBo.getDangerType());
if (dangerTypeEnum != null) {
detailVo.setDangerTypeName(dangerTypeEnum.getName());
}
if (StringUtils.isEmpty(latentDangerBo.getDangerPosition())) {
detailVo.setPosition(latentDangerBo.getStructureName());
detailVo.setDangerPosition(latentDangerBo.getStructureName());
} else {
detailVo.setPosition(latentDangerBo.getStructureName() + "·" + latentDangerBo.getDangerPosition());
detailVo.setDangerPosition(latentDangerBo.getStructureName() + "·" + latentDangerBo.getDangerPosition());
}
detailVo.setDangerState(latentDangerBo.getDangerState());
......@@ -672,19 +684,19 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
detailVo.setProblemDescription(latentDangerBo.getProblemDescription());
LatentDangerStateEnum dangerStateEnum = LatentDangerStateEnum.getByCode(latentDangerBo.getDangerState());
if (dangerStateEnum != null) {
detailVo.setDangerStateDesc(dangerStateEnum.getName());
detailVo.setDangerStateName(dangerStateEnum.getName());
}
detailVo.setDangerName(latentDangerBo.getDangerName());
detailVo.setLevel(latentDangerBo.getDangerLevel());
detailVo.setName(latentDangerBo.getDangerName());
detailVo.setDangerLevel(latentDangerBo.getDangerLevel());
LatentDangerLevelEnum levelEnum = LatentDangerLevelEnum.getEnumByCode(latentDangerBo.getDangerLevel());
if (levelEnum != null) {
detailVo.setLevelDesc(levelEnum.getName());
detailVo.setDangerLevelName(levelEnum.getName());
}
detailVo.setRemark(latentDangerBo.getRemark());
if (latentDangerBo.getReformType() != null) {
LatentDangerReformTypeEnum typeEnum = LatentDangerReformTypeEnum.getEnumByCode(latentDangerBo.getReformType());
if (typeEnum != null) {
detailVo.setReformTypeDesc(typeEnum.getName());
detailVo.setReformTypeName(typeEnum.getName());
}
}
if (latentDangerBo.getReformLimitDate() != null) {
......@@ -702,7 +714,11 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
List<String> photoUrls = Lists.newArrayList(latentDangerBo.getPhotoUrls().split(","));
detailVo.setPhotoUrls(photoUrls);
}
buildOfDifferentDangerType(latentDangerBo, detailVo);
if (dangerBizType.equals(LatentDangerBizTypeEnum.巡检.getCode())) {
buildOfDifferentDangerType(latentDangerBo, detailVo);
}
detailVo.setTaskId(task.getString("id"));
}
return CommonResponseUtil.success(detailVo);
......@@ -717,6 +733,7 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
private void buildOfDifferentDangerType(LatentDangerBo latentDangerBo, LatentDangerDetailVo detailVo) {
if (latentDangerBo.getDangerType().equals(LatentDangerTypeEnum.计划检查.getCode())
|| latentDangerBo.getDangerType().equals(LatentDangerTypeEnum.无计划检查.getCode())) {
// TODO 使用远程调用替换
LatentDangerPatrolBo patrolBo = latentDangerPatrolMapper.getByDangerId(latentDangerBo.getId());
if (patrolBo != null) {
LatentDangerDetailRiskVo riskVo = new LatentDangerDetailRiskVo();
......@@ -1031,12 +1048,12 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
return CommonResponseUtil.failure("隐患不存在");
}
LatentDangerDetailVo detailVo = new LatentDangerDetailVo();
detailVo.setDangerName(latentDangerBo.getDangerName());
detailVo.setLevel(latentDangerBo.getDangerLevel());
detailVo.setPosition(latentDangerBo.getStructureName());
detailVo.setName(latentDangerBo.getDangerName());
detailVo.setDangerLevel(latentDangerBo.getDangerLevel());
detailVo.setDangerPosition(latentDangerBo.getStructureName());
LatentDangerLevelEnum levelEnum = LatentDangerLevelEnum.getEnumByCode(latentDangerBo.getDangerLevel());
if (levelEnum != null) {
detailVo.setLevelDesc(levelEnum.getName());
detailVo.setDangerLevelName(levelEnum.getName());
}
List<LatentDangerFlowRecordBo> records = latentDangerFlowRecordMapper.listByDangerId(latentDangerBo.getId());
if (!CollectionUtils.isEmpty(records)) {
......@@ -1475,7 +1492,7 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
}
@Override
public Page<DangerListResponse> listDanger(PageParam pageParam) {
public IPage<LatentDanger> listDanger(PageParam pageParam) {
String idsStr = (String) pageParam.get("dangerIds");
if (StringUtil.isNotEmpty(idsStr)) {
List<String> dangerIdList = Lists.newArrayList(idsStr.split(","));
......@@ -1489,11 +1506,7 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
Object structureId = pageParam.get("structureId");
List<Long> structureIdList = null;
if (structureId != null && structureId.toString().trim().length() > 0) {
// LinkedHashMap<String, Object> o = equipFeign.getBuildingTree();
ResponseModel<Object> response = equipFeign.getBuildingTree();
// if (o == null || !"200".equals(o.get("status").toString())) {
// throw new YeeException("获取建筑树出错");
// }
List<Map<String, Object>> buildingTree = (List<Map<String, Object>>) response.getResult();
Map<String, Object> node = getAllNodes(buildingTree).stream().filter(map -> structureId.equals(map.get("id"))).findFirst().orElse(null);
if (node != null) {
......@@ -1501,25 +1514,38 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
}
}
pageParam.put("structureId", structureIdList);
List<DangerListResponse> dangerListResponseList = latentDangerMapper.dangerListByMap(pageParam);
Map<Long, String> buildingAbsolutePositionMap = new HashMap<>();
try {
LinkedHashMap<String, Object> buildingAbsolutePosition = (LinkedHashMap<String, Object>) equipFeign.getBuildingAbsolutePosition().getResult();
if (buildingAbsolutePosition == null || !"200".equals(buildingAbsolutePosition.get("status").toString())) {
throw new YeeException("获取建筑树出错");
}
buildingAbsolutePositionMap = (Map<Long, String>) buildingAbsolutePosition.get("result");
} catch (Exception e) {
}
if (!dangerListResponseList.isEmpty()) {
Map<Long, String> finalBuildingAbsolutePositionMap = buildingAbsolutePositionMap;
dangerListResponseList.forEach(danger -> danger.setStructureName(finalBuildingAbsolutePositionMap.get(danger.getStructureId())));
}
Long count = latentDangerMapper.countDangerListByMap(pageParam);
if (CollectionUtils.isEmpty(dangerListResponseList)) {
return new PageImpl<>(dangerListResponseList, pageParam, 0L);
}
return new PageImpl<>(dangerList(dangerListResponseList), pageParam, count);
IPage<LatentDanger> page = new Page<>((Integer) pageParam.get("pageNumber"),
(Integer) pageParam.get("pageSize"));
page = latentDangerMapper.selectPage(page,
new LambdaQueryWrapper<LatentDanger>().like(ValidationUtil.isEmpty(pageParam.get("name")),
LatentDanger::getDangerName,
pageParam.get("name")).eq(ValidationUtil.isEmpty(pageParam.get("dangerLevel")),
LatentDanger::getDangerLevel,
pageParam.get("dangerLevel")).eq(ValidationUtil.isEmpty(pageParam.get("dangerState")),
LatentDanger
::getDangerState, pageParam.get("dangerState")));
return page;
// List<DangerListResponse> dangerListResponseList = latentDangerMapper.dangerListByMap(pageParam);
// Map<Long, String> buildingAbsolutePositionMap = new HashMap<>();
// try {
// LinkedHashMap<String, Object> buildingAbsolutePosition = (LinkedHashMap<String, Object>) equipFeign.getBuildingAbsolutePosition().getResult();
// if (buildingAbsolutePosition == null || !"200".equals(buildingAbsolutePosition.get("status").toString())) {
// throw new YeeException("获取建筑树出错");
// }
// buildingAbsolutePositionMap = (Map<Long, String>) buildingAbsolutePosition.get("result");
// } catch (Exception e) {
// }
// if (!dangerListResponseList.isEmpty()) {
// Map<Long, String> finalBuildingAbsolutePositionMap = buildingAbsolutePositionMap;
// dangerListResponseList.forEach(danger -> danger.setStructureName(finalBuildingAbsolutePositionMap.get(danger.getStructureId())));
// }
// Long count = latentDangerMapper.countDangerListByMap(pageParam);
// if (CollectionUtils.isEmpty(dangerListResponseList)) {
// return new PageImpl<>(dangerListResponseList, pageParam, 0L);
// }
// return new PageImpl<>(dangerList(dangerListResponseList), pageParam, count);
}
private List<Map<String, Object>> getAllNodes(List<Map<String, Object>> buildingTree) {
......@@ -1536,7 +1562,7 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
private List<Long> findBuildChildrenIds(Map<String, Object> building) {
List<Map<String, Object>> buildingTree = getAllNodes(Collections.singletonList(building));
return buildingTree.stream().map(building123 -> Long.valueOf(building123.get("id").toString())).collect(Collectors.toList());
return buildingTree.stream().map(build -> Long.valueOf(build.get("id").toString())).collect(Collectors.toList());
}
@Override
......
......@@ -3,11 +3,13 @@ package com.yeejoin.amos.latentdanger.business.service.intfc;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.amos.latentdanger.business.param.LatentDangerDto;
import com.yeejoin.amos.latentdanger.business.param.LatentDangerExecuteParam;
import com.yeejoin.amos.latentdanger.business.param.PageParam;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerLevelEnum;
import com.yeejoin.amos.latentdanger.dao.entity.LatentDanger;
import org.springframework.data.domain.Page;
import com.alibaba.fastjson.JSONObject;
......@@ -98,7 +100,7 @@ public interface ILatentDangerService {
*/
JSONObject getReviewInfo(Long dangerId);
Page<DangerListResponse> listDanger(PageParam pageParam);
IPage<LatentDanger> listDanger(PageParam pageParam);
List<DangerListResponse> export(PageParam pageParam);
......
......@@ -6,22 +6,27 @@ import lombok.Data;
import java.util.List;
/**
* @author DELL
*/
@Data
public class LatentDangerDetailVo {
private Long dangerId;
private Long id;
private String dangerName;
private String name;
private String level;
private Long bizId;
private String levelDesc;
private String dangerLevel;
private String dangerLevelName;
private String remark;
private String position;
private String dangerPosition;
private String reformTypeDesc;
private String reformTypeName;
private String reformLimitDate;
......@@ -31,9 +36,11 @@ public class LatentDangerDetailVo {
private String dangerState;
private String dangerStateName;
private String dangerType;
private String dangerStateDesc;
private String dangerTypeName;
private Boolean currentUserCanExcute;
......
......@@ -26,6 +26,10 @@ import java.util.List;
@Aspect
@Component
public class EnumFillAop {
@Autowired
RedisUtils redisUtils;
@Pointcut("execution(public * com.yeejoin.amos.latentdanger.business.controller..*(..))")
public void fillEnum() {
......@@ -40,6 +44,10 @@ public class EnumFillAop {
bizType = request.getParameter("bizType");
}
if (!redisUtils.hasKey(Constants.DANGER_BIZ_TYPE_KEY)) {
redisUtils.set(Constants.DANGER_BIZ_TYPE_KEY, bizType);
}
// 获取隐患等级枚举
if (ValidationUtil.isEmpty(LatentDangerLevelEnum.enumMap)) {
List<DictionarieValueModel> dicResult =
......
......@@ -311,7 +311,7 @@ public class LatentDangerController extends AbstractBaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询隐患信息", notes = "查询隐患信息")
@ApiOperation(value = "查询隐患巡检信息", notes = "查询隐患信息")
@GetMapping(value = "/{latentDangerId}")
public CommonResponse getLatentDanger(@PathVariable(required = true) Long latentDangerId) {
return CommonResponseUtil.success(iLatentDangerService.getLatentDanger(latentDangerId));
......
......@@ -935,7 +935,7 @@
where id = #{id};
</update>
<select id="getbyBusinessKey" resultType="com.yeejoin.amos.latentdanger.business.entity.mybatis.extend.LatentDangerBo">
<select id="getByBusinessKey" resultType="com.yeejoin.amos.latentdanger.business.entity.mybatis.extend.LatentDangerBo">
SELECT
*
FROM
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment