精密-启源-领料接口
This commit is contained in:
parent
e58437144f
commit
f0d96b92c4
|
@ -1,13 +1,21 @@
|
|||
package nccloud.api.impl.ic.m4d;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.scmpub.query.SCMBillQuery;
|
||||
import nc.itf.ic.m4d.IMaterialOutMaintain;
|
||||
import nc.itf.mmpac.pickm.IPickmQueryService;
|
||||
import nc.itf.scmpub.reference.uap.pf.PfServiceScmUtil;
|
||||
import nc.itf.uap.pf.busiflow.PfButtonClickContext;
|
||||
import nc.jdbc.framework.processor.ColumnListProcessor;
|
||||
import nc.pubimpl.ic.api.maintain.BillMaintainTool;
|
||||
import nc.pubitf.ic.m4d.api.IMaterialOutMaintainAPI;
|
||||
import nc.util.mmf.busi.service.PFPubService;
|
||||
import nc.util.mmf.framework.base.MMValueCheck;
|
||||
import nc.vo.ic.general.define.ICBillFlag;
|
||||
import nc.vo.ic.general.define.ICBillHeadVO;
|
||||
import nc.vo.ic.general.util.ICLocationUtil;
|
||||
|
@ -16,8 +24,12 @@ import nc.vo.ic.m4d.entity.MaterialOutBodyVO;
|
|||
import nc.vo.ic.m4d.entity.MaterialOutHeadVO;
|
||||
import nc.vo.ic.m4d.entity.MaterialOutVO;
|
||||
import nc.vo.ic.pub.define.ICPubMetaNameConst;
|
||||
import nc.vo.mmpac.pickm.entity.AggPickmVO;
|
||||
import nc.vo.mmpac.pickm.entity.PickmItemVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.ISuperVO;
|
||||
import nc.vo.pub.VOStatus;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule;
|
||||
import nc.vo.scmpub.res.billtype.ICBillType;
|
||||
import nc.vo.scmpub.util.ArrayUtil;
|
||||
|
@ -27,6 +39,7 @@ import nccloud.api.impl.ic.m4d.fill.MaterialOutSaveFillValue;
|
|||
import nccloud.api.impl.ic.m4d.fill.MaterialOutUpdateFillValue;
|
||||
import nccloud.api.impl.ic.pub.check.CheckProhibitUpdateFields;
|
||||
import nccloud.api.uapbd.wms.utils.IWmsSyncUtils;
|
||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||
import nccloud.openapi.ic.util.ICAPILocationVOUtils;
|
||||
import nccloud.openapi.scmpub.pub.TransferCodeToPKTool;
|
||||
import nccloud.openapi.scmpub.pub.TransferMapToVOTool;
|
||||
|
@ -43,8 +56,15 @@ import java.util.*;
|
|||
*/
|
||||
|
||||
public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain {
|
||||
private BaseDAO baseDAO = null;
|
||||
|
||||
private BaseDAO getDao() {
|
||||
if (this.baseDAO == null) {
|
||||
this.baseDAO = new BaseDAO();
|
||||
}
|
||||
return this.baseDAO;
|
||||
}
|
||||
|
||||
// private static final BaseDAO DAO = new BaseDAO();
|
||||
private static final Log log = Log.getInstance("wmslog");
|
||||
// private static final IHttpPostOtherSys HTTP_POST_OTHER_SYS = NCLocator.getInstance().lookup(IHttpPostOtherSys.class);
|
||||
|
||||
|
@ -71,7 +91,7 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain {
|
|||
// if (isSpecialCase) {
|
||||
// processPickingPlanSpecialLogic(vos);
|
||||
// }
|
||||
//其他数据填充
|
||||
// 其他数据填充
|
||||
new MaterialOutSaveFillValue().setDefaultValue(vos);
|
||||
|
||||
IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class);
|
||||
|
@ -103,7 +123,7 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain {
|
|||
// if (isSpecialCase) {
|
||||
// processPickingPlanSpecialLogic(vos);
|
||||
// }
|
||||
//其他数据填充
|
||||
// 其他数据填充
|
||||
new MaterialOutSaveFillValue().setDefaultValue(vos);
|
||||
|
||||
IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class);
|
||||
|
@ -227,7 +247,7 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain {
|
|||
roigBvo.setAttributeValue(battr, newBvo.getAttributeValue(battr));
|
||||
bfields.add(battr);
|
||||
}
|
||||
//设置货位序列号孙表,把原来的孙表删除,修改的货位置为新增
|
||||
// 设置货位序列号孙表,把原来的孙表删除,修改的货位置为新增
|
||||
if (null != newBvo.getLocationVOs()) {
|
||||
List<ICLocationVO> allloc = new ArrayList<ICLocationVO>();
|
||||
if (null != deleteLoc && null != deleteLoc.get(roigBvo.getCgeneralbid())) {
|
||||
|
@ -244,7 +264,7 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain {
|
|||
}
|
||||
// 翻译货位
|
||||
ICAPILocationVOUtils.translate(materialOutVOs);
|
||||
//其他数据填充
|
||||
// 其他数据填充
|
||||
new MaterialOutUpdateFillValue().setDefaultValue(materialOutVOs, bfields);
|
||||
}
|
||||
}
|
||||
|
@ -337,6 +357,95 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain {
|
|||
return materialOut.insertBills(vos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject destIssue(Map<String, Object> paramMap) throws BusinessException {
|
||||
// 启源领料
|
||||
/*
|
||||
1、传入数据基本非空校验
|
||||
2、根据传入的生产订单主键获取流程备料计划
|
||||
3、调用单据转换规则,备料计划VO转为材料出库VO
|
||||
4、处理材料出库VO部分字段的赋值(行数量 = 本次领料套数(启源传入)*单位主用量(备料计划))
|
||||
5、调用材料出库的保存方法
|
||||
*/
|
||||
List<String> mids;
|
||||
try {
|
||||
String sql = "SELECT cpickmid from mm_pickm WHERE dr = 0 AND fbillstatus = 1 AND csourcebillid = '[csourcebillid]'";
|
||||
sql = sql.replace("[csourcebillid]", paramMap.get("cpmohid").toString());
|
||||
mids = (List<String>) getDao().executeQuery(sql, new ColumnListProcessor());
|
||||
} catch (DAOException e) {
|
||||
throw new BusinessException(e);
|
||||
}
|
||||
if (MMValueCheck.isEmpty(mids)) {
|
||||
throw new BusinessException("没有关联审核通过的流程备料计划,无法领料!");
|
||||
}
|
||||
String[] cpickmids = mids.toArray(new String[0]);
|
||||
IPickmQueryService queryService = NCLocator.getInstance().lookup(IPickmQueryService.class);
|
||||
AggPickmVO[] pickmVOS = queryService.queryBillsByPks(cpickmids);
|
||||
if (MMValueCheck.isEmpty(pickmVOS)) {
|
||||
throw new BusinessException("没有关联审核通过的流程备料计划,无法领料!");
|
||||
}
|
||||
List<AggPickmVO> newVos = new ArrayList<>();
|
||||
for (AggPickmVO vo : pickmVOS) {
|
||||
if (vo.getChildrenVO() == null || vo.getChildrenVO().length == 0) {
|
||||
continue;
|
||||
}
|
||||
newVos.add(vo);
|
||||
}
|
||||
if (MMValueCheck.isEmpty(newVos)) {
|
||||
throw new BusinessException("关联的流程备料计划都没有明细行,无法领料!");
|
||||
}
|
||||
Map<String, PickmItemVO> pickmItemVOMap = new HashMap<>();
|
||||
for (AggPickmVO pickmVO : pickmVOS) {
|
||||
PickmItemVO[] pickmItemVOS = (PickmItemVO[]) pickmVO.getChildren(PickmItemVO.class);
|
||||
for (PickmItemVO pickmItemVO : pickmItemVOS) {
|
||||
pickmItemVOMap.put(pickmItemVO.getCpickm_bid(), pickmItemVO);
|
||||
}
|
||||
}
|
||||
// 调用单据转换规则转换出材料出库的VO
|
||||
MaterialOutVO[] vos = (MaterialOutVO[]) PFPubService.runChangeData("55A3", ICBillType.MaterialOut.getCode(),
|
||||
newVos.toArray(new AggPickmVO[0]), null, PfButtonClickContext.ClassifyByItfdef);
|
||||
// 设置行号
|
||||
setMaterialOutRowNum(vos);
|
||||
UFDouble num = new UFDouble(paramMap.get("num").toString());
|
||||
for (MaterialOutVO vo : vos) {
|
||||
// 处理行数量,行数量 = 本次领料套数(启源传入)*单位主用量(备料计划)
|
||||
MaterialOutBodyVO[] bodys = vo.getBodys();
|
||||
for (MaterialOutBodyVO body : bodys) {
|
||||
UFDouble num1 = num;
|
||||
// 查询上游备料计划的单位主用量
|
||||
String csourcebillbid = body.getCsourcebillbid();
|
||||
PickmItemVO pickmItemVO = pickmItemVOMap.get(csourcebillbid);
|
||||
if (pickmItemVO != null) {
|
||||
num1 = num.multiply(pickmItemVO.getNunitusenum());
|
||||
}
|
||||
// nshouldnum 应发主数量 nshouldassistnum 应发数量
|
||||
// NCCForUAPLogger.debug("nshouldnum = " + body.getNshouldnum().toString());
|
||||
// NCCForUAPLogger.debug("nshouldassistnum = " + body.getNshouldassistnum().toString());
|
||||
body.setNshouldnum(num1);
|
||||
body.setNshouldassistnum(num1);
|
||||
}
|
||||
}
|
||||
IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class);
|
||||
MaterialOutVO[] outVOS = materialOut.insertBills(vos);
|
||||
// 查询备料计划行上的成套套数 nbsetpartsnum
|
||||
List<JSONObject> numList = new ArrayList<>();
|
||||
AggPickmVO[] newPickmVOS = queryService.queryBillsByPks(cpickmids);
|
||||
for (AggPickmVO newPickmVO : newPickmVOS) {
|
||||
PickmItemVO[] pickmItemVOS = (PickmItemVO[]) newPickmVO.getChildren(PickmItemVO.class);
|
||||
for (PickmItemVO pickmItemVO : pickmItemVOS) {
|
||||
JSONObject numJson = new JSONObject();
|
||||
String nbsetpartsnum = pickmItemVO.getNbsetpartsnum().toString();
|
||||
numJson.put("nbsetpartsnum", nbsetpartsnum);
|
||||
numJson.put("cbmaterialvid", pickmItemVO.getCbmaterialvid());
|
||||
numList.add(numJson);
|
||||
}
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("outVOS", outVOS);
|
||||
result.put("numList", numList);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查是否满足特殊条件:需要同步的组织
|
||||
|
|
|
@ -7,6 +7,8 @@ package nccloud.api.ic.m4d;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import nc.vo.ic.m4d.entity.MaterialOutVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
|
||||
|
@ -24,4 +26,6 @@ public interface IAPIMaterialOutMaintain {
|
|||
MaterialOutVO[] saveByRef(List<Map<String, Object>> var1) throws BusinessException;
|
||||
|
||||
MaterialOutVO[] batchsave(List<Map<String, Object>> var1) throws BusinessException;
|
||||
|
||||
JSONObject destIssue(Map<String, Object> paramMap) throws BusinessException;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package nccloud.openapi.ic.m4d;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.scmpub.query.SCMBillQuery;
|
||||
|
@ -184,15 +185,16 @@ public class MaterialOutResource extends NCCPubRestResource {
|
|||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("operation/delete")
|
||||
@Consumes({"application/json"})
|
||||
@Produces({"application/json"})
|
||||
public JSONString delete(Map<String, Object> param) {
|
||||
Object[] paramArray = ((ArrayList)param.get("cgeneralhid")).toArray();
|
||||
Object[] paramArray = ((ArrayList) param.get("cgeneralhid")).toArray();
|
||||
String[] paramStrings = new String[paramArray.length];
|
||||
|
||||
for(int i = 0; i < paramArray.length; ++i) {
|
||||
for (int i = 0; i < paramArray.length; ++i) {
|
||||
paramStrings[i] = paramArray[i].toString();
|
||||
}
|
||||
|
||||
|
@ -342,6 +344,25 @@ public class MaterialOutResource extends NCCPubRestResource {
|
|||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("saveByQyMes")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public JSONString saveByQyMes(Map<String, Object> paramMap) {
|
||||
try {
|
||||
if (!paramMap.containsKey("num") || !paramMap.containsKey("cpmohid")) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含流程生产订单信息和领料数量信息", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
IAPIMaterialOutMaintain materialOut =
|
||||
NCLocator.getInstance().lookup(IAPIMaterialOutMaintain.class);
|
||||
JSONObject result = materialOut.destIssue(paramMap);
|
||||
return ResultMessageUtil.toJSON(result, nc.vo.ml.NCLangRes4VoTransl.getNCLangRes()
|
||||
.getStrByID("4008027_0", "04008027-0472")/* @res "材料出库单保存成功" */);
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModule() {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
Loading…
Reference in New Issue