MESHelperController.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. package com.uas.eis.controller;
  2. import com.uas.eis.sdk.entity.ApiResult;
  3. import com.uas.eis.sdk.resp.ApiResponse;
  4. import com.uas.eis.service.MESHelperService;
  5. import org.dom4j.Document;
  6. import org.dom4j.DocumentHelper;
  7. import org.dom4j.Element;
  8. import org.dom4j.io.OutputFormat;
  9. import org.dom4j.io.XMLWriter;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RequestMethod;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import javax.servlet.http.HttpServletRequest;
  16. import java.io.IOException;
  17. import java.io.StringWriter;
  18. import java.util.HashMap;
  19. import java.util.Map;
  20. /**
  21. * @author xiaost
  22. * @date 2022/8/16 11:35
  23. **/
  24. @RestController
  25. @RequestMapping("/MES/helper")
  26. public class MESHelperController {
  27. @Autowired
  28. private MESHelperService mesHelperService;
  29. @RequestMapping(value="/dllMain")
  30. public ApiResult<Map<Object,Object>> DLLMain(HttpServletRequest request, @RequestBody String data){
  31. Map<String, Object> modelMap = new HashMap<String, Object>();
  32. String accessKey = request.getHeader("AccessKey");
  33. String requestId = request.getHeader("RequestId");
  34. Map<Object,Object> map = mesHelperService.DLLMain(accessKey,requestId,data);
  35. return ApiResponse.successRsp(requestId,map);
  36. }
  37. //抛料数据接口
  38. @RequestMapping(value="/StateEventDetail")
  39. public Map<Object,Object> StateEventDetail(HttpServletRequest request, @RequestBody String json){
  40. Map<String, Object> modelMap = new HashMap<String, Object>();
  41. Map<Object,Object> map = mesHelperService.StateEventDetail(json);
  42. return map;
  43. }
  44. //抛料数据接口
  45. @RequestMapping(value="/SendPlaceData")
  46. public Map<Object,Object> SendPlaceData(HttpServletRequest request, @RequestBody String json){
  47. Map<String, Object> modelMap = new HashMap<String, Object>();
  48. Map<Object,Object> map = mesHelperService.SendPlaceData(json);
  49. return map;
  50. }
  51. //物料移动接口
  52. @RequestMapping(value="/SetupResultDataInterface")
  53. public Map<Object,Object> SetupResultDataInterface(HttpServletRequest request, @RequestBody String json){
  54. Map<String, Object> modelMap = new HashMap<String, Object>();
  55. Map<Object,Object> map = mesHelperService.SetupResultDataInterface(json);
  56. return map;
  57. }
  58. //追溯信息接口
  59. @RequestMapping(value="/TraceabilityDataInterface")
  60. public Map<Object,Object> TraceabilityDataInterface(HttpServletRequest request, @RequestBody String json){
  61. Map<String, Object> modelMap = new HashMap<String, Object>();
  62. Map<Object,Object> map = mesHelperService.TraceabilityDataInterface(json);
  63. return map;
  64. }
  65. //追溯信息接口
  66. @RequestMapping(value="/XrayTestDataSave")
  67. public Map<Object,Object> XrayTestDataSave(HttpServletRequest request, @RequestBody String json){
  68. Map<String, Object> modelMap = new HashMap<String, Object>();
  69. Map<Object,Object> map = mesHelperService.XrayTestDataSave(json);
  70. return map;
  71. }
  72. //
  73. //天马电子秤对接接口
  74. @RequestMapping(value="/Weigh")
  75. public Map<Object,Object> Weigh(HttpServletRequest request, @RequestBody String json){
  76. Map<String, Object> modelMap = new HashMap<String, Object>();
  77. Map<Object,Object> map = mesHelperService.Weigh(json);
  78. return map;
  79. }
  80. //镭雕机接口
  81. @RequestMapping(value="/Radium")
  82. public Map<Object,Object> Radium(HttpServletRequest request, @RequestBody String json){
  83. Map<String, Object> modelMap = new HashMap<String, Object>();
  84. Map<Object,Object> map = mesHelperService.Radium(json);
  85. return map;
  86. }
  87. //SPI接口
  88. @RequestMapping(value="/SPI")
  89. public Map<Object,Object> SPI(HttpServletRequest request, @RequestBody String json){
  90. Map<String, Object> modelMap = new HashMap<String, Object>();
  91. Map<Object,Object> map = mesHelperService.SPI(json);
  92. return map;
  93. }
  94. //AOI接口
  95. @RequestMapping(value="/AOI")
  96. public String AOI(HttpServletRequest request,@RequestBody String Data,String Username,String Shiftname, String MachineNO, String LineNO, String procedure,String Moname,
  97. String Lotsn,String Side,String Result,String Defect,String elementQTY,String TestQTY,String Type,String Time) {
  98. Data=Data+"1";
  99. Element root = DocumentHelper.createElement("Data");
  100. Document document = DocumentHelper.createDocument(root);
  101. String Err=mesHelperService.AOI( Username, Shiftname, MachineNO, LineNO, procedure, Moname,
  102. Lotsn, Side, Result, Defect, elementQTY, TestQTY, Type, Time);
  103. Element element1 = root.addElement("Result");
  104. Element element2 = root.addElement("ErrMsg");
  105. if(Err.equals("")||Err==null){
  106. element1.setText("OK");
  107. element2.setText("");
  108. }else{
  109. element1.setText("NG");
  110. element2.setText(Err);
  111. }
  112. StringWriter stringWriter = new StringWriter();
  113. OutputFormat format = OutputFormat.createPrettyPrint();
  114. XMLWriter xmlWriter = new XMLWriter(stringWriter, format);
  115. try {
  116. xmlWriter.write(document);
  117. } catch (IOException e) {
  118. e.printStackTrace();
  119. }
  120. String xmlString = stringWriter.toString();
  121. return xmlString;
  122. }
  123. //更新刮刀数据
  124. @RequestMapping(value="/UploadSteel",method = RequestMethod.POST)
  125. public String UploadSteel(HttpServletRequest request,String SteelMeshCode,String scraperCode, String SteelMeshCount, String scraperCount, String datatime) {
  126. Element root = DocumentHelper.createElement("Data");
  127. Document document = DocumentHelper.createDocument(root);
  128. String Err=mesHelperService.UploadSteel( SteelMeshCode, scraperCode, SteelMeshCount, scraperCount, datatime);
  129. Element element1 = root.addElement("Result");
  130. Element element2 = root.addElement("ErrMsg");
  131. if(Err.equals("")||Err==null){
  132. element1.setText("OK");
  133. element2.setText("");
  134. }else{
  135. element1.setText("NG");
  136. element2.setText(Err);
  137. }
  138. StringWriter stringWriter = new StringWriter();
  139. OutputFormat format = OutputFormat.createPrettyPrint();
  140. XMLWriter xmlWriter = new XMLWriter(stringWriter, format);
  141. try {
  142. xmlWriter.write(document);
  143. } catch (IOException e) {
  144. e.printStackTrace();
  145. }
  146. String xmlString = stringWriter.toString();
  147. return xmlString;
  148. }
  149. //校验钢网是否可以用
  150. @RequestMapping(value="/CheckSteel")
  151. public String CheckSteel(HttpServletRequest request, String SteelMeshCode) {
  152. Element root = DocumentHelper.createElement("Data");
  153. Document document = DocumentHelper.createDocument(root);
  154. String Err=mesHelperService.CheckSteel(SteelMeshCode);
  155. Element element1 = root.addElement("Result");
  156. Element element2 = root.addElement("ErrMsg");
  157. if(Err.equals("")||Err==null){
  158. element1.setText("OK");
  159. element2.setText("");
  160. }else{
  161. element1.setText("NG");
  162. element2.setText(Err);
  163. }
  164. StringWriter stringWriter = new StringWriter();
  165. OutputFormat format = OutputFormat.createPrettyPrint();
  166. XMLWriter xmlWriter = new XMLWriter(stringWriter, format);
  167. try {
  168. xmlWriter.write(document);
  169. } catch (IOException e) {
  170. e.printStackTrace();
  171. }
  172. String xmlString = stringWriter.toString();
  173. return xmlString;
  174. }
  175. /**
  176. * 获取MES生成的SN条码
  177. * @param request
  178. * @param json
  179. * @return
  180. */
  181. @RequestMapping(value="/getMESSnCode")
  182. public Map<Object,Object> GetMESSnCode(HttpServletRequest request, @RequestBody String json){
  183. return mesHelperService.getMESSnCode(json);
  184. }
  185. /**
  186. * 获取MES生成的SN条码
  187. * @param request
  188. * @param json
  189. * @return
  190. */
  191. @RequestMapping(value="/getMakeSnCode")
  192. public Map<Object,Object> getMakeSnCode(HttpServletRequest request, @RequestBody String json){
  193. return mesHelperService.getMakeSnCode(json);
  194. }
  195. /**
  196. * 获取MES生成的SN条码
  197. * @param request
  198. * @param json
  199. * @return
  200. */
  201. @RequestMapping(value="/getMainAllSnCode")
  202. public Map<Object,Object> getMainAllSnCode(HttpServletRequest request, @RequestBody String json){
  203. return mesHelperService.getMainAllSnCode(json);
  204. }
  205. /**
  206. * 微浦MES点料机对接
  207. * @param request
  208. * @param json
  209. * @return
  210. */
  211. @RequestMapping(value="/countQTY")
  212. public Map<Object,Object> countQTY(HttpServletRequest request, @RequestBody String json){
  213. return mesHelperService.countQTY(json);
  214. }
  215. }