作者 张晓杰
@@ -14,4 +14,6 @@ import org.apache.ibatis.annotations.Param; @@ -14,4 +14,6 @@ import org.apache.ibatis.annotations.Param;
14 public interface TblBusinessWorkflowMapper extends BaseMapperPlus<TblBusinessWorkflowMapper, TblBusinessWorkflow, TblBusinessWorkflowVo> { 14 public interface TblBusinessWorkflowMapper extends BaseMapperPlus<TblBusinessWorkflowMapper, TblBusinessWorkflow, TblBusinessWorkflowVo> {
15 15
16 boolean updateByProcInsId(@Param("procInsId") String procInsId, @Param("processStatus") String processStatus); 16 boolean updateByProcInsId(@Param("procInsId") String procInsId, @Param("processStatus") String processStatus);
  17 +
  18 + TblBusinessWorkflow queryByOne(Long id);
17 } 19 }
1 package com.ruoyi.common.businessworkflow.service; 1 package com.ruoyi.common.businessworkflow.service;
2 2
  3 +import com.ruoyi.common.businessworkflow.domain.TblBusinessWorkflow;
3 import com.ruoyi.common.businessworkflow.domain.bo.TblBusinessWorkflowBo; 4 import com.ruoyi.common.businessworkflow.domain.bo.TblBusinessWorkflowBo;
4 import com.ruoyi.common.businessworkflow.domain.vo.TblBusinessWorkflowVo; 5 import com.ruoyi.common.businessworkflow.domain.vo.TblBusinessWorkflowVo;
5 import com.ruoyi.common.core.page.TableDataInfo; 6 import com.ruoyi.common.core.page.TableDataInfo;
@@ -47,4 +48,9 @@ public interface ITblBusinessWorkflowService { @@ -47,4 +48,9 @@ public interface ITblBusinessWorkflowService {
47 Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); 48 Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
48 49
49 Boolean updateByProcInsId(String procInsId,String processStatus); 50 Boolean updateByProcInsId(String procInsId,String processStatus);
  51 +
  52 + /**
  53 + * 根据businessId查业务和工作流关联的数据
  54 + */
  55 + TblBusinessWorkflow queryByOne(Long id);
50 } 56 }
@@ -111,4 +111,9 @@ public class TblBusinessWorkflowServiceImpl implements ITblBusinessWorkflowServi @@ -111,4 +111,9 @@ public class TblBusinessWorkflowServiceImpl implements ITblBusinessWorkflowServi
111 public Boolean updateByProcInsId(String procInsId, String processStatus) { 111 public Boolean updateByProcInsId(String procInsId, String processStatus) {
112 return baseMapper.updateByProcInsId(procInsId, processStatus); 112 return baseMapper.updateByProcInsId(procInsId, processStatus);
113 } 113 }
  114 +
  115 + @Override
  116 + public TblBusinessWorkflow queryByOne(Long id) {
  117 + return baseMapper.queryByOne(id);
  118 + }
114 } 119 }
@@ -20,4 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -20,4 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
20 <update id="updateByProcInsId" parameterType="String"> 20 <update id="updateByProcInsId" parameterType="String">
21 update tbl_business_workflow set process_status = #{processStatus} where proc_ins_id = #{procInsId} 21 update tbl_business_workflow set process_status = #{processStatus} where proc_ins_id = #{procInsId}
22 </update> 22 </update>
  23 + <select id="queryByOne" resultType="com.ruoyi.common.businessworkflow.domain.TblBusinessWorkflow">
  24 + select * from tbl_business_workflow where business_id=#{id}
  25 + </select>
23 </mapper> 26 </mapper>
@@ -8,7 +8,9 @@ import java.util.Map; @@ -8,7 +8,9 @@ import java.util.Map;
8 import cn.hutool.core.convert.Convert; 8 import cn.hutool.core.convert.Convert;
9 import cn.hutool.core.util.ObjectUtil; 9 import cn.hutool.core.util.ObjectUtil;
10 import com.baomidou.mybatisplus.annotation.TableName; 10 import com.baomidou.mybatisplus.annotation.TableName;
  11 +import com.ruoyi.common.businessworkflow.domain.TblBusinessWorkflow;
11 import com.ruoyi.common.businessworkflow.domain.bo.TblBusinessWorkflowBo; 12 import com.ruoyi.common.businessworkflow.domain.bo.TblBusinessWorkflowBo;
  13 +import com.ruoyi.common.businessworkflow.domain.vo.TblBusinessWorkflowVo;
12 import com.ruoyi.common.businessworkflow.service.ITblBusinessWorkflowService; 14 import com.ruoyi.common.businessworkflow.service.ITblBusinessWorkflowService;
13 import com.ruoyi.compliancemanagement.domain.TblContract; 15 import com.ruoyi.compliancemanagement.domain.TblContract;
14 import com.ruoyi.compliancemanagement.model.TblContractModel; 16 import com.ruoyi.compliancemanagement.model.TblContractModel;
@@ -133,6 +135,7 @@ public class TblContractController extends BaseController { @@ -133,6 +135,7 @@ public class TblContractController extends BaseController {
133 @Validated(AddGroup.class) @RequestBody TblContractBo bo) { 135 @Validated(AddGroup.class) @RequestBody TblContractBo bo) {
134 // Matter matter = new Matter(); 136 // Matter matter = new Matter();
135 String procDefId = "Process_1721195856340:1:7aca8265-489a-11ef-a778-421c839c76ba"; 137 String procDefId = "Process_1721195856340:1:7aca8265-489a-11ef-a778-421c839c76ba";
  138 + bo.setStatus("0");
136 iTblContractService.insertByBo(bo); 139 iTblContractService.insertByBo(bo);
137 Long id = bo.getId(); 140 Long id = bo.getId();
138 //Long id = sLeaveService.create(studentLeave,matterKey); 141 //Long id = sLeaveService.create(studentLeave,matterKey);
@@ -216,17 +219,94 @@ public class TblContractController extends BaseController { @@ -216,17 +219,94 @@ public class TblContractController extends BaseController {
216 /** 219 /**
217 * 修改【请填写功能名称】 220 * 修改【请填写功能名称】
218 */ 221 */
  222 + @Transactional(rollbackFor = Exception.class)
219 @SaCheckPermission("system:contract:edit") 223 @SaCheckPermission("system:contract:edit")
220 @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) 224 @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
221 @RepeatSubmit() 225 @RepeatSubmit()
222 @PutMapping() 226 @PutMapping()
223 - public R<Void> edit(@Validated(EditGroup.class) @RequestBody TblContractBo bo) {  
224 - return toAjax(iTblContractService.updateByBo(bo)); 227 + public R<Void> edit(@RequestParam(value = "procDefId")String procDefId,@Validated(EditGroup.class) @RequestBody TblContractBo bo) {
  228 + bo.setStatus("0");
  229 + iTblContractService.updateByBo(bo);
  230 + Long id = bo.getId();
  231 + //Long id = sLeaveService.create(studentLeave,matterKey);
  232 + if (id > 0 || id != null){
  233 + Map<String, Object> variables = new HashMap<>();
  234 + // fromSource用来标识此事项是提交来源是客户端还是移动端
  235 + //合同编号
  236 + variables.put("contractno", bo.getContractno());
  237 + // 合同名称
  238 + variables.put("contractName",bo.getContractName());
  239 + // 合同类型
  240 + variables.put("contractType",bo.getContractType());
  241 + // 合同金额
  242 + variables.put("contractAmount", bo.getContractAmount());
  243 + // 生效日期
  244 + variables.put("effectiveDate", bo.getEffectiveDate());
  245 + // 到期日期
  246 + variables.put("expirationDate", bo.getExpirationDate());
  247 + // 甲方
  248 + variables.put("partyA", bo.getPartyA());
  249 + // 甲方链接地址
  250 + variables.put("partyAAddress", bo.getPartyAAddress());
  251 + // 乙方
  252 + variables.put("partyB", bo.getPartyB());
  253 + // 乙方链接地址
  254 + variables.put("partyBAddress", bo.getPartyBAddress());
  255 + // 付款方式
  256 + variables.put("paymentMethod", bo.getPaymentMethod());
  257 + // 签订日期
  258 + variables.put("signingDate", bo.getSigningDate());
  259 + // 标的物信息
  260 + variables.put("subjectInformation", bo.getSubjectInformation());
  261 + // 附件
  262 + variables.put("attachments", bo.getAttachments());
  263 + // 变更原因
  264 + variables.put("reasonChange", bo.getReasonChange());
  265 + // 变更内容
  266 + variables.put("reasonText", bo.getReasonText());
  267 + // 启动流程
  268 + ProcessInstance processInstance = iWfProcessService.startProcessByDefId(procDefId, variables);
  269 + if(null != processInstance){
  270 +
  271 + // 获取流程状态
  272 + HistoricVariableInstance processStatusVariable = historyService.createHistoricVariableInstanceQuery()
  273 + .processInstanceId(processInstance.getProcessInstanceId())
  274 + .variableName(ProcessConstants.PROCESS_STATUS_KEY)
  275 + .singleResult();
  276 + String processStatus = null;
  277 + if (ObjectUtil.isNotNull(processStatusVariable)) {
  278 + processStatus = Convert.toStr(processStatusVariable.getValue());
  279 + }
  280 +
  281 + HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
  282 + .processDefinitionId(procDefId);
  283 + List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.list();
  284 + // 兼容旧流程
  285 + if (processStatus == null) {
  286 + processStatus = ObjectUtil.isNull(historicProcessInstances.get(0).getEndTime()) ? ProcessStatus.RUNNING.getStatus() : ProcessStatus.COMPLETED.getStatus();
  287 + }
  288 + TblBusinessWorkflow tblBusinessWorkflow = iTblBusinessWorkflowService.queryByOne(id);
  289 + TblBusinessWorkflowBo tblBusinessWorkflowBo = new TblBusinessWorkflowBo();
  290 + tblBusinessWorkflowBo.setBusinessId(id);
  291 + tblBusinessWorkflowBo.setId(tblBusinessWorkflow.getId());
  292 + tblBusinessWorkflowBo.setProcInsId(processInstance.getProcessInstanceId());
  293 + tblBusinessWorkflowBo.setProcDefId(procDefId);
  294 + tblBusinessWorkflowBo.setDeployId(processInstance.getDeploymentId());
  295 + tblBusinessWorkflowBo.setProcessStatus(processStatus);
  296 + TableName table = TblContract.class.getAnnotation(TableName.class);
  297 + tblBusinessWorkflowBo.setTableName(table.value());
  298 + iTblBusinessWorkflowService.updateByBo(tblBusinessWorkflowBo);
  299 +// iTblContractService.updateProcInsIdById(processInstance.getProcessInstanceId(),id);
  300 + }
  301 + return R.ok("成功");
  302 + }else{
  303 + return R.fail("系统故障!");
  304 + }
225 } 305 }
226 306
227 @RepeatSubmit() 307 @RepeatSubmit()
228 @PostMapping("/updateSealByContractno") 308 @PostMapping("/updateSealByContractno")
229 - public R<Void> updateSealByContractno( @RequestBody TblContractBo bo) { 309 + public R<Void> updateSealByContractno(@RequestBody TblContractBo bo) {
230 String contractno = bo.getContractno(); 310 String contractno = bo.getContractno();
231 String sealContract = bo.getSealContract(); 311 String sealContract = bo.getSealContract();
232 return toAjax(iTblContractService.updateSealByContractno(contractno,sealContract)); 312 return toAjax(iTblContractService.updateSealByContractno(contractno,sealContract));