|
|
|
@ -68,59 +68,65 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
|
|
|
|
|
log.warn("#############dealWithData: 数据已存在 invoiceOrderCode={}",invoiceOrderCode); |
|
|
|
|
return R.fail(405,"发货单已存在"); |
|
|
|
|
} |
|
|
|
|
mtFactoryOrderMain = new MtFactoryOrderMain(); |
|
|
|
|
BeanUtil.copyProperties(mtFactoryDataDTO,mtFactoryOrderMain); |
|
|
|
|
boolean saveMain = mtFactoryOrderMainService.save(mtFactoryOrderMain); |
|
|
|
|
if(saveMain){ |
|
|
|
|
mainId = mtFactoryOrderMain.getId();//发货单id
|
|
|
|
|
List<MtFactoryOrderDTO> orderList = mtFactoryDataDTO.getOrderList();//所有订单数据
|
|
|
|
|
for(MtFactoryOrderDTO mtFactoryOrderDTO:orderList){ |
|
|
|
|
String orderCode = mtFactoryOrderDTO.getOrderCode(); |
|
|
|
|
MtFactoryOrder mtFactoryOrder = new MtFactoryOrder(); |
|
|
|
|
BeanUtil.copyProperties(mtFactoryOrderDTO,mtFactoryOrder); |
|
|
|
|
mtFactoryOrder.setMainId(mainId); |
|
|
|
|
boolean saveOrder = mtFactoryOrderService.save(mtFactoryOrder); |
|
|
|
|
if(saveOrder){ |
|
|
|
|
//根据订单自编码去查是否有已存在的包件,有就舍去
|
|
|
|
|
Long orderId = mtFactoryOrder.getId(); |
|
|
|
|
QueryWrapper<MtPackageInfo> qw = new QueryWrapper<>(); |
|
|
|
|
qw.eq("order_id",orderId); |
|
|
|
|
List<MtPackageInfo> existPackages = mtPackageInfoService.list(qw); |
|
|
|
|
List<MtPackageInfoDTO> packageInfos = mtFactoryOrderDTO.getPackageInfos(); |
|
|
|
|
for(MtPackageInfo mtPackageInfo:existPackages){ |
|
|
|
|
String packageCode = mtPackageInfo.getPackageCode(); |
|
|
|
|
for (MtPackageInfoDTO mtPackageInfoDTO:packageInfos){ |
|
|
|
|
String pc = mtPackageInfoDTO.getPackageCode(); |
|
|
|
|
if(packageCode.equals(pc)){ |
|
|
|
|
packageInfos.remove(mtPackageInfoDTO); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<MtPackageInfo> list = new ArrayList<>(); |
|
|
|
|
for(MtPackageInfoDTO mtPackageInfoDTO:packageInfos){ |
|
|
|
|
MtPackageInfo mtPackageInfo = new MtPackageInfo(); |
|
|
|
|
BeanUtil.copyProperties(mtPackageInfoDTO,mtPackageInfo); |
|
|
|
|
mtPackageInfo.setOrderId(orderId); |
|
|
|
|
list.add(mtPackageInfo); |
|
|
|
|
} |
|
|
|
|
//保存包件信息
|
|
|
|
|
boolean b = mtPackageInfoService.saveBatch(list); |
|
|
|
|
if(b){ |
|
|
|
|
log.info("#############dealWithData: 保存数据成功"); |
|
|
|
|
}else{ |
|
|
|
|
log.warn("#############dealWithData: 保存数据失败 orderCode={}",orderCode); |
|
|
|
|
throw new CustomerException(405,"保存数据失败"); |
|
|
|
|
//先取出所有发车单下面的订单
|
|
|
|
|
List<MtFactoryOrderDTO> orderList = mtFactoryDataDTO.getOrderList();//所有订单数据
|
|
|
|
|
for(MtFactoryOrderDTO mtFactoryOrderDTO:orderList){ |
|
|
|
|
String orderCode = mtFactoryOrderDTO.getOrderCode();//订单自编码
|
|
|
|
|
//先取出订单下面的包件进行判断是否存在
|
|
|
|
|
List<MtPackageInfoDTO> packageInfos = mtFactoryOrderDTO.getPackageInfos(); |
|
|
|
|
//查询出该订单自编码下面的目前存在的所有包件
|
|
|
|
|
QueryWrapper<MtPackageInfo> qw = new QueryWrapper<>(); |
|
|
|
|
qw.eq("order_code",orderCode); |
|
|
|
|
List<MtPackageInfo> existPackages = mtPackageInfoService.list(qw); |
|
|
|
|
for(MtPackageInfo mtPackageInfo:existPackages){ |
|
|
|
|
String packageCode = mtPackageInfo.getPackageCode(); |
|
|
|
|
for (MtPackageInfoDTO mtPackageInfoDTO:packageInfos){ |
|
|
|
|
String pc = mtPackageInfoDTO.getPackageCode(); |
|
|
|
|
if(packageCode.equals(pc)){ |
|
|
|
|
packageInfos.remove(mtPackageInfoDTO); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//判断是否有新的包件
|
|
|
|
|
if(packageInfos.size() == 0){ |
|
|
|
|
//如果没有新增包件就直接下一条数据
|
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
//如果有新增包件就去存入订单发车单,和订单信息
|
|
|
|
|
if(Objects.isNull(mtFactoryOrderMain)){ |
|
|
|
|
mtFactoryOrderMain = new MtFactoryOrderMain(); |
|
|
|
|
BeanUtil.copyProperties(mtFactoryDataDTO,mtFactoryOrderMain); |
|
|
|
|
boolean saveMain = mtFactoryOrderMainService.save(mtFactoryOrderMain); |
|
|
|
|
if(saveMain){ |
|
|
|
|
mainId = mtFactoryOrderMain.getId(); |
|
|
|
|
}else{ |
|
|
|
|
log.warn("#############dealWithData: 保存订单失败 orderCode={}",orderCode); |
|
|
|
|
throw new CustomerException(405,"保存订单失败"); |
|
|
|
|
log.warn("##################dealWithData: 保存头信息失败invoiceOrderCode={} ",invoiceOrderCode); |
|
|
|
|
throw new CustomerException(405,"保存数据失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
log.warn("#############dealWithData: 保存发货单失败 invoiceOrderCode={}",invoiceOrderCode); |
|
|
|
|
throw new CustomerException(405,"保存发货单失败"); |
|
|
|
|
//保存订单信息
|
|
|
|
|
MtFactoryOrder mtFactoryOrder = new MtFactoryOrder(); |
|
|
|
|
BeanUtil.copyProperties(mtFactoryOrderDTO,mtFactoryOrder); |
|
|
|
|
mtFactoryOrder.setMainId(mainId); |
|
|
|
|
boolean saveOrder = mtFactoryOrderService.save(mtFactoryOrder); |
|
|
|
|
Long orderId = mtFactoryOrder.getId(); |
|
|
|
|
if(saveOrder){ |
|
|
|
|
List<MtPackageInfo> list = new ArrayList<>(); |
|
|
|
|
for(MtPackageInfoDTO mtPackageInfoDTO:packageInfos){ |
|
|
|
|
MtPackageInfo mtPackageInfo = new MtPackageInfo(); |
|
|
|
|
BeanUtil.copyProperties(mtPackageInfoDTO,mtPackageInfo); |
|
|
|
|
mtPackageInfo.setOrderId(orderId); |
|
|
|
|
mtPackageInfo.setOrderCode(orderCode); |
|
|
|
|
list.add(mtPackageInfo); |
|
|
|
|
} |
|
|
|
|
//保存包件信息
|
|
|
|
|
boolean b = mtPackageInfoService.saveBatch(list); |
|
|
|
|
}else{ |
|
|
|
|
log.warn("##################dealWithData: 保存订单信息失败orderCode={} ",orderCode); |
|
|
|
|
throw new CustomerException(405,"保存数据失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Map<String,Long> map = new HashMap<>(); |
|
|
|
|
map.put("mainId",mainId); |
|
|
|
@ -312,7 +318,7 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
|
|
|
|
|
List<ReceiveBodyDTO> receiveBodyList = receiveInfoDTO.getReceiveBodyList(); |
|
|
|
|
List<ReceivePhotoDTO> receivePhotoList = receiveInfoDTO.getReceivePhotoList(); |
|
|
|
|
//查询签收人
|
|
|
|
|
NewDistributionContactEntity newDistributionContactEntity = newDistributionContactClient.fingById(newDistributionContactId); |
|
|
|
|
NewDistributionContactEntity newDistributionContactEntity = newDistributionContactClient.fingByNewDistributionContactId(newDistributionContactId); |
|
|
|
|
String receiver = null; |
|
|
|
|
if (!Objects.isNull(newDistributionContactEntity)){ |
|
|
|
|
receiver = newDistributionContactEntity.getContact(); |
|
|
|
|