package com.zy.asrs.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.core.common.Cools;
|
import com.core.common.R;
|
import com.zy.asrs.entity.BasStation;
|
import com.zy.asrs.entity.mes.*;
|
import com.zy.asrs.service.BasStationService;
|
import com.zy.asrs.service.MesService;
|
import com.zy.common.web.BaseController;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
|
@RestController
|
public class MesController extends BaseController {
|
|
@Resource
|
private MesService mesService;
|
|
|
// 物料信息同步
|
@PostMapping("/api/mes/synMatInfo")
|
public MesReturn synMatInfo(@RequestBody MesMatInfo param){
|
|
MesReturn mesReturn = new MesReturn();
|
mesReturn.setSuccess(mesService.synMatInfo(param) == 1 ? "1" : "2");
|
return mesReturn;
|
}
|
|
// 出库申请
|
@PostMapping("/api/mes/outBoundOrder")
|
public MesReturn outBoundOrder(@RequestBody MesInApply param){
|
MesReturn mesReturn = new MesReturn();
|
// 终点为空,计算接驳位
|
BasStation basStation = null;
|
if (Cools.isEmpty(param.getNextStationId())) {
|
List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().eq("loc_sts", "O"));
|
if(basStations.isEmpty()) {
|
mesReturn.setSuccess("2");
|
mesReturn.setMessage("无空接驳位,请稍后再试!");
|
return mesReturn;
|
}
|
// 接驳点
|
basStation = basStations.get(0);
|
param.setNextStationId(basStation.getDevNo());
|
|
// 先更新接驳点状态
|
basStation.setModiTime(new Date());
|
basStation.setLocSts("S");
|
basStation.setBarcode(param.getDjNo());
|
basStationService.updateById(basStation);
|
}
|
int i = mesService.outBoundOrder(param);
|
if(i == 1) {
|
mesReturn.setSuccess("1");
|
} else {
|
// 释放接驳点
|
if(basStation != null) {
|
basStation.setModiTime(new Date());
|
basStation.setLocSts("O");
|
basStation.setBarcode("");
|
basStationService.updateById(basStation);
|
}
|
mesReturn.setSuccess("2");
|
}
|
return mesReturn;
|
}
|
|
// // 出库申请(叫料),装配库、滑块库
|
// @PostMapping("/api/mes/callOutBoundOrder")
|
// public MesReturn callOutBoundOrder(@RequestBody MesCallOutApply param){
|
//
|
// MesReturn mesReturn = new MesReturn();
|
// mesReturn.setSuccess(mesService.callOutBoundOrder(param) == 1 ? "1" : "2");
|
// return mesReturn;
|
// }
|
|
// 入库申请
|
@PostMapping("/api/mes/inBoundOrder")
|
public MesReturn inBoundOrder(@RequestBody MesInApply param){
|
|
MesReturn mesReturn = new MesReturn();
|
mesReturn.setSuccess(mesService.inBoundOrder(param, 0) == 1 ? "1" : "2");
|
return mesReturn;
|
}
|
|
// 入站允许
|
@PostMapping("/api/mes/allowInStation")
|
public MesReturn allowInStation(@RequestBody TransInOutStationAllow param){
|
|
return mesService.allowInStation(param);
|
}
|
|
// 离站允许,装配库、滑块库
|
@PostMapping("/api/mes/allowOutStation")
|
public MesReturn allowOutStation(@RequestBody TransInOutStationAllow param){
|
|
return mesService.allowOutStation(param);
|
}
|
|
@Resource
|
private BasStationService basStationService;
|
|
// 下发运输任务,mes调用下刀06(呼叫agv搬运)
|
@PostMapping("/api/mes/submitTask")
|
public JSONObject submitTask(@RequestBody TransTask param){
|
// 终点为空,计算接驳位
|
BasStation basStation = null;
|
if (Cools.isEmpty(param.getNextStationId())) {
|
List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().eq("loc_sts", "O"));
|
if(basStations.isEmpty()) {
|
JSONObject result = new JSONObject();
|
result.put("taskno", param.getTaskno());
|
result.put("Success", "2");
|
result.put("Message", "无空接驳位,请稍后再试!");
|
return result;
|
}
|
// 接驳点
|
basStation = basStations.get(0);
|
param.setNextStationId(basStation.getDevNo());
|
|
// 先更新接驳点状态
|
basStation.setModiTime(new Date());
|
basStation.setLocSts("S");
|
basStation.setBarcode(param.getDjNo());
|
basStationService.updateById(basStation);
|
}
|
|
param.setAgvFactory(1); // 海康
|
param.setNextStationId("A1");
|
JSONObject sendAgvTask = mesService.submitTask(param);
|
if (!"1".equals(sendAgvTask.getString("Success"))) {
|
// 释放接驳点
|
if(basStation != null) {
|
basStation.setModiTime(new Date());
|
basStation.setLocSts("O");
|
basStation.setBarcode("");
|
basStationService.updateById(basStation);
|
}
|
}
|
return sendAgvTask;
|
}
|
|
// 接受成品刀可以入库二维码
|
@PostMapping("/api/mes/inBoundItemBarcode")
|
public MesReturn inBoundItemBarcode(@RequestBody MesItemBarCode param){
|
|
MesReturn mesReturn = new MesReturn();
|
mesReturn.setSuccess("1"); // TODO:待缓存成品刀二维码;
|
return mesReturn;
|
}
|
|
|
// region 测试
|
@GetMapping("/api/mes/transDj")
|
public int transDj(@RequestParam String taskNo,@RequestParam String djNo){
|
|
return mesService.transDj(taskNo,djNo);
|
}
|
|
// 退空托盘返回产线 pda上操作空托返回产线
|
@GetMapping("/tkt")
|
public R tkt(@RequestParam String taskNo){
|
return mesService.tkt(taskNo);
|
}
|
// endregion
|
|
}
|