|
|
@ -2,12 +2,14 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesSortShippingCheckService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesSortShippingCheckService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.log.MesServiceBusiScanLogService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesRedisLockUtil;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesRedisLockUtil;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingCheckModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingCheckModel;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesServiceBusiScanLogRepository;
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
@ -16,6 +18,7 @@ import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@ -32,11 +35,16 @@ public class MesSortShippingCheckController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesRedisLockUtil redisLockUtil;
|
|
|
|
private MesRedisLockUtil redisLockUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesServiceBusiScanLogRepository mesServiceBusiScanLogRepository;
|
|
|
|
|
|
|
|
|
|
|
|
private static final String key = ":BUSI_LOCK:SORT_SHIPPING_CHECK:";
|
|
|
|
private static final String key = ":BUSI_LOCK:SORT_SHIPPING_CHECK:";
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/query-loading-order")
|
|
|
|
@GetMapping("/query-loading-order")
|
|
|
|
@ApiOperation(value = "查询发运单")
|
|
|
|
@ApiOperation(value = "查询发运单")
|
|
|
|
public ResultBean queryLoadingOrderNo(MesShippingOrderManagement shippingOrderManagement) {
|
|
|
|
public ResultBean queryLoadingOrderNo(MesShippingOrderManagement shippingOrderManagement) {
|
|
|
|
|
|
|
|
MesServiceBusiScanLogService scanLogUtil = new MesServiceBusiScanLogService(MesSortShippingCheckController.class);
|
|
|
|
|
|
|
|
scanLogUtil.setMesServiceBusiScanLogRepository(mesServiceBusiScanLogRepository);
|
|
|
|
|
|
|
|
|
|
|
|
Boolean lockFlg = false;
|
|
|
|
Boolean lockFlg = false;
|
|
|
|
String moduleKey = null;
|
|
|
|
String moduleKey = null;
|
|
|
@ -49,25 +57,32 @@ public class MesSortShippingCheckController {
|
|
|
|
organizeCode = !StringUtils.isEmpty(shippingOrderManagement.getOrganizeCode()) ? shippingOrderManagement.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode();
|
|
|
|
organizeCode = !StringUtils.isEmpty(shippingOrderManagement.getOrganizeCode()) ? shippingOrderManagement.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode();
|
|
|
|
|
|
|
|
|
|
|
|
userInfo = !StringUtils.isEmpty(shippingOrderManagement.getUserInfo()) ? shippingOrderManagement.getUserInfo() : AuthUtil.getSessionUser().getUserName();
|
|
|
|
userInfo = !StringUtils.isEmpty(shippingOrderManagement.getUserInfo()) ? shippingOrderManagement.getUserInfo() : AuthUtil.getSessionUser().getUserName();
|
|
|
|
|
|
|
|
scanLogUtil.setOrderNo(shippingOrderManagement.getShippingCode());
|
|
|
|
|
|
|
|
scanLogUtil.setOrganizeCode(organizeCode);
|
|
|
|
|
|
|
|
scanLogUtil.setUserName(userInfo);
|
|
|
|
moduleKey = organizeCode + key + "SHIPPING_CODE:" + shippingOrderManagement.getShippingCode();
|
|
|
|
moduleKey = organizeCode + key + "SHIPPING_CODE:" + shippingOrderManagement.getShippingCode();
|
|
|
|
|
|
|
|
|
|
|
|
log.info("工厂:{} 排序发运扫描发运单 --- {} --- START --- 操作人:{} --- THREAD:{}", organizeCode, moduleKey, userInfo, Thread.currentThread().getName());
|
|
|
|
scanLogUtil.info(String.format("工厂:%s 排序发运扫描发运单 --- %s --- START --- 操作人:%s --- THREAD:%s", organizeCode, moduleKey, userInfo, Thread.currentThread().getName()));
|
|
|
|
|
|
|
|
|
|
|
|
//加锁
|
|
|
|
//加锁
|
|
|
|
lockFlg = redisLockUtil.redisLock(moduleKey);
|
|
|
|
lockFlg = redisLockUtil.redisLock(moduleKey);
|
|
|
|
|
|
|
|
|
|
|
|
log.info("工厂:{} 排序发运扫描发运单 --- {} --- LOCKED --- 操作人:{} --- THREAD:{}", organizeCode, moduleKey, userInfo, Thread.currentThread().getName());
|
|
|
|
scanLogUtil.info(String.format("工厂:%s 排序发运扫描发运单 --- %s --- LOCKED --- 操作人:%s --- THREAD:%s", organizeCode, moduleKey, userInfo, Thread.currentThread().getName()));
|
|
|
|
|
|
|
|
|
|
|
|
// 数据校验
|
|
|
|
// 数据校验
|
|
|
|
ValidatorBean.checkNotNull(shippingOrderManagement.getShippingCode(), "发运单不能为空");
|
|
|
|
ValidatorBean.checkNotNull(shippingOrderManagement.getShippingCode(), "发运单不能为空");
|
|
|
|
shippingOrderManagement.setOrganizeCode(organizeCode);
|
|
|
|
shippingOrderManagement.setOrganizeCode(organizeCode);
|
|
|
|
ConvertBean.serviceModelUpdate(shippingOrderManagement, userInfo);
|
|
|
|
ConvertBean.serviceModelUpdate(shippingOrderManagement, userInfo);
|
|
|
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
MesSortShippingCheckModel model = sortShippingCheckService.doShippingOrderNoQuery(shippingOrderManagement);
|
|
|
|
MesSortShippingCheckModel model = sortShippingCheckService.doShippingOrderNoQuery(shippingOrderManagement);
|
|
|
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
|
|
|
|
scanLogUtil.info("扫描发运单执行结束", end - start);
|
|
|
|
return ResultBean.success(model.getMsg()).setResultObject(model);
|
|
|
|
return ResultBean.success(model.getMsg()).setResultObject(model);
|
|
|
|
} catch (ImppBusiException imppException) {
|
|
|
|
} catch (ImppBusiException imppException) {
|
|
|
|
|
|
|
|
scanLogUtil.error(imppException.getErrorMsg());
|
|
|
|
return ResultBean.fail(imppException);
|
|
|
|
return ResultBean.fail(imppException);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
scanLogUtil.error(ExceptionUtils.getStackTrace(e));
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
//解锁
|
|
|
|
//解锁
|
|
|
@ -75,12 +90,15 @@ public class MesSortShippingCheckController {
|
|
|
|
redisLockUtil.redisUnLock(lockFlg, moduleKey);
|
|
|
|
redisLockUtil.redisUnLock(lockFlg, moduleKey);
|
|
|
|
log.info("工厂:{} 排序发运扫描发运单 --- {} --- UNLOCK --- 操作人:{} --- THREAD:{}", organizeCode, moduleKey, userInfo, Thread.currentThread().getName());
|
|
|
|
log.info("工厂:{} 排序发运扫描发运单 --- {} --- UNLOCK --- 操作人:{} --- THREAD:{}", organizeCode, moduleKey, userInfo, Thread.currentThread().getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scanLogUtil.flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/scan-sn")
|
|
|
|
@PostMapping("/scan-sn")
|
|
|
|
@ApiOperation(value = "扫描条码")
|
|
|
|
@ApiOperation(value = "扫描条码")
|
|
|
|
public ResultBean saveSn(@RequestBody MesSortShippingCheckModel model) {
|
|
|
|
public ResultBean saveSn(@RequestBody MesSortShippingCheckModel model) {
|
|
|
|
|
|
|
|
MesServiceBusiScanLogService scanLogUtil = new MesServiceBusiScanLogService(MesSortShippingCheckController.class);
|
|
|
|
|
|
|
|
scanLogUtil.setMesServiceBusiScanLogRepository(mesServiceBusiScanLogRepository);
|
|
|
|
|
|
|
|
|
|
|
|
Boolean lockFlg = false;
|
|
|
|
Boolean lockFlg = false;
|
|
|
|
String moduleKey = null;
|
|
|
|
String moduleKey = null;
|
|
|
@ -93,15 +111,19 @@ public class MesSortShippingCheckController {
|
|
|
|
organizeCode = !StringUtils.isEmpty(model.getOrganizeCode()) ? model.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode();
|
|
|
|
organizeCode = !StringUtils.isEmpty(model.getOrganizeCode()) ? model.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode();
|
|
|
|
|
|
|
|
|
|
|
|
userInfo = !StringUtils.isEmpty(model.getUserInfo()) ? model.getUserInfo() : AuthUtil.getSessionUser().getUserName();
|
|
|
|
userInfo = !StringUtils.isEmpty(model.getUserInfo()) ? model.getUserInfo() : AuthUtil.getSessionUser().getUserName();
|
|
|
|
|
|
|
|
scanLogUtil.setOrderNo(model.getShippingCode());
|
|
|
|
|
|
|
|
scanLogUtil.setOrganizeCode(organizeCode);
|
|
|
|
|
|
|
|
scanLogUtil.setUserName(userInfo);
|
|
|
|
|
|
|
|
scanLogUtil.setSn(model.getSn());
|
|
|
|
//增加单据锁
|
|
|
|
//增加单据锁
|
|
|
|
moduleKey = organizeCode + key + "SHIPPING_CODE:" + model.getShippingCode();
|
|
|
|
moduleKey = organizeCode + key + "SHIPPING_CODE:" + model.getShippingCode();
|
|
|
|
|
|
|
|
|
|
|
|
log.info("工厂:{} 排序发运扫描条码 --- {} --- START --- 操作人:{} --- THREAD:{}", organizeCode, model.getSn(), userInfo, Thread.currentThread().getName());
|
|
|
|
scanLogUtil.info(String.format("工厂:%s 排序发运扫描条码 --- %s --- START --- 操作人:%s --- THREAD:%s", organizeCode, model.getSn(), userInfo, Thread.currentThread().getName()));
|
|
|
|
|
|
|
|
|
|
|
|
//加锁
|
|
|
|
//加锁
|
|
|
|
lockFlg = redisLockUtil.redisLock(moduleKey);
|
|
|
|
lockFlg = redisLockUtil.redisLock(moduleKey);
|
|
|
|
|
|
|
|
|
|
|
|
log.info("工厂:{} 排序发运扫描条码 --- {} --- LOCKED --- 操作人:{} --- THREAD:{}", organizeCode, model.getSn(), userInfo, Thread.currentThread().getName());
|
|
|
|
scanLogUtil.info(String.format("工厂:%s 排序发运扫描条码 --- %s --- LOCKED --- 操作人:%s --- THREAD:%s", organizeCode, model.getSn(), userInfo, Thread.currentThread().getName()));
|
|
|
|
|
|
|
|
|
|
|
|
// 数据校验
|
|
|
|
// 数据校验
|
|
|
|
ValidatorBean.checkNotNull(model.getShippingCode(), "发运单不能为空");
|
|
|
|
ValidatorBean.checkNotNull(model.getShippingCode(), "发运单不能为空");
|
|
|
@ -109,11 +131,16 @@ public class MesSortShippingCheckController {
|
|
|
|
ValidatorBean.checkNotNull(model.getSn(), "条码不能为空");
|
|
|
|
ValidatorBean.checkNotNull(model.getSn(), "条码不能为空");
|
|
|
|
model.setOrganizeCode(organizeCode);
|
|
|
|
model.setOrganizeCode(organizeCode);
|
|
|
|
model.setUserInfo(userInfo);
|
|
|
|
model.setUserInfo(userInfo);
|
|
|
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
sortShippingCheckService.saveSn(model);
|
|
|
|
sortShippingCheckService.saveSn(model);
|
|
|
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
|
|
|
|
scanLogUtil.info("扫描发运条码执行结束", end - start);
|
|
|
|
return ResultBean.success(model.getMsg()).setResultObject(model);
|
|
|
|
return ResultBean.success(model.getMsg()).setResultObject(model);
|
|
|
|
} catch (ImppBusiException imppException) {
|
|
|
|
} catch (ImppBusiException imppException) {
|
|
|
|
|
|
|
|
scanLogUtil.error(imppException.getErrorMsg());
|
|
|
|
return ResultBean.fail(imppException);
|
|
|
|
return ResultBean.fail(imppException);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
scanLogUtil.error(ExceptionUtils.getStackTrace(e));
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
//解锁
|
|
|
|
//解锁
|
|
|
@ -121,6 +148,7 @@ public class MesSortShippingCheckController {
|
|
|
|
redisLockUtil.redisUnLock(lockFlg, moduleKey);
|
|
|
|
redisLockUtil.redisUnLock(lockFlg, moduleKey);
|
|
|
|
log.info("工厂:{} 排序发运扫描条码 --- {} --- UNLOCK --- 操作人:{} --- THREAD:{}", organizeCode, model.getSn(), userInfo, Thread.currentThread().getName());
|
|
|
|
log.info("工厂:{} 排序发运扫描条码 --- {} --- UNLOCK --- 操作人:{} --- THREAD:{}", organizeCode, model.getSn(), userInfo, Thread.currentThread().getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scanLogUtil.flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|