自定义策略开发
This commit is contained in:
@@ -401,11 +401,23 @@
|
||||
<groupId>org.openscada.jinterop</groupId>
|
||||
<artifactId>org.openscada.jinterop.core</artifactId>
|
||||
<version>2.1.8</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openscada.jinterop</groupId>
|
||||
<artifactId>org.openscada.jinterop.deps</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openscada.utgard</groupId>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.nl.acs.custompolicy.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author jiaolm
|
||||
* @date 2023-05-10
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CustomPolicy implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "策略")
|
||||
private String key_value;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "设备号")
|
||||
private String key_code;
|
||||
|
||||
@ApiModelProperty(value = "策略名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "创建用户名")
|
||||
private String create_user;
|
||||
|
||||
@ApiModelProperty(value = "修改用户名")
|
||||
private String update_user;
|
||||
|
||||
@ApiModelProperty(value = "是否开启")
|
||||
private Integer is_on;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
private String is_delete;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.nl.acs.custompolicy.rest;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.address.service.dto.AddressDto;
|
||||
import org.nl.acs.agv.server.MagicAgvService;
|
||||
import org.nl.acs.custompolicy.server.CustomPolicyService;
|
||||
import org.nl.acs.custompolicy.server.dto.CustomPolicyDTO;
|
||||
import org.nl.acs.custompolicy.server.vo.CustomPolicyPlantVO;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "堆垛机自定义策略")
|
||||
@RequestMapping("/api/customPolicy")
|
||||
@Slf4j
|
||||
public class CustomPolicyController {
|
||||
@Autowired
|
||||
private CustomPolicyService customPolicyService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询自定义策略")
|
||||
@ApiOperation("查询自定义策略")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(customPolicyService.queryAll(whereJson,page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增自定义策略基础信息")
|
||||
@ApiOperation("新增自定义策略基础信息")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody CustomPolicyDTO dto) {
|
||||
customPolicyService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改自定义策略")
|
||||
@ApiOperation("修改自定义策略")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody CustomPolicyDTO dto) {
|
||||
customPolicyService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除自定义策略")
|
||||
@ApiOperation("删除自定义策略")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
customPolicyService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/plantAdd")
|
||||
@Log("新增自定义策略")
|
||||
@ApiOperation("新增自定义策略")
|
||||
public ResponseEntity<Object> createPlant(@RequestBody CustomPolicyPlantVO customPolicyPlantVO) {
|
||||
customPolicyService.createPlant(customPolicyPlantVO);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@GetMapping("/plantList")
|
||||
@Log("自定义策略列表")
|
||||
@ApiOperation("自定义策略列表")
|
||||
public ResponseEntity<Object> plantList(@RequestParam Long id) {
|
||||
return new ResponseEntity<>(customPolicyService.plantList(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/updateOn")
|
||||
@Log("自定义策略列表")
|
||||
@ApiOperation("自定义策略列表")
|
||||
public ResponseEntity<Object> updateOn(@RequestParam Long id,@RequestParam Integer is_on) {
|
||||
customPolicyService.updateOn(id,is_on);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.nl.acs.custompolicy.server;
|
||||
|
||||
import org.nl.acs.common.base.CommonService;
|
||||
import org.nl.acs.common.base.PageInfo;
|
||||
import org.nl.acs.custompolicy.domain.CustomPolicy;
|
||||
import org.nl.acs.custompolicy.server.dto.CustomPolicyDTO;
|
||||
import org.nl.acs.custompolicy.server.vo.CustomPolicyPlantVO;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author jiaolm
|
||||
* @date 2023-05-10
|
||||
*/
|
||||
public interface CustomPolicyService extends CommonService<CustomPolicy> {
|
||||
|
||||
|
||||
PageInfo<CustomPolicyDTO> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
void create(CustomPolicyDTO dto);
|
||||
|
||||
void update(CustomPolicyDTO dto);
|
||||
|
||||
void deleteAll(String[] ids);
|
||||
|
||||
void createPlant(CustomPolicyPlantVO customPolicyPlantVO);
|
||||
|
||||
CustomPolicyPlantVO plantList(Long id);
|
||||
|
||||
void updateOn(Long id,Integer is_on);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.nl.acs.custompolicy.server.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author jiaolm
|
||||
* @date 2023-05-10
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CustomPolicyDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "策略")
|
||||
private String key_value;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "设备号")
|
||||
@NotBlank
|
||||
private String key_code;
|
||||
|
||||
@ApiModelProperty(value = "策略名称")
|
||||
@NotBlank
|
||||
private String name;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "创建用户名")
|
||||
private String create_user;
|
||||
|
||||
@ApiModelProperty(value = "修改用户名")
|
||||
private String update_user;
|
||||
|
||||
@ApiModelProperty(value = "是否开启")
|
||||
private Integer is_on;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
private String is_delete;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @author ls
|
||||
* @date 2023/11/21 14:19
|
||||
*/
|
||||
package org.nl.acs.custompolicy.server.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CustomPolicyPlantDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "任务类型")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "起始设备")
|
||||
private Integer from;
|
||||
@ApiModelProperty(value = "目标设备")
|
||||
private Integer to;
|
||||
@ApiModelProperty(value = "数量")
|
||||
private Integer quantity;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @author ls
|
||||
* @date 2023/11/20 13:33
|
||||
*/
|
||||
package org.nl.acs.custompolicy.server.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CustomPolicyTaskTypeEnum {
|
||||
IN(1,"入库"),
|
||||
OUT(2,"出库"),
|
||||
MOVE(3,"移库");
|
||||
|
||||
Integer code;
|
||||
String status;
|
||||
|
||||
public static String getStatus(Integer code){
|
||||
for (CustomPolicyTaskTypeEnum value : values()) {
|
||||
if (value.code.equals(code)) {
|
||||
return value.status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package org.nl.acs.custompolicy.server.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import jodd.util.StringUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import org.nl.acs.common.base.PageInfo;
|
||||
import org.nl.acs.common.base.impl.CommonServiceImpl;
|
||||
import org.nl.acs.custompolicy.domain.CustomPolicy;
|
||||
import org.nl.acs.custompolicy.server.CustomPolicyService;
|
||||
import org.nl.acs.custompolicy.server.dto.CustomPolicyDTO;
|
||||
import org.nl.acs.custompolicy.server.dto.CustomPolicyPlantDTO;
|
||||
import org.nl.acs.custompolicy.server.mapper.CustomPolicyMapper;
|
||||
import org.nl.acs.custompolicy.server.vo.CustomPolicyPlantVO;
|
||||
import org.nl.acs.utils.ConvertUtil;
|
||||
import org.nl.acs.utils.PageUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author jiaolm
|
||||
* @date 2023-05-10
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class CustomPolicyServiceImpl extends CommonServiceImpl<CustomPolicyMapper, CustomPolicy> implements CustomPolicyService {
|
||||
|
||||
private final CustomPolicyMapper customPolicyMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<CustomPolicyDTO> queryAll(Map whereJson, Pageable page) {
|
||||
IPage<CustomPolicy> queryPage = PageUtil.toMybatisPage(page);
|
||||
LambdaQueryWrapper<CustomPolicy> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CustomPolicy::getIs_delete,0) ;
|
||||
IPage<CustomPolicy> customPolicyIPage = customPolicyMapper.selectPage(queryPage,wrapper);
|
||||
PageInfo<CustomPolicyDTO> customPolicyDTOPageInfo = ConvertUtil.convertPage(customPolicyIPage, CustomPolicyDTO.class);
|
||||
return customPolicyDTOPageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(CustomPolicyDTO dto) {
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
Date now = new Date();
|
||||
dto.setCreate_user(currentUsername);
|
||||
dto.setCreate_time(now);
|
||||
customPolicyMapper.insert( ConvertUtil.convert(dto,CustomPolicy.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(CustomPolicyDTO dto) {
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
Date now = new Date();
|
||||
dto.setUpdate_user(currentUsername);
|
||||
dto.setUpdate_time(now);
|
||||
CustomPolicy customPolicy = ConvertUtil.convert(dto, CustomPolicy.class);
|
||||
customPolicyMapper.updateById(customPolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(String[] ids) {
|
||||
Set<String> idsSet = new HashSet<>(1);
|
||||
idsSet.addAll(Arrays.asList(ids));
|
||||
customPolicyMapper.upBatchIds(idsSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPlant(CustomPolicyPlantVO customPolicyPlantVO) {
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
CustomPolicy customPolicy = new CustomPolicy();
|
||||
Date now = new Date();
|
||||
customPolicy.setId(customPolicyPlantVO.getId());
|
||||
customPolicy.setUpdate_user(currentUsername);
|
||||
customPolicy.setUpdate_time(now);
|
||||
customPolicy.setKey_value(JSON.toJSONString(customPolicyPlantVO));
|
||||
customPolicyMapper.updateById(customPolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPolicyPlantVO plantList(Long id) {
|
||||
CustomPolicy customPolicy = customPolicyMapper.selectById(id);
|
||||
if (BeanUtil.isNotEmpty(customPolicy) && StringUtil.isNotEmpty(customPolicy.getKey_value())) {
|
||||
return JSON.parseObject(customPolicy.getKey_value(), CustomPolicyPlantVO.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOn(Long id, Integer is_on) {
|
||||
CustomPolicy customPolicy = new CustomPolicy();
|
||||
customPolicy.setId(id);
|
||||
customPolicy.setIs_on(is_on);
|
||||
customPolicyMapper.updateById(customPolicy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.acs.custompolicy.server.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.acs.address.domain.Address;
|
||||
import org.nl.acs.common.base.CommonMapper;
|
||||
import org.nl.acs.custompolicy.domain.CustomPolicy;
|
||||
import org.nl.acs.custompolicy.server.dto.CustomPolicyDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author jiaolm
|
||||
* @date 2023-05-10
|
||||
*/
|
||||
@Repository
|
||||
public interface CustomPolicyMapper extends CommonMapper<CustomPolicy> {
|
||||
|
||||
void upBatchIds(@Param("ids") Set<String> idsSet);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.acs.custompolicy.server.mapper.CustomPolicyMapper">
|
||||
<update id="upBatchIds" parameterType="java.lang.String">
|
||||
update custom_policy set is_delete =1 where id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @author ls
|
||||
* @date 2023/11/21 14:22
|
||||
*/
|
||||
package org.nl.acs.custompolicy.server.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nl.acs.custompolicy.server.dto.CustomPolicyPlantDTO;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CustomPolicyPlantVO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty(value = "id")
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "设备号")
|
||||
private String deviceCode;
|
||||
@ApiModelProperty(value = "策略")
|
||||
private List<CustomPolicyPlantDTO> plans;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ spring:
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
username: ${DB_USER:root}
|
||||
# password: ${DB_PWD:Root.123456}
|
||||
password: ${DB_PWD:123456}
|
||||
password: ${DB_PWD:root}
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
# 最小连接数
|
||||
|
||||
Reference in New Issue
Block a user