|
@@ -430,13 +430,19 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
fabricCostInvoice.setCVCName("转入成本");
|
|
|
fabricCostInvoice.setIMoney(d);
|
|
|
fabricCostInvoiceList.add(fabricCostInvoice);
|
|
|
+ // 计算入金额
|
|
|
+ Double costInTotal = fabricCostInvoiceList.stream().mapToDouble(FabricCostInvoice::getIMoney).sum();
|
|
|
// 转出成本
|
|
|
- d = oConvertUtils.getDouble(fabricLossMapper.getOmInToOtherMoney(code), 0);
|
|
|
+ d = oConvertUtils.getDouble(fabricLossMapper.getOmInToOtherMoney(code), 0) + getOutCost(ret.getFabricPoOrderList(), fabricOMOrderList1);
|
|
|
fabricCostInvoice = new FabricCostInvoice();
|
|
|
fabricCostInvoice.setCVCName("转出成本");
|
|
|
fabricCostInvoice.setIMoney(d);
|
|
|
fabricCostInvoiceList.add(fabricCostInvoice);
|
|
|
ret.setFabricCostInvoiceList(fabricCostInvoiceList);
|
|
|
+ // 计算实际单件成本
|
|
|
+ costInTotal -= d;
|
|
|
+ BigDecimal bdPriceReal = new BigDecimal(costInTotal/ret.getNumber());
|
|
|
+ ret.setActualPrice(bdPriceReal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
//开票成本 - 成衣
|
|
|
List<FabricCostClothes> fabricCostClothesList = fabricLossMapper.getCostClothesList(code);
|
|
|
ret.setFabricCostClothesList(fabricCostClothesList);
|
|
@@ -924,6 +930,88 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据采购入库详情,委外订单详情,获取转出成本。(入库数量-出库数量) * 单价
|
|
|
+ * @param poOrderList - 采购入库详情
|
|
|
+ * @param fabricOMOrderList - 委外出入库详情
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Double getOutCost(List<FabricPoOrder> poOrderList, List<FabricOMOrder> fabricOMOrderList){
|
|
|
+ // 采购出入库去掉末尾两行:来源余纱、其他入库纱
|
|
|
+ List<FabricPoOrder> poOrderListReal = new ArrayList<>();
|
|
|
+ if (poOrderList.size()>2){
|
|
|
+ poOrderListReal.addAll(poOrderList);
|
|
|
+ poOrderListReal.remove(poOrderListReal.size()-1);
|
|
|
+ poOrderListReal.remove(poOrderListReal.size()-1);
|
|
|
+ }
|
|
|
+ // 合并所有采购入库+委外入库的物料批次。借用FabricPoOrderIn类
|
|
|
+ List<FabricPoOrderIn> allInList = new ArrayList<>();
|
|
|
+ for (FabricPoOrder item : poOrderListReal){
|
|
|
+ List<FabricPoOrderIn> inList = item.getFabricPoOrderInList();
|
|
|
+ if (oConvertUtils.listIsNotEmpty(inList)){
|
|
|
+ for (FabricPoOrderIn itemIn : inList){
|
|
|
+ Optional<FabricPoOrderIn> findItemOpt = allInList.stream().filter(e->
|
|
|
+ e.getCInvCode().equals(itemIn.getCInvCode()) &&
|
|
|
+ e.getCColor().equals(itemIn.getCColor()) &&
|
|
|
+ e.getCBatch().equals(itemIn.getCBatch())).findFirst();
|
|
|
+ if (findItemOpt.isPresent()){
|
|
|
+ FabricPoOrderIn formatItem = findItemOpt.get();
|
|
|
+ Double dMoney = formatItem.getIPrice()*formatItem.getIQuantity()+itemIn.getIPrice()*itemIn.getIQuantity();
|
|
|
+ Double dQuantity = formatItem.getIQuantity()+itemIn.getIQuantity();
|
|
|
+ formatItem.setIPrice(dMoney/dQuantity);
|
|
|
+ formatItem.setIQuantity(dQuantity);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ FabricPoOrderIn formatItem = new FabricPoOrderIn();
|
|
|
+ formatItem.setCInvCode(itemIn.getCInvCode());
|
|
|
+ formatItem.setCColor(itemIn.getCColor());
|
|
|
+ formatItem.setCBatch(itemIn.getCBatch());
|
|
|
+ formatItem.setIQuantity(itemIn.getIQuantity());
|
|
|
+ formatItem.setIPrice(itemIn.getIPrice());
|
|
|
+ allInList.add(formatItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ for (FabricOMOrder item : fabricOMOrderList){
|
|
|
+ List<FabricMoOrderRK> inList = item.getFabricMoOrderRKList();
|
|
|
+ if (oConvertUtils.listIsNotEmpty(inList)){
|
|
|
+ for (FabricMoOrderRK itemIn : inList){
|
|
|
+ FabricPoOrderIn formatItem = new FabricPoOrderIn();
|
|
|
+ formatItem.setCInvCode(item.getCInvCode());
|
|
|
+ formatItem.setCColor(item.getCColor());
|
|
|
+ formatItem.setCBatch(itemIn.getCBatch());
|
|
|
+ formatItem.setIQuantity(itemIn.getIQuantityIn());
|
|
|
+ formatItem.setIPrice(itemIn.getIPrice());
|
|
|
+ allInList.add(formatItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ // 扣减出库数量
|
|
|
+ for (FabricPoOrderIn itemIn : allInList){
|
|
|
+ for (FabricOMOrder item : fabricOMOrderList){
|
|
|
+ List<FabricMoOrderCK> outList = item.getFabricMoOrderCKList();
|
|
|
+ if (oConvertUtils.listIsNotEmpty(outList)){
|
|
|
+ Double dOut = outList.stream().filter(e->
|
|
|
+ e.getCInvCodeOut().equals(itemIn.getCInvCode()) &&
|
|
|
+ e.getCColorOut().equals(itemIn.getCColor()) &&
|
|
|
+ e.getCBatchOut().equals(itemIn.getCBatch())).mapToDouble(FabricMoOrderCK::getIQuantity).sum();
|
|
|
+ itemIn.setIQuantity(itemIn.getIQuantity()-dOut);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 计算总转出成本
|
|
|
+ Double dTotal = 0.0;
|
|
|
+ for (FabricPoOrderIn itemIn : allInList){
|
|
|
+ if (itemIn.getIQuantity()>0){
|
|
|
+ dTotal += itemIn.getIQuantity()*itemIn.getIPrice();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BigDecimal bdVal = new BigDecimal(dTotal);
|
|
|
+ return bdVal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+
|
|
|
+ }
|
|
|
// 根据文件id,获取文件内容
|
|
|
@Override
|
|
|
public byte[] getFileContent(String fileId){
|