qianxb hai 1 ano
pai
achega
aaf66abaed

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

@@ -27,6 +27,9 @@ public class ContractFromVO {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long id;
 
+    @ApiModelProperty(value = "清单id")
+    private Long contractFormId;
+
     /**
      * 清单编号
      */

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

@@ -158,7 +158,7 @@ public class MiddleMeterApplyController extends BladeController {
 			@ApiImplicitParam(name = "type", value = "类型1按部位排序2按时间排序", required = true)
 	})
 	public R<IPage<MiddleMeterApplyVO>> list(MiddleMeterApply middleMeterApply, Query query,Integer type) {
-		IPage<MiddleMeterApplyVO> pages = middleMeterApplyService.page2(middleMeterApply,query);
+		IPage<MiddleMeterApplyVO> pages = middleMeterApplyService.page2(middleMeterApply,query,type);
 		return R.data(pages);
 	}
 

+ 8 - 3
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractInventoryFormMapper.xml

@@ -137,16 +137,21 @@
                        WHERE contract_id = #{contractId} and contract_form_id = cif.id),0)  as poseNum
         from s_contract_inventory_form cif
         WHERE cif.contract_id = #{contractId} and cif.is_deleted = 0 and cif.is_form_node = 1
-            <if test="formNum != null and formNum != '' and type==1">
+            <if test="formNum != null and formNum != ''">
                 and cif.form_number like concat('%',#{formNum},'%')
             </if>
           and cif.id not in (SELECT contract_form_id from s_inventory_form_meter WHERE contract_id = #{contractId} and contract_meter_id = #{meterId} and is_deleted = 0)
     </select>
     <select id="getNodeResolveForm" resultType="org.springblade.meter.vo.ContractFromVO">
-        select ifm.id, cif.form_number,cif.form_name,cif.current_price,cif.contract_total,cif.change_total,cif.is_supplement,
+        select ifm.id, ifm.contract_form_id ,cif.form_number,cif.form_name,cif.current_price,cif.contract_total,cif.change_total,cif.is_supplement,
                ifm.build_picture_total,ifm.change_build_picture_total,ifm.build_picture_money,ifm.change_build_picture_money,
+
                if(ifm.build_picture_total=ifm.change_build_picture_total,if((select count(1) from s_inventory_form_apply
-                   where contract_id = #{contractId} and is_deleted = 0 and contract_form_id = ifm.contract_form_id and contract_meter_id = ifm.contract_meter_id)=0,0,1),1) as citeStatus,
+                   where contract_id = #{contractId} and is_deleted = 0 and contract_form_id = ifm.contract_form_id and contract_meter_id = ifm.contract_meter_id)=0,
+                       if((select count(1) from s_change_token_inventory
+                          where contract_id = #{contractId} and is_deleted = 0 and contract_form_id = ifm.contract_form_id and contract_meter_id = ifm.contract_meter_id)=0,0,1)
+                   ,1),1) as citeStatus,
+
             IFNULL((SELECT SUM(build_picture_total) from s_inventory_form_meter WHERE contract_id = #{contractId} and contract_form_id = cif.id
                      and is_deleted = 0 and contract_meter_id and contract_meter_id != #{meterId}),0)  as otherPoseNum,
             IFNULL((SELECT SUM(build_picture_total) from s_inventory_form_meter

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

@@ -49,6 +49,8 @@ public interface MiddleMeterApplyMapper extends BaseMapper<MiddleMeterApply> {
     List<MeterTreeContract> getNodeDivide(@Param("contractId") Long contractId, @Param("ids") List<Long> ids);
 
     IPage<MiddleMeterApplyVO> page2(IPage<MiddleMeterApplyVO> iPage,@Param("apply") MiddleMeterApply middleMeterApply);
+    //根据部位排序
+    IPage<MiddleMeterApplyVO> page3(IPage<MiddleMeterApplyVO> iPage,@Param("apply") MiddleMeterApply middleMeterApply,@Param("ids") List<Long> ids);
 
     List<MeterInventoryDetailVO> meterPeriodAllForm(@Param("apply") MiddleMeterApply apply);
 
@@ -67,4 +69,7 @@ public interface MiddleMeterApplyMapper extends BaseMapper<MiddleMeterApply> {
     BigDecimal getCurrentMeterMoney(@Param("contractId") Long contractId,@Param("contractPeriodId") Long contractPeriodId);
 
     Integer getAllAPPly(@Param("contractId") Long contractId,@Param("contractPeriodId") Long contractPeriodId);
+
+    List<Long> getLowestNodeBySort(@Param("contractId") Long contractId,@Param("nodeId") Long nodeId);
+
 }

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

@@ -77,6 +77,25 @@
                     and (mtc.id = #{apply.contractUnitId} or FIND_IN_SET(#{apply.contractUnitId}, ancestor))
                   )
     </select>
+    <select id="page3" resultType="org.springblade.meter.vo.MiddleMeterApplyVO">
+        SELECT *,
+               CASE when approve_status = 0 then '未上报' when approve_status = 1 then '待审批' when approve_status = 2 then '已审批'
+                    else '已废除' end as approveStatusName,
+               (select period_number from s_contract_meter_period cmp where cmp.id = mma.contract_period_id) as periodNumber
+        FROM s_middle_meter_apply mma
+        WHERE contract_id = #{apply.contractId} and is_deleted = 0 and contract_period_id = #{apply.contractPeriodId}
+          and contract_unit_id in (
+                <foreach collection="ids" item="id"  separator=",">
+                    #{id}
+                </foreach>
+            )
+        order by FIELD(contract_unit_id,
+            <foreach collection="ids" item="id"  separator=",">
+                #{id}
+            </foreach>
+        )
+
+    </select>
     <select id="meterPeriodAllForm" resultType="org.springblade.meter.vo.MeterInventoryDetailVO">
         SELECT cif.id,ifa.meter_number,cif.form_number,cif.form_name,cif.current_price,cif.change_total,ifa.current_meter_total,ifa.current_meter_money,ifa.contract_form_id,
                (select period_number from s_contract_meter_period cmp where cmp.id = ifa.contract_period_id) as meterPeriodName,
@@ -127,6 +146,17 @@
         from s_middle_meter_apply
         where contract_id = #{contractId} and contract_period_id = #{contractPeriodId}
     </select>
+    <select id="getLowestNodeBySort" resultType="java.lang.Long">
+        SELECT id
+        FROM s_meter_tree_contract mtc
+        WHERE is_deleted = 0 and contract_id = #{contractId}
+          and (select COUNT(1) from s_meter_tree_contract mtc2 WHERE contract_id = #{contractId} and mtc2.parent_id=mtc.id)=0
+          and id in (SELECT id FROM s_meter_tree_contract mtc
+                                   WHERE contract_id = #{contractId} and is_deleted = 0
+                                     and (mtc.id = #{nodeId} or FIND_IN_SET(#{nodeId}, ancestor))
+        )
+        ORDER by sort
+    </select>
 
 
 </mapper>

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

@@ -50,7 +50,7 @@ public interface IMiddleMeterApplyService extends BaseService<MiddleMeterApply>
 
     void update2(MiddleMeterApplyDTO dto);
 
-    IPage<MiddleMeterApplyVO> page2(MiddleMeterApply middleMeterApply, Query query);
+    IPage<MiddleMeterApplyVO> page2(MiddleMeterApply middleMeterApply, Query query,Integer type);
 
     void delete(List<Long> ids);
 

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

@@ -586,7 +586,7 @@ public class ContractInventoryFormServiceImpl extends BaseServiceImpl<ContractIn
     }
 
     /**
-     * 判断当前节点是否已经分解或变更过,变更过返回true
+     * 判断当前清单是否已经分解或变更过,变更过返回true
      */
     private Boolean nodeIsChange(ContractInventoryForm form) {
         if (form.getBuildChangeTotal() != null) {

+ 28 - 4
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/InventoryFormMeterServiceImpl.java

@@ -26,11 +26,9 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.manager.entity.WbsTree;
-import org.springblade.meter.entity.ContractInventoryForm;
-import org.springblade.meter.entity.InventoryFormApply;
-import org.springblade.meter.entity.InventoryFormMeter;
-import org.springblade.meter.entity.MeterTreeContract;
+import org.springblade.meter.entity.*;
 import org.springblade.meter.mapper.InventoryFormMeterMapper;
+import org.springblade.meter.service.IChangeTokenInventoryService;
 import org.springblade.meter.service.IInventoryFormApplyService;
 import org.springblade.meter.service.IInventoryFormMeterService;
 import org.springblade.core.mp.base.BaseServiceImpl;
@@ -55,6 +53,8 @@ public class InventoryFormMeterServiceImpl extends BaseServiceImpl<InventoryForm
 
     private final IInventoryFormApplyService inventoryFormApplyService;
 
+    private final IChangeTokenInventoryService tokenInventoryService;
+
     @Override
     public List<Long> getNodeAllForm(Long nodeId) {
         return baseMapper.getNodeAllForm(nodeId);
@@ -95,6 +95,10 @@ public class InventoryFormMeterServiceImpl extends BaseServiceImpl<InventoryForm
             if (vo.getBuildPictureTotal() == null){
                 throw new ServiceException("请填写施工图数量");
             }
+            //校验当前节点下当前清单,是否在变更令中变更,或计量中计量
+            if (vo.getCiteStatus() == 0 && formIsChange(meterId,vo.getContractFormId())){
+                throw new ServiceException("清单["+vo.getFormName()+"]已经变更或计量,请刷新页面");
+            }
             //统计
             vo.setBuildPictureMoney(vo.getCurrentPrice().multiply(vo.getBuildPictureTotal()));
             vo.setChangeBuildPictureMoney(vo.getCurrentPrice().multiply(vo.getChangeBuildPictureTotal()));
@@ -132,6 +136,7 @@ public class InventoryFormMeterServiceImpl extends BaseServiceImpl<InventoryForm
         //判断当前清单是否被计量
         List<InventoryFormApply> list = inventoryFormApplyService.list(new LambdaQueryWrapper<InventoryFormApply>()
                 .eq(InventoryFormApply::getContractId, meter.getContractId())
+                .eq(InventoryFormApply::getContractMeterId,Long.parseLong(meterId))
                 .eq(InventoryFormApply::getContractFormId, meter.getContractFormId()));
         if (list.size() > 0){
             throw new ServiceException("当前清单已经计量,不能删除");
@@ -140,4 +145,23 @@ public class InventoryFormMeterServiceImpl extends BaseServiceImpl<InventoryForm
         this.removeById(formIds);
         return R.success("成功");
     }
+
+    /**
+     * 判断当前节点下当前清单是否已经分解或变更过,变更过返回true
+     */
+    private Boolean formIsChange(Long meterId,Long formId) {
+        long count = inventoryFormApplyService.count(new LambdaQueryWrapper<InventoryFormApply>()
+                .eq(InventoryFormApply::getContractFormId, formId)
+                .eq(InventoryFormApply::getContractMeterId, meterId));
+        if (count > 0) {
+            return true;
+        }
+        long count1 = tokenInventoryService.count(new LambdaQueryWrapper<ChangeTokenInventory>()
+                .eq(ChangeTokenInventory::getContractFormId, formId)
+                .eq(ChangeTokenInventory::getContractMeterId, meterId));
+        if (count1 > 0) {
+            return true;
+        }
+        return false;
+    }
 }

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

@@ -546,6 +546,11 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
     @Override
 //    @Async
     public void asyncCalculateNodeMoney(List<ChangeNodeVO> vos) {
+        for (ChangeNodeVO vo : vos) {
+            if (StringUtils.isBlank(vo.getContractPicture())){
+                vo.setContractPicture("");
+            }
+        }
         Map<Long, String> map = vos.stream().collect(Collectors.toMap(l -> l.getId(), l -> l.getContractPicture()));
         //获取所有要重新计算的节点的最新数据
         List<MeterTreeContract> list = this.listByIds(map.keySet());

+ 10 - 2
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MiddleMeterApplyServiceImpl.java

@@ -303,9 +303,17 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
      * 分页 中间计量申请表
      */
     @Override
-    public IPage<MiddleMeterApplyVO> page2(MiddleMeterApply middleMeterApply, Query query) {
+    public IPage<MiddleMeterApplyVO> page2(MiddleMeterApply middleMeterApply, Query query,Integer type) {
         IPage<MiddleMeterApplyVO> iPage = new Page<>(query.getCurrent(),query.getSize());
-        iPage = baseMapper.page2(iPage,middleMeterApply);
+        if (type == 1){
+            //根据部位分页,先查出部位
+            List<Long> ids = baseMapper.getLowestNodeBySort(middleMeterApply.getContractId(),middleMeterApply.getContractUnitId());
+            if (ids.size() != 0){
+                iPage = baseMapper.page3(iPage,middleMeterApply,ids);
+            }
+        }else {
+            iPage = baseMapper.page2(iPage, middleMeterApply);
+        }
         return iPage;
     }