InventoryTask.java 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.uas.eis.task;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.uas.eis.config.DonlimConfig;
  4. import com.uas.eis.dao.BaseDao;
  5. import com.uas.eis.dao.SqlRowList;
  6. import com.uas.eis.dto.InventoryReq;
  7. import com.uas.eis.dto.InventoryResp;
  8. import org.slf4j.Logger;
  9. import org.slf4j.LoggerFactory;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.http.HttpHeaders;
  12. import org.springframework.http.MediaType;
  13. import org.springframework.http.ResponseEntity;
  14. import org.springframework.stereotype.Component;
  15. import java.util.ArrayList;
  16. import java.util.HashMap;
  17. import java.util.List;
  18. import java.util.Map;
  19. @Component
  20. public class InventoryTask extends BaseTask{
  21. @Autowired
  22. private DonlimConfig donlimConfig;
  23. @Autowired
  24. private BaseDao baseDao;
  25. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  26. public void execute() {
  27. Object ob=baseDao.getFieldDataByCondition("DOCKING_XB_WH_CHANGE","max(ID_)","NVL(DEALSTATE,0)=0");
  28. int n=0;
  29. if(ob!=null){
  30. try{
  31. String Sql = "select * from DOCKING_Inventory where YM_VIEW_PARAM.SET_ID_("+ob+")<="+ob+" order by WAREHOUSENO, MATERIALNO";
  32. SqlRowList rs = baseDao.queryForRowSet(Sql);
  33. n=rs.size();
  34. while (rs.next()) {
  35. JSONObject jsonobj=new JSONObject();
  36. jsonobj.put("supplyCode", donlimConfig.getSupplyCode());
  37. jsonobj.put("supplyName", donlimConfig.getSupplyName());
  38. jsonobj.put("warehouseNo", rs.getGeneralString("warehouseNo"));
  39. jsonobj.put("warehouseName", rs.getGeneralString("warehouseName"));
  40. jsonobj.put("materialNo", rs.getGeneralString("materialNo"));
  41. jsonobj.put("materialName", rs.getGeneralString("materialName"));
  42. jsonobj.put("materialSpecification", rs.getGeneralString("materialSpecification"));
  43. jsonobj.put("stockNum", rs.getGeneralInt("stockNum"));
  44. jsonobj.put("updateTime", rs.getGeneralString("updateTime"));
  45. jsonobj.put("bakOne", rs.getGeneralString("bakOne"));
  46. jsonobj.put("bakTwo", rs.getGeneralString("bakTwo"));
  47. jsonobj.put("bakThree", rs.getGeneralString("bakThree"));
  48. jsonobj.put("bakFour", rs.getGeneralString("bakFour"));
  49. InventoryReq req= new InventoryReq();
  50. req.setSupplyCode(donlimConfig.getSupplyCode());
  51. req.configSign();
  52. req.setData(jsonobj);
  53. HttpHeaders headers = new HttpHeaders();
  54. headers.setContentType(MediaType.APPLICATION_JSON);
  55. ResponseEntity<InventoryResp> resp = restTemplate.postForEntity(donlimConfig.getRoute()+"/wms/inventory", configHttpEntity(req), InventoryResp.class);
  56. assertOK(resp);
  57. logger.info("Inventory code {} ,msg {} ",resp.getBody().getCode(),resp.getBody().getMsg());
  58. }
  59. baseDao.execute("update DOCKING_XB_WH_CHANGE set dealdate_=sysdate ,DEALSTATE=1 where ID_<="+ob+" and NVL(DEALSTATE,0)=0");
  60. } catch (Exception e) {
  61. e.printStackTrace();
  62. baseDao.execute("insert into dockinglog(id_,date_,type_,result_,Info_) " +
  63. " values(dockinglog_seq.nextval,sysdate,'Inventory','FAILED','"+ e.getMessage()+"')");
  64. }
  65. baseDao.execute("insert into dockinglog(id_,date_,type_,result_,Info_) values(dockinglog_seq.nextval,sysdate,'SALEOUT','SUCCEED','条数:"+n+"')");
  66. }
  67. /*else{
  68. logger.info("InventoryTask 无数据变更,无须对接 ");
  69. }*/
  70. }
  71. }