Compare commits
No commits in common. "4955882e0b8783e3335261046fda5a3c2c5bb590" and "d449c36194172594da6977ed7396f2bd57f8e053" have entirely different histories.
4955882e0b
...
d449c36194
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding='gb2312'?>
|
||||
<module>
|
||||
<rest>
|
||||
<resource classname="nc.api.mmpac.resource.ApplytaskRestResource" exinfo="作业量新增接口"/>
|
||||
</rest>
|
|
@ -198,31 +198,18 @@ public class PickmToBuyingreqAction implements ICommonAction {
|
|||
// PR=采购件;
|
||||
|
||||
if(null != bomcode && "2".equals(bomcode) ){
|
||||
// sql = " select martype from bd_materialstock where pk_material='" + child.getCbmaterialvid() + "' and pk_org='"+child.getPk_org()+"' and dr=0";
|
||||
// String matType = (String) dao.executeQuery(sql, new ColumnProcessor());
|
||||
// if(null == matType || "MR".equals(matType) || "".equals(matType)){
|
||||
// continue;
|
||||
// }
|
||||
sql = " select martype from bd_materialstock where pk_material='" + child.getCbmaterialvid() + "' and pk_org='"+child.getPk_org()+"' and dr=0";
|
||||
String matType = (String) dao.executeQuery(sql, new ColumnProcessor());
|
||||
if(null == matType || "PR".equals(matType) || "".equals(matType)){
|
||||
continue;
|
||||
}
|
||||
}else if(null != bomcode && "1".equals(bomcode)){
|
||||
continue;
|
||||
}else{
|
||||
sql = " select martype from bd_materialstock where pk_material='" + child.getCbmaterialvid() + "' and pk_org='"+child.getPk_org()+"' and dr=0";
|
||||
String matType = (String) dao.executeQuery(sql, new ColumnProcessor());
|
||||
if(null == matType || "MR".equals(matType) || "".equals(matType)){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
String sql="SELECT\n" +
|
||||
"\n" +
|
||||
" bd_defdoc.code \n" +
|
||||
"FROM\n" +
|
||||
" bd_defdoc where bd_defdoc.bd_defdoc.pk_defdoc='" + materalType + "'";
|
||||
BaseDAO dao = new BaseDAO();
|
||||
String bomcode = (String) dao.executeQuery(sql, new ColumnProcessor());
|
||||
if(null == bomcode || "1".equals(bomcode) || "".equals(bomcode) ){
|
||||
continue;
|
||||
}
|
||||
}else if("2".equals(materalType)){
|
||||
continue;
|
||||
}
|
||||
//只合并项目专用料数据
|
||||
if(child.getBprojectmaterial().booleanValue()){
|
||||
|
|
|
@ -245,15 +245,13 @@ public class PickmToPmo implements ICommonAction {
|
|||
// PR=²É¹º¼þ;
|
||||
|
||||
if(null != bomcode && "1".equals(bomcode) ){
|
||||
|
||||
}else if(null != bomcode && "2".equals(bomcode)){
|
||||
continue;
|
||||
}else{
|
||||
sql = " select martype from bd_materialstock where pk_material='" + child.getCbmaterialvid() + "' and pk_org='"+child.getPk_org()+"' and dr=0";
|
||||
String matType = (String) dao.executeQuery(sql, new ColumnProcessor());
|
||||
if(null == matType || "PR".equals(matType) || "".equals(matType)){
|
||||
continue;
|
||||
}
|
||||
}else if(null != bomcode && "2".equals(bomcode)){
|
||||
continue;
|
||||
}
|
||||
}else {
|
||||
String sql="SELECT\n" +
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
package nc.api.mmpac.resource;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.trade.business.HYPubBO;
|
||||
import nc.bs.trade.business.HYSuperDMO;
|
||||
import nc.impl.mmpac.apply.task.TaskAMaintainServiceImpl;
|
||||
import nc.itf.mmpac.apply.task.ITaskABusinessService;
|
||||
import nc.itf.mmpac.apply.task.ITaskAMaintainService;
|
||||
import nc.itf.mmpac.apply.task.ITaskAQueryService;
|
||||
import nc.itf.mmpac.pmo.pac0002.IPMOQueryService;
|
||||
import nc.itf.uap.IUAPQueryBS;
|
||||
import nc.itf.uap.pf.IPfExchangeService;
|
||||
import nc.util.mmf.framework.base.MMArrayUtil;
|
||||
import nc.util.mmf.framework.base.MMCollectionUtil;
|
||||
import nc.util.mmf.framework.base.MMValueCheck;
|
||||
import nc.vo.mmpac.apply.task.entity.AggTaskAVO;
|
||||
import nc.vo.mmpac.apply.task.entity.TaskABVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.CircularlyAccessibleValueObject;
|
||||
import nc.vo.pub.compiler.PfParameterVO;
|
||||
import nc.vo.pub.lang.UFDate;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
import nccloud.api.rest.utils.ResultMessageUtil;
|
||||
import nccloud.framework.service.ServiceLocator;
|
||||
import nccloud.pubitf.mmpac.pmo.service.IPublicPMOService4Activity;
|
||||
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.*;
|
||||
|
||||
@Path("mmpac/applytask")
|
||||
public class ApplytaskRestResource extends AbstractNCCRestResource {
|
||||
HYSuperDMO dmo = null;
|
||||
private static final Log logger = Log.getInstance("pmoresoucelogger");
|
||||
public HYSuperDMO getSuperDMO() {
|
||||
if (dmo == null) {
|
||||
dmo = new HYSuperDMO();
|
||||
}
|
||||
return dmo;
|
||||
}
|
||||
public ApplytaskRestResource() {
|
||||
}
|
||||
@Override
|
||||
public String getModule() {
|
||||
return "mmpac";
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/save")
|
||||
@Consumes({"application/json"})
|
||||
@Produces({"application/json"})
|
||||
public JSONString save(Map<String, Object> paramMap) throws BusinessException {
|
||||
logger.debug("=================开始进行================");
|
||||
List<Map<String, Object>> paramList = (List) paramMap.get("data");
|
||||
if (paramList == null || paramList.size() == 0) {
|
||||
throw new BusinessException("数据不能为空");
|
||||
}
|
||||
HYPubBO hybo = new HYPubBO();
|
||||
List<String> ids = new ArrayList<String>();
|
||||
List<String> bids= new ArrayList<>();
|
||||
List<AggTaskAVO> aggTaskAVOS = new ArrayList<>();
|
||||
for (Map<String, Object> param : paramList) {
|
||||
Object orderId= hybo.findColValue("mm_pmo","cpmohid"," vbillcode ='" + param.get("billcode") + "' ");
|
||||
String mrlCode= (String) param.get("mrlcode");
|
||||
String mrlid=(String) hybo.findColValue("bd_material","pk_material"," code = '" + mrlCode + "' ");
|
||||
if(mrlid == null){
|
||||
throw new BusinessException("产品编码不能为空");
|
||||
}
|
||||
if (orderId != null && !orderId.equals("")) {
|
||||
PMOAggVO[] pmoaggvos = ((IPMOQueryService)NCLocator.getInstance().lookup(IPMOQueryService.class)).queryByPks(new String[]{(String) orderId});
|
||||
if (pmoaggvos == null || pmoaggvos.length == 0) {
|
||||
|
||||
}else{
|
||||
for (PMOAggVO pmoaggvo : pmoaggvos) {
|
||||
for (PMOItemVO pmoItemVO: pmoaggvo.getChildrenVO()){
|
||||
if(pmoItemVO.getCmaterialvid().equals(mrlid)){
|
||||
ids.add(pmoaggvo.getParentVO().getCpmohid()) ;
|
||||
bids.add(pmoItemVO.getCmoid());
|
||||
AggTaskAVO[] aggvos = pushActivity((String[]) ids.toArray(new String[ids.size()]), (String[]) bids.toArray(new String[ids.size()]));
|
||||
if (aggvos == null || aggvos.length == 0) {
|
||||
|
||||
}else {
|
||||
Object cactivityid= hybo.findColValue("bd_activity","cactivityid"," vactivitycode ='G001' ");
|
||||
|
||||
for (AggTaskAVO aggTaskAVO : aggvos) {
|
||||
aggTaskAVO.getParentVO();
|
||||
TaskABVO[] taskABVOS= (TaskABVO[])aggTaskAVO.getChildrenVO();
|
||||
for (TaskABVO taskABVO : taskABVOS) {
|
||||
taskABVO.setCactivityid((String) cactivityid);
|
||||
taskABVO.setNactnum(new UFDouble((double) param.get("workTime")) );
|
||||
String month = (String) param.get("month");
|
||||
|
||||
taskABVO.setDtaskdate(UFDate.getDate(month) );
|
||||
// taskABVO.setNactnum(new UFDouble((double) param.get("workTime")) );
|
||||
|
||||
}
|
||||
aggTaskAVOS.add(aggTaskAVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ITaskAMaintainService iTaskAQueryService = NCLocator.getInstance().lookup(ITaskAMaintainService.class);
|
||||
AggTaskAVO[] sourceVOs = iTaskAQueryService.insert(aggTaskAVOS.toArray(new AggTaskAVO[aggTaskAVOS.size()]));
|
||||
JSONObject errojson = new JSONObject();
|
||||
errojson.put("data", sourceVOs);
|
||||
errojson.put("status", "1");
|
||||
errojson.put("message", "保存成功");
|
||||
errojson.put("codeList", "");
|
||||
// 返回表示操作成功的JSON字符串
|
||||
return ResultMessageUtil.toJSON(errojson);
|
||||
}
|
||||
public AggTaskAVO[] pushActivity(String[] ids, String[] bids) throws BusinessException {
|
||||
PMOAggVO[] pmoaggvos = ((IPMOQueryService)NCLocator.getInstance().lookup(IPMOQueryService.class)).queryByPks(ids);
|
||||
if (MMArrayUtil.isEmpty(pmoaggvos)) {
|
||||
return null;
|
||||
} else {
|
||||
if (MMArrayUtil.isNotEmpty(bids)) {
|
||||
Set<String> bidSet = new HashSet();
|
||||
|
||||
for(String bid : bids) {
|
||||
bidSet.add(bid);
|
||||
}
|
||||
|
||||
PMOAggVO cardAggvo = pmoaggvos[0];
|
||||
List<PMOItemVO> filterList = new ArrayList();
|
||||
PMOItemVO[] items = cardAggvo.getChildrenVO();
|
||||
if (MMArrayUtil.isNotEmpty(items)) {
|
||||
for(PMOItemVO item : items) {
|
||||
if (!MMValueCheck.isEmpty(item) && bidSet.contains(item.getCmoid())) {
|
||||
filterList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (MMCollectionUtil.isNotEmpty(filterList)) {
|
||||
cardAggvo.setChildrenVO((CircularlyAccessibleValueObject[])filterList.toArray(new PMOItemVO[filterList.size()]));
|
||||
}
|
||||
}
|
||||
|
||||
AggTaskAVO[] taskvos = ((ITaskABusinessService)NCLocator.getInstance().lookup(ITaskABusinessService.class)).fillTaskPmoInfo(pmoaggvos);
|
||||
return taskvos;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package nc.impl.pu.m23.maintain.action;
|
||||
|
||||
import nc.bs.pu.m23.maintain.ArriveInsertBP;
|
||||
import nc.bs.pu.m23.plugin.ArriveActionPlugInPoint;
|
||||
import nc.impl.pu.m23.maintain.rule.CheckBillDateRule;
|
||||
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
|
||||
import nc.vo.pu.m23.entity.ArriveVO;
|
||||
import nc.vo.pu.m23.env.ArrivalUIToBSEnv;
|
||||
|
||||
public class ArriveInsertAction {
|
||||
public ArriveInsertAction() {
|
||||
}
|
||||
|
||||
public ArriveVO[] insertArrive(ArriveVO[] voArray, ArrivalUIToBSEnv env) {
|
||||
AroundProcesser<ArriveVO> processer = new AroundProcesser(ArriveActionPlugInPoint.ArriveInsertAction);
|
||||
addBeforeRule(processer);
|
||||
ArriveInsertBP bp = new ArriveInsertBP(env);
|
||||
ArriveVO[] ret = bp.insertArrive(voArray);
|
||||
processer.after(ret);
|
||||
return ret;
|
||||
}
|
||||
private void addBeforeRule(AroundProcesser<ArriveVO> processer) {
|
||||
processer.addBeforeFinalRule(new CheckBillDateRule());
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package nc.impl.pu.m23.maintain.action;
|
||||
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.saveBeforeCheckRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.flowbiz.PMOCommitFlowCheckRule;
|
||||
import nc.bs.pu.m23.maintain.ArriveUpdateBP;
|
||||
import nc.bs.pu.m23.plugin.ArriveActionPlugInPoint;
|
||||
import nc.impl.pu.m23.maintain.rule.CheckBillDateRule;
|
||||
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
|
||||
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
|
||||
import nc.itf.pu.reference.ic.ATPServices;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||
import nc.vo.pu.m21.entity.OrderVO;
|
||||
import nc.vo.pu.m23.entity.ArriveVO;
|
||||
import nc.vo.pu.m23.env.ArrivalUIToBSEnv;
|
||||
import nc.vo.pu.m23.utils.ExtBillHasGrandsonDataUtils;
|
||||
import nc.vo.scmpub.res.billtype.POBillType;
|
||||
|
||||
public class ArriveUpdateAction {
|
||||
public ArriveUpdateAction() {
|
||||
}
|
||||
|
||||
public ArriveVO[] updateArrive(ArriveVO[] voArray, ArrivalUIToBSEnv env) {
|
||||
AroundProcesser<ArriveVO> processer = new AroundProcesser(ArriveActionPlugInPoint.ArriveUpdateAction);
|
||||
addBeforeRule(processer);
|
||||
processer.addBeforeRule(new CheckBillDateRule());
|
||||
processer.before(voArray);
|
||||
ExtBillHasGrandsonDataUtils<ArriveVO> tool = new ExtBillHasGrandsonDataUtils(voArray);
|
||||
ArriveVO[] originVOArray = (ArriveVO[])tool.getOriginBills();
|
||||
ArriveUpdateBP bp = new ArriveUpdateBP(env);
|
||||
ArriveVO[] ret = bp.updateArrive(voArray, originVOArray);
|
||||
|
||||
processer.after(ret);
|
||||
return ret;
|
||||
}
|
||||
private void addBeforeRule(AroundProcesser<ArriveVO> processer) {
|
||||
processer.addBeforeFinalRule(new CheckBillDateRule());
|
||||
}
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package nc.impl.pu.m23.maintain.rule;
|
||||
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.pubitf.so.m30.api.ISaleOrderQueryAPI;
|
||||
import nc.vo.pu.m21.entity.OrderItemVO;
|
||||
import nc.vo.pu.m21.entity.OrderVO;
|
||||
import nc.vo.pu.m23.entity.ArriveItemVO;
|
||||
import nc.vo.pu.m23.entity.ArriveVO;
|
||||
import nc.vo.pu.pub.util.BillQuery;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.so.m30.entity.SaleOrderBVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class CheckBillDateRule implements IRule<ArriveVO> {
|
||||
public CheckBillDateRule() {
|
||||
}
|
||||
// 日期格式化工具,使用Java标准库
|
||||
private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
public void process(ArriveVO[] vos) {
|
||||
|
||||
|
||||
// 提取API服务实例到循环外,提升性能
|
||||
try{for (ArriveVO vo : vos) {
|
||||
// 校验到货单主信息是否存在
|
||||
if (vo == null || vo.getHVO() == null) {
|
||||
throw new BusinessException("到货单主信息不能为空");
|
||||
}
|
||||
|
||||
Date arriveMakeDate = vo.getHVO().getDmakedate().toDate();
|
||||
// 校验制单日期是否存在
|
||||
if (arriveMakeDate == null) {
|
||||
throw new BusinessException("到货单制单日期不能为空");
|
||||
}
|
||||
|
||||
// 遍历到货单明细
|
||||
ArriveItemVO[] itemVOs = vo.getBVO();
|
||||
if (itemVOs == null || itemVOs.length==0) {
|
||||
continue; // 没有明细则跳过当前到货单处理
|
||||
}
|
||||
|
||||
for (ArriveItemVO itemVO : itemVOs) {
|
||||
// 校验明细必要字段
|
||||
if (itemVO == null) {
|
||||
throw new BusinessException("到货单明细不能为空");
|
||||
}
|
||||
String pkOrder = itemVO.getPk_order();
|
||||
String pkOrderB = itemVO.getPk_order_b();
|
||||
if (StringUtils.isEmpty(pkOrder) || StringUtils.isEmpty(pkOrderB)) {
|
||||
throw new BusinessException("采购订单ID或订单明细ID不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
// 查询对应的销售订单
|
||||
OrderVO[] orderVOs =new BillQuery<OrderVO>(OrderVO.class).query(new String[]{pkOrder});
|
||||
if (orderVOs == null || orderVOs.length == 0) {
|
||||
return;
|
||||
// throw new BusinessException("未找到ID为" + pkOrder + "的采购订单");
|
||||
}
|
||||
|
||||
// 获取订单明细
|
||||
OrderVO o = orderVOs[0];
|
||||
OrderItemVO[] orderItemVOs = o.getBVO();
|
||||
if (orderItemVOs == null || orderItemVOs.length == 0) {
|
||||
return;
|
||||
// throw new BusinessException("采购订单" + pkOrder + "没有明细数据");
|
||||
}
|
||||
|
||||
// 查找匹配的订单明细
|
||||
boolean found = false;
|
||||
for (OrderItemVO orderItem : orderItemVOs) {
|
||||
if (orderItem != null && pkOrderB.equals(orderItem.getPk_order_b())) {
|
||||
found = true;
|
||||
Date expectArriveDate = orderItem.getDplanarrvdate().toDate();
|
||||
if (expectArriveDate == null) {
|
||||
throw new BusinessException("采购订单明细" + pkOrderB + "的计划到货时间不能为空");
|
||||
}
|
||||
|
||||
// 核心逻辑:只允许提前3天到货
|
||||
// 1. 计算预计到货时间前3天的日期(最早允许的制单日期)
|
||||
Date earliestAllowedDate = addDays(expectArriveDate, -3);
|
||||
|
||||
// 2. 判断规则
|
||||
boolean isTooEarly = arriveMakeDate.before(earliestAllowedDate);
|
||||
boolean isTooLate = arriveMakeDate.after(expectArriveDate);
|
||||
|
||||
if (isTooEarly || isTooLate) {
|
||||
String errorMsg;
|
||||
if (isTooEarly) {
|
||||
errorMsg = String.format(
|
||||
"到货单制单日期(%s)早于采购订单预计到货时间(%s)超过3天,不允许保存。最早允许制单日期为%s。订单编号:%s,明细行号:%s",
|
||||
formatDate(arriveMakeDate),
|
||||
formatDate(expectArriveDate),
|
||||
formatDate(earliestAllowedDate),
|
||||
o.getHVO().getVbillcode(),
|
||||
orderItem.getCrowno()
|
||||
);
|
||||
} else { // isTooLate
|
||||
errorMsg = String.format(
|
||||
"到货单制单日期(%s)晚于采购订单预计到货时间(%s),不符合提前到货规则,不允许保存。订单编号:%s,明细行号:%s",
|
||||
formatDate(arriveMakeDate),
|
||||
formatDate(expectArriveDate),
|
||||
o.getHVO().getVbillcode(),
|
||||
orderItem.getCrowno()
|
||||
);
|
||||
}
|
||||
throw new BusinessException(errorMsg);
|
||||
}
|
||||
break; // 找到匹配明细后退出循环
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
throw new BusinessException("未找到采购订单" + pkOrder + "中ID为" + pkOrderB + "的明细");
|
||||
}
|
||||
|
||||
} catch (BusinessException e) {
|
||||
// 直接抛出业务异常,中断流程
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
// 捕获其他异常并包装为业务异常
|
||||
throw new BusinessException("校验采购订单与到货单时间关系时发生错误:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 自定义日期加减方法,替代DateUtils.addDays
|
||||
private static Date addDays(Date date, int days) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
long time = date.getTime() + (long) days * 24 * 60 * 60 * 1000;
|
||||
return new Date(time);
|
||||
}
|
||||
|
||||
// 自定义日期格式化方法,替代DateUtils.format
|
||||
private static String formatDate(Date date) {
|
||||
if (date == null) {
|
||||
return "";
|
||||
}
|
||||
synchronized (DATE_FORMATTER) { // 解决线程安全问题
|
||||
return DATE_FORMATTER.format(date);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,213 +0,0 @@
|
|||
package nc.bs.so.m30.rule.approve;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.trade.business.HYPubBO;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.jdbc.framework.processor.MapProcessor;
|
||||
import nc.vo.org.OrgVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
||||
import nc.vo.so.m30.entity.SaleOrderBVO;
|
||||
import nc.vo.so.m30.entity.SaleOrderHVO;
|
||||
import nc.vo.so.m30.entity.SaleOrderVO;
|
||||
import nc.vo.vorg.DeptVersionVO;
|
||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||
import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 销售订单推送mes
|
||||
*/
|
||||
public class AfterApprovingSynchronizeRuleQMS implements IRule<SaleOrderVO> {
|
||||
private static final String LOG_INFO_NAME = "qyMesLog";
|
||||
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
|
||||
private static final String reqUrl = "IF_QyErpApi.ashx?action=addxsht";
|
||||
private Map<String, String> configParams;
|
||||
|
||||
|
||||
public AfterApprovingSynchronizeRuleQMS() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(SaleOrderVO[] saleOrderVOs) {
|
||||
try {
|
||||
if (saleOrderVOs == null || saleOrderVOs.length == 0) {
|
||||
|
||||
return;
|
||||
}
|
||||
configParams = MyHelper.getConfigParams("xb-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
throw new BusinessException("箱变的QMS接口缺少配置");
|
||||
}
|
||||
buildSyncData(saleOrderVOs);
|
||||
} catch (Exception e) {
|
||||
ExceptionUtils.wrappException(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 构建同步数据
|
||||
*/
|
||||
private void buildSyncData(SaleOrderVO[] useVOs) throws BusinessException {
|
||||
BaseDAO baseDAO = new BaseDAO();
|
||||
Date now= new Date();
|
||||
HYPubBO hybo = new HYPubBO();
|
||||
for (SaleOrderVO vo : useVOs) {
|
||||
// 判断物料的业务单元是否是箱变公司,不是则跳过
|
||||
String pkOrg = vo.getParentVO().getPk_org();
|
||||
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if (checkIfOrg(orgCode, configParams)) {
|
||||
continue;
|
||||
}
|
||||
// 组装数据
|
||||
JSONObject singleObj = new JSONObject();
|
||||
|
||||
SaleOrderHVO pmoHeadVO = vo.getParentVO();
|
||||
SaleOrderBVO[] itemVOS=vo.getChildrenVO();
|
||||
singleObj.put("batchid",now.toString());
|
||||
singleObj.put("hth",pmoHeadVO.getVdef6());
|
||||
singleObj.put("fplx",pmoHeadVO.getDbilldate());
|
||||
String sql = " select name from bd_psndoc where cuserid = '" + pmoHeadVO.getCemployeeid() + "' ";
|
||||
String billmakerName = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
|
||||
|
||||
singleObj.put("xsy",billmakerName);
|
||||
|
||||
singleObj.put("dhdwid",pmoHeadVO.getCcustomerid());
|
||||
String customersql = " select name from bd_customer where pk_customer = '" + pmoHeadVO.getCcustomerid() + "' ";
|
||||
String customerName = (String) baseDAO.executeQuery(customersql, new ColumnProcessor());
|
||||
singleObj.put("dhdw",customerName);
|
||||
|
||||
|
||||
String lrrsql = " select user_name from sm_user where cuserid = '" + pmoHeadVO.getBillmaker() + "' ";
|
||||
String lrrName = (String) baseDAO.executeQuery(lrrsql, new ColumnProcessor());
|
||||
|
||||
singleObj.put("lrr",lrrName);
|
||||
singleObj.put("lrrq",pmoHeadVO.getDmakedate());
|
||||
singleObj.put("bz",pmoHeadVO.getVnote());
|
||||
// 处理Content数组
|
||||
JSONArray contentArray = new JSONArray();
|
||||
for (SaleOrderBVO item : itemVOS) {
|
||||
JSONObject itemObj = new JSONObject();
|
||||
// itemObj.put("sgdh", item.getSgdh());
|
||||
// itemObj.put("xshth", item.getVdef1());
|
||||
// itemObj.put("htqdxh", item.getHtqdxh());
|
||||
// Object no = hybo.findColValue("bd_material", "code", "pk_material = '"+item.getCmaterialvid()+"' ");
|
||||
//
|
||||
// Object name = hybo.findColValue("bd_material", "name", "pk_material = '"+item.getCmaterialvid()+"' ");
|
||||
String wlsql = " select code,name,materialspec,materialtype from bd_material where pk_material = '" + item.getCmaterialvid() + "' ";
|
||||
Map<String,Object> mrlmap = (Map<String, Object>) baseDAO.executeQuery(wlsql, new ColumnProcessor());
|
||||
|
||||
itemObj.put("wlbh", mrlmap.get("code"));
|
||||
itemObj.put("wlmc", mrlmap.get("name"));
|
||||
itemObj.put("wlxhgg", mrlmap.get("materialspec")+(String)mrlmap.get("materialtype"));
|
||||
itemObj.put("dhsl", item.getNastnum());
|
||||
itemObj.put("xsj", item.getNqtorigtaxprice());
|
||||
itemObj.put("bxzje", item.getNqtorigtaxprice());
|
||||
itemObj.put("jhrq", item.getDsenddate());
|
||||
itemObj.put("bz", item.getVrownote());
|
||||
contentArray.add(itemObj);
|
||||
}
|
||||
|
||||
singleObj.put("Content", contentArray);
|
||||
/*
|
||||
{
|
||||
"batchid": "XS202408001",
|
||||
"hth": "HT202408001",
|
||||
"fplx": "增值税专用发票",
|
||||
"xsy": "张三",
|
||||
"xmmc": "某项目供电设备采购",
|
||||
"dhdwid": "C001",
|
||||
"dhdw": "某电力公司",
|
||||
"lrr": "李四",
|
||||
"lrrq": "2024-08-21",
|
||||
"bz": "需加急处理",
|
||||
"Content": [
|
||||
{
|
||||
"wlbh": "ACC26711",
|
||||
"wlmc": "铜排",
|
||||
"wlxhgg": "15558190831",
|
||||
"dhsl": "200",
|
||||
"xsj": "50.00",
|
||||
"bxzje": "10000.00",
|
||||
"jhrq": "2024-09-30",
|
||||
"bz": "需符合国标材质"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
*/
|
||||
pushData(singleObj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送同步数据
|
||||
*/
|
||||
private void pushData(JSONObject param) throws BusinessException {
|
||||
// String jsonString = param.toJSONString();
|
||||
// 转json字符串的时候保留null值
|
||||
String jsonStr = JSON.toJSONString(param,
|
||||
SerializerFeature.WriteMapNullValue,
|
||||
SerializerFeature.WriteNullStringAsEmpty
|
||||
);
|
||||
logger.error("QMS-Material-param = " + jsonStr);
|
||||
NCCForUAPLogger.debug("QMS-Material-param = " + jsonStr);
|
||||
String baseUrl = configParams.get("qmsBaseUrl");
|
||||
String requestUrl = baseUrl + reqUrl;
|
||||
logger.error("QMS-Material-url = " + requestUrl);
|
||||
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr);
|
||||
JSONObject resultObj = JSONObject.parseObject(result);
|
||||
logger.error("QMS-Material-res = " + result);
|
||||
|
||||
if (!"success".equals(resultObj.getString("success"))) {
|
||||
// throw new BusinessException("QMS-Material-error:" + resultObj.getString("msg"));
|
||||
logger.error("QMS-Material-error,result[" + resultObj.toJSONString() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private Map getGoodsInfo(String pkMaterial) throws BusinessException {
|
||||
String sql = " select a.pk_measdoc, c.name unitname, b.pk_measdoc deputyUnit, d.name deputy_unitname, nvl(b.measrate, '1/1') measrate " +
|
||||
"from bd_material a " +
|
||||
"left join bd_materialconvert b on a.pk_material = b.pk_material " +
|
||||
"left join bd_measdoc c on a.pk_measdoc = c.pk_measdoc " +
|
||||
"left join bd_measdoc d on b.pk_measdoc = d.pk_measdoc " +
|
||||
"where a.pk_material = '" + pkMaterial + "' ";
|
||||
// logDl.error("QMS-Material-getUnitInfo-sql = " + sql);
|
||||
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
||||
map.put("convertRate", MyHelper.transferSpecialField(map.get("measrate") + ""));
|
||||
return map;
|
||||
}
|
||||
|
||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||
String targetCode = configParams.get("xbOrg");
|
||||
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
||||
throw new BusinessException("未配置组织参数");
|
||||
}
|
||||
String[] orgItem = targetCode.split(",");
|
||||
for (String orgCode : orgItem) {
|
||||
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -167,10 +167,6 @@ public class ApproveSaleOrderAction {
|
|||
processer.addAfterRule(new SaleOrderCreateRmBeforeRule());
|
||||
// 在审批后推送到MES系统
|
||||
processer.addAfterRule(new AfterApprovingSynchronizeRuleMES());
|
||||
|
||||
|
||||
// 在审批后推送到QMS系统
|
||||
processer.addAfterRule(new AfterApprovingSynchronizeRuleQMS());
|
||||
}
|
||||
|
||||
private boolean isExistDelivery(String ctranstype) {
|
||||
|
|
Loading…
Reference in New Issue