|
@@ -547,20 +547,21 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
|
|
|
fabricOMOrder.setFabricMoOrderRKList(findList);
|
|
|
List<FabricMoOrderCK> ckList = fabricOMOrder.getFabricMoOrderCKList();
|
|
|
- FabricMoOrderCK ckItem = null;
|
|
|
+
|
|
|
+ Double iMoneyCk = 0.0;
|
|
|
if (ckList != null && ckList.size() > 0){
|
|
|
- ckItem = ckList.get(0);
|
|
|
+ for (FabricMoOrderCK item : ckList) {
|
|
|
+ iMoneyCk += item.getIMoney();
|
|
|
+ }
|
|
|
}
|
|
|
- for (FabricMoOrderRK fabricMoOrderRK : findList){
|
|
|
- BigDecimal bdVal = new BigDecimal(fabricMoOrderRK.getIQuantityIn()-fabricMoOrderRK.getISumBillQuantity());
|
|
|
+ for (FabricMoOrderRK fabricMoOrderRK : findList) {
|
|
|
+ BigDecimal bdVal = new BigDecimal(fabricMoOrderRK.getIQuantityIn() - fabricMoOrderRK.getISumBillQuantity());
|
|
|
fabricMoOrderRK.setISumBillQuantityN(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
- bdVal = new BigDecimal(fabricMoOrderRK.getIQuantityIn()-fabricMoOrderRK.getISQuantity());
|
|
|
+ bdVal = new BigDecimal(fabricMoOrderRK.getIQuantityIn() - fabricMoOrderRK.getISQuantity());
|
|
|
fabricMoOrderRK.setISQuantityN(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
- if (ckItem != null && ckItem.getIPrice() != null && ckItem.getIPrice()>0){
|
|
|
- bdVal = new BigDecimal(fabricMoOrderRK.getIProcessFee()+ckItem.getIPrice()*fabricMoOrderRK.getIQuantityOut());
|
|
|
- fabricMoOrderRK.setIPrice(bdVal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
-
|
|
|
- }
|
|
|
+ Double curIMoneyCk = iMoneyCk * fabricMoOrderRK.getIQuantityIn() / fabricOMOrder.getIQuantityIn() ;
|
|
|
+ bdVal = new BigDecimal((fabricMoOrderRK.getIProcessFee() + curIMoneyCk) / fabricMoOrderRK.getIQuantityIn());
|
|
|
+ fabricMoOrderRK.setIPrice(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -682,6 +683,64 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
List<FabricMoOrderCK> rowOutList,
|
|
|
List<Map<String,Object>> rowInList,
|
|
|
List<Map<String,Object>> rowInListWithAV){
|
|
|
+
|
|
|
+ do{
|
|
|
+
|
|
|
+ List<FabricMoOrderCK> findOutCanSetList = rowOutList.stream().filter(out->{
|
|
|
+ return rowInList.stream().filter(in->
|
|
|
+ in.get("cInvCode").toString().equals(out.getCInvCodeOut()) &&
|
|
|
+ in.get("cColor").toString().equals(out.getCColorOut()) &&
|
|
|
+ in.get("cBatch").toString().equals(out.getCBatchOut())).count()==0;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Map<String,Object>> findInCanSetList = rowInList.stream().filter(in->
|
|
|
+ oConvertUtils.getDouble(in.get("iPurchuseMoney").toString(),0) == 0
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+
|
|
|
+ findInCanSetList = findInCanSetList.stream().filter(in->{
|
|
|
+ return findOutCanSetList.stream().filter(out->
|
|
|
+ oConvertUtils.getInt(in.get("MODetailsID")).equals(out.getMODetailsID())).count()>0;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (Map<String,Object> item : findInCanSetList){
|
|
|
+
|
|
|
+ Optional<Map<String,Object>> findRowInfoOpt = rowInfoList.stream().filter(info->
|
|
|
+ oConvertUtils.getInt(info.get("MODetailsID")).equals(oConvertUtils.getInt(item.get("MODetailsID")))
|
|
|
+ ).findFirst();
|
|
|
+ if (!findRowInfoOpt.isPresent()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String,Object> findRowInfo = findRowInfoOpt.get();
|
|
|
+
|
|
|
+ Double iProcessFee = oConvertUtils.getDouble(findRowInfo.get("iProcessFee").toString(),0);
|
|
|
+
|
|
|
+ Double iQuantityIn = oConvertUtils.getDouble(findRowInfo.get("iQuantityIn").toString(),0);
|
|
|
+
|
|
|
+ Double iOutFee = 0.0;
|
|
|
+ List<FabricMoOrderCK> findOutList = rowOutList.stream().filter(out->out.getMODetailsID().equals(oConvertUtils.getInt(item.get("MODetailsID")))).collect(Collectors.toList());
|
|
|
+ for (FabricMoOrderCK itemOut : findOutList){
|
|
|
+ Double outSum = itemOut.getIQuantityOut();
|
|
|
+
|
|
|
+ List<Map<String,Object>> findInByOutList = rowInListWithAV.stream().filter(in->
|
|
|
+ in.get("cInvIdOut").equals(itemOut.getCInvCodeOut()+itemOut.getCColorOut()+itemOut.getCBatchOut())).collect(Collectors.toList());
|
|
|
+ for (Map<String,Object> itemIn :findInByOutList){
|
|
|
+ Double inSum = oConvertUtils.getDouble(itemIn.get("iQuantity").toString(),0);
|
|
|
+ Double iPurchuseMoney = oConvertUtils.getDouble(itemIn.get("iPurchuseMoney").toString(),0);
|
|
|
+ Double curSum = outSum>inSum?inSum:outSum;
|
|
|
+ outSum -= curSum;
|
|
|
+ iOutFee += curSum*iPurchuseMoney/inSum;
|
|
|
+
|
|
|
+ if (outSum<=0){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Double iPrice = (iOutFee+iProcessFee)/iQuantityIn;
|
|
|
+
|
|
|
+ item.put("iPurchuseMoney", iPrice*oConvertUtils.getDouble(item.get("iQuantity").toString(),0));
|
|
|
+ }
|
|
|
+ }while(false);
|
|
|
|
|
|
do {
|
|
|
|