2025-08-25 10:38:31 +08:00
|
|
|
//
|
|
|
|
// Source code recreated from a .class file by IntelliJ IDEA
|
|
|
|
// (powered by FernFlower decompiler)
|
|
|
|
//
|
|
|
|
|
|
|
|
package nccloud.openapi.mmbd.bom;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2025-08-26 09:24:51 +08:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2025-08-25 10:38:31 +08:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import javax.ws.rs.Consumes;
|
|
|
|
import javax.ws.rs.POST;
|
|
|
|
import javax.ws.rs.Path;
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
import nc.bs.framework.common.NCLocator;
|
2025-08-26 09:24:51 +08:00
|
|
|
import nc.itf.bd.bom.bom0202.IBomBillMaintainService;
|
|
|
|
import nc.itf.bd.bom.bom0202.IBomBillQueryService;
|
|
|
|
import nc.mmbd.utils.factoryparam.MMBDFactoryParameter;
|
2025-08-25 10:38:31 +08:00
|
|
|
import nc.util.mmf.framework.base.MMValueCheck;
|
2025-08-26 09:24:51 +08:00
|
|
|
import nc.vo.bd.bom.bom0202.entity.AggBomVO;
|
|
|
|
import nc.vo.bd.bom.bom0202.entity.BomItemVO;
|
|
|
|
import nc.vo.bd.bom.bom0202.entity.BomReplVO;
|
|
|
|
import nc.vo.ml.NCLangRes4VoTransl;
|
|
|
|
import nc.vo.pub.BusinessException;
|
|
|
|
import nc.vo.pub.lang.UFDouble;
|
2025-08-25 10:38:31 +08:00
|
|
|
import nccloud.api.mmbd.bom.IAPIBomBusinessService;
|
|
|
|
import nccloud.api.rest.utils.ResultMessageUtil;
|
2025-08-26 09:24:51 +08:00
|
|
|
import nccloud.framework.core.exception.ExceptionUtils;
|
|
|
|
import nccloud.framework.service.ServiceLocator;
|
2025-08-25 10:38:31 +08:00
|
|
|
import nccloud.ws.rest.resource.AbstractNCCRestResource;
|
|
|
|
import org.json.JSONString;
|
|
|
|
@Path("mmbd/bom")
|
|
|
|
public class BomResource extends AbstractNCCRestResource {
|
|
|
|
public BomResource() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@POST
|
|
|
|
@Path("operation/add")
|
|
|
|
@Consumes({"application/json"})
|
|
|
|
@Produces({"application/json"})
|
|
|
|
public JSONString insert(JSONObject para) {
|
|
|
|
List<Map<String, Object>> paramList = (List)para.get("data");
|
|
|
|
if (MMValueCheck.isEmpty(paramList)) {
|
|
|
|
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含表头信息和表体信息", "1");
|
|
|
|
} else {
|
|
|
|
IAPIBomBusinessService service = (IAPIBomBusinessService)NCLocator.getInstance().lookup(IAPIBomBusinessService.class);
|
|
|
|
JSONString result = service.insert(paramList);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@POST
|
|
|
|
@Path("add")
|
|
|
|
@Consumes({"application/json"})
|
|
|
|
@Produces({"application/json"})
|
|
|
|
public JSONString insert(List<Map<String, Object>> paramList) {
|
|
|
|
if (MMValueCheck.isEmpty(paramList)) {
|
|
|
|
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含表头信息和表体信息", "1");
|
|
|
|
} else {
|
|
|
|
IAPIBomBusinessService service = (IAPIBomBusinessService)NCLocator.getInstance().lookup(IAPIBomBusinessService.class);
|
|
|
|
JSONString result = service.insert(paramList);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@POST
|
|
|
|
@Path("operation/update")
|
|
|
|
@Consumes({"application/json"})
|
|
|
|
@Produces({"application/json"})
|
|
|
|
public JSONString update(JSONObject para) {
|
|
|
|
List<Map<String, Object>> paramList = (List)para.get("data");
|
|
|
|
if (MMValueCheck.isEmpty(paramList)) {
|
|
|
|
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含表头信息和表体信息", "1");
|
|
|
|
} else {
|
|
|
|
IAPIBomBusinessService service = (IAPIBomBusinessService)NCLocator.getInstance().lookup(IAPIBomBusinessService.class);
|
|
|
|
JSONString result = service.update(paramList);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@POST
|
|
|
|
@Path("update")
|
|
|
|
@Consumes({"application/json"})
|
|
|
|
@Produces({"application/json"})
|
|
|
|
public JSONString update(List<Map<String, Object>> paramList) {
|
|
|
|
if (MMValueCheck.isEmpty(paramList)) {
|
|
|
|
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含表头信息和表体信息", "1");
|
|
|
|
} else {
|
|
|
|
IAPIBomBusinessService service = (IAPIBomBusinessService)NCLocator.getInstance().lookup(IAPIBomBusinessService.class);
|
|
|
|
JSONString result = service.update(paramList);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@POST
|
|
|
|
@Path("query")
|
|
|
|
@Consumes({"application/json"})
|
|
|
|
@Produces({"application/json"})
|
|
|
|
public JSONString query(Map<String, Object> paramMap) {
|
|
|
|
if (MMValueCheck.isEmpty(paramMap)) {
|
|
|
|
return ResultMessageUtil.exceptionToJSON("传入数据异常,未传入查询条件", "1");
|
|
|
|
} else {
|
|
|
|
IAPIBomBusinessService service = (IAPIBomBusinessService)NCLocator.getInstance().lookup(IAPIBomBusinessService.class);
|
|
|
|
JSONString result = service.query(paramMap);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-08-26 09:24:51 +08:00
|
|
|
@POST
|
|
|
|
@Path("bomRepl/update")
|
|
|
|
@Consumes({"application/json"})
|
|
|
|
@Produces({"application/json"})
|
|
|
|
public JSONString bomReplupdate(List<Map<String, Object>> paramMap) throws BusinessException {
|
|
|
|
if (MMValueCheck.isEmpty(paramMap)) {
|
|
|
|
return ResultMessageUtil.exceptionToJSON("传入数据异常,未传入更新数据", "1");
|
|
|
|
} else {
|
|
|
|
IAPIBomBusinessService service = (IAPIBomBusinessService)NCLocator.getInstance().lookup(IAPIBomBusinessService.class);
|
|
|
|
// List<>
|
|
|
|
IBomBillQueryService qry = (IBomBillQueryService)NCLocator.getInstance().lookup(IBomBillQueryService.class);
|
|
|
|
IBomBillMaintainService bomBillMaintainService = (IBomBillMaintainService)NCLocator.getInstance().lookup(IBomBillMaintainService.class);
|
|
|
|
|
|
|
|
List<AggBomVO> bomReplVOS=new ArrayList<>();
|
|
|
|
for (Map<String, Object> param : paramMap) {
|
|
|
|
BomReplVO bomReplVO=new BomReplVO();
|
|
|
|
String cbomid = (String) param.get("cbomid");
|
|
|
|
|
|
|
|
AggBomVO[] aggbomvos = qry.queryAggBomByBomID(new String[]{cbomid});
|
|
|
|
if (MMValueCheck.isEmpty(aggbomvos)) {
|
|
|
|
ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("bdpub", "0bdpub0057"));
|
|
|
|
}
|
|
|
|
for (AggBomVO aggBomVO : aggbomvos) {
|
|
|
|
BomItemVO[] bomItemVOS =aggBomVO.getChildrenVO();
|
|
|
|
for (BomItemVO bomItemVO : bomItemVOS) {
|
|
|
|
if(bomItemVO.getCbom_bid().equals((String) param.get("cbombid"))){
|
|
|
|
BomReplVO[] replVOS=bomItemVO.getRepl();
|
|
|
|
for (BomReplVO replVO : replVOS) {
|
|
|
|
if (replVO.getCbom_replaceid().equals((String) param.get("cbom_replaceid"))){
|
|
|
|
replVO.setIreplorder(new UFDouble((Double) param.get("ireplorder")).intValue());
|
|
|
|
replVO.setVnote("测试123");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bomItemVO.setRepl(replVOS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aggBomVO.setChildrenVO(bomItemVOS);
|
|
|
|
AggBomVO[] result = bomBillMaintainService.updateBomWithParam(new AggBomVO[]{aggBomVO}, false, false, MMBDFactoryParameter.getMMECN001Value(aggBomVO.getParentVO().getAttributeValue("pk_org").toString()).booleanValue(), true);
|
|
|
|
bomReplVOS.addAll(List.of(result));
|
|
|
|
|
|
|
|
// String jsonString=result.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return ResultMessageUtil.toJSON(bomReplVOS, "BOM更新成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-08-25 10:38:31 +08:00
|
|
|
public String getModule() {
|
|
|
|
return "mmbd";
|
|
|
|
}
|
|
|
|
}
|