Răsfoiți Sursa

合同计量单元树排序,自动生成的计量单不允许关联质检

qianxb 1 an în urmă
părinte
comite
25decd5447

+ 2 - 1
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/MiddleMeterApply.java

@@ -135,5 +135,6 @@ public class MiddleMeterApply extends BaseEntity {
     @ApiModelProperty(value = "是否关联质检资料1是0否")
     private Integer isLinkData;
 
-
+    @ApiModelProperty(value = "是否自动计量生成1是0否")
+    private Integer isAutoBuild;
 }

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

@@ -53,6 +53,7 @@
                if((select count(1) from s_meter_tree_contract mtc2 where mtc2.project_id = #{projectId}
                     and mtc2.contract_id = #{contractId} and is_deleted = 0 and mtc2.parent_id = mtc1.id) = 0,'false','true') as hasChild
         from s_meter_tree_contract mtc1 where project_id = #{projectId} and contract_id = #{contractId} and is_deleted = 0
+        ORDER BY -mtc1.sort desc,mtc1.create_time
     </select>
     <select id="getWBSTree" resultType="org.springblade.meter.vo.MeterFullTreeVO">
         select p_key_id,id, if(full_name is null,node_name,full_name) as node_name,parent_id,

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

@@ -110,4 +110,6 @@ public interface MiddleMeterApplyMapper extends BaseMapper<MiddleMeterApply> {
     List<InventoryFormMeterVO> getAllFormMeter(@Param("contractId")Long contractId,@Param("ids") List<Long> meterIds);
 
     Task getTaskInfo(@Param("contractId")Long contractId,@Param("id") Long id);
+
+    Integer getWbsLinkFileTotal(@Param("contractId")Long contractId,@Param("id") Long id);
 }

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

@@ -374,6 +374,9 @@
     <select id="getTaskInfo" resultType="org.springblade.business.entity.Task">
         select * from u_task WHERE contract_id = #{contractId} and  form_data_id = id and is_deleted = 0
     </select>
+    <select id="getWbsLinkFileTotal" resultType="java.lang.Integer">
+        select count(1) from s_attachment_form where contract_id = #{contractId} and master_id = #{id} and select_id is not null and is_deleted = 0
+    </select>
 
 
 </mapper>

+ 18 - 3
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MiddleMeterApplyServiceImpl.java

@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.models.auth.In;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.springblade.business.entity.InformationQuery;
@@ -356,14 +357,16 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
             throw new ServiceException("修改失败,不能删除所有计量清单");
         }
         //删除附件
+        int total = baseMapper.getWbsLinkFileTotal(dto.getContractId(),dto.getId());
         attachmentFormService.deleteByMasterId(dto.getId());
         //先保存附件,因为要判断是否关联
         Integer isLinkData = 0;
+        Integer linkTotal = 0;
         List<AttachmentForm> fileList = dto.getFileList();
         if (fileList != null && fileList.size() != 0) {
             for (AttachmentForm file : fileList) {
-                if (isLinkData == 0  && file.getSelectId() != null){
-                    isLinkData = 1;
+                if (file.getSelectId() != null){
+                    linkTotal++;
                 }
                 file.setProjectId(dto.getProjectId());
                 file.setContractId(dto.getContractId());
@@ -371,10 +374,21 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
             }
             attachmentFormService.saveBatch(fileList);
         }
+        if (linkTotal > 0){
+            isLinkData = 1;
+        }
+        //获取计量单信息,判断是否为自动生成
+        MiddleMeterApply meterApply = this.getById(dto.getId());
+        //为自动生成,则获取附件的selectId逗号拼接,判断是否全部存在于当前附件
+        if (meterApply.getIsAutoBuild() == 1){
+            if (linkTotal != total){
+                throw new ServiceException("修改失败:不允许删除关联WBS节点的附件");
+            }
+        }
         //校验当前计量期是否已经上报
         ContractMeterPeriod period = contractMeterPeriodService.getById(dto.getContractPeriodId());
         if (period.getApproveStatus() != 0){
-            throw new ServiceException("修改失败,当前计量期已经上报或审批");
+            throw new ServiceException("修改失败当前计量期已经上报或审批");
         }
         //保存中间计量申请,设置计量金额为0,如果存在计量清单,则统计计量清单总金额
         MiddleMeterApply apply = new MiddleMeterApply();
@@ -1247,6 +1261,7 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
                 apply.setMeterMoney(total);
                 apply.setCalculateFormula(vo2.getCalculateFormula());
                 apply.setIsLinkData(1);
+                apply.setIsAutoBuild(1);
                 //添加到计量单集合
                 middleMeterApplyAdd.add(apply);
                 count++;