|
|
@@ -0,0 +1,73 @@
|
|
|
+package com.uas.eis.task;
|
|
|
+
|
|
|
+import com.uas.eis.dao.BaseDao;
|
|
|
+import com.uas.eis.dao.SqlRowList;
|
|
|
+import com.uas.eis.sdk.entity.ApiResult;
|
|
|
+import com.uas.eis.service.DocCommonService;
|
|
|
+import com.uas.eis.service.ERPService;
|
|
|
+import com.uas.eis.utils.StringUtil;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Component
|
|
|
+@EnableAsync
|
|
|
+@EnableScheduling
|
|
|
+public class WMSUploadTask {
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
+ @Autowired
|
|
|
+ private BaseDao baseDao;
|
|
|
+ @Autowired
|
|
|
+ private DocCommonService docCommonService;
|
|
|
+ @Autowired
|
|
|
+ private ERPService erpService;
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0/2 * * * ?")
|
|
|
+ public void uploadfxML() {
|
|
|
+ logger.info("uploadfxML-begin");
|
|
|
+ //需要调用三次对接方法
|
|
|
+ String[] masterList = new String[]{"YUEJH", "AIFL", "YJH_HK"};
|
|
|
+ for (String master : masterList) {
|
|
|
+ logger.info("uploadfxML-begin-master {}",master);
|
|
|
+ String emCode = "ADMIN";
|
|
|
+ SqlRowList toSendList = baseDao.queryForRowSet("select pi_id,pi_inoutno,pi_class,ds_table,nvl(pi_sendwmserr_count,0) pi_sendwmserr_count from "+master+".prodinout left join documentsetup on ds_name = pi_class " +
|
|
|
+ "where pi_status ='未过账' and PI_WMSORDERTYPE is not null and nvl(PI_SENDWMSFLAG,0) = 0 and ds_inorout in ('-IN','OUT') and PI_SENDWMSERR IS NOT NULL AND NVL(PI_SENDWMSERR_COUNT,0)<5 " +
|
|
|
+ "order by pi_id");
|
|
|
+ if(toSendList.hasNext()){
|
|
|
+ while (toSendList.next()){
|
|
|
+ String id = String.valueOf(toSendList.getObject("pi_id"));
|
|
|
+ String inoutno = String.valueOf(toSendList.getObject("pi_inoutno"));
|
|
|
+ String caller = toSendList.getGeneralString("ds_table");
|
|
|
+ Integer errCount = toSendList.getGeneralInt("pi_sendwmserr_count");
|
|
|
+ logger.info("uploadfxML-Upload:caller {} id {} code {}",caller,id,inoutno);
|
|
|
+ // 调用待测方法
|
|
|
+ Map<String, Object> result = erpService.sendIO(master, id, emCode,caller);
|
|
|
+// System.out.println("result:"+result.toString());
|
|
|
+ if (result.get("success") != null && "true".equals(result.get("success").toString())) {
|
|
|
+ baseDao.execute("update "+master+".prodinout set "+(StringUtil.hasText(result.get("OrderId"))?"pi_wmsordercode='"+result.get("OrderId")+"',":"")+"pi_sendwmsstatus='同步成功' ,PI_SENDWMSERR_COUNT=0,pi_sendwmserr=null,pi_sendwmsflag=-1 where pi_id = "+id);
|
|
|
+ }else{
|
|
|
+ String message = result.get("message") == null ? "同步失败" : result.get("message").toString().replaceAll("'", "''");
|
|
|
+ baseDao.execute("update "+master+".prodinout set pi_sendwmsstatus='同步失败',PI_SENDWMSERR_COUNT=NVL(PI_SENDWMSERR_COUNT,0)+1,pi_sendwmserr=('" + message + "') where pi_id = " + id);
|
|
|
+ if(errCount == 4){
|
|
|
+ StringBuffer msg = new StringBuffer();
|
|
|
+ msg.append("账套:").append(master).append(",").append(toSendList.getGeneralString("pi_class"))
|
|
|
+ .append("[").append(inoutno).append("]")
|
|
|
+ .append("对接WMS失败已达5次,请确认失败原因。");
|
|
|
+ docCommonService.sendErrToRobot("263a7170-3197-4ff5-8a29-be42b646a546",msg.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("uploadfxML-Upload:caller {} id {} Upload res {}",caller,id,result.toString());
|
|
|
+ }
|
|
|
+//
|
|
|
+ }
|
|
|
+ logger.info("uploadfxML-End-master {}",master);
|
|
|
+ }
|
|
|
+ logger.info("uploadfxML-End");
|
|
|
+ }
|
|
|
+}
|