md
This commit is contained in:
parent
999ed811a1
commit
2747fc93ad
@ -38,6 +38,19 @@ public interface EmisElectronicSitePagMapper extends BaseMapper<EmisElectronicSi
|
|||||||
public List<EmisElectronicSitePag> getTotalAvailablePagList(@Param("useSiteCode")String useSiteCode,@Param("prefix")String prefix);
|
public List<EmisElectronicSitePag> getTotalAvailablePagList(@Param("useSiteCode")String useSiteCode,@Param("prefix")String prefix);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select * from emis_electronic_site_pag where use_site_code='${useSiteCode}' and prefix='${prefix}' and material_code='${materialCode}' and has_bill_count>0 order by has_bill_count asc")
|
||||||
|
@ResultMap("EmisElectronicSitePagResult")
|
||||||
|
public List<EmisElectronicSitePag> selectAvailablePagListByMaterialCode(@Param("useSiteCode")String useSiteCode,@Param("prefix")String prefix,@Param("materialCode") String materialCode);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取某类面单数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Select("select sum(has_bill_count) as has_bill_count from emis_electronic_site_pag where use_site_code='${useSiteCode}' and prefix='${prefix}' and material_code='${materialCode}' and has_bill_count>0 GROUP BY material_code")
|
||||||
|
@ResultMap("EmisElectronicSitePagResult")
|
||||||
|
public int getTotalAvailablePagCount(@Param("useSiteCode")String useSiteCode,@Param("prefix")String prefix,@Param("materialCode") String materialCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单个面单是否可用
|
* 获取单个面单是否可用
|
||||||
* @return
|
* @return
|
||||||
@ -56,6 +69,15 @@ public interface EmisElectronicSitePagMapper extends BaseMapper<EmisElectronicSi
|
|||||||
public int updateRealMatchWaybill(@Param("curStartNo")String curStartNo,@Param("id")Long id);
|
public int updateRealMatchWaybill(@Param("curStartNo")String curStartNo,@Param("id")Long id);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新子单占用
|
||||||
|
* @param useQty
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Update("update emis_electronic_site_pag set has_bill_count=has_bill_count-useQty where id=${id} ")
|
||||||
|
public int updateRealMatchSubBill(@Param("useQty") Integer useQty,@Param("id")Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键查询
|
* 主键查询
|
||||||
* @param id
|
* @param id
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public interface IEmisElectronicSitePagService
|
|||||||
public Map getTotalAvailablePag(String useSiteCode, String prefix);
|
public Map getTotalAvailablePag(String useSiteCode, String prefix);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取电子面单数量
|
* 获取电子面单-主单
|
||||||
* @param useSiteCode
|
* @param useSiteCode
|
||||||
* @param prefix
|
* @param prefix
|
||||||
* @return
|
* @return
|
||||||
@ -42,6 +42,25 @@ public interface IEmisElectronicSitePagService
|
|||||||
*/
|
*/
|
||||||
public String realMatchWaybill(String useSiteCode,String prefix) throws EmisBizError;
|
public String realMatchWaybill(String useSiteCode,String prefix) throws EmisBizError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取面单数量
|
||||||
|
* @param useSiteCode
|
||||||
|
* @param prefix
|
||||||
|
* @param materialCode 1001-主单 1002-子单
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getTotalAvailablePagCount(String useSiteCode, String prefix, String materialCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 占用子单号数据
|
||||||
|
* @param useSiteCode
|
||||||
|
* @param prefix
|
||||||
|
* @param qty
|
||||||
|
* @return
|
||||||
|
* @throws EmisBizError
|
||||||
|
*/
|
||||||
|
public String realMatchSubBill(String useSiteCode,String prefix,Integer qty) throws EmisBizError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键查询
|
* 主键查询
|
||||||
* @param id
|
* @param id
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
|||||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.xdadan.erp.emis.domain.EmisElectronicSitePag;
|
import com.xdadan.erp.emis.domain.EmisElectronicSitePag;
|
||||||
@ -100,6 +101,64 @@ public class EmisElectronicSitePagServiceImpl extends EmisBaseService implements
|
|||||||
return waybillNo;
|
return waybillNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 占用子单号数量
|
||||||
|
* @param useSiteCode
|
||||||
|
* @param prefix
|
||||||
|
* @param qty
|
||||||
|
* @return
|
||||||
|
* @throws EmisBizError
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String realMatchSubBill(String useSiteCode,String prefix,Integer qty) throws EmisBizError{
|
||||||
|
|
||||||
|
// 占用子单号数量
|
||||||
|
String waybillNo = "";
|
||||||
|
String lockKey="REALMATSUBBILL_BY_SITE_LOCK";
|
||||||
|
redissonService.lock(lockKey, 120L);
|
||||||
|
|
||||||
|
// 需要加锁
|
||||||
|
int subBillCount=emisElectronicSitePagMapper.getTotalAvailablePagCount(useSiteCode,prefix,"1002");
|
||||||
|
if(subBillCount<=0){
|
||||||
|
redissonService.unlock(lockKey);
|
||||||
|
throw new EmisBizError(EmisBizErrorType.NOT_ENOUGH_PAG,"子单不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Integer hasQty=qty;
|
||||||
|
// 批量占用单号
|
||||||
|
List<EmisElectronicSitePag> subBillList= emisElectronicSitePagMapper.selectAvailablePagListByMaterialCode(useSiteCode,prefix,"1002");
|
||||||
|
for (EmisElectronicSitePag pag:subBillList) {
|
||||||
|
if(pag.getHasBillCount()>=hasQty){
|
||||||
|
// 占用子单号
|
||||||
|
emisElectronicSitePagMapper.updateRealMatchSubBill(hasQty,pag.getId());
|
||||||
|
hasQty=0;
|
||||||
|
}else{
|
||||||
|
emisElectronicSitePagMapper.updateRealMatchSubBill(pag.getHasBillCount(),pag.getId());
|
||||||
|
hasQty=hasQty-pag.getHasBillCount();
|
||||||
|
}
|
||||||
|
// 扣减完毕后退出循环
|
||||||
|
if(hasQty<=0){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
redissonService.unlock(lockKey);
|
||||||
|
return waybillNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取站点可用面单数据
|
||||||
|
* @param useSiteCode
|
||||||
|
* @param prefix
|
||||||
|
* @param materialCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getTotalAvailablePagCount(String useSiteCode, String prefix, String materialCode){
|
||||||
|
return emisElectronicSitePagMapper.getTotalAvailablePagCount(useSiteCode,prefix,materialCode);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询电子面单
|
* 查询电子面单
|
||||||
*
|
*
|
||||||
|
|||||||
@ -66,6 +66,10 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EmisTransLineMapper emisTransLineMapper;
|
private EmisTransLineMapper emisTransLineMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IEmisElectronicSitePagService emisElectronicSitePagService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直接数据查询运单列表 by billCode
|
* 直接数据查询运单列表 by billCode
|
||||||
@ -525,13 +529,26 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
*/
|
*/
|
||||||
private void addWayBill(EmisWaybill emisWaybillSave) throws EmisBizError {
|
private void addWayBill(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||||
|
|
||||||
|
// 子单号做扣减
|
||||||
|
if("1".equals(emisWaybillSave.getBlGenSubbill())) {
|
||||||
|
int subBillCount = emisElectronicSitePagService.getTotalAvailablePagCount(emisWaybillSave.getSendSiteCode(), "T7080", "1002");
|
||||||
|
if(subBillCount<=0){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.FAIL,"子单数量不足");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 公共计算部分
|
// 公共计算部分
|
||||||
calcWayBillCommonInfo(emisWaybillSave);
|
calcWayBillCommonInfo(emisWaybillSave);
|
||||||
|
|
||||||
|
|
||||||
//补齐数据
|
//补齐数据
|
||||||
emisWaybillSave.preInsert();
|
emisWaybillSave.preInsert();
|
||||||
emisWaybillMapper.insertEmisWaybill(emisWaybillSave);
|
emisWaybillMapper.insertEmisWaybill(emisWaybillSave);
|
||||||
|
|
||||||
|
// 扣减子单
|
||||||
|
emisElectronicSitePagService.realMatchSubBill(emisWaybillSave.getSendSiteCode(),"T7080",emisWaybillSave.getParcelQty());
|
||||||
|
|
||||||
|
|
||||||
// 产生主键插入其他数据
|
// 产生主键插入其他数据
|
||||||
// 插入费用
|
// 插入费用
|
||||||
List<EmisWaybillFeeitem> feeitemList=emisWaybillSave.getFeeitemList();
|
List<EmisWaybillFeeitem> feeitemList=emisWaybillSave.getFeeitemList();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user