无货上报lms优化与输送线指令初始化

This commit is contained in:
张江玮
2023-02-02 17:15:49 +08:00
parent 677125f92d
commit 921f57acb2
8 changed files with 77 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -162,7 +163,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
inst_message = null;
this.clearWrite();
}
if (move == 0 && last_move == 1 && mode != 0) {
if (move == 0 && last_move == 1) {
this.requiresShipDeviceUpdate = false;
}
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
@@ -268,8 +269,10 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
if (move > 0 && !requireSucess) {
instruction_require();
}
if (!requiresShipDeviceUpdate) {
if (!requiresShipDeviceUpdate && move == 0) {
this.shipDeviceUpdate();
} else {
this.requiresShipDeviceUpdate = true;
}
break;
case 4:
@@ -321,9 +324,10 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
put("device_code", device_code);
}};
acsToWmsService.shipDeviceUpdate(param);
this.requiresShipDeviceUpdate = true;
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
this.requiresShipDeviceUpdate = true;
}
}

View File

@@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.ext.wms.data.*;
import java.util.Map;
public interface AcsToWmsService {
/**
@@ -105,5 +103,5 @@ public interface AcsToWmsService {
UpdateLKTaskResponse updateLKTaskRequest(UpdateLKTaskRequest updateLKTaskRequest);
// 输送线有货变成无货时向lms请求
void shipDeviceUpdate(JSONObject param);
HttpResponse shipDeviceUpdate(JSONObject param);
}

View File

@@ -18,15 +18,11 @@ import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.service.ParamService;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
@RequiredArgsConstructor
@Slf4j
@@ -502,7 +498,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
@Override
public void shipDeviceUpdate(JSONObject param) {
public HttpResponse shipDeviceUpdate(JSONObject param) {
try {
MDC.put(log_file_type, log_type);
log.info("shipDeviceUpdate-----输入参数{}", param);
@@ -511,7 +507,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
AddressDto addressDto = addressService.findByCode("shipDeviceUpdate");
String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url;
HttpRequest
return HttpRequest
.post(url)
.body(param.toString())
.execute();
@@ -521,5 +517,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} finally {
MDC.remove(log_file_type);
}
return null;
}
}

View File

@@ -145,4 +145,12 @@ public class InstructionController {
public ResponseEntity<Object> queryByTaskId(@RequestBody String taskId) {
return new ResponseEntity<>(instructionService.getByTaskId(taskId), HttpStatus.OK);
}
@Log("初始化")
@ApiOperation("初始化")
@PostMapping(value = "/init/{id}")
public ResponseEntity<Object> init(@RequestBody String id) throws Exception {
instructionService.init(id);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -275,4 +275,5 @@ public interface InstructionService {
boolean createLkInst(String type,Instruction inst);
void init(String id);
}

View File

@@ -17,8 +17,10 @@ import org.nl.acs.agv.server.*;
import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
@@ -1361,4 +1363,36 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
@Override
public void init(String id) {
Instruction inst = this.findById(id);
if (inst == null) {
throw new BadRequestException("指令不存在或已删除");
}
if ("2".equals(inst.getInstruction_status())) {
throw new BadRequestException("指令已经完成");
}
Device startDevice = deviceAppService.findDeviceByCode(inst.getStart_device_code());
DeviceDriver startDeviceDriver = startDevice.getDeviceDriver();
if (startDeviceDriver instanceof SiemensConveyorDeviceDriver) {
Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code());
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> map = new HashMap<>();
map.put("code", "to_target");
map.put("value", nextDevice.getExtraValue().get("address").toString());
list.add(map);
Map<String, String> map2 = new HashMap<>();
map2.put("code", "to_task");
map2.put("value", inst.getInstruction_code());
list.add(map2);
Map<String, String> map3 = new HashMap<>();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
((SiemensConveyorDeviceDriver) startDeviceDriver).writing(list);
}
}
}

View File

@@ -70,4 +70,12 @@ export function reload() {
})
}
export default { add, edit, del, finish, cancel, forceCancel, queryUnFinish, queryByTaskId, reload }
export function init(instruction_id) {
return request({
url: 'api/instruction/init/' + instruction_id,
method: 'post',
data: instruction_id
})
}
export default { add, edit, del, finish, cancel, forceCancel, queryUnFinish, queryByTaskId, reload, init }

View File

@@ -180,6 +180,7 @@
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'a')">完成</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'b')">取消</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'c')">强制取消</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'d')">初始化</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
@@ -320,6 +321,14 @@ export default {
console.log(err.response.data.message)
})
},
init(index, row) {
crudInstruction.init(row.instruction_id).then(res => {
this.crud.toQuery()
this.crud.notify('初始化成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
}).catch(err => {
console.log(err.response.data.message)
})
},
reload() {
crudInstruction.reload().then(res => {
this.crud.toQuery()
@@ -346,6 +355,9 @@ export default {
case 'c':// 强制取消
this.forceCancel(command.index, command.row)
break
case 'd':// 初始化
this.init(command.index, command.row)
break
}
}