|
@@ -30,6 +30,7 @@ import com.yh.saas.plugin.yiliangyiyun.entity.view.PaymentView;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.PaymentManagementMapper;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.mapper.WarehousingOrderMapper;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.service.*;
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.util.QRCodeUtil;
|
|
@@ -92,12 +93,16 @@ public class PaymentManagementServiceImpl extends ServiceImpl<PaymentManagementM
|
|
|
@Autowired
|
|
|
private IContractManagementInfoService ContractManagementInfoService;
|
|
|
@Autowired
|
|
|
- private IInOutWarehouseTaskService inOutWarehouseTaskService;
|
|
|
- @Autowired
|
|
|
private IWarehouseInOutInfoService warehouseInOutInfoService;
|
|
|
@Autowired
|
|
|
private IWarehousingOrderService warehousingOrderService;
|
|
|
@Autowired
|
|
|
+ private IExpenseAllocationInfoService expenseAllocationInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IEnabledInfoService enabledInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IContractInventoryDistributionService contractInventoryDistributionService;
|
|
|
+ @Autowired
|
|
|
private IWarehouseInOutDetailService warehouseInOutDetailService;
|
|
|
@Autowired
|
|
|
private IWarehouseBaseInfoService warehouseBaseInfoService;
|
|
@@ -117,6 +122,8 @@ public class PaymentManagementServiceImpl extends ServiceImpl<PaymentManagementM
|
|
|
private IPurchasePriceDetailService purchasePriceDetailService;
|
|
|
@Autowired
|
|
|
private IPurchasePriceService purchasePriceService;
|
|
|
+ @Autowired
|
|
|
+ private WarehousingOrderMapper warehousingOrderMapper;
|
|
|
@Value("${file-root-path}")
|
|
|
private String localPath;
|
|
|
@Autowired
|
|
@@ -779,6 +786,143 @@ public class PaymentManagementServiceImpl extends ServiceImpl<PaymentManagementM
|
|
|
return "OK";
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String generateOrder(PaymentManagement paymentManagement) {
|
|
|
+ SimpleDateFormat now = new SimpleDateFormat("yyyy-MM-dd 23:55:00");
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTime(new Date());
|
|
|
+ c.add(Calendar.DATE, -1);
|
|
|
+ String beforeDay = now.format(c.getTime());
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
+ pageView.put("beforeDay", beforeDay);
|
|
|
+ pageView.put("warehouseName", "丹东港");
|
|
|
+ //收购
|
|
|
+ List<WarehousingOrder> dataList = warehousingOrderMapper.getAcquisitionListByCondition(pageView);
|
|
|
+ if (!CollectionUtils.isEmpty(dataList)) {
|
|
|
+ for (WarehousingOrder warehousingOrder1 : dataList) {
|
|
|
+ List<PaymentManagement> paymentManagementList = this.selectList(new EntityWrapper<PaymentManagement>()
|
|
|
+ .eq("customer_name", warehousingOrder1.getGoodsSource())
|
|
|
+ .eq("contract_no", warehousingOrder1.getContractNo())
|
|
|
+ .eq("goods_name", warehousingOrder1.getGoodsName())
|
|
|
+ .eq("customer_number_card", warehousingOrder1.getCustomerNumberCard())
|
|
|
+ .ne("status", "待结算")
|
|
|
+ .isNull("order_id")
|
|
|
+ .ge("settlement_date", beforeDay));
|
|
|
+ //生成过的不再生成
|
|
|
+ if (CollectionUtils.isEmpty(paymentManagementList)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ WarehousingOrder warehousingOrder = new WarehousingOrder();
|
|
|
+ warehousingOrder.setId(IdGenerator.generateUUID());
|
|
|
+ Double totalMoisture=0d;
|
|
|
+ for (PaymentManagement paymentManagement1 : paymentManagementList) {
|
|
|
+ QualityInspectionManagement qualityInspectionManagement=qualityInspectionManagementService.selectOne(new EntityWrapper<QualityInspectionManagement>()
|
|
|
+ .eq("relation_id",paymentManagement1.getRelationId()));
|
|
|
+ if (qualityInspectionManagement!=null) {
|
|
|
+ if (qualityInspectionManagement.getWaterContent()!=null) {
|
|
|
+ totalMoisture = totalMoisture + Double.valueOf(qualityInspectionManagement.getWaterContent())
|
|
|
+ * Double.valueOf(String.valueOf(paymentManagement1.getNetWeight() / 1000));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ paymentManagement1.setOrderId(warehousingOrder.getId());
|
|
|
+ this.updateById(paymentManagement1);
|
|
|
+ }
|
|
|
+ warehousingOrder.setBaseId(warehousingOrder1.getBaseId());
|
|
|
+ warehousingOrder.setContractNo(warehousingOrder1.getContractNo());
|
|
|
+ warehousingOrder.setIdentifyId(warehousingOrder1.getIdentifyId());
|
|
|
+ warehousingOrder.setWarehouseName(warehousingOrder1.getWarehouseName());
|
|
|
+ warehousingOrder.setGoodsSource(warehousingOrder1.getGoodsSource());
|
|
|
+ warehousingOrder.setCustomer(warehousingOrder1.getGoodsSource());
|
|
|
+ warehousingOrder.setCompId(warehousingOrder1.getCompId());
|
|
|
+ warehousingOrder.setGoodsName(warehousingOrder1.getGoodsName());
|
|
|
+ warehousingOrder.setInType("收购入库");
|
|
|
+ double weight = (paymentManagementList.stream().mapToDouble(PaymentManagement::getNetWeight).sum()) / 1000;
|
|
|
+ if (totalMoisture!=0) {
|
|
|
+ warehousingOrder.setWeightedMoisture(totalMoisture / weight);
|
|
|
+ }
|
|
|
+ warehousingOrder.setInWarehouseWeight(weight);
|
|
|
+ warehousingOrder.setSurplusWeight(weight);
|
|
|
+ double money = paymentManagementList.stream().mapToDouble(PaymentManagement::getAmountIngPayable).sum();
|
|
|
+ //合营加价
|
|
|
+ if (warehousingOrder1.getJointVentureMarkup() != null) {
|
|
|
+ warehousingOrder.setAvgCost(money / weight + warehousingOrder1.getJointVentureMarkup());
|
|
|
+ } else {
|
|
|
+ //收购成本=总应付/总重量
|
|
|
+ warehousingOrder.setAvgCost(money / weight);
|
|
|
+ if (weight == 0) {
|
|
|
+ warehousingOrder.setAvgCost(0d);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ warehousingOrder.setAmountNotPayable(money);
|
|
|
+ warehousingOrder.setAmountEdPayable(0d);
|
|
|
+ warehousingOrder.setIssuingTime(new Date());
|
|
|
+ warehousingOrder.setGrainFund(money);
|
|
|
+ warehousingOrderService.insert(warehousingOrder);
|
|
|
+ //更新库点库存 (所在仓库所属仓库货名一致)
|
|
|
+ ContractInventoryDistribution contractInventoryDistribution = contractInventoryDistributionService.selectOne(new EntityWrapper<ContractInventoryDistribution>()
|
|
|
+ .eq("comp_id", warehousingOrder1.getCompId()).eq("inventory_type", "3").eq("locus_warehouse", warehousingOrder1.getWarehouseName())
|
|
|
+ .eq("warehouse", warehousingOrder1.getWarehouseName())
|
|
|
+ .eq("goods_name", warehousingOrder1.getGoodsName()));
|
|
|
+ if (contractInventoryDistribution != null) {
|
|
|
+ contractInventoryDistribution.setInventory(contractInventoryDistribution.getInventory() + weight);
|
|
|
+ contractInventoryDistributionService.updateById(contractInventoryDistribution);
|
|
|
+ } else {
|
|
|
+ ContractInventoryDistribution contractInventoryDistribution1 = new ContractInventoryDistribution();
|
|
|
+ contractInventoryDistribution1.setId(IdGenerator.generateUUID());
|
|
|
+ contractInventoryDistribution1.setCompId(warehousingOrder1.getCompId());
|
|
|
+ contractInventoryDistribution1.setWarehouseId(warehousingOrder1.getBaseId());
|
|
|
+ contractInventoryDistribution1.setInventory(weight);
|
|
|
+ contractInventoryDistribution1.setWarehouse(warehousingOrder1.getWarehouseName());
|
|
|
+ contractInventoryDistribution1.setLocusWarehouse(warehousingOrder1.getWarehouseName());
|
|
|
+ contractInventoryDistribution1.setGoodsName(warehousingOrder1.getGoodsName());
|
|
|
+ contractInventoryDistribution1.setInventoryType("3");
|
|
|
+ contractInventoryDistributionService.insert(contractInventoryDistribution1);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //利率对成本的影响
|
|
|
+ //查入库单利率
|
|
|
+ List<EnabledInfo> enabledInfoList = enabledInfoService.selectList(new EntityWrapper<EnabledInfo>()
|
|
|
+ .eq("function_type", "2"));
|
|
|
+ if (!CollectionUtils.isEmpty(enabledInfoList)) {
|
|
|
+ for (EnabledInfo enabledInfo : enabledInfoList) {
|
|
|
+ //查剩余重量>0的入库单
|
|
|
+ List<WarehousingOrder> warehousingOrderList = warehousingOrderService.selectList(new EntityWrapper<WarehousingOrder>()
|
|
|
+ .eq("comp_id", enabledInfo.getCompId())
|
|
|
+ .eq("warehouse_name","丹东港")
|
|
|
+ .gt("create_date", beforeDay)
|
|
|
+ .gt("surplus_weight", 0));
|
|
|
+ if (!CollectionUtils.isEmpty(warehousingOrderList)) {
|
|
|
+ for (WarehousingOrder warehousingOrder : warehousingOrderList) {
|
|
|
+ Double distributionMoney = 0d;
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfoList1 = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
+ .eq("order_id", warehousingOrder.getId())
|
|
|
+ .ne("status", "已驳回"));
|
|
|
+ if (!CollectionUtils.isEmpty(expenseAllocationInfoList1)) {
|
|
|
+ distributionMoney = expenseAllocationInfoList1.stream().mapToDouble(ExpenseAllocationInfo::getDistributionMoney).sum();
|
|
|
+ }
|
|
|
+ distributionMoney=distributionMoney+warehousingOrder.getInterest()+warehousingOrder.getStorageFee();
|
|
|
+ if (distributionMoney / warehousingOrder.getInWarehouseWeight() < 100) {
|
|
|
+ if (warehousingOrder.getSurplusWeight() > 1) {
|
|
|
+ warehousingOrder.setInterest(warehousingOrder.getInterest()+(warehousingOrder.getAvgCost() * enabledInfo.getValue() / 30)*warehousingOrder.getSurplusWeight());
|
|
|
+ warehousingOrder.setAvgCost(warehousingOrder.getAvgCost() + warehousingOrder.getAvgCost() * enabledInfo.getValue() / 30);
|
|
|
+ } else {
|
|
|
+ warehousingOrder.setInterest(warehousingOrder.getInterest()+(warehousingOrder.getAvgCost() * enabledInfo.getValue() * warehousingOrder.getSurplusWeight() / 30)*warehousingOrder.getSurplusWeight());
|
|
|
+ warehousingOrder.setAvgCost(warehousingOrder.getAvgCost() + warehousingOrder.getAvgCost() * enabledInfo.getValue() * warehousingOrder.getSurplusWeight() / 30);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ warehousingOrderService.updateById(warehousingOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 合同编号下拉列表
|
|
|
*
|