李林
2023-12-28 0545e868ee2c01615dec8e10746bf3699f8f6a2e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.yuanchu.mom.service.impl;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
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.dto.ProductCountDto;
import com.yuanchu.mom.dto.RegistrantCountDto;
import com.yuanchu.mom.pojo.DataReporting;
import com.yuanchu.mom.service.DataReportingService;
import com.yuanchu.mom.mapper.DataReportingMapper;
import com.yuanchu.mom.utils.QueryWrappers;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
 
/**
* @author Administrator
* @description 针对表【data_reporting(数据上报)】的数据库操作Service实现
* @createDate 2023-12-23 10:39:43
*/
@Service
@AllArgsConstructor
public class DataReportingServiceImpl extends ServiceImpl<DataReportingMapper, DataReporting>
    implements DataReportingService{
 
    private DataReportingMapper dataReportingMapper;
 
    private GetLook getLook;
 
    @Override
    public Map<String, Object> selectDataReportingList(IPage<DataReportingPageDto> page, DataReportingPageDto dataReportingPageDto) {
        Map<String, Object> map = new HashMap<>();
        Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectDataReportingList");
        if(map1.get("look")==1) dataReportingPageDto.setCreateUser(map1.get("userId"));
        map.put("head", PrintChina.printChina(DataReportingPageDto.class));
        map.put("body", dataReportingMapper.selectDataReportingDtoPageList(page, QueryWrappers.queryWrappers(dataReportingPageDto)));
        return map;
    }
 
    @Override
    public int updateDataReporting(DataReporting dataReporting) {
        DataReporting dataReporting2 = new DataReporting();
        dataReporting2.setId(dataReporting.getId());
        dataReporting2.setInternalCosts(dataReporting.getInternalCosts());
        dataReporting2.setCustomerCosts(dataReporting.getCustomerCosts());
        dataReporting2.setCustomerRebate(dataReporting.getCustomerRebate());
        dataReporting2.setRemark(dataReporting.getRemark());
        dataReporting2.setRebateConsumption(dataReporting.getAccountConsumption().divide(dataReporting.getCustomerRebate(), 2, RoundingMode.HALF_UP));
        dataReporting2.setConsumption(dataReporting.getCustomerCosts().multiply(BigDecimal.valueOf(dataReporting.getFansAdd())));
        System.out.println(dataReporting2);
        return dataReportingMapper.updateById(dataReporting2);
    }
 
    @Override
    public Map<String, Object> selectProductCountDtoPageList(IPage<ProductCountDto> page, ProductCountDto productCountDto) {
        Map<String, Object> map = new HashMap<>();
        map.put("head", PrintChina.printChina(ProductCountDto.class));
        Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectDataReportingList");
        if(map1.get("look")==1) productCountDto.setCreateUser(map1.get("userId"));
        map.put("body", dataReportingMapper.selectProductCountDtoPageList(page, QueryWrappers.queryWrappers(productCountDto)));
        return map;
    }
 
    @Override
    public Map<String, Object> selectRegistrantCountDtoPageList(IPage<RegistrantCountDto> page, RegistrantCountDto registrantCountDto) {
        Map<String, Object> map = new HashMap<>();
        map.put("head", PrintChina.printChina(RegistrantCountDto.class));
        Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectDataReportingList");
        if(map1.get("look")==1) registrantCountDto.setCreateUser(map1.get("userId"));
        map.put("body", dataReportingMapper.selectRegistrantCountDtoPageList(page, QueryWrappers.queryWrappers(registrantCountDto)));
        return map;
    }
 
    @Override
    public Map<String, Object> getDataList() {
        Map<String, Object> map = new HashMap<>();
        map.put("data1", dataReportingMapper.getDataFor1());
        map.put("data2", dataReportingMapper.getDataFor2());
        map.put("data3", dataReportingMapper.getDataFor3());
        map.put("data4", dataReportingMapper.getDataFor4());
        map.put("data5", dataReportingMapper.getDataFor5());
        return map;
    }
}