|
@@ -111,43 +111,125 @@ public class InOutWarehouseTaskServiceImpl extends ServiceImpl<InOutWarehouseTas
|
|
|
if (CollectionUtils.isNotEmpty(sourceRelationInfoList)) {
|
|
|
for (int i=0;i<sourceRelationInfoList.size();i++){
|
|
|
SourceRelationInfo sourceRelationInfo=sourceRelationInfoList.get(i);
|
|
|
- sourceRelationInfo.setId(IdGenerator.generateUUID());
|
|
|
- sourceRelationInfo.setTaskId(inOutWarehouseTask.getId());
|
|
|
- sourceRelationInfo.setIssuingTime(sourceRelationInfo.getIssuingTimeOther());
|
|
|
- //最后一次循环
|
|
|
- if (i==sourceRelationInfoList.size()-1){
|
|
|
- double proportion=0d;
|
|
|
- List<SourceRelationInfo> sourceRelationInfoList1=sourceRelationInfoService.selectList(new EntityWrapper<SourceRelationInfo>()
|
|
|
- .eq("task_id",sourceRelationInfo.getTaskId()));
|
|
|
- if (CollectionUtils.isNotEmpty(sourceRelationInfoList1)){
|
|
|
- //比例和
|
|
|
- proportion = (sourceRelationInfoList1.stream().mapToDouble(SourceRelationInfo::getProportion).sum()) ;
|
|
|
- }
|
|
|
- sourceRelationInfo.setProportion(1-proportion);
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- //计算比例
|
|
|
- sourceRelationInfo.setProportion(sourceRelationInfo.getEstimateOutWarehouseWeight() / Double.valueOf(String.valueOf(inOutWarehouseTask.getWeight())));
|
|
|
- }
|
|
|
- sourceRelationInfoService.insert(sourceRelationInfo);
|
|
|
- //退库勾选标识
|
|
|
- if (sourceRelationInfo.getWarehouseInOutId() != null) {
|
|
|
- WarehouseInOutInfo warehouseInOutInfo = warehouseInOutInfoService.selectById(sourceRelationInfo.getWarehouseInOutId());
|
|
|
- warehouseInOutInfo.setReturnTickFlag(sourceRelationInfo.getReturnTickFlag());
|
|
|
- warehouseInOutInfoService.updateById(warehouseInOutInfo);
|
|
|
- }
|
|
|
- //出库
|
|
|
- else {
|
|
|
- WarehousingOrder warehousingOrder = warehousingOrderService.selectById(sourceRelationInfo.getSourceId());
|
|
|
- if (warehousingOrder != null) {
|
|
|
- warehousingOrder.setOutWarehouseWeight(warehousingOrder.getOutWarehouseWeight() + sourceRelationInfo.getEstimateOutWarehouseWeight());
|
|
|
+// //退库勾选标识
|
|
|
+// if (sourceRelationInfo.getWarehouseInOutId() != null) {
|
|
|
+// WarehouseInOutInfo warehouseInOutInfo = warehouseInOutInfoService.selectById(sourceRelationInfo.getWarehouseInOutId());
|
|
|
+// warehouseInOutInfo.setReturnTickFlag(sourceRelationInfo.getReturnTickFlag());
|
|
|
+// warehouseInOutInfoService.updateById(warehouseInOutInfo);
|
|
|
+// }
|
|
|
+ Double weight = Double.valueOf(String.valueOf(sourceRelationInfo.getEstimateOutWarehouseWeight()));
|
|
|
+ List<WarehousingOrder> warehousingOrderList=warehousingOrderService.selectList(new EntityWrapper<WarehousingOrder>()
|
|
|
+ .eq("comp_id",inOutWarehouseTask.getCompId())
|
|
|
+ .eq("warehouse_name",inOutWarehouseTask.getWarehouseName())
|
|
|
+ .eq("goods_name",sourceRelationInfo.getGoodsName())
|
|
|
+ .gt("surplus_weight",0)
|
|
|
+ .eq("contract_no",sourceRelationInfo.getContractNo())
|
|
|
+ .orderBy("issuing_time"));
|
|
|
+ for (WarehousingOrder warehousingOrder:warehousingOrderList){
|
|
|
+ WarehousingOrder warehousingOrder1 = warehousingOrderService.selectById(warehousingOrder.getId());
|
|
|
+ //预计出库重量大于入库单剩余重量
|
|
|
+ if (weight >= warehousingOrder1.getSurplusWeight()) {
|
|
|
+ weight = weight - warehousingOrder1.getSurplusWeight();
|
|
|
+ SourceRelationInfo sourceRelationInfo1=new SourceRelationInfo();
|
|
|
+ sourceRelationInfo1.setId(IdGenerator.generateUUID());
|
|
|
+ sourceRelationInfo1.setTaskId(inOutWarehouseTask.getId());
|
|
|
+ sourceRelationInfo1.setSourceId(warehousingOrder1.getId());
|
|
|
+ sourceRelationInfo1.setGoodsSource(warehousingOrder1.getGoodsSource());
|
|
|
+ sourceRelationInfo1.setAvgCost(warehousingOrder1.getAvgCost());
|
|
|
+ sourceRelationInfo1.setIssuingTime(warehousingOrder1.getIssuingTime());
|
|
|
+ sourceRelationInfo1.setGoodsName(warehousingOrder1.getGoodsName());
|
|
|
+ sourceRelationInfo1.setContractNo(warehousingOrder1.getContractNo());
|
|
|
+ sourceRelationInfo1.setEstimateOutWarehouseWeight(Float.valueOf(String.valueOf(warehousingOrder1.getSurplusWeight())));
|
|
|
+ sourceRelationInfo1.setSurplusWeight(sourceRelationInfo1.getEstimateOutWarehouseWeight());
|
|
|
+ sourceRelationInfo1.setWarehouseName(warehousingOrder1.getWarehouseName());
|
|
|
+ //计算比例
|
|
|
+ sourceRelationInfo1.setProportion(Double.valueOf(String.valueOf(sourceRelationInfo1.getEstimateOutWarehouseWeight() / inOutWarehouseTask.getWeight())));
|
|
|
+ sourceRelationInfoService.insert(sourceRelationInfo1);
|
|
|
+ //全部出库
|
|
|
+ warehousingOrder1.setOutWarehouseWeight(warehousingOrder1.getInWarehouseWeight());
|
|
|
+ //修改入库单剩余重量
|
|
|
+ warehousingOrder1.setSurplusWeight(0d);
|
|
|
+ warehousingOrderService.updateById(warehousingOrder1);
|
|
|
+ } else if (weight > 0) {
|
|
|
+ Double weightTmp = weight - warehousingOrder1.getSurplusWeight();
|
|
|
+ SourceRelationInfo sourceRelationInfo1=new SourceRelationInfo();
|
|
|
+ sourceRelationInfo1.setId(IdGenerator.generateUUID());
|
|
|
+ sourceRelationInfo1.setTaskId(inOutWarehouseTask.getId());
|
|
|
+ sourceRelationInfo1.setSourceId(warehousingOrder1.getId());
|
|
|
+ sourceRelationInfo1.setGoodsSource(warehousingOrder1.getGoodsSource());
|
|
|
+ sourceRelationInfo1.setAvgCost(warehousingOrder1.getAvgCost());
|
|
|
+ sourceRelationInfo1.setContractNo(warehousingOrder1.getContractNo());
|
|
|
+ sourceRelationInfo1.setIssuingTime(warehousingOrder1.getIssuingTime());
|
|
|
+ sourceRelationInfo1.setGoodsName(warehousingOrder1.getGoodsName());
|
|
|
+ sourceRelationInfo1.setEstimateOutWarehouseWeight(Float.valueOf(String.valueOf(weight)));
|
|
|
+ sourceRelationInfo1.setSurplusWeight(sourceRelationInfo1.getEstimateOutWarehouseWeight());
|
|
|
+ sourceRelationInfo1.setWarehouseName(warehousingOrder1.getWarehouseName());
|
|
|
+ if (i==sourceRelationInfoList.size()-1) {
|
|
|
+ //比例
|
|
|
+ Double proportion = 0d;
|
|
|
+ //最后一次循环
|
|
|
+ List<SourceRelationInfo> sourceRelationInfoList1 = sourceRelationInfoService.selectList(new EntityWrapper<SourceRelationInfo>()
|
|
|
+ .eq("task_id", sourceRelationInfo1.getTaskId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(sourceRelationInfoList1)) {
|
|
|
+ //分摊比例和
|
|
|
+ proportion = (sourceRelationInfoList1.stream().mapToDouble(SourceRelationInfo::getProportion).sum());
|
|
|
+ }
|
|
|
+ sourceRelationInfo1.setProportion(1 - proportion);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ sourceRelationInfo1.setProportion(Double.valueOf(String.valueOf(sourceRelationInfo1.getEstimateOutWarehouseWeight() / inOutWarehouseTask.getWeight())));
|
|
|
+ }
|
|
|
+ sourceRelationInfoService.insert(sourceRelationInfo1);
|
|
|
+ //部分出库
|
|
|
+ warehousingOrder1.setOutWarehouseWeight(warehousingOrder1.getOutWarehouseWeight()+weight);
|
|
|
//修改入库单剩余重量
|
|
|
- warehousingOrder.setSurplusWeight(warehousingOrder.getSurplusWeight() - sourceRelationInfo.getEstimateOutWarehouseWeight());
|
|
|
- warehousingOrderService.updateById(warehousingOrder);
|
|
|
+ warehousingOrder1.setSurplusWeight(warehousingOrder1.getSurplusWeight()-weight);
|
|
|
+ warehousingOrderService.updateById(warehousingOrder1);
|
|
|
+ weight = weightTmp;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+// for (int i=0;i<sourceRelationInfoList.size();i++){
|
|
|
+// SourceRelationInfo sourceRelationInfo=sourceRelationInfoList.get(i);
|
|
|
+// sourceRelationInfo.setId(IdGenerator.generateUUID());
|
|
|
+// sourceRelationInfo.setTaskId(inOutWarehouseTask.getId());
|
|
|
+// sourceRelationInfo.setIssuingTime(sourceRelationInfo.getIssuingTimeOther());
|
|
|
+// //最后一次循环
|
|
|
+// if (i==sourceRelationInfoList.size()-1){
|
|
|
+// double proportion=0d;
|
|
|
+// List<SourceRelationInfo> sourceRelationInfoList1=sourceRelationInfoService.selectList(new EntityWrapper<SourceRelationInfo>()
|
|
|
+// .eq("task_id",sourceRelationInfo.getTaskId()));
|
|
|
+// if (CollectionUtils.isNotEmpty(sourceRelationInfoList1)){
|
|
|
+// //比例和
|
|
|
+// proportion = (sourceRelationInfoList1.stream().mapToDouble(SourceRelationInfo::getProportion).sum()) ;
|
|
|
+// }
|
|
|
+// sourceRelationInfo.setProportion(1-proportion);
|
|
|
+//
|
|
|
+// }
|
|
|
+// else {
|
|
|
+// //计算比例
|
|
|
+// sourceRelationInfo.setProportion(sourceRelationInfo.getEstimateOutWarehouseWeight() / Double.valueOf(String.valueOf(inOutWarehouseTask.getWeight())));
|
|
|
+// }
|
|
|
+// sourceRelationInfoService.insert(sourceRelationInfo);
|
|
|
+// //退库勾选标识
|
|
|
+// if (sourceRelationInfo.getWarehouseInOutId() != null) {
|
|
|
+// WarehouseInOutInfo warehouseInOutInfo = warehouseInOutInfoService.selectById(sourceRelationInfo.getWarehouseInOutId());
|
|
|
+// warehouseInOutInfo.setReturnTickFlag(sourceRelationInfo.getReturnTickFlag());
|
|
|
+// warehouseInOutInfoService.updateById(warehouseInOutInfo);
|
|
|
+// }
|
|
|
+// //出库
|
|
|
+// else {
|
|
|
+// WarehousingOrder warehousingOrder = warehousingOrderService.selectById(sourceRelationInfo.getSourceId());
|
|
|
+// if (warehousingOrder != null) {
|
|
|
+// warehousingOrder.setOutWarehouseWeight(warehousingOrder.getOutWarehouseWeight() + sourceRelationInfo.getEstimateOutWarehouseWeight());
|
|
|
+// //修改入库单剩余重量
|
|
|
+// warehousingOrder.setSurplusWeight(warehousingOrder.getSurplusWeight() - sourceRelationInfo.getEstimateOutWarehouseWeight());
|
|
|
+// warehousingOrderService.updateById(warehousingOrder);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
//出库任务,入库任务,赋值关联id
|
|
@@ -422,6 +504,7 @@ public class InOutWarehouseTaskServiceImpl extends ServiceImpl<InOutWarehouseTas
|
|
|
for (InOutWarehouseTask inOutWarehouseTask1 : inOutWarehouseTaskList) {
|
|
|
List<SourceRelationInfo> sourceRelationInfoList = sourceRelationInfoService.selectList(new EntityWrapper<SourceRelationInfo>()
|
|
|
.eq("task_id", inOutWarehouseTask1.getId())
|
|
|
+ .orderBy("contract_no")
|
|
|
.eq("delete_flag", "0"));
|
|
|
if (CollectionUtils.isNotEmpty(sourceRelationInfoList)) {
|
|
|
inOutWarehouseTask1.setSourceRelationInfoList(sourceRelationInfoList);
|