| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.io.resource.ResourceUtil; |
| | | import cn.hutool.core.text.csv.CsvData; |
| | | import cn.hutool.core.text.csv.CsvReader; |
| | | import cn.hutool.core.text.csv.CsvRow; |
| | | import cn.hutool.core.text.csv.CsvUtil; |
| | | import cn.hutool.core.util.CharsetUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.annotation.ValueAuth; |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.dto.DataReportingCsvDto; |
| | | import com.yuanchu.mom.dto.DataReportingPageDto; |
| | | import com.yuanchu.mom.dto.ProductCountDto; |
| | | import com.yuanchu.mom.dto.RegistrantCountDto; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.tomcat.util.http.fileupload.FileUtils; |
| | | import org.springframework.util.FileCopyUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.nio.file.Files; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | @RequestMapping("/dataReporting") |
| | | @RestController |
| | |
| | | @PostMapping("/upDataReporting") |
| | | public Result upDataReporting(@RequestBody DataReporting dataReporting) { |
| | | return Result.success(dataReportingService.updateDataReporting(dataReporting)); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除数据上报信息") |
| | | @PostMapping("/delDataReporting") |
| | | public Result delDataReporting(Integer id) { |
| | | return Result.success(dataReportingService.delDataReporting(id)); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取项目汇总列表") |
| | |
| | | |
| | | @ApiOperation(value = "删除进粉上报列表") |
| | | @PostMapping("/delFansSubmit") |
| | | public Result delFansSubmit(Integer id){ |
| | | public Result delFansSubmit(Integer id) { |
| | | return Result.success(fansSubmitService.delFansSubmit(id)); |
| | | } |
| | | |
| | |
| | | |
| | | @ApiOperation(value = "删除财务上报列表") |
| | | @PostMapping("/delFinanceSubmit") |
| | | public Result delFinanceSubmit(Integer id){ |
| | | public Result delFinanceSubmit(Integer id) { |
| | | return Result.success(financeSubmitService.delFinanceSubmit(id)); |
| | | } |
| | | |
| | |
| | | return Result.success(financeSubmitService.addFinanceSubmit(financeSubmit)); |
| | | } |
| | | |
| | | @ValueAuth |
| | | @ApiOperation(value = "获取首页数据") |
| | | @GetMapping("/getDataList") |
| | | @ValueAuth |
| | | public Result<?> getDataList() { |
| | | return Result.success(dataReportingService.getDataList()); |
| | | } |
| | | |
| | | @ValueAuth |
| | | @ApiOperation(value = "导入") |
| | | @PostMapping("/inputCsv") |
| | | public Result<?> inputCsv(@RequestParam("file") MultipartFile file) throws IOException { |
| | | CsvReader reader = CsvUtil.getReader(); |
| | | CsvData data = reader.read(new InputStreamReader(file.getInputStream(), "GB2312")); |
| | | List<CsvRow> rows = data.getRows(); |
| | | List<DataReporting> list = new ArrayList<>(); |
| | | for (int i = 5; i < rows.size(); i++) { |
| | | DataReporting reporting = new DataReporting(); |
| | | reporting.setName(rows.get(i).get(0)) |
| | | .setProduct(rows.get(i).get(1)) |
| | | .setShowNum(Integer.valueOf(rows.get(i).get(3))) |
| | | .setClick(Integer.valueOf(rows.get(i).get(4))) |
| | | // .setAvgPrice(new BigDecimal(rows.get(i).get(5))) |
| | | .setAccountConsumption(new BigDecimal(rows.get(i).get(6))); |
| | | // .setSearchBalance(new BigDecimal(rows.get(i).get(6))) |
| | | // .setInfoBalance(new BigDecimal(rows.get(i).get(7))) |
| | | // .setVxClick(Double.valueOf(rows.get(i).get(8))) |
| | | // .setClickThroughRate(rows.get(i).get(9)); |
| | | list.add(reporting); |
| | | } |
| | | dataReportingService.addDataReporting(list); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "新增数据上报") |
| | | @PostMapping("/addDataReporting") |
| | | public Result<?> addDataReporting(@RequestBody DataReporting dataReporting) { |
| | | ArrayList<DataReporting> list = new ArrayList<>(); |
| | | list.add(dataReporting); |
| | | dataReportingService.addDataReporting(list); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出数据上报列表") |
| | | @PostMapping("/downDataReportingFile") |
| | | public Result downDataReportingFile(@RequestBody Map<String, Object> data) { |
| | | Page page = JSON.parseObject(JSON.toJSONString(data.get("page")), Page.class); |
| | | DataReportingPageDto dataReportingPageDto = JSON.parseObject(JSON.toJSONString(data.get("entity")), DataReportingPageDto.class); |
| | | return Result.success(dataReportingService.downDataReportingFile(page, dataReportingPageDto)); |
| | | } |
| | | |
| | | } |