李旭东
2023-12-08 7efc6ed86025b610cab109a2e9f83362740d8ed4
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
91
package com.thhy.screen.modules.biz.bigscreen.service.impl;
 
import com.thhy.general.config.SysUserInfo;
import com.thhy.general.utils.UserInfoUtils;
import com.thhy.screen.modules.biz.agv.entity.AgvStateHistory;
import com.thhy.screen.modules.biz.agv.mapper.AgvStateHistoryMapper;
import com.thhy.screen.modules.biz.bigscreen.entity.*;
import com.thhy.screen.modules.biz.bigscreen.mapper.BigScreenMapper;
import com.thhy.screen.modules.biz.bigscreen.service.ProduceListenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class ProduceListenServiceImpl implements ProduceListenService {
 
    @Autowired
    private BigScreenMapper bigScreenMapper;
 
    @Autowired
    private AgvStateHistoryMapper historyMapper;
 
    @Override
    public Map<String, Object> initProListen(String token) {
        SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(token);
        String companyId = userInfo.getCompanyId();
        Map<String,Object> map = new HashMap<>();
        //年度生产计划和实际完成
        List<PipeYearCount> yearCountList = bigScreenMapper.queryAllProject(companyId);
        yearCountList.forEach(yc ->{
            PipePlanActual pipePlanActual = bigScreenMapper.pipePlanActual(companyId,yc.getProId());
            pipePlanActual.setPlanProduct(yc.getPlanOutput());
            BigDecimal rate = new BigDecimal(0);
            if(pipePlanActual.getRingCount()!=0&&yc.getPlanOutput()!=0){
                rate = new BigDecimal(pipePlanActual.getRingCount()).divide(new BigDecimal(yc.getPlanOutput()),2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
            }
            pipePlanActual.setCompleteRate(rate);
            yc.setPipePlanActual(pipePlanActual);
        });
 
        map.put("pipePlanActual",yearCountList);
        //月度生产计划和实际完成
        //List<PipeMonthPlanActual> pipeMonthPlanActuals = bigScreenMapper.pipeMonthPlanActual(companyId);
        //map.put("pipeMonthPlanActual",pipeMonthPlanActuals);
        //原料消耗 周月
        //List<MaterialWeekAndMonth> materialWeekAndMonths = bigScreenMapper.materialWeekMonth(companyId);
        //map.put("materialWeekAndMonths",materialWeekAndMonths);
        //钢筋消耗
        List<HashMap<String,Object>> steelUseList = bigScreenMapper.querySteelMake();
        map.put("steelUse",steelUseList);
        //缓存区
        List<HashMap<String,Object>> restInfo = bigScreenMapper.queryRestInfo();
        map.put("restInfo",restInfo);
        //水养池
        List<WaterCulInfo> culInfoList = bigScreenMapper.WaterCulInfo(companyId);
        map.put("waterCulInfo",culInfoList);
        //堆场
        List<RepoInfo> repoInfoList = bigScreenMapper.repoInfo(companyId);
        map.put("repoInfo",repoInfoList);
        //发运
        List<SendInfo> sendInfoList = bigScreenMapper.sendInfo(companyId);
        map.put("sendInfo",sendInfoList);
        return map;
    }
 
    @Override
    public Map<String, Object> getDisplay() {
        return bigScreenMapper.displayText();
    }
 
    @Override
    public List<AgvStateHistory> agv() {
        return historyMapper.leastData();
    }
 
    @Override
    public List<PipeYearCount> monthProductRingByPro(String token) {
        SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(token);
        List<PipeYearCount> yearCountList = bigScreenMapper.queryAllProject(userInfo.getCompanyId());
        yearCountList.forEach(yc ->{
            List<HashMap<String,Object>> monthList = bigScreenMapper.monthRingNumByPro(userInfo.getCompanyId(), yc.getProId());
            yc.setMonthList(monthList);
        });
        return yearCountList;
    }
}