Commit 0d31273adb74114effea7dc342002fc29b86d46e

Authored by 房远帅
1 parent a602d959

资金协调手续:审核消息通知及更新审核意见和审核人

@@ -3,15 +3,26 @@ package com.lframework.xingyun.sc.impl.customer; @@ -3,15 +3,26 @@ package com.lframework.xingyun.sc.impl.customer;
3 import com.fasterxml.jackson.core.JsonProcessingException; 3 import com.fasterxml.jackson.core.JsonProcessingException;
4 import com.fasterxml.jackson.databind.ObjectMapper; 4 import com.fasterxml.jackson.databind.ObjectMapper;
5 import com.lframework.starter.bpm.service.FlowTaskService; 5 import com.lframework.starter.bpm.service.FlowTaskService;
  6 +import com.lframework.starter.common.exceptions.impl.DefaultClientException;
  7 +import com.lframework.starter.common.utils.ObjectUtil;
  8 +import com.lframework.starter.mq.core.service.MqProducerService;
6 import com.lframework.starter.web.core.annotations.oplog.OpLog; 9 import com.lframework.starter.web.core.annotations.oplog.OpLog;
  10 +import com.lframework.starter.web.core.components.security.SecurityUtil;
  11 +import com.lframework.starter.web.core.utils.IdUtil;
7 import com.lframework.starter.web.core.utils.JsonUtil; 12 import com.lframework.starter.web.core.utils.JsonUtil;
8 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; 13 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  14 +import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
  15 +import com.lframework.starter.web.inner.service.system.SysUserRoleService;
  16 +import com.lframework.xingyun.sc.entity.FundCoordination;
  17 +import com.lframework.xingyun.sc.handlers.TransactorHandler;
9 import com.lframework.xingyun.sc.service.customer.CustomerCreditService; 18 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
  19 +import com.lframework.xingyun.sc.service.ledger.FundCoordinationService;
10 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService; 20 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
11 import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderService; 21 import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderService;
12 import com.lframework.xingyun.sc.vo.customer.credit.*; 22 import com.lframework.xingyun.sc.vo.customer.credit.*;
13 import com.lframework.xingyun.sc.vo.order.UpdatePurchaseOrderInfoVo; 23 import com.lframework.xingyun.sc.vo.order.UpdatePurchaseOrderInfoVo;
14 import com.lframework.xingyun.sc.vo.purchase.UpdateReplenishmentOrderVo; 24 import com.lframework.xingyun.sc.vo.purchase.UpdateReplenishmentOrderVo;
  25 +import org.apache.commons.collections.CollectionUtils;
15 import org.springframework.stereotype.Service; 26 import org.springframework.stereotype.Service;
16 import org.springframework.transaction.annotation.Transactional; 27 import org.springframework.transaction.annotation.Transactional;
17 28
@@ -27,6 +38,14 @@ public class FlowTaskServiceImpl implements FlowTaskService { @@ -27,6 +38,14 @@ public class FlowTaskServiceImpl implements FlowTaskService {
27 private PurchaseOrderInfoService purchaseOrderInfoService; 38 private PurchaseOrderInfoService purchaseOrderInfoService;
28 @Resource 39 @Resource
29 private ReplenishmentOrderService replenishmentOrderService; 40 private ReplenishmentOrderService replenishmentOrderService;
  41 + @Resource
  42 + private FundCoordinationService fundCoordinationService;
  43 + @Resource
  44 + private MqProducerService mqProducerService;
  45 + @Resource
  46 + private TransactorHandler transactorHandler;
  47 + @Resource
  48 + private SysUserRoleService sysUserRoleService;
30 49
31 50
32 @OpLog(type = OtherOpLogType.class, name = "修改客户资信,ID:{}", params = {"#id"}) 51 @OpLog(type = OtherOpLogType.class, name = "修改客户资信,ID:{}", params = {"#id"})
@@ -93,34 +112,185 @@ public class FlowTaskServiceImpl implements FlowTaskService { @@ -93,34 +112,185 @@ public class FlowTaskServiceImpl implements FlowTaskService {
93 //审核状态 112 //审核状态
94 Object e = map.get("examStatus"); 113 Object e = map.get("examStatus");
95 String examStatus = String.valueOf(e); 114 String examStatus = String.valueOf(e);
  115 + //主键
  116 + Object i = map.get("id");
  117 + String id = String.valueOf(i);
  118 + FundCoordination data = fundCoordinationService.findById(id);
  119 + if (ObjectUtil.isNull(data)) {
  120 + throw new DefaultClientException("资金协调手续不存在!");
  121 + }
  122 + //办事处Code
  123 + Object d = map.get("deptCode");
  124 + String deptCode = String.valueOf(d);
  125 + //审核人
  126 + String userId = SecurityUtil.getCurrentUser().getId();
  127 + //更新审核人及意见
  128 + fundCoordinationService.updateExamine(id, userId, nodeCode, message);
96 129
97 - if (nodeCode.equals("fund_coordination_1")) {  
98 - //办事处内勤  
99 -  
100 - } else if (nodeCode.equals("fund_coordination_2")) {  
101 - //办事处主管  
102 -  
103 - } else if (nodeCode.startsWith("fund_coordination_3-")) { 130 + //消息通知
  131 + List<String> userIdList = new ArrayList<>();
  132 + //申请人
  133 + userIdList.add(data.getApplicant());
  134 + //资金清收责任人
  135 + userIdList.add(data.getFundResponsiblePerson());
  136 + //办事处内勤
  137 + List<String> list1 = transactorHandler.listTransactorsByRoleCode("bscnq", data.getCreateById());
  138 + if (CollectionUtils.isNotEmpty(list1)) {
  139 + userIdList.addAll(list1);
  140 + }
  141 + //办事处主管
  142 + List<String> list2 = transactorHandler.listTransactorsByRoleCode("bsczg", data.getCreateById());
  143 + if (CollectionUtils.isNotEmpty(list2)) {
  144 + userIdList.addAll(list2);
  145 + }
  146 + //营销部分管
  147 + String roleCode = null;
  148 + if ("SZ".equals(deptCode) || "CZ".equals(deptCode) || "BF".equals(deptCode)) {
  149 + //苏州常州北方办事处
  150 + roleCode = "szczbfbscfg";
  151 + } else if ("GD".equals(deptCode) || "FS".equals(deptCode)) {
  152 + //东莞佛山办事处
  153 + roleCode = "dgfsbscfg";
  154 + } else if ("NB".equals(deptCode) || "WZ".equals(deptCode)) {
  155 + //宁波温州办事处
  156 + roleCode = "nbwzbscfg";
  157 + } else if ("ZT".equals(deptCode)) {
  158 + //紫铜办事处分管
  159 + roleCode = "ztbscfg";
  160 + }
  161 + if (nodeCode.startsWith("fund_coordination_3-")) {
104 //办事处分管 162 //办事处分管
  163 + //营销部分管审批的审批意见推送至:申请人、资金清收责任人、办事处内勤、办事处主管、运作科资金管理岗、运作科主管
  164 + // 获取角色下人员ID
  165 + List<String> roleCodes = new ArrayList<>();
  166 + roleCodes.add("yzkzjglg");
  167 + roleCodes.add("yzkzg");
  168 + List<String> userIds = sysUserRoleService.listUserIdByRoleCodes(roleCodes);
  169 + if (CollectionUtils.isNotEmpty(userIds)) {
  170 + userIdList.addAll(userIds);
  171 + }
105 172
  173 + SysSiteMessageDto messageDto = new SysSiteMessageDto();
  174 + messageDto.setUserIdList(userIdList);
  175 + messageDto.setTitle("资金协调手续审核通知");
  176 + if ("PASS".equals(examStatus)) {
  177 + messageDto.setContent("资金协调手续:营销部分管审核通过,具体审核意见:" + message);
  178 + } else {
  179 + messageDto.setContent("资金协调手续:营销部分管审核拒绝,具体审核意见:" + message);
  180 + }
  181 + messageDto.setBizKey(IdUtil.getId());
  182 + //如果是空表示由系统自动发起
  183 + messageDto.setCreateUserId(null);
  184 + mqProducerService.createSysSiteMessage(messageDto);
106 } else if (nodeCode.equals("fund_coordination_4")) { 185 } else if (nodeCode.equals("fund_coordination_4")) {
107 //运作科资金管理岗 186 //运作科资金管理岗
  187 + //运作科审批的审批意见推送至:申请人、资金清收责任人、办事处内勤、办事处主管
108 188
  189 + SysSiteMessageDto messageDto = new SysSiteMessageDto();
  190 + messageDto.setUserIdList(userIdList);
  191 + messageDto.setTitle("资金协调手续审核通知");
  192 + if ("PASS".equals(examStatus)) {
  193 + messageDto.setContent("资金协调手续:运作科资金管理岗审核通过,具体审核意见:" + message);
  194 + } else {
  195 + messageDto.setContent("资金协调手续:运作科资金管理岗审核拒绝,具体审核意见:" + message);
  196 + }
  197 + messageDto.setBizKey(IdUtil.getId());
  198 + //如果是空表示由系统自动发起
  199 + messageDto.setCreateUserId(null);
  200 + mqProducerService.createSysSiteMessage(messageDto);
109 } else if (nodeCode.equals("fund_coordination_5")) { 201 } else if (nodeCode.equals("fund_coordination_5")) {
110 //运作科主管 202 //运作科主管
  203 + //运作科审批的审批意见推送至:申请人、资金清收责任人、办事处内勤、办事处主管
111 204
  205 + SysSiteMessageDto messageDto = new SysSiteMessageDto();
  206 + messageDto.setUserIdList(userIdList);
  207 + messageDto.setTitle("资金协调手续审核通知");
  208 + if ("PASS".equals(examStatus)) {
  209 + messageDto.setContent("资金协调手续:运作科主管审核通过,具体审核意见:" + message);
  210 + } else {
  211 + messageDto.setContent("资金协调手续:运作科主管审核拒绝,具体审核意见:" + message);
  212 + }
  213 + messageDto.setBizKey(IdUtil.getId());
  214 + //如果是空表示由系统自动发起
  215 + messageDto.setCreateUserId(null);
  216 + mqProducerService.createSysSiteMessage(messageDto);
112 } else if (nodeCode.equals("fund_coordination_6")) { 217 } else if (nodeCode.equals("fund_coordination_6")) {
113 //营销部主管 218 //营销部主管
  219 + //营销部主管审批的审批意见推送至:申请人、资金清收责任人、办事处内勤、办事处主管、营销部分管、运作科资金管理岗、运作科主管
  220 + // 获取角色下人员ID
  221 + List<String> roleCodes = new ArrayList<>();
  222 + roleCodes.add("yzkzjglg");
  223 + roleCodes.add("yzkzg");
  224 + roleCodes.add(roleCode);
  225 + List<String> userIds = sysUserRoleService.listUserIdByRoleCodes(roleCodes);
  226 + if (CollectionUtils.isNotEmpty(userIds)) {
  227 + userIdList.addAll(userIds);
  228 + }
114 229
115 - } else if (nodeCode.equals("fund_coordination_7")) {  
116 - //财务部副经理  
117 - 230 + SysSiteMessageDto messageDto = new SysSiteMessageDto();
  231 + messageDto.setUserIdList(userIdList);
  232 + messageDto.setTitle("资金协调手续审核通知");
  233 + if ("PASS".equals(examStatus)) {
  234 + messageDto.setContent("资金协调手续:营销部主管审核通过,具体审核意见:" + message);
  235 + } else {
  236 + messageDto.setContent("资金协调手续:营销部主管审核拒绝,具体审核意见:" + message);
  237 + }
  238 + messageDto.setBizKey(IdUtil.getId());
  239 + //如果是空表示由系统自动发起
  240 + messageDto.setCreateUserId(null);
  241 + mqProducerService.createSysSiteMessage(messageDto);
118 } else if (nodeCode.equals("fund_coordination_8")) { 242 } else if (nodeCode.equals("fund_coordination_8")) {
119 //营销中心主管 243 //营销中心主管
  244 + //营销中心主管审批的审批意见推送至:申请人、资金清收责任人、办事处内勤、办事处主管、营销部分管、运作科资金管理岗、运作科主管、营销部主管
  245 + // 获取角色下人员ID
  246 + List<String> roleCodes = new ArrayList<>();
  247 + roleCodes.add("yzkzjglg");
  248 + roleCodes.add("yzkzg");
  249 + roleCodes.add(roleCode);
  250 + roleCodes.add("yxbzg");
  251 + List<String> userIds = sysUserRoleService.listUserIdByRoleCodes(roleCodes);
  252 + if (CollectionUtils.isNotEmpty(userIds)) {
  253 + userIdList.addAll(userIds);
  254 + }
120 255
  256 + SysSiteMessageDto messageDto = new SysSiteMessageDto();
  257 + messageDto.setUserIdList(userIdList);
  258 + messageDto.setTitle("资金协调手续审核通知");
  259 + if ("PASS".equals(examStatus)) {
  260 + messageDto.setContent("资金协调手续:营销中心主管审核通过,具体审核意见:" + message);
  261 + } else {
  262 + messageDto.setContent("资金协调手续:营销中心主管审核拒绝,具体审核意见:" + message);
  263 + }
  264 + messageDto.setBizKey(IdUtil.getId());
  265 + //如果是空表示由系统自动发起
  266 + messageDto.setCreateUserId(null);
  267 + mqProducerService.createSysSiteMessage(messageDto);
121 } else if (nodeCode.equals("fund_coordination_9")) { 268 } else if (nodeCode.equals("fund_coordination_9")) {
122 //总经理 269 //总经理
  270 + //总经理审批的审批意见推送至:申请人、资金清收责任人、内勤、办事处主管、营销部分管、运作科资金管理岗、运作科主管、营销部主管、营销中心主管
  271 + // 获取角色下人员ID
  272 + List<String> roleCodes = new ArrayList<>();
  273 + roleCodes.add("yzkzjglg");
  274 + roleCodes.add("yzkzg");
  275 + roleCodes.add(roleCode);
  276 + roleCodes.add("yxbzg");
  277 + List<String> userIds = sysUserRoleService.listUserIdByRoleCodes(roleCodes);
  278 + if (CollectionUtils.isNotEmpty(userIds)) {
  279 + userIdList.addAll(userIds);
  280 + }
123 281
  282 + SysSiteMessageDto messageDto = new SysSiteMessageDto();
  283 + messageDto.setUserIdList(userIdList);
  284 + messageDto.setTitle("资金协调手续审核通知");
  285 + if ("PASS".equals(examStatus)) {
  286 + messageDto.setContent("资金协调手续:总经理审核通过,具体审核意见:" + message);
  287 + } else {
  288 + messageDto.setContent("资金协调手续:总经理审核拒绝,具体审核意见:" + message);
  289 + }
  290 + messageDto.setBizKey(IdUtil.getId());
  291 + //如果是空表示由系统自动发起
  292 + messageDto.setCreateUserId(null);
  293 + mqProducerService.createSysSiteMessage(messageDto);
124 } 294 }
125 295
126 } 296 }
@@ -174,8 +174,7 @@ public class FundCoordinationServiceImpl extends BaseMpServiceImpl<FundCoordinat @@ -174,8 +174,7 @@ public class FundCoordinationServiceImpl extends BaseMpServiceImpl<FundCoordinat
174 //审核 174 //审核
175 String deptCode = transactorHandler.returnDeptCode(SecurityUtil.getCurrentUser().getId()); 175 String deptCode = transactorHandler.returnDeptCode(SecurityUtil.getCurrentUser().getId());
176 data.setDeptCode(deptCode); 176 data.setDeptCode(deptCode);
177 - flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, data);  
178 - 177 +// flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, data);
179 return data.getId(); 178 return data.getId();
180 } 179 }
181 180
@@ -283,6 +282,94 @@ public class FundCoordinationServiceImpl extends BaseMpServiceImpl<FundCoordinat @@ -283,6 +282,94 @@ public class FundCoordinationServiceImpl extends BaseMpServiceImpl<FundCoordinat
283 } 282 }
284 } 283 }
285 284
  285 + @OpLog(type = OtherOpLogType.class, name = "修改资金协调手续审核人及意见,ID:{}", params = {"#id"})
  286 + @Transactional(rollbackFor = Exception.class)
  287 + @Override
  288 + public void updateExamine(String id, String userId, String nodeCode, String message) {
  289 +
  290 + FundCoordination data = getBaseMapper().findById(id);
  291 + if (ObjectUtil.isNull(data)) {
  292 + throw new DefaultClientException("资金协调手续不存在!");
  293 + }
  294 +
  295 + if (nodeCode.equals("fund_coordination_1")) {
  296 + //办事处内勤
  297 + LambdaUpdateWrapper<FundCoordination> updateWrapper = Wrappers.lambdaUpdate(FundCoordination.class)
  298 + .set(FundCoordination::getOfficeClerk, StringUtil.isBlank(userId) ? null : userId)
  299 + .set(FundCoordination::getOfficeClerkOpinion, StringUtil.isBlank(message) ? null : message)
  300 + .eq(FundCoordination::getId, id);
  301 +
  302 + getBaseMapper().update(updateWrapper);
  303 + } else if (nodeCode.equals("fund_coordination_2")) {
  304 + //办事处主管
  305 + LambdaUpdateWrapper<FundCoordination> updateWrapper = Wrappers.lambdaUpdate(FundCoordination.class)
  306 + .set(FundCoordination::getOfficeSupervisor, StringUtil.isBlank(userId) ? null : userId)
  307 + .set(FundCoordination::getOfficeSupervisorOpinion, StringUtil.isBlank(message) ? null : message)
  308 + .eq(FundCoordination::getId, id);
  309 +
  310 + getBaseMapper().update(updateWrapper);
  311 + } else if (nodeCode.startsWith("fund_coordination_3-")) {
  312 + //办事处分管
  313 + LambdaUpdateWrapper<FundCoordination> updateWrapper = Wrappers.lambdaUpdate(FundCoordination.class)
  314 + .set(FundCoordination::getMarketingDeputyDirector, StringUtil.isBlank(userId) ? null : userId)
  315 + .set(FundCoordination::getMarketingDeputyDirectorOpinion, StringUtil.isBlank(message) ? null : message)
  316 + .eq(FundCoordination::getId, id);
  317 +
  318 + getBaseMapper().update(updateWrapper);
  319 + } else if (nodeCode.equals("fund_coordination_4")) {
  320 + //运作科资金管理岗
  321 + LambdaUpdateWrapper<FundCoordination> updateWrapper = Wrappers.lambdaUpdate(FundCoordination.class)
  322 + .set(FundCoordination::getFundManagementOperationDepartment, StringUtil.isBlank(userId) ? null : userId)
  323 + .set(FundCoordination::getFundManagementOperationDepartmentOpinion, StringUtil.isBlank(message) ? null : message)
  324 + .eq(FundCoordination::getId, id);
  325 +
  326 + getBaseMapper().update(updateWrapper);
  327 + } else if (nodeCode.equals("fund_coordination_5")) {
  328 + //运作科主管
  329 + LambdaUpdateWrapper<FundCoordination> updateWrapper = Wrappers.lambdaUpdate(FundCoordination.class)
  330 + .set(FundCoordination::getOperationsDepartmentSupervisor, StringUtil.isBlank(userId) ? null : userId)
  331 + .set(FundCoordination::getOperationsDepartmentSupervisorOpinion, StringUtil.isBlank(message) ? null : message)
  332 + .eq(FundCoordination::getId, id);
  333 +
  334 + getBaseMapper().update(updateWrapper);
  335 + } else if (nodeCode.equals("fund_coordination_6")) {
  336 + //营销部主管
  337 + LambdaUpdateWrapper<FundCoordination> updateWrapper = Wrappers.lambdaUpdate(FundCoordination.class)
  338 + .set(FundCoordination::getMarketingDepartmentManager, StringUtil.isBlank(userId) ? null : userId)
  339 + .set(FundCoordination::getMarketingDepartmentManagerOpinion, StringUtil.isBlank(message) ? null : message)
  340 + .eq(FundCoordination::getId, id);
  341 +
  342 + getBaseMapper().update(updateWrapper);
  343 + } else if (nodeCode.equals("fund_coordination_7")) {
  344 + //财务部副经理
  345 + LambdaUpdateWrapper<FundCoordination> updateWrapper = Wrappers.lambdaUpdate(FundCoordination.class)
  346 + .set(FundCoordination::getFinanceDepartment, StringUtil.isBlank(userId) ? null : userId)
  347 + .set(FundCoordination::getFinanceDepartmentOpinion, StringUtil.isBlank(message) ? null : message)
  348 + .eq(FundCoordination::getId, id);
  349 +
  350 + getBaseMapper().update(updateWrapper);
  351 + } else if (nodeCode.equals("fund_coordination_8")) {
  352 + //营销中心主管
  353 + LambdaUpdateWrapper<FundCoordination> updateWrapper = Wrappers.lambdaUpdate(FundCoordination.class)
  354 + .set(FundCoordination::getMarketingCenterSupervisor, StringUtil.isBlank(userId) ? null : userId)
  355 + .set(FundCoordination::getMarketingCenterSupervisorOpinion, StringUtil.isBlank(message) ? null : message)
  356 + .eq(FundCoordination::getId, id);
  357 +
  358 + getBaseMapper().update(updateWrapper);
  359 + } else if (nodeCode.equals("fund_coordination_9")) {
  360 + //总经理
  361 + LambdaUpdateWrapper<FundCoordination> updateWrapper = Wrappers.lambdaUpdate(FundCoordination.class)
  362 + .set(FundCoordination::getGeneralManager, StringUtil.isBlank(userId) ? null : userId)
  363 + .set(FundCoordination::getGeneralManagerOpinion, StringUtil.isBlank(message) ? null : message)
  364 + .eq(FundCoordination::getId, id);
  365 +
  366 + getBaseMapper().update(updateWrapper);
  367 + }
  368 +
  369 + OpLogUtil.setVariable("id", data.getId());
  370 + OpLogUtil.setExtra(id);
  371 + }
  372 +
286 373
287 @Override 374 @Override
288 public void cleanCacheByKey(Serializable key) { 375 public void cleanCacheByKey(Serializable key) {
@@ -67,4 +67,14 @@ public interface FundCoordinationService extends BaseMpService<FundCoordination> @@ -67,4 +67,14 @@ public interface FundCoordinationService extends BaseMpService<FundCoordination>
67 * @param id 主键 67 * @param id 主键
68 */ 68 */
69 void reviewPass(String id); 69 void reviewPass(String id);
  70 +
  71 + /**
  72 + * 更新审核人及意见
  73 + *
  74 + * @param id 主键
  75 + * @param userId 审核人
  76 + * @param nodeCode 审核节点
  77 + * @param message 审核意见
  78 + */
  79 + void updateExamine(String id, String userId, String nodeCode, String message);
70 } 80 }