md
This commit is contained in:
parent
3a367cbe89
commit
011d1cd2cd
@ -83,15 +83,35 @@ public class EmisElectronicPagController extends BaseController
|
||||
return AjaxResult.success(emisElectronicPagService.selectEmisElectronicPagById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电子面单单号
|
||||
*/
|
||||
@PostMapping(value = "/realMatchWaybill")
|
||||
public AjaxResult realMatchWaybill()
|
||||
{
|
||||
try {
|
||||
String waybillNo = emisElectronicPagService.realMatchWaybill();
|
||||
return AjaxResult.success("处理成功",waybillNo);
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return AjaxResult.error(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增电子面单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('emis:emisElectronicPag:add')")
|
||||
@Log(title = "电子面单", businessType = BusinessType.INSERT)
|
||||
@Log(title = "新增电子面单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody EmisElectronicPag emisElectronicPag)
|
||||
{
|
||||
return toAjax(emisElectronicPagService.insertEmisElectronicPag(emisElectronicPag));
|
||||
try{
|
||||
return toAjax(emisElectronicPagService.insertEmisElectronicPag(emisElectronicPag));
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return AjaxResult.error(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -13,6 +13,11 @@ package com.xdadan.erp.emis.mapper;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xdadan.erp.emis.domain.EmisElectronicPag;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.ResultMap;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* @ClassName EmisElectronicPagMapper
|
||||
* @Description <p> 电子面单 Mapper 接口 </p>
|
||||
@ -67,4 +72,16 @@ public interface EmisElectronicPagMapper extends BaseMapper<EmisElectronicPag>
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmisElectronicPagByIds(Long[] ids);
|
||||
|
||||
@Select("select count(1) from emis_electronic_pag where (${startNo}>=start_no and ${startNo}<=end_no) or (${endNo}>=start_no and ${endNo}<=end_no) ")
|
||||
public int checkPagIsExists(@Param("startNo") String startNo,@Param("endNo") String endNo);
|
||||
|
||||
|
||||
@Select("select * from emis_electronic_pag where has_bill_count>0 limit 1 ")
|
||||
@ResultMap("EmisElectronicPagResult")
|
||||
public EmisElectronicPag getOneAvailablePag();
|
||||
|
||||
|
||||
@Update("update emis_electronic_pag set cur_start_no=${curStartNo},has_bill_count=has_bill_count-1 where id=${id} ")
|
||||
public int updateRealMatchWaybill(@Param("curStartNo")String curStartNo,@Param("id")Long id);
|
||||
}
|
||||
|
||||
@ -27,6 +27,11 @@ public interface IEmisElectronicPagService
|
||||
*/
|
||||
public EmisElectronicPag selectEmisElectronicPagById(Long id);
|
||||
|
||||
|
||||
public String realMatchWaybill() throws Exception;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询电子面单列表
|
||||
*
|
||||
@ -41,7 +46,7 @@ public interface IEmisElectronicPagService
|
||||
* @param emisElectronicPag 电子面单
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmisElectronicPag(EmisElectronicPag emisElectronicPag);
|
||||
public int insertEmisElectronicPag(EmisElectronicPag emisElectronicPag) throws Exception;
|
||||
|
||||
/**
|
||||
* 修改电子面单
|
||||
|
||||
@ -10,7 +10,14 @@
|
||||
|
||||
package com.xdadan.erp.emis.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.xdadan.erp.common.core.redis.RedissonService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.xdadan.erp.emis.domain.EmisElectronicPag;
|
||||
@ -29,6 +36,11 @@ public class EmisElectronicPagServiceImpl implements IEmisElectronicPagService
|
||||
@Autowired
|
||||
private EmisElectronicPagMapper emisElectronicPagMapper;
|
||||
|
||||
@Autowired
|
||||
RedissonService redissonService;
|
||||
|
||||
public static String PAG_PREFIX="T7080";
|
||||
|
||||
/**
|
||||
* 查询电子面单
|
||||
*
|
||||
@ -41,6 +53,43 @@ public class EmisElectronicPagServiceImpl implements IEmisElectronicPagService
|
||||
return emisElectronicPagMapper.selectEmisElectronicPagById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分配电子面单
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String realMatchWaybill() throws Exception {
|
||||
// 获取电子面单号
|
||||
// 获取分段电子面单数量
|
||||
String waybillNo = "";
|
||||
String lockKey="REALMATCHWAYBILL_LOCK";
|
||||
redissonService.lock(lockKey, 120L);
|
||||
// 需要加锁
|
||||
EmisElectronicPag emisElectronicPag=emisElectronicPagMapper.getOneAvailablePag();
|
||||
if(emisElectronicPag==null){
|
||||
redissonService.unlock(lockKey);
|
||||
throw new Exception("无可用面单号");
|
||||
}
|
||||
|
||||
// 产生新单号
|
||||
String curStartNo = emisElectronicPag.getCurStartNo();
|
||||
if(StringUtils.isEmpty(curStartNo)) {
|
||||
curStartNo = emisElectronicPag.getStartNo();
|
||||
}
|
||||
|
||||
long newStartNumber = Long.valueOf(curStartNo.replace(PAG_PREFIX,""));
|
||||
newStartNumber= newStartNumber+1;
|
||||
|
||||
waybillNo=PAG_PREFIX+String.valueOf(newStartNumber);
|
||||
|
||||
// 更新当前值并且递减数量
|
||||
emisElectronicPagMapper.updateRealMatchWaybill(waybillNo,emisElectronicPag.getId());
|
||||
redissonService.unlock(lockKey);
|
||||
return waybillNo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询电子面单列表
|
||||
*
|
||||
@ -60,8 +109,16 @@ public class EmisElectronicPagServiceImpl implements IEmisElectronicPagService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertEmisElectronicPag(EmisElectronicPag emisElectronicPag)
|
||||
{
|
||||
public int insertEmisElectronicPag(EmisElectronicPag emisElectronicPag) throws Exception {
|
||||
// 检查段是否有重复
|
||||
int existsCount=emisElectronicPagMapper.checkPagIsExists(emisElectronicPag.getStartNo(),emisElectronicPag.getEndNo());
|
||||
if(existsCount > 0){
|
||||
throw new Exception("号段已存在");
|
||||
}
|
||||
|
||||
emisElectronicPag.setHasBillCount(emisElectronicPag.getBillCount());
|
||||
emisElectronicPag.setStatus("0");
|
||||
emisElectronicPag.setProvideDate(new Date());
|
||||
return emisElectronicPagMapper.insertEmisElectronicPag(emisElectronicPag);
|
||||
}
|
||||
|
||||
@ -101,4 +158,6 @@ public class EmisElectronicPagServiceImpl implements IEmisElectronicPagService
|
||||
return emisElectronicPagMapper.deleteEmisElectronicPagById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -143,4 +143,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -40,7 +40,7 @@
|
||||
<if test="prodNameEn != null and prodNameEn != ''"> and prod_name_en like concat('%', #{prodNameEn}, '%')</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="country != null and country != ''"> and country like concat('%', #{country}, '%')</if>
|
||||
<if test="transLineCode != null and transLineCode != ''"> and trans_line_code like concat('%', #{transLineCode}, '%')</if>
|
||||
<if test="transLineCode != null and transLineCode != ''"> and trans_line_code=#{transLineCode}</if>
|
||||
<if test="transLine != null and transLine != ''"> and trans_line like concat('%', #{transLine}, '%')</if>
|
||||
<if test="carryType != null and carryType != ''"> and carry_type like concat('%', #{carryType}, '%')</if>
|
||||
<if test="transType != null and transType != ''"> and trans_type like concat('%', #{transType}, '%')</if>
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
package com.xdadan.erp.web.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
|
||||
@Slf4j
|
||||
public class ConfigHelper {
|
||||
|
||||
private static byte[] keybytes = new byte[] {
|
||||
49, 50, 51, 52, 53, 80, 55, 56, 57, 64,
|
||||
65, 66, 67,
|
||||
68, 69, 70 };
|
||||
|
||||
public static String encrypt(String value) {
|
||||
String s = null;
|
||||
int mode = 1;
|
||||
try {
|
||||
Cipher cipher = initCipher(mode);
|
||||
byte[] outBytes = cipher.doFinal(value.getBytes());
|
||||
s = String.valueOf(Hex.encodeHex(outBytes));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static String decrypt(String value) {
|
||||
String s = null;
|
||||
int mode = 2;
|
||||
try {
|
||||
Cipher cipher = initCipher(mode);
|
||||
byte[] outBytes = cipher.doFinal(Hex.decodeHex(value.toCharArray()));
|
||||
s = new String(outBytes);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private static Cipher initCipher(int mode) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException {
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
Key key = new SecretKeySpec(keybytes, "AES");
|
||||
cipher.init(mode, key);
|
||||
return cipher;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String m=ConfigHelper.decrypt("513953ec53422e6d503172d5a1db9578e824220d54f5634094c6728e95e80895b510317a83f7f0b1a01998fda0d73ffc");
|
||||
System.out.println(m);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user