|
|
@@ -0,0 +1,201 @@
|
|
|
+package com.uas.mes.pda.service.impl;
|
|
|
+
|
|
|
+import com.uas.mes.core.exception.APIErrorException;
|
|
|
+import com.uas.mes.core.util.CollectionUtil;
|
|
|
+import com.uas.mes.core.util.StringUtil;
|
|
|
+import com.uas.mes.pda.service.PdaGetESOPService;
|
|
|
+import sun.misc.BASE64Encoder;
|
|
|
+import com.uas.mes.common.util.BaseUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import com.uas.mes.common.data.BaseDao;
|
|
|
+import com.uas.mes.core.data.SqlRowList;
|
|
|
+import com.uas.mes.core.exception.SystemException;
|
|
|
+import com.uas.mes.core.util.FlexJsonUtil;
|
|
|
+import com.uas.mes.pda.dao.PdaCommonDao;
|
|
|
+import com.uas.mes.pda.service.PdaFeederUseService;
|
|
|
+import com.uas.mes.pm.service.FeederUseService;
|
|
|
+import sun.misc.BASE64Decoder;
|
|
|
+import sun.misc.BASE64Encoder;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author xiaost
|
|
|
+ * @date 2022/11/17 10:39
|
|
|
+ **/
|
|
|
+@Service("pdaGetESOPService")
|
|
|
+public class PdaGetESOPServiceImpl implements PdaGetESOPService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BaseDao baseDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getESOP(String ps_code, String ss_code) throws Exception {
|
|
|
+
|
|
|
+ /* 传参:sourcecode岗位资源编号,makecode 工单号
|
|
|
+ * 返回:从productsop表获取对应sourcecode和makecode对应产品匹配的sop记录
|
|
|
+ * (最好用个函数或者存储过程方便维护取数规则)的附件字段,返回结果:是否成功,版本号PS_CODE,附件文件数组
|
|
|
+ */
|
|
|
+ List<String> list = baseDao.callProcedureWithOut("GETSOP",new Object[]{ps_code},new Integer[]{1},new Integer[]{2,3,4});
|
|
|
+ if(StringUtil.hasText(list.get(0))) {
|
|
|
+ throw new APIErrorException(APIErrorException.APIErrorCode.BUSINESS_FAILED,list.get(0));
|
|
|
+ }else{
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("ps_code", list.get(1));
|
|
|
+ if(StringUtil.hasText(list.get(2))) {
|
|
|
+ //;分割
|
|
|
+ String[] pathids = list.get(2).split(";");
|
|
|
+ String pathroot = baseDao.getDBSetting("filePathUrl");
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select fp_path,fp_name from filepath where fp_id in (" + CollectionUtil.toString(pathids) + ") and nvl(fp_path,' ')<>' '");
|
|
|
+ if(rs.next()){
|
|
|
+ List<Map<String,Object>> listr = new ArrayList<>();
|
|
|
+ for(Map<String,Object> mp :rs.getResultList()){
|
|
|
+ //盐加密
|
|
|
+ Map<String, Object> mp1 = new HashMap<>();
|
|
|
+ String path = mp.get("fp_path").toString();
|
|
|
+ path = path.replaceAll("/app/mes/webapps/postattach",pathroot);
|
|
|
+ // mp1.put("path",MD5Encode(path+"{"+SystemSession.getUser().getEm_code()+"}" )); //MD5加密,盐
|
|
|
+ mp1.put("path",encryptBASE64(path));
|
|
|
+ String pa = decryBASE64(mp1.get("path").toString().replaceAll("\\s*|\r|\n|\t",""));
|
|
|
+ mp1.put("filename",mp.get("fp_name"));
|
|
|
+ listr.add(mp1);
|
|
|
+ }
|
|
|
+ map.put("url",listr);
|
|
|
+ }else {
|
|
|
+ map.put("url", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, String>> getSopSource() throws Exception {
|
|
|
+ List<Map<String, String>> maps = new ArrayList<Map<String, String>>();
|
|
|
+ SqlRowList rs=baseDao.queryForRowSet("select * from SOPSOURCE");
|
|
|
+ while (rs.next()){
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("SS_CODE",rs.getString("SS_CODE"));
|
|
|
+ map.put("SS_NAME",rs.getString("SS_NAME"));
|
|
|
+ map.put("SS_LINECODE",rs.getString("SS_LINECODE"));
|
|
|
+ map.put("SS_WCCODE",rs.getString("SS_WCCODE"));
|
|
|
+ map.put("SS_STEPCODE",rs.getString("SS_STEPCODE"));
|
|
|
+ map.put("ss_brdip",rs.getString("ss_brdip"));
|
|
|
+ map.put("ss_brdport",rs.getString("ss_brdport"));
|
|
|
+ maps.add(map);
|
|
|
+ }
|
|
|
+ return maps;
|
|
|
+ }
|
|
|
+ TcpServer tcpServer = new TcpServer(9999);
|
|
|
+ @Override
|
|
|
+ public List<Map<String, String>> getProductSOP() throws Exception {
|
|
|
+ List<Map<String, String>> maps = new ArrayList<Map<String, String>>();
|
|
|
+ SqlRowList rs=baseDao.queryForRowSet("select * from productsop");
|
|
|
+ while (rs.next()){
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("PS_CODE",rs.getString("PS_CODE"));
|
|
|
+ map.put("PS_PRODCODE",rs.getString("PS_PRODCODE"));
|
|
|
+ map.put("PS_STEPCODE",rs.getString("PS_STEPCODE"));
|
|
|
+ maps.add(map);
|
|
|
+ }
|
|
|
+ return maps;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getSOPAddress(String ps_code, String ss_code) throws Exception {
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> sendSop(String data) throws Exception {
|
|
|
+ //使用独立线程进行开启端口
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ tcpServer.start();
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+ List<Map<Object, Object>> maps = BaseUtil.parseGridStoreToMaps(data);
|
|
|
+ List<Map<String,Object>> listr = new ArrayList<>();
|
|
|
+ Thread.sleep(5000);
|
|
|
+ for (Map<Object, Object> m : maps) {
|
|
|
+
|
|
|
+ SqlRowList rs=baseDao.queryForRowSet("select ps_code,PS_ATTACHSOP,PS_SOURCECODE,ps_prodcode from productsop where ps_code='"+m.get("ss_pscode").toString()+"'");
|
|
|
+ if(rs.next()){
|
|
|
+ String attach=rs.getString("PS_ATTACHSOP");
|
|
|
+ String sourcecode=rs.getString("PS_SOURCECODE");
|
|
|
+ String prodcode=rs.getString("ps_prodcode");
|
|
|
+ String ps_code=rs.getString("ps_code");
|
|
|
+ String[] pathids = attach.split(";");
|
|
|
+ String pathroot = baseDao.getDBSetting("filePathUrl");
|
|
|
+ rs = baseDao.queryForRowSet("select fp_path,fp_name from filepath where fp_id in (" + CollectionUtil.toString(pathids) + ") and nvl(fp_path,' ')<>' '");
|
|
|
+ if(rs.next()){
|
|
|
+
|
|
|
+ String path;
|
|
|
+ String filename;
|
|
|
+ for(Map<String,Object> mp :rs.getResultList()){
|
|
|
+ //盐加密
|
|
|
+ Map<String, Object> mp1 = new HashMap<>();
|
|
|
+ path = mp.get("fp_path").toString();
|
|
|
+ path = path.replaceAll("/app/mes/webapps/postattach",pathroot);
|
|
|
+ // mp1.put("path",MD5Encode(path+"{"+SystemSession.getUser().getEm_code()+"}" )); //MD5加密,盐
|
|
|
+ mp1.put("path",encryptBASE64(path).replaceAll("\\s*|\r|\n|\t",""));
|
|
|
+ mp1.put("filename",mp.get("fp_name"));
|
|
|
+ mp1.put("ss_code",m.get("ss_code"));
|
|
|
+ mp1.put("ps_sourcecode",sourcecode);
|
|
|
+ mp1.put("ps_prodcode",prodcode);
|
|
|
+ mp1.put("ps_code",ps_code);
|
|
|
+ listr.add(mp1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tcpServer.Send(listr.toString());
|
|
|
+ tcpServer.stop();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /***
|
|
|
+
|
|
|
+ * BASE64解密
|
|
|
+
|
|
|
+ * @param key
|
|
|
+
|
|
|
+ * @return
|
|
|
+
|
|
|
+ * @throws Exception
|
|
|
+
|
|
|
+ */
|
|
|
+ public static String decryBASE64(String key) throws Exception{
|
|
|
+
|
|
|
+ return new String((new BASE64Decoder()).decodeBuffer(key));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+
|
|
|
+ * BASE64加密
|
|
|
+
|
|
|
+ * @param key
|
|
|
+
|
|
|
+ * @return
|
|
|
+
|
|
|
+ * @throws Exception
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public static String encryptBASE64(String key) throws Exception{
|
|
|
+
|
|
|
+ return (new BASE64Encoder()).encode(key.getBytes());
|
|
|
+
|
|
|
+ }
|
|
|
+}
|