package com.xlht.xlhtproject.service.impl; import com.xlht.xlhtproject.domain.*; import com.xlht.xlhtproject.enums.BusinessEnum; import com.xlht.xlhtproject.mapper.TShuju1Mapper; import com.xlht.xlhtproject.mapper.TTbXieMapper; import com.xlht.xlhtproject.mapper.ZAssayMapper; import com.xlht.xlhtproject.mapper.ZAssayResultMapper; import com.xlht.xlhtproject.service.IFrontService; import com.xlht.xlhtproject.utils.DateUtils; import com.xlht.xlhtproject.utils.StringUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; import static com.xlht.xlhtproject.enums.MyConstants.*; @Service @Slf4j public class FrontServiceImpl implements IFrontService { @Autowired private TShuju1Mapper shuju1Mapper; @Autowired private TTbXieMapper xieMapper; @Autowired private ZAssayMapper zAssayMapper; @Autowired private ZAssayResultMapper zAssayResultMapper; @Override public SmartAdd smartAddDataInfo() { return this.shuju1Mapper.getNewestData(); } @Override public Map> smartAddCharList(int type, String timeBegin, String timeEnd) { // return Collections.emptyMap(); //日期兜底处理 Date nowDate = DateUtils.getNowDate(); Date dayBefore7 = DateUtils.plusDate(-1, nowDate); //2024年09月13日17:02:59 支持前段自定义起止时间 //先用日期获取当天和前一天的数据,如果获取不到,则提示错误信息 String nowDateStr = StringUtils.isBlank(timeEnd) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, nowDate) : timeEnd; String dayBefore1Str = StringUtils.isBlank(timeBegin) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, dayBefore7) : timeBegin; //返回的对象 Map> result = new HashMap<>(); //获取筛选日期内的所有的数据 List tShuju1List = this.shuju1Mapper.selectTShuju1List(TShuju1.builder().timeBegin(dayBefore1Str).timeEnd(nowDateStr).build()); List list = new ArrayList<>(); //先判断类型,然后根据不同类型,查询不同的数据 if(BusinessEnum.SmartAddMedicineReqEnum.JSLL.getCode() == type){ //查询仪表即可 list = tShuju1List.stream() .map(o -> new ChartBasic(o.getTIME(), Objects.isNull(o.getScJsZll()) ? null : o.getScJsZll().divide(BigDecimal_2, NUMBER_SCALE_4, RoundingMode.HALF_UP))) .collect(Collectors.toList()); result.put(BusinessEnum.DataSourceEnum.YB.getCode(), list); }else if(BusinessEnum.SmartAddMedicineReqEnum.HY_1_XSY.getCode() == type){ //查询化验室 list = tShuju1List.stream() .map(o -> new ChartBasic(o.getTIME(), o.getJqr1HyXiaodan())) .collect(Collectors.toList()); result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list); //查询预测 锡林浩特没有预测数据 // result.put(BusinessEnum.DataSourceEnum.YC.getCode(), list); }else if(BusinessEnum.SmartAddMedicineReqEnum.HY_2_XSY.getCode() == type){ //查询化验室 list = tShuju1List.stream() .map(o -> new ChartBasic(o.getTIME(), o.getJqr2HyXiaodan())) .collect(Collectors.toList()); result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list); //查询预测 锡林浩特没有预测数据 // list = // result.put(BusinessEnum.DataSourceEnum.YC.getCode(), list); }else if(BusinessEnum.SmartAddMedicineReqEnum.QY_1_AD.getCode() == type){ //查询化验室 list = tShuju1List.stream() .map(o -> new ChartBasic(o.getTIME(), o.getJqr1QyAndan())) .collect(Collectors.toList()); result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list); }else if(BusinessEnum.SmartAddMedicineReqEnum.QY_2_AD.getCode() == type){ //查询化验室 list = tShuju1List.stream() .map(o -> new ChartBasic(o.getTIME(), o.getJqr2QyAndan())) .collect(Collectors.toList()); result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list); }else if(BusinessEnum.SmartAddMedicineReqEnum.JSCOD.getCode() == type){ //查询仪表即可 list = tShuju1List.stream() .map(o -> new ChartBasic(o.getTIME(), o.getScJsCod())) .collect(Collectors.toList()); result.put(BusinessEnum.DataSourceEnum.YB.getCode(), list); //查询化验室 list = tShuju1List.stream() .map(o -> new ChartBasic(o.getTIME(), o.getJqrSwcCod())) .collect(Collectors.toList()); result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list); }else if(BusinessEnum.SmartAddMedicineReqEnum.JSTN.getCode() == type){ //查询仪表即可 list = tShuju1List.stream() .map(o -> new ChartBasic(o.getTIME(), o.getScJsZongdan())) .collect(Collectors.toList()); result.put(BusinessEnum.DataSourceEnum.YB.getCode(), list); }else if(BusinessEnum.SmartAddMedicineReqEnum.TYTJL.getCode() == type){ //查询仪表即可 锡林浩特的没有 /*list = tShuju1List.stream() .map(o -> new ChartBasic(o.getTIME(), o.get())) .collect(Collectors.toList()); result.put(BusinessEnum.DataSourceEnum.YB.getCode(), list);*/ }else{ log.info("暂不支持的类型~~~"); } return result; } @Override public HomeCountInfo homeCountInfo() { HomeCountInfo build = HomeCountInfo.builder().build(); //获取化验状态 TTbXie tTbXie = this.xieMapper.selectTTbXieByID(LONG_1); if(!Objects.isNull(tTbXie)) build.setStatus(tTbXie.getJqrZhuantai()); //获取累计运行天数 定义:只要某天有化验,那么就算累计加一天 //2024年10月13日13:56:33 查询逻辑调整:不再查询化验记录,查询上报的数据 (T_SHUJU_1)表的数据 build.setDays(this.zAssayMapper.selectDistinctDays()); /*//获取累计化验轮次 build.setCounts(this.zAssayMapper.selectCount()); //获取累计化验次数 build.setTotals(this.zAssayResultMapper.selectCount());*/ //2024年10月13日13:56:14 化验次数和化验轮次 int count = this.shuju1Mapper.selectCountDistinctAssayNo(); build.setCounts(count); build.setTotals(count * INT_7); return build; } }