|
@@ -16,12 +16,21 @@
|
|
|
*/
|
|
|
package org.springblade.meter.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import org.springblade.meter.entity.InventoryFormApply;
|
|
|
import org.springblade.meter.mapper.InventoryFormApplyMapper;
|
|
|
import org.springblade.meter.service.IInventoryFormApplyService;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.meter.vo.ChangeFormVO2;
|
|
|
+import org.springblade.meter.vo.InventoryFormApplyVO;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 工程清单与中间计量申请 中间表 服务实现类
|
|
|
*
|
|
@@ -36,4 +45,40 @@ public class InventoryFormApplyServiceImpl extends BaseServiceImpl<InventoryForm
|
|
|
public void deleteByMiddleId(Long id) {
|
|
|
baseMapper.deleteByMiddleId(id);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ public void asyncCalculateMiddleMeterRatio(List<ChangeFormVO2> allForm) {
|
|
|
+ //等待一秒
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000L);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //需要修改的数据
|
|
|
+ List<InventoryFormApply> needUpdateData = new ArrayList<>();
|
|
|
+ //目前先这样查询,后期优化
|
|
|
+ for (ChangeFormVO2 vo2 : allForm) {
|
|
|
+ //查询指定节点,指定清单,在中间计量申请和清单中间表的数据,结果为多个计量期
|
|
|
+ List<InventoryFormApplyVO> vos = baseMapper.getByMeterIdAndFormId(vo2);
|
|
|
+ //不存在则跳过
|
|
|
+ if (vos.size() == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //循环修改
|
|
|
+ BigDecimal total = vo2.getNewestChangeTotal().add(vo2.getCurrentChangeTotal());
|
|
|
+ for (InventoryFormApplyVO vo : vos) {
|
|
|
+ InventoryFormApply apply = new InventoryFormApply();
|
|
|
+ apply.setId(vo.getId());
|
|
|
+ if (total.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ apply.setPayRatio(BigDecimal.ZERO);
|
|
|
+ }else {
|
|
|
+ apply.setPayRatio(vo.getCurrentMeterTotal().divide(total,2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ needUpdateData.add(apply);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.updateBatchById(needUpdateData);
|
|
|
+
|
|
|
+ }
|
|
|
}
|