Commit 488fed04 authored by litengwei's avatar litengwei

安装改造适配多流程节点

parent 88b4d200
......@@ -225,4 +225,15 @@ public class JgInstallationNoticeDto extends BaseDto {
@ApiModelProperty(value = "设备使用地点-街道(镇)")
private String streetName;
private List<String> roleIds;
private String dataType ;
private String nextExecuteIds;
private String promoter;
private String instanceStatus;
}
......@@ -367,4 +367,15 @@ public class JgInstallationNotice extends BaseEntity {
@TableField(value ="\"street_name\"")
private String streetName;
@TableField("next_execute_ids")
private String nextExecuteIds;
@TableField(value = "promoter")
private String promoter;
@TableField("instance_status")
private String instanceStatus;
}
......@@ -18,6 +18,9 @@
isn.city_name AS cityName,
isn.county_name AS countyName,
isn.instance_id AS instanceId,
isn.promoter,
isn.next_execute_ids AS nextExecuteIds,
isn.instance_status AS instanceStatus,
isn.notice_report_url AS noticeReportUrl
FROM
tzs_jg_installation_notice isn
......@@ -41,7 +44,7 @@
</if>
</if>
<if test="type == 'supervision'">
AND (isn.notice_status in ('6612', '6613', '6614') or isn.status in('6614') )
AND (isn.notice_status in ('6612', '6613', '6610') )
AND isn.receive_org_credit_code = #{orgCode}
</if>
<if test="type == 'enterprise'">
......
......@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
@FeignClient(name = "TZS-YMT", path = "/ymt", configuration =
@FeignClient(name = "TZS-YMT", path = "/ymt", configuration =
{FeignConfiguration.class})
public interface TzsServiceFeignClient {
......@@ -44,5 +44,21 @@ public interface TzsServiceFeignClient {
ResponseModel<Map<String, Object>> applicationFormCode(@RequestParam("type") String type,
@RequestParam("batchSize") int batchSize);
/**
* 申请单编号生成
* @param key
* @return String
*/
@RequestMapping(value = "/generate-code/deviceRegistrationCode", method = RequestMethod.POST)
ResponseModel<String> deviceRegistrationCode(@RequestParam("key") String key);
/**
* 申请单编号生成
* @param key
* @return String
*/
@RequestMapping(value = "/generate-code/useRegistrationCode", method = RequestMethod.POST)
ResponseModel<String> useRegistrationCode(@RequestParam("key") String key);
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aspose.words.SaveFormat;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -9,6 +10,7 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.module.jg.api.dto.ByteArrayMultipartFile;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
......@@ -44,6 +46,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -174,10 +177,11 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
if (Objects.isNull(noticeDto) || StringUtils.isEmpty(submitType)) {
throw new IllegalArgumentException("参数不能为空");
}
String[] taskName = new String[]{"流程结束"};
// 字段转换
this.convertField(noticeDto);
ArrayList<String> roleListFirst = new ArrayList<>();
ArrayList<String> roleListSecond = new ArrayList<>();
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
AjaxResult ajaxResult;
// 发起流程
......@@ -189,34 +193,32 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
ajaxResult = Workflow.taskClient.startByVariable(dto);
String instanceId = ((Map) ajaxResult.get("data")).get("id").toString();
noticeDto.setInstanceId(instanceId);
// 查询下节点任务
getNext(roleListFirst, instanceId,taskName);
noticeDto.setInstanceStatus(String.join(",", roleListFirst));
} catch (Exception e) {
log.error("提交失败:{}", e);
}
}
ajaxResult = Workflow.taskClient.getTask(noticeDto.getInstanceId());
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");
//组装信息
TaskResultDTO taskResultDTO = new TaskResultDTO();
taskResultDTO.setResultCode("approvalStatus");
taskResultDTO.setTaskId(taskId);
taskResultDTO.setComment("提交流程");
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", op);
taskResultDTO.setVariable(map);
//执行流程
AjaxResult ajaxResult1;
try {
ajaxResult1 = Workflow.taskClient.completeByTask(taskId, taskResultDTO);
if (ajaxResult1.get("code").equals(200)) {
noticeDto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
JgInstallationNotice bean = new JgInstallationNotice();
BeanUtils.copyProperties(noticeDto, bean);
jgInstallationNoticeMapper.updateById(bean);
JgInstallationNotice notice = new JgInstallationNotice();
BeanUtils.copyProperties(noticeDto,notice);
boolean submit = submit(notice, op);
if(submit) {
// 查询下节点任务
getNext(roleListSecond, notice.getInstanceId(),taskName);
notice.setStatus(taskName[0]);
if (!ObjectUtils.isEmpty(notice.getInstanceStatus())) {
notice.setInstanceStatus(notice.getInstanceStatus() + "," + roleListSecond);
} else {
notice.setInstanceStatus(String.join(",", roleListSecond));
}
} catch (Exception e) {
log.error("提交失败:{}", e);
notice.setPromoter(RequestContext.getExeUserId());
notice.setNextExecuteIds(String.join(",", roleListSecond));
notice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
jgInstallationNoticeMapper.updateById(notice);
}
} else {
JgInstallationNotice bean = new JgInstallationNotice();
......@@ -401,6 +403,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@SuppressWarnings({"Duplicates", "rawtypes"})
@Transactional(rollbackFor = Exception.class)
public void saveNotice(String submitType, Map<String, JgInstallationNoticeDto> jgInstallationNoticeDtoMap, ReginParams reginParams) {
String[] taskName = new String[]{"流程结束"};
JgInstallationNoticeDto model = jgInstallationNoticeDtoMap.get(TABLE_PAGE_ID);
// 字段转换
convertField(model);
......@@ -417,6 +421,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
return;
}
ArrayList<String> roleListFirst = new ArrayList<>();
ArrayList<String> roleListSecond = new ArrayList<>();
// 判断当前是否为提交
List<String> instanceIdList = new ArrayList<>();
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
......@@ -429,7 +435,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey(PROCESS_DEFINITION_KEY);
dto.setBusinessKey(String.valueOf(i));
dto.setCompleteFirstTask(true);
// dto.setCompleteFirstTask(true);
list.add(dto);
}
actWorkflowBatchDTO.setProcess(list);
......@@ -440,11 +446,39 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
for (Object obj :returnList
) {
JSONObject jsonObject = JSON.parseObject(JSONObject.toJSONString(obj));
instanceIdList.add(jsonObject.getString("id"));
String instanceId = jsonObject.getString("id");
instanceIdList.add(instanceId);
// 查询下节点任务
if(returnList.get(0).equals(obj)) {
getNext(roleListFirst, instanceId,taskName);
}
// 推动下一个节点
AjaxResult ajaxResult = Workflow.taskClient.getTask(instanceId);
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");
//组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
dto.setComment("提交流程");
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", "0");
dto.setVariable(map);
//执行流程
AjaxResult ajaxResult1 = null;
try {
ajaxResult1 = Workflow.taskClient.completeByTask(taskId, dto);
if (ajaxResult1.get("code").equals(200)) {
getNext(roleListSecond, instanceId,taskName);
} else {
log.error("提交失败");
}
} catch (Exception e) {
log.error("提交失败:{}", e);
}
}
} catch (Exception e) {
e.printStackTrace();
log.error("提交失败:{}", e);
}
}
......@@ -458,6 +492,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
String applyNo = applyNoList.get(i);
dto.setApplyNo(applyNo);
dto.setNoticeDate(new Date());
dto.setNextExecuteIds(String.join(",", roleListSecond));
dto.setInstanceStatus(String.join(",", roleListFirst));
dto.setPromoter(reginParams.getUserModel().getUserId());
dto.setStatus(taskName[0]);
dto.setInstallUnitName(reginParams.getCompany().getCompanyName());
dto.setInstallUnitCreditCode(reginParams.getCompany().getCompanyCode());
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
......@@ -484,6 +522,22 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
void getNext(ArrayList<String> roleListFirst, String instanceId, String[] taskName) {
AjaxResult aj = Workflow.taskClient.getTaskNoAuth(instanceId);
JSONObject taskNoAuth = JSON.parseObject(JSON.toJSONString(aj.get("data")));
if (!ObjectUtils.isEmpty(taskNoAuth)) {
String nextTaskId = taskNoAuth.getString("id");
AjaxResult taskGroupName = Workflow.taskClient.getTaskGroupName(nextTaskId);
taskName[0] = taskNoAuth.getString("name");
JSONArray data = JSON.parseArray(JSON.toJSONString(taskGroupName.get("data")));
for (Object datum : data) {
if (((Map) datum).containsKey("groupId")) {
roleListFirst.add(((Map) datum).get("groupId").toString());
}
}
}
}
private void convertField(JgInstallationNoticeDto model) {
// 处理图片
if(!ValidationUtil.isEmpty(model.getProxyStatementAttachmentList())) {
......@@ -596,16 +650,23 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
public void cancel(JgInstallationNoticeDto noticeDto) {
String[] taskName = new String[]{"流程结束"};
FeignClientResult ajaxResult = Workflow.taskV2Client.rollBack(noticeDto.getInstanceId());
JgInstallationNotice jgInstallationNotice = this.baseMapper.selectById(noticeDto.getSequenceNbr());
ArrayList<String> roleList = new ArrayList<>();
if(ajaxResult.getStatus() == 200) {
getNext(roleList, noticeDto.getInstanceId(),taskName);
jgInstallationNotice.setStatus(taskName[0]);
jgInstallationNotice.setPromoter("");
jgInstallationNotice.setNextExecuteIds(String.join(",", roleList));
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode()));
jgInstallationNoticeMapper.updateById(jgInstallationNotice);
}
}
public void accept(JgInstallationNoticeDto dto,String op) {
String[] taskName = new String[]{"流程结束"};
String userId = RequestContext.getExeUserId();
JgInstallationNotice jgInstallationNotice = this.jgInstallationNoticeMapper.selectById(dto.getSequenceNbr());
// 组装设备注册代码
StringBuffer stringBuffer = new StringBuffer();
......@@ -616,93 +677,80 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
log.error("日期转换失败:{}", e);
}
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId,dto.getSequenceNbr());
JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper);
LambdaQueryWrapper<OtherInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(OtherInfo::getRecord,jgRelationEquip.getEquId());
OtherInfo tzsJgOtherInfo = tzsJgOtherInfoMapper.selectOne(queryWrapper1);
LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(RegistrationInfo::getRecord,jgRelationEquip.getEquId());
RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
stringBuffer.append(tzsJgRegistrationInfo.getEquCategory()).append(jgInstallationNotice.getCity()).append(ym);
String equCode = stringBuffer.toString();
String deviceRegistrationCode = iCreateCodeService.createDeviceRegistrationCode(equCode);
Map<String, Object> map = new HashMap<>();
map.put("cityCode",jgInstallationNotice.getCity());
map.put("countyCode",jgInstallationNotice.getCounty());
map.put("equCategory",tzsJgRegistrationInfo.getEquCategory());
map.put("isXiXian", jgInstallationNotice.getIsXixian() == null ? "0" : jgInstallationNotice.getIsXixian());
Map<String, Object> mapCode;
ResponseModel<Map<String, Object>> code = tzsServiceFeignClient.createCode(map);
mapCode = code.getResult();
LambdaQueryWrapper<SupervisoryCodeInfo> queryWrapper3 = new LambdaQueryWrapper<>();
queryWrapper3.eq(SupervisoryCodeInfo::getSupervisoryCode,mapCode.get("superviseCode").toString());
SupervisoryCodeInfo supervisoryCodeInfo = supervisoryCodeInfoMapper.selectOne(queryWrapper3);
supervisoryCodeInfo.setStatus("1");
supervisoryCodeInfoMapper.updateById(supervisoryCodeInfo);
ArrayList<String> roleList = new ArrayList<>();
boolean submit = submit(jgInstallationNotice, op);
if(submit) {
getNext(roleList, dto.getInstanceId(),taskName);
jgInstallationNotice.setStatus(taskName[0]);
if("0".equals(op)) {
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.HAVE_PROCESSED.getCode()));
this.generateInstallationNoticeReport(jgInstallationNotice.getSequenceNbr());
// 更新其他业务表
tzsJgOtherInfo.setCode96333(mapCode.get("code96333").toString());
tzsJgOtherInfo.setSupervisoryCode(mapCode.get("superviseCode").toString());
tzsJgRegistrationInfo.setEquCode(deviceRegistrationCode);
jgInstallationNotice.setEquRegisterCode(deviceRegistrationCode);
jgInstallationNotice.setSupervisoryCode(mapCode.get("superviseCode").toString());
Map<String,Map<String,Object>> objMap = new HashMap<>();
Map<String,Object> map1 =new HashMap<>();
map1.put("CODE96333",tzsJgOtherInfo.getCode96333() );
map1.put("EQU_CODE",tzsJgRegistrationInfo.getEquCode() );
map1.put("SUPERVISORY_CODE",tzsJgOtherInfo.getSupervisoryCode());
objMap.put(tzsJgOtherInfo.getRecord(),map1);
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap);
tzsJgOtherInfoMapper.updateById(tzsJgOtherInfo);
tzsJgRegistrationInfoMapper.updateById(tzsJgRegistrationInfo);
if(roleList.size() == 0) {
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId,dto.getSequenceNbr());
JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper);
LambdaQueryWrapper<OtherInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(OtherInfo::getRecord,jgRelationEquip.getEquId());
OtherInfo tzsJgOtherInfo = tzsJgOtherInfoMapper.selectOne(queryWrapper1);
LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(RegistrationInfo::getRecord,jgRelationEquip.getEquId());
RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
stringBuffer.append(tzsJgRegistrationInfo.getEquCategory()).append(jgInstallationNotice.getCity()).append(ym);
String equCode = stringBuffer.toString();
ResponseModel<String> responseModel = tzsServiceFeignClient.deviceRegistrationCode(equCode);
String deviceRegistrationCode = responseModel.getResult();
Map<String, Object> map = new HashMap<>();
map.put("cityCode",jgInstallationNotice.getCity());
map.put("countyCode",jgInstallationNotice.getCounty());
map.put("equCategory",tzsJgRegistrationInfo.getEquCategory());
map.put("isXiXian", jgInstallationNotice.getIsXixian() == null ? "0" : jgInstallationNotice.getIsXixian());
Map<String, Object> mapCode;
ResponseModel<Map<String, Object>> code = tzsServiceFeignClient.createCode(map);
mapCode = code.getResult();
LambdaQueryWrapper<SupervisoryCodeInfo> queryWrapper3 = new LambdaQueryWrapper<>();
queryWrapper3.eq(SupervisoryCodeInfo::getSupervisoryCode,mapCode.get("superviseCode").toString());
SupervisoryCodeInfo supervisoryCodeInfo = supervisoryCodeInfoMapper.selectOne(queryWrapper3);
supervisoryCodeInfo.setStatus("1");
supervisoryCodeInfoMapper.updateById(supervisoryCodeInfo);
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.HAVE_PROCESSED.getCode()));
this.generateInstallationNoticeReport(jgInstallationNotice.getSequenceNbr());
// 更新其他业务表
tzsJgOtherInfo.setCode96333(mapCode.get("code96333").toString());
tzsJgOtherInfo.setSupervisoryCode(mapCode.get("superviseCode").toString());
tzsJgRegistrationInfo.setEquCode(deviceRegistrationCode);
jgInstallationNotice.setEquRegisterCode(deviceRegistrationCode);
jgInstallationNotice.setSupervisoryCode(mapCode.get("superviseCode").toString());
Map<String,Map<String,Object>> objMap = new HashMap<>();
Map<String,Object> map1 =new HashMap<>();
map1.put("CODE96333",tzsJgOtherInfo.getCode96333() );
map1.put("EQU_CODE",tzsJgRegistrationInfo.getEquCode() );
map1.put("SUPERVISORY_CODE",tzsJgOtherInfo.getSupervisoryCode());
objMap.put(tzsJgOtherInfo.getRecord(),map1);
jgInstallationNotice.setPromoter("");
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap);
tzsJgOtherInfoMapper.updateById(tzsJgOtherInfo);
tzsJgRegistrationInfoMapper.updateById(tzsJgRegistrationInfo);
} else {
jgInstallationNotice.setNextExecuteIds(String.join(",", roleList));
if (!ObjectUtils.isEmpty(jgInstallationNotice.getInstanceStatus())) {
jgInstallationNotice.setInstanceStatus(jgInstallationNotice.getInstanceStatus() + "," + String.join(",", roleList));
} else {
jgInstallationNotice.setInstanceStatus(String.join(",", roleList));
}
jgInstallationNotice.setPromoter(userId);
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
}
} else {
jgInstallationNotice.setPromoter("");
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode()));
jgInstallationNotice.setStatus(String.valueOf(FlowStatusEnum.REJECTED.getCode()));
}
jgInstallationNoticeMapper.updateById(jgInstallationNotice);
}
// // 组装监管码
// String division = "";
// if (((XIAN.equals(dto.getCity()) || XIAN_YANG.equals(dto.getCity())) && "1".equals(dto.getIsXixian()))) {
// division = "X";
// } else {
// //生成监管码前缀
// Map<String, Object> divisionMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), dto.getCounty());
// division = ObjectUtils.isEmpty(divisionMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), dto.getCity()).get("code").toString() : divisionMap.get("code").toString();
// }
//
// // 组装96333码
// String prefix = "";
// if (((XIAN.equals(dto.getCity()) || XIAN_YANG.equals(dto.getCity())) && "1".equals(dto.getIsXixian()))) {
// prefix = EquipmentCategoryEnum.XXCSM.getValue();
// } else {
// Map<String, Object> elevatorMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), dto.getCounty());
// prefix = ObjectUtils.isEmpty(elevatorMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), dto.getCity()).get("code").toString() : elevatorMap.get("code").toString();
// }
}
}
\ No newline at end of file
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