Commit e5cd9dc0 authored by chenzhao's avatar chenzhao

修改隐患阻断bug

parent 3c9738c6
......@@ -96,7 +96,7 @@ public class LatentDangerController extends BaseController {
String departmentName = getDepartmentName(reginParams);
RoleBo role = reginParams.getRole();
return ResponseHelper.buildResponse(iLatentDangerService.savePatrol(latentDangerDtoList, user.getUserId(),
user.getRealName(), deptId, departmentName, companyId, loginOrgCode, role));
user.getRealName(), deptId, departmentName, companyId, loginOrgCode, role,null));
}
@ApiOperation(value = "隐患列表", notes = "隐患列表")
......@@ -406,7 +406,12 @@ public class LatentDangerController extends BaseController {
@GetMapping(value = "/web/updateStatusByUserIdAndPlandIdLike/{userId}/{plandId}")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel updateStatusByUserIdAndPlandIdLike(@PathVariable String userId,@PathVariable String plandId) {
iLatentDangerService.updateStatusByUserIdAndPlandIdLike(userId,plandId);
return ResponseHelper.buildResponse(null);
ReginParams reginParams = getSelectedOrgInfo();
try {
iLatentDangerService.updateStatusByUserIdAndPlandIdLike(userId,plandId,reginParams);
} catch (Exception e) {
e.printStackTrace();
}
return ResponseHelper.buildResponse(null);
}
}
......@@ -19,6 +19,7 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageImpl;
......@@ -236,8 +237,7 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
}
@Transactional(rollbackFor = Exception.class)
@Override
public List<LatentDanger> savePatrol(List<LatentDangerDto> latentDangerDtoList, String userId, String userRealName,
public List<LatentDanger> savePatrolPlanB(List<LatentDangerDto> latentDangerDtoList, String userId, String userRealName,
String departmentId, String departmentName, String companyId, String orgCode, RoleBo role)
throws Exception {
if (ValidationUtil.isEmpty(latentDangerDtoList)) {
......@@ -294,7 +294,8 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
if (!ValidationUtil.isEmpty(param.getPhotoUrl())) {
flowJson.put("photoUrls", Joiner.on(",").join(param.getPhotoUrl()));
}
if (ValidationUtil.isEmpty(param.getId()) && !"draft".equals(latentDanger.getDangerState())) {
if (!ValidationUtil.isEmpty(param.getId()) && !"draft".equals(latentDanger.getDangerState()) || !ValidationUtil.isEmpty(param.getId()) &&"dangerSubmit".equals(latentDanger.getDangerState()) ) {
// 第一次保存隐患提交记录
LatentDangerFlowRecord inputRecord = saveFlowRecord(instance.getString("id"), "提交隐患", userId,
departmentId, flowJson, latentDanger.getId(), role,
......@@ -321,6 +322,109 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
return dangerList;
}
@Transactional(rollbackFor = Exception.class)
@Override
public List<LatentDanger> savePatrol(List<LatentDangerDto> latentDangerDtoList, String userId, String userRealName,
String departmentId, String departmentName, String companyId, String orgCode, RoleBo role,String flag)
throws Exception {
if (ValidationUtil.isEmpty(latentDangerDtoList)) {
throw new Exception("参数有误");
}
// 获取业务类型枚举
LatentDangerBizTypeEnum bizTypeEnum = LatentDangerBizTypeEnum.getByCode(bizType);
if (ValidationUtil.isEmpty(bizTypeEnum)) {
throw new Exception("业务类型有误");
}
List<LatentDanger> dangerList = Lists.newArrayList();
for (LatentDangerDto param : latentDangerDtoList) {
String businessKey = RandomUtil.buildOrderNo();
LatentDangerLevelEnum levelEnum = LatentDangerLevelEnum.getEnumByCode(param.getDangerLevel());
if (levelEnum == null) {
throw new Exception("隐患等级参数有误");
}
LatentDangerTypeEnum dangerTypeEnum = LatentDangerTypeEnum
.getByCode(latentDangerDtoList.get(0).getCheckMode());
if (ValidationUtil.isEmpty(dangerTypeEnum)) {
throw new Exception("检查类型参数有误");
}
Date endTime = DateUtils.getTargetEndTime(param.getReformLimitDate());
param.setReformLimitDate(endTime);
// 保存隐患
LatentDanger latentDanger = importSaveLatentDanger(param, userId, departmentId, businessKey, orgCode,
dangerTypeEnum);
JSONObject instance = new JSONObject();
// 巡检业务需要在填写隐患后直接开启工作流
if (bizTypeEnum == LatentDangerBizTypeEnum.巡检) {
// 更新巡检p_check_input表state字段
updateCheckInputDangerState(latentDanger.getBizId(), DangerHandleStateEnum.HANDLE.getCode());
Long dangerId = latentDanger.getId();
Date startDate = new Date();
JSONObject jsonObject = remoteWorkFlowService.startNew(dangerId, businessKey, processDefinitionKey);
Date endDate = new Date();
logger.info("-------------------------提交隐患时间" + (endDate.getTime() - startDate.getTime()));
if (jsonObject == null) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new Exception("启动流程失败");
}
instance = jsonObject.getJSONObject("data");
if (instance == null) {
throw new Exception("无提交隐患权限");
}
}
JSONObject flowJson = new JSONObject();
if (!ValidationUtil.isEmpty(param.getPhotoUrl())) {
flowJson.put("photoUrls", Joiner.on(",").join(param.getPhotoUrl()));
}
//为不影响其他业余 加一个判断 flag == 1 是外部单位导入的隐患
if (flag == null){
if (ValidationUtil.isEmpty(param.getId()) && !"draft".equals(latentDanger.getDangerState()) ) {
// 第一次保存隐患提交记录
LatentDangerFlowRecord inputRecord = saveFlowRecord(instance.getString("id"), "提交隐患", userId,
departmentId, flowJson, latentDanger.getId(), role,
LatentDangerExecuteTypeEnum.填写隐患完成.getName(), latentDanger.getRemark(), userRealName,
departmentName, latentDanger.getDangerState(), ExecuteTypeEnum.通过.getCode());
latentDanger.setCurrentFlowRecordId(inputRecord.getId());
latentDanger.setInstanceId(instance.getString("id"));
latentDangerMapper.updateById(latentDanger);
ruleDangerService.addLatentDangerRule(latentDanger, RuleTypeEnum.隐患第一次提交.getCode(), onSiteConfirmRole);
}
}else if(flag.equals("1")){
if (!ValidationUtil.isEmpty(param.getId()) && !"draft".equals(latentDanger.getDangerState()) ) {
// 第一次保存隐患提交记录
LatentDangerFlowRecord inputRecord = saveFlowRecord(instance.getString("id"), "提交隐患", userId,
departmentId, flowJson, latentDanger.getId(), role,
LatentDangerExecuteTypeEnum.填写隐患完成.getName(), latentDanger.getRemark(), userRealName,
departmentName, latentDanger.getDangerState(), ExecuteTypeEnum.通过.getCode());
latentDanger.setCurrentFlowRecordId(inputRecord.getId());
latentDanger.setInstanceId(instance.getString("id"));
latentDangerMapper.updateById(latentDanger);
ruleDangerService.addLatentDangerRule(latentDanger, RuleTypeEnum.隐患第一次提交.getCode(), onSiteConfirmRole);
}
}
// TODO 使用远程调用替换
// LatentDangerPatrolBo patrolBo = latentDangerPatrolMapper.getByDangerId(latentDanger.getId());
// sendMessage(latentDanger, LatentDangerExecuteTypeEnum.填写隐患完成, patrolBo,
// "巡检隐患排查与治理", this.getNextExecuteUsers(latentDanger.getInstanceId()), userRealName, departmentName);
// try {
// webMqttComponent.publish(dangerTopic, "");
// } catch (Exception e) {
// logger.error("巡检隐患提交数字换流站页面推送失败-----------" + e.getMessage());
// }
dangerList.add(latentDanger);
}
return dangerList;
}
// TODO 使用远程调用替换
// private void updateMeasuresContentStatus(Long riskFactorId, Long measuresContentId, String evaluateId, RiskFactorsCmStatusEnum riskFactorsCmStatusEnum) {
// Map<String, Object> map = Maps.newHashMap();
......@@ -446,7 +550,8 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
latentDanger.setPhotoUrls(Joiner.on(",").join(dangerDto.getPhotoUrl()));
}
this.saveOrUpdate(latentDanger);
return latentDanger;
return latentDangerMapper.selectById(latentDanger.getId());
//return latentDanger;
}
public LatentDangerFlowRecord saveFlowRecord(String taskId, String taskName, String userId, String departmentId,
......@@ -2597,7 +2702,7 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
return resultMap;
}
public void updateStatusByUserIdAndPlandIdLike(String userId,String plandId){
public void updateStatusByUserIdAndPlandIdLike(String userId,String plandId,ReginParams reginParams) throws Exception{
String plandId1 ="planId\""+":"+"\""+plandId;
List<LatentDanger> list =latentDangerMapper.updateStatusByUserIdAndPlandIdLike(userId, plandId1);
list.stream().forEach(i->{
......@@ -2605,6 +2710,39 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
i.setDangerStateName(LatentDangerState.SupervisionDangerStateEnum.提交隐患.getName());
});
this.saveOrUpdateBatch(list);
// this.saveOrUpdateBatch(list);
List<LatentDangerDto> dangerDtos = Lists.newArrayList();
for (LatentDanger latentDanger : list) {
LatentDangerDto latentDangerDto = new LatentDangerDto();
BeanUtils.copyProperties(latentDanger,latentDangerDto);
latentDangerDto.setCheckMode(latentDanger.getDangerType());
dangerDtos.add(latentDangerDto);
}
String userRealName = null;
String departmentId = null;
String departmentName = null;
String companyId = null;
String orgCode = null;
RoleBo role = null;
if (reginParams.getPersonIdentity() != null){
userRealName = reginParams.getPersonIdentity().getPersonName();
}
if (reginParams.getDepartment().getSequenceNbr() != null) {
departmentId =reginParams.getDepartment().getSequenceNbr().toString();
}
if (reginParams.getDepartment().getDepartmentName() != null) {
departmentName = reginParams.getDepartment().getDepartmentName();
}
if (reginParams.getCompany() != null) {
companyId = reginParams.getCompany().getSequenceNbr().toString();
orgCode =reginParams.getCompany().getOrgCode();
}
if (reginParams.getRole() != null) {
role = reginParams.getRole();
}
this.savePatrol(dangerDtos,userId,userRealName,departmentId,departmentName,companyId,orgCode,role,"1");
}
}
\ No newline at end of file
......@@ -38,7 +38,7 @@ public interface ILatentDangerService {
String departmentId, String departmentName, String companyId, String orgCode, RoleBo role);
List<LatentDanger> savePatrol(List<LatentDangerDto> latentDangerDtoList, String userId, String userRealName,
String departmentId, String departmentName, String companyId, String orgCode, RoleBo role) throws Exception;
String departmentId, String departmentName, String companyId, String orgCode, RoleBo role,String flag) throws Exception;
CommonResponse list(String toke, String product, String appKey, LatentDangerListParam latentDangerListParam, AgencyUserModel user, String loginOrgCode, String deptId);
......@@ -195,5 +195,5 @@ public interface ILatentDangerService {
public Map<String, Integer> currentLandgerCount(String companyId,String loginOrgCode);
void updateStatusByUserIdAndPlandIdLike(String userId, String planId);
void updateStatusByUserIdAndPlandIdLike(String userId, String planId,ReginParams reginParams) throws Exception;
}
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