tangzy
2021-09-01 be923adca382374294dfb44fce92c9c15f7413f1
src/main/java/org/springblade/modules/directive/controller/DirectiveController.java
@@ -4,6 +4,7 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.common.constant.FtpConstant;
import org.springblade.common.utils.arg;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
@@ -33,7 +34,8 @@
   /**
    * 自定义分页
    * @param query page,size
    *
    * @param query     page,size
    * @param directive 指令信息对象
    */
   @GetMapping("/page")
@@ -44,6 +46,7 @@
   /**
    * 新增
    *
    * @param directive 指令信息对象
    */
   @PostMapping("/save")
@@ -55,6 +58,7 @@
   /**
    * 指令信息新增,同时新增图片到指令文件表中
    *
    * @param directive 指令信息对象
    */
   @PostMapping("/saveDirectiveAndFile")
@@ -63,17 +67,36 @@
      boolean status = false;
      directive.setSendTime(new Date());
      status = directiveService.save(directive);
      if (status){
      //数据同步
      String s1 =
         "insert into sys_directive(id,type,send_directive_id,receive_directive_ids,send_time,content) " +
            "values(" + "'" + directive.getId() + "'" + "," +
            "'" + directive.getType() + "'" + "," +
            "'" + directive.getSendDirectiveId() + "'" + "," +
            "'" + directive.getReceiveDirectiveIds() + "'" + "," +
            "'" + directive.getSendTime() + "'" + "," +
            "'" + directive.getContent() + "'" + ")";
      FtpUtil.sqlFileUpload(s1);
      if (status) {
         //新增图片
         if (null!=directive.getUrl() && directive.getUrl()!=""){
         if (null != directive.getUrl() && directive.getUrl() != "") {
            String[] directiveUrl = directive.getUrl().split(",");
            for (String url : directiveUrl) {
               String s = url.substring(26, url.length());
               String urls = FtpConstant.ip + s;
               DirectiveFile directiveFile = new DirectiveFile();
               directiveFile.setType(1);
               directiveFile.setDirectiveId(directive.getId());
               directiveFile.setUrl(url);
               directiveFile.setUrl(urls);
               status = directiveService.saveDirectiveFile(directiveFile);
               if (!status){
               String s2 =
                  "insert into sys_directive_file(id,type,directive_id,url) " +
                     "values(" + "'" + directiveFile.getId() + "'" + "," +
                     "'" + directiveFile.getType() + "'" + "," +
                     "'" + directiveFile.getDirectiveId() + "'" + "," +
                     "'" + urls+ "'"+ ")";
               FtpUtil.sqlFileUpload(s2);
               if (!status) {
                  return R.status(false);
               }
            }
@@ -87,28 +110,44 @@
   /**
    * 指令信息修改,同时新增图片到指令文件表中
    *
    * @param directive 指令信息对象
    */
   @PostMapping("/updateDirectiveAndFile")
   public R updateDirectiveAndFile(@RequestBody DirectiveVo directive) throws Exception {
      //新增指令信息
      boolean update = directiveService.updateById(directive);
      //内网同步
      String s1 = "update sys_directive set type = " + "'" + directive.getType() + "'" +
         ",send_directive_id = " + "'" + directive.getSendDirectiveId() + "'" +
         ",receive_directive_ids = " + "'" + directive.getReceiveDirectiveIds() + "'" +
         ",send_time = " + "'" + directive.getSendTime() + "'" +
         ",content = " + "'" + directive.getContent() + "'" +
         " " + "where id = " + "'" + directive.getId() + "'";
      FtpUtil.sqlFileUpload(s1);
      boolean status = false;
      //内网新增
      //arg.test01(arg.url+"/directive/updateDirectiveAndFile",directive);
      if (update){
      if (update) {
         //先删除图片
         int i = directiveService.deleleByDirectiveId(directive.getId());
         //新增图片
         if (null!=directive.getUrl() && directive.getUrl()!=""){
         if (null != directive.getUrl() && directive.getUrl() != "") {
            String[] directiveUrl = directive.getUrl().split(",");
            for (String url : directiveUrl) {
               String s = url.substring(26, url.length());
               String urls = FtpConstant.ip + s;
               DirectiveFile directiveFile = new DirectiveFile();
               directiveFile.setType(1);
               directiveFile.setDirectiveId(directive.getId());
               directiveFile.setUrl(url);
               status = directiveService.saveDirectiveFile(directiveFile);
               if (!status){
               String s2 =
                  "insert into sys_directive_file(id,type,directive_id,url) " +
                     "values(" + "'" + directiveFile.getId() + "'" + "," +
                     "'" + directiveFile.getType() + "'" + "," +
                     "'" + directiveFile.getDirectiveId() + "'" + "," +
                     "'" + urls + "'"+ ")";
               FtpUtil.sqlFileUpload(s2);
               if (!status) {
                  R.status(false);
               }
            }
@@ -121,6 +160,7 @@
   /**
    * 修改
    *
    * @param directive 指令信息对象
    */
   @PostMapping("/update")
@@ -130,6 +170,7 @@
   /**
    * 新增或修改
    *
    * @param directive 指令信息对象
    */
   @PostMapping("/submit")
@@ -139,12 +180,13 @@
   /**
    * 删除
    *
    * @param ids 指令信息ids 数组
    */
   @PostMapping("/remove")
   public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
      //图片也删除
      if (null!=ids && ids!=""){
      if (null != ids && ids != "") {
         String[] directiveIds = ids.split(",");
         for (String directiveId : directiveIds) {
            directiveService.deleleByDirectiveId(Long.parseLong(directiveId));
@@ -157,6 +199,7 @@
   /**
    * 详情
    *
    * @param directive 指令信息对象
    */
   @GetMapping("/detail")
@@ -169,6 +212,7 @@
   /**
    * 自定义详情查询
    *
    * @param directive 指令信息对象
    */
   @GetMapping("/details")