|
@@ -227,9 +227,13 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
fabricLoss1 = JSON.parseObject(JSON.toJSONString(syLossReport1.getContent()), FabricLoss.class);
|
|
|
syCostAllocation.setFabriccostIncludestax(new BigDecimal(fabricLoss1.getActualMoney()));
|
|
|
syCostAllocation.setFabriccostNotincludestax(syCostAllocation.getFabriccostIncludestax().divide(new BigDecimal(1.13),2,BigDecimal.ROUND_HALF_UP));
|
|
|
+// System.out.println("面辅料人名币含税成本\t"+syCostAllocation.getFabriccostIncludestax());
|
|
|
+// System.out.println("面辅料人名币不含税成本\t"+syCostAllocation.getFabriccostNotincludestax());
|
|
|
//美元面料含税成本和不含税成本
|
|
|
syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostIncludestax().divide(syCostAllocation.getExchangeRate(),2,BigDecimal.ROUND_HALF_UP));
|
|
|
syCostAllocation.setFabriccostNotincludestaxUsd(syCostAllocation.getFabriccostIncludestaxUsd().divide(new BigDecimal(1.13),2,BigDecimal.ROUND_HALF_UP));
|
|
|
+// System.out.println("面辅料美元含税成本\t"+syCostAllocation.getFabriccostIncludestaxUsd());
|
|
|
+// System.out.println("面辅料美元不含税成本\t"+syCostAllocation.getFabriccostNotincludestaxUsd());
|
|
|
}
|
|
|
|
|
|
/*如果出现多供应商的情况拼接 供应商*/
|
|
@@ -264,22 +268,19 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
-- 4.根据第三步的采购订单用计划号not like ,找出所有不是本次采购的采购订单
|
|
|
2.余下:从采购起手,找到所有的采购入库,然后关联材料出库,排除掉自己使用的 就是余下的
|
|
|
* */
|
|
|
- //若余下数量不为0则给转入数据对象赋值
|
|
|
- if(oConvertUtils.isEmpty(Fabric.getFabricremainingQuantity())){
|
|
|
- Fabric.setFabricremainingQuantity(BigDecimal.ZERO);
|
|
|
+ //若转入数量不为0则给转入数据对象赋值
|
|
|
+ if(oConvertUtils.isEmpty(Fabric.getFabrictransferQuantity())){
|
|
|
+ Fabric.setFabrictransferQuantity(BigDecimal.ZERO);
|
|
|
}
|
|
|
- if(Fabric.getFabricremainingQuantity().compareTo(BigDecimal.ZERO) != 0 ){
|
|
|
- List<SyRemaining> syRemaining = syCostAllocationFabricMapper.queryRemainingByFabric(plannum,Fabric.getGoodsName());
|
|
|
+ if(0!=Fabric.getFabrictransferQuantity().compareTo(BigDecimal.ZERO)){
|
|
|
+ List<SyTransfer> transferlist = syCostAllocationFabricMapper.queryTransferByFabric(plannum,Fabric.getGoodsName());
|
|
|
BigDecimal cost = new BigDecimal(BigInteger.ZERO);
|
|
|
- for (SyRemaining syRemain:syRemaining) {
|
|
|
- System.out.println("Fabric.fabricremainingQuantity\t"+Fabric.getFabricremainingQuantity());
|
|
|
- System.out.println("syRemain.number\t"+syRemain.getNumber());
|
|
|
- System.out.println("syRemainList\n"+syRemain);
|
|
|
-// syRemain.setNumber(Fabric.getFabricremainingQuantity().toString());
|
|
|
+ BigDecimal quantity = new BigDecimal(BigInteger.ZERO);
|
|
|
+ for (SyTransfer syTransfer:transferlist) {
|
|
|
//查询单证面损数据
|
|
|
SyFabricLossReport syFabricLossReport = null;
|
|
|
QueryWrapper<SyFabricLossReport> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("plan_code", syRemain.getPlanCode());
|
|
|
+ queryWrapper.eq("plan_code", syTransfer.getPlanCode());
|
|
|
List<SyFabricLossReport> syFabricLossReportList = syFabricLossReportService.list(queryWrapper);
|
|
|
if (syFabricLossReportList.size()>0){
|
|
|
syFabricLossReport = syFabricLossReportList.get(0);
|
|
@@ -289,30 +290,46 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
if (syFabricLossReport != null){
|
|
|
fabricLoss = JSON.parseObject(JSON.toJSONString(syFabricLossReport.getContent()), FabricLoss.class);
|
|
|
for (FabricOMOrder fabricOMOrder:fabricLoss.getFabricOMOrderList2()) {
|
|
|
- if(fabricOMOrder.getCInvName().equals(syRemain.getGoodsName())){
|
|
|
+ if(fabricOMOrder.getCInvName().equals(syTransfer.getGoodsName())){
|
|
|
Double unitCost=fabricOMOrder.getFabricMoOrderRKList().stream().mapToDouble(FabricMoOrderRK::getIPrice).average().orElse(0d);
|
|
|
- syRemain.setUnitCost(new BigDecimal(unitCost));
|
|
|
- syRemain.setCost(syRemain.getUnitCost().multiply(new BigDecimal(syRemain.getNumber())));
|
|
|
- cost=cost.add(syRemain.getCost());
|
|
|
+ syTransfer.setUnitCost(new BigDecimal(unitCost).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ syTransfer.getUnitCost();
|
|
|
+ BigDecimal unitCost1=syTransfer.getUnitCost();
|
|
|
+ BigDecimal number2=new BigDecimal(syTransfer.getNumber()).setScale(4, RoundingMode.HALF_UP);
|
|
|
+ syTransfer.setCost(unitCost1.multiply(number2).setScale(2, RoundingMode.HALF_UP));
|
|
|
+// System.out.println("GoodsName\t"+syTransfer.getGoodsName()+"UnitCost\t"+syTransfer.getUnitCost());
|
|
|
+// syTransfer.setCost(syTransfer.getUnitCost().multiply(new BigDecimal(syTransfer.getNumber())));
|
|
|
+ cost=cost.add(syTransfer.getCost());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ quantity=quantity.add(new BigDecimal(syTransfer.getNumber()));
|
|
|
}
|
|
|
- Fabric.setRemainingQuantitycost(cost);
|
|
|
- Fabric.setSyRemaining(syRemaining);
|
|
|
+ Fabric.setSyTransfers(transferlist);
|
|
|
+ Fabric.setFabrictransferQuantity(quantity);
|
|
|
+ Fabric.setTransferCost(cost);
|
|
|
}
|
|
|
- //若转入数量不为0则给转入数据对象赋值
|
|
|
- if(oConvertUtils.isEmpty(Fabric.getFabrictransferQuantity())){
|
|
|
- Fabric.setFabrictransferQuantity(BigDecimal.ZERO);
|
|
|
+
|
|
|
+ //若余下数量不为0则给转入数据对象赋值
|
|
|
+ if(oConvertUtils.isEmpty(Fabric.getFabricremainingQuantity())){
|
|
|
+ Fabric.setFabricremainingQuantity(BigDecimal.ZERO);
|
|
|
+ }else if (Fabric.getFabrictransferQuantity().doubleValue()>0){
|
|
|
+ Fabric.setFabricremainingQuantity(Fabric.getPurchaseQuantity().add(Fabric.getFabrictransferQuantity()).subtract(Fabric.getUsageQuantity()));
|
|
|
}
|
|
|
- if(0!=Fabric.getFabrictransferQuantity().compareTo(BigDecimal.ZERO)){
|
|
|
- List<SyTransfer> transferlist = syCostAllocationFabricMapper.queryTransferByFabric(plannum,Fabric.getGoodsName());
|
|
|
+ Fabric.setRemainingQuantitycost(new BigDecimal("0"));
|
|
|
+ if(Fabric.getFabricremainingQuantity().compareTo(BigDecimal.ZERO) != 0 ){
|
|
|
+ List<SyRemaining> syRemaining = syCostAllocationFabricMapper.queryRemainingByFabric(plannum,Fabric.getGoodsName());
|
|
|
BigDecimal cost = new BigDecimal(BigInteger.ZERO);
|
|
|
- for (SyTransfer syTransfer:transferlist) {
|
|
|
+ for (SyRemaining syRemain:syRemaining) {
|
|
|
+// System.out.println("Fabric.fabricremainingQuantity\t"+Fabric.getFabricremainingQuantity());
|
|
|
+// System.out.println("syRemain.number\t"+syRemain.getNumber());
|
|
|
+// System.out.println("syRemainList\n"+syRemain);
|
|
|
+// syRemain.setNumber(Fabric.getFabricremainingQuantity().toString());
|
|
|
//查询单证面损数据
|
|
|
SyFabricLossReport syFabricLossReport = null;
|
|
|
QueryWrapper<SyFabricLossReport> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("plan_code", syTransfer.getPlanCode());
|
|
|
+// queryWrapper.eq("plan_code", syRemain.getPlanCode());
|
|
|
+ queryWrapper.eq("plan_code", plannum);
|
|
|
List<SyFabricLossReport> syFabricLossReportList = syFabricLossReportService.list(queryWrapper);
|
|
|
if (syFabricLossReportList.size()>0){
|
|
|
syFabricLossReport = syFabricLossReportList.get(0);
|
|
@@ -322,22 +339,42 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
if (syFabricLossReport != null){
|
|
|
fabricLoss = JSON.parseObject(JSON.toJSONString(syFabricLossReport.getContent()), FabricLoss.class);
|
|
|
for (FabricOMOrder fabricOMOrder:fabricLoss.getFabricOMOrderList2()) {
|
|
|
- if(fabricOMOrder.getCInvName().equals(syTransfer.getGoodsName())){
|
|
|
+// System.out.println("fabricOMOrder.cColor\t"+fabricOMOrder.getCColor()+"\tsyRemain.color\t"+syRemain.getColor());
|
|
|
+ if(fabricOMOrder.getCInvName().equals(syRemain.getGoodsName())&&
|
|
|
+ fabricOMOrder.getCColor()!=null&&syRemain.getColor()!=null&&
|
|
|
+ fabricOMOrder.getCColor().equals(syRemain.getColor())){
|
|
|
Double unitCost=fabricOMOrder.getFabricMoOrderRKList().stream().mapToDouble(FabricMoOrderRK::getIPrice).average().orElse(0d);
|
|
|
- syTransfer.setUnitCost(new BigDecimal(unitCost).setScale(2, RoundingMode.HALF_UP));
|
|
|
- syTransfer.getUnitCost();
|
|
|
- BigDecimal unitCost1=syTransfer.getUnitCost();
|
|
|
- BigDecimal number2=new BigDecimal(syTransfer.getNumber()).setScale(4, RoundingMode.HALF_UP);
|
|
|
- syTransfer.setCost(unitCost1.multiply(number2).setScale(2, RoundingMode.HALF_UP));
|
|
|
-// System.out.println("GoodsName\t"+syTransfer.getGoodsName()+"UnitCost\t"+syTransfer.getUnitCost());
|
|
|
-// syTransfer.setCost(syTransfer.getUnitCost().multiply(new BigDecimal(syTransfer.getNumber())));
|
|
|
- cost=cost.add(syTransfer.getCost());
|
|
|
+ syRemain.setUnitCost(new BigDecimal(unitCost));
|
|
|
+ syRemain.setCost(syRemain.getUnitCost().multiply(new BigDecimal(syRemain.getNumber())));
|
|
|
+// cost=cost.add(syRemain.getCost()).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ cost=cost.add(syRemain.getCost());
|
|
|
+// System.out.println("数量\t"+syRemain.getNumber()+"\t成本\t"+syRemain.getUnitCost()+"\t余下数量的成本\t"+cost);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Fabric.setSyTransfers(transferlist);
|
|
|
- Fabric.setTransferCost(cost);
|
|
|
+ Fabric.setRemainingQuantitycost(cost);
|
|
|
+ BigDecimal costUsd=cost.divide(syCostAllocation.getExchangeRate(),4,BigDecimal.ROUND_HALF_UP);
|
|
|
+ System.out.println("\t含税合计人民币总价\t"+syCostAllocation.getFabriccostIncludestax()+"\t需要减去的人民币\t"+cost);
|
|
|
+// System.out.println("\t不含税合计人民币总价\t"+syCostAllocation.getFabriccostNotincludestax()+"\t需要减去的人民币\t"+cost);
|
|
|
+// System.out.println("\t含税合计美元总价\t"+syCostAllocation.getFabriccostIncludestaxUsd()+"\t需要减去的美元\t"+costUsd);
|
|
|
+// System.out.println("\t不含税合计美元总价\t"+syCostAllocation.getFabriccostNotincludestaxUsd()+"\t需要减去的美元\t"+costUsd);
|
|
|
+// System.out.println("面辅料人名币含税成本\t"+syCostAllocation.getFabriccostIncludestax());
|
|
|
+// System.out.println("面辅料人名币不含税成本\t"+syCostAllocation.getFabriccostNotincludestax());
|
|
|
+ if(syCostAllocation!=null&&syCostAllocation.getFabriccostIncludestax()!=null){
|
|
|
+// syCostAllocation.setFabriccostIncludestax(syCostAllocation.getFabriccostIncludestax().subtract(cost).setScale(2, RoundingMode.HALF_UP));
|
|
|
+// syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostIncludestaxUsd().subtract(costUsd).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+
|
|
|
+// syCostAllocation.setFabriccostNotincludestax(syCostAllocation.getFabriccostNotincludestax().subtract(cost));
|
|
|
+// System.out.println("\t不含税合计人民币总价\t"+syCostAllocation.getFabriccostNotincludestax());
|
|
|
+// System.out.println("面辅料美元含税成本\t"+syCostAllocation.getFabriccostIncludestaxUsd());
|
|
|
+// System.out.println("面辅料美元不含税成本\t"+syCostAllocation.getFabriccostNotincludestaxUsd());
|
|
|
+// syCostAllocation.setFabriccostNotincludestaxUsd(syCostAllocation.getFabriccostNotincludestaxUsd().subtract(costUsd));
|
|
|
+//// System.out.println("余下数量的总成本\t"+Fabric.getRemainingQuantitycost());
|
|
|
+// System.out.println("面辅料美元含税成本\t"+syCostAllocation.getFabriccostIncludestaxUsd());
|
|
|
+// System.out.println("面辅料美元不含税成本\t"+syCostAllocation.getFabriccostNotincludestaxUsd());
|
|
|
+ Fabric.setSyRemaining(syRemaining);
|
|
|
}
|
|
|
|
|
|
//多发少发链接结合赋值
|
|
@@ -579,7 +616,11 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
|
|
|
//清空单号 不让它显示在查询框上
|
|
|
syCostAllocation.setPlanNum(plannum);
|
|
|
-
|
|
|
+ if (syCostAllocation.getShortvalue()!=null&&syCostAllocation.getShortvalue().intValue()>0){
|
|
|
+ BigDecimal shortvalue=(syCostAllocation.getSalesrrdersOriginaltotal().subtract(syCostAllocation.getUsdTotalexportprice())).multiply(syCostAllocation.getExchangeRate());
|
|
|
+ System.out.println("shortvalue\t"+shortvalue);
|
|
|
+ syCostAllocation.setShortvalue(shortvalue);
|
|
|
+ }
|
|
|
return syCostAllocation;
|
|
|
}
|
|
|
|