Explorar o código

面料损耗更新

fenghaifu hai 1 ano
pai
achega
844c72a195

+ 65 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/service/impl/FabricLossServiceImpl.java

@@ -605,7 +605,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			fabricPoOrderIn.setIQuantityNSettle(DoubleOperation.sub(fabricPoOrderIn.getIQuantity(),fabricPoOrderIn.getIQuantitySettle()));
 			// 获取保存的委外单价
 			Optional<FabricMoOrderCK> findOpt = moOrderCKList.stream().filter(e->e.getInvOutId().equalsIgnoreCase(fabricPoOrderIn.getInvId())).findFirst();
-			if (findOpt.isPresent()){
+			if (findOpt.isPresent() && findOpt.get().getIPrice()>0){
 				FabricMoOrderCK findItem = findOpt.get();
 				fabricPoOrderIn.setIPrice(DoubleOperation.getScale(findItem.getIPrice(),4));
 			}else {
@@ -956,6 +956,60 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 		List<FabricMoOrderRK> rowInList = fabricLossMapper.getOmInDetailList(code);
 		rowInList.forEach(e->e.setITempUseSum(0.0));
 		// 设置是否本计划入库标识
+		List<FabricMoOrderCK> tmpOutList = new ArrayList<>();
+		rowOutList.forEach(e->{
+			FabricMoOrderCK tmpOut = tmpOutList.stream().filter(o->o.getInvOutId().equalsIgnoreCase(e.getInvOutId())).findAny().orElse(null);
+			if (tmpOut == null){
+				tmpOut = new FabricMoOrderCK();
+				tmpOut.setCInvCodeOut(e.getCInvCodeOut());
+				tmpOut.setCColorOut(e.getCColorOut());
+				tmpOut.setCBatchOut(e.getCBatchOut());
+				tmpOut.setIQuantityOut(e.getIQuantityOut());
+				tmpOutList.add(tmpOut);
+			}else{
+				tmpOut.setIQuantityOut(DoubleOperation.add(tmpOut.getIQuantityOut(),e.getIQuantityOut()));
+			}
+		});
+		List<FabricMoOrderCK> tmpInList = new ArrayList<>();
+		poOrderInList.forEach(e->{
+			FabricMoOrderCK tmpOut = tmpInList.stream().filter(o->o.getInvOutId().equalsIgnoreCase(e.getInvId())).findAny().orElse(null);
+			if (tmpOut == null){
+				tmpOut = new FabricMoOrderCK();
+				tmpOut.setCInvCodeOut(e.getCInvCode());
+				tmpOut.setCColorOut(e.getCColor());
+				tmpOut.setCBatchOut(e.getCBatch());
+				tmpOut.setIQuantityOut(e.getIQuantity());
+				tmpInList.add(tmpOut);
+			}else{
+				tmpOut.setIQuantityOut(DoubleOperation.add(tmpOut.getIQuantityOut(),e.getIQuantity()));
+			}
+		});
+		rowInList.forEach(e->{
+			FabricMoOrderCK tmpOut = tmpInList.stream().filter(o->o.getInvOutId().equalsIgnoreCase(e.getInvId())).findAny().orElse(null);
+			if (tmpOut == null){
+				tmpOut = new FabricMoOrderCK();
+				tmpOut.setCInvCodeOut(e.getCInvCode());
+				tmpOut.setCColorOut(e.getCColor());
+				tmpOut.setCBatchOut(e.getCBatch());
+				tmpOut.setIQuantityOut(e.getIQuantityIn());
+				tmpInList.add(tmpOut);
+			}else{
+				tmpOut.setIQuantityOut(DoubleOperation.add(tmpOut.getIQuantityOut(),e.getIQuantityIn()));
+			}
+		});
+		List<String> otherInInvId = new ArrayList<>();  // 其他入库的物料
+		tmpOutList.forEach(o->{
+			FabricMoOrderCK in = tmpInList.stream().filter(i->i.getInvOutId().equalsIgnoreCase(o.getInvOutId())).findAny().orElse(null);
+			if (in != null){
+				o.setIQuantityOut(DoubleOperation.sub(o.getIQuantityOut(),in.getIQuantityOut()));
+			}
+		});
+		tmpOutList.forEach(o->{
+			if (o.getIQuantityOut()>0){
+				otherInInvId.add(o.getInvOutId());
+			}
+		});
+		/*
 		List<String> otherInInvId = new ArrayList<>();  // 其他入库的物料
 		for (FabricMoOrderCK outItem : rowOutList){
 			if (poOrderInList.stream().filter(e->e.getInvId().equalsIgnoreCase(outItem.getInvOutId())).count()>0 ||
@@ -964,7 +1018,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			}else{
 				otherInInvId.add(outItem.getInvOutId());
 			}
-		}
+		}*/
 		// 查询物料入库信息
 		List<FabricCommonIn> otherInList = new ArrayList<>();
 		if (otherInInvId.size()>0) {
@@ -1701,6 +1755,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			if (DoubleOperation.sub(moOrderCK.getIQuantityOut(),moOrderCK.getITempUseSum())==0){
 				continue;
 			}
+			moOrderCK.setIQuantityOut(DoubleOperation.sub(moOrderCK.getIQuantityOut(),moOrderCK.getITempUseSum()));
 			FabricPoOrderOut poOrderOut = FabricPoOrderOut.getByMoOut(moOrderCK);
 			// 批号是期初的,或者普通采购入库的非杂纱,算来源余纱
 			if ("期初".equalsIgnoreCase(moOrderCK.getCBatchOut()) ||
@@ -1790,6 +1845,13 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			}
 		}
 		// 入排序
+		allInList.forEach(e->{
+			if (e.getIPrice() == null){
+				e.setIPrice(0.0);
+			}
+		});
+		allInList.stream().sorted(Comparator.comparing(FabricPoOrderIn::getIPrice).reversed());
+		/*
 		Collections.sort(allInList, new Comparator<FabricPoOrderIn>() {
 			@Override
 			public int compare(FabricPoOrderIn o1, FabricPoOrderIn o2) {
@@ -1811,7 +1873,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 
 				return (int)(o1.getIPrice()-o2.getIPrice());
 			}
-		});
+		});*/
 		// 转入数量有负数的,从正数扣除
 		List<FabricPoOrderIn> nList = allInList.stream().filter(e->e.getIQuantity()<0).collect(Collectors.toList());// 负数
 		allInList = allInList.stream().filter(e->e.getIQuantity()>=0).collect(Collectors.toList());// 正数

+ 34 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/DoubleOperation.java

@@ -14,21 +14,45 @@ import java.math.BigDecimal;
  */
 public class DoubleOperation {
 	public static Double add(Double d1, Double d2){
+		if (d1 == null || Double.isInfinite(d1)) {
+			d1 = 0.0;
+		}
+		if (d2 == null || Double.isInfinite(d2)) {
+			d2 = 0.0;
+		}
 		BigDecimal p1 = new BigDecimal(Double.toString(d1));
 		BigDecimal p2 = new BigDecimal(Double.toString(d2));
 		return p1.add(p2).doubleValue();
 	}
 	public static Double sub(Double d1, Double d2){
+		if (d1 == null || Double.isInfinite(d1)) {
+			d1 = 0.0;
+		}
+		if (d2 == null || Double.isInfinite(d2)) {
+			d2 = 0.0;
+		}
 		BigDecimal p1 = new BigDecimal(Double.toString(d1));
 		BigDecimal p2 = new BigDecimal(Double.toString(d2));
 		return p1.subtract(p2).doubleValue();
 	}
 	public static Double mul(Double d1, Double d2){
+		if (d1 == null || Double.isInfinite(d1)) {
+			d1 = 0.0;
+		}
+		if (d2 == null || Double.isInfinite(d2)) {
+			d2 = 0.0;
+		}
 		BigDecimal p1 = new BigDecimal(Double.toString(d1));
 		BigDecimal p2 = new BigDecimal(Double.toString(d2));
 		return p1.multiply(p2).doubleValue();
 	}
-	public static Double mul(Double d1, Double d2, int scale){
+	public static Double mul(Double d1, Double d2, int scale) {
+		if (d1 == null || Double.isInfinite(d1)) {
+			d1 = 0.0;
+		}
+		if (d2 == null || Double.isInfinite(d2)) {
+			d2 = 0.0;
+		}
 		BigDecimal p1 = new BigDecimal(Double.toString(d1));
 		BigDecimal p2 = new BigDecimal(Double.toString(d2));
 		BigDecimal p3 = p1.multiply(p2);
@@ -42,6 +66,9 @@ public class DoubleOperation {
 	 * @return
 	 */
 	public static Double getScale(Double d1, int scale){
+		if (d1 == null || Double.isInfinite(d1)) {
+			d1 = 0.0;
+		}
 		BigDecimal p1 = new BigDecimal(Double.toString(d1));
 		return p1.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
 	}
@@ -54,6 +81,12 @@ public class DoubleOperation {
 	 * @return
 	 */
 	public static Double div(Double d1, Double d2, int scale){
+		if (d1 == null || Double.isInfinite(d1)) {
+			d1 = 0.0;
+		}
+		if (d2 == null || Double.isInfinite(d2)) {
+			d2 = 0.0;
+		}
 		BigDecimal p1 = new BigDecimal(Double.toString(d1));
 		BigDecimal p2 = new BigDecimal(Double.toString(d2));
 		if (d2 == 0.0){