|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.mongodb.internal.operation.FindOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
@@ -973,7 +974,9 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
if (commonInList.size()>0){
|
|
|
List<Integer> moDetailIdList = new ArrayList<>();
|
|
|
for (FabricCommonIn item : commonInList){
|
|
|
- moDetailIdList.add(item.getMODetailsID());
|
|
|
+ if (!moDetailIdList.contains(item.getMODetailsID())) {
|
|
|
+ moDetailIdList.add(item.getMODetailsID());
|
|
|
+ }
|
|
|
}
|
|
|
// 出入库详情
|
|
|
//List<Map<String,Object>> inOutDetailList = fabricLossMapper.getOmInOutInfoListByDetailId(moDetailIdList);
|
|
@@ -991,24 +994,13 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
setAssemVouchInPriceList(inList);
|
|
|
|
|
|
// 每行设置金额
|
|
|
- for (FabricCommonIn item : commonInList){
|
|
|
- Integer detailId = item.getMODetailsID();
|
|
|
- /*List<Map<String,Object>> findInOutList = inOutDetailList.stream().filter(e->oConvertUtils.getInt(e.get("MODetailsID")).equals(detailId)).collect(Collectors.toList());
|
|
|
- if (findInOutList.size() == 0){
|
|
|
- continue;
|
|
|
- }*/
|
|
|
- List<FabricMoOrderRK> findInList = moInList.stream().filter(e->e.getMODetailsID().equals(detailId.toString())&&e.getInvId().equalsIgnoreCase(item.getInvId())).collect(Collectors.toList());
|
|
|
- if (findInList.size() == 0){
|
|
|
- continue;
|
|
|
- }
|
|
|
- Double iProcessFee = findInList.get(0).getIProcessFee();
|
|
|
- Double iQuantityIn = findInList.get(0).getIQuantityIn();
|
|
|
- Double iTotalIn = moInList.stream().filter(e->e.getMODetailsID().equals(detailId.toString())).mapToDouble(FabricMoOrderRK::getIQuantityIn).sum();
|
|
|
+ //for (FabricCommonIn item : commonInList){
|
|
|
+ for (Integer detailId : moDetailIdList){
|
|
|
Double iOutTotalMoney = 0.0;// 出库材料费用
|
|
|
|
|
|
for (FabricMoOrderCK ckItem : outList){
|
|
|
Double dOutLeft = ckItem.getIQuantityOut();
|
|
|
- if (ckItem.getMODetailsID().equals(item.getMODetailsID().toString())){
|
|
|
+ if (ckItem.getMODetailsID().equals(detailId.toString())){
|
|
|
for (FabricCommonIn inItem : inList){
|
|
|
if (inItem.getInvId().equalsIgnoreCase(ckItem.getInvOutId()) && inItem.getIQuantity()>0){
|
|
|
Double dCurSum = inItem.getIQuantity();
|
|
@@ -1021,15 +1013,34 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ ckItem.setIQuantityOut(dOutLeft);
|
|
|
}
|
|
|
}
|
|
|
- if (iTotalIn == 0 || iQuantityIn == 0){
|
|
|
- item.setIPrice(0.0);
|
|
|
- }else {
|
|
|
- // 入库单价
|
|
|
- Double iPrice =(iOutTotalMoney/iTotalIn*iQuantityIn+iProcessFee)/iQuantityIn;
|
|
|
|
|
|
- item.setIPrice(DoubleOperation.getScale(iPrice,4));
|
|
|
+ List<FabricMoOrderRK> findInList = moInList.stream().filter(e->e.getMODetailsID().equals(detailId.toString())).collect(Collectors.toList());
|
|
|
+ if (findInList.size() == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Double iTotalIn = moInList.stream().filter(e->e.getMODetailsID().equals(detailId.toString())).mapToDouble(FabricMoOrderRK::getIQuantityIn).sum();
|
|
|
+
|
|
|
+ for (FabricMoOrderRK itemRk : findInList){
|
|
|
+ Double iProcessFee = itemRk.getIProcessFee();
|
|
|
+ Double iQuantityIn = itemRk.getIQuantityIn();
|
|
|
+ if (iTotalIn == 0 || iQuantityIn == 0){
|
|
|
+ itemRk.setIPrice(0.0);
|
|
|
+ }else {
|
|
|
+ // 入库单价
|
|
|
+ Double iPrice =iOutTotalMoney/iTotalIn+iProcessFee/iQuantityIn;
|
|
|
+
|
|
|
+ itemRk.setIPrice(DoubleOperation.getScale(iPrice,4));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ for (FabricCommonIn item : commonInList){
|
|
|
+ Optional<FabricMoOrderRK> findOpt = moInList.stream().filter(e->e.getMODetailsID().equalsIgnoreCase(item.getMODetailsID().toString()) && e.getInvId().equalsIgnoreCase(item.getInvId())).findFirst();
|
|
|
+ if (findOpt.isPresent()){
|
|
|
+ item.setIPrice(findOpt.get().getIPrice());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1061,9 +1072,11 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
if (orgInList.size() == 0){
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
for (FabricAssemVouchsOrgIn item : assemVouchsInvIdList){
|
|
|
if ("转换入库".equalsIgnoreCase(item.getCBusType())){
|
|
|
Optional<FabricAssemVouchsOrgIn> findOpt = orgInList.stream().filter(e->e.getCInvIdAfter().equals(item.getCInvIdAfter())).findFirst();
|
|
|
+
|
|
|
if (findOpt.isPresent()){
|
|
|
FabricAssemVouchsOrgIn findItem = findOpt.get();
|
|
|
item.setCBusType(findItem.getCBusType());
|
|
@@ -1075,11 +1088,98 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
}
|
|
|
}
|
|
|
// 设置采购入库单价
|
|
|
- List<Integer> autoIdList = assemVouchsInvIdList.stream().filter(e->"rdrecords01".equalsIgnoreCase(e.getCTableName())).map(FabricAssemVouchsOrgIn::getAutoId).collect(Collectors.toList());
|
|
|
+ List<Integer> autoIdList = assemVouchsInvIdList.stream().filter(e->
|
|
|
+ "rdrecords01".equalsIgnoreCase(e.getCTableName()) &&
|
|
|
+ !"委外入库".equalsIgnoreCase(e.getCBusType())).map(FabricAssemVouchsOrgIn::getAutoId).collect(Collectors.toList());
|
|
|
if (autoIdList.size()>0){
|
|
|
List<FabricInPrice> priceList = fabricLossMapper.getPoInPriceList(autoIdList);
|
|
|
setAssemVouchsInPrice(commonInList, assemVouchsInvIdList, priceList);
|
|
|
}
|
|
|
+
|
|
|
+ // 设置委外入库单价
|
|
|
+ List<FabricAssemVouchsOrgIn> fabricAssemVouchsOrgInList = assemVouchsInvIdList.stream().filter(e->
|
|
|
+ "rdrecords01".equalsIgnoreCase(e.getCTableName()) &&
|
|
|
+ "委外加工".equalsIgnoreCase(e.getCBusType())).collect(Collectors.toList());
|
|
|
+ if (fabricAssemVouchsOrgInList.size()>0){
|
|
|
+ autoIdList = fabricAssemVouchsOrgInList.stream().map(FabricAssemVouchsOrgIn::getAutoId).collect(Collectors.toList());
|
|
|
+ List<Map<String,Integer>> autoIdMoDetailIdMapList = fabricLossMapper.getMoDetailIdListByAutoId(autoIdList);
|
|
|
+
|
|
|
+ List<Integer> moDetailIdList = new ArrayList<>();
|
|
|
+ for (Map<String,Integer> item : autoIdMoDetailIdMapList){
|
|
|
+ if (!moDetailIdList.contains(item.get("iOMoDID"))) {
|
|
|
+ moDetailIdList.add(item.get("iOMoDID"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取委外订单出库物料详情
|
|
|
+ List<FabricMoOrderCK> outList = fabricLossMapper.getOmRowOutListByDetailId(moDetailIdList);
|
|
|
+ // 获取委外订单入库物料详情
|
|
|
+ List<FabricMoOrderRK> moInList = fabricLossMapper.getOmInDetailListByDetailId(moDetailIdList);
|
|
|
+ // 获取委外订单出库物料入库详情
|
|
|
+ List<String> invIdList = new ArrayList<>();
|
|
|
+ outList.forEach(e->invIdList.add(e.getInvOutId()));
|
|
|
+ List<FabricCommonIn> inList = fabricLossMapper.getInListByInvId(invIdList);
|
|
|
+ // 入库价格保留四位小数
|
|
|
+ inList.forEach(e->e.setIPrice(DoubleOperation.getScale(e.getIPrice(),4)));
|
|
|
+
|
|
|
+ for (Integer detailId : moDetailIdList){
|
|
|
+ Double iOutTotalMoney = 0.0;// 出库材料费用
|
|
|
+
|
|
|
+ for (FabricMoOrderCK ckItem : outList){
|
|
|
+ Double dOutLeft = ckItem.getIQuantityOut();
|
|
|
+ if (ckItem.getMODetailsID().equals(detailId.toString())){
|
|
|
+ for (FabricCommonIn inItem : inList){
|
|
|
+ if (inItem.getInvId().equalsIgnoreCase(ckItem.getInvOutId()) && inItem.getIQuantity()>0){
|
|
|
+ Double dCurSum = inItem.getIQuantity();
|
|
|
+ dCurSum = Math.min(dOutLeft, dCurSum);
|
|
|
+ inItem.setIQuantity(DoubleOperation.sub(inItem.getIQuantity(),dCurSum));
|
|
|
+ dOutLeft = DoubleOperation.sub(dOutLeft, dCurSum);
|
|
|
+ iOutTotalMoney = DoubleOperation.add(iOutTotalMoney, DoubleOperation.mul(dCurSum,inItem.getIPrice(),2));
|
|
|
+ if (dOutLeft<=0){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ckItem.setIQuantityOut(dOutLeft);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FabricMoOrderRK> findInList = moInList.stream().filter(e->e.getMODetailsID().equals(detailId.toString())).collect(Collectors.toList());
|
|
|
+ if (findInList.size() == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Double iTotalIn = moInList.stream().filter(e->e.getMODetailsID().equals(detailId.toString())).mapToDouble(FabricMoOrderRK::getIQuantityIn).sum();
|
|
|
+
|
|
|
+ for (FabricMoOrderRK itemRk : findInList){
|
|
|
+ Double iProcessFee = itemRk.getIProcessFee();
|
|
|
+ Double iQuantityIn = itemRk.getIQuantityIn();
|
|
|
+ if (iTotalIn == 0 || iQuantityIn == 0){
|
|
|
+ itemRk.setIPrice(0.0);
|
|
|
+ }else {
|
|
|
+ // 入库单价
|
|
|
+ Double iPrice =iOutTotalMoney/iTotalIn+iProcessFee/iQuantityIn;
|
|
|
+
|
|
|
+ itemRk.setIPrice(DoubleOperation.getScale(iPrice,4));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ for (FabricAssemVouchsOrgIn orgIn : fabricAssemVouchsOrgInList){
|
|
|
+ Optional<FabricMoOrderRK> finRkOpt = moInList.stream().filter(e->e.getInvId().equalsIgnoreCase(orgIn.getCInvIdAfter())).findFirst();
|
|
|
+ Double iPrice = 0.0;
|
|
|
+ if (finRkOpt.isPresent()){
|
|
|
+ iPrice = finRkOpt.get().getIPrice();
|
|
|
+ }
|
|
|
+ if (iPrice.equals(0)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (FabricCommonIn commonIn : commonInList){
|
|
|
+ if ("转换入库".equalsIgnoreCase(commonIn.getCBusType()) && commonIn.getInvId().equalsIgnoreCase(orgIn.getCInvIdFinal())) {
|
|
|
+ commonIn.setIPrice(iPrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
// 设置其他入库单价
|
|
|
autoIdList = assemVouchsInvIdList.stream().filter(e->"rdrecords08".equalsIgnoreCase(e.getCTableName())).map(FabricAssemVouchsOrgIn::getAutoId).collect(Collectors.toList());
|
|
|
if (autoIdList.size()>0){
|