|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.uas.eis.core.support.TokenProperties;
|
|
import com.uas.eis.core.support.TokenProperties;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
import com.uas.eis.dao.SqlRowList;
|
|
import com.uas.eis.dao.SqlRowList;
|
|
|
|
|
+import com.uas.eis.entity.Customer;
|
|
|
import com.uas.eis.entity.Make;
|
|
import com.uas.eis.entity.Make;
|
|
|
import com.uas.eis.entity.MakeMaterial;
|
|
import com.uas.eis.entity.MakeMaterial;
|
|
|
import com.uas.eis.entity.Product;
|
|
import com.uas.eis.entity.Product;
|
|
@@ -20,6 +21,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -246,6 +248,47 @@ public class ScheduleTaskServiceImpl implements ScheduleTaskService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void syncCustomer() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select id from mes_customer where status='W' order by id");
|
|
|
|
|
+ List<Customer> customers = baseDao.query("select cu_id,nvl(cu_mescode,cu_code) cu_oldcode,nvl(cu_mescode,cu_code) cu_code,cu_name,cu_shortname,nvl(cu_cop,'BYT') cu_cop,flag from mes_customer where status='W' order by id", Customer.class);
|
|
|
|
|
+ if (customers!=null&&customers.size()>0){
|
|
|
|
|
+ for (Customer customer:customers) {
|
|
|
|
|
+ customer.setMesUser(tokenConfig.get("mesUser"));
|
|
|
|
|
+ customer.setMesPwd(MD5Util.encodeByMD5(tokenConfig.get("mesPwd")));
|
|
|
|
|
+ Map<String, Object> map = syncMES(JSON.toJSONString(customer, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncCustomer"));
|
|
|
|
|
+ if (map!=null){
|
|
|
|
|
+ int code = Integer.parseInt(StringUtil.nvl(map.get("msgId"), "-1"));
|
|
|
|
|
+ if (code==0){
|
|
|
|
|
+ baseDao.updateByCondition("mes_customer","status='D'","status='W' and id="+rs.getInt("id"));
|
|
|
|
|
+ }else {
|
|
|
|
|
+ int flag = customer.getFlag();
|
|
|
|
|
+ if (flag == 1) {
|
|
|
|
|
+ customer.setFlag(0);
|
|
|
|
|
+ } else if (flag == 0) {
|
|
|
|
|
+ customer.setFlag(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Object> map1 = syncMES(JSON.toJSONString(customer, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncCustomer"));
|
|
|
|
|
+ if (map1!=null){
|
|
|
|
|
+ int code1 = Integer.parseInt(StringUtil.nvl(map.get("msgId"), "-1"));
|
|
|
|
|
+ if (code1==0){
|
|
|
|
|
+ baseDao.updateByCondition("mes_customer","status='D'","status='W' and id="+rs.getInt("id"));
|
|
|
|
|
+ }else {
|
|
|
|
|
+ baseDao.updateByCondition("mes_customer","status='F'","status='W' and id="+rs.getInt("id"));
|
|
|
|
|
+ baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_type) values (MESERRORLOG_SEQ.NEXTVAL,'"+tokenConfig.get("syncCustomer")+"','"+StringUtil.nvl(map.get("msgStr"),"")+"',sysdate,'"+customer.getCu_code()+"','客户资料')");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ logger.info("客户资料异常信息:"+e.getMessage());
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private Map<String, Object> syncMES(String params,String url){
|
|
private Map<String, Object> syncMES(String params,String url){
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("code",-1);
|
|
map.put("code",-1);
|