Browse Source

资料关联台账,关键质检资料

qianxb 1 năm trước cách đây
mục cha
commit
e354db0cc4

+ 3 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/MeterInventoryVO.java

@@ -76,4 +76,7 @@ public class MeterInventoryVO {
     @ApiModelProperty(value = "其他期支付比例")
     private BigDecimal otherPayRatio;
 
+    @ApiModelProperty(value = "合同计量单元实际变更后施工图数量")
+    private BigDecimal currentBuildChangeTotal;
+
 }

+ 2 - 3
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/MiddleMeterApplyController.java

@@ -281,12 +281,11 @@ public class MiddleMeterApplyController extends BladeController {
     @ApiOperationSupport(order = 14)
     @ApiOperation(value = "资料关联台账-关联质检资料", notes = "传合同id,计量单id,选中文件id逗号分隔")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "contractId", value = "合同id", required = true),
             @ApiImplicitParam(name = "id", value = "计量单id", required = true),
             @ApiImplicitParam(name = "fileIds", value = "选中文件id逗号分隔(返回数据的selectId,queryInfo的主键)", required = true)
     })
-    public R<String> dataLinkFile(Long contractId, Long id,String fileIds) {
-        middleMeterApplyService.dataLinkFile(contractId, id,fileIds);
+    public R<String> dataLinkFile(Long id,String fileIds) {
+        middleMeterApplyService.dataLinkFile(id,fileIds);
         return R.success("关联成功");
     }
 }

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

@@ -18,6 +18,7 @@ package org.springblade.meter.mapper;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.springblade.business.entity.InformationQuery;
 import org.springblade.manager.entity.ContractInfo;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.meter.dto.WbsNodeDTO;
@@ -97,4 +98,6 @@ public interface MiddleMeterApplyMapper extends BaseMapper<MiddleMeterApply> {
     List<WbsTreeContract> getAllAncestors(@Param("ids") HashSet<Long> set, @Param("contractId") Long contractId);
 
     WbsNodeVO getNodeInfo(@Param("pId") Long pId);
+
+    List<InformationQuery>  getQueryDataByIds(@Param("ids") List<Long> ids);
 }

+ 10 - 6
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml

@@ -61,9 +61,7 @@
                             and contract_meter_id = #{nodeId} and contract_form_id = cif.id),0) as resolveTotal,
                0 as currentMeterTotal,0 as containChangeTotal,0 as currentMeterMoney,
                (IFNULL((select sum(current_meter_total) from s_inventory_form_apply where is_deleted = 0
-                            and contract_meter_id = #{nodeId} and contract_form_id = cif.id),0)) as allMeterTotal,
-                (IFNULL((select sum(pay_ratio) from s_inventory_form_apply where is_deleted = 0
-                and contract_meter_id = #{nodeId} and contract_form_id = cif.id),0)) as otherPayRatio
+                            and contract_meter_id = #{nodeId} and contract_form_id = cif.id),0)) as allMeterTotal
         from s_contract_inventory_form  cif where contract_id = #{contractId} and is_deleted = 0 and is_form_node = 1
         AND id in
         <foreach collection="ids" item="id" open="(" separator="," close=")">
@@ -137,10 +135,10 @@
                       and contract_meter_id = #{nodeId} and contract_form_id = ifa.contract_form_id and id != ifa.id),0)) as otherMeterTotal,
                (IFNULL((select sum(current_meter_total) from s_inventory_form_apply where is_deleted = 0
                       and contract_meter_id = #{nodeId} and contract_form_id = ifa.contract_form_id),0)) as allMeterTotal,
-               (IFNULL((select sum(pay_ratio) from s_inventory_form_apply ifa2 where is_deleted = 0 and ifa2.id != ifa.id
-                      and contract_meter_id = #{nodeId} and contract_form_id = ifa.contract_form_id),0)) as otherPayRatio,
                (select up_pay_ratio from s_inventory_form_meter where is_deleted = 0
-                      and contract_meter_id = #{nodeId} and contract_form_id = ifa.contract_form_id) as upPayRatio
+                      and contract_meter_id = #{nodeId} and contract_form_id = ifa.contract_form_id) as upPayRatio,
+               (select change_build_picture_total from s_inventory_form_meter where is_deleted = 0
+                        and contract_meter_id = #{nodeId} and contract_form_id = ifa.contract_form_id) as currentBuildChangeTotal
         from s_inventory_form_apply ifa
         where ifa.contract_id = #{contractId} and ifa.is_deleted = 0
         AND ifa.middle_meter_id = #{id}
@@ -313,6 +311,12 @@
         </foreach>
         )
     </select>
+    <select id="getQueryDataByIds" resultType="org.springblade.business.entity.InformationQuery">
+        select * from u_information_query where id in
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
 
 
 </mapper>

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IMiddleMeterApplyService.java

@@ -79,5 +79,5 @@ public interface IMiddleMeterApplyService extends BaseService<MiddleMeterApply>
     /**
      * 资料关联台账-关联质检资料
      */
-    void dataLinkFile(Long contractId, Long id, String fileIds);
+    void dataLinkFile( Long id, String fileIds);
 }

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/InventoryFormApplyServiceImpl.java

@@ -77,7 +77,7 @@ public class InventoryFormApplyServiceImpl extends BaseServiceImpl<InventoryForm
                     if (total.compareTo(BigDecimal.ZERO) == 0) {
                         apply.setPayRatio(BigDecimal.ZERO);
                     } else {
-                        apply.setPayRatio(vo.getCurrentMeterTotal().divide(total, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
+                        apply.setPayRatio(vo.getCurrentMeterTotal().divide(total, 4, RoundingMode.DOWN).multiply(new BigDecimal(100)));
                     }
                     needUpdateData.add(apply);
                 }

+ 50 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MiddleMeterApplyServiceImpl.java

@@ -17,10 +17,12 @@
 package org.springblade.meter.service.impl;
 
 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 lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
+import org.springblade.business.entity.InformationQuery;
 import org.springblade.business.entity.Task;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
@@ -45,6 +47,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -130,6 +133,7 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
             vo.setPayRatio(new BigDecimal(0));
             //设置其他计量总数
             vo.setOtherMeterTotal(vo.getAllMeterTotal().subtract(vo.getCurrentMeterTotal()));
+            vo.setOtherPayRatio(vo.getOtherMeterTotal().divide(vo.getChangeTotal(), 4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2));
             //设置施工图数量是否大于合同数量
             vo.setIsBuildThanContract(vo.getChangeTotal().compareTo(vo.getContractChangeAllTotal()) == 1?1:0);
         }
@@ -347,6 +351,7 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
         MiddleMeterApply apply = new MiddleMeterApply();
         BeanUtils.copyProperties(dto,apply);
         apply.setMeterMoney(null);
+        apply.setIsLinkData(isLinkData);
         //保存计量清单
         List<MeterInventoryVO> formList = dto.getFormList();
         //删除当前节点本期清单
@@ -516,6 +521,7 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
         //计算分解数量是否超过合同数量
         for (MeterInventoryVO form : formList) {
             //设置施工图数量是否大于合同数量
+            form.setOtherPayRatio(form.getOtherMeterTotal().divide(form.getCurrentBuildChangeTotal(), 4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2));
             form.setIsBuildThanContract(form.getChangeTotal().compareTo(form.getContractChangeAllTotal()) == 1?1:0);
         }
         vo.setFormList(formList);
@@ -842,7 +848,50 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
      * 资料关联台账-关联质检资料
      */
     @Override
-    public void dataLinkFile(Long contractId, Long id, String fileIds) {
+    @Transactional
+    public void dataLinkFile(Long id, String fileIds) {
+        //获取中间计量申请信息
+        MiddleMeterApply apply = this.getById(id);
+        if (apply == null){
+            throw new ServiceException("未找到中间计量申请信息");
+        }
+        //根据文件id,查询出queryInfo数据
+        if (StringUtils.isBlank(fileIds)){
+            throw new ServiceException("请选择关联资料");
+        }
+        List<Long> ids = Func.toLongList(fileIds);
+        List<InformationQuery> list = baseMapper.getQueryDataByIds(ids);
+        if (list.size() == 0){
+            throw new ServiceException("未找到关联资料信息");
+        }
+        //构造附件
+        List<AttachmentForm> files = new ArrayList<>();
+        for (InformationQuery query : list) {
+            AttachmentForm form = new AttachmentForm();
+            form.setFileType(1);
+            form.setProjectId(apply.getProjectId());
+            form.setContractId(apply.getContractId());
+            form.setMasterId(id);
+            form.setFileName(query.getName());
+            String url;
+            if (StringUtils.isNotBlank(query.getEVisaPdfUrl())){
+                url = query.getEVisaPdfUrl();
+            }else if (StringUtils.isNotBlank(query.getPdfUrl())){
+                url = query.getPdfUrl();
+            }else {
+                throw new ServiceException("未找到资料:"+query.getName()+",的pdf图片");
+            }
+            form.setFileUrl(url);
+            form.setFilePdfUrl(url);
+            form.setSelectId(query.getId());
+            files.add(form);
+        }
+        //保存附件
+        attachmentFormService.saveBatch(files);
+        //修改中间计量申请的关联状态
+        this.update(new LambdaUpdateWrapper<MiddleMeterApply>()
+                .eq(MiddleMeterApply::getId,id)
+                .set(MiddleMeterApply::getIsLinkData,1));
 
     }