diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java index 5ab5fdee..fc61d10b 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java @@ -272,7 +272,12 @@ public class AbnormalBillServiceImpl extends ServiceImpl abnormalBillList = abnormalBillMapper.selectList(queryWrapper); if (abnormalBillList.size()>0){ AbnormalBill abnormalBilltop=abnormalBillList.get(0); - if (StringUtils.isBlank(abnormalBilltop.getProgram()) && !abnormalBilltop.getStatus().equals("Q")){ + /** + * SFC数量 + */ + String handle = HandleEnum.SFC.getHandle(site, abnormalBill.getSfc()); + Sfc sfcServiceById = sfcService.getById(handle); + if (StringUtils.isBlank(abnormalBilltop.getProgram()) && !abnormalBilltop.getStatus().equals("Q") && sfcServiceById.getQty().equals(abnormalBill.getNcQty())){ throw new BaseException("此SFC的上一个异常还没有进行方案确认,请联系工艺评审人员进行处理!"); } } diff --git a/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java b/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java index 550f1001..c74ee601 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java @@ -13,7 +13,6 @@ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; -import com.sun.deploy.net.URLEncoder; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.apache.poi.ss.usermodel.Workbook; @@ -49,6 +48,9 @@ public class FileController { @Autowired public DrawingFtpClient ftpClient; + + @Autowired + private DrawingFtpClient drawingFtpClient; @Autowired public WorkmanshipCardFtpClient workmanshipCardFtpClient; @@ -127,6 +129,7 @@ public class FileController { String path = request.getParameter("Path"); String type = request.getParameter("Type"); + try { //服务器发布 //String coderPath = new String(path.getBytes("ISO8859_1")); @@ -138,9 +141,11 @@ public class FileController { // } if (null == in) { if (type.equals("DRAWING")){ + jSchClient = new JSchClient(drawingFtpClient.getAddress(), drawingFtpClient.getUserName(), + drawingFtpClient.getPassword(), drawingFtpClient.getPort()); jSchClient.connectSFTP(); - in = jSchClient.getSFTP(path); - //in = fileService.getSFTP(path); + in = jSchClient.getSFTP(path); + // in = fileService.getSFTP(path); }else { in = workmanshipCardFtpClient.getFtp(new String(path.getBytes("GBK"), FTPClient.DEFAULT_CONTROL_ENCODING)); } @@ -179,7 +184,6 @@ public class FileController { } catch (Exception e) { return R.failed("获取文件失败:文件路径为" + path + ":" + e.getMessage()); } finally { - try { if (null != out) { out.close(); @@ -190,10 +194,10 @@ public class FileController { if (null != outStream){ outStream.close(); } + if (jSchClient != null ){ jSchClient.close(); } - } catch (Exception e1) { return R.failed("获取文件失败:关闭文件流处理异常" + e1.getMessage()); } @@ -206,51 +210,51 @@ public class FileController { * * @return */ - @ResponseBody - @RequestMapping(method = RequestMethod.GET, value = "/LabelPrintPdf/{fileName}") - public R getLabelPrintPdf(HttpServletRequest request, HttpServletResponse response, @PathVariable("fileName") String fileName) { - InputStream in = null; - OutputStream out = null; - String path = request.getParameter("Path").replace('-', '/'); - ; - try { - //服务器发布 - in = ftpClient.getFtp(path); - if (null == in) { - in = ftpClient.getFtp(new String(path.getBytes("GBK"), FTPClient.DEFAULT_CONTROL_ENCODING)); - } - - if (null == in) { - throw new BaseException("获取FTP文件路径为:【" + path + "】的文件流失败!"); - } - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - int nRead; - byte[] data = new byte[16384]; - while ((nRead = in.read(data, 0, data.length)) != -1) { - buffer.write(data, 0, nRead); - } - byte[] data2 = buffer.toByteArray(); - out = response.getOutputStream(); - out.write(data2); - out.flush(); - - } catch (Exception e) { - return R.failed("下载文件失败:文件路径为" + path + ":" + e.getMessage()); - } finally { - try { - if (null != out) { - out.close(); - } - if (null != in) { - in.close(); - } - - } catch (Exception e1) { - return R.failed("下载文件失败:关闭文件流处理异常" + e1.getMessage()); - } - } - return R.ok(null, "下载文件成功!"); - } +// @ResponseBody +// @RequestMapping(method = RequestMethod.GET, value = "/LabelPrintPdf/{fileName}") +// public R getLabelPrintPdf(HttpServletRequest request, HttpServletResponse response, @PathVariable("fileName") String fileName) { +// InputStream in = null; +// OutputStream out = null; +// String path = request.getParameter("Path").replace('-', '/'); +// ; +// try { +// //服务器发布 +// in = ftpClient.getFtp(path); +// if (null == in) { +// in = ftpClient.getFtp(new String(path.getBytes("GBK"), FTPClient.DEFAULT_CONTROL_ENCODING)); +// } +// +// if (null == in) { +// throw new BaseException("获取FTP文件路径为:【" + path + "】的文件流失败!"); +// } +// ByteArrayOutputStream buffer = new ByteArrayOutputStream(); +// int nRead; +// byte[] data = new byte[16384]; +// while ((nRead = in.read(data, 0, data.length)) != -1) { +// buffer.write(data, 0, nRead); +// } +// byte[] data2 = buffer.toByteArray(); +// out = response.getOutputStream(); +// out.write(data2); +// out.flush(); +// +// } catch (Exception e) { +// return R.failed("下载文件失败:文件路径为" + path + ":" + e.getMessage()); +// } finally { +// try { +// if (null != out) { +// out.close(); +// } +// if (null != in) { +// in.close(); +// } +// +// } catch (Exception e1) { +// return R.failed("下载文件失败:关闭文件流处理异常" + e1.getMessage()); +// } +// } +// return R.ok(null, "下载文件成功!"); +// } public static char byteToChar(byte[] b) { int hi = (b[0] & 0xFF) << 8; diff --git a/common/src/main/java/com/foreverwin/mesnac/common/ftp/JSchClient.java b/common/src/main/java/com/foreverwin/mesnac/common/ftp/JSchClient.java index e8ee3df9..bece0474 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/ftp/JSchClient.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/ftp/JSchClient.java @@ -104,6 +104,7 @@ public class JSchClient { } + public InputStream downloadStream(String directory, String downloadFile){ ChannelSftp sftp; try{ diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/FileServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/FileServiceImpl.java index 3d77ed22..857cc5fd 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/FileServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/FileServiceImpl.java @@ -226,19 +226,19 @@ public class FileServiceImpl implements FileService { if (itemBo.contains(",")) { itemBos = itemBo.split(","); -// for (String item : itemBos) { -// //通过SFTP连接服务器 -// jSchClient.connectSFTP(); -// if (version==null || version.equals("")){ -// version =GetDrawingVersionSFTP(item, jSchClient, drawingFtpClient.getDownloadDir()); -// } -// if (null != version) { -// //拼接文件路径 -// String ftpFilePath = drawingFtpClient.getDownloadDir() + "/" + item + "_" + version + "/" + -// item + "_" + version + ".PDF"; -// pathMap.put(item + "_" + version + ".PDF", ftpFilePath); -// } -// } + for (String item : itemBos) { + //通过SFTP连接服务器 + jSchClient.connectSFTP(); + if (version==null || version.equals("")){ + version =GetDrawingVersionSFTP(item, jSchClient, drawingFtpClient.getDownloadDir()); + } + if (null != version) { + //拼接文件路径 + String ftpFilePath = drawingFtpClient.getDownloadDir() + "/" + item + "_" + version + "/" + + item + "_" + version + ".PDF"; + pathMap.put(item + "_" + version + ".PDF", ftpFilePath); + } + } } else { //单物料编码传入 @@ -258,11 +258,10 @@ public class FileServiceImpl implements FileService { } catch (Exception e) { e.printStackTrace(); } -// finally { -// jSchClient.close(); -// } } - + if (jSchClient != null){ + jSchClient.close(); + } } if (pathMap == null || pathMap.size() == 0) { throw new BaseException("未找到图纸相应信息,请在图纸管理系统申请!"); diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ProdReadyTaskServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ProdReadyTaskServiceImpl.java index d9b97f76..8106a86b 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ProdReadyTaskServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ProdReadyTaskServiceImpl.java @@ -478,7 +478,11 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl