| | |
| | | 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")); |
| | | 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)); |
| | | String date2 = date; |
| | | if(date == null) { |
| | | 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.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"))); |
| | | dataReportingMapper.insert(dataReporting); |
| | | } else { |
| | | dataReporting.setId(one.getId()); |
| | | dataReporting.setName(null); |
| | | dataReportingMapper.updateById(dataReporting); |
| | | } |
| | | // dataReporting.setVxCard(param); |
| | | // if (ObjectUtil.isEmpty(one)) { |
| | | dataReporting.setRegistrant(map.get("name")); |
| | | dataReporting.setDepartment(map.get("department")); |
| | | 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); |
| | | // } |
| | | } |
| | | } |
| | | |
| | | @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); |
| | | } |
| | | |
| | |
| | | String name = "数据上报" + time + ".csv"; |
| | | String path = outPath + name; |
| | | CsvWriter writer = CsvUtil.getWriter(path, CharsetUtil.CHARSET_GBK); |
| | | writer.write(new String[]{"导出时间:"+time}); |
| | | writer.write(new String[]{"导出时间:" + time}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{"时间范围:"+dataReportingPageDto.getCreateTime().format(DateTimeFormatter.ofPattern("yyyyMMdd"))}); |
| | | writer.write(new String[]{"时间范围:" + dataReportingPageDto.getCreateTime().format(DateTimeFormatter.ofPattern("yyyyMMdd"))}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{}); |
| | | List<Map<String, String>> head = JSON.parseObject(JSON.toJSONString(map.get("head")), List.class); |
| | |
| | | str[i] = head.get(i).get("value"); |
| | | } |
| | | writer.write(str); |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a->{ |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a -> { |
| | | Map<String, Object> map1 = JSON.parseObject(JSON.toJSONString(a), Map.class); |
| | | for (int i = 0; i < head.size(); i++) { |
| | | str[i] = map1.get(head.get(i).get("label"))==null?null:map1.get(head.get(i).get("label"))+""; |
| | | str[i] = map1.get(head.get(i).get("label")) == null ? null : map1.get(head.get(i).get("label")) + ""; |
| | | } |
| | | writer.write(str); |
| | | }); |
| | |
| | | String name = "项目数据统计" + time + ".csv"; |
| | | String path = outPath + name; |
| | | CsvWriter writer = CsvUtil.getWriter(path, CharsetUtil.CHARSET_GBK); |
| | | writer.write(new String[]{"导出时间:"+time}); |
| | | writer.write(new String[]{"导出时间:" + time}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{}); |
| | |
| | | str[i] = head.get(i).get("value"); |
| | | } |
| | | writer.write(str); |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a->{ |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a -> { |
| | | Map<String, Object> map1 = JSON.parseObject(JSON.toJSONString(a), Map.class); |
| | | for (int i = 0; i < head.size(); i++) { |
| | | str[i] = map1.get(head.get(i).get("label"))==null?null:map1.get(head.get(i).get("label"))+""; |
| | | str[i] = map1.get(head.get(i).get("label")) == null ? null : map1.get(head.get(i).get("label")) + ""; |
| | | } |
| | | writer.write(str); |
| | | }); |
| | |
| | | String name = "员工数据统计" + time + ".csv"; |
| | | String path = outPath + name; |
| | | CsvWriter writer = CsvUtil.getWriter(path, CharsetUtil.CHARSET_GBK); |
| | | writer.write(new String[]{"导出时间:"+time}); |
| | | writer.write(new String[]{"导出时间:" + time}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{}); |
| | |
| | | str[i] = head.get(i).get("value"); |
| | | } |
| | | writer.write(str); |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a->{ |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a -> { |
| | | Map<String, Object> map1 = JSON.parseObject(JSON.toJSONString(a), Map.class); |
| | | for (int i = 0; i < head.size(); i++) { |
| | | str[i] = map1.get(head.get(i).get("label"))==null?null:map1.get(head.get(i).get("label"))+""; |
| | | str[i] = map1.get(head.get(i).get("label")) == null ? null : map1.get(head.get(i).get("label")) + ""; |
| | | } |
| | | writer.write(str); |
| | | }); |
| | |
| | | String name = "粉丝上报" + time + ".csv"; |
| | | String path = outPath + name; |
| | | CsvWriter writer = CsvUtil.getWriter(path, CharsetUtil.CHARSET_GBK); |
| | | writer.write(new String[]{"导出时间:"+time}); |
| | | writer.write(new String[]{"导出时间:" + time}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{"时间范围:"+fansSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyyMMdd"))}); |
| | | writer.write(new String[]{"时间范围:" + fansSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyyMMdd"))}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{}); |
| | | List<Map<String, String>> head = JSON.parseObject(JSON.toJSONString(map.get("head")), List.class); |
| | |
| | | str[i] = head.get(i).get("value"); |
| | | } |
| | | writer.write(str); |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a->{ |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a -> { |
| | | Map<String, Object> map1 = JSON.parseObject(JSON.toJSONString(a), Map.class); |
| | | for (int i = 0; i < head.size(); i++) { |
| | | str[i] = map1.get(head.get(i).get("label"))==null?null:map1.get(head.get(i).get("label"))+""; |
| | | str[i] = map1.get(head.get(i).get("label")) == null ? null : map1.get(head.get(i).get("label")) + ""; |
| | | } |
| | | writer.write(str); |
| | | }); |
| | |
| | | String name = "财务上报" + time + ".csv"; |
| | | String path = outPath + name; |
| | | CsvWriter writer = CsvUtil.getWriter(path, CharsetUtil.CHARSET_GBK); |
| | | writer.write(new String[]{"导出时间:"+time}); |
| | | writer.write(new String[]{"导出时间:" + time}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{"时间范围:"+financeSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyyMMdd"))}); |
| | | writer.write(new String[]{"时间范围:" + financeSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyyMMdd"))}); |
| | | writer.write(new String[]{}); |
| | | writer.write(new String[]{}); |
| | | List<Map<String, String>> head = JSON.parseObject(JSON.toJSONString(map.get("head")), List.class); |
| | |
| | | str[i] = head.get(i).get("value"); |
| | | } |
| | | writer.write(str); |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a->{ |
| | | JSON.parseObject(JSON.toJSONString(map.get("body")), IPage.class).getRecords().forEach(a -> { |
| | | Map<String, Object> map1 = JSON.parseObject(JSON.toJSONString(a), Map.class); |
| | | for (int i = 0; i < head.size(); i++) { |
| | | str[i] = map1.get(head.get(i).get("label"))==null?null:map1.get(head.get(i).get("label"))+""; |
| | | str[i] = map1.get(head.get(i).get("label")) == null ? null : map1.get(head.get(i).get("label")) + ""; |
| | | } |
| | | writer.write(str); |
| | | }); |
| | |
| | | if (StringUtils.isEmpty(dataComparisonDto.getName()) |
| | | || StringUtils.isEmpty(dataComparisonDto.getComparisonName())) { |
| | | map.put("body", new Page<DataComparisonDto>()); |
| | | }else { |
| | | long startTime = System.currentTimeMillis(); |
| | | } else { |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | |