|
|
@@ -0,0 +1,519 @@
|
|
|
+package com.mes.ui;
|
|
|
+
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.mes.netty.NettyClient;
|
|
|
+import com.mes.util.DateLocalUtils;
|
|
|
+import com.mes.util.JdbcUtils;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.MalformedURLException;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.Properties;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
+
|
|
|
+public class DataUtil {
|
|
|
+ public static final Logger log = LoggerFactory.getLogger(DataUtil.class);
|
|
|
+
|
|
|
+ public static Boolean synrTcp(NettyClient nettyClient,String mes_gw){
|
|
|
+ try{
|
|
|
+ //TCP连接后,直接先发同步报文
|
|
|
+ String start = "aaaabbbbbABW";
|
|
|
+ String msgType = "SYNR";
|
|
|
+ String gw = "GW"+DataUtil.rightPad(mes_gw, 6);
|
|
|
+ String da = "DA" + DateLocalUtils.getCurrentDate();
|
|
|
+ String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
|
|
|
+ String synr_str = start + msgType + gw + da + zt;
|
|
|
+ //插入报文本地数据
|
|
|
+ String gy = "";
|
|
|
+ String sn = "";
|
|
|
+ JdbcUtils.insertData(gw, gy, synr_str, msgType, sn);
|
|
|
+
|
|
|
+ nettyClient.run(synr_str);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean heartBeat(NettyClient nettyClient,String mes_gw){
|
|
|
+ try{
|
|
|
+ //TCP连接后,直接先发同步报文
|
|
|
+ String start = "aaaabbbbbABW";
|
|
|
+ String msgType = "AXTW";
|
|
|
+ String gw = "GW"+DataUtil.rightPad(mes_gw, 6);
|
|
|
+ String da = "DA" + DateLocalUtils.getCurrentDate();
|
|
|
+ String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
|
|
|
+ String axtw_str = start + msgType + gw + da + zt;
|
|
|
+ //插入报文本地数据
|
|
|
+ String gy = "";
|
|
|
+ String sn = "";
|
|
|
+ JdbcUtils.insertData(gw, gy, axtw_str, msgType, sn);
|
|
|
+ nettyClient.future.channel().writeAndFlush(axtw_str);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean checkQuality(NettyClient nettyClient, String sn, String user){
|
|
|
+ try{
|
|
|
+ String msgType = "AQDW";
|
|
|
+ String gy = "100000";
|
|
|
+ Boolean aqdw_str = sendMessage(nettyClient,msgType,gy,"",sn,"",user,"00","");
|
|
|
+ return aqdw_str;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean startWork(NettyClient nettyClient,String sn,String user){
|
|
|
+ try{
|
|
|
+ String msgType = "MKSW";
|
|
|
+ String gy = "";
|
|
|
+ Boolean aqdw_str = sendMessage(nettyClient,msgType,gy,"",sn,"",user,"00","");
|
|
|
+ return aqdw_str;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean bindUser(NettyClient nettyClient,String sn,String user){
|
|
|
+ try{
|
|
|
+ String msgType = "MBDW";
|
|
|
+ String gy = "400001";
|
|
|
+ String param = rightPad(user, 36);
|
|
|
+ Boolean aqdw_str = sendMessage(nettyClient,msgType,gy,"",sn,"",user,"01",param);
|
|
|
+ return aqdw_str;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean bindWarehouse(NettyClient nettyClient,String sn,String wsn,String user,String craft){
|
|
|
+ try{
|
|
|
+ String msgType = "MBDW";
|
|
|
+ String param = rightPad(wsn, 36);
|
|
|
+ Boolean aqdw_str = sendMessage(nettyClient,msgType,craft,"",sn,"",user,"01",param);
|
|
|
+ return aqdw_str;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean unBindWarehouse(NettyClient nettyClient,String sn,String wsn,String user,String craft){
|
|
|
+ try{
|
|
|
+ String msgType = "MJBW";
|
|
|
+ String param = rightPad(wsn, 36);
|
|
|
+ Boolean aqdw_str = sendMessage(nettyClient,msgType,craft,"",sn,"",user,"01",param);
|
|
|
+ return aqdw_str;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean sendQuality(NettyClient nettyClient,String sn,String ret,String user){
|
|
|
+ try{
|
|
|
+ String msgType = "MQDW";
|
|
|
+ String gy = "100000";
|
|
|
+ String param = "";
|
|
|
+ Boolean aqdw_str = sendMessage(nettyClient,msgType,gy,"",sn,ret,user,"00",param);
|
|
|
+ return aqdw_str;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean sendQualityNew(NettyClient nettyClient,String sn,String ret,String user){
|
|
|
+ try{
|
|
|
+ String msgType = "MQDW";
|
|
|
+ String craft = "100000";
|
|
|
+ String params = "";
|
|
|
+ String enconding = "UTF-8";
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
+ pro.load(br);
|
|
|
+ String gw = "GW"+rightPad(pro.getProperty("mes.gw"), 6);
|
|
|
+ String start = "aaaabbbbbABW";
|
|
|
+ String gy = "GY" + rightPad(craft, 6);
|
|
|
+ String reslx = "LX" + rightPad("", 2);
|
|
|
+ String id = pro.getProperty("mes.line_sn") + rightPad(sn, 36);
|
|
|
+ String rs = "RS"+ rightPad(ret, 2);
|
|
|
+ String da = "DA" + DateLocalUtils.getCurrentDate();
|
|
|
+ String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
|
|
|
+ String yh = "YH" + rightPad(user, 20);
|
|
|
+ String aqdw_str = start + msgType + gw + gy + reslx + id + rs + da + zt + yh + "00" + params;
|
|
|
+ System.out.println("message="+aqdw_str);
|
|
|
+ JdbcUtils.insertSubmitRecord(gw, sn, aqdw_str);
|
|
|
+ return true;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Boolean sendMessage(NettyClient nettyClient,String msgType,String craft,String lx,String sn,String result,String user,String paramNums,String params){
|
|
|
+ try{
|
|
|
+ String enconding = "UTF-8";
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
+ pro.load(br);
|
|
|
+ String gw = "GW"+rightPad(pro.getProperty("mes.gw"), 6);
|
|
|
+ String start = "aaaabbbbbABW";
|
|
|
+ String gy = "GY" + rightPad(craft, 6);
|
|
|
+ String reslx = "LX" + rightPad(lx, 2);
|
|
|
+ String id = pro.getProperty("mes.line_sn") + rightPad(sn, 36);
|
|
|
+ String rs = "RS"+ rightPad(result, 2);
|
|
|
+ String da = "DA" + DateLocalUtils.getCurrentDate();
|
|
|
+ String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
|
|
|
+ String yh = "YH" + rightPad(user, 20);
|
|
|
+ String aqdw_str = start + msgType + gw + gy + reslx + id + rs + da + zt + yh + paramNums + params;
|
|
|
+ System.out.println("message="+aqdw_str);
|
|
|
+ JdbcUtils.insertData(gw, gy, aqdw_str, msgType, sn);
|
|
|
+ nettyClient.future.channel().writeAndFlush(aqdw_str);
|
|
|
+ return true;
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String rightPad(final String str, final int size) {
|
|
|
+ if (str == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String strret = str;
|
|
|
+ if(str.length() > size){
|
|
|
+ strret = str.substring(0,size);
|
|
|
+ }
|
|
|
+ return String.format("%-"+size+"s", strret);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject getBindMaterail() {
|
|
|
+ try{
|
|
|
+ String enconding = "UTF-8";
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
+ pro.load(br);
|
|
|
+ String mes_server_ip = pro.getProperty("mes.server_ip");
|
|
|
+ String oprno = pro.getProperty("mes.gw").trim();
|
|
|
+ String lineSn = pro.getProperty("mes.line_sn").trim();
|
|
|
+ String url = "http://"+mes_server_ip+":8980/js/a/mes/mesLineProcessMaterial/materials";
|
|
|
+ String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn;
|
|
|
+ System.out.println("params="+params);
|
|
|
+ String result = doPost(url,params);
|
|
|
+ System.out.println("result="+result);
|
|
|
+
|
|
|
+ if(result.equalsIgnoreCase("false")) {
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ return JSONObject.parseObject(result);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject saveBindMaterail(String batchSn,String craft,String materialId,String type) {
|
|
|
+ try{
|
|
|
+ String enconding = "UTF-8";
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
+ pro.load(br);
|
|
|
+ String mes_server_ip = pro.getProperty("mes.server_ip");
|
|
|
+ String oprno = pro.getProperty("mes.gw").trim();
|
|
|
+ String lineSn = pro.getProperty("mes.line_sn").trim();
|
|
|
+ String url = "http://"+mes_server_ip+":8980/js/a/mes/mesMaterialPrebind/bind";
|
|
|
+ String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&batchSn="+batchSn+"&craft="+craft+"&materialId="+materialId+"&type="+type;
|
|
|
+ System.out.println("params="+params);
|
|
|
+ String result = doPost(url,params);
|
|
|
+ System.out.println("result="+result);
|
|
|
+
|
|
|
+ if(result.equalsIgnoreCase("false")) {
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ return JSONObject.parseObject(result);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 新增:上传工件ld点击记录,NG时调用
|
|
|
+ public static JSONObject ldResult(String sn, String userCode,String ldFlag) {
|
|
|
+ try{
|
|
|
+ String enconding = "UTF-8";
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
+ pro.load(br);
|
|
|
+
|
|
|
+ String mes_server_ip = pro.getProperty("mes.server_ip");
|
|
|
+ String oprno = pro.getProperty("mes.gw").trim();
|
|
|
+ String lineSn = pro.getProperty("mes.line_sn").trim();
|
|
|
+ String gy = "100000";
|
|
|
+ String url = "http://" + mes_server_ip + ":8980/js/a/mes/mesProductRecord/ldresult";
|
|
|
+
|
|
|
+ String params = "__ajax=json"
|
|
|
+ + "&sn=" + sn
|
|
|
+ + "&oprno=" + oprno
|
|
|
+ + "&lineSn=" + lineSn
|
|
|
+ + "&ldFlag=" + ldFlag
|
|
|
+ + "&userCode=" + userCode
|
|
|
+ + "&craft=" + gy;
|
|
|
+
|
|
|
+ System.out.println("params=" + params);
|
|
|
+
|
|
|
+ // 5. 发送 POST 请求
|
|
|
+ String result = doPost(url, params);
|
|
|
+ System.out.println("result=" + result);
|
|
|
+
|
|
|
+ // 6. 处理返回结果
|
|
|
+ if(result == null || result.trim().isEmpty() || result.equalsIgnoreCase("false")) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ return JSONObject.parseObject(result);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace(); // 建议打印堆栈以便调试
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static JSONObject pcResult(String sn, String userCode,String ldFlag,String result,int isRepair) {
|
|
|
+ try{
|
|
|
+ String enconding = "UTF-8";
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
+ pro.load(br);
|
|
|
+
|
|
|
+ String mes_server_ip = pro.getProperty("mes.server_ip");
|
|
|
+ String oprno = pro.getProperty("mes.gw").trim();
|
|
|
+ String lineSn = pro.getProperty("mes.line_sn").trim();
|
|
|
+ String gy = "100000";
|
|
|
+ String url = "http://" + mes_server_ip + ":8980/js/a/mes/mesProductRecord/pcresult";
|
|
|
+
|
|
|
+ String params = "__ajax=json"
|
|
|
+ + "&sn=" + sn
|
|
|
+ + "&oprno=" + oprno
|
|
|
+ + "&lineSn=" + lineSn
|
|
|
+ + "&ldFlag=" + ldFlag
|
|
|
+ + "&ucode=" + userCode
|
|
|
+ + "&result=" + result
|
|
|
+ + "&isRepair=" + isRepair
|
|
|
+ + "&craft="
|
|
|
+ + "&remark="
|
|
|
+ + "&ps=";
|
|
|
+
|
|
|
+ System.out.println("params=" + params);
|
|
|
+
|
|
|
+ // 5. 发送 POST 请求
|
|
|
+ String resultParams = doPost(url, params);
|
|
|
+ System.out.println("resultParam=" + resultParams);
|
|
|
+
|
|
|
+ // 6. 处理返回结果
|
|
|
+ if(resultParams == null || resultParams.trim().isEmpty() || resultParams.equalsIgnoreCase("false")) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ return JSONObject.parseObject(resultParams);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace(); // 建议打印堆栈以便调试
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static JSONObject pcCheck(String sn, String userCode,int isRepair) {
|
|
|
+ try{
|
|
|
+ String enconding = "UTF-8";
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
+ pro.load(br);
|
|
|
+
|
|
|
+ String mes_server_ip = pro.getProperty("mes.server_ip");
|
|
|
+ String oprno = pro.getProperty("mes.gw").trim();
|
|
|
+ String lineSn = pro.getProperty("mes.line_sn").trim();
|
|
|
+ String gy = "100000";
|
|
|
+ String url = "http://" + mes_server_ip + ":8980/js/a/mes/mesProductRecord/pccheck";
|
|
|
+
|
|
|
+ String params = "__ajax=json"
|
|
|
+ + "&sn=" + sn
|
|
|
+ + "&oprno=" + oprno
|
|
|
+ + "&lineSn=" + lineSn
|
|
|
+ + "&ucode=" + userCode
|
|
|
+ + "&isRepair=" + isRepair;
|
|
|
+
|
|
|
+ System.out.println("params=" + params);
|
|
|
+
|
|
|
+ // 5. 发送 POST 请求
|
|
|
+ String resultParams = doPost(url, params);
|
|
|
+ System.out.println("resultParam=" + resultParams);
|
|
|
+
|
|
|
+ // 6. 处理返回结果
|
|
|
+ if(resultParams == null || resultParams.trim().isEmpty() || resultParams.equalsIgnoreCase("false")) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ return JSONObject.parseObject(resultParams);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace(); // 建议打印堆栈以便调试
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String doPost(String httpUrl, String param) {
|
|
|
+ HttpURLConnection connection = null;
|
|
|
+ InputStream is = null;
|
|
|
+ OutputStream os = null;
|
|
|
+ BufferedReader br = null;
|
|
|
+ String result = null;
|
|
|
+ try {
|
|
|
+ URL url = new URL(httpUrl);
|
|
|
+ connection = (HttpURLConnection) url.openConnection();
|
|
|
+ connection.setRequestMethod("POST");
|
|
|
+ connection.setConnectTimeout(15000);
|
|
|
+ connection.setReadTimeout(60000);
|
|
|
+ connection.setDoOutput(true);
|
|
|
+ connection.setDoInput(true);
|
|
|
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ connection.setRequestProperty("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0");
|
|
|
+ os = connection.getOutputStream();
|
|
|
+ os.write(param.getBytes());
|
|
|
+ if (connection.getResponseCode() == 200) {
|
|
|
+ is = connection.getInputStream();
|
|
|
+ br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
|
|
+ StringBuffer sbf = new StringBuffer();
|
|
|
+ String temp = null;
|
|
|
+ while ((temp = br.readLine()) != null) {
|
|
|
+ sbf.append(temp);
|
|
|
+ sbf.append("\r\n");
|
|
|
+ }
|
|
|
+ result = sbf.toString();
|
|
|
+ }
|
|
|
+ } catch (MalformedURLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (null != br) {
|
|
|
+ try {
|
|
|
+ br.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null != os) {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null != is) {
|
|
|
+ try {
|
|
|
+ is.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ connection.disconnect();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询工作记录
|
|
|
+ * @param oprno 工位号(空则查所有工位)
|
|
|
+ * @param sn 工件码(可选,用于搜索)
|
|
|
+ * @param pageNo 页码
|
|
|
+ * @param pageSize 每页条数
|
|
|
+ * @return 工作记录响应
|
|
|
+ */
|
|
|
+ public static WorkRecordResp getWorkRecordList(String oprno, String sn, int pageNo, int pageSize) {
|
|
|
+ WorkRecordResp resp = new WorkRecordResp();
|
|
|
+ try {
|
|
|
+ String enconding = "UTF-8";
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
+ pro.load(br);
|
|
|
+ String mes_server_ip = pro.getProperty("mes.server_ip");
|
|
|
+ String lineSn = pro.getProperty("mes.line_sn").trim();
|
|
|
+
|
|
|
+ String url = "http://" + mes_server_ip + ":8980/js/a/mes/mesProductRecord/workData";
|
|
|
+ StringBuilder params = new StringBuilder();
|
|
|
+ params.append("__ajax=json");
|
|
|
+ params.append("&lineSn=").append(lineSn);
|
|
|
+ params.append("&pageNo=").append(pageNo);
|
|
|
+ params.append("&pageSize=").append(pageSize);
|
|
|
+
|
|
|
+ if (oprno != null && !oprno.isEmpty()) {
|
|
|
+ params.append("&oprno=").append(oprno);
|
|
|
+ }
|
|
|
+ // 注意:不传auto参数,这样"所有工位"查询时会返回整条产线所有工位的数据
|
|
|
+ if (sn != null && !sn.isEmpty()) {
|
|
|
+ params.append("&sn=").append(sn);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("查询工作记录: url=" + url + ", params=" + params.toString());
|
|
|
+ String result = doPost(url, params.toString());
|
|
|
+ log.info("查询工作记录结果: result=" + result);
|
|
|
+
|
|
|
+ if (result == null || result.trim().isEmpty()) {
|
|
|
+ resp.setResult(false);
|
|
|
+ resp.setMessage("请求返回空结果");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject jsonObj = JSONObject.parseObject(result);
|
|
|
+ if (jsonObj == null) {
|
|
|
+ resp.setResult(false);
|
|
|
+ resp.setMessage("解析响应失败");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.setResult(true);
|
|
|
+ resp.setPageNo(jsonObj.getIntValue("pageNo"));
|
|
|
+ resp.setPageSize(jsonObj.getIntValue("pageSize"));
|
|
|
+ resp.setCount(jsonObj.getLongValue("count"));
|
|
|
+
|
|
|
+ List<WorkRecordData> list = new ArrayList<>();
|
|
|
+ JSONArray listArray = jsonObj.getJSONArray("list");
|
|
|
+ if (listArray != null) {
|
|
|
+ for (int i = 0; i < listArray.size(); i++) {
|
|
|
+ JSONObject item = listArray.getJSONObject(i);
|
|
|
+ WorkRecordData data = new WorkRecordData();
|
|
|
+ data.setId(item.getString("id"));
|
|
|
+ data.setSn(item.getString("sn"));
|
|
|
+ data.setOprno(item.getString("oprno"));
|
|
|
+ data.setUpdateBy(item.getString("updateBy"));
|
|
|
+ data.setUpdateDate(item.getString("updateDate"));
|
|
|
+ data.setContent(item.getString("content"));
|
|
|
+ list.add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp.setList(list);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询工作记录异常: " + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ resp.setResult(false);
|
|
|
+ resp.setMessage("查询异常: " + e.getMessage());
|
|
|
+ }
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+}
|