diff --git a/src/main/java/com/zcloud/aspect/DockingAspect.java b/src/main/java/com/zcloud/aspect/DockingAspect.java index 817e3d28..a6aa51f9 100644 --- a/src/main/java/com/zcloud/aspect/DockingAspect.java +++ b/src/main/java/com/zcloud/aspect/DockingAspect.java @@ -15,6 +15,7 @@ import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -32,7 +33,8 @@ public class DockingAspect { private DockSendMessageService sendMessageService; @Autowired private DockingRelationService dockingRelationService; - + @Value("${baseimgpath}") + public String baseimgpath; @Pointcut("@annotation(com.zcloud.aspect.DockAnnotation)") public void pointcut() { } @@ -172,7 +174,7 @@ public class DockingAspect { sendData.put("url", servletPath); // 有存自己表里的图片 把自己图片服务器的前缀传过去 if (annotation.hasAnnex()) { - sendData.put("baseImgPath", "czks-baseimgpath"); + sendData.put("BASEIMGPATH", "czks-baseimgpath"); // 自己表里的图片集合 sendData.put("sendPicturesList", proceed.get("sendPicturesList")); proceed.remove("sendPicturesList"); @@ -191,6 +193,7 @@ public class DockingAspect { tenCorpDto.setTopic("docking"); tenCorpDto.setProducer_name("qa-prevention-czks"); sendMessageService.sendMessage(tenCorpDto); + System.out.println("------------------------切面方法结束------------------------"); } @PostConstruct diff --git a/src/main/java/com/zcloud/controller/filemanager/MfolderController.java b/src/main/java/com/zcloud/controller/filemanager/MfolderController.java index b0a088ac..c772cfa6 100644 --- a/src/main/java/com/zcloud/controller/filemanager/MfolderController.java +++ b/src/main/java/com/zcloud/controller/filemanager/MfolderController.java @@ -5,10 +5,7 @@ import com.zcloud.aspect.DockAnnotation; import net.sf.json.JSONArray; import java.io.Console; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import javax.servlet.http.HttpServletResponse; @@ -82,6 +79,7 @@ public class MfolderController extends BaseController { @RequestMapping(value="/upload") @RequiresPermissions("mfolder:add") @ResponseBody + @DockAnnotation(hasAnnex = true) public Object add( @RequestParam(value="FFILE",required=false) MultipartFile file, @RequestParam(value="NAME",required=false) String NAME, @@ -90,6 +88,7 @@ public class MfolderController extends BaseController { @RequestParam(value="SHARE",required=false) String SHARE ) throws Exception{ Map map = new HashMap(); + ArrayList pictureList = new ArrayList<>(); String errInfo = "success"; PageData pd = new PageData(); String ffile = DateUtil.getDays(), fileName = ""; @@ -118,10 +117,13 @@ public class MfolderController extends BaseController { pd.put("MFOLDER_ID", this.get32UUID()); //主键 pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 mfolderService.save(pd); //存入数据库表 + pictureList.add(Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName+"@@"+fileName); }else{ errInfo = "fail"; } map.put("result", errInfo); //返回结果 + map.put("dockData", JSON.toJSONString(pd)); //返回结果 + map.put("sendPicturesList", JSON.toJSONString(pictureList)); //返回结果 return map; } diff --git a/src/main/java/com/zcloud/controller/keyProjects/OutSourcedController.java b/src/main/java/com/zcloud/controller/keyProjects/OutSourcedController.java index 96e2f522..f5253b35 100644 --- a/src/main/java/com/zcloud/controller/keyProjects/OutSourcedController.java +++ b/src/main/java/com/zcloud/controller/keyProjects/OutSourcedController.java @@ -428,15 +428,17 @@ public class OutSourcedController extends BaseController { String ffile = DateUtil.getDays(); String fileName = this.get32UUID() + file9One.getOriginalFilename(). substring(file9One.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file9One, fileName, Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile); PageData pdImg = new PageData(); String fileUpdateName = file9One.getOriginalFilename(); + String IMGFILES_ID = this.get32UUID(); pdImg.put("IMGFILES_ID", this.get32UUID()); pdImg.put("FILE_NAME", fileUpdateName); pdImg.put("FILEPATH", Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName); pdImg.put("TYPE", "300"); pdImg.put("FOREIGN_KEY", pd.getString("OUTSOURCED_ID")); imgfilesService.save(pdImg); + Smb.sshSftp(file9One, fileName, Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile,IMGFILES_ID,pd.getString("OUTSOURCED_ID"),"300"); + } } diff --git a/src/main/java/com/zcloud/service/mq/DockSendMessageService.java b/src/main/java/com/zcloud/service/mq/DockSendMessageService.java index 9f3b4ab4..64d3b3e3 100644 --- a/src/main/java/com/zcloud/service/mq/DockSendMessageService.java +++ b/src/main/java/com/zcloud/service/mq/DockSendMessageService.java @@ -5,6 +5,7 @@ import com.zcloud.dto.TenCorpDto; public interface DockSendMessageService { void sendMessage(TenCorpDto tenCorpDto) throws Exception; + void sendMessagePicture(TenCorpDto tenCorpDto) throws Exception; void SendDelayQueue(TenCorpDto tenCorpDto); void SendDelayQueue(String message); diff --git a/src/main/java/com/zcloud/service/mq/impl/DockSendMessageServiceImpl.java b/src/main/java/com/zcloud/service/mq/impl/DockSendMessageServiceImpl.java index 3ed3b704..cc2cc2b0 100644 --- a/src/main/java/com/zcloud/service/mq/impl/DockSendMessageServiceImpl.java +++ b/src/main/java/com/zcloud/service/mq/impl/DockSendMessageServiceImpl.java @@ -24,7 +24,8 @@ public class DockSendMessageServiceImpl implements DockSendMessageService { @Value("${mq.topic.docking}") private String docking; - + @Value("${mq.topic.dockingPicture}") + private String dockingPicture; @Resource private RocketMQTemplate rocketMQTemplate; @@ -37,6 +38,7 @@ public class DockSendMessageServiceImpl implements DockSendMessageService { @Resource private MqMessageLogMapper mqMessageLogMapper; + @Override public void sendMessage(TenCorpDto tenCorpDto) throws Exception { try { PageData log = tenCorpDto.getPd(); @@ -59,6 +61,29 @@ public class DockSendMessageServiceImpl implements DockSendMessageService { } } + @Override + public void sendMessagePicture(TenCorpDto tenCorpDto) throws Exception { + try { + PageData log = tenCorpDto.getPd(); + log.put("MESSAGE_LOG_ID", Warden.get32UUID()); + log.put("CREATE_TIME", DateUtil.getTime()); + mqMessageLogMapper.save(log); + System.out.println("生产者:" + tenCorpDto.toString()); + SendResult sendResult = rocketMQTemplate.syncSend(this.dockingPicture, tenCorpDto.toString()); + if (!sendResult.getSendStatus().equals(SendStatus.SEND_OK)) { + throw new RuntimeException("产品入栈失败"); + } + } catch (Exception e) { + e.printStackTrace(); + PageData log = tenCorpDto.getPd(); + log.put("MESSAGE_ERROR_LOG_ID", Warden.get32UUID()); + log.put("ERROR_MESSAGE", e.getMessage()); + log.put("TYPE", "0"); + log.put("TIME", DateUtil.getTime()); + mqErrorMessageLogMapper.save(log); + } + } + @Override public void SendDelayQueue(TenCorpDto tenCorpDto) { PageData log = tenCorpDto.getPd(); diff --git a/src/main/java/com/zcloud/util/Smb.java b/src/main/java/com/zcloud/util/Smb.java index 4b1c97e9..5d928701 100644 --- a/src/main/java/com/zcloud/util/Smb.java +++ b/src/main/java/com/zcloud/util/Smb.java @@ -4,7 +4,11 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Vector; +import com.zcloud.dto.TenCorpDto; +import com.zcloud.entity.PageData; +import com.zcloud.service.mq.DockSendMessageService; import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @@ -29,9 +33,8 @@ public class Smb { public static String user; public static String password; public static String basePath; + public static String baseimgpath; - @Resource - private RocketMQTemplate rocketMQTemplate; @Value("${smb.host}") public void setHostPath(String hostProperties) { host = hostProperties; @@ -47,6 +50,11 @@ public class Smb { user = userProperties; } + @Value("${baseimgpath}") + public void setbaseimgpathProperties(String baseimgpathProperties) { + baseimgpath = baseimgpathProperties; + } + @Value("${smb.password}") public void setPasswordPath(String passwordProperties) { password = passwordProperties; @@ -141,12 +149,13 @@ public class Smb { } } } + /* * bus_imgfiles表 * IMGFILES_ID,FOREIGN_KEY,TYPE * 这三个值必须要传,所以用到Smb.sshSftp * */ - public static void sshSftp(MultipartFile file, String fileName, String path,String IMGFILES_ID,String FOREIGN_KEY,String TYPE) throws Exception { + public static void sshSftp(MultipartFile file, String fileName, String path, String IMGFILES_ID, String FOREIGN_KEY, String TYPE) throws Exception { Session session = null; Channel channel = null; JSch jsch = new JSch(); @@ -189,9 +198,23 @@ public class Smb { // System.out.println(v.get(i)); // } // 以下代码实现从本地上传一个文件到服务器,如果要实现下载,对换以下流就可以了 - + DockSendMessageService sendMessageService = SpringUtil.getBean(DockSendMessageService.class); sftp.put(file.getInputStream(), fileName); + PageData pageData = new PageData(); + pageData.put("IMGFILES_ID", IMGFILES_ID); + pageData.put("FOREIGN_KEY", FOREIGN_KEY); + pageData.put("TYPE", TYPE); + pageData.put("BASEIMGPATH", baseimgpath); + pageData.put("FILEPATH", path); + pageData.put("FILENAME", fileName); + TenCorpDto tenCorpDto = new TenCorpDto(); + tenCorpDto.setMessage("图片消息"); + tenCorpDto.setData(pageData); + tenCorpDto.setId(UuidUtil.get32UUID()); + tenCorpDto.setTopic("dockingPicture"); + tenCorpDto.setProducer_name("qa-prevention-czks"); + sendMessageService.sendMessagePicture(tenCorpDto); } catch (Exception e) { e.printStackTrace(); } finally { @@ -208,12 +231,13 @@ public class Smb { } } } + /* * bus_imgfiles表 * IMGFILES_ID,FOREIGN_KEY,TYPE * 这三个值必须要传,所以用到Smb.sshSftp * */ - public static void sshSftpForInput(InputStream fileI, String fileName, String path,String IMGFILES_ID,String FOREIGN_KEY,String TYPE) throws Exception { + public static void sshSftpForInput(InputStream fileI, String fileName, String path, String IMGFILES_ID, String FOREIGN_KEY, String TYPE) throws Exception { Session session = null; Channel channel = null; JSch jsch = new JSch(); @@ -258,7 +282,20 @@ public class Smb { // 以下代码实现从本地上传一个文件到服务器,如果要实现下载,对换以下流就可以了 sftp.put(fileI, fileName); + DockSendMessageService sendMessageService = SpringUtil.getBean(DockSendMessageService.class); + PageData pageData = new PageData(); + pageData.put("IMGFILES_ID", IMGFILES_ID); + pageData.put("FOREIGN_KEY", FOREIGN_KEY); + pageData.put("TYPE", TYPE); + pageData.put("FILEPATCH", path); + TenCorpDto tenCorpDto = new TenCorpDto(); + tenCorpDto.setMessage("文件消息"); + tenCorpDto.setData(pageData); + tenCorpDto.setId(UuidUtil.get32UUID()); + tenCorpDto.setTopic("docking"); + tenCorpDto.setProducer_name("qa-prevention-czks"); + sendMessageService.sendMessagePicture(tenCorpDto); } catch (Exception e) { e.printStackTrace(); } finally { diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 1a7480dd..7f202d9d 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -43,14 +43,9 @@ spring.main.banner-mode=off preventionxgf.api.url=http://192.168.0.31:8992/qa-prevention-xgf/ qa-regulatory-gwj.api.url=http://192.168.0.31:8992/qa-regulatory-gwj/ -#??????? -smb.host=39.103.224.166 -smb.port=22 -smb.user=root -smb.password=Zcloud@zcloud88888 -smb.basePath=/mnt/qgfile/file/ -#???????????? -baseimgpath = https://qgqy.qhdsafety.com/file/ + + + #???????? czks-useridentity=CZKS czks-baseimgpath=https://qgqy.qhdsafety.com/file/ @@ -61,7 +56,7 @@ gwj-baseimgpath=https://qgqy.qhdsafety.com/file/ gwj-backendaddr=http://192.168.0.31:8991/qa-prevention-gwj/ #mq ??????????? -rocketmq.name-server=192.168.0.75:9876 +rocketmq.name-server=192.168.0.79:9876 rocketmq.producer.group=libmiddle rocketmq.producer.send-message-timeout=3000 rocketmq.producer.compress-message-body-threshold=4096 @@ -77,6 +72,7 @@ mq.group.eightWork=scheduled_tasks_eightWork #???? mq.topic.docking=docking +mq.topic.dockingPicture=dockingPicture mq.group.docking=scheduled_tasks_docking #?????? @@ -84,3 +80,11 @@ perLoc.url=http://192.168.210.32:8084 perLoc.userName=qaaqadmin perLoc.pwd=Cfd2023@ +#??????? +smb.host=39.101.130.96 +smb.port=22 +smb.user=root +smb.password=Zcloud@zcloud88888 +smb.basePath=/mnt/wwag/file/ +#???????????? +baseimgpath =https://wwag.qhdsafety.com/file/ diff --git a/src/main/resources/application-master.properties b/src/main/resources/application-master.properties index 53999d54..9355fea6 100644 --- a/src/main/resources/application-master.properties +++ b/src/main/resources/application-master.properties @@ -30,8 +30,10 @@ spring.datasource.testOnBorrow: false spring.datasource.testOnReturn: false #?????????filters????????sql?????,'wall'????? filters: stat, wall, log4j + #???????????? baseimgpath = https://qgqy.qhdsafety.com/ + #???????? spring.cache.ehcache.cofnig=ehcache.xml @@ -65,7 +67,7 @@ smb.host=192.168.192.201 smb.port=22 smb.user=root smb.password=SJSKAQHBGLXT@20220311 -smb.basePath=/mnt/qask/file/ +smb.basePath=/mnt/qask/file/czks # ???????? czks-useridentity=CZKS