md
This commit is contained in:
parent
d773863b89
commit
89d6f761f8
@ -162,7 +162,7 @@ public class EmisWaybillController extends EmisBaseController
|
||||
String msg="下单成功";
|
||||
try {
|
||||
|
||||
emisWaybillService.draftSubmitOrder(emisWaybillSave);
|
||||
emisWaybillService.draftSubmitOrder(emisWaybillSave,false);
|
||||
jObjOut.put("billDetail", emisWaybillSave);
|
||||
|
||||
}catch(EmisBizError ex){
|
||||
|
||||
@ -87,7 +87,9 @@ public interface IEmisWaybillService
|
||||
* @return
|
||||
* @throws EmisBizError
|
||||
*/
|
||||
public int draftSubmitOrder(EmisWaybill emisWaybill) throws EmisBizError;
|
||||
public int draftSubmitOrder(EmisWaybill emisWaybill,Boolean isOms) throws EmisBizError;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -257,13 +257,17 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int draftSubmitOrder(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||
public int draftSubmitOrder(EmisWaybill emisWaybillSave,Boolean isOms) throws EmisBizError {
|
||||
boolean isNew = true;
|
||||
EmisWaybill emisWaybillOld = null;
|
||||
|
||||
// 下单网点
|
||||
String sendSiteCode=SecurityUtils.getLoginUser().getUser().getOwnerSiteCode();
|
||||
emisWaybillSave.setSendSiteCode(sendSiteCode);
|
||||
String sendSiteCode=emisWaybillSave.getSendSiteCode();
|
||||
// 非OMS方式使用员工所属网点
|
||||
if(!isOms){
|
||||
sendSiteCode=SecurityUtils.getLoginUser().getUser().getOwnerSiteCode();
|
||||
emisWaybillSave.setSendSiteCode(sendSiteCode);
|
||||
}
|
||||
|
||||
// 如果没有单号就生成单号,如果有单号需要判断是否重复
|
||||
if( !StringUtils.isEmpty(emisWaybillSave.getBillCode()) ) {
|
||||
@ -278,11 +282,15 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
}
|
||||
|
||||
// 转换草稿数据到真实数据
|
||||
cvtWaybillDraftToReal(emisWaybillSave);
|
||||
cvtWaybillDraftToReal(emisWaybillSave,isOms);
|
||||
|
||||
|
||||
// 开始下单
|
||||
addNewWaybill(emisWaybillSave);
|
||||
if(!isOms) {
|
||||
addNewWaybill(emisWaybillSave);
|
||||
}else{
|
||||
addNewWaybillByOms(emisWaybillSave);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -293,7 +301,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
* @param emisWaybillSave
|
||||
* @throws EmisBizError
|
||||
*/
|
||||
private void cvtWaybillDraftToReal(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||
private void cvtWaybillDraftToReal(EmisWaybill emisWaybillSave,Boolean isOms) throws EmisBizError {
|
||||
|
||||
// 货物名称必填
|
||||
if(StringUtils.isEmpty(emisWaybillSave.getGoodsInfo())){
|
||||
@ -303,12 +311,14 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
// 运费必填
|
||||
if(emisWaybillSave.getFreight() == null || (
|
||||
emisWaybillSave.getFreight()!=null && emisWaybillSave.getFreight().compareTo(BigDecimal.ZERO)==0 ) ){
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "运费必须大于0");
|
||||
if(!isOms) {
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "运费必须大于0");
|
||||
}
|
||||
}
|
||||
|
||||
// 货值必填
|
||||
if(StringUtils.isEmpty(emisWaybillSave.getRealValue()) ){
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "货值必填");
|
||||
// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "货值必填");
|
||||
}
|
||||
|
||||
// 线路转换
|
||||
@ -370,19 +380,20 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
emisWaybillSave.setPickupMethod(pickupMethod);
|
||||
|
||||
// 取件员或操作员
|
||||
if("1".equals(pickupMethod)){
|
||||
SysUser empUser=getEmisStaffBySiteCodeAndEmpName(getCurrentUser().getOwnerSiteCode(),emisWaybillSave.getOperateEmployeeCode());
|
||||
if(empUser==null){
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "操作员不正确");
|
||||
if(!isOms) {
|
||||
if ("1".equals(pickupMethod)) {
|
||||
SysUser empUser = getEmisStaffBySiteCodeAndEmpName(getCurrentUser().getOwnerSiteCode(), emisWaybillSave.getOperateEmployeeCode());
|
||||
if (empUser == null) {
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "操作员不正确");
|
||||
}
|
||||
emisWaybillSave.setOperateEmployeeCode(empUser.getEmpCode());
|
||||
} else if ("2".equals(pickupMethod)) {
|
||||
SysUser empUser = getEmisStaffBySiteCodeAndEmpName(getCurrentUser().getOwnerSiteCode(), emisWaybillSave.getOperateEmployeeCode());
|
||||
if (empUser == null) {
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "取件员不正确");
|
||||
}
|
||||
emisWaybillSave.setTakePieceEmployeeCode(empUser.getEmpCode());
|
||||
}
|
||||
emisWaybillSave.setOperateEmployeeCode(empUser.getEmpCode());
|
||||
}
|
||||
else if("2".equals(pickupMethod)){
|
||||
SysUser empUser=getEmisStaffBySiteCodeAndEmpName(getCurrentUser().getOwnerSiteCode(),emisWaybillSave.getOperateEmployeeCode());
|
||||
if(empUser==null){
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "取件员不正确");
|
||||
}
|
||||
emisWaybillSave.setTakePieceEmployeeCode(empUser.getEmpCode());
|
||||
}
|
||||
|
||||
// 包装类型
|
||||
@ -420,7 +431,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
emisWaybillSave.setPackType(packTypeCvtStr);
|
||||
|
||||
|
||||
// 派送方式
|
||||
String dispatchMethod=DictUtils.getDictValue("emis_tab_dispatch_mode",emisWaybillSave.getDispatchMethod());
|
||||
if(dispatchMethod==null){
|
||||
@ -444,8 +454,13 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
if(emisCustomerUser==null){
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "月结客户不存在");
|
||||
}
|
||||
emisWaybillSave.setCustomerCode(emisCustomerUser.getCustomerCode());
|
||||
emisWaybillSave.setCustomerName(emisCustomerUser.getCustomerName());
|
||||
|
||||
// oms 单据归属为用户
|
||||
if(!isOms) {
|
||||
emisWaybillSave.setCustomerCode(emisCustomerUser.getCustomerCode());
|
||||
emisWaybillSave.setCustomerName(emisCustomerUser.getCustomerName());
|
||||
}
|
||||
|
||||
emisWaybillSave.setCustNo(emisCustomerUser.getMonthlyPayCode());
|
||||
emisWaybillSave.setPayee(emisCustomerUser.getPayee());
|
||||
emisWaybillSave.setSalesmen(emisCustomerUser.getSalesmen());
|
||||
@ -453,15 +468,17 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
}else{
|
||||
emisWaybillSave.setCustNo(null);
|
||||
// 判断现金的回款联系人和销售联系人
|
||||
SysUser payee=getEmisStaffByEmpName(emisWaybillSave.getPayee());
|
||||
if(payee==null){
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "回款联系人不存在");
|
||||
}
|
||||
if(!isOms) {
|
||||
// 判断现金的回款联系人和销售联系人
|
||||
SysUser payee = getEmisStaffByEmpName(emisWaybillSave.getPayee());
|
||||
if (payee == null) {
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "回款联系人不存在");
|
||||
}
|
||||
|
||||
SysUser salesmen=getEmisStaffByEmpName(emisWaybillSave.getSalesmen());
|
||||
if(salesmen==null){
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "销售联系人不存在");
|
||||
SysUser salesmen = getEmisStaffByEmpName(emisWaybillSave.getSalesmen());
|
||||
if (salesmen == null) {
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "销售联系人不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -480,14 +497,16 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
}
|
||||
emisWaybillSave.setCustomsClear(customsClear);
|
||||
|
||||
if(StringUtils.isEmpty(emisWaybillSave.getBlMessage())){
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "发送寄件/签收短信不正确");
|
||||
}
|
||||
if(!isOms) {
|
||||
if (StringUtils.isEmpty(emisWaybillSave.getBlMessage())) {
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "发送寄件/签收短信不正确");
|
||||
}
|
||||
|
||||
if("是".equals(emisWaybillSave.getBlMessage())){
|
||||
emisWaybillSave.setBlMessage("1");
|
||||
}else{
|
||||
emisWaybillSave.setBlMessage("0");
|
||||
if ("是".equals(emisWaybillSave.getBlMessage())) {
|
||||
emisWaybillSave.setBlMessage("1");
|
||||
} else {
|
||||
emisWaybillSave.setBlMessage("0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -521,6 +540,8 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据父区域获取行政区代码
|
||||
* @return
|
||||
@ -582,7 +603,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
// 新开单
|
||||
if(isNew){
|
||||
addNewWaybill(emisWaybillSave);
|
||||
addNewWaybill(emisWaybillSave,false);
|
||||
}
|
||||
// 运单修改
|
||||
else{
|
||||
@ -1020,27 +1041,25 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
// 登记网点
|
||||
if(isNew) {
|
||||
emisWaybillSave.setRegisterSiteCode(getCurrentUser().getOwnerSiteCode());
|
||||
emisWaybillSave.setRegisterManCode(getCurrentUser().getEmpCode());
|
||||
emisWaybillSave.setRegisterDate(new Date());
|
||||
emisWaybillSave.setRegisterSiteCode(getCurrentUser().getOwnerSiteCode());
|
||||
emisWaybillSave.setRegisterManCode(getCurrentUser().getEmpCode());
|
||||
emisWaybillSave.setRegisterDate(new Date());
|
||||
}
|
||||
|
||||
if(isNew) {
|
||||
emisWaybillSave.setDataFrom(WaybillHelper.getDataFrom());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(emisWaybillSave.getFreight().floatValue()<=0.0f){
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"运费必须大于0");
|
||||
}
|
||||
|
||||
if(emisWaybillSave.getSettlementWeight().floatValue() <=0.0f
|
||||
|| emisWaybillSave.getTotalVolume().floatValue() <=0.0f
|
||||
|| emisWaybillSave.getBillWeight().floatValue() <=0.0f
|
||||
|| emisWaybillSave.getVolumeWeight().floatValue() <=0.0f
|
||||
){
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"结算重量,体积,体积重量,实重必须大于0");
|
||||
if (emisWaybillSave.getSettlementWeight().floatValue() <= 0.0f
|
||||
|| emisWaybillSave.getTotalVolume().floatValue() <= 0.0f
|
||||
|| emisWaybillSave.getBillWeight().floatValue() <= 0.0f
|
||||
|| emisWaybillSave.getVolumeWeight().floatValue() <= 0.0f
|
||||
) {
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "结算重量,体积,体积重量,实重必须大于0");
|
||||
}
|
||||
|
||||
if(StringUtils.isAnyEmpty(
|
||||
@ -1057,7 +1076,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"计费方式必填");
|
||||
}
|
||||
|
||||
|
||||
// 发件网点
|
||||
if(StringUtils.isEmpty(emisWaybillSave.getSendSiteCode())){
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"寄件网点必填");
|
||||
@ -1328,36 +1346,33 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
private void addNewWaybill(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||
|
||||
// 子单号做扣减
|
||||
if("1".equals(emisWaybillSave.getBlGenSubbill())) {
|
||||
if ("1".equals(emisWaybillSave.getBlGenSubbill())) {
|
||||
int subBillCount = emisElectronicSitePagService.getTotalAvailablePagCount(emisWaybillSave.getSendSiteCode(), "T7080", "1002");
|
||||
if(subBillCount<=0){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"子单数量不足");
|
||||
if (subBillCount <= 0) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "子单数量不足");
|
||||
}
|
||||
}
|
||||
|
||||
// 判断网点余额-运单金额 是否足够,如果不够则不允许下单
|
||||
EmisSiteAccount emisSiteAccount=getSiteAccountBySiteCode(emisWaybillSave.getSendSiteCode());
|
||||
if(emisSiteAccount==null){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"网点结算账户不存在,请先开结算账户");
|
||||
EmisSiteAccount emisSiteAccount = getSiteAccountBySiteCode(emisWaybillSave.getSendSiteCode());
|
||||
if (emisSiteAccount == null) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "网点结算账户不存在,请先开结算账户");
|
||||
}
|
||||
|
||||
BigDecimal curMoney=emisSiteAccount.getCurMoney();
|
||||
BigDecimal closeMoney=emisSiteAccount.getCloseMoney();
|
||||
BigDecimal curMoney = emisSiteAccount.getCurMoney();
|
||||
BigDecimal closeMoney = emisSiteAccount.getCloseMoney();
|
||||
|
||||
BigDecimal newCurMoney=curMoney.subtract(emisWaybillSave.getFreight());
|
||||
if(newCurMoney.compareTo(closeMoney)==-1){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"网点余额不足,请充值");
|
||||
BigDecimal newCurMoney = curMoney.subtract(emisWaybillSave.getFreight());
|
||||
if (newCurMoney.compareTo(closeMoney) == -1) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "网点余额不足,请充值");
|
||||
}
|
||||
|
||||
// 公共计算部分
|
||||
calcWayBillCommonInfo(emisWaybillSave,true);
|
||||
|
||||
|
||||
//补齐数据
|
||||
emisWaybillMapper.insertEmisWaybill(emisWaybillSave);
|
||||
|
||||
|
||||
|
||||
// 扣减子单
|
||||
emisElectronicSitePagService.realMatchSubBill(emisWaybillSave.getSendSiteCode(),"T7080",emisWaybillSave.getParcelQty());
|
||||
|
||||
@ -1521,41 +1536,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
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();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user