This commit is contained in:
linfso 2024-07-27 06:03:38 +08:00
parent cf40f65e9c
commit 84d7f97517
3 changed files with 165 additions and 27 deletions

View File

@ -195,9 +195,14 @@ public class EmisWaybillController extends EmisBaseController
}
/**
* 该方方法不要使用,跳转到开单界面
* @param waybillOrder
* @return
*/
@Log(title = "确认接单", businessType = BusinessType.UPDATE)
@PostMapping(value = "/confirmOrder")
public AjaxResult confirmOrder(@Valid @RequestBody WaybillOrder waybillOrder)
@PostMapping(value = "/confirmOrder1")
public AjaxResult confirmOrder1(@Valid @RequestBody WaybillOrder waybillOrder)
{
try {
@ -210,7 +215,7 @@ public class EmisWaybillController extends EmisBaseController
// emisWaybill.setOrderRemark(waybillOrder.getOrderRemark());
emisWaybillService.confirmOrder(emisWaybill);
return AjaxResult.success("取消成功");
return AjaxResult.success("保存成功");
}catch(EmisBizError ex){
ex.printStackTrace();
return AjaxResult.error("("+ex.getErrorCode()+")"+ex.getMessage());

View File

@ -130,13 +130,15 @@ public interface IEmisWaybillService
*/
public int cancelOrder(EmisWaybill emisWaybill) throws EmisBizError;
/**
* 确认订单
* @param emisWaybill
* @return
* @throws EmisBizError
*/
public int confirmOrder(EmisWaybill emisWaybill) throws EmisBizError;
/**
* 确认订单
* @param oldEmisWaybill
* @param emisWaybillSave
* @return
* @throws EmisBizError
*/
public void confirmOrder(EmisWaybill oldEmisWaybill,EmisWaybill emisWaybillSave) throws EmisBizError;
/**
* 指派业务员

View File

@ -589,7 +589,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
@Transactional
public int realSubmitOrder(EmisWaybill emisWaybillSave) throws EmisBizError {
boolean isNew = true;
EmisWaybill emisWaybillOld = null;
@ -607,6 +606,8 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
}
}
// 新开单
if(isNew){
addNewWaybill(emisWaybillSave);
@ -614,14 +615,26 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
// 运单修改
else{
// 检查是否已锁单
checkDBBillIsLock(emisWaybillOld);
// 判断是否是接单
boolean isConfirmOrder=false;
if("1".equals(emisWaybillOld.getOrderStatus())){
emisWaybillSave.setId(emisWaybillOld.getId());
emisWaybillSave.setOrderSn(emisWaybillOld.getOrderSn());
emisWaybillSave.setId(emisWaybillOld.getId());
// 把历史发货日期带过来用于重新计算预估到到时间
emisWaybillSave.setSendDate(emisWaybillOld.getSendDate());
// 开始接单
confirmOrder(emisWaybillOld,emisWaybillSave);
reUpdateWayBill(emisWaybillOld,emisWaybillSave);
}else {
// 检查是否已锁单
checkDBBillIsLock(emisWaybillOld);
emisWaybillSave.setId(emisWaybillOld.getId());
// 把历史发货日期带过来用于重新计算预估到到时间
emisWaybillSave.setSendDate(emisWaybillOld.getSendDate());
reUpdateWayBill(emisWaybillOld, emisWaybillSave);
}
}
return 1;
@ -702,29 +715,147 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
return emisWaybillMapper.cancelOrder(emisWaybill);
}
/**
* 确认订单
* @param emisWaybill
* @param oldEmisWaybill
* @param emisWaybillSave
* @return
* @throws EmisBizError
*/
@Override
public int confirmOrder(EmisWaybill emisWaybill) throws EmisBizError{
public void confirmOrder(EmisWaybill oldEmisWaybill,EmisWaybill emisWaybillSave) throws EmisBizError{
// 已接单不允许再接单
EmisWaybill emisWaybillOld = this.selectEmisWaybillByOrderSn(emisWaybill.getOrderSn());
if(emisWaybillOld==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS,"订单不存在");
}
if(OrderStatus.CANCEL.statusCode.equals(emisWaybillOld.getOrderStatus())){
if(OrderStatus.CANCEL.statusCode.equals(oldEmisWaybill.getOrderStatus())){
throw new EmisBizError(EmisBizErrorType.FAIL,"订单已取消");
}
if(!OrderStatus.INIT.statusCode.equals(emisWaybillOld.getOrderStatus())){
if(!OrderStatus.INIT.statusCode.equals(oldEmisWaybill.getOrderStatus())){
throw new EmisBizError(EmisBizErrorType.FAIL,"已接单");
}
return emisWaybillMapper.confirmOrder(emisWaybill);
if(!WaybillStatus.INIT.statusCode.equals(oldEmisWaybill.getWaybillStatus())){
throw new EmisBizError(EmisBizErrorType.FAIL,"已揽收");
}
// 子单号做扣减
if ("1".equals(emisWaybillSave.getBlGenSubbill())) {
int subBillCount = emisElectronicSitePagService.getTotalAvailablePagCount(emisWaybillSave.getSendSiteCode(), "T7080", "1002");
if (subBillCount <= 0) {
throw new EmisBizError(EmisBizErrorType.FAIL, "子单数量不足");
}
}
emisWaybillSave.setId(oldEmisWaybill.getId());
// 公共计算部分
calcWayBillCommonInfo(emisWaybillSave,true);
emisWaybillSave.preUpdate();
// 变为已接单
emisWaybillSave.setOrderStatus("1");
// 基础信息更新
emisWaybillMapper.updateEmisWaybill(emisWaybillSave);
// 扣减子单
emisElectronicSitePagService.realMatchSubBill(emisWaybillSave.getSendSiteCode(),"T7080",emisWaybillSave.getParcelQty());
// 删除旧信息
emisWaybillFeeitemMapper.deleteEmisWaybillFeeitemByWaybillId(emisWaybillSave.getId());
emisWaybillCargoMapper.deleteEmisWaybillCargoByWaybillId(emisWaybillSave.getId());
// 产生主键插入其他数据
// 插入费用
List<EmisWaybillFeeitem> feeitemList=emisWaybillSave.getFeeitemList();
if(!CollectionUtils.isEmpty(feeitemList)){
for (EmisWaybillFeeitem feeItem:feeitemList) {
feeItem.setWaybillId(emisWaybillSave.getId());
emisWaybillFeeitemMapper.insertEmisWaybillFeeitem(feeItem);
}
}
// 插入商品信息
if(!CollectionUtil.isEmpty(emisWaybillSave.getCargoList() )){
List<EmisWaybillCargo> cargoList=emisWaybillSave.getCargoList();
for (EmisWaybillCargo cargoItem:cargoList) {
cargoItem.setWaybillId(emisWaybillSave.getId());
emisWaybillCargoMapper.insertEmisWaybillCargo(cargoItem);
}
}
// 保存货物图片
if(!StringUtils.isEmpty(emisWaybillSave.getGoodsPics())){
if(CollectionUtil.isEmpty(emisWaybillSave.getAttachmentList() )){
List<EmisWaybillAttachment> attachmentList = new ArrayList<EmisWaybillAttachment>();
EmisWaybillAttachment goodsPicAttachment = new EmisWaybillAttachment();
goodsPicAttachment.setAttachType(WaybillAttachType.GOODS_PIC.typeCode);
goodsPicAttachment.setBillCode(emisWaybillSave.getBillCode());
goodsPicAttachment.setFileUrl(emisWaybillSave.getGoodsPics());
attachmentList.add(goodsPicAttachment);
emisWaybillSave.setAttachmentList(attachmentList);
}
}
// 插入附件信息
if(!CollectionUtil.isEmpty(emisWaybillSave.getAttachmentList() )){
// 商品附件图片插入到附件
List<EmisWaybillAttachment> attachmentList=emisWaybillSave.getAttachmentList();
for (EmisWaybillAttachment attachmentItem:attachmentList) {
attachmentItem.setWaybillId(emisWaybillSave.getId());
attachmentItem.setBillCode(emisWaybillSave.getBillCode());
emisWaybillAttachmentMapper.insertEmisWaybillAttachment(attachmentItem);
}
}
// 占用进仓单号
if(!StringUtils.isEmpty(emisWaybillSave.getWarehouseInNo())) {
String warehouseInNo = WaybillHelper.formatQueryValue(emisWaybillSave.getWarehouseInNo());
// useWarehouseInNo(emisWaybillSave.getBillCode(),null,warehouseInNo);
useWarehouseInNo(emisWaybillSave.getBillCode(),null,warehouseInNo);
}
// 插入揽收记录
ScanInfo scanInfo = new ScanInfo();
List<Map<String,Object>> scanDataList = new ArrayList<>();
scanInfo.setOpType(2);
scanInfo.setScanType(ScanType.GOT.opCode);
String dispatchOrSendManCode="";
if("1".equals(emisWaybillSave.getPickupMethod())){
dispatchOrSendManCode=emisWaybillSave.getOperateEmployeeCode();
}
else if("2".equals(emisWaybillSave.getPickupMethod())){
dispatchOrSendManCode=emisWaybillSave.getTakePieceEmployeeCode();
}
Map<String,Object> scanDateItem = new HashMap<>();
scanDateItem.put("billCode",emisWaybillSave.getBillCode());
scanDateItem.put("dispatchOrSendManCode",dispatchOrSendManCode);
scanDateItem.put("scanDate", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,emisWaybillSave.getSendDate()));
scanDateItem.put("scanWeight", "0.0");
scanDataList.add(scanDateItem);
scanInfo.setScanData(scanDataList);
try {
emisTmsScanRecordService.scan(scanInfo);
} catch (Exception e) {
e.printStackTrace();
}
// 占用进仓单号
useWarehouseInNo(emisWaybillSave.getBillCode(),oldEmisWaybill.getWarehouseInNo(),emisWaybillSave.getWarehouseInNo());
// 运单修改需要重新出账
try {
redoGenerateBill(emisWaybillSave.getBillCode());
}catch (Exception ex){
ex.printStackTrace();
}
}
/**