| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.AppAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.asrs.entity.AgvWarn; |
| | | import com.zy.asrs.entity.AgvWrkMast; |
| | | import com.zy.asrs.entity.param.AgvWarnBody; |
| | |
| | | import com.zy.asrs.service.AgvWarnService; |
| | | import com.zy.asrs.service.AgvWrkMastService; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.utils.AppAuthUtil; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/agv") |
| | | public class AgvWarnController extends BaseController { |
| | | |
| | | |
| | |
| | | @PostMapping("/service/rest/agvCallbackService/warnCallback") |
| | | @AppAuth(memo = "AGV告警回调") |
| | | public Object taskEventStaus(@RequestBody AgvWarnCallBackParam param, HttpServletRequest request) { |
| | | log.info("AGV告警回调:{}", JSON.toJSONString(param)); |
| | | List<AgvWarnBody> data = param.getData(); |
| | | //og.info("AGV告警回调:{}", JSON.toJSONString(param)); |
| | | AppAuthUtil.auth("", param, request); |
| | | List<AgvWarnBody> agvWarnBodies = param.getData(); |
| | | // List<AgvWarnBody> agvWarnBodies = JSONArray.parseArray(data, AgvWarnBody.class); |
| | | AgvWarn agvWarn = null; |
| | | List<AgvWarn> agvWarns = new ArrayList<>(); |
| | | List<AgvWarn> updates = new ArrayList<>(); |
| | | for (AgvWarnBody body : data) { |
| | | List<AgvWarn> agvWarnList = agvWarnService.selectList(new EntityWrapper<AgvWarn>().eq("robot_code", body.getRobotCode()).eq("begin_time", body.getBeginTime()).eq("warn_content", body.getWarnContent())); |
| | | for (AgvWarnBody body : agvWarnBodies) { |
| | | List<AgvWarn> agvWarnList = agvWarnService.selectList(new EntityWrapper<AgvWarn>().eq("robot_code", body.getRobotCode()).eq("warn_content", body.getWarnContent())); |
| | | if (Cools.isEmpty(agvWarnList)) { |
| | | agvWarn = new AgvWarn(); |
| | | agvWarn.setBeginTime(body.getBeginTime()); |
| | | agvWarn.setBeginTime(body.getBeginDate()); |
| | | agvWarn.setAppeTime(new Date()); |
| | | agvWarn.setTimes(0); |
| | | agvWarn.setModiTime(DateUtils.convert(body.getBeginDate(), DateUtils.yyyyMMddHHmmss_F)); |
| | | agvWarn.setRobotCode(body.getRobotCode()); |
| | | agvWarn.setWarnContent(body.getWarnContent()); |
| | | if (body.getTaskCode() != null) { |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectById(body.getTaskCode()); |
| | | if (agvWrkMast != null) { |
| | | agvWarn.setLocNo(agvWrkMast.getLocNo()); |
| | | agvWarn.setSourceLocNo(agvWrkMast.getSourceLocNo()); |
| | | try { |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectById(Math.abs(Integer.parseInt(body.getTaskCode()))); |
| | | if (agvWrkMast != null) { |
| | | agvWarn.setLocNo(agvWrkMast.getLocNo()); |
| | | agvWarn.setSourceLocNo(agvWrkMast.getSourceLocNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("任务不存在"); |
| | | } |
| | | } |
| | | agvWarns.add(agvWarn); |
| | |
| | | agvWarn.setWarnContent(agvWarn.getWarnContent().contains(body.getWarnContent()) ? body.getWarnContent() : agvWarn.getWarnContent() + "、" + body.getWarnContent()); |
| | | agvWarn.setModiTime(new Date()); |
| | | if (body.getTaskCode() != null) { |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectById(body.getTaskCode()); |
| | | if (agvWrkMast != null) { |
| | | agvWarn.setLocNo(agvWrkMast.getLocNo()); |
| | | agvWarn.setSourceLocNo(agvWrkMast.getSourceLocNo()); |
| | | try { |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectById(body.getTaskCode()); |
| | | if (agvWrkMast != null) { |
| | | agvWarn.setLocNo(agvWrkMast.getLocNo()); |
| | | agvWarn.setSourceLocNo(agvWrkMast.getSourceLocNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("任务不存在"); |
| | | } |
| | | } |
| | | updates.add(agvWarn); |
| | |
| | | agvWarnService.updateBatchById(updates); |
| | | } |
| | | Map<String, Object> result = new HashMap<>(); |
| | | logPost(param, JSONObject.toJSONString(result), true); |
| | | logPost(JSONObject.toJSONString(param), JSONObject.toJSONString(result), true); |
| | | result.put("code", 0); |
| | | result.put("message", "成功"); |
| | | result.put("reqCode", param.getReqCode()); |
| | | return result; |
| | | } |
| | | |
| | | private void logPost(AgvWarnCallBackParam param, String response, boolean success) { |
| | | private void logPost(String param, String response, boolean success) { |
| | | apiLogService.save( |
| | | "ESS任务回调", |
| | | "ESS小车报警回调", |
| | | "/phyzwms/agv/task/event/status", |
| | | null, |
| | | null, |
| | | JSONObject.toJSONString(param), |
| | | param, |
| | | response, |
| | | success |
| | | ); |