From 607a04451aa004fdb29da7de09b3a3915334730e Mon Sep 17 00:00:00 2001 From: tuqiang <437016993@qq.com> Date: Fri, 13 Sep 2024 13:40:03 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=96=B0=E5=A2=9E=E4=B8=80=E4=BD=93?= =?UTF-8?q?=E6=9C=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/nl/acs/region/domain/Region.java | 63 +++++ .../nl/acs/region/rest/RegionController.java | 9 + .../nl/acs/region/service/RegionService.java | 12 + .../nl/acs/region/service/dto/RegionDto.java | 39 +++ .../service/impl/RegionServiceImpl.java | 63 +++++ .../region/service/mapper/RegionMapper.java | 9 + .../org/nl/acs/task/service/TaskService.java | 3 +- .../task/service/impl/TaskServiceImpl.java | 2 +- .../main/java/org/nl/hand/dto/HeadDto.java | 5 + .../java/org/nl/hand/dto/HeadTaskDto.java | 5 + .../java/org/nl/hand/rest/PdaController.java | 109 ++++++++ .../java/org/nl/hand/service/HandService.java | 2 +- .../java/org/nl/hand/service/PdaService.java | 31 +++ .../nl/hand/service/impl/PdaServiceImpl.java | 245 ++++++++++++++++++ .../dict/dao/mapper/SysDictMapper.java | 2 + 15 files changed, 595 insertions(+), 4 deletions(-) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/domain/Region.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/rest/RegionController.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/RegionService.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/dto/RegionDto.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/impl/RegionServiceImpl.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/mapper/RegionMapper.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/rest/PdaController.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/PdaService.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/PdaServiceImpl.java diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/domain/Region.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/domain/Region.java new file mode 100644 index 0000000..1a3ffbc --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/domain/Region.java @@ -0,0 +1,63 @@ +package org.nl.acs.region.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.*; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@TableName("acs_region") +public class Region implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableField(exist = false) + private String id; + + + + @TableId(type = IdType.ASSIGN_ID) + private String region_id; + + + @NotBlank + private String region_code; + + + @NotBlank + private String region_name; + + + + @NotBlank + private String is_charge; + + + @NotBlank + private String has_agv; + + + @NotBlank + @TableField(fill = FieldFill.INSERT) + private String create_by; + + + @NotBlank + @TableField(fill = FieldFill.INSERT) + private String create_time; + + + @TableField(fill = FieldFill.INSERT_UPDATE) + private String update_by; + + private String update_time; + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/rest/RegionController.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/rest/RegionController.java new file mode 100644 index 0000000..2a8a9ee --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/rest/RegionController.java @@ -0,0 +1,9 @@ +package org.nl.acs.region.rest; + +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +public class RegionController { +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/RegionService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/RegionService.java new file mode 100644 index 0000000..2dba6e7 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/RegionService.java @@ -0,0 +1,12 @@ +package org.nl.acs.region.service; + +import com.alibaba.fastjson.JSONArray; +import org.nl.acs.common.base.CommonService; +import org.nl.acs.region.domain.Region; +import org.nl.acs.region.service.dto.RegionDto; + +public interface RegionService extends CommonService { + JSONArray queryAllRegions(); + + Region findByCode(String code); +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/dto/RegionDto.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/dto/RegionDto.java new file mode 100644 index 0000000..378d94a --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/dto/RegionDto.java @@ -0,0 +1,39 @@ +package org.nl.acs.region.service.dto; + +import lombok.*; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class RegionDto implements Serializable { + + private static final long serialVersionUID = 1L; + + private String region_code; + + + private String region_name; + + + private String is_charge; + + + private String has_agv; + + + private String create_by; + + + private String create_time; + + + private String update_by; + + private String update_time; +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/impl/RegionServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/impl/RegionServiceImpl.java new file mode 100644 index 0000000..b161cda --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/impl/RegionServiceImpl.java @@ -0,0 +1,63 @@ +package org.nl.acs.region.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; +import lombok.AllArgsConstructor; +import org.nl.acs.auto.initial.ApplicationAutoInitial; +import org.nl.acs.common.base.impl.CommonServiceImpl; +import org.nl.acs.region.domain.Region; +import org.nl.acs.region.service.RegionService; +import org.nl.acs.region.service.mapper.RegionMapper; +import org.nl.common.exception.BadRequestException; +import org.nl.config.language.LangProcess; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@AllArgsConstructor +// @CacheConfig(cacheNames = RouteLineService.CACHE_KEY) +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class RegionServiceImpl extends CommonServiceImpl implements RegionService{ + + @Autowired + RegionService regionService; + @Autowired + RegionMapper regionMapper; + + @Override + public JSONArray queryAllRegions() { + //查询所有区域 + List list = regionService.lambdaQuery().list(); + if (CollectionUtil.isEmpty(list)) { + throw new BadRequestException(LangProcess.msg("error_no_regional")); + } + JSONArray arr = JSONArray.parseArray(JSON.toJSONString(list)); + JSONArray result = new JSONArray(); + for (int i = 0; i < arr.size(); i++) { + JSONObject obj = arr.getJSONObject(i); + JSONObject json = new JSONObject(); + json.put("region_code", obj.getString("region_code")); + json.put("region_name", obj.getString("region_name")); + json.put("is_charge", obj.getString("is_charge")); + json.put("has_agv", obj.getString("has_agv")); + result.add(json); + } + return result; + } + + @Override + public Region findByCode(String code) { + Region region = new LambdaQueryChainWrapper<>(regionMapper) + .eq(StrUtil.isNotEmpty(code), Region::getRegion_code, code) + .one(); + return region; + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/mapper/RegionMapper.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/mapper/RegionMapper.java new file mode 100644 index 0000000..4f4e373 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/region/service/mapper/RegionMapper.java @@ -0,0 +1,9 @@ +package org.nl.acs.region.service.mapper; + +import org.nl.acs.common.base.CommonMapper; +import org.nl.acs.region.domain.Region; +import org.springframework.stereotype.Repository; + +@Repository +public interface RegionMapper extends CommonMapper { +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java index f14fe7d..627addb 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java @@ -171,10 +171,9 @@ public interface TaskService extends CommonService { /** * 查询所有未完成任务 * - * @param whereJson 条件参数 * @return List */ - List queryAllUnfinished(Map whereJson); + List queryAllUnfinished(); /** * 根据状态查询 diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 78bdc2b..7a38733 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -403,7 +403,7 @@ public class TaskServiceImpl extends CommonServiceImpl impleme @Override - public List queryAllUnfinished(Map whereJson) { + public List queryAllUnfinished() { List taskList = new LambdaQueryChainWrapper<>(taskMapper) .lt(Task::getTask_status, TaskStatusEnum.FINISHED.getIndex()) .list(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadDto.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadDto.java index 35bc4b7..4579914 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadDto.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadDto.java @@ -26,4 +26,9 @@ public class HeadDto implements Serializable { */ private String task_type; + /** + * 物料类型 + */ + private String material; + } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadTaskDto.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadTaskDto.java index 89ff13c..545bd75 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadTaskDto.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadTaskDto.java @@ -36,4 +36,9 @@ public class HeadTaskDto implements Serializable { * 2 强制完成 */ private String type; + + /** + * 任务id + */ + private String task_id; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/rest/PdaController.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/rest/PdaController.java new file mode 100644 index 0000000..41a013f --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/rest/PdaController.java @@ -0,0 +1,109 @@ +package org.nl.hand.rest; + + +import cn.dev33.satoken.annotation.SaIgnore; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.task.service.dto.TaskIdAndStatusDTO; +import org.nl.common.logging.annotation.Log; +import org.nl.hand.dto.HeadDto; +import org.nl.hand.dto.HeadTaskDto; +import org.nl.hand.dto.RegionDto; +import org.nl.hand.service.PdaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@Api(tags = "一体机接口") +@RequestMapping("api/pda") +@Slf4j +public class PdaController { + @Autowired + PdaService pdaService; + + @PostMapping("/queryAllPoints") + @Log("查询所有点位") + @ApiOperation("查询所有点位") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity queryAllPoints() { + return new ResponseEntity<>(pdaService.queryAllPoints(), HttpStatus.OK); + } + + @PostMapping("/queryAreas") + @Log("查询所有区域") + @ApiOperation("查询所有区域") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity queryAreas() { + return new ResponseEntity<>(pdaService.queryAreas(), HttpStatus.OK); + } + + @PostMapping("/queryMaterials/{material_type}") + @Log("查询物料类型") + @ApiOperation("查询物料类型") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity queryMaterials(@RequestParam String material_type) { + return new ResponseEntity<>(pdaService.queryMaterials(material_type), HttpStatus.OK); + } + + @PostMapping("/callTask") + @Log("一体机创建任务") + @ApiOperation("一体机创建任务") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity callTask(@RequestBody HeadDto dto) { + return new ResponseEntity<>(pdaService.callTask(dto), HttpStatus.OK); + } + + @PostMapping("/areaControl") + @Log(value = "区域控制") + @ApiOperation("区域控制") + @SaIgnore + public ResponseEntity areaControl(@RequestBody String whereJson){ + return new ResponseEntity<>(pdaService.areaControl(whereJson), HttpStatus.OK); + } + + @PostMapping("/putAction") + @Log(value = "一体机下发动作信号") + @ApiOperation("一体机下发动作信号") + @SaIgnore + public ResponseEntity putAction(@RequestBody String whereJson){ + return new ResponseEntity<>(pdaService.putAction(whereJson), HttpStatus.OK); + } + + @PostMapping("/forceFinish") + @Log("强制完成") + @ApiOperation("强制完成") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity forceFinish(@RequestBody HeadTaskDto dto) throws Exception { + return new ResponseEntity<>(pdaService.forceFinish(dto), HttpStatus.OK); + } + + @PostMapping("/queryTaskIds") + @Log("查询任务号") + @ApiOperation("查询任务号") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity queryTaskIds() throws Exception { + return new ResponseEntity<>(pdaService.queryTaskIds(), HttpStatus.OK); + } + + @PostMapping("/cancel") + @Log("取消任务") + @ApiOperation("取消任务") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity cancel(TaskIdAndStatusDTO dto) throws Exception { + return new ResponseEntity<>(pdaService.cancel(dto), HttpStatus.OK); + } + + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/HandService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/HandService.java index 2502e26..2e91628 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/HandService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/HandService.java @@ -16,7 +16,7 @@ import java.util.Map; public interface HandService { - Map queryPointByArea(String region_code); + Map queryPointByArea(String region_code); /** * 手持创建任务 diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/PdaService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/PdaService.java new file mode 100644 index 0000000..ebee1c1 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/PdaService.java @@ -0,0 +1,31 @@ +package org.nl.hand.service; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.nl.acs.task.service.dto.TaskIdAndStatusDTO; +import org.nl.hand.dto.HeadDto; +import org.nl.hand.dto.HeadTaskDto; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.Map; + +public interface PdaService { + + JSONArray queryAllPoints(); + + JSONArray queryMaterials(String code); + + Map callTask(HeadDto dto); + + Map areaControl(String whereJson); + + Map forceFinish(HeadTaskDto dto); + + JSONArray queryTaskIds(); + + Map cancel(TaskIdAndStatusDTO dto) throws Exception; + + JSONArray queryAreas(); + + Map putAction(String whereJson); +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/PdaServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/PdaServiceImpl.java new file mode 100644 index 0000000..983fdce --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/PdaServiceImpl.java @@ -0,0 +1,245 @@ +package org.nl.hand.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.region.domain.Region; +import org.nl.acs.region.service.RegionService; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.acs.task.service.dto.TaskIdAndStatusDTO; +import org.nl.common.exception.BadRequestException; +import org.nl.config.language.LangProcess; +import org.nl.hand.dto.HeadDto; +import org.nl.hand.dto.HeadTaskDto; +import org.nl.hand.service.HandService; +import org.nl.hand.service.PdaService; +import org.nl.system.service.dict.dao.Dict; +import org.nl.system.service.dict.dao.mapper.SysDictMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +@Service +@RequiredArgsConstructor +@Slf4j +public class PdaServiceImpl implements PdaService { + @Autowired + private DeviceService deviceService; + + @Autowired + private SysDictMapper sysDictMapper; + + @Autowired + DeviceAppService deviceAppService; + + @Autowired + RegionService regionService; + + @Autowired + private TaskService taskserver; + + @Override + public JSONArray queryAllPoints() { + JSONArray data = new JSONArray(); + //查询所有设备 + List list = deviceService.lambdaQuery() + .list(); + if (CollectionUtil.isEmpty(list)) { + throw new BadRequestException(LangProcess.msg("error_no_regional")); + } + JSONArray arr = JSONArray.parseArray(JSON.toJSONString(list)); + JSONArray result = new JSONArray(); + for (int i = 0; i < arr.size(); i++) { + JSONObject obj = arr.getJSONObject(i); + JSONObject json = new JSONObject(); + json.put("device_code", obj.getString("device_code")); + json.put("device_name", obj.getString("device_name")); + result.add(json); + } + return result; + } + + @Override + public JSONArray queryMaterials(String code) { + List list = sysDictMapper.selectList(new LambdaQueryWrapper() + .eq(ObjectUtil.isNotEmpty(code), Dict::getCode, code)); + if (ObjectUtil.isNotEmpty(list)) { + throw new BadRequestException(LangProcess.msg("error_checkExist",code)); + } + JSONArray arr = JSONArray.parseArray(JSON.toJSONString(list)); + JSONArray result = new JSONArray(); + for (int i = 0; i < arr.size(); i++) { + JSONObject obj = arr.getJSONObject(i); + JSONObject json = new JSONObject(); + json.put("label", obj.getString("label")); + json.put("value", obj.getString("value")); + result.add(json); + } + return result; + } + + @Override + public Map callTask(HeadDto dto) { + JSONArray errArr = new JSONArray(); + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + String material = dto.getMaterial(); + + if (StrUtil.isEmpty(start_device_code)) { + throw new BadRequestException("起点不能为空"); + } + if (StrUtil.isEmpty(next_device_code)) { + throw new BadRequestException("终点不能为空"); + } + if (StrUtil.isEmpty(material)) { + throw new BadRequestException("物料类型不能为空"); + } + + JSONObject jo = new JSONObject(); + jo.put("start_device_code", start_device_code); + jo.put("next_device_code", next_device_code); + jo.put("start_point_code", start_device_code); + jo.put("next_point_code", next_device_code); + jo.put("material", material); + jo.put("task_type", "1"); + jo.put("agv_system_type", "2"); + jo.put("priority", "1"); + + TaskDto task_dto = jo.toJavaObject(TaskDto.class); + try { + taskserver.create(task_dto); + } catch (Exception e) { +// e.printStackTrace(); + JSONObject json = new JSONObject(); + json.put("message", e.getMessage()); + errArr.add(json); + throw new RuntimeException(e.getMessage()); + } + JSONArray data = new JSONArray(); + JSONObject resultJson = new JSONObject(); + if (ObjectUtil.isEmpty(errArr)) { + resultJson.put("message", "操作成功"); + resultJson.put("data", data); + } else { + resultJson.put("message", "操作失败"); + resultJson.put("data", data); + } + return resultJson; + } + + @Override + public Map areaControl(String whereJson) { + JSONObject jsonObject = JSON.parseObject(whereJson); + JSONArray errArr = new JSONArray(); + String region_code = jsonObject.getString("region_code"); + String option = jsonObject.getString("option"); + Region region = regionService.findByCode(region_code); + region.setIs_charge(option); + regionService.updateById(region); + JSONObject resultJson = new JSONObject(); + if (ObjectUtil.isEmpty(errArr)) { + resultJson.put("status", HttpStatus.OK.value()); + resultJson.put("message", "操作成功"); + } else { + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "操作失败"); + if (ObjectUtil.isNotEmpty(errArr)) { + resultJson.put("errArr", errArr); + } + } + return resultJson; + } + + @Override + public Map forceFinish(HeadTaskDto dto) { + JSONObject resultJson = new JSONObject(); + TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO(); + taskIdAndStatusDTO.setTask_id(dto.getTask_id()); + try { + taskserver.finish(taskIdAndStatusDTO); + } catch (Exception e) { + resultJson.put("message", e.getMessage()); + return resultJson; + } + resultJson.put("message", "操作成功"); + return resultJson; + } + + @Override + public JSONArray queryTaskIds() { + //查询所有就绪或者执行中的任务 + List list = taskserver.queryAllUnfinished(); + if (CollectionUtil.isEmpty(list)) { + throw new BadRequestException(LangProcess.msg("error_no_regional")); + } + JSONArray arr = JSONArray.parseArray(JSON.toJSONString(list)); + JSONArray result = new JSONArray(); + for (int i = 0; i < arr.size(); i++) { + JSONObject obj = arr.getJSONObject(i); + JSONObject json = new JSONObject(); + json.put("task_id", obj.getString("task_id")); + result.add(json); + } + return result; + } + + @Override + public Map cancel(TaskIdAndStatusDTO dto) { + JSONObject resultJson = new JSONObject(); + try { + taskserver.cancelAndInst(dto.getTask_id()); + } catch (Exception e) { + resultJson.put("message", e.getMessage()); + return resultJson; + } + resultJson.put("message", "取消成功"); + return resultJson; + } + + @Override + public JSONArray queryAreas() { + return regionService.queryAllRegions(); + } + + @Override + public Map putAction(String whereJson) { + JSONObject jsonObject = JSON.parseObject(whereJson); + JSONArray errArr = new JSONArray(); + String device_code = jsonObject.getString("device_code"); + String option = jsonObject.getString("option"); + StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + Device device_k = deviceAppService.findDeviceByCode(device_code); + if (device_k.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device_k.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option)); + } + JSONObject resultJson = new JSONObject(); + if (ObjectUtil.isEmpty(errArr)) { + resultJson.put("status", HttpStatus.OK.value()); + resultJson.put("message", "操作成功"); + } else { + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "操作失败"); + if (ObjectUtil.isNotEmpty(errArr)) { + resultJson.put("errArr", errArr); + } + } + return resultJson; + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/dict/dao/mapper/SysDictMapper.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/dict/dao/mapper/SysDictMapper.java index d83ff61..22f8689 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/dict/dao/mapper/SysDictMapper.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/dict/dao/mapper/SysDictMapper.java @@ -1,5 +1,6 @@ package org.nl.system.service.dict.dao.mapper; +import org.apache.ibatis.annotations.Mapper; import org.nl.system.service.dict.dao.Dict; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author generator * @since 2022-12-14 */ +@Mapper public interface SysDictMapper extends BaseMapper { }