| | |
| | | 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.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.poi.excel.ExcelUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.annotation.ValueAuth; |
| | | import com.yuanchu.mom.dto.*; |
| | | import com.yuanchu.mom.exception.ErrorException; |
| | | import com.yuanchu.mom.mapper.FansSubmitMapper; |
| | | import com.yuanchu.mom.pojo.DataReporting; |
| | | import com.yuanchu.mom.pojo.FansSubmit; |
| | | import com.yuanchu.mom.pojo.FinanceSubmit; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RequestMapping("/dataReporting") |
| | | @RestController |
| | |
| | | private FansSubmitService fansSubmitService; |
| | | |
| | | private FinanceSubmitService financeSubmitService; |
| | | |
| | | private FansSubmitMapper fansSubmitMapper; |
| | | |
| | | @ApiOperation(value = "获取数据上报列表") |
| | | @PostMapping("/selectDataReportingList") |
| | |
| | | public Result selectFansSubmitList(@RequestBody Map<String, Object> data) { |
| | | Page page = JSON.parseObject(JSON.toJSONString(data.get("page")), Page.class); |
| | | FansSubmit fansSubmit = JSON.parseObject(JSON.toJSONString(data.get("entity")), FansSubmit.class); |
| | | if (ObjectUtil.isNotEmpty(fansSubmit.getCreateTime())){ |
| | | if (ObjectUtil.isNotEmpty(fansSubmit.getCreateTime())) { |
| | | fansSubmit.setCreateTime(fansSubmit.getCreateTime().plusDays(1)); |
| | | } |
| | | return Result.success(fansSubmitService.selectFansSubmitList(page, fansSubmit)); |
| | |
| | | public Result selectFinanceSubmitList(@RequestBody Map<String, Object> data) { |
| | | Page page = JSON.parseObject(JSON.toJSONString(data.get("page")), Page.class); |
| | | FinanceSubmit financeSubmit = JSON.parseObject(JSON.toJSONString(data.get("entity")), FinanceSubmit.class); |
| | | if (ObjectUtil.isNotEmpty(financeSubmit.getCreateTime())){ |
| | | if (ObjectUtil.isNotEmpty(financeSubmit.getCreateTime())) { |
| | | financeSubmit.setCreateTime(financeSubmit.getCreateTime().plusDays(1)); |
| | | } |
| | | return Result.success(financeSubmitService.selectFinanceSubmitList(page, financeSubmit)); |
| | |
| | | break; |
| | | } |
| | | } |
| | | if(reporting.getAccountConsumption().compareTo(BigDecimal.ZERO) > 0) list.add(reporting); |
| | | if (reporting.getAccountConsumption().compareTo(BigDecimal.ZERO) > 0) list.add(reporting); |
| | | } |
| | | 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,dataReporting.getVxCard()); |
| | | dataReportingService.addDataReporting(list, null, dataReporting.getVxCard()); |
| | | return Result.success(); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "导入进粉上报列表") |
| | | @PostMapping("/inputFansSubmitCsv") |
| | | public Result<?> inputFansSubmitCsv(@RequestParam("file") MultipartFile file) throws IOException { |
| | | CsvReader reader = CsvUtil.getReader(); |
| | | List<FansSubmit> fansSubmitLists = new ArrayList<>(); |
| | | List<FansSubmit> fansSubmitList = new ArrayList<>(); |
| | | List<String> dates = new ArrayList<>(); |
| | | AtomicReference<String> product = new AtomicReference<>(); |
| | | ExcelUtil.readBySax(file.getInputStream(), 0, (i, l, list) -> { |
| | | LocalDateTime date = null; |
| | | try { |
| | | date = LocalDateTime.parse((list.get(0) + "").replace(" ", "T")); |
| | | dates.add(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))+" 00:00:00"); |
| | | } catch (Exception e) {} |
| | | if (l == 0 || l == 1 || l == 2 |
| | | || date.compareTo(LocalDateTime.now()) < 1) { |
| | | for (int i1 = 1; i1 < list.size(); i1++) { |
| | | try { |
| | | FansSubmit fansSubmit = fansSubmitList.get(i1 - 1); |
| | | fansSubmit.setId(null); |
| | | product.set(getFansSubmit(l, list.get(i1), date, fansSubmit, product.get())); |
| | | } catch (IndexOutOfBoundsException e) { |
| | | FansSubmit fansSubmit = new FansSubmit(); |
| | | product.set(getFansSubmit(l, list.get(i1), date, fansSubmit, product.get())); |
| | | fansSubmitList.add(fansSubmit); |
| | | } |
| | | } |
| | | if(l>2){ |
| | | fansSubmitLists.addAll(JSON.parseArray(JSON.toJSONString(fansSubmitList.stream().filter(a -> !Objects.equals(a.getCustom(), "合计")).collect(Collectors.toList())), FansSubmit.class)); |
| | | } |
| | | } |
| | | }); |
| | | fansSubmitMapper.delete(Wrappers.<FansSubmit>lambdaUpdate().in(FansSubmit::getCreateTime, dates)); |
| | | fansSubmitService.saveBatch(fansSubmitLists); |
| | | /*CsvReader reader = CsvUtil.getReader(); |
| | | CsvData data = reader.read(new InputStreamReader(file.getInputStream(), "GB2312")); |
| | | List<CsvRow> rows = data.getRows(); |
| | | String format; |
| | |
| | | } |
| | | } |
| | | fansSubmitService.addFansSubmit(fansSubmit, format); |
| | | } |
| | | }*/ |
| | | return Result.success(); |
| | | } |
| | | |
| | | public String getFansSubmit(long l, Object thing, LocalDateTime date, FansSubmit fansSubmit, String product) { |
| | | String str = (thing == null ? null : thing + ""); |
| | | if(l==0){ |
| | | if (str != null) product = str; |
| | | fansSubmit.setProduct(product); |
| | | }else if(l==1){ |
| | | Pattern pattern = Pattern.compile("[\u4E00-\u9FA5]"); |
| | | Matcher matcher = pattern.matcher(str == null ? "" : str); |
| | | if (matcher.find()) { |
| | | fansSubmit.setCustom(str); |
| | | } else { |
| | | fansSubmit.setVx(str); |
| | | } |
| | | }else if(l==2){ |
| | | if (fansSubmit.getVx() == null) { |
| | | fansSubmit.setVx(str); |
| | | } |
| | | }else{ |
| | | fansSubmit.setCreateTime(date.plusDays(1)); |
| | | fansSubmit.setFansAdd((str == null || str.equals("")) ? 0 : Integer.parseInt(str)); |
| | | } |
| | | return product; |
| | | } |
| | | |
| | | @ApiOperation(value = "获取数据对比列表") |
| | |
| | | |
| | | @ApiOperation(value = "批量修改微信号") |
| | | @PostMapping("/updateVxCards") |
| | | public Result updateVxCards(String str){ |
| | | public Result updateVxCards(String str) { |
| | | List<DataReporting> list = JSON.parseArray(str, DataReporting.class); |
| | | return Result.success(dataReportingService.updateVxCards(list)); |
| | | } |