wangliang 1 год назад
Родитель
Сommit
cbfd176b5d

+ 8 - 3
sop-business/src/main/java/com/qmth/sop/business/mapper/TBSopInfoMapper.java

@@ -84,21 +84,26 @@ public interface TBSopInfoMapper extends BaseMapper<TBSopInfo> {
      * @param fieldValue
      * @param dpr
      * @param fieldOrder
+     * @param defaultFieldName
+     * @param defaultFieldOrder
      * @param leadId
      * @param crmUserId
      * @param customName
      * @param taskKey
      * @param crmName
      * @param sopNo
+     * @param dingPlan
      * @return
      */
     @SuppressWarnings("MybatisXMapperMethodInspection")
     IPage<Map> list(IPage<Map> iPage, @Param("type") String type, @Param("serviceId") Long serviceId,
             @Param("tableName") String tableName, @Param("fieldName") String fieldName,
             @Param("fieldValue") String fieldValue, @Param("dpr") DataPermissionDto dpr,
-            @Param("fieldOrder") String fieldOrder, @Param("leadId") Long leadId, @Param("crmUserId") Long crmUserId,
-            @Param("customName") String customName, @Param("taskKey") String taskKey, @Param("crmName") String crmName,
-            @Param("sopNo") String sopNo, @Param("dingPlan") String dingPlan);
+            @Param("fieldOrder") String fieldOrder, @Param("defaultFieldName") String defaultFieldName,
+            @Param("defaultFieldOrder") String defaultFieldOrder, @Param("leadId") Long leadId,
+            @Param("crmUserId") Long crmUserId, @Param("customName") String customName,
+            @Param("taskKey") String taskKey, @Param("crmName") String crmName, @Param("sopNo") String sopNo,
+            @Param("dingPlan") String dingPlan);
 
     /**
      * 根据crmNo查询在途的sop信息

+ 58 - 16
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -694,18 +694,57 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         Optional.ofNullable(maxTfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
         sopInfoListParam.setVersion(maxTfCustomFlow.getVersion());
         String tableName = sopInfoListParam.getType().getTableName() + "_" + sopInfoListParam.getVersion();
-        String fieldName = null, fieldValue = null, fieldOrder = null;
+        String fieldName = null, fieldValue = null, fieldOrder = null, defaultFieldName = null, defaultFieldOrder = null;
         StringJoiner stringJoinerView = new StringJoiner(",");
         StringJoiner stringJoinerCondition = new StringJoiner("");
         StringJoiner stringJoinerOrder = new StringJoiner("");
+        StringJoiner stringJoinerDefaultView = new StringJoiner(",");
+        StringJoiner stringJoinerDefaultFieldOrderView = new StringJoiner(",");
+        stringJoinerDefaultFieldOrderView = stringJoinerDefaultFieldOrderView.add("order by tbsi.update_time desc");
 
         //显示字段
+        boolean pendApproveName = false;
         if (!CollectionUtils.isEmpty(sopInfoListParam.getFormWidgetMetadataViewList())) {
             for (FormWidgetMetadataParam f : sopInfoListParam.getFormWidgetMetadataViewList()) {
-                stringJoinerView.add(f.getFieldId());
+                //加入固定字段转换
+                if (SystemConstant.SOP_TRANSFORM_MAP.containsKey(f.getFieldId())) {
+                    if (Objects.equals(f.getFieldId(), "pendApproveName")) {
+                        pendApproveName = true;
+                    } else if (Objects.equals(f.getFieldId(), "taskName")) {
+                        stringJoinerDefaultView.add(
+                                "IFNULL(" + SystemConstant.SOP_TRANSFORM_MAP.get(f.getFieldId()) + ",'--') as "
+                                        + f.getFieldId());
+                    } else if (Objects.equals(f.getFieldId(), "sopNo")) {
+                        stringJoinerDefaultFieldOrderView.add(
+                                SystemConstant.SOP_TRANSFORM_MAP.get(f.getFieldId()) + " desc");
+                        stringJoinerDefaultView.add(
+                                SystemConstant.SOP_TRANSFORM_MAP.get(f.getFieldId()) + " as " + f.getFieldId());
+                    } else {
+                        stringJoinerDefaultView.add(
+                                SystemConstant.SOP_TRANSFORM_MAP.get(f.getFieldId()) + " as " + f.getFieldId());
+                    }
+                } else {
+                    stringJoinerView.add(f.getFieldId());
+                }
             }
             fieldName = stringJoinerView.toString();
+        } else {
+            for (Map.Entry<String, String> entry : SystemConstant.SOP_TRANSFORM_MAP.entrySet()) {
+                if (Objects.equals(entry.getKey(), "pendApproveName")) {
+                    pendApproveName = true;
+                } else if (Objects.equals(entry.getKey(), "taskName")) {
+                    stringJoinerDefaultView.add("IFNULL(" + entry.getValue() + ",'--') as " + entry.getKey());
+                } else if (Objects.equals(entry.getKey(), "sopNo")) {
+                    stringJoinerDefaultFieldOrderView.add(entry.getValue() + " desc");
+                    stringJoinerDefaultView.add(entry.getValue() + " as " + entry.getKey());
+                } else {
+                    stringJoinerDefaultView.add(entry.getValue() + " as " + entry.getKey());
+                }
+            }
         }
+        defaultFieldName = stringJoinerDefaultView.toString();
+        defaultFieldOrder = stringJoinerDefaultFieldOrderView.toString();
+
         //筛选字段
         if (!CollectionUtils.isEmpty(sopInfoListParam.getFormWidgetMetadataConditionList())) {
             LinkedMultiValueMap<String, FormWidgetMetadataParam> formWidgetMetadataParamLinkedMultiValueMap = new LinkedMultiValueMap<>(
@@ -849,9 +888,10 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         IPage<Map> list = this.baseMapper.list(
                 new Page<>(sopInfoListParam.getPageNumber(), sopInfoListParam.getPageSize()),
                 Objects.nonNull(sopInfoListParam.getType()) ? sopInfoListParam.getType().name() : null,
-                sopInfoListParam.getServiceId(), tableName, fieldName, fieldValue, dpr, fieldOrder,
-                sopInfoListParam.getLeadId(), sopInfoListParam.getCrmUserId(), sopInfoListParam.getCustomName(),
-                sopInfoListParam.getTaskKey(), sopInfoListParam.getCrmName(), sopInfoListParam.getSopNo(),
+                sopInfoListParam.getServiceId(), tableName, fieldName, fieldValue, dpr, fieldOrder, defaultFieldName,
+                defaultFieldOrder, sopInfoListParam.getLeadId(), sopInfoListParam.getCrmUserId(),
+                sopInfoListParam.getCustomName(), sopInfoListParam.getTaskKey(), sopInfoListParam.getCrmName(),
+                sopInfoListParam.getSopNo(),
                 Objects.nonNull(sopInfoListParam.getDingPlan()) ? sopInfoListParam.getDingPlan().toString() : null);
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         for (Map m : list.getRecords()) {
@@ -888,17 +928,19 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             }
 
             String flowId = (String) m.get("flowId");
-            TFFlowLog tfFlowLog = tfFlowLogService.findByLastFlowLog(Long.parseLong(flowId));
-            if (Objects.nonNull(tfFlowLog) && Objects.nonNull(tfFlowLog.getPendApproveId())) {
-                List<String> userList = Arrays.asList(
-                        tfFlowLog.getPendApproveId().split(SystemConstant.LIST_JOIN_SPLIT));
-                List<OrgUserNameDto> orgUserNameDtoList = sysUserService.findOrgUserName(
-                        userList.stream().map(s -> Long.parseLong(s)).collect(Collectors.toList()));
-                List<String> userName = orgUserNameDtoList.stream().map(s -> s.getOrgUserName())
-                        .collect(Collectors.toList());
-                m.put("pendApproveName", StringUtils.join(userName, SystemConstant.LIST_JOIN_SPLIT));
-            } else {
-                m.put("pendApproveName", "--");
+            if (pendApproveName) {
+                TFFlowLog tfFlowLog = tfFlowLogService.findByLastFlowLog(Long.parseLong(flowId));
+                if (Objects.nonNull(tfFlowLog) && Objects.nonNull(tfFlowLog.getPendApproveId())) {
+                    List<String> userList = Arrays.asList(
+                            tfFlowLog.getPendApproveId().split(SystemConstant.LIST_JOIN_SPLIT));
+                    List<OrgUserNameDto> orgUserNameDtoList = sysUserService.findOrgUserName(
+                            userList.stream().map(s -> Long.parseLong(s)).collect(Collectors.toList()));
+                    List<String> userName = orgUserNameDtoList.stream().map(s -> s.getOrgUserName())
+                            .collect(Collectors.toList());
+                    m.put("pendApproveName", StringUtils.join(userName, SystemConstant.LIST_JOIN_SPLIT));
+                } else {
+                    m.put("pendApproveName", "--");
+                }
             }
 
             String taskIds = (String) m.get("taskId");

+ 4 - 16
sop-business/src/main/resources/mapper/TBSopInfoMapper.xml

@@ -43,28 +43,17 @@
 
     <select id="list" resultType="java.util.Map">
         select distinct cast(tbsi.id as char) as id,
+                <if test="defaultFieldName != null and defaultFieldName != ''">
+                    ${defaultFieldName},
+                </if>
                cast(tbs.id as char) as serviceId,
-               tbs.name as serviceName,
-               tbsi.sop_no as sopNo,
                tbsi.update_time as updateTime,
-               tbsi.crm_no as crmNo,
-               tbc.begin_time as beginTime,
                cast(su1.id as char) as customManagerId,
-               su1.real_name as customManagerName,
-               sc.type as customManagerType,
                IF(sc.type = 'OFFICE','教务处','研究生') as customManagerTypeStr,
-               sc.name as customName,
-               tbc.name as crmName,
                cast(tbp.id as char) as productId,
-               tbp.name as productName,
-               tbc.exam_start_time as examStartTime,
-               tbc.exam_end_time as examEndTime,
                cast(tfcfe.flow_id as char) as flowId,
                cast(tfcfe.create_id as char) as flowCreateId,
-               su2.real_name as flowCreateName,
-               tffa.create_time as flowCreateTime,
                tffa.update_time as flowUpdateTime,
-               tffa.status,
                CASE
                 WHEN tffa.status = 'FINISH' THEN '已完结'
                 WHEN tffa.status = 'END' THEN '已作废'
@@ -74,7 +63,6 @@
                IF(tfcf.type = 'OFFICE_SOP_FLOW','教务处SOP','研究生SOP') as typeStr,
                tfcf.version,
                cast(tfcf.flow_deployment_id as char) as flowDeploymentId,
-               IFNULL(art.NAME_,'--') as taskName,
                art.TASK_DEF_KEY_ as taskDefKey,
                tbcd.id as crmDetailId,
                tbcd.course_name as courseName,
@@ -193,7 +181,7 @@
                  order by ${fieldOrder}
              </when>
              <otherwise>
-                 order by tbsi.sop_no desc,tbsi.update_time desc
+                 ${defaultFieldOrder}
              </otherwise>
          </choose>
     </select>