Commit 3460a338 authored by zhangsen's avatar zhangsen

更名变更API开发

parent 1ac231f2
package com.yeejoin.amos.boot.module.jg.api.dto; package com.yeejoin.amos.boot.module.jg.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto; import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
...@@ -84,4 +85,16 @@ public class JgChangeRegistrationNameDto extends BaseDto { ...@@ -84,4 +85,16 @@ public class JgChangeRegistrationNameDto extends BaseDto {
@ApiModelProperty(value = "任务发起人id") @ApiModelProperty(value = "任务发起人id")
private String promoter; private String promoter;
/**
* 流程状态
*/
@TableField("instance_status")
private String instanceStatus;
private List<String> roleIds;
// 区分监管和企业
private String type;
} }
...@@ -136,4 +136,10 @@ public class JgChangeRegistrationName extends BaseEntity { ...@@ -136,4 +136,10 @@ public class JgChangeRegistrationName extends BaseEntity {
@TableField("promoter") @TableField("promoter")
private String promoter; private String promoter;
/**
* 流程状态
*/
@TableField("instance_status")
private String instanceStatus;
} }
...@@ -49,6 +49,15 @@ public enum WorkFlowStatusEnum { ...@@ -49,6 +49,15 @@ public enum WorkFlowStatusEnum {
CHANGE_REEXAMINE("三级受理", "changeReexamine", "三级待受理", "", ""), CHANGE_REEXAMINE("三级受理", "changeReexamine", "三级待受理", "", ""),
/** /**
* 更名变更登记流程
*/
UNIT_RENAME_SUBMIT("使用单位提交", "unitRenameSubmit", "使用单位待提交", "一级受理已驳回", "使用单位已撤回"),
UNIT_RENAME_RECEIVE("一级受理", "unitRenameReceive", "一级待受理", "二级受理已驳回", "一级受理已撤回"),
UNIT_RENAME_PRELIMINARY("二级受理", "unitRenamePreliminary", "二级待受理", "三级受理已驳回", "二级受理已撤回"),
UNIT_RENAME_REEXAMINE("三级受理", "unitRenameReexamine", "三级待受理", "", ""),
/**
* 移装变更登记流程 * 移装变更登记流程
*/ */
TRANSFER_SUBMIT("使用单位提交", "transferSubmit", "使用单位待提交", "一级受理已驳回", "使用单位已撤回"), TRANSFER_SUBMIT("使用单位提交", "transferSubmit", "使用单位待提交", "一级受理已驳回", "使用单位已撤回"),
......
package com.yeejoin.amos.boot.module.jg.api.mapper; package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationNameDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgScrapCancelDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationName; import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationName;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -16,4 +19,8 @@ import java.util.Map; ...@@ -16,4 +19,8 @@ import java.util.Map;
public interface JgChangeRegistrationNameMapper extends BaseMapper<JgChangeRegistrationName> { public interface JgChangeRegistrationNameMapper extends BaseMapper<JgChangeRegistrationName> {
List<Map<String, Object>> getEquipInfoByOrgCode(@Param("code") String code); List<Map<String, Object>> getEquipInfoByOrgCode(@Param("code") String code);
void deleteByChangeRegistrationId(@Param("changeRegistrationId") Long changeRegistrationId);
Page<Map<String, Object>> getListPage(Page<Map<String, Object>> page, JgChangeRegistrationNameDto dto, List<String> roleIds, String orgCode);
} }
package com.yeejoin.amos.boot.module.jg.api.service;
/**
* 更名变更登记接口类
*
* @author system_generator
* @date 2023-12-25
*/
public interface IJgChangeRegistrationNameService {
}
...@@ -14,4 +14,47 @@ ...@@ -14,4 +14,47 @@
WHERE WHERE
USE_UNIT_CREDIT_CODE = #{code} USE_UNIT_CREDIT_CODE = #{code}
</select> </select>
<delete id="deleteByChangeRegistrationId">
delete from tzs_jg_change_registration_name_eq where name_change_registration_id = #{changeRegistrationId}
</delete>
<select id="getListPage" resultType="java.util.Map">
select ur.sequence_nbr as sequenceNbr,
ur.instance_id as instanceId,
ur.audit_status as auditStatus,
ur.apply_no as applyNo,
DATE_FORMAT(ur.rec_date,'%Y-%m-%d') as recDate,
DATE_FORMAT(ur.create_date,'%Y-%m-%d') as createDate,
DATE_FORMAT(ur.audit_pass_date,'%Y-%m-%d') as auditPassDate,
ur.receive_org_code as receiveOrgCode,
ur.receive_org_name as receiveOrgName,
ur.receive_company_code as receiveCompanyCode,
ur.use_unit_name as useUnitName,
ur.new_use_unit_name AS newUseUnitName,
ur.promoter,
ur.next_executor_ids as nextExecutorIds
from tzs_jg_change_registration_name ur
<where>
and ur.is_delete = 0
<if test="dto.auditStatus != null and dto.auditStatus != ''">
and ur.audit_status = #{dto.auditStatus}
</if>
<if test="dto.applyNo != null and dto.applyNo != ''">
and ur.apply_no like concat('%',#{dto.applyNo},'%')
</if>
<if test="roleIds != null and dto.type == 'supervision'">
<foreach collection='roleIds' item='role' open='and (' close=')' separator='or'>
ur.instance_status like concat('%',#{role},'%')
</foreach>
</if>
<if test="dto.type == 'supervision'">
AND ur.receive_org_code = #{orgCode}
</if>
<if test="dto.type == 'enterprise' ">
and ur.use_unit_code = #{orgCode}
</if>
</where>
order by ur.rec_date desc
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.jg.biz.controller;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.dto.JgScrapCancelDto;
import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.*;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationNameServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationNameDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
/**
* 更名变更登记
*
* @author system_generator
* @date 2023-12-25
*/
@RestController
@Api(tags = "更名变更登记Api")
@RequestMapping(value = "/jg-change-registration-name")
public class JgChangeRegistrationNameController extends BaseController {
@Autowired
JgChangeRegistrationNameServiceImpl jgChangeRegistrationNameService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增/新增并提交", notes = "新增/新增并提交")
public ResponseModel<Object> save(@RequestParam String submitType, @RequestBody Map<String, JSONObject> model) {
jgChangeRegistrationNameService.save(submitType, model);
return ResponseHelper.buildResponse("ok");
}
/**
* 根据sequenceNbr更新
*
* @param model 安装告知
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/updateInfo")
@ApiOperation(httpMethod = "POST", value = "编辑API", notes = "编辑API")
public ResponseModel<JgChangeRegistrationNameDto> updateInfo(@RequestParam String submitType,
@RequestBody Map<String, Object> model,
@RequestParam(value = "op", required = false) String op) {
JgChangeRegistrationNameDto dto = BeanUtil.mapToBean(((LinkedHashMap) model.get("jgRegistrationInfo")), JgChangeRegistrationNameDto.class, true);
if (Objects.isNull(dto)) {
throw new IllegalArgumentException("参数jgRegistrationInfo不能为空");
}
Object o = ((LinkedHashMap<?, ?>) model.get("jgRegistrationInfo")).get("changeCertificateList");
dto.setChangeCertificateList((List<Map<String, Object>>) o);
return ResponseHelper.buildResponse(jgChangeRegistrationNameService.updateInfo(submitType, dto, op));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/deleteMessage")
@ApiOperation(httpMethod = "POST", value = "单个删除", notes = "单个删除")
public ResponseModel<Object> deleteMessage(@RequestParam("id") Long id) {
List<Long> ids = Collections.singletonList(id);
jgChangeRegistrationNameService.deleteBatch(ids);
return ResponseHelper.buildResponse("ok");
}
/**
* 撤回
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/withdraw")
@ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回")
public ResponseModel<Object> revocation(@RequestBody JSONObject map) {
jgChangeRegistrationNameService.revocation(String.valueOf(map.get("instanceId")));
return ResponseHelper.buildResponse("ok");
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/flowExecute")
@ApiOperation(httpMethod = "POST", value = "执行流程", notes = "执行流程")
public ResponseModel<Object> flowExecute(@RequestBody JSONObject map) {
LinkedHashMap model1 = (LinkedHashMap) map.get("model");
LinkedHashMap jgRegistrationInfoMap = (LinkedHashMap) model1.get("jgRegistrationInfo");
JgChangeRegistrationNameDto jgScrapCancelDto = JSON.parseObject(JSON.toJSONString(jgRegistrationInfoMap), JgChangeRegistrationNameDto.class);
jgChangeRegistrationNameService.flowExecute(Long.valueOf(String.valueOf(jgScrapCancelDto.getSequenceNbr())), jgScrapCancelDto.getInstanceId(), String.valueOf(map.get("operate")), String.valueOf(map.get("opinion")));
return ResponseHelper.buildResponse("ok");
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "列表全部数据查询", notes = "列表全部数据查询")
@PostMapping(value = "/getList")
public ResponseModel<Page<Map<String, Object>>> getList(@RequestBody JgChangeRegistrationNameDto dto,
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page<Map<String, Object>> page = new Page<>(current, size);
return ResponseHelper.buildResponse(jgChangeRegistrationNameService.getList(dto, page, dto.getRoleIds()));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/details")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个详情", notes = "根据sequenceNbr查询单个详情")
public ResponseModel<Map<String, Object>> selectOne(@RequestParam(required = false, value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(jgChangeRegistrationNameService.queryBySequenceNbr(sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "列表筛选办理状态下拉", notes = "列表筛选办理状态下拉")
@GetMapping(value = "/getAuditStatusList")
public ResponseModel<List<Map<String, String>>> getAuditStatusList(@RequestParam(value = "code") String code) {
return ResponseHelper.buildResponse(WorkFlowStatusEnum.getInfoList(code));
}
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
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.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.JgScrapCancelDto;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.CancelTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgChangeRegistrationNameMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationNameService;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationNameDto;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.flc.api.fegin.WorkFlowFeignService;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.flc.api.feign.AccessFeignService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.AjaxResult;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*;
/**
* 更名变更登记服务实现类
*
* @author system_generator
* @date 2023-12-25
*/
@Service
public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeRegistrationNameDto, JgChangeRegistrationName, JgChangeRegistrationNameMapper> implements IJgChangeRegistrationNameService {
@Autowired
private JgChangeRegistrationNameEqServiceImpl jgChangeRegistrationNameEqService;
@Autowired
RedisUtils redisUtils;
@Autowired
JgChangeRegistrationNameMapper jgChangeRegistrationNameMapper;
@Autowired
TzsServiceFeignClient tzsServiceFeignClient;
@Autowired
WorkFlowFeignService workFlowFeignService;
@Autowired
AccessFeignService accessFeignService;
@Transactional(rollbackFor = Exception.class)
public void save(String submitType, Map<String, JSONObject> jgRegistrationInfoMap) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String[] taskName = new String[]{"流程结束"};
JSONObject jgRegistrationInfo = jgRegistrationInfoMap.get("jgRegistrationInfo");
JgChangeRegistrationNameDto model = JSON.parseObject(jgRegistrationInfo.toJSONString(), JgChangeRegistrationNameDto.class);
List<Map<String, Object>> deviceList = jgChangeRegistrationNameMapper.getEquipInfoByOrgCode(reginParams.getCompany().getCompanyCode());
// 获取告知单号
ResponseModel<List<String>> listResponseModel = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.SBZX.getCode(), 1);
if (!ObjectUtils.isEmpty(listResponseModel) && listResponseModel.getStatus() != HttpStatus.OK.value()) {
log.error(" 获取告知单号失败");
throw new RuntimeException();
}
List<String> applyNoList = listResponseModel.getResult();
if (CollectionUtils.isEmpty(applyNoList)) {
return;
}
ArrayList<String> roleListFirst = new ArrayList<>();
ArrayList<String> roleListSecond = new ArrayList<>();
// 判断当前是否为提交
List<String> instanceIdList = new ArrayList<>();
if ("1".equals(submitType)) {
// 发起流程
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
List<ActWorkflowStartDTO> list = new ArrayList<>();
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey("renovationRegistrationReview2");
dto.setBusinessKey("1");
list.add(dto);
actWorkflowBatchDTO.setProcess(list);
try {
FeignClientResult result = Workflow.taskV2Client.startByVariableBatch(actWorkflowBatchDTO);
List<Object> returnList = (List<Object>) result.getResult();
for (Object obj : returnList) {
JSONObject jsonObject = JSON.parseObject(JSONObject.toJSONString(obj));
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 dto2 = new TaskResultDTO();
dto2.setResultCode("approvalStatus");
dto2.setTaskId(taskId);
dto2.setComment("提交流程");
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", "0");
dto2.setVariable(map);
//执行流程
AjaxResult ajaxResult1 = null;
try {
ajaxResult1 = Workflow.taskClient.completeByTask(taskId, dto2);
if (ajaxResult1.get("code").equals(200)) {
getNext(roleListSecond, instanceId, taskName);
roleListFirst.addAll(roleListSecond);
} else {
log.error("提交失败");
}
} catch (Exception e) {
log.error("提交失败:{}", e);
}
}
} catch (Exception e) {
log.error("提交失败:{}", e);
}
}
JgChangeRegistrationName dto = new JgChangeRegistrationName();
// 字段转换
convertField(model);
BeanUtils.copyProperties(model, dto);
dto.setApplyNo(applyNoList.get(0));
dto.setCreateDate(new Date());
dto.setNextExecutorIds(String.join(",", roleListSecond));
dto.setInstanceStatus(String.join(",", roleListFirst));
dto.setPromoter(reginParams.getUserModel().getUserId());
if (!CollectionUtils.isEmpty(instanceIdList)) {
dto.setInstanceId(instanceIdList.get(0));
dto.setAuditStatus(String.valueOf(WorkFlowStatusEnum.UNIT_RENAME_RECEIVE.getPass()));
} else {
dto.setAuditStatus(String.valueOf(WorkFlowStatusEnum.UNIT_RENAME_SUBMIT.getPass()));
}
dto.setUseUnitCreditCode(reginParams.getCompany().getCompanyCode());
dto.setUseUnitName(reginParams.getCompany().getCompanyName());
this.save(dto);
List<JgChangeRegistrationNameEq> equipList = new ArrayList<>();
deviceList.forEach(obj -> {
JgChangeRegistrationNameEq jgRelationEquip = new JgChangeRegistrationNameEq();
jgRelationEquip.setEquId(String.valueOf(obj.get("equipId")));
jgRelationEquip.setNameChangeRegistrationId(String.valueOf(dto.getSequenceNbr()));
jgRelationEquip.setIsInvalid("0");
jgRelationEquip.setCreateDate(dto.getCreateDate());
jgRelationEquip.setCreateUserId(reginParams.getUserModel().getUserId());
jgRelationEquip.setCreateUserName(reginParams.getUserModel().getRealName());
equipList.add(jgRelationEquip);
JgRegistrationHistory jgRegistrationHistory = new JgRegistrationHistory();
jgRegistrationHistory.setCreateUserId(reginParams.getUserModel().getUserId());
jgRegistrationHistory.setCreateDate(dto.getCreateDate());
// jgRegistrationHistory.setUseRegistrationCode();
// jgRegistrationHistory.setRegistrationClass();
});
jgChangeRegistrationNameEqService.saveBatch(equipList);
}
public JgChangeRegistrationNameDto updateInfo(String submitType, JgChangeRegistrationNameDto jgChangeRegistrationNameDto, String op) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (Objects.isNull(jgChangeRegistrationNameDto) || StringUtils.isEmpty(submitType)) {
throw new IllegalArgumentException("参数不能为空");
}
String[] taskName = new String[]{"流程结束"};
// 字段转换
this.convertField(jgChangeRegistrationNameDto);
ArrayList<String> roleListFirst = new ArrayList<>();
ArrayList<String> roleListSecond = new ArrayList<>();
if ("1".equals(submitType)) {
AjaxResult ajaxResult;
// 发起流程
if (!StringUtils.hasText(jgChangeRegistrationNameDto.getInstanceId())) {
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey("renovationRegistrationReview2");
dto.setBusinessKey("1");
try {
ajaxResult = Workflow.taskClient.startByVariable(dto);
String instanceId = ((Map) ajaxResult.get("data")).get("id").toString();
jgChangeRegistrationNameDto.setInstanceId(instanceId);
// 查询下节点任务
getNext(roleListFirst, instanceId, taskName);
jgChangeRegistrationNameDto.setInstanceStatus(String.join(",", roleListFirst));
} catch (Exception e) {
log.error("提交失败:{}", e);
}
}
JgChangeRegistrationName jgChangeRegistrationName = this.getById(jgChangeRegistrationNameDto.getSequenceNbr());
BeanUtils.copyProperties(jgChangeRegistrationNameDto, jgChangeRegistrationName);
boolean submit = submit(jgChangeRegistrationName, op);
//删除重新生成 eq表数据
jgChangeRegistrationNameMapper.deleteByChangeRegistrationId(jgChangeRegistrationName.getSequenceNbr());
List<Map<String, Object>> deviceList = jgChangeRegistrationNameMapper.getEquipInfoByOrgCode(reginParams.getCompany().getCompanyCode());
List<JgChangeRegistrationNameEq> equipList = new ArrayList<>();
deviceList.forEach(obj -> {
JgChangeRegistrationNameEq jgRelationEquip = new JgChangeRegistrationNameEq();
jgRelationEquip.setEquId(String.valueOf(obj.get("equipId")));
jgRelationEquip.setNameChangeRegistrationId(String.valueOf(jgChangeRegistrationName.getSequenceNbr()));
jgRelationEquip.setIsInvalid("0");
jgRelationEquip.setCreateDate(jgChangeRegistrationName.getCreateDate());
jgRelationEquip.setCreateUserId(reginParams.getUserModel().getUserId());
jgRelationEquip.setCreateUserName(reginParams.getUserModel().getRealName());
equipList.add(jgRelationEquip);
});
jgChangeRegistrationNameEqService.saveBatch(equipList);
if (submit) {
// 查询下节点任务
getNext(roleListSecond, jgChangeRegistrationName.getInstanceId(), taskName);
String join = String.join(",", roleListSecond);
if (!ObjectUtils.isEmpty(jgChangeRegistrationName.getInstanceStatus())) {
jgChangeRegistrationName.setInstanceStatus(jgChangeRegistrationName.getInstanceStatus() + "," + join);
} else {
jgChangeRegistrationName.setInstanceStatus(String.join(",", roleListSecond));
}
jgChangeRegistrationName.setPromoter(RequestContext.getExeUserId());
jgChangeRegistrationName.setNextExecutorIds(String.join(",", roleListSecond));
jgChangeRegistrationName.setAuditStatus(String.valueOf(WorkFlowStatusEnum.UNIT_RENAME_RECEIVE.getPass()));
this.updateById(jgChangeRegistrationName);
}
} else {
JgChangeRegistrationName bean = new JgChangeRegistrationName();
BeanUtils.copyProperties(jgChangeRegistrationNameDto, bean);
this.updateById(bean);
}
return jgChangeRegistrationNameDto;
}
public boolean submit(JgChangeRegistrationName notice, String op) {
AjaxResult ajaxResult = Workflow.taskClient.getTask(notice.getInstanceId());
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", op);
dto.setVariable(map);
//执行流程
AjaxResult ajaxResult1 = null;
try {
ajaxResult1 = Workflow.taskClient.completeByTask(taskId, dto);
if (ajaxResult1.get("code").equals(200)) {
return true;
} else {
return false;
}
} catch (Exception e) {
log.error("提交失败:{}", e);
return false;
}
}
private void convertField(JgChangeRegistrationNameDto model) {
// 处理文件
if (!ValidationUtil.isEmpty(model.getChangeCertificateList())) {
model.setChangeCertificate(JSON.toJSONString(model.getChangeCertificateList()));
}
String receiveOrgId = model.getReceiveOrgCode();
if (!ObjectUtils.isEmpty(receiveOrgId)) {
String[] receiveOrgIdList = receiveOrgId.split("_");
if (receiveOrgIdList.length > 1) {
model.setReceiveOrgCode(receiveOrgIdList[0]);
model.setReceiveOrgName(receiveOrgIdList[1]);
}
}
}
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());
}
}
}
}
public void deleteBatch(List<Long> ids) {
JgChangeRegistrationName jgChangeRegistrationName = new JgChangeRegistrationName();
jgChangeRegistrationName.setIsDelete(true);
LambdaQueryWrapper<JgChangeRegistrationName> lambda = new QueryWrapper<JgChangeRegistrationName>().lambda();
lambda.in(JgChangeRegistrationName::getSequenceNbr, ids);
this.update(jgChangeRegistrationName, lambda);
}
public void revocation(String instanceId) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName();
JgChangeRegistrationName jgChangeRegistrationName = new JgChangeRegistrationName();
LambdaQueryWrapper<JgChangeRegistrationName> lambda = new QueryWrapper<JgChangeRegistrationName>().lambda();
lambda.eq(JgChangeRegistrationName::getInstanceId, instanceId);
ArrayList<String> roleList = new ArrayList<>();
try {
workFlowFeignService.rollBack(instanceId);
JSONObject taskNoAuth = workFlowFeignService.getTaskNoAuth(instanceId);
JSONObject nextTask = JSON.parseObject(JSON.toJSONString(taskNoAuth.get("data")));
if (!ObjectUtils.isEmpty(taskNoAuth.get("data"))) {
String nextTaskId = nextTask.getString("id");
FeignClientResult<JSONObject> nodeInfo = workFlowFeignService.getNodeInfo(nextTaskId);
JSONObject result = nodeInfo.getResult();
Map<String, Object> taskInfo = (Map<String, Object>) result.get("taskInfo");
taskCode = String.valueOf(taskInfo.get("taskDefinitionKey"));
AjaxResult taskGroupName = Workflow.taskClient.getTaskGroupName(nextTaskId);
JSONArray data = JSON.parseArray(JSON.toJSONString(taskGroupName.get("data")));
for (Object datum : data) {
if (((Map<?, ?>) datum).containsKey("groupId")) {
roleList.add(((Map<?, ?>) datum).get("groupId").toString());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (!FlowStatusEnum.TO_BE_FINISHED.getName().equals(taskCode)) {
jgChangeRegistrationName.setAuditStatus(WorkFlowStatusEnum.getMessage(taskCode).getRollBack());
}
String join = String.join(",", roleList);
jgChangeRegistrationName.setPromoter(reginParams.getUserModel().getUserId());
jgChangeRegistrationName.setNextExecutorIds(join);
this.update(jgChangeRegistrationName, lambda);
}
public void flowExecute(Long id, String instanceId, String operate, String comment) {
try {
JSONObject task = workFlowFeignService.getTaskNoAuth(instanceId);
JSONObject taskMessage = JSON.parseObject(JSON.toJSONString(task.get("data")));
String taskId = taskMessage.getString("id");
//组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
dto.setComment(comment);
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", operate);
dto.setVariable(map);
//执行流程
Workflow.taskClient.completeByTask(taskId, dto);
} catch (Exception e) {
e.printStackTrace();
}
// 更新下一步执行人
updateExecuteIds(instanceId, id, operate);
}
public void updateExecuteIds(String instanceId, Long sequenceNbr, String operate) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String role = "";
String taskCode = FlowStatusEnum.TO_BE_FINISHED.getName();
ArrayList<String> roleList = new ArrayList<>();
JgChangeRegistrationName jgChangeRegistrationName = this.getBaseMapper().selectById(sequenceNbr);
try {
// 查询下节点任务
JSONObject taskNoAuth = workFlowFeignService.getTaskNoAuth(instanceId);
if (!ObjectUtils.isEmpty(taskNoAuth.get("data"))) {
JSONObject nextTask = JSON.parseObject(JSON.toJSONString(taskNoAuth.get("data")));
String nextTaskId = nextTask.getString("id");
FeignClientResult<JSONObject> nodeInfo = workFlowFeignService.getNodeInfo(nextTaskId);
JSONObject result = nodeInfo.getResult();
Map<String, Object> taskInfo = (Map<String, Object>) result.get("taskInfo");
taskCode = String.valueOf(taskInfo.get("taskDefinitionKey"));
AjaxResult taskGroupName = Workflow.taskClient.getTaskGroupName(nextTaskId);
JSONArray data = JSON.parseArray(JSON.toJSONString(taskGroupName.get("data")));
for (Object datum : data) {
if (((Map) datum).containsKey("groupId")) {
roleList.add(((Map) datum).get("groupId").toString());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (!FlowStatusEnum.TO_BE_FINISHED.getName().equals(taskCode)) {
role = String.join(",", roleList);
jgChangeRegistrationName.setNextExecutorIds(role);
jgChangeRegistrationName.setPromoter(reginParams.getUserModel().getUserId());
jgChangeRegistrationName.setInstanceId(instanceId);
if (!ObjectUtils.isEmpty(jgChangeRegistrationName.getInstanceStatus())) {
jgChangeRegistrationName.setInstanceStatus(jgChangeRegistrationName.getInstanceStatus() + "," + role);
} else {
jgChangeRegistrationName.setInstanceStatus(role);
}
if ("0".equals(operate)) {
// 通过操作
jgChangeRegistrationName.setAuditStatus(WorkFlowStatusEnum.getMessage(taskCode).getPass());
} else {
// 驳回操作
jgChangeRegistrationName.setAuditStatus(WorkFlowStatusEnum.getMessage(taskCode).getReject());
jgChangeRegistrationName.setPromoter(null);
}
} else {
// TODO: 2023/12/25 流程完成后业务开发
jgChangeRegistrationName.setAuditStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
jgChangeRegistrationName.setAuditPassDate(new Date());
}
this.getBaseMapper().updateById(jgChangeRegistrationName);
}
public Map<String, Object> queryBySequenceNbr(Long sequenceNbr) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
// Map<String, Object> resultMap = accessFeignService.getData(reginParams.getCompany().getCompanyCode()).getResult();
Map<String, Object> resultMap = accessFeignService.getData("91610131MA6WMXA43W").getResult();
String unitName = String.valueOf(resultMap.get("unitName"));
JgChangeRegistrationName jgChangeRegistrationName = new JgChangeRegistrationName();
Map<String, Object> dtoMap = new HashMap<>();
Map<String, Object> map = new HashMap<>();
if (!Objects.isNull(sequenceNbr)) {
jgChangeRegistrationName = this.baseMapper.selectById(sequenceNbr);
jgChangeRegistrationName.setNewUseUnitName(unitName);
jgChangeRegistrationName.setReceiveOrgCode(jgChangeRegistrationName.getReceiveOrgCode() + "_" + jgChangeRegistrationName.getReceiveOrgName());
} else {
jgChangeRegistrationName.setUseUnitCreditCode(reginParams.getCompany().getCompanyCode());
jgChangeRegistrationName.setNewUseUnitName(unitName);
jgChangeRegistrationName.setUseUnitName(reginParams.getCompany().getCompanyName());
}
BeanUtil.copyProperties(jgChangeRegistrationName, dtoMap);
dtoMap.put("changeCertificateList", JSON.parseArray(jgChangeRegistrationName.getChangeCertificate()));
map.put("jgRegistrationInfo", dtoMap);
return map;
}
public Page<Map<String, Object>> getList(JgChangeRegistrationNameDto dto, Page<Map<String, Object>> page, List<String> roleIds) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String orgCode = reginParams.getCompany().getCompanyCode();
Page<Map<String, Object>> listPage = this.baseMapper.getListPage(page, dto, roleIds, orgCode);
return listPage;
}
}
\ 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