transferOutOrder = queryOfsStockoutOrder(queryOfsStockoutOrderRequestVO);
- if (transferOutOrder==null||transferOutOrder.size() == 0) {
+ if (transferOutOrder == null || transferOutOrder.size() == 0) {
return;
}
//过滤成功日志
@@ -241,7 +245,7 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
for (StockoutOrderSearchResponse.StockoutOrder stockoutOrder : transferOutOrder) {
StockoutOrderSearchResponse.StockoutOrder.StockoutH header = stockoutOrder.getHeader();
//过滤"NMNS"\"YNS"\"HJ"
- if("NMNS".equals(header.getCompanyCode())||"YNS".equals(header.getCompanyCode())||"HJ".equals(header.getCompanyCode())){
+ if ("NMNS".equals(header.getCompanyCode()) || "YNS".equals(header.getCompanyCode()) || "HJ".equals(header.getCompanyCode())) {
continue;
}
String rootAppPk = header.getCode();
@@ -293,7 +297,7 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
create = stockoutH.getCreated();
modify = stockoutH.getLastUpdated();
//dbilldate 单据日期
- parentvo.setDbilldate(modify.substring(0,10));
+ parentvo.setDbilldate(modify.substring(0, 10));
//dauditdate 审批日期
parentvo.setDauditdate(modify);
//coperatorid 制单人
@@ -325,18 +329,18 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
//pk_defdoc1 ofs调出店铺
String outShop = locateShop(ofsTranseferOrder.getHeader().getCompanyCode());
- if(outShop==null){
- Assert.state(false,"根据调出公司:{},未查询到对应的店铺,请维护(BDDP,调拨公司对应店铺)自定义项档案。", ofsTranseferOrder.getHeader().getCompanyCode());
- }else {
- //parentvo.setPk_defdoc1(ofsTranseferOrder.getHeader().getStoreCode());
- parentvo.setPk_defdoc1(outShop);
+ if (outShop == null) {
+ Assert.state(false, "根据调出公司:{},未查询到对应的店铺,请维护(BDDP,调拨公司对应店铺)自定义项档案。", ofsTranseferOrder.getHeader().getCompanyCode());
+ } else {
+ //parentvo.setPk_defdoc1(ofsTranseferOrder.getHeader().getStoreCode());
+ parentvo.setPk_defdoc1(outShop);
}
//pk_defdoc4 ofs调入店铺
String inShop = locateShop(ofsTranseferOrder.getHeader().getToCompanyCode());
- if (inShop==null) {
- Assert.state(false,"根据调入公司:{},未查询到对应的店铺,请维护(BDDP,调拨公司对应店铺)自定义项档案。", ofsTranseferOrder.getHeader().getCompanyCode());
- }else {
+ if (inShop == null) {
+ Assert.state(false, "根据调入公司:{},未查询到对应的店铺,请维护(BDDP,调拨公司对应店铺)自定义项档案。", ofsTranseferOrder.getHeader().getCompanyCode());
+ } else {
//parentvo.setPk_defdoc4(ofsTranseferOrder.getHeader().getToStoreCode());
parentvo.setPk_defdoc4(inShop);
}
@@ -348,7 +352,7 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
//vuserdef20 OFS调拨订单 id
parentvo.setVdef20(ofsTranseferOrder.getHeader().getId());
- boolean is_flag=false;
+ boolean is_flag = false;
StringBuffer stringBuffer = new StringBuffer();
//子表
@@ -371,18 +375,18 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
//202411091719:妮妮姐说:优先取结存价,没有的话取采购价,如果都没有就报错!!!
String nabprice = queryIaMonthledger(ofsDetail, ofsTranseferOrder.getHeader().getCompanyCode());
if (nabprice == null) {
- Assert.state(false, "公司:{},货品:{},SKU编码:{},无结存价和采购价,请维护!",ofsTranseferOrder.getHeader().getCompanyCode(),ofsDetail.getSkuName(),ofsDetail.getSkuCode());
+ Assert.state(false, "公司:{},货品:{},SKU编码:{},无结存价、起初价、采购价,请维护!", ofsTranseferOrder.getHeader().getCompanyCode(), ofsDetail.getSkuName(), ofsDetail.getSkuCode());
} else {
children.setNprice(nabprice);
}
//ntaxrate 税率
children.setNtaxrate("13");
- }catch (Exception eD){
- is_flag=true;
+ } catch (Exception eD) {
+ is_flag = true;
stringBuffer.append(eD.getMessage());
}
}
- if(is_flag){
+ if (is_flag) {
Assert.state(false, String.valueOf(stringBuffer));
}
billVO.setParentvo(parentvo);
@@ -420,7 +424,7 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
integrationTaskLivingDetailsEntity.setBusinessDate(modify);
integrationTaskLivingDetailsEntity.setRootAppPk(ofsCode);
integrationTaskLivingDetailsEntity.setRootAppBill(ofsCode);
- integrationTaskLivingDetailsEntity.setNewSystemNumber(corpCode+"_"+vbillcode);//u8c调拨订单号
+ integrationTaskLivingDetailsEntity.setNewSystemNumber(corpCode + "_" + vbillcode);//u8c调拨订单号
integrationTaskLivingDetailsEntity.setNewSystemPrimary(cbillid);//u8c调拨订单号
integrationTaskLivingDetailsEntity.setPluginId(getPluginId());
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
@@ -577,31 +581,35 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
@Autowired
private BalanceUnitPriceUtil balanceUnitPriceUtil;
+
/**
* 202411091719:妮妮姐说:优先取结存价,没有的话取采购价,如果都没有就报错!!!
* 根据存货管理档案档案,查询最后一次结算的单价,已根据ts 倒排,get(0)为最近一次核算价格
+ *
+ * 202502071359:妮妮姐电话:取值顺序 结存->期初->采购
+ * eg:1月 如果结存价取结存价,如果没有取期初,如果没有再去最后一次采购
*/
- public String queryIaMonthledger(OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferB sku,String companyCode) throws Exception {
+ public String queryIaMonthledger(OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferB sku, String companyCode) throws Exception {
String totalPayAmount = null;
//查询公司
BdCorpEntity bdCorpEntity = queryU8CEntityUtil.queryBdCorpByUnitCode(companyCode);
- if(bdCorpEntity==null){
- Assert.state(false,"根据OFS公司编码:{},查询U8C公司不存在。请检查U8C档案",companyCode);
+ if (bdCorpEntity == null) {
+ Assert.state(false, "根据OFS公司编码:{},查询U8C公司不存在。请检查U8C档案", companyCode);
}
//查询存货基本档案主键
BdInvbasdocEntity bdInvbasdocEntity = queryU8CEntityUtil.queryBdInvbasdocByCode(sku.getSkuCode());
- if(bdInvbasdocEntity==null){
- Assert.state(false,"根据OFS SKU CODE:{},查询U8C存货基本档案不存在。请检查U8C档案",sku.getSkuCode());
+ if (bdInvbasdocEntity == null) {
+ Assert.state(false, "根据OFS SKU CODE:{},查询U8C存货基本档案不存在。请检查U8C档案", sku.getSkuCode());
}
//查询存货管理档案
BdInvmandocEntity bdInvmandocEntity = queryU8CEntityUtil.queryBdInvmandocByPkInvbasdocAndPkCorp(bdInvbasdocEntity.getPkInvbasdoc(), bdCorpEntity.getPkCorp());
- if(bdInvmandocEntity==null){
- Assert.state(false,"根据U8C存货基本档案主键:{},U8C公司主键:{},查询U8C存货管理档案不存在。请检查U8C档案",bdInvbasdocEntity.getPkInvbasdoc(),bdCorpEntity.getPkCorp());
+ if (bdInvmandocEntity == null) {
+ Assert.state(false, "根据U8C存货基本档案主键:{},U8C公司主键:{},查询U8C存货管理档案不存在。请检查U8C档案", bdInvbasdocEntity.getPkInvbasdoc(), bdCorpEntity.getPkCorp());
}
- //结存价
+ //结存价(月份)
IaMonthledgerEntity iaMonthledgerEntity = new IaMonthledgerEntity();
iaMonthledgerEntity.setPkCorp(bdCorpEntity.getPkCorp());
iaMonthledgerEntity.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());
@@ -619,6 +627,26 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
}
+ //取期初价格,需要总价nabmny/数量nabnum,保留四位小数
+ IaPeriodaccountEntity iaPeriodaccountEntity = new IaPeriodaccountEntity();
+ iaPeriodaccountEntity.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());
+ iaPeriodaccountEntity.setCaccountmonth("00");
+ iaPeriodaccountEntity.setDr("0");
+ iaPeriodaccountEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
+ List iaPeriodaccountEntityList = iIaPeriodaccountDao.query(iaPeriodaccountEntity);
+ if (iaPeriodaccountEntityList.size() != 0) {
+ IaPeriodaccountEntity iaPeriodaccountEntity1 = iaPeriodaccountEntityList.get(0);
+ BigDecimal nabmny = new BigDecimal(iaPeriodaccountEntity1.getNabmny());
+ BigDecimal nabnum = new BigDecimal(iaPeriodaccountEntity1.getNabnum());
+ // 检查分母是否为0,避免出现算术异常
+ if (nabnum.compareTo(BigDecimal.ZERO) == 0) {
+ Assert.state(false, "公司编码:{},物料编码:{},取期初价格时,数量为0,请检查", companyCode, sku.getSkuCode());
+ }
+ BigDecimal result = nabmny.divide(nabnum, 4, RoundingMode.HALF_UP);
+ return result.stripTrailingZeros().toPlainString();
+ }
+
+
//取采购价
List bdInvmandocEntityArrayList1 = new ArrayList<>();
bdInvmandocEntityArrayList1.add(bdInvmandocEntity);
@@ -636,7 +664,7 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
totalPayAmount = multiply.stripTrailingZeros().toPlainString();
}
return totalPayAmount;
- }else {
+ } else {
return null;
}
@@ -649,7 +677,7 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
List defdocEntityList = queryU8CEntityUtil.queryBdDefDocByListCode("BDDP");
for (BdDefdocEntity bdDefdocEntity : defdocEntityList) {
- if (companyCode.equals(bdDefdocEntity.getDoccode())){
+ if (companyCode.equals(bdDefdocEntity.getDoccode())) {
return bdDefdocEntity.getMemo();
}
}