add 手持点位管理功能

This commit is contained in:
张江玮
2023-10-13 14:27:01 +08:00
parent 328602c761
commit 3b561d5372
8 changed files with 174 additions and 140 deletions

View File

@@ -461,7 +461,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
}
public JSONArray createBlocksData(Instruction inst) {
String ip = paramService.findByCode("local_ip").getValue();
String ip = paramService.findByCode("local_host").getValue();
String addr = ip + port;
JSONArray blocks = new JSONArray();

View File

@@ -3,7 +3,7 @@ package org.nl.hand.amb.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@@ -29,15 +29,15 @@ import java.util.Map;
@RequestMapping("/api/hand")
@Slf4j
public class HFHandController {
private final HFHandService HandService;
private final HFHandService handService;
@PostMapping("/area")
@PostMapping("/region")
@Log("查询区域")
@ApiOperation("查询区域")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> query() {
return new ResponseEntity<>(HandService.queryArea(null), HttpStatus.OK);
return new ResponseEntity<>(handService.queryArea(null), HttpStatus.OK);
}
@PostMapping("/point")
@@ -47,8 +47,8 @@ public class HFHandController {
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryPoint(@RequestBody Map<String, String> whereJson) {
String region = (String) whereJson.get("region");
return new ResponseEntity<>(HandService.queryPointByArea(region), HttpStatus.OK);
String region = whereJson.get("region_code");
return new ResponseEntity<>(handService.queryPointByArea(region), HttpStatus.OK);
}
@PostMapping("/point/storage")
@@ -58,7 +58,7 @@ public class HFHandController {
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryDeviceAugmentabilityByCode(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryDeviceAugmentabilityByCode(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.queryDeviceAugmentabilityByCode(whereJson), HttpStatus.OK);
}
@PostMapping("/task_type")
@@ -68,7 +68,7 @@ public class HFHandController {
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryTaskType() {
return new ResponseEntity<>(HandService.queryTaskType(), HttpStatus.OK);
return new ResponseEntity<>(handService.queryTaskType(), HttpStatus.OK);
}
@PostMapping("/tasks")
@@ -78,7 +78,7 @@ public class HFHandController {
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryTask(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryTask(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.queryTask(whereJson), HttpStatus.OK);
}
@PostMapping("/insts")
@@ -88,7 +88,7 @@ public class HFHandController {
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryInst(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryInst(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.queryInst(whereJson), HttpStatus.OK);
}
@PostMapping("/routeplan_type")
@@ -97,7 +97,7 @@ public class HFHandController {
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryRouteplanType() {
return new ResponseEntity<>(HandService.queryRouteplanType(), HttpStatus.OK);
return new ResponseEntity<>(handService.queryRouteplanType(), HttpStatus.OK);
}
@PostMapping("/task")
@@ -106,7 +106,7 @@ public class HFHandController {
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> createTask(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.createTask(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.createTask(whereJson), HttpStatus.OK);
}
@PostMapping("/inst")
@@ -115,7 +115,7 @@ public class HFHandController {
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> Instoperation(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.Instoperation(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.Instoperation(whereJson), HttpStatus.OK);
}
@PostMapping("/taskoperation")
@@ -124,7 +124,7 @@ public class HFHandController {
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> Taskoperation(@RequestBody Map<String, String> whereJson) throws Exception {
return new ResponseEntity<>(HandService.Taskoperation(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.Taskoperation(whereJson), HttpStatus.OK);
}
@PostMapping("/deviceStatus")
@@ -134,7 +134,7 @@ public class HFHandController {
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> updateDeviceStatus(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.updateDeviceStatus(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.updateDeviceStatus(whereJson), HttpStatus.OK);
}
@PostMapping("/handlogin")
@@ -144,7 +144,7 @@ public class HFHandController {
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> handlogin(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.handleLogin(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.handleLogin(whereJson), HttpStatus.OK);
}
@PostMapping("/matrial")
@@ -153,7 +153,7 @@ public class HFHandController {
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryMaterial() {
return new ResponseEntity<>(HandService.queryMaterial(), HttpStatus.OK);
return new ResponseEntity<>(handService.queryMaterial(), HttpStatus.OK);
}
@PostMapping("/task2")
@@ -162,7 +162,7 @@ public class HFHandController {
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> createTask2(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.createTask2(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.createTask2(whereJson), HttpStatus.OK);
}
@PostMapping("/createChargingTask")
@@ -171,7 +171,25 @@ public class HFHandController {
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> createChargingTask(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.createChargingTask(whereJson), HttpStatus.OK);
return new ResponseEntity<>(handService.createChargingTask(whereJson), HttpStatus.OK);
}
@PostMapping("/material")
@Log("查询物料")
@ApiOperation("查询物料")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> material() {
return new ResponseEntity<>(handService.material(), HttpStatus.OK);
}
@PostMapping("/pointOpt")
@Log("点位操作")
@ApiOperation("点位操作")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> pointOpt(@RequestBody JSONObject param) {
return new ResponseEntity<>(handService.pointOpt(param), HttpStatus.OK);
}
}

View File

@@ -2,6 +2,8 @@
package org.nl.hand.amb.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
/**
@@ -119,4 +121,8 @@ public interface HFHandService {
* @return
*/
Map<String, Object> createChargingTask(Map<String, String> whereJson);
JSONObject material();
JSONObject pointOpt(JSONObject param);
}

View File

@@ -35,6 +35,7 @@ import org.nl.hand.amb.service.HFHandService;
import org.nl.modules.common.config.RsaProperties;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.RsaUtils;
import org.nl.modules.system.service.DictService;
import org.nl.modules.system.service.UserService;
import org.nl.modules.system.service.dto.UserDto;
import org.nl.modules.system.util.CodeUtil;
@@ -59,6 +60,7 @@ public class HFHandServiceImpl implements HFHandService {
private final UserService userService;
private final DeviceService deviceService;
private final DeviceAppService deviceAppService;
private final DictService dictService;
InstructionService instructionService = null;
@@ -73,123 +75,41 @@ public class HFHandServiceImpl implements HFHandService {
}
@Override
public Map<String, Object> queryPointByArea(String dict_id) {
public Map<String, Object> queryPointByArea(String region) {
if (StrUtil.isEmpty(region)) {
throw new BadRequestException("区域不能为空!");
}
JSONArray devices = WQLObject.getWQLObject("acs_device").query("region = '" + region + "' AND device_type = 'station' AND is_config = 'true' ", "seq_num").getResultJSONArray(0);
JSONArray resultArr = new JSONArray();
JSONObject resultJson = new JSONObject();
JSONObject jo = new JSONObject();
for (int i = 0; i < devices.size(); i++) {
JSONObject device = devices.getJSONObject(i);
String deviceCode = device.getString("device_code");
Device deviceCache = this.deviceAppService.findDeviceByCode(deviceCode);
if (StrUtil.isEmpty(dict_id)) {
throw new BadRequestException("区域id不能为空");
}
String value = "";
String move = "";
String status = "";
String input_material = "0";
String allow_update = "";
String material = "";
String batch = "";
//再字典中查询出value
//JSONObject valuejo = WQLObject.getWQLObject("sys_dict_detail").query("detail_id='" + dict_id + "'").uniqueResult(0);
JSONObject valuejo = WQL.getWO("QJN_QUERY001").addParam("flag", "3").addParam("detail_id", dict_id).process().uniqueResult(0);
if (!ObjectUtil.isEmpty(valuejo)) {
value = valuejo.getString("value");
}
//根据value值去查所有的设备
JSONArray acs_deviceja = WQLObject.getWQLObject("ACS_DEVICE").query("region='" + value + "' and device_type='conveyor' and is_config='true' ", "seq_num,device_name").getResultJSONArray(0);
for (int i = 0; i < acs_deviceja.size(); i++) {
JSONObject devicejo = acs_deviceja.getJSONObject(i);
String device_code = devicejo.getString("device_code");
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device device = appService.findDeviceByCode(device_code);
//无光电普通站点
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
//检测站点
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (StrUtil.equals(device.getIslock(), "true")) {
status = "3";
move = "有任务";
} else {
if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) {
status = "0";
move = "无货";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) {
status = "1";
move = "有托盘";
} else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) {
status = "2";
move = "有托盘有货";
}
JSONObject row = new JSONObject();
row.put("device_code", deviceCode);
row.put("device_name", device.getString("device_name"));
String status = "0";
if ("true".equals(deviceCache.getExtraValue().get("station_manager"))) {
if ("1".equals(deviceCache.getIslock())) {
status = "2";
} else if (1 == deviceCache.getHas_goods()) {
status = "1";
}
material = device.getMaterial_type();
//material = standardOrdinarySiteDeviceDriver.getMaterial();
if (StrUtil.isNullOrUndefined(material)) {
material = "";
}
batch = device.getBatch();
//batch = standardOrdinarySiteDeviceDriver.getBatch();
if (StrUtil.isNullOrUndefined(batch)) {
batch = "";
}
String input_materialflag = (String) device.getExtraValue().get("input_material");
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("false")) {
input_material = "0";
}
if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("true")) {
input_material = "1";
}
jo.put("material_type", material);
jo.put("batch", batch);
jo.put("islock", device.getIslock());
jo.put("status_name", move);
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_name"));
jo.put("allow_update", "1");
jo.put("input_material", input_material);
// 特殊驱动
row.put("material_type", deviceCache.getMaterial_type());
row.put("qty", deviceCache.getBatch());
}
//检测站点
else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
if (StrUtil.equals(device.getIslock(), "true")) {
status = "3";
move = "有任务";
} else {
if (standardInspectSiteDeviceDriver.getHasGoods() == 0) {
status = "0";
move = "无货";
} else if (standardInspectSiteDeviceDriver.getHasGoods() == 1) {
status = "1";
move = "有托盘";
} else if (standardInspectSiteDeviceDriver.getHasGoods() == 2) {
status = "2";
move = "有托盘有货";
}
}
jo.put("material_type", standardInspectSiteDeviceDriver.getMaterial());
jo.put("status_name", move);
jo.put("status", status);
jo.put("device_id", devicejo.getString("device_id"));
jo.put("device_code", devicejo.getString("device_code"));
jo.put("device_name", devicejo.getString("device_name"));
jo.put("allow_update", "1");
jo.put("batch", standardInspectSiteDeviceDriver.getBatch());
jo.put("input_material", input_material);
}
resultArr.add(jo);
row.put("status", status);
resultArr.add(row);
}
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", resultArr);
return resultJson;
JSONObject result = new JSONObject();
result.put("code", "1");
result.put("desc", "查询成功");
result.put("result", resultArr);
return result;
}
@Override
@@ -778,4 +698,96 @@ public class HFHandServiceImpl implements HFHandService {
jo.put("desc", "操作成功!");
return jo;
}
@Override
public JSONObject material() {
JSONArray materialType = WQLObject.getWQLObject("sys_dict_detail").query("`name` = 'material_type'").getResultJSONArray(0);
JSONObject result = new JSONObject();
result.put("code", "1");
result.put("desc", "查询成功");
result.put("result", materialType);
return result;
}
@Override
public JSONObject pointOpt(JSONObject param) {
JSONObject result = new JSONObject();
String type = param.getString("type");
if (StrUtil.isBlank(type)) {
result.put("code", "0");
result.put("desc", "未知操作!");
return result;
}
String deviceCode = param.getString("device_code");
if (StrUtil.isBlank(deviceCode)) {
result.put("code", "0");
result.put("desc", "未知点位!");
return result;
}
Device device = this.deviceAppService.findDeviceByCode(deviceCode);
if ("1".equals(device.getIslock())) {
result.put("code", "0");
result.put("desc", "当前点位有正在执行的任务,禁止操作!");
return result;
}
if ("1".equals(type)) {
// 确认
String materialType = param.getString("material_type");
if (StrUtil.isBlank(materialType) || "0".equals(materialType)) {
result.put("code", "0");
result.put("desc", "物料不能为空!");
return result;
}
int qty = param.getIntValue("qty");
if (qty <= 0) {
result.put("code", "0");
result.put("desc", "数量必须大于零!");
return result;
}
if ("true".equals(device.getExtraValue().get("station_manager"))) {
device.setHas_goods(1);
device.setMaterial_type(materialType);
device.setBatch(String.valueOf(qty));
JSONObject rpUpdate = new JSONObject();
rpUpdate.put("hasgoods", "1");
rpUpdate.put("material_type", materialType);
rpUpdate.put("batch", qty);
rpUpdate.put("update_by", "sc");
rpUpdate.put("update_time", DateUtil.now());
WQLObject.getWQLObject("acs_device_runpoint").update(rpUpdate, "device_code = '" + deviceCode + "'");
} else {
result.put("code", "0");
result.put("desc", "此点位在设备配置中未开启点位管理,无法保存物料等信息!");
return result;
}
} else if ("2".equals(type)) {
// 清空
if ("true".equals(device.getExtraValue().get("station_manager"))) {
device.setHas_goods(0);
device.setMaterial_type("0");
device.setBatch("0");
JSONObject rpUpdate = new JSONObject();
rpUpdate.put("hasgoods", "0");
rpUpdate.put("material_type", "0");
rpUpdate.put("batch", "0");
rpUpdate.put("update_by", "sc");
rpUpdate.put("update_time", DateUtil.now());
WQLObject.getWQLObject("acs_device_runpoint").update(rpUpdate, "device_code = '" + deviceCode + "'");
}
} else {
result.put("code", "0");
result.put("desc", "未知操作!");
return result;
}
result.put("code", "1");
result.put("desc", "操作成功!");
return result;
}
}

View File

@@ -46,14 +46,12 @@
IF 输入.flag = "1"
QUERY
SELECT
dtl.detail_id as region_id,
dtl.label as region_name,
dtl.value as region_code
label,
`value`
FROM
sys_dict sys
LEFT JOIN sys_dict_detail dtl ON dtl.dict_id = sys.dict_id
sys_dict_detail
WHERE
sys.NAME = "region_type"
`name` = 'region'
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -230,7 +230,7 @@ public class ResultBean implements Serializable, Cloneable {
rows = new ArrayList();
}
JSONArray jrows = this.rows2jsonarray(rows);
JSONObject jrow = null;
JSONObject jrow = new JSONObject();
if (jrows.size() > 0) {
jrow = jrows.getJSONObject(0);
}

View File

@@ -172,7 +172,7 @@
<span class="el-dropdown-link">
<i class="el-icon-menu" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-menu slot="dropdonwn">
<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>