package com.ld.igds.three.service.impl; import com.alibaba.fastjson.JSONObject; import com.ld.igds.common.CoreThreeService; import com.ld.igds.models.MWarnInfo; import com.ld.igds.models.ThreeConf; import com.ld.igds.three.ThreeCodeEnum; import com.ld.igds.three.ThreeConstant; import com.ld.igds.three.data.Data1003; import com.ld.igds.three.data.ThreeResponse; import com.ld.igds.three.mapper.ThreeMapper; import com.ld.igds.three.param.ThreeCommonParam; import com.ld.igds.three.param.ThreeRequest; import com.ld.igds.three.service.ThreeService; import com.ld.igds.three.util.ThreeRespUtil; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * 1003-警告信息接口实现 * * @author chen */ @Service public class ThreeServiceImpl1003 implements ThreeService { @Autowired private CoreThreeService commonService; @Autowired private ThreeMapper threeMapper; @Override public String getInterfaceId() { return ThreeConstant.API_THREE_1003; } @SuppressWarnings("unchecked") @Override public ThreeResponse execute(ThreeRequest req){ //转化请求参数 ThreeCommonParam param = JSONObject.parseObject(req.getData().toString(), ThreeCommonParam.class); //判断uid if(StringUtils.isEmpty(param.getUid())){ return ThreeRespUtil.error(ThreeCodeEnum.CODE_1005, req); } //根据uid获取三维信息 ThreeConf threeConf = commonService.getCacheThreeConfById(req.getCompanyId(), param.getUid()); if(threeConf == null){ return ThreeRespUtil.error(ThreeCodeEnum.CODE_1111, "未查询到此uid的配置信息,请联系管理员!", req); } List warnList = threeMapper.getWarnList(req.getCompanyId(), req.getDeptId(), threeConf.getDepotId()); List list = new ArrayList<>(); Data1003 data1003; if(warnList != null && warnList.size() > 0){ for (MWarnInfo warnInfo : warnList) { data1003 = new Data1003(); data1003.setUid(threeConf.getUid()); data1003.setType(warnInfo.getType()); data1003.setTime(DateFormatUtils.format(warnInfo.getTime(), "MM-dd HH:mm")); list.add(data1003); } } return ThreeRespUtil.success(list, req); } }