流程生产订单-无备料领料API
This commit is contained in:
parent
005f2a508b
commit
197dc87e5f
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding='gb2312'?>
|
||||||
|
<module>
|
||||||
|
<rest>
|
||||||
|
<resource classname="nccloud.openapi.mmpac.pickm.PmoUnpickmDeliveryReources" exinfo="无备料领料接口"/>
|
||||||
|
</rest>
|
||||||
|
|
@ -0,0 +1,264 @@
|
||||||
|
package nccloud.openapi.mmpac.pickm;
|
||||||
|
|
||||||
|
import nc.bs.dao.BaseDAO;
|
||||||
|
import nc.bs.dao.DAOException;
|
||||||
|
import nc.bs.framework.common.NCLocator;
|
||||||
|
import nc.bs.logging.Log;
|
||||||
|
import nc.bs.uapbd.util.MyHelper;
|
||||||
|
import nc.itf.mmpac.pickm.IPickmBusinessService;
|
||||||
|
import nc.itf.mmpac.pmo.pac0002.IPMOQueryService;
|
||||||
|
import nc.itf.mmpac.pmo.pac0002.IPMOTransTypeQueryService;
|
||||||
|
import nc.itf.uap.IUAPQueryBS;
|
||||||
|
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||||
|
import nc.jdbc.framework.processor.MapProcessor;
|
||||||
|
import nc.pubitf.mmpac.pickm.mo.IPickmQueryServiceForMO;
|
||||||
|
import nc.util.mmf.framework.base.MMArrayUtil;
|
||||||
|
import nc.util.mmf.framework.base.MMValueCheck;
|
||||||
|
import nc.vo.bd.stordoc.StordocVO;
|
||||||
|
import nc.vo.ml.NCLangRes4VoTransl;
|
||||||
|
import nc.vo.mmpac.pickm.entity.AggPickmVO;
|
||||||
|
import nc.vo.mmpac.pickm.entity.PickmHeadVO;
|
||||||
|
import nc.vo.mmpac.pickm.entity.PickmItemVO;
|
||||||
|
import nc.vo.mmpac.pickm.enumeration.FbillstatusEnum;
|
||||||
|
import nc.vo.mmpac.pickm.param.PickmTransParam;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.constant.PMOConstLang;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFBillstatusEnum;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFItemStatusEnum;
|
||||||
|
import nc.vo.org.OrgVO;
|
||||||
|
import nc.vo.pub.BusinessException;
|
||||||
|
import nc.vo.pub.VOStatus;
|
||||||
|
import nc.vo.pub.lang.UFBoolean;
|
||||||
|
import nc.vo.pub.lang.UFDate;
|
||||||
|
import nc.vo.pub.lang.UFDouble;
|
||||||
|
import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
||||||
|
import nc.ws.opm.pub.utils.result.APIErrCodeEnum;
|
||||||
|
import nccloud.api.rest.utils.ResultMessageUtil;
|
||||||
|
import nccloud.framework.core.exception.ExceptionUtils;
|
||||||
|
import nccloud.ws.rest.resource.AbstractNCCRestResource;
|
||||||
|
import org.json.JSONString;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程生产订单-无备料领料API
|
||||||
|
*
|
||||||
|
* @author mzr
|
||||||
|
* @date 2025/10/13
|
||||||
|
*/
|
||||||
|
@Path("mmpac/unpickm")
|
||||||
|
public class PmoUnpickmDeliveryReources extends AbstractNCCRestResource {
|
||||||
|
private static final Log logger = Log.getInstance("qyMesLog");
|
||||||
|
public BaseDAO dao;
|
||||||
|
|
||||||
|
public BaseDAO getDao() {
|
||||||
|
if (dao == null) {
|
||||||
|
dao = new BaseDAO();
|
||||||
|
}
|
||||||
|
return dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("unPickmDelivery")
|
||||||
|
@Consumes({"application/json"})
|
||||||
|
@Produces({"application/json"})
|
||||||
|
public JSONString unPickmDelivery(Map<String, Object> paramMap) {
|
||||||
|
// 参数校验
|
||||||
|
String[] fields = new String[]{"mobid", "pk_org", "item"};
|
||||||
|
for (String field : fields) {
|
||||||
|
Object keyValue = paramMap.get(field);
|
||||||
|
if (null == keyValue || "".equals(keyValue)) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含" + field, APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 流程生产订单明细id
|
||||||
|
String mobid = (String) paramMap.get("mobid");
|
||||||
|
// 组织编码
|
||||||
|
String orgCode = (String) paramMap.get("pk_org");
|
||||||
|
// 材料明细信息
|
||||||
|
List<Map<String, Object>> itemList = (List) paramMap.get("item");
|
||||||
|
for (Map<String, Object> objectMap : itemList) {
|
||||||
|
Object cbmaterialvid = objectMap.get("cbmaterialvid");
|
||||||
|
if (null == cbmaterialvid || "".equals(cbmaterialvid)) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON("传入数据异常,物料编码参数不能为空", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||||
|
}
|
||||||
|
Object nplanoutastnum = objectMap.get("nplanoutastnum");
|
||||||
|
if (null == nplanoutastnum || "".equals(nplanoutastnum) || "0".equals(nplanoutastnum)) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON("计划出库数量传入数据异常", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 查询流程生产订单
|
||||||
|
IPMOQueryService pmoQuery = NCLocator.getInstance().lookup(IPMOQueryService.class);
|
||||||
|
PMOAggVO[] pmoAggVOS = pmoQuery.queryPMOAggVOByBid(new String[]{mobid});
|
||||||
|
if (MMValueCheck.isEmpty(pmoAggVOS)) {
|
||||||
|
ExceptionUtils.wrapBusinessException("查询不到流程生产订单");
|
||||||
|
}
|
||||||
|
PMOAggVO aggvo = pmoAggVOS[0];
|
||||||
|
List<String> cmoidList = new ArrayList<>();
|
||||||
|
PMOHeadVO headvo = aggvo.getParentVO();
|
||||||
|
if (PMOFBillstatusEnum.AUDIT.equalsValue(headvo.getFbillstatus())) {
|
||||||
|
Map<String, UFBoolean> trantypeMap = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
trantypeMap = NCLocator.getInstance().lookup(IPMOTransTypeQueryService.class).getBunplannpickingByTranTypeIDs(new String[]{headvo.getCtrantypeid()});
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
nc.vo.pubapp.pattern.exception.ExceptionUtils.wrappException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trantypeMap == null || UFBoolean.FALSE.equals(trantypeMap.get(headvo.getCtrantypeid()))) {
|
||||||
|
ExceptionUtils.wrapBusinessException(PMOConstLang.getUnPickmDeliverTransTypeInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
PMOItemVO[] items = aggvo.getChildrenVO();
|
||||||
|
if (!MMArrayUtil.isEmpty(items)) {
|
||||||
|
if (items.length > 1) {
|
||||||
|
ExceptionUtils.wrapBusinessException(PMOConstLang.getSingleRowSelectedInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PMOItemVO item : items) {
|
||||||
|
if (!PMOFItemStatusEnum.PLAN.equalsValue(item.getFitemstatus())) {
|
||||||
|
cmoidList.add(item.getCmoid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cmoidList.isEmpty()) {
|
||||||
|
ExceptionUtils.wrapBusinessException(PMOConstLang.getMSG_RULE_NO_ROWDATA());
|
||||||
|
}
|
||||||
|
// 领料前校验流程生产订单
|
||||||
|
// 根据流程生产订单明细id查询备料计划
|
||||||
|
PickmTransParam param = new PickmTransParam();
|
||||||
|
param.setSourceBillRowID(mobid);
|
||||||
|
IPickmQueryServiceForMO pickmQueryServiceForMO = NCLocator.getInstance().lookup(IPickmQueryServiceForMO.class);
|
||||||
|
AggPickmVO[] vos = pickmQueryServiceForMO.queryPickmByMO(new PickmTransParam[]{param});
|
||||||
|
// 领料前校验流程备料计划
|
||||||
|
if (MMValueCheck.isEmpty(vos)) {
|
||||||
|
ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("5008100_0", "05008100-0014"));
|
||||||
|
}
|
||||||
|
if (vos.length > 1) {
|
||||||
|
ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("5008100_0", "05008100-0015"));
|
||||||
|
}
|
||||||
|
if (FbillstatusEnum.PLAN_STATE.equalsValue(vos[0].getParentVO().getFbillstatus())) {
|
||||||
|
// 只有审核态或完成态的备料计划才能进行无备料领料!
|
||||||
|
ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("5008100_0", "05008100-0016"));
|
||||||
|
}
|
||||||
|
AggPickmVO pickmVO = vos[0];
|
||||||
|
PickmHeadVO pickmHeadVO = pickmVO.getParentVO();
|
||||||
|
String cpickmid = pickmHeadVO.getCpickmid();
|
||||||
|
List<PickmItemVO> itemVOS = new ArrayList<>();
|
||||||
|
String pkOrg = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE + " = '" + orgCode + "'" + " and ISBUSINESSUNIT = 'Y'");
|
||||||
|
if (MMValueCheck.isEmpty(pkOrg) || "~".equals(pkOrg)) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON("组织编码不存在,未能在系统查询到该组织", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||||
|
}
|
||||||
|
String warehouseId = getWarehouseInfo(pkOrg);
|
||||||
|
if (MMValueCheck.isEmpty(warehouseId) || "~".equals(warehouseId)) {
|
||||||
|
return ResultMessageUtil.exceptionToJSON("请检查仓库编码是否配置正确", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||||
|
}
|
||||||
|
for (int i = 0; i < itemList.size(); i++) {
|
||||||
|
Map<String, Object> objectMap = itemList.get(i);
|
||||||
|
String cbmaterialvid = objectMap.getOrDefault("cbmaterialvid", "") + "";
|
||||||
|
Map<String, Object> materialMap = getMaterialInfo(cbmaterialvid);
|
||||||
|
if (materialMap == null || materialMap.isEmpty()) {
|
||||||
|
throw new BusinessException("传入数据异常,物料编码不存在");
|
||||||
|
}
|
||||||
|
String pkMaterial = materialMap.get("pk_material") + "";
|
||||||
|
String pkMeasdoc = materialMap.get("pk_measdoc") + "";
|
||||||
|
PickmItemVO itemVO = new PickmItemVO();
|
||||||
|
itemVO.setCpickmid(cpickmid);
|
||||||
|
itemVO.setPk_group("00");
|
||||||
|
itemVO.setPk_org(pkOrg);
|
||||||
|
itemVO.setPk_org_v(pkOrg);
|
||||||
|
itemVO.setCdeliverorgvid(pkOrg);// 发料组织
|
||||||
|
itemVO.setCdeliverorgid(pkOrg);// 发料组织
|
||||||
|
itemVO.setVrowno((i * 10) + "");// 行号
|
||||||
|
itemVO.setCbmaterialid(pkMaterial);
|
||||||
|
itemVO.setCbmaterialvid(pkMaterial);
|
||||||
|
itemVO.setCbastunitid(pkMeasdoc);
|
||||||
|
itemVO.setCbunitid(pkMeasdoc);
|
||||||
|
itemVO.setVbchangerate("1/1");
|
||||||
|
itemVO.setCoutstockid(warehouseId);// 发料仓库
|
||||||
|
// 需用日期
|
||||||
|
if (MMValueCheck.isNotEmpty(objectMap.get("drequiredate"))) {
|
||||||
|
itemVO.setDrequiredate(new UFDate(objectMap.get("drequiredate").toString()));
|
||||||
|
} else {
|
||||||
|
itemVO.setDrequiredate(new UFDate());
|
||||||
|
}
|
||||||
|
// 计划出库数量
|
||||||
|
if (MMValueCheck.isNotEmpty(objectMap.get("nplanoutastnum"))) {
|
||||||
|
UFDouble nplanoutastnum = new UFDouble(objectMap.get("nplanoutastnum").toString());
|
||||||
|
itemVO.setNplanoutastnum(nplanoutastnum);// 计划出库数量
|
||||||
|
itemVO.setNplanoutnum(nplanoutastnum);// 计划出库主数量
|
||||||
|
itemVO.setNunitastnum(nplanoutastnum);// 单位定额
|
||||||
|
itemVO.setNunitnum(nplanoutastnum);// 主单位定额
|
||||||
|
itemVO.setNunituseastnum(nplanoutastnum);// 单位用量
|
||||||
|
itemVO.setNunitusenum(nplanoutastnum);// 单位主用量
|
||||||
|
// itemVO.setAttributeValue("nastnum", nplanoutastnum);
|
||||||
|
itemVO.setAttributeValue("nquotastnum", nplanoutastnum);// 定额用量
|
||||||
|
itemVO.setAttributeValue("nquotnum", nplanoutastnum);// 主定额用量
|
||||||
|
// itemVO.setAttributeValue("ndissipationum", nplanoutastnum);
|
||||||
|
} else {
|
||||||
|
itemVO.setNplanoutnum(UFDouble.ONE_DBL);
|
||||||
|
}
|
||||||
|
itemVO.setFsupplytype(1);// 供应方式 一般发料=0,定量发料=1
|
||||||
|
if (MMValueCheck.isNotEmpty(objectMap.get("vnote"))) {
|
||||||
|
itemVO.setVbnote(objectMap.get("vnote").toString());// 备注
|
||||||
|
}
|
||||||
|
itemVO.setStatus(VOStatus.NEW);
|
||||||
|
itemVOS.add(itemVO);
|
||||||
|
}
|
||||||
|
// 调用无备料领料的标准业务方法
|
||||||
|
IPickmBusinessService service = NCLocator.getInstance().lookup(IPickmBusinessService.class);
|
||||||
|
service.noItemsDeliverMaterial(itemVOS.toArray(new PickmItemVO[0]));
|
||||||
|
return ResultMessageUtil.toJSON(true, "操作成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("未备料领料操作异常", e);
|
||||||
|
return ResultMessageUtil.exceptionToJSON(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getWarehouseInfo(String pk_org) throws DAOException {
|
||||||
|
Map<String, String> configParams = MyHelper.getConfigParams("jm-config", null);
|
||||||
|
String warehouseCode = configParams.get("warehouseCode");
|
||||||
|
SqlBuilder sqlBuilder = new SqlBuilder();
|
||||||
|
sqlBuilder.append(" select " + StordocVO.PK_STORDOC);
|
||||||
|
sqlBuilder.append(" from " + StordocVO.getDefaultTableName());
|
||||||
|
sqlBuilder.append(" where dr = 0");
|
||||||
|
sqlBuilder.append(" and ");
|
||||||
|
sqlBuilder.append(StordocVO.CODE, warehouseCode);
|
||||||
|
sqlBuilder.append(" and ");
|
||||||
|
sqlBuilder.append(StordocVO.PK_ORG, pk_org);
|
||||||
|
String warehouseId = (String) getDao().executeQuery(sqlBuilder.toString(), new ColumnProcessor());
|
||||||
|
return warehouseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取物料的信息
|
||||||
|
*
|
||||||
|
* @param cbmaterialvid
|
||||||
|
* @return
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
private Map<String, Object> getMaterialInfo(String cbmaterialvid) throws BusinessException {
|
||||||
|
if (cbmaterialvid == null || cbmaterialvid.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||||
|
String sql = " select pk_material,pk_measdoc" +
|
||||||
|
" from bd_material" +
|
||||||
|
" where code = '" + cbmaterialvid + "' ";
|
||||||
|
return (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModule() {
|
||||||
|
return "mmpac";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue