Browse Source

0516修改 定时生成台账

luguang 6 months ago
parent
commit
2dbfa16c13

+ 3 - 0
20240516.sql

@@ -0,0 +1,3 @@
+ALTER TABLE `tenant_coinage`.`rfid_delivery`
+    ADD COLUMN `transport_url` varchar(255) NULL COMMENT '运送接收人url' AFTER `securities`,
+ADD COLUMN `branch_url` varchar(255) NULL COMMENT '分行接收人url' AFTER `transport_url`

+ 5 - 5
src/main/java/com/sy/coinage/task/ScheduleTask.java

@@ -60,11 +60,11 @@ public class ScheduleTask {
     private IWorkshopAccountService workshopAccountService;
 
     // 每天02:00:00 执行生成台账
-//    @Scheduled(cron = everyDay02)
-//    private void createAccount() {
-//        log.debug("执行了定时任务={}", "每天02:00:00生成台账");
-//        this.workshopAccountService.createAccount(new Date(), 2);
-//    }
+    @Scheduled(cron = everyDay02)
+    private void createAccount() {
+        log.debug("执行了定时任务={}", "每天02:00:00生成台账");
+        this.workshopAccountService.createAccount(new Date(), 2);
+    }
 
 
     // -------websocket每30秒执行

+ 55 - 4
src/main/java/com/sy/coinage/workshop/controller/DeliveryController.java

@@ -1,7 +1,9 @@
 package com.sy.coinage.workshop.controller;
 
+import com.sy.coinage.config.CustomConfig;
 import com.sy.coinage.core.redis.RedisService;
 import com.sy.coinage.core.util.DateUtils;
+import com.sy.coinage.file.model.MyFile;
 import com.sy.coinage.sys.model.Dict;
 import com.sy.coinage.sys.service.IDictService;
 import com.sy.coinage.workshop.service.IProductService;
@@ -15,10 +17,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import com.sy.coinage.core.annotation.ActiveFastJsonProfile;
 import com.sy.coinage.core.annotation.CurrentUser;
@@ -39,6 +38,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.util.Date;
 
 /**
  * -发货单主表Controller
@@ -60,6 +63,9 @@ public class DeliveryController extends BaseController {
     @Autowired
     private IDictService dictService;
 
+    @Autowired
+    private CustomConfig customConfig;
+
     /**
      * 发货单主表分页列表
      */
@@ -210,4 +216,49 @@ public class DeliveryController extends BaseController {
         return "";
     }
 
+    @PostMapping("/imp")
+    public Object imp(@RequestParam(required = true) MultipartFile file,
+                      @RequestParam(required = true) Integer id, @RequestParam(required = true) Integer type,
+                      @CurrentUser CacheUserVO user) throws Exception {
+        String saveUrl = this.imp(file);
+        Delivery model = this.deliveryService.getById(id);
+        String filePath = customConfig.getAttaPath() + model.getTransportUrl();
+        File f = new File(filePath);
+        if (f.exists()) {
+            f.delete();
+        }
+        if (type != null && type == 1) {
+            model.setTransportUrl(saveUrl);
+        } else {
+            model.setBranchUrl(saveUrl);
+        }
+        this.deliveryService.updateById(model);
+        return "";
+    }
+
+    private String imp(MultipartFile file) throws Exception {
+        String date = DateUtils.toString(new Date(), DateUtils.YYMMDD);
+        // 上传文件的名称
+        String fname = file.getOriginalFilename();
+        // 获取后缀
+        String sufferFix = fname.substring(fname.lastIndexOf("."));
+        // 访问url
+        String fileUrl = customConfig.getPathUrl() + "/" + date;
+        // 存储路径
+        String filePath = customConfig.getAttaPath() + fileUrl;
+        File path = new File(filePath);
+        if (!path.exists()) {
+            path.mkdirs();
+        }
+        long s = System.currentTimeMillis();
+        // 文件访问url
+        String saveUrl = fileUrl + "/" + s + sufferFix;
+        // 文件存储路径
+        String savePath = filePath + "/" + s + sufferFix;
+        File dest = new File(savePath);
+        // 生成临时文件
+        file.transferTo(dest.getAbsoluteFile());
+        return saveUrl;
+    }
+
 }

+ 8 - 0
src/main/java/com/sy/coinage/workshop/model/Delivery.java

@@ -140,6 +140,14 @@ public class Delivery implements Serializable {
     @TableField(value = "securities")
     private String securities;
 
+    @ApiModelProperty(value = "运送接收人url")
+    @TableField(value = "transport_url")
+    private String transportUrl;
+
+    @ApiModelProperty(value = "分行接收人url")
+    @TableField(value = "branch_url")
+    private String branchUrl;
+
     @ApiModelProperty(value = "明细集合")
     @TableField(select = false, exist = false)
     List<DeliveryDetail> detailList;