丽知:调拨订单新增期初价格查询

This commit is contained in:
zhengyf 2025-02-09 00:07:04 +08:00
parent 1ffef190ef
commit 61de821ebd
2 changed files with 57 additions and 30 deletions

View File

@ -164,10 +164,9 @@
<if test="vfree8 != null and vfree8 != ''"> and VFREE8 = #{vfree8} </if>
<if test="vfree9 != null and vfree9 != ''"> and VFREE9 = #{vfree9} </if>
<if test="vproducebatch != null and vproducebatch != ''"> and VPRODUCEBATCH = #{vproducebatch} </if>
and sts='Y'
-- and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
ORDER BY TS DESC
</select>
<!-- 查询符合条件的数量 -->

View File

@ -10,6 +10,7 @@ import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.lets.constant.OverallConstant;
import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant;
import com.hzya.frame.plugin.lets.dao.IIaMonthledgerDao;
import com.hzya.frame.plugin.lets.dao.IIaPeriodaccountDao;
import com.hzya.frame.plugin.lets.entity.*;
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsStockinOrderRequestVO;
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsStockoutOrderRequestVO;
@ -45,6 +46,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -104,6 +106,8 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
@Autowired
private IIaMonthledgerDao iaMonthledgerDao;
@Autowired
private IIaPeriodaccountDao iIaPeriodaccountDao;
@Autowired
private QueryU8CEntityUtil queryU8CEntityUtil;
@Override
@ -371,7 +375,7 @@ 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);
}
@ -577,9 +581,13 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
@Autowired
private BalanceUnitPriceUtil balanceUnitPriceUtil;
/**
* 202411091719妮妮姐说优先取结存价没有的话取采购价如果都没有就报错
* 根据存货管理档案档案查询最后一次结算的单价,已根据ts 倒排get(0)为最近一次核算价格
* <p>
* 202502071359妮妮姐电话取值顺序 结存->期初->采购
* eg1月 如果结存价取结存价如果没有取期初如果没有再去最后一次采购
*/
public String queryIaMonthledger(OFSTranseferOrderSearchResponse.OFSTranseferOrder.OFSTranseferB sku, String companyCode) throws Exception {
String totalPayAmount = null;
@ -601,7 +609,7 @@ public class TransferOutPluginInitializer extends PluginBaseEntity {
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<IaPeriodaccountEntity> 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<BdInvmandocEntity> bdInvmandocEntityArrayList1 = new ArrayList<>();
bdInvmandocEntityArrayList1.add(bdInvmandocEntity);