he2802 2 سال پیش
والد
کامیت
265301bcc7

+ 6 - 1
zhongzheng-admin-saas/src/main/java/com/zhongzheng/controller/financial/TopCostTpController.java

@@ -1,5 +1,6 @@
 package com.zhongzheng.controller.financial;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Arrays;
 
@@ -51,7 +52,11 @@ public class TopCostTpController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo<TopCostTpVo> list(TopCostTpQueryBo bo) {
         startPage();
-        List<TopCostTpVo> list = iTopCostTpService.queryList(bo);
+        List<Integer> statusList = new ArrayList<>();
+        statusList.add(0);
+        statusList.add(1);
+        bo.setStatusList(statusList);
+        List<TopCostTpVo> list = iTopCostTpService.selectList(bo);
         return getDataTable(list);
     }
 

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/financial/bo/TopCostTpQueryBo.java

@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.List;
+
 /**
  * 成本模板分页查询对象 top_cost_tp
  *
@@ -39,4 +41,8 @@ public class TopCostTpQueryBo extends BaseEntity {
 	private Integer status;
 	@ApiModelProperty("机构ID")
 	private Long tenantId;
+	@ApiModelProperty("机构排序")
+	private Integer tenantSort;
+	@ApiModelProperty("0 禁用 1启用")
+	private List<Integer> statusList;
 }

+ 5 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/financial/mapper/TopCostTpMapper.java

@@ -2,7 +2,11 @@ package com.zhongzheng.modules.top.financial.mapper;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.top.financial.bo.TopCostTpQueryBo;
 import com.zhongzheng.modules.top.financial.domain.TopCostTp;
+import com.zhongzheng.modules.top.financial.vo.TopCostTpVo;
+
+import java.util.List;
 
 /**
  * 成本模板Mapper接口
@@ -11,5 +15,5 @@ import com.zhongzheng.modules.top.financial.domain.TopCostTp;
  * @date 2023-04-20
  */
 public interface TopCostTpMapper extends BaseMapper<TopCostTp> {
-
+   List<TopCostTpVo> selectList(TopCostTpQueryBo queryBo);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/financial/service/ITopCostTpService.java

@@ -52,4 +52,6 @@ public interface ITopCostTpService extends IService<TopCostTp> {
 
 
 	Boolean updateDefaultStatus(TopCostTpEditBo bo);
+
+	List<TopCostTpVo> selectList(TopCostTpQueryBo queryBo);
 }

+ 24 - 15
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/financial/service/impl/TopCostTpServiceImpl.java

@@ -54,6 +54,7 @@ public class TopCostTpServiceImpl extends ServiceImpl<TopCostTpMapper, TopCostTp
         LambdaQueryWrapper<TopCostTp> lqw = Wrappers.lambdaQuery();
         lqw.like(StrUtil.isNotBlank(bo.getTpName()), TopCostTp::getTpName, bo.getTpName());
         lqw.eq(bo.getStatus() != null, TopCostTp::getStatus, bo.getStatus());
+        lqw.in(bo.getStatusList() != null, TopCostTp::getStatus, bo.getStatusList());
         List<TopCostTpVo> list = entity2Vo(this.list(lqw));
         for(TopCostTpVo vo:list){
             TopCostTpItemQueryBo itemQueryBo = new TopCostTpItemQueryBo();
@@ -122,10 +123,12 @@ public class TopCostTpServiceImpl extends ServiceImpl<TopCostTpMapper, TopCostTp
         TopCostTp update = BeanUtil.toBean(bo, TopCostTp.class);
         validEntityBeforeSave(update);
         update.setUpdateTime(DateUtils.getNowTime());
-        iTopCostTpItemService.remove(new LambdaQueryWrapper<TopCostTpItem>().eq(TopCostTpItem::getTpId, bo.getTpId()));
-        for(TopCostTpItemAddBo itemBo : bo.getItemList()){
-            itemBo.setTpId(bo.getTpId());
-            iTopCostTpItemService.insertByAddBo(itemBo);
+        if(Validator.isNotEmpty(bo.getItemList())){
+            iTopCostTpItemService.remove(new LambdaQueryWrapper<TopCostTpItem>().eq(TopCostTpItem::getTpId, bo.getTpId()));
+            for(TopCostTpItemAddBo itemBo : bo.getItemList()){
+                itemBo.setTpId(bo.getTpId());
+                iTopCostTpItemService.insertByAddBo(itemBo);
+            }
         }
         if(this.updateById(update)){
             if(Validator.isNotEmpty(bo.getDefaultStatus())){
@@ -136,7 +139,6 @@ public class TopCostTpServiceImpl extends ServiceImpl<TopCostTpMapper, TopCostTp
                     objectLambdaUpdateWrapper.set(TopCostTp::getUpdateTime, DateUtils.getNowTime());
                     update(null, objectLambdaUpdateWrapper);
                 }
-
             }
             return true;
         }
@@ -165,18 +167,25 @@ public class TopCostTpServiceImpl extends ServiceImpl<TopCostTpMapper, TopCostTp
     public Boolean updateDefaultStatus(TopCostTpEditBo bo) {
         TopCostTp update = new TopCostTp();
         update.setTpId(bo.getTpId());
-        if(bo.getDefaultStatus()==1){
-            LambdaUpdateWrapper<TopCostTp> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
-            objectLambdaUpdateWrapper.ne(TopCostTp::getTpId, bo.getTpId());
-            objectLambdaUpdateWrapper.set(TopCostTp::getDefaultStatus, 0);
-            objectLambdaUpdateWrapper.set(TopCostTp::getUpdateTime, DateUtils.getNowTime());
-            update(null, objectLambdaUpdateWrapper);
-            update.setDefaultStatus(1);
-        }
-        if(bo.getDefaultStatus()==0){
-            update.setDefaultStatus(0);
+        if(Validator.isNotEmpty(bo.getDefaultStatus())){
+            if(bo.getDefaultStatus()==1){
+                LambdaUpdateWrapper<TopCostTp> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+                objectLambdaUpdateWrapper.ne(TopCostTp::getTpId, bo.getTpId());
+                objectLambdaUpdateWrapper.set(TopCostTp::getDefaultStatus, 0);
+                objectLambdaUpdateWrapper.set(TopCostTp::getUpdateTime, DateUtils.getNowTime());
+                update(null, objectLambdaUpdateWrapper);
+                update.setDefaultStatus(1);
+            }
+            if(bo.getDefaultStatus()==0){
+                update.setDefaultStatus(0);
+            }
         }
         update.setUpdateTime(DateUtils.getNowTime());
         return this.updateById(update);
     }
+
+    @Override
+    public List<TopCostTpVo> selectList(TopCostTpQueryBo queryBo) {
+        return this.baseMapper.selectList(queryBo);
+    }
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/financial/vo/TopCostTpVo.java

@@ -37,4 +37,6 @@ public class TopCostTpVo {
 	private Long tenantId;
 	@ApiModelProperty("默认状态")
 	private Integer defaultStatus;
+	@ApiModelProperty("机构名称")
+	private String tenantName;
 }

+ 25 - 1
zhongzheng-system/src/main/resources/mapper/modules/top/TopCostTpMapper.xml

@@ -13,5 +13,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="defaultStatus" column="default_status"/>
     </resultMap>
 
-
+    <select id="selectList" parameterType="com.zhongzheng.modules.top.financial.bo.TopCostTpQueryBo"  resultType="com.zhongzheng.modules.top.financial.vo.TopCostTpVo">
+        SELECT
+            ct.*,
+            st.tenant_name
+        FROM
+            top_cost_tp ct
+                LEFT JOIN sys_tenant st ON ct.tenant_id = st.tenant_id
+        WHERE
+            1 = 1
+        <if test="status != null and status.size()!=0 ">
+            AND ct.status in
+            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="tpName != null and tpName != ''">
+            AND ct.tp_name  like concat('%', #{tpName}, '%')
+        </if>
+        <if test="tenantSort != null and tenantSort == 1">
+            ORDER BY ct.tenant_id
+        </if>
+        <if test="tenantSort != null and tenantSort == 0">
+            ORDER BY ct.tenant_id DESC
+        </if>
+    </select>
 </mapper>