Commit 54f815056877c9947337f453c5ad9d4475ff97ad

Authored by 房远帅
1 parent 83d4cbd4

采购:内贸资信获取审核人

1 1 package com.lframework.xingyun.sc.procurement.impl.credit;
2 2
  3 +import cn.hutool.json.JSONArray;
  4 +import cn.hutool.json.JSONObject;
3 5 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4 6 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
5 7 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
... ... @@ -344,8 +346,46 @@ public class ProcurementDomesticCustomerCreditServiceImpl
344 346 if (StringUtils.isBlank(id)) {
345 347 return new DomesticReviewerDto();
346 348 }
347   - DomesticReviewerDto reviewer = getBaseMapper().getReviewerById(id);
348   - return reviewer == null ? new DomesticReviewerDto() : reviewer;
  349 + DomesticReviewerDto reviewer = new DomesticReviewerDto();
  350 + reviewer.setId(id);
  351 +
  352 + String defJson = getBaseMapper().getLatestFlowDefJson(id);
  353 + if (StringUtils.isBlank(defJson)) {
  354 + return reviewer;
  355 + }
  356 +
  357 + JSONObject flowJson = JsonUtil.parseObj(defJson);
  358 + Object nodeListObj = flowJson.get("nodeList");
  359 + if (ObjectUtil.isNull(nodeListObj)) {
  360 + return reviewer;
  361 + }
  362 +
  363 + JSONArray nodeList = JsonUtil.parseArray(nodeListObj);
  364 + for (Object nodeObj : nodeList) {
  365 + if (ObjectUtil.isNull(nodeObj)) {
  366 + continue;
  367 + }
  368 +
  369 + JSONObject nodeJson = JsonUtil.parseObj(nodeObj);
  370 + String nodeCode = nodeJson.getStr("nodeCode");
  371 + if (StringUtils.isBlank(nodeCode)) {
  372 + continue;
  373 + }
  374 +
  375 + String approverName = getFirstApproverName(nodeJson);
  376 + if (StringUtils.isBlank(approverName)) {
  377 + continue;
  378 + }
  379 +
  380 + if (isProcurementOfficeNode(nodeCode)) {
  381 + reviewer.setProcurementOffice(approverName);
  382 + } else if ("domestic_customer_credit_gyglk".equals(nodeCode)) {
  383 + reviewer.setSupplyManagementSection(approverName);
  384 + } else if ("domestic_customer_credit_gybzg".equals(nodeCode)) {
  385 + reviewer.setSupplyDepartment(approverName);
  386 + }
  387 + }
  388 + return reviewer;
349 389 }
350 390
351 391 /**
... ... @@ -417,6 +457,49 @@ public class ProcurementDomesticCustomerCreditServiceImpl
417 457 }
418 458
419 459 /**
  460 + * 获取节点首个审批人名称
  461 + *
  462 + * @param nodeJson 流程节点JSON
  463 + * @return 审批人名称
  464 + */
  465 + private String getFirstApproverName(JSONObject nodeJson) {
  466 + if (nodeJson == null) {
  467 + return null;
  468 + }
  469 +
  470 + JSONObject extMap = nodeJson.getJSONObject("extMap");
  471 + if (extMap == null) {
  472 + return null;
  473 + }
  474 +
  475 + Object handleInfosObj = extMap.get("handleInfos");
  476 + if (ObjectUtil.isNull(handleInfosObj)) {
  477 + return null;
  478 + }
  479 +
  480 + JSONArray handleInfos = JsonUtil.parseArray(handleInfosObj);
  481 + if (handleInfos.isEmpty()) {
  482 + return null;
  483 + }
  484 +
  485 + JSONObject firstHandleInfo = JsonUtil.parseObj(handleInfos.get(0));
  486 + return firstHandleInfo.getStr("createBy");
  487 + }
  488 +
  489 + /**
  490 + * 判断是否为采购处主管节点
  491 + *
  492 + * @param nodeCode 节点编码
  493 + * @return 是否为采购处主管节点
  494 + */
  495 + private boolean isProcurementOfficeNode(String nodeCode) {
  496 + return "domestic_customer_credit_cgczg_1".equals(nodeCode)
  497 + || "domestic_customer_credit_cgczg_2".equals(nodeCode)
  498 + || "domestic_customer_credit_cgczg_3".equals(nodeCode)
  499 + || "domestic_customer_credit_cgczg_4".equals(nodeCode);
  500 + }
  501 +
  502 + /**
420 503 * 发送评审有效期提醒消息。
421 504 *
422 505 * @param customerCredit 内贸资信
... ...
... ... @@ -26,7 +26,7 @@ public interface ProcurementDomesticCustomerCreditMapper extends BaseMapper<Proc
26 26 ProcurementDomesticCustomerCredit findById(@Param("id") String id);
27 27
28 28 /**
29   - * 获取审核人
  29 + * 查询最新流程定义JSON
30 30 */
31   - DomesticReviewerDto getReviewerById(@Param("id") String id);
  31 + String getLatestFlowDefJson(@Param("id") String id);
32 32 }
... ...
... ... @@ -179,35 +179,11 @@
179 179 WHERE tb.id = #{id}
180 180 </select>
181 181
182   - <select id="getReviewerById" resultType="com.lframework.xingyun.sc.procurement.dto.DomesticReviewerDto">
183   - SELECT
184   - business_id,
185   - -- 1. 采购处主管 (动态获取)
186   - JSON_UNQUOTE(
187   - JSON_EXTRACT(def_json, CONCAT(
188   - REPLACE(JSON_SEARCH(def_json, 'one', 'domestic_customer_credit_cgczg_%'), '.nodeCode', ''),
189   - '.extMap.handleInfos[0].createBy'
190   - ))
191   - ) AS procurementOffice,
192   -
193   - -- 2. 供应管理科主管 (domestic_customer_credit_gyglk)
194   - JSON_UNQUOTE(
195   - JSON_EXTRACT(def_json, CONCAT(
196   - REPLACE(JSON_SEARCH(def_json, 'one', 'domestic_customer_credit_gyglk'), '.nodeCode', ''),
197   - '.extMap.handleInfos[0].createBy'
198   - ))
199   - ) AS supplyManagementSection,
200   -
201   - -- 3. 供应部主管 (domestic_customer_credit_gybzg)
202   - JSON_UNQUOTE(
203   - JSON_EXTRACT(def_json, CONCAT(
204   - REPLACE(JSON_SEARCH(def_json, 'one', 'domestic_customer_credit_gybzg'), '.nodeCode', ''),
205   - '.extMap.handleInfos[0].createBy'
206   - ))
207   - ) AS supplyDepartment
208   -
  182 + <select id="getLatestFlowDefJson" resultType="java.lang.String">
  183 + SELECT def_json
209 184 FROM flow_instance
210 185 WHERE business_id = #{id}
211   - ORDER BY create_time DESC LIMIT 1
  186 + ORDER BY create_time DESC
  187 + LIMIT 1
212 188 </select>
213 189 </mapper>
... ...