Procházet zdrojové kódy

Merge branch 'master' of http://39.108.216.210:3000/zhuwei/bladex

huangtf před 8 měsíci
rodič
revize
c19bc71b82

+ 17 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/FormData.java

@@ -3,6 +3,7 @@ package org.springblade.manager.dto;
 
 import lombok.Data;
 import lombok.Setter;
+import org.checkerframework.checker.units.qual.A;
 import org.springblade.common.utils.BaseUtils;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringPool;
@@ -10,6 +11,7 @@ import org.springblade.manager.entity.Formula;
 
 import java.util.*;
 import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -244,11 +246,25 @@ public class FormData {
         return !Objects.isNull(this.getFormula());
     }
 
+
+    /*元素非空判断*/
+    public static Predicate<Object> isNotEmpty = s->{
+        if(s!=null){
+            String s1= s.toString().replaceAll("[\\s\\t\\n]+","");
+            return !s1.isEmpty()&&!s1.matches("[/]+");
+        }
+        return false;
+    };
+
+/*    public static void main(String[] args) {
+        List<String> list = Arrays.asList("//","/1/"," "," xxx  ","/");
+        list.forEach(e-> System.out.println(isNotEmpty.test(e)));
+    }*/
     /**
      * 元素内容是否为空
      */
     public Boolean empty() {
-        return !(Func.isNotEmpty(this.values) && this.values.stream().map(ElementData::getValue).anyMatch(Func::isNotEmpty));
+        return !(this.values.size()>0&& this.values.stream().map(ElementData::getValue).anyMatch(isNotEmpty));
     }
 
     public List<Object> getRawValue(){

+ 5 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractInventoryFormController.java

@@ -31,6 +31,7 @@ import org.springblade.meter.vo.ContractInventoryFormVO;
 import org.springblade.meter.vo.ContractInventoryFormVO2;
 import org.springblade.meter.vo.FormTreeVO;
 import org.springblade.meter.vo.InventoryFormDetailVO;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -56,6 +57,8 @@ public class ContractInventoryFormController extends BladeController {
 
 	private final IContractInventoryFormService contractInventoryFormService;
 
+	private final JdbcTemplate jdbcTemplate;
+
 
 	/**
 	 * 获取合同清单树
@@ -175,7 +178,8 @@ public class ContractInventoryFormController extends BladeController {
 	@ApiOperationSupport(order = 8)
 	@ApiOperation(value = "获取导入模板", notes = "返回导入模板URL")
 	public R<String> getImportTemplate() {
-		return R.data("https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240401/b5d3d7780a343641c0cc414dee7991f8.xls");
+		String url = jdbcTemplate.queryForObject("select dict_value from blade_dict_biz where code = 'import_template' and dict_key = 11 and is_deleted = 0", String.class);
+		return R.data(url);
 	}
 
 

+ 14 - 30
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/MeterTreeController.java

@@ -772,36 +772,8 @@ public class MeterTreeController extends BladeController {
     @GetMapping("/contract/remove")
     @ApiOperationSupport(order = 29)
     @ApiOperation(value = "合同段树节点删除", notes = "传入id")
-    public R<Object> contractRemove(@RequestParam String id) {
-        if (StringUtils.isNotEmpty(id)) {
-            MeterTreeContract obj = meterTreeContractService.getById(id);
-            if (obj != null) {
-                if (obj.getParentId().equals(0L) && obj.getAncestor().equals("0")) {
-                    throw new ServiceException("根节点无法删除");
-                }
-
-                /*子节点判断*/
-                Long countChild = meterTreeContractService.getBaseMapper().selectCount(Wrappers.<MeterTreeContract>lambdaQuery()
-                        .eq(MeterTreeContract::getTemplateId, obj.getTemplateId())
-                        .eq(MeterTreeContract::getProjectId, obj.getProjectId())
-                        .eq(MeterTreeContract::getContractId, obj.getContractId())
-                        .eq(MeterTreeContract::getStatus, 1)
-                        .like(MeterTreeContract::getAncestor, id));
-                if (countChild > 0) {
-                    throw new ServiceException("该节点下存在子节点,无法删除");
-                }
-
-                /*清单判断*/
-                Long inventoryFormMeterCount = inventoryFormMeterService.getBaseMapper().selectCount(Wrappers.<InventoryFormMeter>lambdaQuery()
-                        .eq(InventoryFormMeter::getContractMeterId, id));
-                if (inventoryFormMeterCount != null && inventoryFormMeterCount > 0) {
-                    throw new ServiceException("该节点下存在清单信息,无法删除");
-                }
-
-                return R.data(meterTreeContractService.removeById(id));
-            }
-        }
-        return R.fail("操作失败");
+    public R<Object> contractRemove(@RequestParam Long id) {
+        return meterTreeContractService.contractRemove(id);
     }
 
     @GetMapping("/contract/lock")
@@ -913,4 +885,16 @@ public class MeterTreeController extends BladeController {
         return R.success("取消关联成功");
     }
 
+    @GetMapping("/contract/importTemplate")
+    @ApiOperationSupport(order = 37)
+    @ApiOperation(value = "获取合同计量单元导入模板", notes = "获取合同计量单元导入模板,传入type")
+    public R<String> importTemplate(Integer type) {
+        if (type == null) {
+            R.fail("操作失败,请传入type");
+        }
+        String url = jdbcTemplate.queryForObject("select dict_value from blade_dict_biz where code = 'import_template' and dict_key = "+type+" and is_deleted = 0", String.class);
+        return R.data(url);
+
+    }
+
 }

+ 3 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/InventoryFormMeterMapper.java

@@ -40,4 +40,7 @@ public interface InventoryFormMeterMapper extends BaseMapper<InventoryFormMeter>
     void batchInsert(List<InventoryFormMeter> inventoryFormMeters);
 
     List<InventoryFormMeterVO> getFormByNodeIds(@Param("contractId") Long contractId,@Param("ids") List<Long> nodeIds);
+
+    //根据计量单元id,删除当前节点以及下层节点,关联的所有清单
+    void deleteByNodeId(@Param("meterId") Long meterId,@Param("contractId") Long contractId);
 }

+ 3 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/InventoryFormMeterMapper.xml

@@ -30,6 +30,9 @@
             #{item.changeBuildPictureMoney})
         </foreach>
     </insert>
+    <delete id="deleteByNodeId">
+        DELETE FROM s_inventory_form_meter WHERE contract_meter_id in ( select id from s_meter_tree_contract where contract_id = #{contractId} and is_deleted = 0 and (id = #{meterId} or FIND_IN_SET(#{meterId}, ancestor)))
+    </delete>
 
     <select id="getNodeAllForm" resultType="java.lang.Long">
         select contract_form_id

+ 9 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MeterTreeContractMapper.java

@@ -1,6 +1,7 @@
 package org.springblade.meter.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.springblade.meter.dto.MeterTreeContractDTO;
@@ -59,4 +60,12 @@ public interface MeterTreeContractMapper extends BaseMapper<MeterTreeContract> {
     void updateBatchForm(@Param("list") List<InventoryFormMeterVO> resultFormListUpdate2);
 
     MeterTreeContractVO contractDetail(@Param("id") Long id);
+
+    List<MeterTreeContract> getAllMeterNode(@Param("id") Long id,@Param("contractId") Long contractId);
+
+    @Delete("DELETE FROM s_meter_tree_contract where contract_id = #{contractId} and is_deleted = 0 and (id = #{id} or FIND_IN_SET(#{id}, ancestor))")
+    int deleteByCondition(Long id, Long contractId);
+
+    List<MeterTreeContract> getAllLockNode(@Param("id") Long id,@Param("contractId") Long contractId);
+
 }

+ 12 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MeterTreeContractMapper.xml

@@ -155,6 +155,18 @@
                                                     and mtc2.parent_id = mtc1.id and mtc2.is_deleted = 0 ) as childTotal
         from s_meter_tree_contract mtc1 WHERE  id = #{id}
     </select>
+    <select id="getAllMeterNode" resultType="org.springblade.meter.entity.MeterTreeContract">
+        select mtc.id,mtc.node_name
+        from s_meter_tree_contract mtc inner join s_middle_meter_apply mma on mma.contract_unit_id = mtc.id and mma.contract_id = #{contractId} and mma.is_deleted = 0
+        where mtc.contract_id = #{contractId} and mtc.is_deleted = 0 and (mtc.id = #{id} or FIND_IN_SET(#{id}, mtc.ancestor))
+        GROUP by mtc.id
+    </select>
+    <select id="getAllLockNode" resultType="org.springblade.meter.entity.MeterTreeContract">
+        select mtc.id,mtc.node_name
+        from s_meter_tree_contract mtc
+        where mtc.contract_id = #{contractId} and mtc.is_deleted = 0 and is_lock = 1
+          and (mtc.id = #{id} or FIND_IN_SET(#{id}, mtc.ancestor))
+    </select>
 
 
 </mapper>

+ 4 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml

@@ -189,7 +189,10 @@
     <select id="getCurrentMeterMoney" resultType="java.math.BigDecimal">
         select ifnull(sum(meter_money),0)
         from s_middle_meter_apply
-        where contract_id = #{contractId} and is_deleted = 0 and contract_period_id = #{contractPeriodId} and approve_status != 3
+        where contract_id = #{contractId} and is_deleted = 0 and approve_status != 3
+        <if test="contractPeriodId != -1">
+            and contract_period_id = #{contractPeriodId}
+        </if>
     </select>
 
 

+ 2 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/MeterTreeContractService.java

@@ -52,4 +52,6 @@ public interface MeterTreeContractService extends BaseService<MeterTreeContract>
     void deleteLinkWbsTree(Map<String, String> ids);
 
     MeterTreeContractVO contractDetail(Long id);
+
+    R<Object> contractRemove(Long id);
 }

+ 34 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MeterTreeContractServiceImpl.java

@@ -2360,6 +2360,40 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
         return baseMapper.contractDetail(id);
     }
 
+    /**
+     *删除节点,只要未被计量,都可以删除
+     * @param id
+     * @return
+     */
+    @Override
+    @Transactional
+    public R<Object> contractRemove(Long id) {
+        if (id == null){
+            throw new ServiceException("请传入id");
+        }
+        MeterTreeContract obj = this.getById(id);
+        if (obj != null) {
+            if (obj.getParentId().equals(0L) && obj.getAncestor().equals("0")) {
+                throw new ServiceException("根节点无法删除");
+            }
+        }
+        //判断当前节点和子节点是否被锁定
+        List<MeterTreeContract> list2 = baseMapper.getAllLockNode(id,obj.getContractId());
+        if (list2.size() > 0){
+            throw new ServiceException("以下"+list2.size()+"个节点已经被锁定:["+list2.stream().map(l->l.getNodeName()).collect(Collectors.joining(","))+"]");
+        }
+        //判断当前节点和子节点是否被计量,获取所有被计量的节点
+        List<MeterTreeContract> list = baseMapper.getAllMeterNode(id,obj.getContractId());
+        if (list.size() > 0){
+            throw new ServiceException("以下"+list.size()+"个节点已经被计量:["+list.stream().map(l->l.getNodeName()).collect(Collectors.joining(","))+"]");
+        }
+        //删除中间表信息
+        inventoryFormMeterMapper.deleteByNodeId(id,obj.getContractId());
+        //删除节点,并提示删除数量
+        int total = baseMapper.deleteByCondition(id,obj.getContractId());
+        return R.success("操作成功,本次删除"+total+"个节点");
+    }
+
     /**
      *  通过清单信息和合同计量单元节点,施工图数量,返回组装好的中间表对象
      */

+ 4 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MiddleMeterApplyServiceImpl.java

@@ -679,6 +679,10 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
      */
     @Override
     public String getMeterNumber(MiddleMeterApply apply) {
+        //如果计量期id为-1则代表不用查询
+        if (apply.getContractPeriodId() == -1){
+            return "";
+        }
         StringBuilder str = new StringBuilder();
         //获取合同信息
         ContractInfo info = baseMapper.getContractInfo(apply.getContractId());