供应商推艾普mes(lihao修改)
This commit is contained in:
parent
b207feb8e7
commit
74eea66f2c
|
@ -5,17 +5,14 @@
|
|||
|
||||
package nccloud.api.uapbd.supplier.tms.listene;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import nc.bs.bd.baseservice.ArrayClassConvertUtil;
|
||||
import nc.bs.bd.baseservice.md.VOArrayUtil;
|
||||
import nc.bs.businessevent.IBusinessEvent;
|
||||
import nc.bs.businessevent.IBusinessListener;
|
||||
import nc.bs.businessevent.bd.BDCommonEvent;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.trade.business.HYPubBO;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
|
@ -25,62 +22,68 @@ import nc.vo.pub.BusinessException;
|
|||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||
import nccloud.commons.lang.ArrayUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 供应商推艾普MES
|
||||
*
|
||||
* @author lihao
|
||||
*/
|
||||
public class SupplierVoListener implements IBusinessListener {
|
||||
private static final String LOG_INFO_NAME = "dldzlog";
|
||||
private static final Log logDl = Log.getInstance(LOG_INFO_NAME);
|
||||
private static final String reqUrl = "/prj-v5-web/ext/api/supplier";
|
||||
private Map<String, String> configParams;
|
||||
public SupplierVoListener() {
|
||||
}
|
||||
|
||||
public void doAction(IBusinessEvent event) throws BusinessException {
|
||||
BDCommonEvent e = (BDCommonEvent)event;
|
||||
BDCommonEvent e = (BDCommonEvent) event;
|
||||
configParams = MyHelper.getConfigParams("Dldz-config", null);
|
||||
String modifyType = "";
|
||||
// EventType是事件编码 1002-新增后 1004-修改后 1006-删除后
|
||||
// EventType是事件编码 1002-新增后 1004-修改后 1006-删除后
|
||||
if ("1002".equals(e.getEventType())) {
|
||||
modifyType = "I";
|
||||
SupplierVO[] newvos = ArrayClassConvertUtil.convert(e.getObjs(), SupplierVO.class);
|
||||
this.putSupplier(newvos, modifyType);
|
||||
}else if("1004".equals(e.getEventType())) {
|
||||
} else if ("1004".equals(e.getEventType())) {
|
||||
modifyType = "U";
|
||||
SupplierVO[] newvos = ArrayClassConvertUtil.convert(e.getObjs(), SupplierVO.class);
|
||||
this.putSupplier(newvos, modifyType);
|
||||
}else if("1006".equals(e.getEventType())) {
|
||||
} else if ("1006".equals(e.getEventType())) {
|
||||
modifyType = "D";
|
||||
SupplierVO[] newvos = ArrayClassConvertUtil.convert(e.getObjs(), SupplierVO.class);
|
||||
this.putSupplier(newvos, modifyType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void putSupplier(SupplierVO[] objs, String modifyType) throws BusinessException {
|
||||
if (!ArrayUtils.isEmpty(objs)) {
|
||||
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (SupplierVO obj : objs) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("supplierName", obj.getName());
|
||||
map.put("supplierCode", obj.getCode());
|
||||
String supplierTypeId=obj.getPk_supplierclass();
|
||||
HYPubBO hy = new HYPubBO();
|
||||
// OrgVO orgvo = (OrgVO)hy.queryByPrimaryKey(OrgVO.class, );
|
||||
String supplierTypeId = obj.getPk_supplierclass();
|
||||
|
||||
String supplierType = (String) hy.findColValue("bd_supplierclass", "code", "code = '"+supplierTypeId+"' ");
|
||||
map.put("supplierType", supplierType.substring(0,1));
|
||||
HYPubBO hy = new HYPubBO();
|
||||
String supplierType = (String) hy.findColValue("bd_supplierclass", "code", "pk_supplierclass = '" + supplierTypeId + "' ");
|
||||
map.put("supplierType", supplierType.substring(0, 1));
|
||||
map.put("status", modifyType);
|
||||
list.add(map);
|
||||
}
|
||||
JSONObject result = JSONObject.parseObject(JSONObject.toJSONString(list));
|
||||
JSONArray result = JSONArray.parseArray(JSONObject.toJSONString(list));
|
||||
pushData(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送同步数据
|
||||
*/
|
||||
private void pushData(JSONObject param) throws BusinessException {
|
||||
private void pushData(JSONArray param) throws BusinessException {
|
||||
// String jsonString = param.toJSONString();
|
||||
// 转json字符串的时候保留null值
|
||||
String jsonStr = JSON.toJSONString(param,
|
||||
|
@ -97,8 +100,8 @@ public class SupplierVoListener implements IBusinessListener {
|
|||
logDl.error("EpicMes-Supplier-res = " + result);
|
||||
|
||||
if (!"1".equals(resultObj.getString("flag"))) {
|
||||
// throw new BusinessException("EpicMes-Supplier-error:" + resultObj.getString("msg"));
|
||||
logDl.error("EpicMes-Supplier-error,result[" + resultObj.toJSONString() + "]");
|
||||
// throw new BusinessException("EpicMes-Supplier-error:" + resultObj.getString("msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue