| | |
| | | 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 "展现量": |
| | | try { |
| | | reporting.setShowNum(Integer.parseInt(str)); |
| | | } catch (Exception e) { |
| | | } |
| | | break; |
| | | case "点击量": |
| | | try { |
| | | reporting.setClick(Integer.parseInt(str)); |
| | | } catch (Exception e) { |
| | | } |
| | | break; |
| | | case "消费": |
| | | 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)); |
| | | } |
| | | } |
| | |
| | | @ValueTableShow(3) |
| | | private BigDecimal consumption; |
| | | |
| | | @ApiModelProperty("项目") |
| | | @ValueTableShow(2) |
| | | private String product; |
| | | |
| | | @ApiModelProperty("登记时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | |
| | | @ValueTableShow(7) |
| | | private BigDecimal comparisonConsumption; |
| | | |
| | | @ApiModelProperty("部门") |
| | | @ValueTableShow(8) |
| | | private String uDepartment; |
| | | |
| | | @ApiModelProperty("公司") |
| | | @ValueTableShow(9) |
| | | private String uCompany; |
| | | |
| | | @ApiModelProperty("对比的登记时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime comparisonCreateTime; |
| | |
| | | public class ProductCountDto extends OrderBy implements Serializable { |
| | | |
| | | @ValueTableShow(1) |
| | | @ApiModelProperty("日期") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty("日期") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | |
| | | */ |
| | | @ApiModelProperty("登记日期") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ValueTableShow(1) |
| | | private LocalDateTime createTime; |
| | | /** |
| | | * |
| | | */ |
| | | @ApiModelProperty("系统日期") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ValueTableShow(1) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty("创建用户") |
| | |
| | | Map<String, String> selectUser(Integer userId); |
| | | |
| | | IPage<DataComparisonDto> selectDataComparisonDtoPageList(Page page, DataComparisonDto dataComparisonDto); |
| | | |
| | | List<String> selectDataReportingForCreateUserNames(String time); |
| | | } |
| | | |
| | | |
| | |
| | | private String name2; |
| | | |
| | | /** |
| | | * 项目 |
| | | */ |
| | | @Size(max= 255,message="编码长度不能超过255") |
| | | @ApiModelProperty("项目") |
| | | @Length(max= 255,message="编码长度不能超过255") |
| | | @ValueTableShow(4) |
| | | private String product; |
| | | |
| | | /** |
| | | * 渠道 |
| | | */ |
| | | @Size(max= 255,message="编码长度不能超过255") |
| | |
| | | @ValueTableShow(4) |
| | | private String agent; |
| | | |
| | | /** |
| | | * 项目 |
| | | */ |
| | | @Size(max= 255,message="编码长度不能超过255") |
| | | @ApiModelProperty("项目") |
| | | @Length(max= 255,message="编码长度不能超过255") |
| | | @ValueTableShow(5) |
| | | private String product; |
| | | /** |
| | | * 展现量 |
| | | */ |
| | |
| | | @ApiModelProperty("客户返点") |
| | | @ValueTableShow(18) |
| | | private BigDecimal customerRebate; |
| | | |
| | | @ApiModelProperty("微信号") |
| | | @ValueTableShow(19) |
| | | private String vxCard; |
| | | |
| | | /** |
| | | * 备用字段 |
| | | */ |
| | |
| | | /** |
| | | * |
| | | */ |
| | | @ApiModelProperty("创建时间") |
| | | @ApiModelProperty("系统时间") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ValueTableShow(20) |
| | |
| | | /** |
| | | * |
| | | */ |
| | | @ApiModelProperty("更新时间") |
| | | @ApiModelProperty("登记时间") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ValueTableShow(21) |
| | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | private Integer dataId; |
| | | } |
| | |
| | | |
| | | private Integer dataId; |
| | | |
| | | @TableField(select = false, exist = false) |
| | | private String param; |
| | | |
| | | } |
| | |
| | | |
| | | Map<String, Object> getDataList(); |
| | | |
| | | void addDataReporting(List<DataReporting> list, String date); |
| | | void addDataReporting(List<DataReporting> list, String date, String param); |
| | | |
| | | Integer delDataReporting(Integer id); |
| | | |
| | |
| | | |
| | | String downFinanceSubmitFile(IPage<FinanceSubmit> page, FinanceSubmit financeSubmit); |
| | | |
| | | void deleteAllData(String date); |
| | | |
| | | List<String> selectDataReportingForCreateUserNames(String time); |
| | | |
| | | int updateVxCards(List<DataReporting> list); |
| | | |
| | | } |
| | |
| | | import com.yuanchu.mom.pojo.FansSubmit; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | int addFansSubmit(FansSubmit fansSubmit, String date); |
| | | |
| | | List<FansSubmit> vxs(String date); |
| | | |
| | | String getYesterday(); |
| | | |
| | | } |
| | |
| | | |
| | | int updateFinanceSubmit(FinanceSubmit financeSubmit); |
| | | |
| | | int addFinanceSubmit(FinanceSubmit financeSubmit, String date); |
| | | int addFinanceSubmit(FinanceSubmit financeSubmit, String date, String param); |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import com.yuanchu.mom.dto.ProductCountDto; |
| | | import com.yuanchu.mom.dto.RegistrantCountDto; |
| | | import com.yuanchu.mom.mapper.FansSubmitMapper; |
| | | import com.yuanchu.mom.mapper.FinanceSubmitMapper; |
| | | import com.yuanchu.mom.pojo.DataReporting; |
| | | import com.yuanchu.mom.pojo.FansSubmit; |
| | | import com.yuanchu.mom.pojo.FinanceSubmit; |
| | |
| | | @Resource |
| | | private FinanceSubmitService financeSubmitService; |
| | | |
| | | @Resource |
| | | private FinanceSubmitMapper financeSubmitMapper; |
| | | |
| | | @Override |
| | | public Map<String, Object> selectDataReportingList(IPage<DataReportingPageDto> page, DataReportingPageDto dataReportingPageDto) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | dataReporting2.setCustomerCosts(dataReporting.getCustomerCosts()); |
| | | dataReporting2.setCustomerRebate(dataReporting.getCustomerRebate()); |
| | | dataReporting2.setRemark(dataReporting.getRemark()); |
| | | dataReporting2.setVxCard(dataReporting.getVxCard()); |
| | | try { |
| | | dataReporting2.setRebateConsumption(dataReporting.getAccountConsumption().divide(dataReporting.getCustomerRebate(), 2, RoundingMode.HALF_UP)); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | try { |
| | | dataReporting2.setDiscountedConsumption(dataReporting.getConsumption().divide(dataReporting.getAgentRebate(), 2, RoundingMode.HALF_UP)); |
| | | }catch (Exception e){} |
| | | } catch (Exception e) { |
| | | } |
| | | try { |
| | | dataReporting2.setActualCost(dataReporting.getAccountConsumption().divide(new BigDecimal(dataReporting.getFansAdd()), 2, RoundingMode.HALF_UP)); |
| | | }catch (Exception e){} |
| | | } catch (Exception e) { |
| | | } |
| | | try { |
| | | dataReporting2.setProfit(dataReporting.getRebateConsumption().subtract(dataReporting.getConsumption())); |
| | | }catch (Exception e){} |
| | | } catch (Exception e) { |
| | | } |
| | | String format = dataReportingMapper.selectById(dataReporting.getId()).getCreateTime().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getProduct, dataReporting.getProduct()).eq(FansSubmit::getVx, dataReporting.getVxCard()).select(FansSubmit::getFansAdd).like(FansSubmit::getCreateTime, format)); |
| | | Integer sum = 0; |
| | | for (FansSubmit fansSubmit : fansSubmits) { |
| | | sum += fansSubmit.getFansAdd(); |
| | | } |
| | | dataReporting2.setFansAdd(sum); |
| | | return dataReportingMapper.updateById(dataReporting2); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addDataReporting(List<DataReporting> list, String date) { |
| | | public void addDataReporting(List<DataReporting> list, String date, String param) { |
| | | int userId = Integer.parseInt(JSONUtil.parseObj(new Jwt().readJWT(ServletUtils.getRequest().getHeader("token")).get("data")).get("id") + ""); |
| | | Map<String, String> map = dataReportingMapper.selectUser(userId); |
| | | for (DataReporting dataReporting : list) { |
| | | if (dataReporting.getName() == null || dataReporting.getName().equals("")) dataReporting.setName(map.get("account")); |
| | | String date2 = date; |
| | | if (date == null) { |
| | | date = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | }; |
| | | DataReporting one = dataReportingMapper.selectOne(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getProduct, dataReporting.getProduct()).eq(DataReporting::getName, dataReporting.getName()).eq(DataReporting::getCreateUser, userId).like(DataReporting::getCreateTime, date)); |
| | | date2 = fansSubmitService.getYesterday(); |
| | | date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } else date = LocalDateTime.parse(date+"T00:00:00").plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | // List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getProduct, dataReporting.getProduct()).eq(FansSubmit::getVx, param).select(FansSubmit::getFansAdd).like(FansSubmit::getCreateTime, date)); |
| | | FinanceSubmit financeSubmit = financeSubmitMapper.selectOne(Wrappers.<FinanceSubmit>lambdaQuery().eq(FinanceSubmit::getCompany, dataReporting.getAgent()).eq(FinanceSubmit::getName, dataReporting.getName()).select(FinanceSubmit::getEmployeeRebate).like(FinanceSubmit::getCreateTime, date).orderByDesc(FinanceSubmit::getId).last("limit 1")); |
| | | // Integer sum = 0; |
| | | // for (FansSubmit fansSubmit : fansSubmits) { |
| | | // sum += fansSubmit.getFansAdd(); |
| | | // } |
| | | // dataReporting.setFansAdd(sum); |
| | | if(ObjectUtil.isNotEmpty(financeSubmit)){ |
| | | dataReporting.setAgentRebate(financeSubmit.getEmployeeRebate()); |
| | | } |
| | | if (dataReporting.getName() == null || dataReporting.getName().equals("")) |
| | | dataReporting.setName(map.get("account")); |
| | | // DataReporting one = dataReportingMapper.selectOne(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getProduct, dataReporting.getProduct()).eq(DataReporting::getName, dataReporting.getName()).eq(DataReporting::getCreateUser, userId).like(DataReporting::getCreateTime, date)); |
| | | try { |
| | | dataReporting.setRebateConsumption(dataReporting.getAccountConsumption().divide(dataReporting.getCustomerRebate(), 2, RoundingMode.HALF_UP)); |
| | | } catch (Exception e) { |
| | |
| | | dataReporting.setRemark(dataReporting.getConsumption().subtract(dataReporting.getRebateConsumption())); |
| | | } catch (Exception e) { |
| | | } |
| | | if (ObjectUtil.isEmpty(one)) { |
| | | // dataReporting.setVxCard(param); |
| | | // if (ObjectUtil.isEmpty(one)) { |
| | | dataReporting.setRegistrant(map.get("name")); |
| | | dataReporting.setDepartment(map.get("department")); |
| | | dataReporting.setCreateTime(LocalDateTime.parse(date + " " + new SimpleDateFormat("HH:mm:ss").format(new Date()), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | dataReporting.setCreateTime(LocalDateTime.parse(date2 + " " + new SimpleDateFormat("HH:mm:ss").format(new Date()), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | dataReportingMapper.insert(dataReporting); |
| | | } else { |
| | | dataReporting.setId(one.getId()); |
| | | dataReporting.setName(null); |
| | | dataReportingMapper.updateById(dataReporting); |
| | | } |
| | | // } else { |
| | | // dataReporting.setId(one.getId()); |
| | | // dataReporting.setName(null); |
| | | // dataReportingMapper.updateById(dataReporting); |
| | | // } |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Integer delDataReporting(Integer id) { |
| | | List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getDataId, id).select(FansSubmit::getId)); |
| | | fansSubmitMapper.deleteBatchIds(fansSubmits); |
| | | /*List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getDataId, id).select(FansSubmit::getId)); |
| | | if(fansSubmits.size()>0)fansSubmitMapper.deleteBatchIds(fansSubmits); |
| | | List<FinanceSubmit> financeSubmits = financeSubmitMapper.selectList(Wrappers.<FinanceSubmit>lambdaQuery().eq(FinanceSubmit::getDataId, id).select(FinanceSubmit::getId)); |
| | | if(financeSubmits.size()>0)financeSubmitMapper.deleteBatchIds(financeSubmits);*/ |
| | | return dataReportingMapper.deleteById(id); |
| | | } |
| | | |
| | |
| | | || StringUtils.isEmpty(dataComparisonDto.getComparisonName())) { |
| | | map.put("body", new Page<DataComparisonDto>()); |
| | | }else { |
| | | long startTime = System.currentTimeMillis(); |
| | | IPage<DataComparisonDto> dataReportingPageDtoIPage = dataReportingMapper.selectDataComparisonDtoPageList(page, dataComparisonDto); |
| | | long endTime = System.currentTimeMillis(); |
| | | System.out.println("执行时间:" + (endTime - startTime) + " 毫秒"); |
| | | map.put("body", dataReportingPageDtoIPage); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAllData(String date) { |
| | | List<DataReporting> list = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getCreateUser, getLook.selectPowerByMethodAndUserId("selectDataReportingList").get("userId")).like(DataReporting::getCreateTime, date)); |
| | | for (DataReporting reporting : list) { |
| | | delDataReporting(reporting.getId()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<String> selectDataReportingForCreateUserNames(String time) { |
| | | return dataReportingMapper.selectDataReportingForCreateUserNames(time.split(" ")[0]); |
| | | } |
| | | |
| | | @Override |
| | | public int updateVxCards(List<DataReporting> list) { |
| | | for (DataReporting reporting : list) { |
| | | updateDataReporting(reporting); |
| | | } |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.dto.DataReportingPageDto; |
| | | import com.yuanchu.mom.exception.ErrorException; |
| | | import com.yuanchu.mom.mapper.DataReportingMapper; |
| | | import com.yuanchu.mom.pojo.DataReporting; |
| | | import com.yuanchu.mom.pojo.FansSubmit; |
| | | import com.yuanchu.mom.service.FansSubmitService; |
| | | import com.yuanchu.mom.mapper.FansSubmitMapper; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import com.yuanchu.mom.utils.ServletUtils; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int delFansSubmit(Integer id) { |
| | | FansSubmit fansSubmit = fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, id).select(FansSubmit::getFansAdd, FansSubmit::getDataId)); |
| | | DataReporting dataReporting = dataReportingMapper.selectById(fansSubmit.getDataId()); |
| | | dataReporting.setFansAdd(dataReporting.getFansAdd() - fansSubmit.getFansAdd()); |
| | | FansSubmit fansSubmit = fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, id).select(FansSubmit::getFansAdd,FansSubmit::getProduct,FansSubmit::getVx,FansSubmit::getCreateTime)); |
| | | fansSubmitMapper.deleteById(id); |
| | | List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getProduct, fansSubmit.getProduct()).eq(FansSubmit::getVx, fansSubmit.getVx()).select(FansSubmit::getFansAdd).like(FansSubmit::getCreateTime, fansSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); |
| | | Integer sum = 0; |
| | | for (FansSubmit fansSubmit2 : fansSubmits) { |
| | | sum += fansSubmit2.getFansAdd(); |
| | | } |
| | | List<DataReporting> dataReportings = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getProduct, fansSubmit.getProduct()).eq(DataReporting::getVxCard, fansSubmit.getVx()).like(DataReporting::getCreateTime, fansSubmit.getCreateTime().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); |
| | | for (DataReporting dataReporting : dataReportings) { |
| | | dataReporting.setFansAdd(sum); |
| | | dataReportingMapper.updateById(dataReporting); |
| | | return fansSubmitMapper.deleteById(id); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int updateFansSubmit(FansSubmit fansSubmit) { |
| | | DataReporting dataReporting = dataReportingMapper.selectById(fansSubmit.getDataId()); |
| | | dataReporting.setFansAdd(dataReporting.getFansAdd() + fansSubmit.getFansAdd() - fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, fansSubmit.getId()).select(FansSubmit::getFansAdd)).getFansAdd()); |
| | | public int updateFansSubmit(FansSubmit fansSubmit3) { |
| | | fansSubmitMapper.updateById(fansSubmit3); |
| | | FansSubmit fansSubmit = fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, fansSubmit3.getId()).select(FansSubmit::getFansAdd,FansSubmit::getProduct,FansSubmit::getVx,FansSubmit::getCreateTime)); |
| | | List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getProduct, fansSubmit.getProduct()).eq(FansSubmit::getVx, fansSubmit.getVx()).select(FansSubmit::getFansAdd).like(FansSubmit::getCreateTime, fansSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); |
| | | Integer sum = 0; |
| | | for (FansSubmit fansSubmit2 : fansSubmits) { |
| | | sum += fansSubmit2.getFansAdd(); |
| | | } |
| | | List<DataReporting> dataReportings = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getProduct, fansSubmit.getProduct()).eq(DataReporting::getVxCard, fansSubmit.getVx()).like(DataReporting::getCreateTime, fansSubmit.getCreateTime().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); |
| | | for (DataReporting dataReporting : dataReportings) { |
| | | dataReporting.setFansAdd(sum); |
| | | dataReportingMapper.updateById(dataReporting); |
| | | return fansSubmitMapper.updateById(fansSubmit); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int addFansSubmit(FansSubmit fansSubmit, String date) { |
| | | if(date == null) date = getYesterday(); |
| | | DataReporting dataReporting = dataReportingMapper.selectOne(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getName, fansSubmit.getCustom()).eq(DataReporting::getProduct, fansSubmit.getProduct()).eq(DataReporting::getCreateUser, getLook.selectPowerByMethodAndUserId("selectRegistrantCountDtoPageList").get("userId")).like(DataReporting::getCreateTime, date)); |
| | | if(ObjectUtil.isEmpty(dataReporting)){ |
| | | throw new ErrorException(date+" 客户:"+fansSubmit.getCustom()+" 并未上报过 "+fansSubmit.getProduct()+" 项目"); |
| | | String date2 = null; |
| | | if(date == null) { |
| | | date = getToday(); |
| | | date2 = getYesterday(); |
| | | }else{ |
| | | date = LocalDateTime.parse(date + "T00:00:00").plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | date2 = LocalDateTime.parse(date + "T00:00:00").minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | fansSubmit.setCreateTime(LocalDateTime.parse(date + "T00:00:00")); |
| | | } |
| | | dataReporting.setFansAdd((dataReporting.getFansAdd()==null?0:dataReporting.getFansAdd()) + fansSubmit.getFansAdd()); |
| | | fansSubmitMapper.insert(fansSubmit); |
| | | List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getProduct, fansSubmit.getProduct()).eq(FansSubmit::getVx, fansSubmit.getVx()).select(FansSubmit::getFansAdd).like(FansSubmit::getCreateTime, date)); |
| | | Integer sum = 0; |
| | | for (FansSubmit fansSubmit2 : fansSubmits) { |
| | | sum += fansSubmit2.getFansAdd(); |
| | | } |
| | | List<DataReporting> dataReportings = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getProduct, fansSubmit.getProduct()).eq(DataReporting::getVxCard, fansSubmit.getVx()).like(DataReporting::getCreateTime, date2).orderByDesc(DataReporting::getAccountConsumption)); |
| | | for (DataReporting dataReporting : dataReportings) { |
| | | dataReporting.setFansAdd(sum); |
| | | dataReportingMapper.updateById(dataReporting); |
| | | fansSubmit.setDataId(dataReporting.getId()); |
| | | return fansSubmitMapper.insert(fansSubmit); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public String getYesterday(){ |
| | | return LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } |
| | | |
| | | public String getToday(){ |
| | | return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } |
| | | |
| | | @Override |
| | | public List<FansSubmit> vxs(String date) { |
| | | String format = LocalDateTime.parse(date.replace(" ", "T")).plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | QueryWrapper<FansSubmit> queryWrapper = new QueryWrapper<FansSubmit>(); |
| | | queryWrapper.select("DISTINCT vx").like("create_time", format); |
| | | return fansSubmitMapper.selectList(queryWrapper); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | import com.yuanchu.mom.pojo.FansSubmit; |
| | | import com.yuanchu.mom.pojo.FinanceSubmit; |
| | | import com.yuanchu.mom.service.DataReportingService; |
| | | import com.yuanchu.mom.service.FansSubmitService; |
| | | import com.yuanchu.mom.service.FinanceSubmitService; |
| | | import com.yuanchu.mom.mapper.FinanceSubmitMapper; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public int delFinanceSubmit(Integer id) { |
| | | return financeSubmitMapper.deleteById(id); |
| | | FinanceSubmit financeSubmit = financeSubmitMapper.selectOne(Wrappers.<FinanceSubmit>lambdaQuery().eq(FinanceSubmit::getId, id).select(FinanceSubmit::getEmployeeRebate,FinanceSubmit::getName,FinanceSubmit::getCompany,FinanceSubmit::getCreateTime,FinanceSubmit::getDataId)); |
| | | financeSubmitMapper.deleteById(id); |
| | | FinanceSubmit financeSubmit2 = financeSubmitMapper.selectOne(Wrappers.<FinanceSubmit>lambdaQuery().eq(FinanceSubmit::getCompany, financeSubmit.getCompany()).eq(FinanceSubmit::getName, financeSubmit.getName()).eq(FinanceSubmit::getDataId, financeSubmit.getDataId()).select(FinanceSubmit::getEmployeeRebate).like(FinanceSubmit::getCreateTime, financeSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).orderByDesc(FinanceSubmit::getId).last("limit 1")); |
| | | if(ObjectUtil.isEmpty(financeSubmit2)){ |
| | | return 1; |
| | | }; |
| | | List<DataReporting> dataReportings = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getAgent, financeSubmit.getCompany()).eq(DataReporting::getName, financeSubmit.getName()).eq(DataReporting::getCreateUser, financeSubmit.getDataId()).like(DataReporting::getCreateTime, financeSubmit.getCreateTime().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); |
| | | for (DataReporting dataReporting : dataReportings) { |
| | | dataReporting.setAgentRebate(financeSubmit2.getEmployeeRebate()); |
| | | dataReportingMapper.updateById(computingMethod(dataReporting)); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public int updateFinanceSubmit(FinanceSubmit financeSubmit) { |
| | | DataReporting reporting = dataReportingMapper.selectById(financeSubmit.getDataId()); |
| | | reporting.setId(financeSubmit.getDataId()); |
| | | reporting.setAgentRebate(financeSubmit.getEmployeeRebate()); |
| | | public int updateFinanceSubmit(FinanceSubmit financeSubmit3) { |
| | | financeSubmitMapper.updateById(financeSubmit3); |
| | | FinanceSubmit financeSubmit = financeSubmitMapper.selectOne(Wrappers.<FinanceSubmit>lambdaQuery().eq(FinanceSubmit::getId, financeSubmit3.getId()).select(FinanceSubmit::getEmployeeRebate,FinanceSubmit::getName,FinanceSubmit::getCompany,FinanceSubmit::getCreateTime,FinanceSubmit::getDataId)); |
| | | FinanceSubmit financeSubmit2 = financeSubmitMapper.selectOne(Wrappers.<FinanceSubmit>lambdaQuery().eq(FinanceSubmit::getCompany, financeSubmit.getCompany()).eq(FinanceSubmit::getName, financeSubmit.getName()).eq(FinanceSubmit::getDataId, financeSubmit.getDataId()).select(FinanceSubmit::getEmployeeRebate).like(FinanceSubmit::getCreateTime, financeSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).orderByDesc(FinanceSubmit::getId).last("limit 1")); |
| | | if(ObjectUtil.isEmpty(financeSubmit2))return 1; |
| | | List<DataReporting> dataReportings = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getAgent, financeSubmit.getCompany()).eq(DataReporting::getName, financeSubmit.getName()).eq(DataReporting::getCreateUser, financeSubmit.getDataId()).like(DataReporting::getCreateTime, financeSubmit.getCreateTime().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); |
| | | for (DataReporting dataReporting : dataReportings) { |
| | | dataReporting.setAgentRebate(financeSubmit2.getEmployeeRebate()); |
| | | dataReportingMapper.updateById(computingMethod(dataReporting)); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | public DataReporting computingMethod(DataReporting dataReporting){ |
| | | try { |
| | | reporting.setDiscountedConsumption(reporting.getConsumption().divide(reporting.getAgentRebate(), 2, RoundingMode.HALF_UP)); |
| | | }catch (Exception e){} |
| | | dataReportingMapper.updateById(reporting); |
| | | return financeSubmitMapper.updateById(financeSubmit); |
| | | dataReporting.setRebateConsumption(dataReporting.getAccountConsumption().divide(dataReporting.getCustomerRebate(), 2, RoundingMode.HALF_UP)); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | @Override |
| | | public int addFinanceSubmit(FinanceSubmit financeSubmit, String date) { |
| | | if(date == null) date = getYesterday(); |
| | | DataReporting dataReporting = dataReportingMapper.selectOne(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getAgent, financeSubmit.getCompany()).eq(DataReporting::getName, financeSubmit.getName()).eq(DataReporting::getCreateUser, getLook.selectPowerByMethodAndUserId("selectRegistrantCountDtoPageList").get("userId")).like(DataReporting::getCreateTime, date)); |
| | | if(ObjectUtil.isEmpty(dataReporting)){ |
| | | throw new ErrorException(date+" 账户:"+financeSubmit.getName()+" 代理商:"+financeSubmit.getCompany()+" 并未上报过"); |
| | | try { |
| | | dataReporting.setConsumption(dataReporting.getCustomerCosts().multiply(BigDecimal.valueOf(dataReporting.getFansAdd()))); |
| | | } catch (Exception e) { |
| | | } |
| | | dataReporting.setAgentRebate(financeSubmit.getEmployeeRebate()); |
| | | try { |
| | | dataReporting.setDiscountedConsumption(dataReporting.getConsumption().divide(dataReporting.getAgentRebate(), 2, RoundingMode.HALF_UP)); |
| | | }catch (Exception e){} |
| | | dataReportingMapper.updateById(dataReporting); |
| | | financeSubmit.setDataId(dataReporting.getId()); |
| | | return financeSubmitMapper.insert(financeSubmit); |
| | | } catch (Exception e) { |
| | | } |
| | | try { |
| | | dataReporting.setActualCost(dataReporting.getAccountConsumption().divide(new BigDecimal(dataReporting.getFansAdd()), 2, RoundingMode.HALF_UP)); |
| | | } catch (Exception e) { |
| | | } |
| | | try { |
| | | dataReporting.setProfit(dataReporting.getRebateConsumption().subtract(dataReporting.getConsumption())); |
| | | } catch (Exception e) { |
| | | } |
| | | return dataReporting; |
| | | } |
| | | |
| | | @Override |
| | | public int addFinanceSubmit(FinanceSubmit financeSubmit, String date, String param) { |
| | | if(date == null) date = getYesterday(); |
| | | // financeSubmit.setDataId(Integer.parseInt(param)); |
| | | String date2 = null; |
| | | if(date == null) { |
| | | date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | date2 = getYesterday(); |
| | | }else{ |
| | | date = LocalDateTime.parse(date + "T00:00:00").plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | date2 = LocalDateTime.parse(date + "T00:00:00").minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | financeSubmit.setCreateTime(LocalDateTime.parse(date + "T00:00:00")); |
| | | } |
| | | financeSubmitMapper.insert(financeSubmit); |
| | | FinanceSubmit financeSubmit2 = financeSubmitMapper.selectOne(Wrappers.<FinanceSubmit>lambdaQuery().eq(FinanceSubmit::getCompany, financeSubmit.getCompany()).eq(FinanceSubmit::getName, financeSubmit.getName()).select(FinanceSubmit::getEmployeeRebate).like(FinanceSubmit::getCreateTime, date).orderByDesc(FinanceSubmit::getId).last("limit 1")); |
| | | if(ObjectUtil.isEmpty(financeSubmit2))return 1; |
| | | List<DataReporting> dataReportings = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getAgent, financeSubmit.getCompany()).eq(DataReporting::getName, financeSubmit.getName()).like(DataReporting::getCreateTime, date2)); |
| | | for (DataReporting dataReporting : dataReportings) { |
| | | dataReporting.setAgentRebate(financeSubmit2.getEmployeeRebate()); |
| | | dataReportingMapper.updateById(computingMethod(dataReporting)); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | public String getYesterday(){ |
| | |
| | | </select> |
| | | |
| | | <select id="selectDataComparisonDtoPageList" resultType="com.yuanchu.mom.dto.DataComparisonDto"> |
| | | select a.account account, |
| | | select a.uName account, |
| | | a.name name, |
| | | a.account_consumption consumption, |
| | | b.account comparisonAccount, |
| | | a.product, |
| | | COALESCE(b.uName, #{dataComparisonDto.comparisonName}) comparisonAccount, |
| | | b.name comparisonName, |
| | | b.account_consumption comparisonConsumption |
| | | b.account_consumption comparisonConsumption, |
| | | b.uDepartment, |
| | | b.uCompany |
| | | from (select dr1.*, user.id uId, user.name uName, user.account |
| | | from data_reporting dr1 |
| | | join user on dr1.create_user = user.id |
| | | where date_format(dr1.create_time, '%Y-%m-%d') = |
| | | date_format(#{dataComparisonDto.createTime}, '%Y-%m-%d') |
| | | and user.name = #{dataComparisonDto.name}) a |
| | | left join (select dr2.*, user.id uId, user.name uName, user.account |
| | | left join (select dr2.*, user.id uId, user.name uName, user.account,user.department uDepartment,user.company uCompany |
| | | from data_reporting dr2 |
| | | join user on dr2.create_user = user.id |
| | | where date_format(dr2.create_time, '%Y-%m-%d') = |
| | |
| | | where (a.account_consumption != b.account_consumption |
| | | or b.account_consumption is null) |
| | | </select> |
| | | <select id="selectDataReportingForCreateUserNames" resultType="java.lang.String"> |
| | | select distinct u1.name from data_reporting dr |
| | | left join user u1 on dr.create_user = u1.id |
| | | where dr.create_time like concat('%', #{time}, '%') |
| | | </select> |
| | | </mapper> |
| | |
| | | type = "删除"; |
| | | } else if(remark.contains("添加")||remark.contains("新增")){ |
| | | type = "添加"; |
| | | } else if(remark.contains("导入")){ |
| | | type = "导入"; |
| | | } else if(remark.contains("导出")){ |
| | | type = "导出"; |
| | | } |
| | | try { |
| | | authMapper.insertPower(value.getMethod().getName(), remark, type); |
| | |
| | | int deletePower(); |
| | | |
| | | @Select("select COALESCE(count(*), 0) from power p left join user u on u.role_id = p.role_id where u.id = #{userId} and p.menu_method = #{method}") |
| | | int isPower(Integer userId, String method); |
| | | Integer isPower(Integer userId, String method); |
| | | |
| | | @Select("select look from power p left join user u on u.role_id = p.role_id where u.id = #{userId} and p.menu_method = #{method}") |
| | | int countPower(Integer userId, String method); |
| | | Integer countPower(Integer userId, String method); |
| | | |
| | | } |
| | |
| | | return Result.success(userService.addUser(user)); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取用户信息枚举") |
| | | @GetMapping("/getUserMenu") |
| | | @ValueAuth |
| | | public Result<?> getUserMenu() { |
| | | return Result.success(userService.getUserMenu()); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @ValueTableShow(2) |
| | | @Size(max= 255,message="编码长度不能超过255") |
| | | @ApiModelProperty("公司") |
| | | @ApiModelProperty("项目") |
| | | @Length(max= 255,message="编码长度不能超过255") |
| | | private String company; |
| | | |
| | |
| | | |
| | | int addUser(User user); |
| | | |
| | | List<User> getUserMenu(); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | |
| | | public int addUser(User user) { |
| | | return userMapper.insert(user); |
| | | } |
| | | |
| | | @Override |
| | | public List<User> getUserMenu() { |
| | | return userMapper.selectList(Wrappers.<User>lambdaQuery().eq(User::getState, 1).select(User::getName, User::getId)); |
| | | } |
| | | } |