Procházet zdrojové kódy

计量单元删除增加锁定限制,计量系统导入模板URL全部动态配置

qianxb před 8 měsíci
rodič
revize
9c1d0859f3

+ 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);
 	}
 
 

+ 12 - 28
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/MeterTreeController.java

@@ -774,34 +774,6 @@ public class MeterTreeController extends BladeController {
     @ApiOperation(value = "合同段树节点删除", notes = "传入id")
     public R<Object> contractRemove(@RequestParam Long id) {
         return meterTreeContractService.contractRemove(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));
-//            }
-//        }
     }
 
     @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/MeterTreeContractMapper.java

@@ -65,4 +65,7 @@ public interface MeterTreeContractMapper extends BaseMapper<MeterTreeContract> {
 
     @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);
+
 }

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

@@ -161,6 +161,12 @@
         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>

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

@@ -2377,6 +2377,11 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
                 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){