package com.ld.igds.phone.service.impl; import com.alibaba.fastjson.JSONObject; import com.ld.igds.grain.manager.GrainManager; import com.ld.igds.constant.RespCodeEnum; import com.ld.igds.gas.CoreGasService; import com.ld.igds.gas.dto.GasData; import com.ld.igds.gas.dto.GasParam; import com.ld.igds.phone.constant.PhoneConstant; import com.ld.igds.phone.dto.AuthUser; import com.ld.igds.phone.dto.DtoGas; import com.ld.igds.phone.dto.PhoneResponse; import com.ld.igds.phone.param.ParamDepot; import com.ld.igds.phone.param.PhoneRequest; import com.ld.igds.phone.service.PhoneService; import com.ld.igds.phone.util.PhoneRespUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; /** * 粮情展示-气体详情接口实现 * * @author chen */ @Service public class ServiceImpl5306 implements PhoneService { @Autowired private CoreGasService coreGasService; @Override public String getInterfaceId() { return PhoneConstant.API_PHONE_5306; } @SuppressWarnings("unchecked") @Override public PhoneResponse execute(PhoneRequest req, AuthUser authUser) throws Exception { //转化为对象 ParamDepot paramDepot = JSONObject.parseObject(req.getData().toString(), ParamDepot.class); //设置查询参数 GasParam param = new GasParam(); param.setCompanyId(authUser.getCompanyId()); param.setLimit(1); param.setDepotId(paramDepot.getDepotId()); List list = coreGasService.pageQueryList(param); if(null == list || list.isEmpty()){ return PhoneRespUtil.error(RespCodeEnum.CODE_2000,"暂无查到气体检测记录!"); } //封装响应数据 DtoGas dtoGas = new DtoGas(); dtoGas.setDepotId(list.get(0).getDepotId()); dtoGas.setReceiveDate(list.get(0).getReceiveDate()); dtoGas.setPerCo2Max(list.get(0).getPerCo2Max()); dtoGas.setPerCo2(list.get(0).getPerCo2()); dtoGas.setPerCo2Min(list.get(0).getPerCo2Min()); dtoGas.setPerO2Max(list.get(0).getPerO2Max()); dtoGas.setPerO2(list.get(0).getPerO2()); dtoGas.setPerO2Min(list.get(0).getPerO2Min()); dtoGas.setPerPh3Max(list.get(0).getPerPh3Max()); dtoGas.setPerPh3(list.get(0).getPerPh3()); dtoGas.setPerPh3Min(list.get(0).getPerPh3Min()); dtoGas.setPerN2Max(list.get(0).getPerN2Max()); dtoGas.setPerN2Max(list.get(0).getPerN2Max()); dtoGas.setPerN2Min(list.get(0).getPerN2Min()); dtoGas.setCheckUser(list.get(0).getCheckUser()); return PhoneRespUtil.success(dtoGas, req); } }