优化浮点数bug

This commit is contained in:
lihao 2025-08-29 14:31:23 +08:00
parent d9c232ab26
commit 3e15bd6457
2 changed files with 37 additions and 6 deletions

View File

@ -115,10 +115,14 @@ public class saveBeforeCheck implements IBusinessListener {
Object nassistnumObj = valMap.get("nassistnum");
String nassistnums = (nassistnumObj != null) ? nassistnumObj.toString() : "";
double nassistnum = (nassistnums.isEmpty()) ? 0 : Double.parseDouble(nassistnums);// 累计出库主数量
if (sQty < (nassistnum + bdsfnum)) {
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库实发数量'" + (nassistnum + bdsfnum)
+ "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!");
if (new UFDouble(sQty).compareTo((new UFDouble(nassistnum).add(new UFDouble(bdnum)))) <0) {
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库实发数量'" + (new UFDouble(nassistnum).add(new UFDouble(bdnum)).toString())
+ "'大于销售订单累计发货申请数量'" + (new UFDouble(sQty)).toString() + "',无法保存!");
}
// if (sQty < (nassistnum + bdsfnum)) {
// throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库实发数量'" + (nassistnum + bdsfnum)
// + "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!");
// }
} catch (NumberFormatException e) {
throw new BusinessException("累计发货申请数量、累计出库数量转化数值失败" + e);
}

View File

@ -13,11 +13,15 @@ import nc.impl.pubapp.pattern.rule.IRule;
import nc.vo.pu.m20.entity.PraybillItemVO;
import nc.vo.pu.m20.entity.PraybillVO;
import nc.vo.pu.pub.constant.PUMDValue;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nccloud.commons.lang.ArrayUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 请购单删除时回写备料计划是否下达字段
@ -30,22 +34,35 @@ public class UpdatePickmRule implements IRule<PraybillVO> {
if (!ArrayUtils.isEmpty(vos)) {
try {
List<String> pk= new ArrayList<String>();
List<Map<String,Object>> updateList = new ArrayList<>();
for (PraybillVO vo : vos) {
PraybillItemVO[] praybillItemVOS=vo.getBVO();
for (PraybillItemVO praybillItemVO : praybillItemVOS) {
if("55A3".equals(praybillItemVO.getCsourcetypecode())){
Map<String,Object> map = new HashMap<>();
map.put("num",praybillItemVO.getNastnum());
map.put("pk",praybillItemVO.getCfirstbid());
pk.add(praybillItemVO.getCsourcebid());
}
}
}
if(!updateList.isEmpty()){
// 回写已经下达数量
updetaPmoNum(updateList);
}
if(!pk.isEmpty()){
//回写是否下方为是
updetaPmo(pk);
}
} catch (Exception e) {
ExceptionUtils.wrappException(e);
} catch (BusinessException e) {
try {
throw new BusinessException(e.getMessage());
} catch (BusinessException ex) {
throw new RuntimeException(ex);
}
}
}
@ -67,9 +84,19 @@ public class UpdatePickmRule implements IRule<PraybillVO> {
} else {
result = "'" + (String) arrayList.get(0) + "'";
}
String sql = " update mm_pickm_b set vbdef13='N' where mm_pickm_b.cpickm_bid in(" + result + ")";
String sql = " update mm_pickm_b set vbdef13='N' where mm_pickm_b.cpickm_bid in(" + result + ") and mm_pickm_b.vbdef16='0' ";
BaseDAO dao = new BaseDAO();
dao.executeUpdate(sql);
}
private void updetaPmoNum(List<Map<String, Object>> updateList) throws DAOException {
BaseDAO dao = new BaseDAO();
for (Map<String, Object> updateMap : updateList) {
String sql = " update mm_pickm_b set vbdef16 = TO_CHAR(TO_NUMBER(vbdef16) -TO_NUMBER('"+((UFDouble)updateMap.get("num")).toString()+"')) where mm_pickm_b.cpickm_bid ='" + updateMap.get("pk") + "'";
dao.executeUpdate(sql);
}
}
}