|
@@ -213,9 +213,11 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
|
|
|
//查询单证面损数据 面料(不)含税成本
|
|
|
SyFabricLossReport syLossReport1 = null;
|
|
|
+// System.out.println("面损plan_code\t"+plannum+"\t面损长度\t"+plannum.length());
|
|
|
QueryWrapper<SyFabricLossReport> queryLossWrapper = new QueryWrapper<>();
|
|
|
queryLossWrapper.eq("plan_code", plannum);
|
|
|
List<SyFabricLossReport> syLossReportList = syFabricLossReportService.list(queryLossWrapper);
|
|
|
+// System.out.println("面损syLossReportList\t"+syLossReportList.size());
|
|
|
if (syLossReportList.size()>0){
|
|
|
syLossReport1 = syLossReportList.get(0);
|
|
|
}
|
|
@@ -226,9 +228,11 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
fabricLoss1 = JSON.parseObject(JSON.toJSONString(syLossReport1.getContent()), FabricLoss.class);
|
|
|
|
|
|
BigDecimal fabariccostIncludestax=new BigDecimal("0");
|
|
|
- for (FabricCostInvoice fabricCostInvoice : fabricLoss1.getFabricCostInvoiceList()){
|
|
|
- if (fabricCostInvoice.getIMoney()!=null){
|
|
|
- fabariccostIncludestax=fabariccostIncludestax.add(new BigDecimal(fabricCostInvoice.getIMoney())).setScale(2, RoundingMode.HALF_UP) ;
|
|
|
+ if (fabricLoss1.getFabricCostInvoiceList()!=null){
|
|
|
+ for (FabricCostInvoice fabricCostInvoice : fabricLoss1.getFabricCostInvoiceList()){
|
|
|
+ if (fabricCostInvoice.getIMoney()!=null){
|
|
|
+ fabariccostIncludestax=fabariccostIncludestax.add(new BigDecimal(fabricCostInvoice.getIMoney())).setScale(2, RoundingMode.HALF_UP) ;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// syCostAllocation.setFabriccostIncludestax(new BigDecimal(fabricLoss1.getActualMoney()));// 实际总金额
|
|
@@ -259,9 +263,68 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
|
|
|
int planQuantity=syCostAllocation.getPlanQuantity().intValue();
|
|
|
|
|
|
+ long startTime2 = System.currentTimeMillis();
|
|
|
/*查询U8数据 面料*/
|
|
|
List<SyCostAllocationFabric> list3 = syCostAllocationFabricMapper.queryByCostFabric3(plannum,planQuantity);
|
|
|
|
|
|
+ //获取所有转入数据
|
|
|
+// List<SyTransfer> transferlists = syCostAllocationFabricMapper.queryTransferByFabric3(plannum);
|
|
|
+
|
|
|
+ //获取所有转入数据
|
|
|
+ List<SyTransfer> transferlists = syCostAllocationFabricMapper.queryTransferByFabric4(plannum);
|
|
|
+
|
|
|
+ Map<String,List<SyTransfer>> syTransferMaps=new HashMap<>();
|
|
|
+
|
|
|
+ long startTime1 = System.currentTimeMillis();
|
|
|
+ //获取所有余下数量
|
|
|
+ List<SyRemaining> syRemainings=syCostAllocationFabricMapper.queryRemainingByFabric4(plannum);
|
|
|
+
|
|
|
+ //面料余下数量
|
|
|
+ Map<String,List<SyRemaining>> syRemainingMaps=new HashMap<>();
|
|
|
+
|
|
|
+ //多发少发链接结合赋值
|
|
|
+ List<SyCostAllocationFabric> pilosityFeweLists = syCostAllocationFabricMapper.querypilosityFewer2(plannum);
|
|
|
+
|
|
|
+ System.out.println("多发少发链接结合赋值\t"+pilosityFeweLists);
|
|
|
+ Map<String,List<SyCostAllocationFabric>> syFabricMaps=new HashMap<>();
|
|
|
+
|
|
|
+ for (SyTransfer transfer : transferlists){
|
|
|
+ if (syTransferMaps.containsKey(transfer.getGoodsName())){
|
|
|
+ List<SyTransfer> transferlist=syTransferMaps.get(transfer.getGoodsName());
|
|
|
+ transferlist.add(transfer);
|
|
|
+ }else{
|
|
|
+ List<SyTransfer> transferlist=new ArrayList<>();
|
|
|
+ transferlist.add(transfer);
|
|
|
+ syTransferMaps.put(transfer.getGoodsName(),transferlist);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (SyRemaining syRemaining :syRemainings){
|
|
|
+ if (syRemainingMaps.containsKey(syRemaining.getGoodsName())){
|
|
|
+ List<SyRemaining> remaininglist=syRemainingMaps.get(syRemaining.getGoodsName());
|
|
|
+ remaininglist.add(syRemaining);
|
|
|
+ }else{
|
|
|
+ List<SyRemaining> remaininglist=new ArrayList<>();
|
|
|
+ remaininglist.add(syRemaining);
|
|
|
+ syRemainingMaps.put(syRemaining.getGoodsName(),remaininglist);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (SyCostAllocationFabric syCostAllocationFabric : pilosityFeweLists){
|
|
|
+ if (syFabricMaps.containsKey(syCostAllocationFabric.getGoodsName())){
|
|
|
+ List<SyCostAllocationFabric> syCostAllocationFabrics=syFabricMaps.get(syCostAllocationFabric.getGoodsName());
|
|
|
+ syCostAllocationFabrics.add(syCostAllocationFabric);
|
|
|
+ }else{
|
|
|
+ List<SyCostAllocationFabric> syCostAllocationFabrics=new ArrayList<>();
|
|
|
+ syCostAllocationFabrics.add(syCostAllocationFabric);
|
|
|
+ syFabricMaps.put(syCostAllocationFabric.getGoodsName(),syCostAllocationFabrics);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询单证面损数据
|
|
|
+ SyFabricLossReport syFabricLossReport = null;
|
|
|
+ QueryWrapper<SyFabricLossReport> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("plan_code", syCostAllocation.getPlanNum());
|
|
|
+ List<SyFabricLossReport> syFabricLossReportList = syFabricLossReportService.list(queryWrapper);
|
|
|
for (int i=0;i<list3.size();i++) {
|
|
|
|
|
|
SyCostAllocationFabric Fabric = list3.get(i);
|
|
@@ -283,19 +346,17 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
}
|
|
|
//转入数量、余下数量
|
|
|
if(0!=Fabric.getFabrictransferQuantity().compareTo(BigDecimal.ZERO) || 0!=Fabric.getFabricremainingQuantity().compareTo(BigDecimal.ZERO)){
|
|
|
- List<SyTransfer> transferlist = syCostAllocationFabricMapper.queryTransferByFabric(plannum,Fabric.getGoodsName());
|
|
|
+// List<SyTransfer> transferlist = syCostAllocationFabricMapper.queryTransferByFabric(plannum,Fabric.getGoodsName());
|
|
|
+ List<SyTransfer> transferlist = syTransferMaps.get(Fabric.getGoodsName());
|
|
|
+ if (transferlist==null || transferlist.size()==0){
|
|
|
+ transferlist=new ArrayList<>();
|
|
|
+ }
|
|
|
BigDecimal cost = new BigDecimal(BigInteger.ZERO);
|
|
|
BigDecimal quantity = new BigDecimal(BigInteger.ZERO);
|
|
|
for (SyTransfer syTransfer:transferlist) {
|
|
|
- //查询单证面损数据
|
|
|
- SyFabricLossReport syFabricLossReport = null;
|
|
|
- QueryWrapper<SyFabricLossReport> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("plan_code", syTransfer.getPlanCode());
|
|
|
- List<SyFabricLossReport> syFabricLossReportList = syFabricLossReportService.list(queryWrapper);
|
|
|
if (syFabricLossReportList.size()>0){
|
|
|
syFabricLossReport = syFabricLossReportList.get(0);
|
|
|
}
|
|
|
-
|
|
|
FabricLoss fabricLoss = null;
|
|
|
if (syFabricLossReport != null){
|
|
|
fabricLoss = JSON.parseObject(JSON.toJSONString(syFabricLossReport.getContent()), FabricLoss.class);
|
|
@@ -315,7 +376,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
quantity=quantity.add(new BigDecimal(syTransfer.getNumber()));
|
|
|
}
|
|
|
Fabric.setSyTransfers(transferlist);
|
|
|
- Fabric.setFabrictransferQuantity(quantity);
|
|
|
+// Fabric.setFabrictransferQuantity(quantity);//转入数量
|
|
|
Fabric.setTransferCost(cost);
|
|
|
}
|
|
|
|
|
@@ -327,22 +388,19 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
}
|
|
|
Fabric.setRemainingQuantitycost(new BigDecimal("0"));
|
|
|
if(Fabric.getFabricremainingQuantity().compareTo(BigDecimal.ZERO) != 0 ){
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
- List<SyRemaining> syRemaining = syCostAllocationFabricMapper.queryRemainingByFabric(plannum,Fabric.getGoodsName());
|
|
|
- long endTime2 = System.currentTimeMillis();
|
|
|
+// List<SyRemaining> syRemaining = syCostAllocationFabricMapper.queryRemainingByFabric(plannum,Fabric.getGoodsName());
|
|
|
+// if (syRemaining.size()==0){
|
|
|
+// syRemaining=syCostAllocationFabricMapper.queryRemainingByFabric3(plannum,Fabric.getGoodsName());
|
|
|
+// }
|
|
|
+ List<SyRemaining> syRemaining=syRemainingMaps.get(Fabric.getGoodsName());
|
|
|
BigDecimal cost = new BigDecimal(BigInteger.ZERO);
|
|
|
+ if (syRemaining==null || syRemaining.size()==0){
|
|
|
+ syRemaining=new ArrayList<>();
|
|
|
+ }
|
|
|
for (SyRemaining syRemain:syRemaining) {
|
|
|
-// syRemain.setNumber(Fabric.getFabricremainingQuantity().toString());
|
|
|
- //查询单证面损数据
|
|
|
- SyFabricLossReport syFabricLossReport = null;
|
|
|
- QueryWrapper<SyFabricLossReport> queryWrapper = new QueryWrapper<>();
|
|
|
-// 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);
|
|
|
}
|
|
|
-
|
|
|
FabricLoss fabricLoss = null;
|
|
|
if (syFabricLossReport != null){
|
|
|
fabricLoss = JSON.parseObject(JSON.toJSONString(syFabricLossReport.getContent()), FabricLoss.class);
|
|
@@ -365,24 +423,28 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
// syCostAllocation.setFabriccostIncludestax(syCostAllocation.getFabriccostIncludestax().subtract(cost).setScale(2, RoundingMode.HALF_UP));
|
|
|
// syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostIncludestaxUsd().subtract(costUsd).setScale(2, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
-
|
|
|
Fabric.setSyRemaining(syRemaining);
|
|
|
}
|
|
|
|
|
|
- //多发少发链接结合赋值
|
|
|
- List<SyCostAllocationFabric> pilosityFeweList = syCostAllocationFabricMapper.querypilosityFewer(plannum,Fabric.getGoodsName());
|
|
|
+ //多发少发链接结合赋值 syFabricMaps
|
|
|
+// List<SyCostAllocationFabric> pilosityFeweList = syCostAllocationFabricMapper.querypilosityFewer(plannum,Fabric.getGoodsName());
|
|
|
+ List<SyCostAllocationFabric> pilosityFeweList = syFabricMaps.get(Fabric.getGoodsName());
|
|
|
+ System.out.println("多发少发链接\t"+pilosityFeweList);
|
|
|
Fabric.setPilosityFewerList(pilosityFeweList);
|
|
|
|
|
|
- //多发少发 = 使用数量-计划数量
|
|
|
+ //多发少发 = 使用数量-计划数量------>购入数量-计划数量
|
|
|
if(oConvertUtils.isEmpty(Fabric.getUsageQuantity())){
|
|
|
Fabric.setUsageQuantity(BigDecimal.ZERO);
|
|
|
}
|
|
|
Fabric.setPilosityFewer(Fabric.getUsageQuantity().subtract(Fabric.getPlanQuantity()));
|
|
|
|
|
|
-
|
|
|
//单耗件= 计划数量/表头计划数量
|
|
|
Fabric.setUnitConsumption(Fabric.getPlanQuantity().divide(syCostAllocation.getPlanQuantity(),4,BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
+// 转入成本
|
|
|
+// Fabric.setTransferCost();
|
|
|
+// 余下数量的成本
|
|
|
+// Fabric.setRemainingQuantitycost();
|
|
|
}
|
|
|
|
|
|
//如果没有面损表信息,查询所有采购发票
|
|
@@ -419,13 +481,13 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
BigDecimal num2 = money2.multiply(li.getUsageQuantity());
|
|
|
includestaxTotal = includestaxTotal.add(num2);
|
|
|
//(发票金额/发票数量)*使用数量
|
|
|
- System.out.println("面料含税成本\t"+usageQuantityTotal+"\t面料不含税成本\t"+notincludestaxTotal+"\t发票数量\t"+str.getInvoiceQuantity()+"\t使用数量\t"+li.getUsageQuantity());
|
|
|
+// System.out.println("面料含税成本\t"+usageQuantityTotal+"\t面料不含税成本\t"+notincludestaxTotal+"\t发票数量\t"+str.getInvoiceQuantity()+"\t使用数量\t"+li.getUsageQuantity());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
syCostAllocation.setFabriccostIncludestax(usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
- System.out.println("实际总金额2\t"+usageQuantityTotal);
|
|
|
+// System.out.println("实际总金额2\t"+usageQuantityTotal);
|
|
|
syCostAllocation.setFabriccostNotincludestax(notincludestaxTotal);
|
|
|
syCostAllocation.setFabriccostIncludestaxUsd(includestaxTotal);
|
|
|
}else{
|
|
@@ -436,149 +498,178 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
|
|
|
}
|
|
|
|
|
|
- //查询U8数据 辅料数据关联临时表 syTransfers
|
|
|
+ long startTime3 = System.currentTimeMillis();
|
|
|
+ //查询U8数据 辅料数据关联临时表 syTransfers ingredientsTransferQuantity
|
|
|
List<SyCostAllocationIngredient> list4 = syCostAllocationIngredientMapper.queryByCostIngredient4(plannum,syCostAllocation.getExchangeRate());
|
|
|
- HashMap<String,List<SyCostAllocationIngredient>> stringListHashMap=new HashMap();//物料名称+物料编码
|
|
|
- HashMap<String,List<SyCostAllocationIngredient>> stringListHashMap2=new HashMap();//物料名称+物料编码+供应商
|
|
|
- List<SyCostAllocationIngredient> ingredients4=new ArrayList<>();//重新赋值
|
|
|
- HashMap<String,BigDecimal> stringBigDecimalHashMap=new HashMap();//获取转入数量 syf107
|
|
|
for (SyCostAllocationIngredient ingredient : list4){
|
|
|
- if (stringListHashMap.containsKey(ingredient.getGoodsName()+ingredient.getGoodsCode())){
|
|
|
- List<SyCostAllocationIngredient> ingredients=stringListHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode());
|
|
|
- ingredients.add(ingredient);
|
|
|
- BigDecimal transferQuantity=new BigDecimal("0");//转入数量
|
|
|
- for (SyCostAllocationIngredient ingredient1 : ingredients){
|
|
|
- transferQuantity=transferQuantity.add(ingredient1.getIngredientsTransferQuantity());//转入数量
|
|
|
- }
|
|
|
- BigDecimal usageQuantity=new BigDecimal("0");//使用数量
|
|
|
- BigDecimal purchaseQuantity=new BigDecimal("0");//购入数量
|
|
|
- for (SyCostAllocationIngredient ingredient1 : ingredients){
|
|
|
- if (usageQuantity.compareTo(ingredient1.getUsageQuantity())!=0){
|
|
|
- usageQuantity=usageQuantity.add(ingredient1.getUsageQuantity());//转入数量
|
|
|
- }
|
|
|
- purchaseQuantity=purchaseQuantity.add(ingredient1.getPurchaseQuantity());
|
|
|
- }
|
|
|
- stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"ingredientsTransferQuantity",transferQuantity);
|
|
|
- stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"usageQuantity",usageQuantity);
|
|
|
- stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"purchaseQuantity",purchaseQuantity);
|
|
|
- stringListHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode(),ingredients);
|
|
|
- }else{
|
|
|
- List<SyCostAllocationIngredient> ingredients=new ArrayList<>();
|
|
|
- ingredients.add(ingredient);
|
|
|
- stringListHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode(),ingredients);
|
|
|
+ if (ingredient.getUsageQuantity()!=null&&ingredient.getPurchaseQuantity()!=null && ingredient.getUsageQuantity().compareTo(ingredient.getPurchaseQuantity())>0){
|
|
|
+ BigDecimal transferQuantity=ingredient.getUsageQuantity().subtract(ingredient.getPurchaseQuantity());
|
|
|
+// ingredient.setIngredientsTransferQuantity(transferQuantity);
|
|
|
}
|
|
|
-
|
|
|
- if (stringListHashMap2.containsKey(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper())){
|
|
|
- List<SyCostAllocationIngredient> ingredients=stringListHashMap2.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper());
|
|
|
- ingredients.add(ingredient);
|
|
|
- stringListHashMap2.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper(),ingredients);
|
|
|
- }else{
|
|
|
- List<SyCostAllocationIngredient> ingredients=new ArrayList<>();
|
|
|
- ingredients.add(ingredient);
|
|
|
- stringListHashMap2.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper(),ingredients);
|
|
|
- }
|
|
|
- }
|
|
|
- for (List<SyCostAllocationIngredient> syCostAllocationIngredients : stringListHashMap.values()){
|
|
|
- if (syCostAllocationIngredients.size()>1){//解决转入数量和使用数量问题
|
|
|
- for (SyCostAllocationIngredient ingredient : syCostAllocationIngredients){
|
|
|
- BigDecimal transferQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"ingredientsTransferQuantity");
|
|
|
- BigDecimal usageQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"usageQuantity");
|
|
|
- BigDecimal purchaseQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"purchaseQuantity");
|
|
|
- if (ingredient.getUsageQuantity().equals(transferQuantity)){
|
|
|
- ingredient.setIngredientsTransferQuantity(ingredient.getUsageQuantity().subtract(transferQuantity));
|
|
|
-// ingredient.setUsageQuantity(ingredient.getUsageQuantity().subtract(usageQuantity));
|
|
|
- }
|
|
|
- if (usageQuantity.compareTo(purchaseQuantity)==0){
|
|
|
- ingredient.setUsageQuantity(ingredient.getPurchaseQuantity());
|
|
|
-// ingredient.setUsageQuantity(ingredient.getUsageQuantity().subtract(usageQuantity));
|
|
|
- }
|
|
|
- }
|
|
|
+ if (ingredient.getUsageQuantity()!=null&&ingredient.getPurchaseQuantity()!=null && ingredient.getUsageQuantity().compareTo(ingredient.getPurchaseQuantity())<0){
|
|
|
+ BigDecimal remainingQuantity=ingredient.getPurchaseQuantity().subtract(ingredient.getUsageQuantity());
|
|
|
+// ingredient.setIngredientsRemainingQuantity(transferQuantity);
|
|
|
}
|
|
|
}
|
|
|
- for (List<SyCostAllocationIngredient> syCostAllocationIngredients : stringListHashMap2.values()){
|
|
|
- SyCostAllocationIngredient allocationIngredient1=new SyCostAllocationIngredient();
|
|
|
- if (syCostAllocationIngredients.size()>1){
|
|
|
- int num=0;
|
|
|
- for (SyCostAllocationIngredient ingredient : syCostAllocationIngredients){
|
|
|
- if (num==0){
|
|
|
- allocationIngredient1=ingredient;
|
|
|
- }else{
|
|
|
- //转入数量
|
|
|
- allocationIngredient1.setIngredientsTransferQuantity(allocationIngredient1.getIngredientsTransferQuantity().add(ingredient.getIngredientsTransferQuantity()));
|
|
|
- //转入成本
|
|
|
-// allocationIngredient1.setTransferCost(allocationIngredient1.getTransferCost().add(ingredient.getTransferCost()));
|
|
|
- //使用数量
|
|
|
-// allocationIngredient1.setUsageQuantity(allocationIngredient1.getUsageQuantity().add(ingredient.getUsageQuantity()));
|
|
|
- //购入数量
|
|
|
- BigDecimal PurchaseQuantity=(allocationIngredient1.getPurchaseQuantity().add(ingredient.getPurchaseQuantity()));
|
|
|
- allocationIngredient1.setPurchaseQuantity(PurchaseQuantity);
|
|
|
- //余下数量
|
|
|
- BigDecimal ingredientsRemainingQuantity=allocationIngredient1.getPurchaseQuantity().subtract(ingredient.getUsageQuantity());
|
|
|
- if (ingredientsRemainingQuantity.doubleValue()>BigDecimal.ZERO.doubleValue()){
|
|
|
- allocationIngredient1.setIngredientsRemainingQuantity(ingredientsRemainingQuantity);
|
|
|
- }else{
|
|
|
- allocationIngredient1.setIngredientsRemainingQuantity(BigDecimal.ZERO);
|
|
|
-// allocationIngredient1.setTransferCost(BigDecimal.ZERO);
|
|
|
- }
|
|
|
-// allocationIngredient1.setIngredientsRemainingQuantity(allocationIngredient1.getPurchaseQuantity().subtract(ingredient.getUsageQuantity()));
|
|
|
- //转入数量
|
|
|
- BigDecimal ingredientsTransferQuantity=allocationIngredient1.getUsageQuantity().subtract(allocationIngredient1.getPurchaseQuantity());
|
|
|
- if (ingredientsTransferQuantity.doubleValue()>BigDecimal.ZERO.doubleValue()){
|
|
|
- allocationIngredient1.setIngredientsTransferQuantity(ingredientsTransferQuantity);
|
|
|
- }else{
|
|
|
- allocationIngredient1.setIngredientsTransferQuantity(BigDecimal.ZERO);
|
|
|
- }
|
|
|
-// allocationIngredient1.setIngredientsTransferQuantity(allocationIngredient1.getUsageQuantity().subtract(allocationIngredient1.getPurchaseQuantity()));
|
|
|
- //损耗
|
|
|
- allocationIngredient1.setLoss((allocationIngredient1.getPurchaseQuantity().subtract(allocationIngredient1.getUsageQuantity())).divide(allocationIngredient1.getPurchaseQuantity(),4));
|
|
|
- //人民币金额
|
|
|
- allocationIngredient1.setRmbAmount(allocationIngredient1.getRmbAmount().add(ingredient.getRmbAmount()));
|
|
|
- //美元金额
|
|
|
- allocationIngredient1.setUsdAmount(allocationIngredient1.getUsdAmount().add(ingredient.getUsdAmount()));
|
|
|
- //不含税金额
|
|
|
- allocationIngredient1.setPriceExcludingtax(allocationIngredient1.getPriceExcludingtax().add(ingredient.getPriceExcludingtax()));
|
|
|
- //用量
|
|
|
- }
|
|
|
- num++;
|
|
|
- }
|
|
|
- }else{
|
|
|
- allocationIngredient1=syCostAllocationIngredients.get(0);
|
|
|
- }
|
|
|
- ingredients4.add(allocationIngredient1);
|
|
|
- }
|
|
|
- list4=ingredients4;
|
|
|
-
|
|
|
- List<SyRemaining> remaininglists = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum);
|
|
|
- Map<String,List<SyRemaining>> remainingMaps=new HashMap<>();
|
|
|
- for (SyRemaining syRemaining : remaininglists){
|
|
|
- if (remainingMaps.containsKey(syRemaining.getGoodsName())){
|
|
|
- List<SyRemaining> remaininglist=remainingMaps.get(syRemaining.getGoodsName());
|
|
|
- remaininglist.add(syRemaining);
|
|
|
+// HashMap<String,List<SyCostAllocationIngredient>> stringListHashMap=new HashMap();//物料名称+物料编码
|
|
|
+// HashMap<String,List<SyCostAllocationIngredient>> stringListHashMap2=new HashMap();//物料名称+物料编码+供应商
|
|
|
+// List<SyCostAllocationIngredient> ingredients4=new ArrayList<>();//重新赋值
|
|
|
+// HashMap<String,BigDecimal> stringBigDecimalHashMap=new HashMap();//获取转入数量 syf107
|
|
|
+// for (SyCostAllocationIngredient ingredient : list4){
|
|
|
+// if (stringListHashMap.containsKey(ingredient.getGoodsName()+ingredient.getGoodsCode())){
|
|
|
+// List<SyCostAllocationIngredient> ingredients=stringListHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode());
|
|
|
+// ingredients.add(ingredient);
|
|
|
+// BigDecimal transferQuantity=new BigDecimal("0");//转入数量
|
|
|
+// for (SyCostAllocationIngredient ingredient1 : ingredients){
|
|
|
+// transferQuantity=transferQuantity.add(ingredient1.getIngredientsTransferQuantity());//转入数量
|
|
|
+// }
|
|
|
+// BigDecimal usageQuantity=new BigDecimal("0");//使用数量
|
|
|
+// BigDecimal purchaseQuantity=new BigDecimal("0");//购入数量
|
|
|
+// for (SyCostAllocationIngredient ingredient1 : ingredients){
|
|
|
+// if (usageQuantity.compareTo(ingredient1.getUsageQuantity())!=0){
|
|
|
+// usageQuantity=usageQuantity.add(ingredient1.getUsageQuantity());//转入数量
|
|
|
+// }
|
|
|
+// purchaseQuantity=purchaseQuantity.add(ingredient1.getPurchaseQuantity());
|
|
|
+// }
|
|
|
+// stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"ingredientsTransferQuantity",transferQuantity);
|
|
|
+// stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"usageQuantity",usageQuantity);
|
|
|
+// stringBigDecimalHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+"purchaseQuantity",purchaseQuantity);
|
|
|
+// stringListHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode(),ingredients);
|
|
|
+// }else{
|
|
|
+// List<SyCostAllocationIngredient> ingredients=new ArrayList<>();
|
|
|
+// ingredients.add(ingredient);
|
|
|
+// stringListHashMap.put(ingredient.getGoodsName()+ingredient.getGoodsCode(),ingredients);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (stringListHashMap2.containsKey(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper())){
|
|
|
+// List<SyCostAllocationIngredient> ingredients=stringListHashMap2.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper());
|
|
|
+// ingredients.add(ingredient);
|
|
|
+// stringListHashMap2.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper(),ingredients);
|
|
|
+// }else{
|
|
|
+// List<SyCostAllocationIngredient> ingredients=new ArrayList<>();
|
|
|
+// ingredients.add(ingredient);
|
|
|
+// stringListHashMap2.put(ingredient.getGoodsName()+ingredient.getGoodsCode()+ingredient.getSupper(),ingredients);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// for (List<SyCostAllocationIngredient> syCostAllocationIngredients : stringListHashMap.values()){
|
|
|
+// if (syCostAllocationIngredients.size()>1){//解决转入数量和使用数量问题
|
|
|
+// for (SyCostAllocationIngredient ingredient : syCostAllocationIngredients){
|
|
|
+// BigDecimal transferQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"ingredientsTransferQuantity");
|
|
|
+// BigDecimal usageQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"usageQuantity");
|
|
|
+// BigDecimal purchaseQuantity=stringBigDecimalHashMap.get(ingredient.getGoodsName()+ingredient.getGoodsCode()+"purchaseQuantity");
|
|
|
+// if (ingredient.getUsageQuantity().equals(transferQuantity)){
|
|
|
+// ingredient.setIngredientsTransferQuantity(ingredient.getUsageQuantity().subtract(transferQuantity));
|
|
|
+//// ingredient.setUsageQuantity(ingredient.getUsageQuantity().subtract(usageQuantity));
|
|
|
+// }
|
|
|
+// if (usageQuantity.compareTo(purchaseQuantity)==0){
|
|
|
+// ingredient.setUsageQuantity(ingredient.getPurchaseQuantity());
|
|
|
+//// ingredient.setUsageQuantity(ingredient.getUsageQuantity().subtract(usageQuantity));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// for (List<SyCostAllocationIngredient> syCostAllocationIngredients : stringListHashMap2.values()){
|
|
|
+// SyCostAllocationIngredient allocationIngredient1=new SyCostAllocationIngredient();
|
|
|
+// if (syCostAllocationIngredients.size()>1){
|
|
|
+// int num=0;
|
|
|
+// for (SyCostAllocationIngredient ingredient : syCostAllocationIngredients){
|
|
|
+// if (num==0){
|
|
|
+// allocationIngredient1=ingredient;
|
|
|
+// }else{
|
|
|
+// //转入数量
|
|
|
+// allocationIngredient1.setIngredientsTransferQuantity(allocationIngredient1.getIngredientsTransferQuantity().add(ingredient.getIngredientsTransferQuantity()));
|
|
|
+// //转入成本
|
|
|
+//// allocationIngredient1.setTransferCost(allocationIngredient1.getTransferCost().add(ingredient.getTransferCost()));
|
|
|
+// //使用数量
|
|
|
+//// allocationIngredient1.setUsageQuantity(allocationIngredient1.getUsageQuantity().add(ingredient.getUsageQuantity()));
|
|
|
+// //购入数量
|
|
|
+// BigDecimal PurchaseQuantity=(allocationIngredient1.getPurchaseQuantity().add(ingredient.getPurchaseQuantity()));
|
|
|
+// allocationIngredient1.setPurchaseQuantity(PurchaseQuantity);
|
|
|
+// //余下数量
|
|
|
+// BigDecimal ingredientsRemainingQuantity=allocationIngredient1.getPurchaseQuantity().subtract(ingredient.getUsageQuantity());
|
|
|
+// if (ingredientsRemainingQuantity.doubleValue()>BigDecimal.ZERO.doubleValue()){
|
|
|
+// allocationIngredient1.setIngredientsRemainingQuantity(ingredientsRemainingQuantity);
|
|
|
+// }else{
|
|
|
+// allocationIngredient1.setIngredientsRemainingQuantity(BigDecimal.ZERO);
|
|
|
+//// allocationIngredient1.setTransferCost(BigDecimal.ZERO);
|
|
|
+// }
|
|
|
+//// allocationIngredient1.setIngredientsRemainingQuantity(allocationIngredient1.getPurchaseQuantity().subtract(ingredient.getUsageQuantity()));
|
|
|
+// //转入数量
|
|
|
+// BigDecimal ingredientsTransferQuantity=allocationIngredient1.getUsageQuantity().subtract(allocationIngredient1.getPurchaseQuantity());
|
|
|
+// if (ingredientsTransferQuantity.doubleValue()>BigDecimal.ZERO.doubleValue()){
|
|
|
+// allocationIngredient1.setIngredientsTransferQuantity(ingredientsTransferQuantity);
|
|
|
+// }else{
|
|
|
+// allocationIngredient1.setIngredientsTransferQuantity(BigDecimal.ZERO);
|
|
|
+// }
|
|
|
+//// allocationIngredient1.setIngredientsTransferQuantity(allocationIngredient1.getUsageQuantity().subtract(allocationIngredient1.getPurchaseQuantity()));
|
|
|
+// //损耗
|
|
|
+// allocationIngredient1.setLoss((allocationIngredient1.getPurchaseQuantity().subtract(allocationIngredient1.getUsageQuantity())).divide(allocationIngredient1.getPurchaseQuantity(),4));
|
|
|
+// //人民币金额
|
|
|
+// allocationIngredient1.setRmbAmount(allocationIngredient1.getRmbAmount().add(ingredient.getRmbAmount()));
|
|
|
+// //美元金额
|
|
|
+// allocationIngredient1.setUsdAmount(allocationIngredient1.getUsdAmount().add(ingredient.getUsdAmount()));
|
|
|
+// //不含税金额
|
|
|
+// allocationIngredient1.setPriceExcludingtax(allocationIngredient1.getPriceExcludingtax().add(ingredient.getPriceExcludingtax()));
|
|
|
+// //用量
|
|
|
+// }
|
|
|
+// num++;
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// allocationIngredient1=syCostAllocationIngredients.get(0);
|
|
|
+// }
|
|
|
+// ingredients4.add(allocationIngredient1);
|
|
|
+// }
|
|
|
+// list4=ingredients4;//辅料合计
|
|
|
+
|
|
|
+// List<SyRemaining> remaininglists = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum);
|
|
|
+// Map<String,List<SyRemaining>> remainingMaps=new HashMap<>();
|
|
|
+// for (SyRemaining syRemaining : remaininglists){
|
|
|
+// if (remainingMaps.containsKey(syRemaining.getGoodsName())){
|
|
|
+// List<SyRemaining> remaininglist=remainingMaps.get(syRemaining.getGoodsName());
|
|
|
+// remaininglist.add(syRemaining);
|
|
|
+//// remainingMaps.put(syRemaining.getGoodsName(),remaininglist);
|
|
|
+// }else{
|
|
|
+// List<SyRemaining> remaininglist=new ArrayList<>();
|
|
|
+// remaininglist.add(syRemaining);
|
|
|
// remainingMaps.put(syRemaining.getGoodsName(),remaininglist);
|
|
|
- }else{
|
|
|
- List<SyRemaining> remaininglist=new ArrayList<>();
|
|
|
- remaininglist.add(syRemaining);
|
|
|
- remainingMaps.put(syRemaining.getGoodsName(),remaininglist);
|
|
|
- }
|
|
|
- }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
for (int i=0;i<list4.size();i++) {
|
|
|
SyCostAllocationIngredient Ingredient = list4.get(i);
|
|
|
//若转入数量不为0则给转入数据对象赋值 List<SyTransfer>
|
|
|
-// System.out.println("辅料转入数量\t"+Ingredient.getIngredientsTransferQuantity());
|
|
|
+// System.out.println("货物名称\t"+Ingredient.getGoodsName()+"\t辅料转入数量\t"+Ingredient.getIngredientsTransferQuantity());
|
|
|
// System.out.println("辅料判断\t"+(0!=Ingredient.getIngredientsTransferQuantity().compareTo(BigDecimal.ZERO)));
|
|
|
if(0!=Ingredient.getIngredientsTransferQuantity().compareTo(BigDecimal.ZERO)){
|
|
|
+ long startTime5 = System.currentTimeMillis();
|
|
|
List<SyTransfer> transferlist = syCostAllocationFabricMapper.queryTransferByFabric2(plannum,Ingredient.getGoodsName());
|
|
|
// syCostAllocationIngredientMapper.queryTransferByIngredient(plannum,Ingredient.getGoodsName());
|
|
|
// Ingredient.setSyTransfers(transferlist);
|
|
|
Ingredient.setSyTransfers(transferlist);
|
|
|
}
|
|
|
+// System.out.println("辅料人名币金额\t"+Ingredient.getRmbAmount()+"\t购入数量\t"+Ingredient.getPurchaseQuantity());
|
|
|
+ BigDecimal unitCost=new BigDecimal("0");
|
|
|
+ if (Ingredient.getPurchaseQuantity().compareTo(new BigDecimal("0"))>0){
|
|
|
+ unitCost=Ingredient.getRmbAmount().divide(Ingredient.getPurchaseQuantity(),4,BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
//若剩余数量不为0则给转入数据对象赋值
|
|
|
if(Ingredient.getIngredientsRemainingQuantity()!=null){
|
|
|
if(Ingredient.getIngredientsRemainingQuantity().compareTo(BigDecimal.ZERO)>0){
|
|
|
-// List<SyRemaining> remaininglist = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum,Ingredient.getGoodsName());
|
|
|
-// Ingredient.setSyRemaining(remaininglist);
|
|
|
- Ingredient.setSyRemaining(remainingMaps.get(Ingredient.getGoodsName()));
|
|
|
+// List<SyRemaining> remaininglist = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum,Ingredient.getGoodsName());
|
|
|
+// Ingredient.setSyRemaining(remaininglist);
|
|
|
+// Ingredient.setSyRemaining(remainingMaps.get(Ingredient.getGoodsName()));
|
|
|
+ List<SyRemaining> syRemainings1=syRemainingMaps.get(Ingredient.getGoodsName());
|
|
|
+ if (syRemainings1==null || syRemainings1.size()==0){
|
|
|
+ syRemainings1=new ArrayList<>();
|
|
|
+ }
|
|
|
+ for (SyRemaining remaining : syRemainings1){
|
|
|
+// System.out.println("辅料数量\t"+remaining.getNumber());
|
|
|
+ BigDecimal number=new BigDecimal(remaining.getNumber());
|
|
|
+ BigDecimal cost=unitCost.multiply(number).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ remaining.setUnitCost(unitCost);//总成本
|
|
|
+ remaining.setCost(cost);//总成本
|
|
|
+ }
|
|
|
+ Ingredient.setSyRemaining(syRemainings1);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -596,7 +687,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
|
|
|
syCostAllocation.setExcipiencostIncludestaxUsd(BigDecimal.ZERO);
|
|
|
}
|
|
|
//人民币金额 RmbAmount+ 辅料含税成本 ExcipiencostIncludestax
|
|
|
-// System.out.println("getRmbAmount\t"+Ingredient.getRmbAmount()+"getExcipiencostIncludestax\t"+syCostAllocation.getExcipiencostIncludestax());
|
|
|
+ //System.out.println("getRmbAmount\t"+Ingredient.getRmbAmount()+"getExcipiencostIncludestax\t"+syCostAllocation.getExcipiencostIncludestax());
|
|
|
syCostAllocation.setExcipiencostIncludestax(Ingredient.getRmbAmount().add(syCostAllocation.getExcipiencostIncludestax()));
|
|
|
syCostAllocation.setExcipiencostIncludestaxUsd(Ingredient.getUsdAmount().add(syCostAllocation.getExcipiencostIncludestaxUsd()));
|
|
|
|