|
@@ -17,6 +17,8 @@
|
|
|
package org.springblade.meter.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.meter.entity.InventoryFormApply;
|
|
|
import org.springblade.meter.mapper.InventoryFormApplyMapper;
|
|
|
import org.springblade.meter.service.IInventoryFormApplyService;
|
|
@@ -59,23 +61,26 @@ public class InventoryFormApplyServiceImpl extends BaseServiceImpl<InventoryForm
|
|
|
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));
|
|
|
+ if (StringUtils.isNotBlank(vo2.getApplyIds())) {
|
|
|
+ //查询指定节点,指定清单,在中间计量申请和清单中间表的数据,结果为多个计量期
|
|
|
+ List<Long> ids = Func.toLongList(vo2.getApplyIds());
|
|
|
+ List<InventoryFormApplyVO> vos = baseMapper.getByMeterIdAndFormId(ids);
|
|
|
+ //不存在则跳过
|
|
|
+ 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, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
|
|
|
+ }
|
|
|
+ needUpdateData.add(apply);
|
|
|
}
|
|
|
- needUpdateData.add(apply);
|
|
|
}
|
|
|
}
|
|
|
this.updateBatchById(needUpdateData);
|