|
@@ -0,0 +1,90 @@
|
|
|
+package org.jeecg.ctop.finance.settlement.controller;
|
|
|
+
|
|
|
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
|
+import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.ctop.finance.settlement.entity.pojo.SettlementInfoPojo;
|
|
|
+import org.jeecg.ctop.finance.settlement.entity.vo.BytedanceAccountImportVo;
|
|
|
+
|
|
|
+
|
|
|
+import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Administrator
|
|
|
+ * 2021/7/28
|
|
|
+ **/
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/finance/settLementController")
|
|
|
+public class SettlementController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISettlementInfoService settlementInfoService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="test", notes="test")
|
|
|
+ @GetMapping(value = "/test")
|
|
|
+ public Result test(
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ PageHelper.startPage(pageNo,pageSize);
|
|
|
+ List<SettlementInfoPojo> list = settlementInfoService.getList();
|
|
|
+ PageInfo<SettlementInfoPojo> pageInfo = new PageInfo<SettlementInfoPojo>(list);
|
|
|
+ return Result.successMsg("chenggong.",pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/import")
|
|
|
+ public Result getProjects(@RequestParam("files") MultipartFile[] files) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ ImportParams importParams = new ImportParams();
|
|
|
+ //表格标题行数
|
|
|
+ importParams.setTitleRows(1);
|
|
|
+ //表头行数
|
|
|
+ importParams.setHeadRows(1);
|
|
|
+ //表头
|
|
|
+ importParams.setImportFields(new String[]{"账户ID", "账户名称"});
|
|
|
+
|
|
|
+ for (MultipartFile file : files) {
|
|
|
+ ExcelImportResult<BytedanceAccountImportVo> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(),BytedanceAccountImportVo.class,importParams);
|
|
|
+ if (excelImportResult.getList().size() < 1){
|
|
|
+ return Result.error("读取Excel失败,数据不能为空,请重新检查数据并导入。");
|
|
|
+ }
|
|
|
+ log.info("{}",excelImportResult.getList());
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ return Result.error("账户数据上传失败,请使用正确的模板导入!");
|
|
|
+ }
|
|
|
+ return Result.successMsg("账户数据上传成功。",null);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|