|
@@ -88,6 +88,10 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
private GeTuiUtils geTuiUtils;
|
|
|
@Autowired
|
|
|
private IStockSaleReceiptReportService stockSaleReceiptReportService;
|
|
|
+ @Autowired
|
|
|
+ private IWeightedDetailsService weightedDetailsService;
|
|
|
+ @Autowired
|
|
|
+ private ICostManagementInfoService costManagementInfoService;
|
|
|
|
|
|
/**
|
|
|
* 待完成页面列表
|
|
@@ -99,8 +103,8 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
public Page<WarehouseInOutInfo> selectWarehouseInOutInfo(WarehouseInOutInfo warehouseInOutInfo) {
|
|
|
//查询页面信息
|
|
|
Wrapper<WarehouseInOutInfo> warehouseInOutInfoWrapper = new EntityWrapper<WarehouseInOutInfo>();
|
|
|
- if (warehouseInOutInfo.getInOutFlag()!=null){
|
|
|
- warehouseInOutInfoWrapper.eq("in_out_flag",warehouseInOutInfo.getInOutFlag());
|
|
|
+ if (warehouseInOutInfo.getInOutFlag() != null) {
|
|
|
+ warehouseInOutInfoWrapper.eq("in_out_flag", warehouseInOutInfo.getInOutFlag());
|
|
|
}
|
|
|
warehouseInOutInfoWrapper.eq("base_id", warehouseInOutInfo.getBaseId())
|
|
|
.eq("position_id", warehouseInOutInfo.getPositionId())
|
|
@@ -228,6 +232,8 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
//判断出入库
|
|
|
//常用库入库
|
|
|
if ("2".equals(warehouseInOutInfo.getInOutFlag()) && "1".equals(warehouseBaseInfo.getWarehouseType())) {
|
|
|
+
|
|
|
+ float original = 0f;
|
|
|
//判断是否有库
|
|
|
if (warehouseBaseInfo != null) {
|
|
|
// 查询库位
|
|
@@ -240,6 +246,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
.eq("delete_flag", "0"));
|
|
|
// 判断是否有货
|
|
|
if (warehousePositionStorageInfo != null) {
|
|
|
+ original = warehousePositionStorageInfo.getStorage();
|
|
|
// 更新库存量
|
|
|
warehousePositionStorageInfo.setStorage(warehousePositionStorageInfo.getStorage() + warehouseInOutInfo.getNetWeight());
|
|
|
warehousePositionStorageInfoService.updateById(warehousePositionStorageInfo);
|
|
@@ -268,14 +275,79 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
tranCarInfo.setDeductionAmount(warehouseInOutInfo.getDeductionAmount());
|
|
|
tranCarInfo.setStatus(StatusEnum.DELIVERED.getName());
|
|
|
tranCarInfo.setStatusFlag(StatusEnum.DELIVERED.getFlag());
|
|
|
- if ("1".equals(tranCarInfo.getSubmit())){
|
|
|
+ if ("1".equals(tranCarInfo.getSubmit())) {
|
|
|
throw new YException(YExceptionEnum.CARNO_SUBMITTED_ERROR);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
tranCarInfo.setSubmit("1");
|
|
|
}
|
|
|
tranCarInfoService.updateById(tranCarInfo);
|
|
|
}
|
|
|
+
|
|
|
+ // 生成加权成本数据
|
|
|
+ WeightedDetails weightedDetails = new WeightedDetails();
|
|
|
+ weightedDetails.setCompId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
|
+ weightedDetails.setId(IdGenerator.generateUUID());
|
|
|
+ weightedDetails.setWarehouseId(warehouseInOutInfo.getBaseId());
|
|
|
+ weightedDetails.setWarehouseName(warehouseInOutInfo.getWarehouseName());
|
|
|
+ weightedDetails.setGoodsNameKey(warehouseInOutInfo.getGoodsNameKey());
|
|
|
+ weightedDetails.setGoodsName(warehouseInOutInfo.getGoodsName());
|
|
|
+ weightedDetails.setGrainType(warehouseInOutInfo.getType());
|
|
|
+ weightedDetails.setInTypeKey(warehouseInOutInfo.getTaskTypeKey());
|
|
|
+ weightedDetails.setInType(warehouseInOutInfo.getTaskType());
|
|
|
+ weightedDetails.setNetWeight(warehouseInOutInfo.getNetWeight());
|
|
|
+ weightedDetails.setPureWeight(warehouseInOutInfo.getPureWeight());
|
|
|
+ weightedDetails.setUnitPrice(warehouseInOutInfo.getUnitPrice());
|
|
|
+ weightedDetails.setDeductionAmount(warehouseInOutInfo.getDeductionAmount());
|
|
|
+ weightedDetails.setFreight(warehouseInOutInfo.getFreight());
|
|
|
+ weightedDetails.setOriginalStock(original);
|
|
|
+ // 查询入库全加权成本
|
|
|
+ List<WeightedDetails> weightedDetailsList = weightedDetailsService.selectList(new EntityWrapper<WeightedDetails>().eq("warehouse_id", warehouseInOutInfo.getWarehouseName())
|
|
|
+ .eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()).orderBy("update_date", false));
|
|
|
+ if (CollectionUtils.isEmpty(weightedDetailsList)) {
|
|
|
+ weightedDetails.setCostBefore(0f);
|
|
|
+ } else {
|
|
|
+ weightedDetails.setCostBefore(weightedDetailsList.get(0).getCostBefore());
|
|
|
+ }
|
|
|
+ // 计算新加权成本
|
|
|
+ Float newCost = 0f;
|
|
|
+ if ("干粮".equals(warehouseInOutInfo.getTaskType())) {
|
|
|
+ newCost = ((warehouseInOutInfo.getCost() + warehouseInOutInfo.getFreight()) * warehouseInOutInfo.getNetWeight() + original * weightedDetails.getCostBefore()) / (warehouseInOutInfo.getNetWeight() + original);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ newCost = ((warehouseInOutInfo.getCost() + warehouseInOutInfo.getFreight()) * warehouseInOutInfo.getNetWeight() + original * weightedDetails.getCostBefore()) / (warehouseInOutInfo.getPureWeight() + original);
|
|
|
+
|
|
|
+ }
|
|
|
+ weightedDetails.setCostAfter(newCost);
|
|
|
+
|
|
|
+ weightedDetailsService.insert(weightedDetails);
|
|
|
+ // 修改成本信息表
|
|
|
+ CostManagementInfo costManagementInfo = costManagementInfoService.selectOne(new EntityWrapper<CostManagementInfo>().eq("warehouse_id", weightedDetails.getWarehouseId())
|
|
|
+ .eq("goods_name_key", weightedDetails.getGoodsNameKey()));
|
|
|
+ List<WeightedDetails> weightedDetailsLists = weightedDetailsService.selectList(new EntityWrapper<WeightedDetails>().eq("warehouse_id", warehouseInOutInfo.getWarehouseName())
|
|
|
+ .eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()).orderBy("update_date", false));
|
|
|
+ Float net = 0f;
|
|
|
+ for(int i=0;i<weightedDetailsLists.size();i++){
|
|
|
+ net = net +weightedDetailsLists.get(i).getNetWeight();
|
|
|
+ }
|
|
|
+ if(costManagementInfo ==null){
|
|
|
+ CostManagementInfo costManagementInfo1= new CostManagementInfo();
|
|
|
+ costManagementInfo1.setCompId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
|
+ costManagementInfo1.setId(IdGenerator.generateUUID());
|
|
|
+ costManagementInfo1.setWarehouseId(weightedDetails.getWarehouseId());
|
|
|
+ costManagementInfo1.setWarehouseName(weightedDetails.getWarehouseName());
|
|
|
+ costManagementInfo1.setGoodsNameKey(weightedDetails.getGoodsNameKey());
|
|
|
+ costManagementInfo1.setGoodsName(weightedDetails.getGoodsName());
|
|
|
+ costManagementInfo1.setWarehouseType(warehouseBaseInfo.getWarehouseType());
|
|
|
+
|
|
|
+ costManagementInfo1.setStorage(net);
|
|
|
+ costManagementInfo1.setCost(weightedDetails.getCostAfter());
|
|
|
+ costManagementInfoService.insert(costManagementInfo1);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ costManagementInfo.setCost(weightedDetails.getCostAfter());
|
|
|
+ costManagementInfo.setStorage(net);
|
|
|
+ costManagementInfoService.updateById(costManagementInfo);
|
|
|
+ }
|
|
|
}
|
|
|
//常用库出库
|
|
|
else if ("1".equals(warehouseInOutInfo.getInOutFlag()) && "1".equals(warehouseBaseInfo.getWarehouseType())) {
|
|
@@ -383,6 +455,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
.eq("delete_flag", "0"));
|
|
|
//更新库存量
|
|
|
if (warehouseBaseInfo != null) {
|
|
|
+ float original = 0f;
|
|
|
// 查询库位
|
|
|
WarehousePositionInfo warehousePositionInfo = warehousePositionInfoService.selectById(warehouseInOutInfo.getPositionId());
|
|
|
if (warehousePositionInfo != null) {
|
|
@@ -393,12 +466,14 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
.eq("delete_flag", "0"));
|
|
|
// 判断是否有货
|
|
|
if (warehousePositionStorageInfo != null) {
|
|
|
+ original = warehousePositionStorageInfo.getStorage() + warehouseInOutInfo.getNetWeight();
|
|
|
// 更新库存量
|
|
|
warehousePositionStorageInfo.setStorage(warehousePositionStorageInfo.getStorage() + warehouseInOutInfo.getNetWeight());
|
|
|
warehousePositionStorageInfoService.updateById(warehousePositionStorageInfo);
|
|
|
}
|
|
|
// 没有货
|
|
|
else {
|
|
|
+ original=0f;
|
|
|
WarehousePositionStorageInfo warehousePositionStorageInfo1 = new WarehousePositionStorageInfo();
|
|
|
warehousePositionStorageInfo1.setId(IdGenerator.generateUUID());
|
|
|
warehousePositionStorageInfo1.setPositionId(warehouseInOutInfo.getPositionId());
|
|
@@ -408,11 +483,76 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
warehousePositionStorageInfoService.insert(warehousePositionStorageInfo1);
|
|
|
}
|
|
|
}
|
|
|
+ // 生成加权成本数据
|
|
|
+ WeightedDetails weightedDetails = new WeightedDetails();
|
|
|
+ weightedDetails.setCompId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
|
+ weightedDetails.setId(IdGenerator.generateUUID());
|
|
|
+ weightedDetails.setWarehouseId(warehouseInOutInfo.getBaseId());
|
|
|
+ weightedDetails.setWarehouseName(warehouseInOutInfo.getWarehouseName());
|
|
|
+ weightedDetails.setGoodsNameKey(warehouseInOutInfo.getGoodsNameKey());
|
|
|
+ weightedDetails.setGoodsName(warehouseInOutInfo.getGoodsName());
|
|
|
+ weightedDetails.setGrainType(warehouseInOutInfo.getType());
|
|
|
+ weightedDetails.setInTypeKey(warehouseInOutInfo.getTaskTypeKey());
|
|
|
+ weightedDetails.setInType(warehouseInOutInfo.getTaskType());
|
|
|
+ weightedDetails.setNetWeight(warehouseInOutInfo.getNetWeight());
|
|
|
+ weightedDetails.setPureWeight(warehouseInOutInfo.getPureWeight());
|
|
|
+ weightedDetails.setUnitPrice(warehouseInOutInfo.getUnitPrice());
|
|
|
+ weightedDetails.setDeductionAmount(warehouseInOutInfo.getDeductionAmount());
|
|
|
+ weightedDetails.setFreight(warehouseInOutInfo.getFreight());
|
|
|
+ weightedDetails.setOriginalStock(original);
|
|
|
+ // 查询入库全加权成本
|
|
|
+ List<WeightedDetails> weightedDetailsList = weightedDetailsService.selectList(new EntityWrapper<WeightedDetails>().eq("warehouse_id", warehouseInOutInfo.getWarehouseName())
|
|
|
+ .eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()).orderBy("update_date", false));
|
|
|
+ if (CollectionUtils.isEmpty(weightedDetailsList)) {
|
|
|
+ weightedDetails.setCostBefore(0f);
|
|
|
+ } else {
|
|
|
+ weightedDetails.setCostBefore(weightedDetailsList.get(0).getCostBefore());
|
|
|
+ }
|
|
|
+ // 计算新加权成本
|
|
|
+ Float newCost = 0f;
|
|
|
+ if ("干粮".equals(warehouseInOutInfo.getTaskType())) {
|
|
|
+ newCost = ((warehouseInOutInfo.getCost() + warehouseInOutInfo.getFreight()) * warehouseInOutInfo.getNetWeight() + original * weightedDetails.getCostBefore()) / (warehouseInOutInfo.getNetWeight() + original);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ newCost = ((warehouseInOutInfo.getCost() + warehouseInOutInfo.getFreight()) * warehouseInOutInfo.getNetWeight() + original * weightedDetails.getCostBefore()) / (warehouseInOutInfo.getPureWeight() + original);
|
|
|
+
|
|
|
+ }
|
|
|
+ weightedDetails.setCostAfter(newCost);
|
|
|
+
|
|
|
+ weightedDetailsService.insert(weightedDetails);
|
|
|
+ // 修改成本信息表
|
|
|
+ CostManagementInfo costManagementInfo = costManagementInfoService.selectOne(new EntityWrapper<CostManagementInfo>().eq("warehouse_id", weightedDetails.getWarehouseId())
|
|
|
+ .eq("goods_name_key", weightedDetails.getGoodsNameKey()));
|
|
|
+ List<WeightedDetails> weightedDetailsLists = weightedDetailsService.selectList(new EntityWrapper<WeightedDetails>().eq("warehouse_id", warehouseInOutInfo.getWarehouseName())
|
|
|
+ .eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()).orderBy("update_date", false));
|
|
|
+ Float net = 0f;
|
|
|
+ for(int i=0;i<weightedDetailsLists.size();i++){
|
|
|
+ net = net +weightedDetailsLists.get(i).getNetWeight();
|
|
|
+ }
|
|
|
+ if(costManagementInfo ==null){
|
|
|
+ CostManagementInfo costManagementInfo1= new CostManagementInfo();
|
|
|
+ costManagementInfo1.setCompId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
|
+ costManagementInfo1.setId(IdGenerator.generateUUID());
|
|
|
+ costManagementInfo1.setWarehouseId(weightedDetails.getWarehouseId());
|
|
|
+ costManagementInfo1.setWarehouseName(weightedDetails.getWarehouseName());
|
|
|
+ costManagementInfo1.setGoodsNameKey(weightedDetails.getGoodsNameKey());
|
|
|
+ costManagementInfo1.setGoodsName(weightedDetails.getGoodsName());
|
|
|
+ costManagementInfo1.setWarehouseType(warehouseBaseInfo.getWarehouseType());
|
|
|
+
|
|
|
+ costManagementInfo1.setStorage(net);
|
|
|
+ costManagementInfo1.setCost(weightedDetails.getCostAfter());
|
|
|
+ costManagementInfoService.insert(costManagementInfo1);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ costManagementInfo.setCost(weightedDetails.getCostAfter());
|
|
|
+ costManagementInfo.setStorage(net);
|
|
|
+ costManagementInfoService.updateById(costManagementInfo);
|
|
|
+ }
|
|
|
}
|
|
|
StockPurchaseReceiptReport stockPurchaseReceiptReport = new StockPurchaseReceiptReport();
|
|
|
PurchaseReceiptReport purchaseReceiptReport = new PurchaseReceiptReport();
|
|
|
// 期货采购入库统计
|
|
|
- if("2".equals(contractManagementInfo.getGoodsType())) {
|
|
|
+ if ("2".equals(contractManagementInfo.getGoodsType())) {
|
|
|
purchaseReceiptReport.setId(IdGenerator.generateUUID());
|
|
|
purchaseReceiptReport.setCompId(warehouseBaseInfo.getCompId());
|
|
|
purchaseReceiptReport.setContractNo(warehouseInOutInfo.getContractNo());
|
|
@@ -480,7 +620,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
}
|
|
|
}
|
|
|
//现货采购入库统计
|
|
|
- else{
|
|
|
+ else {
|
|
|
stockPurchaseReceiptReport.setId(IdGenerator.generateUUID());
|
|
|
stockPurchaseReceiptReport.setCompId(warehouseBaseInfo.getCompId());
|
|
|
stockPurchaseReceiptReport.setContractNo(warehouseInOutInfo.getContractNo());
|
|
@@ -506,10 +646,9 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
tranCarInfo.setDeductionAmount(warehouseInOutInfo.getDeductionAmount());
|
|
|
tranCarInfo.setStatus(StatusEnum.DELIVERED.getName());
|
|
|
tranCarInfo.setStatusFlag(StatusEnum.DELIVERED.getFlag());
|
|
|
- if ("1".equals(tranCarInfo.getSubmit())){
|
|
|
+ if ("1".equals(tranCarInfo.getSubmit())) {
|
|
|
throw new YException(YExceptionEnum.CARNO_SUBMITTED_ERROR);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
tranCarInfo.setSubmit("1");
|
|
|
}
|
|
|
tranCarInfoService.updateById(tranCarInfo);
|
|
@@ -594,8 +733,8 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
}
|
|
|
//查询期货现货合同
|
|
|
ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
- .eq("contract_no",warehouseInOutInfo.getContractNo()));
|
|
|
- if("2".equals(contractManagementInfo.getGoodsType())){
|
|
|
+ .eq("contract_no", warehouseInOutInfo.getContractNo()));
|
|
|
+ if ("2".equals(contractManagementInfo.getGoodsType())) {
|
|
|
//客户生成收货信息
|
|
|
TranCarInfo tranCarInfo = new TranCarInfo();
|
|
|
tranCarInfo.setId(IdGenerator.generateUUID());
|
|
@@ -626,7 +765,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
salesDeliveryReport.setUnitPrice(saleOrder.getUnitPrice());
|
|
|
salesDeliveryReport.setInvoiceFee(saleOrder.getInvoiceFee());
|
|
|
//期货
|
|
|
- if (saleOrder.getBasis()!=null){
|
|
|
+ if (saleOrder.getBasis() != null) {
|
|
|
salesDeliveryReport.setBasisPrice(saleOrder.getBasis());
|
|
|
BigDecimal unitPrice = new BigDecimal(Float.toString(salesDeliveryReport.getUnitPrice()));
|
|
|
BigDecimal basis = new BigDecimal(Float.toString(salesDeliveryReport.getBasisPrice()));
|
|
@@ -681,7 +820,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
salesDeliveryReportService.updateById(salesDeliveryReport);
|
|
|
workflowService.activateInstance(salesDeliveryReport.getWorkflowId(), salesDeliveryReport.getId());
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//现货销售统计
|
|
|
StockSaleReceiptReport stockSaleReceiptReport = new StockSaleReceiptReport();
|
|
|
stockSaleReceiptReport.setId(IdGenerator.generateUUID());
|
|
@@ -692,11 +831,11 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
stockSaleReceiptReport.setGrossWeight(warehouseInOutInfo.getGrossWeight());
|
|
|
stockSaleReceiptReport.setTare(warehouseInOutInfo.getTare());
|
|
|
stockSaleReceiptReport.setNetWeight(warehouseInOutInfo.getNetWeight());
|
|
|
- if("出库任务".equals(warehouseInOutInfo.getTaskType())){
|
|
|
+ if ("出库任务".equals(warehouseInOutInfo.getTaskType())) {
|
|
|
stockSaleReceiptReport.setDeliveryDate(warehouseInOutInfo.getInOutDate());
|
|
|
stockSaleReceiptReport.setSettlementWeight(warehouseInOutInfo.getNetWeight());
|
|
|
stockSaleReceiptReport.setAmountIngReceivable(warehouseInOutInfo.getUnitPrice() * stockSaleReceiptReport.getSettlementWeight());
|
|
|
- }else if ("退库并出库".equals(warehouseInOutInfo.getTaskType())){
|
|
|
+ } else if ("退库并出库".equals(warehouseInOutInfo.getTaskType())) {
|
|
|
stockSaleReceiptReport.setReturnDate(warehouseInOutInfo.getInOutDate());
|
|
|
stockSaleReceiptReport.setSettlementWeight(-warehouseInOutInfo.getNetWeight());
|
|
|
stockSaleReceiptReport.setAmountIngReceivable(0.0f);
|
|
@@ -755,6 +894,8 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
}
|
|
|
//更新库存量
|
|
|
if (warehouseBaseInfo != null) {
|
|
|
+
|
|
|
+ Float original = 0f;
|
|
|
// 查询库位
|
|
|
WarehousePositionInfo warehousePositionInfo = warehousePositionInfoService.selectById(warehouseInOutInfo.getPositionId());
|
|
|
if (warehousePositionInfo != null) {
|
|
@@ -765,12 +906,14 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
.eq("delete_flag", "0"));
|
|
|
// 判断是否有货
|
|
|
if (warehousePositionStorageInfo != null) {
|
|
|
+ original = warehousePositionStorageInfo.getStorage() + warehouseInOutInfo.getNetWeight();
|
|
|
// 更新库存量
|
|
|
warehousePositionStorageInfo.setStorage(warehousePositionStorageInfo.getStorage() + warehouseInOutInfo.getNetWeight());
|
|
|
warehousePositionStorageInfoService.updateById(warehousePositionStorageInfo);
|
|
|
}
|
|
|
// 没有货
|
|
|
else {
|
|
|
+ original= 0f;
|
|
|
WarehousePositionStorageInfo warehousePositionStorageInfo1 = new WarehousePositionStorageInfo();
|
|
|
warehousePositionStorageInfo1.setId(IdGenerator.generateUUID());
|
|
|
warehousePositionStorageInfo1.setPositionId(warehouseInOutInfo.getPositionId());
|
|
@@ -780,11 +923,77 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
warehousePositionStorageInfoService.insert(warehousePositionStorageInfo1);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 生成加权成本数据
|
|
|
+ WeightedDetails weightedDetails = new WeightedDetails();
|
|
|
+ weightedDetails.setCompId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
|
+ weightedDetails.setId(IdGenerator.generateUUID());
|
|
|
+ weightedDetails.setWarehouseId(warehouseInOutInfo.getBaseId());
|
|
|
+ weightedDetails.setWarehouseName(warehouseInOutInfo.getWarehouseName());
|
|
|
+ weightedDetails.setGoodsNameKey(warehouseInOutInfo.getGoodsNameKey());
|
|
|
+ weightedDetails.setGoodsName(warehouseInOutInfo.getGoodsName());
|
|
|
+ weightedDetails.setGrainType(warehouseInOutInfo.getType());
|
|
|
+ weightedDetails.setInTypeKey(warehouseInOutInfo.getTaskTypeKey());
|
|
|
+ weightedDetails.setInType(warehouseInOutInfo.getTaskType());
|
|
|
+ weightedDetails.setNetWeight(warehouseInOutInfo.getNetWeight());
|
|
|
+ weightedDetails.setPureWeight(warehouseInOutInfo.getPureWeight());
|
|
|
+ weightedDetails.setUnitPrice(warehouseInOutInfo.getUnitPrice());
|
|
|
+ weightedDetails.setDeductionAmount(warehouseInOutInfo.getDeductionAmount());
|
|
|
+ weightedDetails.setFreight(warehouseInOutInfo.getFreight());
|
|
|
+ weightedDetails.setOriginalStock(original);
|
|
|
+ // 查询入库全加权成本
|
|
|
+ List<WeightedDetails> weightedDetailsList = weightedDetailsService.selectList(new EntityWrapper<WeightedDetails>().eq("warehouse_id", warehouseInOutInfo.getWarehouseName())
|
|
|
+ .eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()).orderBy("update_date", false));
|
|
|
+ if (CollectionUtils.isEmpty(weightedDetailsList)) {
|
|
|
+ weightedDetails.setCostBefore(0f);
|
|
|
+ } else {
|
|
|
+ weightedDetails.setCostBefore(weightedDetailsList.get(0).getCostBefore());
|
|
|
+ }
|
|
|
+ // 计算新加权成本
|
|
|
+ Float newCost = 0f;
|
|
|
+ if ("干粮".equals(warehouseInOutInfo.getTaskType())) {
|
|
|
+ newCost = ((warehouseInOutInfo.getCost() + warehouseInOutInfo.getFreight()) * warehouseInOutInfo.getNetWeight() + original * weightedDetails.getCostBefore()) / (warehouseInOutInfo.getNetWeight() + original);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ newCost = ((warehouseInOutInfo.getCost() + warehouseInOutInfo.getFreight()) * warehouseInOutInfo.getNetWeight() + original * weightedDetails.getCostBefore()) / (warehouseInOutInfo.getPureWeight() + original);
|
|
|
+
|
|
|
+ }
|
|
|
+ weightedDetails.setCostAfter(newCost);
|
|
|
+
|
|
|
+ weightedDetailsService.insert(weightedDetails);
|
|
|
+ // 修改成本信息表
|
|
|
+ CostManagementInfo costManagementInfo = costManagementInfoService.selectOne(new EntityWrapper<CostManagementInfo>().eq("warehouse_id", weightedDetails.getWarehouseId())
|
|
|
+ .eq("goods_name_key", weightedDetails.getGoodsNameKey()));
|
|
|
+ List<WeightedDetails> weightedDetailsLists = weightedDetailsService.selectList(new EntityWrapper<WeightedDetails>().eq("warehouse_id", warehouseInOutInfo.getWarehouseName())
|
|
|
+ .eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()).orderBy("update_date", false));
|
|
|
+ Float net = 0f;
|
|
|
+ for(int i=0;i<weightedDetailsLists.size();i++){
|
|
|
+ net = net +weightedDetailsLists.get(i).getNetWeight();
|
|
|
+ }
|
|
|
+ if(costManagementInfo ==null){
|
|
|
+ CostManagementInfo costManagementInfo1= new CostManagementInfo();
|
|
|
+ costManagementInfo1.setCompId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
|
+ costManagementInfo1.setId(IdGenerator.generateUUID());
|
|
|
+ costManagementInfo1.setWarehouseId(weightedDetails.getWarehouseId());
|
|
|
+ costManagementInfo1.setWarehouseName(weightedDetails.getWarehouseName());
|
|
|
+ costManagementInfo1.setGoodsNameKey(weightedDetails.getGoodsNameKey());
|
|
|
+ costManagementInfo1.setGoodsName(weightedDetails.getGoodsName());
|
|
|
+ costManagementInfo1.setWarehouseType(warehouseBaseInfo.getWarehouseType());
|
|
|
+
|
|
|
+ costManagementInfo1.setStorage(net);
|
|
|
+ costManagementInfo1.setCost(weightedDetails.getCostAfter());
|
|
|
+ costManagementInfoService.insert(costManagementInfo1);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ costManagementInfo.setCost(weightedDetails.getCostAfter());
|
|
|
+ costManagementInfo.setStorage(net);
|
|
|
+ costManagementInfoService.updateById(costManagementInfo);
|
|
|
+ }
|
|
|
}
|
|
|
StockPurchaseReceiptReport stockPurchaseReceiptReport = new StockPurchaseReceiptReport();
|
|
|
PurchaseReceiptReport purchaseReceiptReport = new PurchaseReceiptReport();
|
|
|
// 期货采购入库统计
|
|
|
- if("2".equals(contractManagementInfo.getGoodsType())) {
|
|
|
+ if ("2".equals(contractManagementInfo.getGoodsType())) {
|
|
|
purchaseReceiptReport.setId(IdGenerator.generateUUID());
|
|
|
purchaseReceiptReport.setCompId(warehouseBaseInfo.getCompId());
|
|
|
purchaseReceiptReport.setContractNo(warehouseInOutInfo.getContractNo());
|
|
@@ -852,7 +1061,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
}
|
|
|
}
|
|
|
//现货采购入库统计
|
|
|
- else{
|
|
|
+ else {
|
|
|
stockPurchaseReceiptReport.setId(IdGenerator.generateUUID());
|
|
|
stockPurchaseReceiptReport.setCompId(warehouseBaseInfo.getCompId());
|
|
|
stockPurchaseReceiptReport.setContractNo(warehouseInOutInfo.getContractNo());
|
|
@@ -878,10 +1087,9 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
tranCarInfo.setDeductionAmount(warehouseInOutInfo.getDeductionAmount());
|
|
|
tranCarInfo.setStatus(StatusEnum.DELIVERED.getName());
|
|
|
tranCarInfo.setStatusFlag(StatusEnum.DELIVERED.getFlag());
|
|
|
- if ("1".equals(tranCarInfo.getSubmit())){
|
|
|
+ if ("1".equals(tranCarInfo.getSubmit())) {
|
|
|
throw new YException(YExceptionEnum.CARNO_SUBMITTED_ERROR);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
tranCarInfo.setSubmit("1");
|
|
|
}
|
|
|
tranCarInfoService.updateById(tranCarInfo);
|
|
@@ -968,8 +1176,8 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
|
|
|
//查询期货现货合同
|
|
|
ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
- .eq("contract_no",warehouseInOutInfo.getContractNo()));
|
|
|
- if("2".equals(contractManagementInfo.getGoodsType())){
|
|
|
+ .eq("contract_no", warehouseInOutInfo.getContractNo()));
|
|
|
+ if ("2".equals(contractManagementInfo.getGoodsType())) {
|
|
|
//客户生成收货信息
|
|
|
TranCarInfo tranCarInfo = new TranCarInfo();
|
|
|
tranCarInfo.setId(IdGenerator.generateUUID());
|
|
@@ -1000,7 +1208,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
salesDeliveryReport.setUnitPrice(saleOrder.getUnitPrice());
|
|
|
salesDeliveryReport.setInvoiceFee(saleOrder.getInvoiceFee());
|
|
|
//期货
|
|
|
- if (saleOrder.getBasis()!=null){
|
|
|
+ if (saleOrder.getBasis() != null) {
|
|
|
salesDeliveryReport.setBasisPrice(saleOrder.getBasis());
|
|
|
BigDecimal unitPrice = new BigDecimal(Float.toString(salesDeliveryReport.getUnitPrice()));
|
|
|
BigDecimal basis = new BigDecimal(Float.toString(salesDeliveryReport.getBasisPrice()));
|
|
@@ -1055,7 +1263,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
salesDeliveryReportService.updateById(salesDeliveryReport);
|
|
|
workflowService.activateInstance(salesDeliveryReport.getWorkflowId(), salesDeliveryReport.getId());
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//现货销售统计
|
|
|
StockSaleReceiptReport stockSaleReceiptReport = new StockSaleReceiptReport();
|
|
|
stockSaleReceiptReport.setId(IdGenerator.generateUUID());
|
|
@@ -1066,15 +1274,21 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
stockSaleReceiptReport.setGrossWeight(warehouseInOutInfo.getGrossWeight());
|
|
|
stockSaleReceiptReport.setTare(warehouseInOutInfo.getTare());
|
|
|
stockSaleReceiptReport.setNetWeight(warehouseInOutInfo.getNetWeight());
|
|
|
- if("出库任务".equals(warehouseInOutInfo.getTaskType())){
|
|
|
+ if ("出库任务".equals(warehouseInOutInfo.getTaskType())) {
|
|
|
stockSaleReceiptReport.setDeliveryDate(warehouseInOutInfo.getInOutDate());
|
|
|
stockSaleReceiptReport.setSettlementWeight(warehouseInOutInfo.getNetWeight());
|
|
|
stockSaleReceiptReport.setAmountIngReceivable(warehouseInOutInfo.getUnitPrice() * stockSaleReceiptReport.getSettlementWeight());
|
|
|
- }else if ("退库并出库".equals(warehouseInOutInfo.getTaskType())){
|
|
|
- stockSaleReceiptReport.setReturnDate(warehouseInOutInfo.getInOutDate());
|
|
|
- stockSaleReceiptReport.setSettlementWeight(-warehouseInOutInfo.getNetWeight());
|
|
|
- stockSaleReceiptReport.setAmountIngReceivable(0.0f);
|
|
|
- stockSaleReceiptReport.setReturnFlag("1");
|
|
|
+ } else if ("退库并出库".equals(warehouseInOutInfo.getTaskType())) {
|
|
|
+ if ("1".equals(warehouseInOutInfo.getTaskTypeKey())) {
|
|
|
+ stockSaleReceiptReport.setDeliveryDate(warehouseInOutInfo.getInOutDate());
|
|
|
+ stockSaleReceiptReport.setSettlementWeight(warehouseInOutInfo.getNetWeight());
|
|
|
+ stockSaleReceiptReport.setAmountIngReceivable(warehouseInOutInfo.getUnitPrice() * stockSaleReceiptReport.getSettlementWeight());
|
|
|
+ } else if ("4".equals(warehouseInOutInfo.getTaskTypeKey())) {
|
|
|
+ stockSaleReceiptReport.setReturnDate(warehouseInOutInfo.getInOutDate());
|
|
|
+ stockSaleReceiptReport.setSettlementWeight(-warehouseInOutInfo.getNetWeight());
|
|
|
+ stockSaleReceiptReport.setAmountIngReceivable(0.0f);
|
|
|
+ stockSaleReceiptReport.setReturnFlag("1");
|
|
|
+ }
|
|
|
}
|
|
|
stockSaleReceiptReportService.insert(stockSaleReceiptReport);
|
|
|
boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(stockSaleReceiptReport.getWorkflowId());
|
|
@@ -1294,7 +1508,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
|
|
|
WarehouseInOutInfo warehouseInOutInfo = this.selectById(id);
|
|
|
//详情信息
|
|
|
WarehouseInOutDetail warehouseInOutDetail = warehouseInOutDetailService.selectOne(new EntityWrapper<WarehouseInOutDetail>().eq(WarehouseInOutDetail.QueryFiles.INFO_ID, id));
|
|
|
- if (warehouseInOutDetail!=null){
|
|
|
+ if (warehouseInOutDetail != null) {
|
|
|
warehouseInOutInfo.setWarehouseInOutDetail(warehouseInOutDetail);
|
|
|
}
|
|
|
return warehouseInOutInfo;
|