Browse Source

面料损耗更新

fenghaifu 2 years ago
parent
commit
9a14b34535

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/mapper/xml/FabricLossMapper.xml

@@ -145,7 +145,7 @@
 						RdRecords08 b
 						INNER JOIN rdrecord08 a ON a.id = b.ID
 					WHERE
-					a.cbustype in ('其他入库','转换入库')
+					a.cbustype in ('其他入库')/*,'转换入库'*/
 					)
 				) and
 				a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) not IN (

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

@@ -29,6 +29,7 @@ import org.jeecg.modules.system.model.SysUserSysDepartModel;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
 import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
+import org.jeecg.modules.system.util.DoubleOperation;
 import org.jeecg.modules.system.vo.SysUserDepVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheEvict;
@@ -690,16 +691,17 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 				orderItem.setCColor(cColor);
 				orderItem.setCInvCode(cInvCode);
 				orderItem.setOmcVenAbbName(item.getCVenAbbName());
-				orderItem.setIQuantityIn(item.getIQuantity());
-				orderItem.setIQuantityOut(item.getIQuantity());
+				BigDecimal bdVal = new BigDecimal(Double.toString(item.getIQuantity()));
+				orderItem.setIQuantityIn(bdVal.doubleValue());
+				orderItem.setIQuantityOut(bdVal.doubleValue());
 				List<FabricPoOrderOut> findOutList = fabricPoOrderOutListGroup.stream().filter(e->e.getCInvCode().equals(cInvCode) &&
 						e.getCColor().equals(cColor)).collect(Collectors.toList());
 				orderItem.setFabricPoOrderOutList(findOutList);
 				fabricPoOrderList.add(orderItem);
 			}else{
 				FabricPoOrder findItem = findOpt.get();
-				findItem.setIQuantityOut(findItem.getIQuantityOut()+item.getIQuantity());
-				findItem.setIQuantityIn(findItem.getIQuantityIn()+item.getIQuantity());
+				findItem.setIQuantityOut(DoubleOperation.add(findItem.getIQuantityOut(),item.getIQuantity()));
+				findItem.setIQuantityIn(DoubleOperation.add(findItem.getIQuantityIn(),item.getIQuantity()));
 				if (findItem.getOmcVenAbbName().indexOf(item.getCVenAbbName()) == -1){
 					findItem.setOmcVenAbbName(findItem.getOmcVenAbbName()+","+item.getCVenAbbName());
 				}
@@ -790,16 +792,17 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 				orderItem.setCColor(cColor);
 				orderItem.setCInvCode(cInvCode);
 				orderItem.setOmcVenAbbName(item.getCVenAbbName());
-				orderItem.setIQuantityIn(item.getIQuantity());
-				orderItem.setIQuantityOut(item.getIQuantity());
+				BigDecimal bdVal = new BigDecimal(Double.toString(item.getIQuantity()));
+				orderItem.setIQuantityIn(bdVal.doubleValue());
+				orderItem.setIQuantityOut(bdVal.doubleValue());
 				List<FabricPoOrderOut> findOutList = fabricPoOrderOutListGroup.stream().filter(e->e.getCInvCode().equals(cInvCode) &&
 						e.getCColor().equals(cColor)).collect(Collectors.toList());
 				orderItem.setFabricPoOrderOutList(findOutList);
 				fabricPoOrderList.add(orderItem);
 			}else{
 				FabricPoOrder findItem = findOpt.get();
-				findItem.setIQuantityOut(findItem.getIQuantityOut()+item.getIQuantity());
-				findItem.setIQuantityIn(findItem.getIQuantityIn()+item.getIQuantity());
+				findItem.setIQuantityOut(DoubleOperation.add(findItem.getIQuantityOut(),item.getIQuantity()));
+				findItem.setIQuantityIn(DoubleOperation.add(findItem.getIQuantityIn(),item.getIQuantity()));
 				if (findItem.getOmcVenAbbName().indexOf(item.getCVenAbbName()) == -1){
 					findItem.setOmcVenAbbName(findItem.getOmcVenAbbName()+","+item.getCVenAbbName());
 				}

+ 45 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/DoubleOperation.java

@@ -0,0 +1,45 @@
+package org.jeecg.modules.system.util;
+
+import java.math.BigDecimal;
+
+/**
+ * @author fenghaifu
+ * @version V1.0
+ * @Copyright: 上海萃颠信息科技有限公司. All rights reserved.
+ * @Title:DoubleOperation
+ * @projectName jeecg-boot-parent
+ * @Description:double运算,解决精度问题
+ * @date: 2022-11-16 20:24
+ * @updatehistory: 2022-11-16 20:24 新增
+ */
+public class DoubleOperation {
+	public static Double add(Double d1, Double d2){
+		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){
+		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){
+		BigDecimal p1 = new BigDecimal(Double.toString(d1));
+		BigDecimal p2 = new BigDecimal(Double.toString(d2));
+		return p1.multiply(p2).doubleValue();
+	}
+
+	/**
+	 *
+	 * @param d1
+	 * @param d2
+	 * @param scale 保留小数位数
+	 * @return
+	 */
+	public static Double div(Double d1, Double d2, int scale){
+		BigDecimal p1 = new BigDecimal(Double.toString(d1));
+		BigDecimal p2 = new BigDecimal(Double.toString(d2));
+		return p1.divide(p2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
+	}
+}
+