|
@@ -0,0 +1,47 @@
|
|
|
+package com.malk.lanyun.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.lang.UUID;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.malk.lanyun.entity.Budget;
|
|
|
+import com.malk.lanyun.listener.BudgetListener;
|
|
|
+import com.malk.server.common.McException;
|
|
|
+import com.malk.server.common.McR;
|
|
|
+import com.malk.service.aliwork.YDClient;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 宜搭传入预算文件解析
|
|
|
+ * @author floe
|
|
|
+ * @date 2024/12/2 21:14
|
|
|
+ */
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/yd/")
|
|
|
+public class YdYsController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private YDClient ydClient;
|
|
|
+
|
|
|
+ @PostMapping("saveYsDataByFile")
|
|
|
+ public McR saveYsDataByFile(@RequestBody JSONObject param) {
|
|
|
+ log.info("解析预算文件,入参: {} ", param);
|
|
|
+ McException.assertParamException_Null(param,"url","type","yearStr","year");
|
|
|
+ String id= UUID.randomUUID().toString();
|
|
|
+ String fileName = "/home/"+id+".xlsx";
|
|
|
+ String url=ydClient.convertTemporaryUrl(param.getString("url"));
|
|
|
+ HttpUtil.downloadFile(url,fileName);
|
|
|
+ EasyExcel.read(fileName, Budget.class, new BudgetListener(ydClient,param.getString("type"),param.getString("yearStr"),param.getString("year"))).sheet().headRowNumber(3).doRead();
|
|
|
+ FileUtil.del(fileName);
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|