| | |
| | | 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.*; |
| | | import com.yuanchu.mom.exception.ErrorException; |
| | | import com.yuanchu.mom.pojo.DataReporting; |
| | |
| | | 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 javax.validation.constraints.NotBlank; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.nio.file.Files; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | |
| | | @RequestMapping("/dataReporting") |
| | |
| | | @ApiOperation(value = "添加财务上报信息") |
| | | @PostMapping("/addFinanceSubmit") |
| | | public Result<?> addFinanceSubmit(@RequestBody FinanceSubmit financeSubmit, String date) { |
| | | return Result.success(financeSubmitService.addFinanceSubmit(financeSubmit, date)); |
| | | return Result.success(financeSubmitService.addFinanceSubmit(financeSubmit, date, financeSubmit.getParam())); |
| | | } |
| | | |
| | | @ValueAuth |
| | |
| | | |
| | | @ApiOperation(value = "导入数据上报列表") |
| | | @PostMapping("/inputCsv") |
| | | public Result<?> inputCsv(@RequestParam("file") MultipartFile file) throws IOException { |
| | | public Result<?> inputCsv(@RequestParam("file") MultipartFile file, String param) throws IOException { |
| | | CsvReader reader = CsvUtil.getReader(); |
| | | CsvData data = reader.read(new InputStreamReader(file.getInputStream(), "GB2312")); |
| | | List<CsvRow> rows = data.getRows(); |
| | |
| | | e.printStackTrace(); |
| | | throw new ErrorException("文件中日期在转换时出现错误"); |
| | | } |
| | | for (int i = 6; i < rows.size(); i++) { |
| | | int fieldIndex = 5; |
| | | for (int i = 0; i < rows.size(); i++) { |
| | | if (JSON.toJSONString(rows.get(i)).contains("账户ID")) { |
| | | fieldIndex = i; |
| | | break; |
| | | } |
| | | } |
| | | for (int i = fieldIndex + 1; i < rows.size(); i++) { |
| | | DataReporting reporting = new DataReporting(); |
| | | for (int i1 = 0; i1 < rows.get(5).size(); i1++) { |
| | | for (int i1 = 0; i1 < rows.get(fieldIndex).size(); i1++) { |
| | | String str = rows.get(i).get(i1); |
| | | if (str == null) continue; |
| | | switch (rows.get(5).get(i1)) { |
| | | switch (rows.get(fieldIndex).get(i1)) { |
| | | case "账户": |
| | | reporting.setName(str); |
| | | break; |
| | | case "备注": |
| | | String[] split = str.split("-"); |
| | | if (split.length == 4) { |
| | | if (split.length > 3) { |
| | | reporting.setName2(split[0]); |
| | | reporting.setChannel(split[1]); |
| | | reporting.setAgent(split[2]); |
| | | reporting.setProduct(split[3]); |
| | | reporting.setChannel(split[2]); |
| | | reporting.setAgent(split[3]); |
| | | reporting.setProduct(split[1]); |
| | | break; |
| | | } |
| | | reporting.setProduct(str); |
| | | break; |
| | | case "展现量": |
| | | reporting.setShowNum(Integer.parseInt(str)); |
| | | try { |
| | | reporting.setShowNum(Integer.parseInt(str)); |
| | | } catch (Exception e) { |
| | | } |
| | | break; |
| | | case "点击量": |
| | | reporting.setClick(Integer.parseInt(str)); |
| | | try { |
| | | reporting.setClick(Integer.parseInt(str)); |
| | | } catch (Exception e) { |
| | | } |
| | | break; |
| | | case "消费": |
| | | reporting.setAccountConsumption(new BigDecimal(str)); |
| | | try { |
| | | reporting.setAccountConsumption(new BigDecimal(str)); |
| | | } catch (Exception e) { |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | list.add(reporting); |
| | | } |
| | | dataReportingService.addDataReporting(list, format); |
| | | dataReportingService.addDataReporting(list, format, param); |
| | | return Result.success(); |
| | | } |
| | | |
| | |
| | | public Result<?> addDataReporting(@RequestBody DataReporting dataReporting) { |
| | | ArrayList<DataReporting> list = new ArrayList<>(); |
| | | list.add(dataReporting); |
| | | dataReportingService.addDataReporting(list, null); |
| | | dataReportingService.addDataReporting(list, null,dataReporting.getVxCard()); |
| | | return Result.success(); |
| | | } |
| | | |
| | |
| | | |
| | | @ApiOperation(value = "导入财务上报列表") |
| | | @PostMapping("/inputFinanceSubmitCsv") |
| | | public Result<?> inputFinanceSubmitCsv(@RequestParam("file") MultipartFile file) throws IOException { |
| | | public Result<?> inputFinanceSubmitCsv(@RequestParam("file") MultipartFile file, String param) throws IOException { |
| | | CsvReader reader = CsvUtil.getReader(); |
| | | CsvData data = reader.read(new InputStreamReader(file.getInputStream(), "GB2312")); |
| | | List<CsvRow> rows = data.getRows(); |
| | |
| | | break; |
| | | } |
| | | } |
| | | financeSubmitService.addFinanceSubmit(financeSubmit, format); |
| | | financeSubmitService.addFinanceSubmit(financeSubmit, format, param); |
| | | } |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "一键删除所有数据上报的数据") |
| | | @PostMapping("/deleteAllData") |
| | | public Result deleteAllData(String date) { |
| | | dataReportingService.deleteAllData(date); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取数据上报的登记人筛选项") |
| | | @PostMapping("/selectDataReportingForCreateUserNames") |
| | | @ValueAuth |
| | | public Result selectDataReportingForCreateUserNames(String time) { |
| | | return Result.success(dataReportingService.selectDataReportingForCreateUserNames(time)); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取微信号列表") |
| | | @GetMapping("/selectVxs") |
| | | @ValueAuth |
| | | public Result selectVxs(String time) { |
| | | return Result.success(fansSubmitService.vxs(time)); |
| | | } |
| | | |
| | | @ApiOperation(value = "批量修改微信号") |
| | | @PostMapping("/updateVxCards") |
| | | public Result updateVxCards(String str){ |
| | | List<DataReporting> list = JSON.parseArray(str, DataReporting.class); |
| | | return Result.success(dataReportingService.updateVxCards(list)); |
| | | } |
| | | } |