فهرست منبع

资料查询排序及其他bug

liuyc 2 سال پیش
والد
کامیت
5b11e85cf5

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/InformationQuery.java

@@ -113,4 +113,7 @@ public class InformationQuery extends BaseEntity {
     @ApiModelProperty("合并的pdfUrl,当是首件记录时(type = 3)有值")
     private String linkMergePdfUrl;
 
+    @ApiModelProperty("排序")
+    private Integer sort;
+
 }

+ 56 - 1
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -33,6 +33,7 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.core.tool.utils.Func;
@@ -58,6 +59,7 @@ import org.springblade.core.boot.ctrl.BladeController;
 
 import java.io.IOException;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 /**
@@ -979,7 +981,7 @@ public class InformationWriteQueryController extends BladeController {
     @ApiOperationSupport(order = 16)
     @ApiOperation(value = "自定义排序")
     public R<Boolean> diySort(@RequestBody DiySortVO vo) {
-        //获取排序集合
+        //获取排序集合 自定义当前同级排序
         List<String> sortList = vo.getSortList();
         if (sortList.size() > 0) {
             for (int i = 0, l = sortList.size(); i < l; i++) {
@@ -995,6 +997,59 @@ public class InformationWriteQueryController extends BladeController {
             }
         }
 
+        //对整棵树进行排序(资料查询需要同步显示排序,所以如此设计逻辑) ,采用自增
+        List<String> sortLists = vo.getSortList();
+        String id = sortLists.stream().map(String::valueOf).findAny().orElse(null);
+        WbsTreeContract wbsTreeContract = wbsTreeContractClient.getContractNodeByPrimaryKeyId(id);
+
+        //获取合同段整棵树
+        List<WbsTreeContract> list = null;
+        if (ObjectUtil.isNotEmpty(wbsTreeContract)) {
+            list = informationQueryService.getContractWbsTreeAll(wbsTreeContract);
+        }
+        List<WbsTreeContract> result = new ArrayList<>();
+        if (Objects.requireNonNull(list).size() > 0) {
+            Iterator<WbsTreeContract> iterator = list.iterator();
+            int sort = 2;
+            while (iterator.hasNext()) {
+                WbsTreeContract next = iterator.next();
+                if (ObjectUtil.isNotEmpty(next)) {
+                    if (sortList.size() > 0) {
+                        boolean b = true;
+                        for (String nowId : sortList) {
+                            if (next.getPKeyId().equals(Long.parseLong(nowId))) {
+                                //剔除自定义排序节点
+                                iterator.remove();
+                                b = false;
+                                break;
+                            }
+                        }
+                        if (!b){
+                            continue;
+                        }
+                    }
+
+                    if (ObjectUtil.isNotEmpty(next.getParentId()) && next.getParentId() == 0) {
+                        //根节点
+                        next.setSort(1);
+                    } else if (ObjectUtil.isNotEmpty(next.getParentId()) && next.getParentId() != 0) {
+                        //其他节点
+                        next.setSort(sort);
+                        sort++;
+                    }
+
+                    //修改排序
+                    result.add(next);
+
+                    iterator.remove();
+                }
+            }
+
+            informationQueryService.updateBatchByPKeyId(result);
+
+            return R.data(true);
+        }
+
         return R.data(false);
     }
 

+ 4 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.java

@@ -81,4 +81,8 @@ public interface InformationQueryMapper extends BaseMapper<InformationQuery> {
 
 	List<WbsTreeContract> getContractNodeByPrimaryKeyIds(String ids);
 
+    List<WbsTreeContract> getContractWbsTreeAll(@Param("obj") WbsTreeContract wbsTreeContract);
+
+    void updateBatchByPKeyId(@Param("list")List<WbsTreeContract> result);
+
 }

+ 17 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.xml

@@ -75,6 +75,16 @@
 
     <resultMap id="intResultMap" type="java.lang.Integer"/>
 
+    <update id="updateBatchByPKeyId">
+        <foreach collection="list" item="item" index="index" separator=";">
+            update m_wbs_tree_contract
+            <set>
+                sort = #{item.sort}
+            </set>
+            where p_key_id = #{item.pKeyId}
+        </foreach>
+    </update>
+
     <select id="queryContractTreeSupervision" resultMap="queryContractTreeMap">
         SELECT
             wtc.is_concealed_works_node AS "isConcealedWorksNode",
@@ -384,7 +394,8 @@
             query.report_number,
             query.file_user_id_and_name,
             query.pdf_url,
-            query.e_visa_pdf_url
+            query.e_visa_pdf_url,
+            (select sort from m_wbs_tree_contract c where c.p_key_id = query.wbs_id ) as sort
         from
         (
             select
@@ -423,6 +434,7 @@
         <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
             and query.createTimes between #{query.startTime} and #{query.endTime}
         </if>
+        order by sort
         limit #{current}, #{size}
     </select>
 
@@ -430,4 +442,8 @@
         select * from m_wbs_tree_contract where p_key_id in (${ids}) and is_deleted = 0 order by ancestors,sort
     </select>
 
+    <select id="getContractWbsTreeAll" resultType="org.springblade.manager.entity.WbsTreeContract">
+        select * from m_wbs_tree_contract where project_id = #{obj.projectId} and contract_id = #{obj.contractId} and `type` = 1 and status = 1
+    </select>
+
 </mapper>

+ 6 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/IInformationQueryService.java

@@ -23,6 +23,7 @@ import org.springblade.business.vo.InformationQueryVO;
 import org.springblade.business.vo.QueryProcessDataVO;
 import org.springblade.core.mp.base.BaseService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
 
 import java.util.List;
@@ -93,4 +94,9 @@ public interface IInformationQueryService extends BaseService<InformationQuery>
 	 */
 	IPage<InformationQueryVO> selectInformationQueryPage(IPage<InformationQueryVO> page, InformationQueryVO vo);
 
+
+    List<WbsTreeContract> getContractWbsTreeAll(WbsTreeContract wbsTreeContract);
+
+    void updateBatchByPKeyId(List<WbsTreeContract> result);
+
 }

+ 10 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/InformationQueryServiceImpl.java

@@ -496,6 +496,16 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
         return page.setRecords(null);
     }
 
+    @Override
+    public List<WbsTreeContract> getContractWbsTreeAll(WbsTreeContract wbsTreeContract) {
+        return baseMapper.getContractWbsTreeAll(wbsTreeContract);
+    }
+
+    @Override
+    public void updateBatchByPKeyId(List<WbsTreeContract> result) {
+        baseMapper.updateBatchByPKeyId(result);
+    }
+
     /**
      * 统合方法
      */

+ 1 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -443,10 +443,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             try {
                 this.jdbcTemplate.execute(sql.toString());
             } catch (Exception e) {
-                e.printStackTrace();
+                throw new ServiceException("当前字段值太长,请减少输入的字符数量或联系管理员");
             }
 
-
             List<Object> linkTabIds = tableInfo.getLinkTabIds();
             if (linkTabIds == null || linkTabIds.size() <= 0) {
                 //这一步主要为了兼容同工序时只想在第一张勾选的情况

+ 8 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsFormElementServiceImpl.java

@@ -128,15 +128,18 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
     @Override
     public WbsFormElement saveAndSyn(WbsFormElement wbsFormElement, String tableName) {
         try {
-
             //获取实体表主库信息
             TableInfo tableInfo = tableInfoMapper.selectById(wbsFormElement.getFId());
             if (tableInfo == null) {
                 throw new ServiceException("没有找到主库信息,确认fid是否正确");
             } else {
                 tableName = tableInfo.getTabEnName();
+            }
 
+            if(StringUtils.isEmpty(tableName)){
+                throw new ServiceException("未获取到对应的实体表名称initTableName,操作失败");
             }
+
             //获取当前表单下所有元素
             List<WbsFormElement> wbsFormElements = baseMapper.selectList(Wrappers.<WbsFormElement>query().lambda().eq(WbsFormElement::getFId, wbsFormElement.getFId()));
             String substring = "";
@@ -261,6 +264,10 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean updateAndSyn(List<WbsFormElement> wbsFormElementList, String initTableName) {
+        if (StringUtils.isEmpty(initTableName)){
+            throw new ServiceException("未获取到initTableName对应实体表名称,操作失败");
+        }
+
         //修改元素基础信息
         wbsFormElementList.forEach(obj -> obj.setStatus(1));
         boolean b = this.updateBatchById(wbsFormElementList);