diff --git a/ServiceSite/facade/src/main/java/com/seasky/flowportal/dto/busFlow/BusFlowCmd.java b/ServiceSite/facade/src/main/java/com/seasky/flowportal/dto/busFlow/BusFlowCmd.java index 22d054053d4f6887c089aaa459727dd82edb4c81..8b270709ca34e512c8eeec6cf9fbe032bbb8a243 100644 --- a/ServiceSite/facade/src/main/java/com/seasky/flowportal/dto/busFlow/BusFlowCmd.java +++ b/ServiceSite/facade/src/main/java/com/seasky/flowportal/dto/busFlow/BusFlowCmd.java @@ -46,4 +46,7 @@ public class BusFlowCmd implements Serializable { //鍗曟嵁浜嬬敱 private String applyReason; + + private String webUrl; + } diff --git a/ServiceSite/facade/src/main/java/com/seasky/flowportal/dto/flow/FlowCmd.java b/ServiceSite/facade/src/main/java/com/seasky/flowportal/dto/flow/FlowCmd.java index 2be1d19cfcc6e4445ee36dc0acbf8e5f09b51a94..46cd19db5d02070f1ff2a650d4e7d020d59d0d81 100644 --- a/ServiceSite/facade/src/main/java/com/seasky/flowportal/dto/flow/FlowCmd.java +++ b/ServiceSite/facade/src/main/java/com/seasky/flowportal/dto/flow/FlowCmd.java @@ -51,4 +51,6 @@ public class FlowCmd implements Serializable { //涓嬩竴鑺傜偣id private String activityId; + + private String webUrl; } diff --git a/ServiceSite/src/main/java/com/seasky/flowportal/domain/po/BusFlowPo.java b/ServiceSite/src/main/java/com/seasky/flowportal/domain/po/BusFlowPo.java index 152bd9875372fadbfaa2e53b5c0a243ddd5cf33e..6c36d4cce0e98683daca592a3023bdfdffce5e4b 100644 --- a/ServiceSite/src/main/java/com/seasky/flowportal/domain/po/BusFlowPo.java +++ b/ServiceSite/src/main/java/com/seasky/flowportal/domain/po/BusFlowPo.java @@ -42,4 +42,8 @@ public class BusFlowPo extends BasePO implements Serializable { @TableField(value = "log") private String log; + + @TableField(value = "web_url") + private String webUrl; + } \ No newline at end of file diff --git a/ServiceSite/src/main/java/com/seasky/flowportal/domain/po/TaskVO.java b/ServiceSite/src/main/java/com/seasky/flowportal/domain/po/TaskVO.java index fc956e4734d6a7c789ed52053932e013a1ba0a49..53d0cb29fc17b03e3760813374d9a5e560551726 100644 --- a/ServiceSite/src/main/java/com/seasky/flowportal/domain/po/TaskVO.java +++ b/ServiceSite/src/main/java/com/seasky/flowportal/domain/po/TaskVO.java @@ -7,6 +7,7 @@ import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.util.Date; +import java.util.List; /** @@ -181,7 +182,7 @@ public class TaskVO { /** * 鍙備笌鑰� */ - private ParticipantVO[] participants; + private List<ParticipantVO> participants; public int getId() { return id; @@ -319,11 +320,11 @@ public class TaskVO { this.creatorId = creatorId; } - public ParticipantVO[] getParticipants() { + public List<ParticipantVO> getParticipants() { return participants; } - public void setParticipants(ParticipantVO[] participants) { + public void setParticipants(List<ParticipantVO> participants) { this.participants = participants; } diff --git a/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/BusFlowServiceImpl.java b/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/BusFlowServiceImpl.java index a161f361f905dd46b2a1d6c2fe9af6a663961afc..4114d758f4ef091311d36a3a2b55dfd62cfc27d9 100644 --- a/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/BusFlowServiceImpl.java +++ b/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/BusFlowServiceImpl.java @@ -24,7 +24,11 @@ import com.seasky.flowportal.service.LoginPortalService; import com.seasky.flowportal.service.convert.BusFlowConvert; import com.seasky.flowportal.utils.MyHttpDelete; import com.seasky.flowportal.utils.SudySignUtil; +import com.seasky.flowportal.utils.Util; +import jdk.nashorn.internal.runtime.JSType; import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.net.ntp.TimeStamp; import org.apache.http.HttpEntity; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.config.RequestConfig; @@ -35,6 +39,7 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; +import org.simpleframework.xml.convert.Convert; import org.springframework.amqp.core.AmqpTemplate; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; @@ -44,10 +49,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; +import java.security.Timestamp; +import java.util.*; import java.util.stream.Collectors; /** @@ -136,28 +139,6 @@ public class BusFlowServiceImpl implements BusFlowService { executeBusFlow(busFlowPo); } } - //================== -/* List<BusFlowPo> busFlowPoList1 = busFlowMapper.selectList(new QueryWrapper<BusFlowPo>().ne("execution_status", 1).orderByAsc("create_date")); - BusFlowPo busFlowPo = busFlowPoList1.get(0); - if (ObjectUtils.isEmpty(busFlowPo) || busFlowPo.getExecutionStatus() == ExecutionStatusEnum.Retry.getIndex()){ - // - } - if (busFlowPo.getExecutionStatus() == ExecutionStatusEnum.Unexecuted.getIndex()){ - boolean flag = (busFlowPo.getOpen().equals(OpenEnum.CREATE.getName()) || busFlowPo.getOrderStatus().equals("瀹屾垚")); - if (ObjectUtils.isEmpty(busFlowPo.getAuditor()) && !flag){ - ExceptionUtil.getException(null,"瀹℃牳浜轰笉鑳戒负绌�"); - } - boolean flag1 = (busFlowPo.getNextOrderStatus().equals("瀹℃壒椹冲洖") || busFlowPo.getNextOrderStatus().equals("瀹屾垚")); - if (ObjectUtils.isEmpty(busFlowPo.getNextAuditor()) || busFlowPo.getNextAuditor().split(",").length == 0 && !flag1){ - ExceptionUtil.getException(null,"寰呭姙浜轰笉鑳戒负绌�"); - } - executeBusFlow(busFlowPo); - } - List<BusFlowPo> busFlowPoList2 = busFlowMapper.selectList(new QueryWrapper<BusFlowPo>().ne("execution_status", 1).orderByAsc("create_date")); - BusFlowPo busFlowPo1 = busFlowPoList2.get(0); - if (busFlowPo1.getExecutionStatus().equals(ExecutionStatusEnum.Unexecuted.getIndex())){ - saveBusFlow(busFlowPo1); - }*/ } public boolean executeBusFlow(BusFlowPo busFlowPo1) { @@ -252,25 +233,11 @@ public class BusFlowServiceImpl implements BusFlowService { if (busFlowCmd.getNextOrderStatus() != OrderStatusEnum.BACK.getName()) { List<BusFlowPo> busFlows = busFlowMapper.selectList(new QueryWrapper<BusFlowPo>().eq("apply_code",busFlowCmd.getApplyCode()).orderByDesc("create_date")); BusFlowPo busFlow = busFlows.get(1); - busFlowCmd.setId(busFlow.getId()); + busFlowCmd.setTaskBizId(busFlow.getId().toString()); if (busFlow.getId() == null) { ExceptionUtil.getException(null,"鏈壘鍒伴渶瑕佸畬鎴愮殑寰呭姙id"); } - String nonce = "3L6nnjbX"; - String timestamp=System.currentTimeMillis()+""; - // 鍒涘缓httpGet杩滅▼杩炴帴瀹炰緥 - String signature = null; - String loginName=loginPortalService.getLoginUser().getUserName(); - String summary = SudySignUtil.buildSummary(baseConfigProperties.getAlgorithm(),loginName); - try { - signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp,nonce,null,baseConfigProperties.getSecret()); - } catch (Exception e) { - e.printStackTrace(); - } - String taskBizId = busFlowCmd.getId().toString(); - TaskVO taskVO = new TaskVO(); - taskVO.setTaskBizId(taskBizId); - doneTask(taskBizId,signature,nonce,timestamp,loginName); + doneTask(busFlowCmd); } busFlowCmd.setExecutionStatus(ExecutionStatusEnum.Succeeded.getIndex()); BusFlowPo busFlowPo = BusFlowConvert.cmdToPo(busFlowCmd); @@ -287,6 +254,7 @@ public class BusFlowServiceImpl implements BusFlowService { private BaseResultModel<Boolean> CancelTodo(BusFlowCmd busFlowCmd) { BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); + String nonce = getNonce(); BaseResultModel<Boolean> result = new SuccessResultModel<>(); { if (busFlowCmd.getAuditor() != null) @@ -301,18 +269,7 @@ public class BusFlowServiceImpl implements BusFlowService { if (auditorModel.getExecutionStatus() == ExecutionStatusEnum.Unexecuted.getIndex()) { if(busFlowCmd.getIsOrderStatusChanged() == false) { - String nonce = "3L6nnjbX"; - String timestamp=System.currentTimeMillis()+""; - // 鍒涘缓httpGet杩滅▼杩炴帴瀹炰緥 - String signature = null; - String loginName=loginPortalService.getLoginUser().getUserName(); - try { - signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp,nonce,null,baseConfigProperties.getSecret()); - } catch (Exception e) { - e.printStackTrace(); - } - String taskBizId = busFlowCmd.getId().toString(); - removePartipantsTask(signature,nonce,timestamp,taskBizId,loginName); + removePartipantsTask(busFlowCmd); } auditorModel.setExecutionStatus(ExecutionStatusEnum.DeletePerson.getIndex()); busFlowCmd.setAuditor(JSONArray.toJSONString(auditorModel)); @@ -326,18 +283,7 @@ public class BusFlowServiceImpl implements BusFlowService { if (auditorModel.getExecutionStatus() == ExecutionStatusEnum.DeletePerson.getIndex()) { if (busFlowCmd.getIsOrderStatusChanged() == false) { - String nonce = "3L6nnjbX"; - String timestamp=System.currentTimeMillis()+""; - // 鍒涘缓httpGet杩滅▼杩炴帴瀹炰緥 - String signature = null; - String loginName=loginPortalService.getLoginUser().getUserName(); - try { - signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp,nonce,null,baseConfigProperties.getSecret()); - } catch (Exception e) { - e.printStackTrace(); - } - String taskBizId = busFlowCmd.getId().toString(); - addPartipantsTask(signature,nonce,timestamp,taskBizId,loginName); + addPartipantsTask(busFlowCmd); } auditorModel.setExecutionStatus(busFlowCmd.getIsOrderStatusChanged() == true ? ExecutionStatusEnum.AdditionalPerson.getIndex() : ExecutionStatusEnum.Succeeded.getIndex()); busFlowCmd.setAuditor(JSONArray.toJSONString(auditorModel)); @@ -355,17 +301,7 @@ public class BusFlowServiceImpl implements BusFlowService { { BusFlowPo busFlow = busFlowMapper.selectOne(new QueryWrapper<BusFlowPo>().eq("documentId",busFlowCmd.getDocumentId()).eq("next_order_status",busFlowCmd.getNextOrderStatus())); busFlowCmd.setTaskBizId(busFlow.getId().toString()); - String nonce = "3L6nnjbX"; - String timestamp=System.currentTimeMillis()+""; - // 鍒涘缓httpGet杩滅▼杩炴帴瀹炰緥 - String signature = null; - try { - signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp,nonce,null,baseConfigProperties.getSecret()); - } catch (Exception e) { - e.printStackTrace(); - } - String taskBizId = busFlowCmd.getId().toString(); - deleteTask(taskBizId,signature,nonce,timestamp); + deleteTask(busFlowCmd); } } auditorModel.setExecutionStatus(ExecutionStatusEnum.Succeeded.getIndex()); @@ -389,7 +325,7 @@ public class BusFlowServiceImpl implements BusFlowService { { String nextAuditor = busFlowCmd.getNextAuditor(); List<BusFlowUserModel> nextAuditors = JSONArray.parseArray(nextAuditor, BusFlowUserModel.class); - //List<BusFlowUserModel> collect = nextAuditors.stream().filter(busFlowUserModel -> ExecutionStatusEnum.Succeeded.getIndex() == busFlowUserModel.getExecutionStatus()).collect(Collectors.toList()); + //List<BusFlowUserModel> collect = nextAuditors.stream().filter(busFlowUserModel -> ExecutionStatusEnum.Succeeded.getIndex() != busFlowUserModel.getExecutionStatus()).collect(Collectors.toList()); List<BusFlowUserModel> collect = nextAuditors; if(collect.size() != 0) { @@ -397,43 +333,7 @@ public class BusFlowServiceImpl implements BusFlowService { if(busFlowCmd.getIsOrderStatusChanged() == true) { ExpenseReimbursementPo order = expenseReimbursementMapper.selectOne(new QueryWrapper<ExpenseReimbursementPo>().eq("reimbursement_code", busFlowCmd.getApplyCode())); busFlowCmd.setApplyReason(order.getApplyReason()); - String nonce = "3L6nnjbX"; - String timestamp=System.currentTimeMillis()+""; - // 鍒涘缓httpGet杩滅▼杩炴帴瀹炰緥 - String signature = null; - String loginName = order.getApplicantName(); - String summary = SudySignUtil.buildSummary(baseConfigProperties.getAlgorithm(),loginName); - try { - signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp,nonce,null,baseConfigProperties.getSecret()); - } catch (Exception e) { - e.printStackTrace(); - } - String taskBizId = busFlowCmd.getId().toString(); - TaskVO taskVO = new TaskVO(); - taskVO.setTaskBizId(taskBizId); - createTask(taskVO,signature,nonce,timestamp,loginName); - } - else - { - BusFlowPo busFlow = busFlowMapper.selectOne(new QueryWrapper<BusFlowPo>().eq("documentId",busFlowCmd.getDocumentId()).eq("next_order_status",busFlowCmd.getNextOrderStatus())); - String nextAuditor1 = busFlow.getNextAuditor(); - List<BusFlowUserModel> nextAuditors1 = JSONArray.parseArray(nextAuditor1, BusFlowUserModel.class); - List<BusFlowUserModel> collect1 = collect.stream().filter(obj -> find(obj.getUserId(), nextAuditors1)).collect(Collectors.toList()); - if(collect1.size() > 0) - { - String nonce = "3L6nnjbX"; - String timestamp=System.currentTimeMillis()+""; - // 鍒涘缓httpGet杩滅▼杩炴帴瀹炰緥 - String signature = null; - String loginName="admin"; - try { - signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp,nonce,null,baseConfigProperties.getSecret()); - } catch (Exception e) { - e.printStackTrace(); - } - String taskBizId = busFlowCmd.getId().toString(); - addPartipantsTask(signature,nonce,timestamp,taskBizId,loginName); - } + createTask(busFlowCmd,nextAuditors); } } nextAuditors.forEach(e -> e.setExecutionStatus(ExecutionStatusEnum.Succeeded.getIndex())); @@ -449,183 +349,114 @@ public class BusFlowServiceImpl implements BusFlowService { return result; } - public Boolean find(String empNumber, List<BusFlowUserModel> list) { - for (int i = 0; i < list.size(); i++) { - if (list.get(i).getUserId() .equals(empNumber)) { - return true; - } - } - return false; - } - - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /** * 2.2.1 * 鍒涘缓浠诲姟 * @throws Exception */ - private void createTask(TaskVO task, String signature, String nonce, String timestamp, String loginName) { + private void createTask(BusFlowCmd busFlowCmd,List<BusFlowUserModel> user) { BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); + String nonce = getNonce(); String url = baseConfigProperties.getHost() + "/_web/_apps/taskcenter/api/v3/taskcenter/app/" + baseConfigProperties.getAppCode() + "/task/category/" + baseConfigProperties.getTaskCategoryCode() + ".rst"; - -// url = url + "_method=PUT"; - Date date = new Date(); - task.setCreatorId(loginName); - task.setDeadLine(date); + BusFlowUserModel creator = new BusFlowUserModel(); + if (busFlowCmd.getOpen().equals(OpenEnum.CREATE)){ + creator = user.get(0); + }else { + creator=JSONArray.parseArray(busFlowCmd.getNextAuditor(), BusFlowUserModel.class).get(0); + } + String timestamp = System.currentTimeMillis()+ ""; + String signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp, nonce,null,baseConfigProperties.getSecret()); + //boolean b = SudySignUtil.checkSign(baseConfigProperties.getAlgorithm(), baseConfigProperties.getAppCode(), timestamp, nonce, null, baseConfigProperties.getSecret(), signature, 20); + //System.out.println("b======" + b); + + TaskVO task = new TaskVO(); + String taskBizId = busFlowCmd.getId().toString(); + String title = busFlowCmd.getApplyReason() + busFlowCmd.getApplyCode(); + String webUrl = baseConfigProperties.getWebUrl() + busFlowCmd.getWebUrl(); + //浠诲姟鍙備笌鑰� + ArrayList<ParticipantVO> participantVOS = new ArrayList<>(); + for (BusFlowUserModel busFlowUserModel : user) { + ParticipantVO participantVO = new ParticipantVO(); + participantVO.setType(ParticipantVO.TYPE_USER); + participantVO.setUserCode(busFlowUserModel.getUserCode()); + participantVOS.add(participantVO); + } + task.setTaskBizId(taskBizId); + task.setCreatorId(creator.getUserCode()); + //task.setCreateName("闄堟€濇兜"); task.setImportance(TaskVO.IMPORTANCE_MIDDLE); task.setState(TaskVO.STATE_UNDO); - task.setSubTitle("璇峰噯鏃跺弬鍔�"); - task.setTitle(task.getTaskBizId() + "-璇峰亣鐢宠"); - task.setUrl("http://www.baidu.com"); - task.setDoneUrl("http://www.google.cn/"); -// //浠诲姟鍙備笌鑰� - ParticipantVO[] participantVOS = new ParticipantVO[1]; - ParticipantVO participantVO = new ParticipantVO(); - participantVO.setType(ParticipantVO.TYPE_USER); - participantVO.setUserCode(loginName); -// participantVO.setMonitor(true); - participantVOS[0] = participantVO; -// -// ParticipantVO participantVO1 = new ParticipantVO(); -// participantVO1.setType(ParticipantVO.TYPE_USER); -// participantVO1.setUserCode("admin"); -// participantVO1.setMonitor(false); -// participantVOS[1] = participantVO1; - -// ParticipantVO participantVO1 = new ParticipantVO(); -// participantVO1.setType(ParticipantVO.TYPE_GROUP); -// participantVO1.setGroupName("eos_wlxxzxwlb"); -// participantVOS[0] = participantVO1; -// ParticipantVO participantVO2 = new ParticipantVO(); -// participantVO2.setType(ParticipantVO.TYPE_USER); -// participantVO2.setUserCode("999002"); -// participantVOS[1] = participantVO2; -// ParticipantVO participantVO1 = new ParticipantVO(); -// participantVO1.setType(ParticipantVO.TYPE_USER); -// participantVO1.setUserCode("010026"); -// participantVOS[1] = participantVO1; + task.setTitle(title); + task.setUrl(webUrl); + task.setDoneUrl(webUrl); task.setParticipants(participantVOS); - -// TaskVO parentTaskVO = new TaskVO (); -// parentTaskVO.setProcessTrace(true); -// parentTaskVO.setCreatorId("admin"); -// parentTaskVO.setTaskBizId("010010=04"); -// parentTaskVO.setUrl("http://"); -// parentTaskVO.setTitle("ffchen璇峰亣鐢宠"); -// parentTaskVO.setCreateTime(new Date()); -// participantVO = new ParticipantVO(); -// participantVO.setUserCode("admin"); -// participantVO.setType(0); -// participantVOS = new ParticipantVO[1]; -// participantVOS[0] = participantVO; -// parentTaskVO.setParticipants(participantVOS); -// task.setParentTask(parentTaskVO); doPost(url, JSON.toJSONString(task), signature, nonce, timestamp, null); } - - private void doneTask(String taskBizId,String signature,String nonce,String timestamp,String loginName){ + private void doneTask(BusFlowCmd busFlowCmd){ BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); - String url = baseConfigProperties.getHost()+"/_web/_apps/taskcenter/api/v3/taskcenter/app/"+baseConfigProperties.getAppCode()+"/task/"+ taskBizId+"/user/"+loginName+"/userDone.rst"; + BusFlowUserModel user = JSONArray.parseObject(busFlowCmd.getAuditor(), BusFlowUserModel.class); + String nonce = getNonce(); + String url = baseConfigProperties.getHost()+"/_web/_apps/taskcenter/api/v3/taskcenter/app/"+baseConfigProperties.getAppCode()+"/task/"+ busFlowCmd.getTaskBizId()+"/user/"+user.getUserCode()+"/userDone.rst"; + String timestamp = System.currentTimeMillis()+ ""; + String signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp, nonce,null,baseConfigProperties.getSecret()); UserDoneAO userDoneAO = new UserDoneAO(); - userDoneAO.setFinishTask(false); + userDoneAO.setFinishTask(busFlowCmd.getIsOrderStatusChanged() == true); userDoneAO.setDoneDate(new Date()); doPost(url,JSON.toJSONString(userDoneAO),signature,nonce,timestamp,null); } - private void addPartipantsTask(String signature,String nonce,String timestamp,String taskBizId,String loginName){ + private void addPartipantsTask(BusFlowCmd busFlowCmd){ + String nonce = getNonce(); + String timestamp = System.currentTimeMillis()+ ""; + String taskBizId = busFlowCmd.getId().toString(); BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); String url = baseConfigProperties.getHost()+"/_web/_apps/taskcenter/api/v3/taskcenter/app/"+ baseConfigProperties.getAppCode() +"/task/"+taskBizId+"/participant.rst"; + String signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp, nonce,null,baseConfigProperties.getSecret()); + String auditor = busFlowCmd.getAuditor(); + BusFlowUserModel user = new BusFlowUserModel(); + if (ObjectUtils.isNotEmpty(auditor)){ + user = JSONArray.parseObject(auditor,BusFlowUserModel.class); + } ParticipantVO[] participants = new ParticipantVO[1]; ParticipantVO participant = new ParticipantVO(); participant.setType(ParticipantVO.TYPE_USER); - participant.setUserCode(loginName); + participant.setUserCode(user.getUserCode()); participants[0] = participant; doPost(url,JSON.toJSONString(participants),signature,nonce,timestamp,null); } - private void removePartipantsTask(String signature,String nonce,String timestamp,String taskBizId,String loginName){ + private void removePartipantsTask(BusFlowCmd busFlowCmd){ + String nonce = getNonce(); + String timestamp = System.currentTimeMillis()+ ""; + String taskBizId = busFlowCmd.getId().toString(); BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); String url = baseConfigProperties.getHost()+"/_web/_apps/taskcenter/api/v3/taskcenter/app/"+baseConfigProperties.getAppCode()+"/task/" + taskBizId +"/participant.rst"; + String signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp, nonce,null,baseConfigProperties.getSecret()); + String auditor = busFlowCmd.getAuditor(); + BusFlowUserModel user = new BusFlowUserModel(); + if (ObjectUtils.isNotEmpty(auditor)){ + user = JSONArray.parseObject(auditor,BusFlowUserModel.class); + } ParticipantVO[] participants = new ParticipantVO[1]; ParticipantVO participant = new ParticipantVO(); participant.setType(ParticipantVO.TYPE_USER); - participant.setUserCode(loginName); + participant.setUserCode(user.getUserCode()); participants[0] = participant; doDelete(url,JSON.toJSONString(participants),signature,nonce,timestamp); } - /** - * 2.2.2 - * 鍒涘缓浠诲姟骞跺畬鎴� - * @throws Exception - */ - private void createTaskAndUserDone (String signature, String nonce, String timestamp, String loginName, String taskBizId, String parentTaskBizId) throws Exception { - BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); - TaskVO task = new TaskVO(); - Date date = new Date(); - task.setCreatorId(loginName); - task.setDeadLine(date); - task.setUrl("http://"); - task.setImportance(TaskVO.IMPORTANCE_MIDDLE); - task.setState(TaskVO.STATE_UNDO); - task.setSubTitle("test"); - task.setTitle("second test3. bizId=tz2, cate=2, app=2, participant=0810035"); - task.setTaskBizId(taskBizId); - //浠诲姟鍙備笌鑰� - ParticipantVO[] participantVOS = new ParticipantVO[1]; - ParticipantVO participantVO = new ParticipantVO(); - participantVO.setType(ParticipantVO.TYPE_USER); - participantVO.setUserCode(loginName); - participantVOS[0] = participantVO; - task.setParticipants(participantVOS); - String randomId = UUID.randomUUID().toString(); - UserDoneAO userDoneAO = new UserDoneAO(); - userDoneAO.setDoneDate(new Date()); - userDoneAO.setFinishTask(true); - userDoneAO.setDelegate(false); - TaskAndDoneAO taskAndDoneAO = new TaskAndDoneAO(); - taskAndDoneAO.setTaskVO(task); - taskAndDoneAO.setUserDoneAO(userDoneAO); - - String url = baseConfigProperties.getHost() + "/_web/_apps/taskcenter/api/v3/taskcenter/app/" + baseConfigProperties.getAppCode() + "/task/category/" + baseConfigProperties.getTaskCategoryCode() + "/done.rst?userId=" + loginName; - doPost(url, JSON.toJSONString(taskAndDoneAO), signature, nonce, timestamp, null); - } - - - /** - * 2.2.8 - * 鍒犻櫎浠诲姟 - * @param taskBizId 浠诲姟bizid - * @param signature - * @param nonce - * @param timestamp - */ - private void deleteTask (String taskBizId, String signature, String nonce, String timestamp){ + private void deleteTask (BusFlowCmd busFlowCmd){ + String nonce = getNonce(); + String timestamp = System.currentTimeMillis()+ ""; + String taskBizId = busFlowCmd.getId().toString(); BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); + String signature = SudySignUtil.buildSign(baseConfigProperties.getAlgorithm(),baseConfigProperties.getAppCode(),timestamp, nonce,null,baseConfigProperties.getSecret()); String url = baseConfigProperties.getHost() + "/_web/_apps/taskcenter/api/v3/taskcenter/app/" + baseConfigProperties.getAppCode() + "/task/" + taskBizId + "/delete.rst?" + "cascade=true"; - doPost(url, null, signature, nonce, timestamp, null); } - /** - * 2.2.10 - * 瀹屾垚浠诲姟 - * @param taskBizId 浠诲姟bizid - * @param signature - * @param nonce - * @param timestamp - */ - private void finishTask (String taskBizId, String signature, String nonce, String timestamp, String loginName){ - BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); - String url = baseConfigProperties.getHost() + "/_web/_apps/taskcenter/api/v3/taskcenter/app/" + baseConfigProperties.getAppCode() + "/task/" + taskBizId + "/finish.rst"; - FinishTaskVO finishTaskVO = new FinishTaskVO(); - finishTaskVO.setDoneDate(new Date()); - doPost(url, JSON.toJSONString(finishTaskVO), signature, nonce, timestamp, null); - } - - public String doPost (String url, String json, String signature, String nonce, String timestamp, String summary){ BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); System.out.println(url); @@ -636,7 +467,7 @@ public class BusFlowServiceImpl implements BusFlowService { // 閫氳繃鍧€榛樿閰嶇疆鍒涘缓涓€涓猦ttpClient瀹炰緥 httpClient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(url); - System.out.println(json); + //System.out.println("json=======" + json); if (json != null) { StringEntity stringEntity = new StringEntity(json, ContentType.APPLICATION_JSON); httpPost.setEntity(stringEntity); @@ -657,13 +488,15 @@ public class BusFlowServiceImpl implements BusFlowService { .build(); // 涓篽ttpGet瀹炰緥璁剧疆閰嶇疆 httpPost.setConfig(requestConfig); + //System.out.println(httpPost); // 鎵цget璇锋眰寰楀埌杩斿洖瀵硅薄 response = httpClient.execute(httpPost); + //System.out.println("response================================" + response); // 閫氳繃杩斿洖瀵硅薄鑾峰彇杩斿洖鏁版嵁 HttpEntity entity = response.getEntity(); // 閫氳繃EntityUtils涓殑toString鏂规硶灏嗙粨鏋滆浆鎹负瀛楃涓� result = EntityUtils.toString(entity); - System.out.println(result); + //System.out.println(result); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { @@ -749,4 +582,15 @@ public class BusFlowServiceImpl implements BusFlowService { } return result; } + + private String getNonce() + { + return getRandomString(new Random().nextInt(6)+5); + } + //鐢熸垚闅忔満瀛楃涓� + public String getRandomString(int length) + { + String s = RandomStringUtils.randomAlphabetic(length); + return s; + } } diff --git a/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/ExpenseReimbursementServiceImpl.java b/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/ExpenseReimbursementServiceImpl.java index 5a1d25830fa3b283459c32285840087b03edc262..e435dae829d3df1796e9a00e54d3651af7a97423 100644 --- a/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/ExpenseReimbursementServiceImpl.java +++ b/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/ExpenseReimbursementServiceImpl.java @@ -1027,6 +1027,7 @@ public class ExpenseReimbursementServiceImpl implements ExpenseReimbursementServ flowCmd.setApplyUserId(expenseReimbursementCmd.getApplicantNo()); flowCmd.setApprover(expenseReimbursementCmd.getApplicantNo()); flowCmd.setBusinessData(BeanUtil.beanToMap(expenseReimbursementCmd)); + flowCmd.setWebUrl(getWebUrl(expenseReimbursementCmd.getReimbursementType(),expenseReimbursementCmd.getApprovalDetailId())); BaseConfigProperties baseConfigProperties = baseConfigService.getBaseConfigProperties(); String defKey = baseConfigProperties.getProcessDefinitionMap().get(expenseReimbursementCmd.getReimbursementType()); if (ObjectUtils.isEmpty(defKey)) { @@ -1501,4 +1502,12 @@ public class ExpenseReimbursementServiceImpl implements ExpenseReimbursementServ throw ExceptionUtil.getException(null, "鏈壘鍒板崟鎹俊鎭�"); return expenseReimbursementPoList.get(0); } + + public String getWebUrl(String reimbursementType,String approvalDetailId) { + ReimbursementTypeEnum reimbursementTypeEnum = ReimbursementTypeEnum.getValueByName(reimbursementType); + if (ObjectUtils.isEmpty(reimbursementTypeEnum)) { + return ""; + } + return String.format("%s/%s", reimbursementTypeEnum.getRoute(), approvalDetailId); + } } diff --git a/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/FlowServiceImpl.java b/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/FlowServiceImpl.java index f76bb06d1cab5cfbf661c362007ee640fb85834a..b9715d1e529ec77430bfb5c442e91a12666c74a9 100644 --- a/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/FlowServiceImpl.java +++ b/ServiceSite/src/main/java/com/seasky/flowportal/service/impl/FlowServiceImpl.java @@ -3,6 +3,7 @@ package com.seasky.flowportal.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.seasky.core.common.Result; import com.seasky.core.ddd.utils.MapperUtils; import com.seasky.core.util.ExceptionUtil; @@ -36,6 +37,7 @@ import com.seasky.flowportal.dto.user.UserInfoQuery; import com.seasky.flowportal.enums.FlowOpenEnum; import com.seasky.flowportal.enums.OpenEnum; import com.seasky.flowportal.enums.OrderStatusEnum; +import com.seasky.flowportal.enums.ReimbursementTypeEnum; import com.seasky.flowportal.mapper.ExpenseReimbursementMapper; import com.seasky.flowportal.service.BaseConfigService; import com.seasky.flowportal.service.BusFlowService; @@ -247,67 +249,6 @@ public class FlowServiceImpl extends FlowService { } public void saveBusFlow(OpenEnum open,FlowCmd flowCmd,String orderStatus){ - /* - * - * //鑾峰彇鍗曞彿 - var order = ExpenseReimbursementRepository.SelectOrder(new ExpenseReimbursementInputModel { PKID = model.DocumentID }); - if (order.OrderTypes == EnumOrderTypes.鍓嶇疆鐢宠) - { - var getPrefix = PreApplyHelper.GetWebUrlPreFix(order.ApplyType); - if (!getPrefix.IsSuccess) - { - LogWriter.WriteLog(EnumLogLevel.Fatal, "SaveBusFlow", "MyAppsService", "", getPrefix.ErrorMessage); - return; - } - order.WebUrl = getPrefix.Data + order.ApplyCode; - } - //鑾峰彇瀹℃牳浜� - BusFlowUserModel auditor = null; - bool noAuditor = open == EnumOpen.淇濆瓨 || orderStatus == EnumBaseFlowStatus.瀹屾垚; - if (!noAuditor) - { - var userInfo = UserRepository.SelectWithKeys(new UserModel { UserID = BaseData.BLL.ApplicationContext.Current.UserId }); - auditor = new BusFlowUserModel { UserId = userInfo.UserID, UserNo = userInfo.UserNo, UserName = userInfo.UserName }; - } - //鑾峰彇寰呭姙鑺傜偣 - var resultGetCurNode = GetCurNodeInfoByDocumentID(model); - var nextOrderStatus = resultGetCurNode.IsSuccess ? resultGetCurNode.Data?.Values?.FirstOrDefault() : string.Empty; - //鑾峰彇寰呭姙浜� - var nextAuditor = new List<BusFlowUserModel>(); - bool noNextAuditor = nextOrderStatus == EnumBaseFlowStatus.瀹屾垚 || nextOrderStatus == EnumBaseFlowStatus.瀹℃壒椹冲洖; - if (!noNextAuditor) - { - var resultUsers = GetAuditorByDocumentID(model); - if (resultUsers.IsSuccess) - { - foreach (var item in resultUsers.Data) - { - var userInfo = UserRepository.SelectWithKeys(new UserModel { UserID = Guid.Parse(item) }); - if (userInfo == null) continue; - nextAuditor.Add(new BusFlowUserModel { UserId = userInfo.UserID, UserNo = userInfo.UserNo, UserName = userInfo.UserName }); - } - } - } - var resultCreateAndPushBusFlow = BusFlowService.CreateAndPushBusFlow(new BusFlowInputModel - { - Open = open, - DocumentID = model.DocumentID, - ApplyCode = order.ApplyCode, - OrderStatus = orderStatus, - AuditorModel = auditor, - NextOrderStatus = nextOrderStatus, - NextAuditorModel = nextAuditor, - WebUrl = order.WebUrl - }); - var busFlow = resultCreateAndPushBusFlow.Data; - LogWriter.WriteLog(EnumLogLevel.Debug, "SaveBusFlow", "MyAppsService", "", $"閫€鍑烘柟娉曪細busFlow: {JsonConvert.SerializeObject(busFlow)}", null); - } - catch (Exception e) - { - LogWriter.WriteLog(EnumLogLevel.Fatal, "SaveBusFlow", "MyAppsService", "", $"淇濆瓨娴佺▼澶勭悊杩囩▼澶辫触", e); - } - return; - * */ UserInfoOut loginUser = null; if(ObjectUtils.isNotEmpty(flowCmd.getApplyUserId())){ loginUser = externalDataService.getUserInfoByUserNo(flowCmd.getApplyUserId()); @@ -359,6 +300,9 @@ public class FlowServiceImpl extends FlowService { UserInfoQuery userInfoQuery = new UserInfoQuery(); userInfoQuery.setUserNo(assignee); UserInfoOut userInfo = externalDataService.getUserInfoByUserNo(assignee); + if (ObjectUtils.isEmpty(userInfo)){ + ExceptionUtil.getException(null,"鏃犲鎵逛汉"); + } nextAuditorList.add(new BusFlowUserModel(userInfo.getUserId(),userInfo.getUserNo(),userInfo.getUserName(),null)); } nextAuditor = JSONArray.toJSONString(nextAuditorList); @@ -374,9 +318,9 @@ public class FlowServiceImpl extends FlowService { busFlowPo.setExecutionStatus(0); busFlowPo.setDocumentId(""); busFlowPo.setLog("[]"); + busFlowPo.setWebUrl(flowCmd.getWebUrl()); busFlowService.createAndPushBusFlow(busFlowPo); } - @Override public String createFlow(FlowCmd flowCmd) { ProcessCmd processCmd = MapperUtils.INSTANCE.map(ProcessCmd.class, flowCmd); diff --git a/ServiceSite/src/main/java/com/seasky/flowportal/utils/Util.java b/ServiceSite/src/main/java/com/seasky/flowportal/utils/Util.java index cfa3c43de98fc30b9d4243fcb6923f6c0ae90a48..975787ad296a1dc81f45ade3766eb4b52816b49f 100644 --- a/ServiceSite/src/main/java/com/seasky/flowportal/utils/Util.java +++ b/ServiceSite/src/main/java/com/seasky/flowportal/utils/Util.java @@ -1,6 +1,7 @@ package com.seasky.flowportal.utils; import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -19,19 +20,7 @@ public class Util { * @return * @throws Exception */ - public static String buildSignuate(String appCode, String secret, String timestamp, String nonce) throws Exception{ - if (appCode == null) { - throw new Exception( "appCode锛�"); - } - if (timestamp==null) { - throw new Exception( "timestamp瑙f瀽涓虹┖锛�"); - } - if (nonce == null) { - throw new Exception( "nonce瑙f瀽涓虹┖锛�"); - } - if (secret == null) { - throw new Exception( "绉侀挜閿欒锛�"); - } + public static String buildSignuate(String appCode, String secret, String timestamp, String nonce) throws Exception { return buildSignature(secret, timestamp, appCode, nonce); }