ソースを参照

合同计量单元导入后,修改所有实际挂载的合同计量清单的变更后数量

qianxb 8 ヶ月 前
コミット
3abbdfbea1

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

@@ -1,12 +1,15 @@
 package org.springblade.meter.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import jdk.internal.org.objectweb.asm.tree.analysis.Value;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.springblade.meter.entity.InventoryFormMeter;
 import org.springblade.meter.entity.MeterTreeContract;
 
+import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 public interface MeterTreeContractMapper extends BaseMapper<MeterTreeContract> {
@@ -21,4 +24,6 @@ public interface MeterTreeContractMapper extends BaseMapper<MeterTreeContract> {
     List<InventoryFormMeter> getNodeAllForm(@Param("ids") Set<Long> ids);
 
     List<String> getAllEqualsNumber(@Param("contractId") Long contractId,@Param("numbers") List<String> collect);
+
+    void batchUpdateFormByNumber(@Param("contractId") Long contractId,@Param("map") Map<String, BigDecimal> map);
 }

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

@@ -11,6 +11,16 @@
             where id = #{item.id}
         </foreach>
     </update>
+    <update id="batchUpdateFormByNumber">
+        <foreach item="value" collection="map" index="key" separator=";">
+            UPDATE s_contract_inventory_form
+            <set>
+                change_total = change_total + #{value},
+                change_money = current_price * change_total
+            </set>
+            where contract_id = #{contractId} and form_number = #{key}
+        </foreach>
+    </update>
 
     <select id="getAllChildNodeMoney" resultType="org.springblade.meter.entity.MeterTreeContract">
         select ifnull(sum(build_picture_money),0) as build_picture_money,

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

@@ -1306,6 +1306,12 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
                                         objForm.setBuildPictureMoney(objForm.getBuildPictureTotal().multiply(contractInventoryForm.getChangePrice())); //数量*变更后单价
                                         objForm.setChangeBuildPictureMoney(objForm.getBuildPictureMoney());
 
+                                        //设置清单增量
+                                        ContractInventoryForm form = new ContractInventoryForm();
+                                        form.setFormNumber(formCode);
+                                        form.setChangeTotal(this.parseString(buildPictureTotal));
+                                        InventoryFormListUpdate.add(form);
+
                                         /*计量单元节点金额相关累加*/
                                         money = money.add(objForm.getBuildPictureMoney());
                                         moneyChange = moneyChange.add(objForm.getChangeBuildPictureMoney());
@@ -1363,6 +1369,11 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
 
                                         //累加
                                         BigDecimal bigDecimal = this.parseString(buildPictureTotal);
+                                        //设置清单增量
+                                        ContractInventoryForm form = new ContractInventoryForm();
+                                        form.setFormNumber(formCode);
+                                        form.setChangeTotal(bigDecimal);
+                                        InventoryFormListUpdate.add(form);
                                         formUpdate.setBuildPictureTotal(formUpdate.getBuildPictureTotal().add(bigDecimal));
 
                                         formUpdate.setChangeBuildPictureTotal(formUpdate.getBuildPictureTotal());
@@ -1408,6 +1419,11 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
                                     formAdd.setBuildPictureMoney(formAdd.getBuildPictureTotal().multiply(contractInventoryFormAdd.getChangePrice())); //数量*变更后单价
                                     formAdd.setChangeBuildPictureMoney(formAdd.getBuildPictureMoney());
 
+                                    //设置清单增量
+                                    ContractInventoryForm form = new ContractInventoryForm();
+                                    form.setFormNumber(formCode);
+                                    form.setChangeTotal(this.parseString(buildPictureTotal));
+                                    InventoryFormListUpdate.add(form);
                                     /*新增清单*/
                                     resultFormListAdd.add(formAdd);
 
@@ -1494,6 +1510,11 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
                 }
             }
         }
+        //修改合同工程清单的变更后数量
+        Map<String, BigDecimal> map = InventoryFormListUpdate.stream()
+                .collect(Collectors.groupingBy(l -> l.getFormNumber(),
+                        Collectors.mapping(ContractInventoryForm::getChangeTotal, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
+        baseMapper.batchUpdateFormByNumber(meterTreeContract.getContractId(),map);
         return R.success("成功导入:节点("+addNode+")个,"+"新增清单("+addForm+")条,"+"修改清单("+updateForm+")条.");
     }