From 25de31fb12f1458013daeb5d3277b4bf5388b9f7 Mon Sep 17 00:00:00 2001 From: linfso Date: Sat, 27 Jul 2024 07:02:16 +0800 Subject: [PATCH] md --- .../erp/web/emis/EmisWaybillController.java | 36 ---- .../erp/emis/mapper/EmisWaybillMapper.java | 65 +++++++ .../service/impl/EmisWaybillServiceImpl.java | 162 ++++++++++++------ .../resources/mapper/EmisWaybillMapper.xml | 68 ++++++++ 4 files changed, 240 insertions(+), 91 deletions(-) diff --git a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisWaybillController.java b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisWaybillController.java index 331c02c44..ee228b785 100644 --- a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisWaybillController.java +++ b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisWaybillController.java @@ -195,42 +195,6 @@ public class EmisWaybillController extends EmisBaseController } - /** - * 该方方法不要使用,跳转到开单界面 - * @param waybillOrder - * @return - */ - @Log(title = "确认接单", businessType = BusinessType.UPDATE) - @PostMapping(value = "/confirmOrder1") - public AjaxResult confirmOrder1(@Valid @RequestBody WaybillOrder waybillOrder) - { - try { - - if(StringUtils.isEmpty(waybillOrder.getOrderSn()) ){ - return AjaxResult.error("订单号不能为空"); - } - - EmisWaybill emisWaybill = new EmisWaybill(); - emisWaybill.setOrderSn(waybillOrder.getOrderSn()); -// emisWaybill.setOrderRemark(waybillOrder.getOrderRemark()); - emisWaybillService.confirmOrder(emisWaybill); - - return AjaxResult.success("保存成功"); - }catch(EmisBizError ex){ - ex.printStackTrace(); - return AjaxResult.error("("+ex.getErrorCode()+")"+ex.getMessage()); - } - catch (Exception ex){ - ex.printStackTrace(); - // 返回子定义异常 - if(ex instanceof EmisBizError){ - return AjaxResult.error(ex.getMessage(),((EmisBizError)ex).getErrorCode()); - } - - return AjaxResult.error("服务器异常,联系客服"); - } - } - @Log(title = "取消运单", businessType = BusinessType.UPDATE) @PostMapping(value = "/cancelOrder") public AjaxResult cancelOrder(@Valid @RequestBody WaybillOrder waybillOrder) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisWaybillMapper.java b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisWaybillMapper.java index f81a10c32..678d826a3 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisWaybillMapper.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisWaybillMapper.java @@ -176,4 +176,69 @@ public interface EmisWaybillMapper extends BaseMapper */ public List getSiteDestStatInfoMap(EmisWaybill emisWaybill); + + + + + /** + * 专属业务员列表 + * @param customerCode + * @param searchValue + * @return + */ + public List selectUserBindSalesmenList(@Param("customerCode") String customerCode,@Param("searchValue")String searchValue); + + + /** + * 业务员信息查询 + * @param searchValue + * @return + */ + public List queryNewSalesmen(@Param("searchValue")String searchValue); + + + /** + * 绑定专属业务员 + * @param customerCode + * @param empCode + * @return + */ + public int insertBindSalesmen(@Param("customerCode") String customerCode,@Param("empCode") String empCode); + + + + /** + * 检查是否绑定 + * @param customerCode + * @param empCode + * @return + */ + public int checkIsBindSalesmen(@Param("customerCode") String customerCode,@Param("empCode") String empCode); + + + /** + * 检查业务员是否存在 + * @return + */ + public int checkEmpIsExist(@Param("empCode") String empCode); + + /** + * 取消绑定 + * @param customerCode + * @return + */ + public int cancelBindSalesmenDefault(@Param("customerCode") String customerCode); + + /** + * 删除绑定 + * @param customerCode + * @param empCode + * @return + */ + public int deleteBindSalesmen(@Param("customerCode") String customerCode,@Param("empCode") String empCode); + + + public int setBindSalesmenDefault(@Param("customerCode") String customerCode,@Param("empCode") String empCode); + + } diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java index 889349e9c..41185f006 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java @@ -667,7 +667,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb } } - // 新开单 + // OMS新开单,不允许修改 if(isNew){ addNewWaybillByOms(emisWaybillSave); } @@ -758,7 +758,16 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb // 基础信息更新 emisWaybillMapper.updateEmisWaybill(emisWaybillSave); + // 绑定专属业务员 + String bindEmpCode=emisWaybillSave.getTakePieceEmployeeCode(); + if(StringUtils.isEmpty(bindEmpCode)){ + bindEmpCode=emisWaybillSave.getOperateEmployeeCode(); + } + String customerCode=emisWaybillSave.getCustomerCode(); + if(!StringUtils.isEmpty(bindEmpCode)&&!StringUtils.isEmpty(customerCode)) { + bindSalesmen(bindEmpCode,customerCode); + } // 扣减子单 emisElectronicSitePagService.realMatchSubBill(emisWaybillSave.getSendSiteCode(),"T7080",emisWaybillSave.getParcelQty()); @@ -899,12 +908,17 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb emisWaybillSave.setOrderSn(orderSn); } - if( StringUtils.isAnyEmpty( - emisWaybillSave.getTransLineType(), - emisWaybillSave.getProductType() - ) - ) { - throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"线路、产品必填"); + // 下单用户必须存在 + if(StringUtils.isEmpty(emisWaybillSave.getCustomerCode())){ + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"下单客户不存在"); + } + + if( StringUtils.isEmpty(emisWaybillSave.getTransLineType())) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"线路必填"); + } + + if( StringUtils.isAnyEmpty(emisWaybillSave.getProductType())) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"产品必填"); } // 检查数据 @@ -933,9 +947,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"支付方式必填"); } - if(StringUtils.isEmpty(emisWaybillSave.getCalcFeeType())){ -// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"计费方式必填"); emisWaybillSave.setCalcFeeType("1"); } @@ -964,25 +976,28 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"收货人信息不完整,名称, 电话,国家,省份,地址必填"); } - - if(StringUtils.isEmpty(emisWaybillSave.getPackType())){ - emisWaybillSave.setPackType("2"); + // 目的网点 + if(StringUtils.isEmpty(emisWaybillSave.getDispatchUnderlingSiteCode())){ + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"收件地址不在服务区域"); } + + + // 寄件网点判断,若果没有寄件网点则使用南京分拨中心 + if(!StringUtils.isEmpty(emisWaybillSave.getSendSiteCode())) { + emisWaybillSave.setSendSiteCode("25000"); + } + + if(isNew) { - if( emisWaybillSave.getSendDate()==null ){ + if( emisWaybillSave.getSendDate()==null ){ throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"发件日期必填"); } } - // 登记网点 + // 登记网点,总部 if(isNew) { - if(!StringUtils.isEmpty(emisWaybillSave.getSendSiteCode())) { - emisWaybillSave.setRegisterSiteCode(emisWaybillSave.getSendSiteCode()); - }else{ - // 没有寄件网点则登记网点放到总部 - emisWaybillSave.setRegisterSiteCode("88888"); - } + emisWaybillSave.setRegisterSiteCode("88888"); emisWaybillSave.setRegisterManCode("1"); emisWaybillSave.setRegisterDate(new Date()); } @@ -991,11 +1006,13 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb emisWaybillSave.setDataFrom(WaybillHelper.getDataFrom()); } + + if(StringUtils.isEmpty(emisWaybillSave.getPackType())){ + emisWaybillSave.setPackType("2"); + } + // 发件网点 - if(StringUtils.isEmpty(emisWaybillSave.getSendSiteCode())){ -// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"寄件网点必填"); - emisWaybillSave.setSendSiteCode("88888"); - }else{ + if(!StringUtils.isEmpty(emisWaybillSave.getSendSiteCode())){ // 寄件网点财务中心 EmisSite sendSite = getSiteByCode(emisWaybillSave.getSendSiteCode()); if(sendSite!=null) { @@ -1005,11 +1022,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb // oms 客户必须存在 String customerCode = emisWaybillSave.getCustomerCode(); - String customerName = emisWaybillSave.getCustomerName(); - - // 订单运单初始状态 订单为已接单,运单未初始,待揽收 - emisWaybillSave.setOrderStatus("0"); - emisWaybillSave.setWaybillStatus("0"); // 计算三段码 目的网点2字码+目的地名称 String destSite3Code = ""; @@ -1034,7 +1046,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb // 下单时间 emisWaybillSave.setOrderDate(emisWaybillSave.getSendDate()); - // 订单类型 0-客户下单 + // 订单类型 0-客户下单 1-系统开单 2-预录单 emisWaybillSave.setOrderType("0"); // 寄件地址 @@ -1115,26 +1127,25 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb log.error("===OMS下单模式,计费错误:",ex.getMessage()); } - - // 开单当天不算时效 - Date estDate = getEstimateDate( - emisWaybillSave.getSendDate(),emisWaybillSave.getProductType(), - emisWaybillSave.getSendCountry(), - emisWaybillSave.getReceiveCountry(),0); - - // 预计到达时间 - log.info("预估到达时间==>"+ DateUtils.dateTime(estDate)); - emisWaybillSave.setEstimateDate(estDate); - - // 子单号 - if("1".equals(emisWaybillSave.getBlGenSubbill()) ){ - // 子单号拼接 - StringBuilder sb = new StringBuilder(); - for(int i=1;i<=emisWaybillSave.getParcelQty().intValue();i++){ - sb.append(emisWaybillSave.getBillCode()+ StringUtils.leftPad(String.valueOf(i),4,"0")+","); - } - emisWaybillSave.setBillCodeSub(sb.toString()); - } +// // 开单当天不算时效 +// Date estDate = getEstimateDate( +// emisWaybillSave.getSendDate(),emisWaybillSave.getProductType(), +// emisWaybillSave.getSendCountry(), +// emisWaybillSave.getReceiveCountry(),0); +// +// // 预计到达时间 +// log.info("预估到达时间==>"+ DateUtils.dateTime(estDate)); +// emisWaybillSave.setEstimateDate(estDate); +// +// // 子单号 +// if("1".equals(emisWaybillSave.getBlGenSubbill()) ){ +// // 子单号拼接 +// StringBuilder sb = new StringBuilder(); +// for(int i=1;i<=emisWaybillSave.getParcelQty().intValue();i++){ +// sb.append(emisWaybillSave.getBillCode()+ StringUtils.leftPad(String.valueOf(i),4,"0")+","); +// } +// emisWaybillSave.setBillCodeSub(sb.toString()); +// } } @@ -1483,6 +1494,18 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb //补齐数据 emisWaybillMapper.insertEmisWaybill(emisWaybillSave); + // 绑定专属业务员 + String bindEmpCode=emisWaybillSave.getTakePieceEmployeeCode(); + if(StringUtils.isEmpty(bindEmpCode)){ + bindEmpCode=emisWaybillSave.getOperateEmployeeCode(); + } + String customerCode=emisWaybillSave.getCustomerCode(); + + if(!StringUtils.isEmpty(bindEmpCode)&&!StringUtils.isEmpty(customerCode)) { + bindSalesmen(bindEmpCode,customerCode); + } + + // 扣减子单 emisElectronicSitePagService.realMatchSubBill(emisWaybillSave.getSendSiteCode(),"T7080",emisWaybillSave.getParcelQty()); @@ -1567,6 +1590,28 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb } + public int bindSalesmen(String empCode,String customerCode) throws EmisBizError { + + int eCnt=emisWaybillMapper.checkEmpIsExist(empCode); + if(eCnt==0){ + return 0; + } + + int cnt=emisWaybillMapper.checkIsBindSalesmen(customerCode,empCode); + if(cnt==0){ + emisWaybillMapper.insertBindSalesmen(customerCode,empCode); + } + + // 取消全部默认 + emisWaybillMapper.cancelBindSalesmenDefault(customerCode); + + // 设置默认 + emisWaybillMapper.setBindSalesmenDefault(customerCode,empCode); + + return 1; + } + + /** * Oms 新开单 * @param emisWaybillSave @@ -1577,12 +1622,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb // 公共计算部分 calcWayBillCommonInfoByOms(emisWaybillSave,true); - //补齐数据 + // 插入运单数据 emisWaybillMapper.insertEmisWaybill(emisWaybillSave); - // 扣减子单 -// emisElectronicSitePagService.realMatchSubBill(emisWaybillSave.getSendSiteCode(),"T7080",emisWaybillSave.getParcelQty()); - // 产生主键插入其他数据 // 插入费用 List feeitemList=emisWaybillSave.getFeeitemList(); @@ -1643,10 +1685,20 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb emisWaybillSave.preUpdate(); - // 基础信息更新 emisWaybillMapper.updateEmisWaybill(emisWaybillSave); + // 绑定专属业务员 + String bindEmpCode=emisWaybillSave.getTakePieceEmployeeCode(); + if(StringUtils.isEmpty(bindEmpCode)){ + bindEmpCode=emisWaybillSave.getOperateEmployeeCode(); + } + String customerCode=emisWaybillSave.getCustomerCode(); + + if(!StringUtils.isEmpty(bindEmpCode)&&!StringUtils.isEmpty(customerCode)) { + bindSalesmen(bindEmpCode,customerCode); + } + // 删除旧信息 emisWaybillFeeitemMapper.deleteEmisWaybillFeeitemByWaybillId(emisWaybillSave.getId()); diff --git a/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml b/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml index 4081c7dcf..d2e3fc22a 100644 --- a/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml @@ -2381,4 +2381,72 @@ #{id} + + + + + + + + + + + + + + + + + update sys_oms_user_bind_emp set default_flag='0' where customer_code=#{customerCode} + + + + update sys_oms_user_bind_emp set default_flag='1' where customer_code=#{customerCode} and emp_code=#{empCode} + + + + delete from sys_oms_user_bind_emp where customer_code=#{customerCode} and emp_code=#{empCode} + + + + insert into sys_oms_user_bind_emp(customer_code,emp_code) values(#{customerCode}, #{empCode}) + \ No newline at end of file