Commit 516db5f9 authored by yangyang's avatar yangyang

fix(jyjc):merge新增、更新接口

parent adfcdb7d
package com.yeejoin.amos.boot.module.jyjc.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 检验检测开通流程执行状态
* <p>
* ProjectName: amos-boot-biz
* PackageName: com.yeejoin.amos.boot.module.jyjc.api.enums
*
* @author yangyang
* @version v1.0
* @date 2023/12/14 21:56
*/
@Getter
@AllArgsConstructor
public enum OpeningApplicationStatusEnums {
START("start", "启动"),
EXCUTING("excuting", "执行中"),
REJECT("reject", "驳回"),
WITHDRAW("withdraw", "撤回"),
COMPLETE("complete", "完成");
private String code;
private String name;
}
...@@ -79,7 +79,7 @@ public class JyjcOpeningApplicationController extends BaseController { ...@@ -79,7 +79,7 @@ public class JyjcOpeningApplicationController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "重新提交开通申请", notes = "重新提交开通申请") @ApiOperation(httpMethod = "POST", value = "重新提交开通申请", notes = "重新提交开通申请")
public ResponseModel<JyjcOpeningApplicationModel> resubmitJyjcOpeningApplication(@RequestBody JyjcOpeningApplicationModel model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) { public ResponseModel<JyjcOpeningApplicationModel> resubmitJyjcOpeningApplication(@RequestBody JyjcOpeningApplicationModel model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr); model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(jyjcOpeningApplicationServiceImpl.saveOrUpdateModel(model, true)); return ResponseHelper.buildResponse(jyjcOpeningApplicationServiceImpl.resubmit(model));
} }
/** /**
......
...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; ...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto; import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.jyjc.api.common.CommonConstants; import com.yeejoin.amos.boot.module.jyjc.api.common.CommonConstants;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcOpeningApplication; import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcOpeningApplication;
import com.yeejoin.amos.boot.module.jyjc.api.enums.OpeningApplicationStatusEnums;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcBaseMapper; import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcBaseMapper;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcOpeningApplicationMapper; import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcOpeningApplicationMapper;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcOpeningApplicationService; import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcOpeningApplicationService;
...@@ -109,7 +110,8 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp ...@@ -109,7 +110,8 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
String roleGroups = executorArray.stream().map(json -> Optional.ofNullable(((LinkedHashMap) json).get("groupId")).orElse("").toString()).collect(Collectors.joining(",")); String roleGroups = executorArray.stream().map(json -> Optional.ofNullable(((LinkedHashMap) json).get("groupId")).orElse("").toString()).collect(Collectors.joining(","));
model.setWorkflowRole(roleGroups); model.setWorkflowRole(roleGroups);
} }
model.setStatus(!ValidationUtil.isEmpty(dataObject) && !ValidationUtil.isEmpty(dataObject.get("status")) ? String.valueOf(dataObject.get("status")) : ""); model.setStatus(OpeningApplicationStatusEnums.START.getCode());
// model.setStatus(!ValidationUtil.isEmpty(dataObject) && !ValidationUtil.isEmpty(dataObject.get("status")) ? String.valueOf(dataObject.get("status")) : "");
model.setWorkflowProstanceId(instanceId); model.setWorkflowProstanceId(instanceId);
} }
if (model.getSequenceNbr() == null) { if (model.getSequenceNbr() == null) {
...@@ -128,7 +130,15 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp ...@@ -128,7 +130,15 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
} }
} }
public void updateModelByInstanceId(String instanceId) { @Transactional (rollbackFor = {Exception.class, BaseException.class})
public JyjcOpeningApplicationModel resubmit(JyjcOpeningApplicationModel model) {
model.setStatus(OpeningApplicationStatusEnums.EXCUTING.getCode());
model = this.updateWithModel(model);
execueFlow("0", model.getWorkflowProstanceId(), "");
return model;
}
public void updateModelByInstanceId(String instanceId, String status) {
log.info("updateModelByInstanceId, instanceId={}", instanceId); log.info("updateModelByInstanceId, instanceId={}", instanceId);
JyjcOpeningApplication entity = this.lambdaQuery().eq(JyjcOpeningApplication::getWorkflowProstanceId, instanceId).one(); JyjcOpeningApplication entity = this.lambdaQuery().eq(JyjcOpeningApplication::getWorkflowProstanceId, instanceId).one();
if (entity == null) { if (entity == null) {
...@@ -137,30 +147,11 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp ...@@ -137,30 +147,11 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
JSONObject taskJson = getTask(instanceId); JSONObject taskJson = getTask(instanceId);
log.info("taskJson => {}", taskJson); log.info("taskJson => {}", taskJson);
entity.setWorkflowRole(getWorkflowRoleGroups(taskJson)); entity.setWorkflowRole(getWorkflowRoleGroups(taskJson));
entity.setStatus(getWorkflowStatus(taskJson)); // entity.setStatus(getWorkflowStatus(taskJson));
entity.setStatus(status);
this.updateById(entity); this.updateById(entity);
} }
private String getWorkflowStatus(JSONObject dataObject) {
return !ValidationUtil.isEmpty(dataObject) && !ValidationUtil.isEmpty(dataObject.get("status")) ? String.valueOf(dataObject.get("status")) : "";
}
private String getWorkflowRoleGroups(JSONObject dataObject) {
JSONArray executorArray = dataObject.getJSONObject("nodeInfo").getJSONArray("executor");
if(!ValidationUtil.isEmpty(executorArray)) {
return executorArray.stream().map(json -> Optional.ofNullable(((LinkedHashMap) json).get("groupId")).orElse("").toString()).collect(Collectors.joining(","));
}
return null;
}
private JSONObject getTask(String instanceId) {
AjaxResult ajaxResult = Workflow.taskClient.getTask(instanceId);
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");// 工作流ID
FeignClientResult<JSONObject> nodeInfo = workflowFeignClient.getNodeInfotoken(RequestContext.getAppKey(), RequestContext.getProduct(), RequestContext.getToken(), taskId);
dataObject.put("nodeInfo", nodeInfo.getResult());
return dataObject;
}
/** /**
* 分页查询 * 分页查询
...@@ -270,8 +261,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp ...@@ -270,8 +261,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
if (ajaxResult == null || (ajaxResult.get(AjaxResult.CODE_TAG) != null && !"200".equals(ajaxResult.get(AjaxResult.CODE_TAG).toString()))) { if (ajaxResult == null || (ajaxResult.get(AjaxResult.CODE_TAG) != null && !"200".equals(ajaxResult.get(AjaxResult.CODE_TAG).toString()))) {
throw new BaseException("开启工作流错误"); throw new BaseException("开启工作流错误");
} }
String instanceId = ((Map) ajaxResult.get("data")).get("id").toString(); return ((Map) ajaxResult.get("data")).get("id").toString();
return instanceId;
} }
/** /**
...@@ -297,14 +287,12 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp ...@@ -297,14 +287,12 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
} }
updateModelByInstanceId(instanceId); updateModelByInstanceId(instanceId, "0".equals(op) ? OpeningApplicationStatusEnums.EXCUTING.getCode() : OpeningApplicationStatusEnums.REJECT.getCode());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* 撤回流程办理单 * 撤回流程办理单
*/ */
...@@ -315,12 +303,32 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp ...@@ -315,12 +303,32 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
if (ObjectUtils.isEmpty(ajaxResult1)) { if (ObjectUtils.isEmpty(ajaxResult1)) {
} }
updateModelByInstanceId(instanceId); updateModelByInstanceId(instanceId, OpeningApplicationStatusEnums.WITHDRAW.getCode());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private String getWorkflowStatus(JSONObject dataObject) {
return !ValidationUtil.isEmpty(dataObject) && !ValidationUtil.isEmpty(dataObject.get("status")) ? String.valueOf(dataObject.get("status")) : "";
}
private String getWorkflowRoleGroups(JSONObject dataObject) {
JSONArray executorArray = dataObject.getJSONObject("nodeInfo").getJSONArray("executor");
if(!ValidationUtil.isEmpty(executorArray)) {
return executorArray.stream().map(json -> Optional.ofNullable(((LinkedHashMap) json).get("groupId")).orElse("").toString()).collect(Collectors.joining(","));
}
return null;
}
private JSONObject getTask(String instanceId) {
AjaxResult ajaxResult = Workflow.taskClient.getTask(instanceId);
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");// 工作流ID
FeignClientResult<JSONObject> nodeInfo = workflowFeignClient.getNodeInfotoken(RequestContext.getAppKey(), RequestContext.getProduct(), RequestContext.getToken(), taskId);
dataObject.put("nodeInfo", nodeInfo.getResult());
return dataObject;
}
/** /**
* JY+年(4位)+月(2位)+日(2位)+序列号(3位 * JY+年(4位)+月(2位)+日(2位)+序列号(3位
......
...@@ -53,6 +53,6 @@ public class CreateCodeController extends BaseController { ...@@ -53,6 +53,6 @@ public class CreateCodeController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "申请单编号生成", notes = "申请单编号生成") @ApiOperation(httpMethod = "POST", value = "申请单编号生成", notes = "申请单编号生成")
public ResponseModel<List<String>> CreateANCode1(@RequestParam("type") String type, public ResponseModel<List<String>> CreateANCode1(@RequestParam("type") String type,
@RequestParam("num") int num) { @RequestParam("num") int num) {
return ResponseHelper.buildResponse(createCodeService.CreateANCode(type,num)); return ResponseHelper.buildResponse(createCodeService.createApplicationFormCode(type,num));
} }
} }
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