feat(mmpac): 增加C038组织vdef7(启源单据号)重复校验逻辑
This commit is contained in:
parent
e39327ab16
commit
3b92d6f854
|
|
@ -20,6 +20,7 @@ import nc.vo.pub.billtype.BilltypeVO;
|
||||||
import nc.vo.pub.lang.UFDate;
|
import nc.vo.pub.lang.UFDate;
|
||||||
import nc.vo.pubapp.AppContext;
|
import nc.vo.pubapp.AppContext;
|
||||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||||
|
import nc.ws.opm.pub.utils.result.APIErrCodeEnum;
|
||||||
import nccloud.api.mmpac.wr.IAPIWrMaintain;
|
import nccloud.api.mmpac.wr.IAPIWrMaintain;
|
||||||
import nccloud.api.rest.utils.NCCRestUtils;
|
import nccloud.api.rest.utils.NCCRestUtils;
|
||||||
import nccloud.api.rest.utils.ResultMessageUtil;
|
import nccloud.api.rest.utils.ResultMessageUtil;
|
||||||
|
|
@ -134,8 +135,8 @@ public class WrResource extends AbstractNCCRestResource {
|
||||||
BaseDAO baseDAO = new BaseDAO();
|
BaseDAO baseDAO = new BaseDAO();
|
||||||
for (AggWrVO aggWrVO : aggWrVOS) {
|
for (AggWrVO aggWrVO : aggWrVOS) {
|
||||||
List<BilltypeVO> collection = (List<BilltypeVO>) baseDAO.retrieveByClause(BilltypeVO.class, " pk_billtypecode='" + aggWrVO.getParentVO().getVtrantypecode() + "'");
|
List<BilltypeVO> collection = (List<BilltypeVO>) baseDAO.retrieveByClause(BilltypeVO.class, " pk_billtypecode='" + aggWrVO.getParentVO().getVtrantypecode() + "'");
|
||||||
if(collection==null||collection.size()==0){
|
if (collection == null || collection.size() == 0) {
|
||||||
throw new BusinessException("翻译报告类型失败,检查报告类型编码【"+aggWrVO.getParentVO().getVtrantypecode()+"】");
|
throw new BusinessException("翻译报告类型失败,检查报告类型编码【" + aggWrVO.getParentVO().getVtrantypecode() + "】");
|
||||||
}
|
}
|
||||||
aggWrVO.getParentVO().setVtrantypeid(collection.get(0).getPk_billtypeid());
|
aggWrVO.getParentVO().setVtrantypeid(collection.get(0).getPk_billtypeid());
|
||||||
aggWrVO.getParentVO().setDbilldate(new UFDate());
|
aggWrVO.getParentVO().setDbilldate(new UFDate());
|
||||||
|
|
@ -305,6 +306,19 @@ public class WrResource extends AbstractNCCRestResource {
|
||||||
Map<String, Object> bodyInfo = (Map<String, Object>) paramMap.get(BODYTABLE);
|
Map<String, Object> bodyInfo = (Map<String, Object>) paramMap.get(BODYTABLE);
|
||||||
itemInfos.add(bodyInfo);
|
itemInfos.add(bodyInfo);
|
||||||
}
|
}
|
||||||
|
// 精密(C038)专项需求,vdef7(启源MES单据号)有值且能在数据库中查到,则返回提示请勿重复添加
|
||||||
|
if ("C038".equals(headInfo.get("pk_org"))) {
|
||||||
|
if (MMValueCheck.isEmpty(headInfo.get("vdef7"))) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON("精密铸造组织需要传vdef7(启源MES单据号)的值", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||||
|
}
|
||||||
|
String vdef7 = headInfo.get("vdef7") + "";
|
||||||
|
String countSql = "select count(1) from mm_wr where dr = 0 and vdef7 = '" + vdef7 + "'";
|
||||||
|
// NCCForUAPLogger.debug("countSql = " + countSql);
|
||||||
|
Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor());
|
||||||
|
if (num > 0) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON("C038组织下单号(" + vdef7 + ")已存在,请勿重复添加", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 预处理数据:处理仓库转换和MES相关字段
|
// 预处理数据:处理仓库转换和MES相关字段
|
||||||
preProcessMesData(headInfo, itemInfos, baseDAO);
|
preProcessMesData(headInfo, itemInfos, baseDAO);
|
||||||
|
|
@ -356,11 +370,11 @@ public class WrResource extends AbstractNCCRestResource {
|
||||||
voList.add(vo);
|
voList.add(vo);
|
||||||
IAPIWrMaintain server = NCLocator.getInstance().lookup(IAPIWrMaintain.class);
|
IAPIWrMaintain server = NCLocator.getInstance().lookup(IAPIWrMaintain.class);
|
||||||
List<AggWrVO> aggWrVOS = TransferCodeToPKTool.transferAggVO(voList);
|
List<AggWrVO> aggWrVOS = TransferCodeToPKTool.transferAggVO(voList);
|
||||||
//翻译报告类型
|
// 翻译报告类型
|
||||||
for (AggWrVO aggWrVO : aggWrVOS) {
|
for (AggWrVO aggWrVO : aggWrVOS) {
|
||||||
List<BilltypeVO> collection = (List<BilltypeVO>) baseDAO.retrieveByClause(BilltypeVO.class, " pk_billtypecode='" + aggWrVO.getParentVO().getVtrantypecode() + "'");
|
List<BilltypeVO> collection = (List<BilltypeVO>) baseDAO.retrieveByClause(BilltypeVO.class, " pk_billtypecode='" + aggWrVO.getParentVO().getVtrantypecode() + "'");
|
||||||
if(collection==null||collection.size()==0){
|
if (collection == null || collection.size() == 0) {
|
||||||
throw new BusinessException("翻译报告类型失败,检查报告类型编码【"+aggWrVO.getParentVO().getVtrantypecode()+"】");
|
throw new BusinessException("翻译报告类型失败,检查报告类型编码【" + aggWrVO.getParentVO().getVtrantypecode() + "】");
|
||||||
}
|
}
|
||||||
aggWrVO.getParentVO().setVtrantypeid(collection.get(0).getPk_billtypeid());
|
aggWrVO.getParentVO().setVtrantypeid(collection.get(0).getPk_billtypeid());
|
||||||
aggWrVO.getParentVO().setDbilldate(new UFDate());
|
aggWrVO.getParentVO().setDbilldate(new UFDate());
|
||||||
|
|
@ -573,12 +587,14 @@ public class WrResource extends AbstractNCCRestResource {
|
||||||
}
|
}
|
||||||
server.delete(deleteVos.toArray(new AggWrVO[0]));
|
server.delete(deleteVos.toArray(new AggWrVO[0]));
|
||||||
return ResultMessageUtil.toJSON(new String[0], "生产报告删除成功");
|
return ResultMessageUtil.toJSON(new String[0], "生产报告删除成功");
|
||||||
} catch (Exception e) { return ResultMessageUtil.exceptionToJSON(e);
|
} catch (Exception e) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预处理数据:包含仓库转换和MES相关字段处理
|
* 预处理数据:包含仓库转换和MES相关字段处理
|
||||||
|
*
|
||||||
* @param headInfo 表头信息
|
* @param headInfo 表头信息
|
||||||
* @param itemInfos 表体信息列表
|
* @param itemInfos 表体信息列表
|
||||||
* @param baseDAO 数据库操作对象
|
* @param baseDAO 数据库操作对象
|
||||||
|
|
@ -603,13 +619,14 @@ public class WrResource extends AbstractNCCRestResource {
|
||||||
* 处理MES相关字段自动赋值
|
* 处理MES相关字段自动赋值
|
||||||
* 如果用户code是MES,那么将cbmoid保持和vbsrcid一致,cbmobid保持和vbsrcrowid一致
|
* 如果用户code是MES,那么将cbmoid保持和vbsrcid一致,cbmobid保持和vbsrcrowid一致
|
||||||
* 增加vbmobillcode单据号,通过cbmoid查询流程生产订单表的vbillcode
|
* 增加vbmobillcode单据号,通过cbmoid查询流程生产订单表的vbillcode
|
||||||
|
*
|
||||||
* @param itemMap 表体信息
|
* @param itemMap 表体信息
|
||||||
* @param baseDAO 数据库操作对象
|
* @param baseDAO 数据库操作对象
|
||||||
* @throws BusinessException 查询失败时抛出异常
|
* @throws BusinessException 查询失败时抛出异常
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void processMESFields(Map<String, Object> itemMap, BaseDAO baseDAO) throws BusinessException {
|
private void processMESFields(Map<String, Object> itemMap, BaseDAO baseDAO) throws BusinessException {
|
||||||
//检查是否需要处理MES字段
|
// 检查是否需要处理MES字段
|
||||||
// 这里可以通过上下文、用户信息或其他标识来判断
|
// 这里可以通过上下文、用户信息或其他标识来判断
|
||||||
// 暂时通过检查是否存在特定字段来判断是MES用户
|
// 暂时通过检查是否存在特定字段来判断是MES用户
|
||||||
boolean isMESUser = isMESUser(itemMap);
|
boolean isMESUser = isMESUser(itemMap);
|
||||||
|
|
@ -619,7 +636,7 @@ public class WrResource extends AbstractNCCRestResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//设置cbmoid保持和vbsrcid一致
|
// 设置cbmoid保持和vbsrcid一致
|
||||||
if (itemMap.containsKey("vbsrcid") && MMValueCheck.isNotEmpty(itemMap.get("vbsrcid"))) {
|
if (itemMap.containsKey("vbsrcid") && MMValueCheck.isNotEmpty(itemMap.get("vbsrcid"))) {
|
||||||
itemMap.put("cbmoid", itemMap.get("vbsrcid"));
|
itemMap.put("cbmoid", itemMap.get("vbsrcid"));
|
||||||
}
|
}
|
||||||
|
|
@ -650,9 +667,11 @@ public class WrResource extends AbstractNCCRestResource {
|
||||||
throw new BusinessException("处理MES字段失败:" + e.getMessage());
|
throw new BusinessException("处理MES字段失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否为MES用户
|
* 判断是否为MES用户
|
||||||
* 通过获取线程上下文中的用户编码来判断是否为MES用户
|
* 通过获取线程上下文中的用户编码来判断是否为MES用户
|
||||||
|
*
|
||||||
* @param itemMap 表体信息(保留参数以保持方法签名一致性)
|
* @param itemMap 表体信息(保留参数以保持方法签名一致性)
|
||||||
* @return 是否为MES用户
|
* @return 是否为MES用户
|
||||||
*/
|
*/
|
||||||
|
|
@ -674,6 +693,7 @@ public class WrResource extends AbstractNCCRestResource {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理仓库转换(将原有的仓库转换逻辑包装成独立函数)
|
* 处理仓库转换(将原有的仓库转换逻辑包装成独立函数)
|
||||||
|
*
|
||||||
* @param qualityInfos 质量信息列表
|
* @param qualityInfos 质量信息列表
|
||||||
* @param baseDAO 数据库操作对象
|
* @param baseDAO 数据库操作对象
|
||||||
* @throws BusinessException 转换失败时抛出异常
|
* @throws BusinessException 转换失败时抛出异常
|
||||||
|
|
@ -696,6 +716,7 @@ public class WrResource extends AbstractNCCRestResource {
|
||||||
/**
|
/**
|
||||||
* 转换仓库编码为主键
|
* 转换仓库编码为主键
|
||||||
* 首先假设传入值是主键,如果查询不到,再假设是编码进行查询
|
* 首先假设传入值是主键,如果查询不到,再假设是编码进行查询
|
||||||
|
*
|
||||||
* @param warehouseValue 仓库值(可能是主键或编码)
|
* @param warehouseValue 仓库值(可能是主键或编码)
|
||||||
* @param baseDAO 数据库操作对象
|
* @param baseDAO 数据库操作对象
|
||||||
* @return 仓库主键
|
* @return 仓库主键
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue