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 initProListen(String token) { SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(token); String companyId = userInfo.getCompanyId(); Map map = new HashMap<>(); //年度生产计划和实际完成 List 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 pipeMonthPlanActuals = bigScreenMapper.pipeMonthPlanActual(companyId); map.put("pipeMonthPlanActual",pipeMonthPlanActuals); //原料消耗 周月 List materialWeekAndMonths = bigScreenMapper.materialWeekMonth(companyId); map.put("materialWeekAndMonths",materialWeekAndMonths); //水养池 List culInfoList = bigScreenMapper.WaterCulInfo(companyId); map.put("waterCulInfo",culInfoList); //堆场 List repoInfoList = bigScreenMapper.repoInfo(companyId); map.put("repoInfo",repoInfoList); //发运 List sendInfoList = bigScreenMapper.sendInfo(companyId); map.put("sendInfo",sendInfoList); return map; } @Override public Map getDisplay() { return bigScreenMapper.displayText(); } @Override public List agv() { return historyMapper.leastData(); } @Override public List monthProductRingByPro(String token) { SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(token); List yearCountList = bigScreenMapper.queryAllProject(userInfo.getCompanyId()); yearCountList.forEach(yc ->{ List> monthList = bigScreenMapper.monthRingNumByPro(userInfo.getCompanyId(), yc.getProId()); yc.setMonthList(monthList); }); return yearCountList; } }