fix: CustomPolicy

This commit is contained in:
2023-12-06 17:10:28 +08:00
parent d45e352ce2
commit 4d339161b7
16 changed files with 114 additions and 74 deletions

View File

@@ -39,60 +39,14 @@ public class AbstractDriverService<T> implements IDriverService {
}
public JSONObject getCommonDeviceInfo(T t) {
JSONObject map = new JSONObject();
try {
Class<?> tClass = t.getClass();
Method methodMode = tClass.getMethod("getMode");
Method methodMove = tClass.getMethod("getMove");
Integer mode = (Integer) methodMode.invoke(t);
Integer move = (Integer) methodMove.invoke(t);
/* map.put("move",StageActorUtil.getMove(move));
map.put("hasGoods",StageActorUtil.getHasGoods(move));
map.put("mode",StageActorUtil.getMode(mode));
map.put("isOnline",StageActorUtil.getIsOnline(mode));*/
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return map;
}
public JSONObject getCommonDeviceInfo(T t, int i) {
JSONObject map = new JSONObject();
try {
Class<?> tClass = t.getClass();
Method methodMode = tClass.getMethod("getMode");
Integer mode = (Integer) methodMode.invoke(t);
/* map.put("mode",StageActorUtil.getMode(mode));
map.put("isOnline",StageActorUtil.getIsOnline(mode));*/
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return map;
}
public JSONObject getCommonDeviceInfo(T t, int i, int j) {
JSONObject map = new JSONObject();
try {
Class<?> tClass = t.getClass();
Method methodMode = tClass.getMethod("getMode");
Method methodMove = tClass.getMethod("getMove");
Method methodGetHasGoods = tClass.getMethod("getHasGoods");
Method methodGetIsonline = tClass.getMethod("getIsonline");
Integer mode = (Integer) methodMode.invoke(t);
Integer move = (Integer) methodMove.invoke(t);
Integer hasGoods = (Integer) methodGetHasGoods.invoke(t);
Boolean isOnline = (Boolean) methodGetIsonline.invoke(t);
/* map.put("mode",StageActorUtil.getMode(mode,0));
map.put("move",StageActorUtil.getMove(move));*/
map.put("hasGoods", hasGoods);
map.put("isOnline", isOnline);
} catch (NoSuchMethodException e) {

View File

@@ -14,7 +14,10 @@ public interface IDriverService {
JSONObject getDeviceInfo(Device device);
/**
* 获取db值
* getDbValue
* @param device
* @param dbName
* @return
*/
Integer getDbValue(Device device, String dbName);
}

View File

@@ -16,7 +16,6 @@ public class StandardOrdinarySiteDevice extends AbstractDriverService {
public JSONObject getDeviceInfo(Device device) {
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
JSONObject jo = new JSONObject();
// jo.put("move", StageActorUtil.getMove(standardOrdinarySiteDeviceDriver.getHasGoods()));
jo.put("container", standardOrdinarySiteDeviceDriver.getContainer());
jo.put("hasGoods", standardOrdinarySiteDeviceDriver.getHasGoods());
jo.put("isOnline", true);

View File

@@ -16,18 +16,35 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CommonMapper<E> extends BaseMapper<E> {
/**
* 查询
* @return
*/
default QueryChainWrapper<E> query() {
return ChainWrappers.queryChain(this);
}
/**
* lambdaQuery
* @return
*/
default LambdaQueryChainWrapper<E> lambdaQuery() {
return ChainWrappers.lambdaQueryChain(this);
}
/**
* 更新
* @return
*/
default UpdateChainWrapper<E> update() {
return ChainWrappers.updateChain(this);
}
/**
* lambdaUpdate
* @return
*/
default LambdaUpdateChainWrapper<E> lambdaUpdate() {
return ChainWrappers.lambdaUpdateChain(this);
}

View File

@@ -20,7 +20,13 @@ import java.util.List;
@Slf4j
public class QueryHelpMybatisPlus {
// TODO DataPermission
/**
*
* @param query
* @param <R>
* @param <Q>
* @return
*/
public static <R, Q> QueryWrapper<R> getPredicate(Q query) {
QueryWrapper<R> queryWrapper = new QueryWrapper<>();
if (query == null) {
@@ -47,7 +53,6 @@ public class QueryHelpMybatisPlus {
// 模糊多字段
if (ObjectUtil.isNotEmpty(blurry)) {
String[] blurrys = blurry.split(",");
//queryWrapper.or();
queryWrapper.and(wrapper -> {
for (String blurry1 : blurrys) {
String column = humpToUnderline(blurry1);
@@ -62,7 +67,6 @@ public class QueryHelpMybatisPlus {
String finalAttributeName = attributeName;
switch (q.type()) {
case EQUAL:
//queryWrapper.and(wrapper -> wrapper.eq(finalAttributeName, val));
queryWrapper.eq(attributeName, val);
break;
case GREATER_THAN:
@@ -88,11 +92,6 @@ public class QueryHelpMybatisPlus {
queryWrapper.in(finalAttributeName, (Collection<Long>) val);
}
break;
// case NOT_IN:
// if (CollUtil.isNotEmpty((Collection<Long>) val)) {
// queryWrapper.notIn(finalAttributeName, (Collection<Long>) val);
// }
// break;
case NOT_EQUAL:
queryWrapper.ne(finalAttributeName, val);
break;

View File

@@ -16,16 +16,18 @@ public class DequeCustomerDeviceStrategy implements DeviceStrategy {
public DequeCustomerDeviceStrategy() {
}
@Override
public String getCode() {
return DequeCustomerDeviceStrategy.class.getSimpleName();
}
@Override
public String getName() {
return "自定义队列策略";
}
@Override
public WaitingInstructionDeque strategy(List<Instruction> instructions, String device_code) {
//WaitingInstructionDeque deque = this.instructionService.findWaitingInstructionDequeByDeviceCode(device_code);
System.out.println("自定义队列策略");
Map<String, List<Instruction>> factory = new HashMap();
@@ -45,14 +47,12 @@ public class DequeCustomerDeviceStrategy implements DeviceStrategy {
List<String> sort_keys = new LinkedList();
sort_keys.addAll(keys);
Collections.sort(sort_keys);
// SortUtlEx.sort(sort_keys, this.comparator);
Iterator var12 = sort_keys.iterator();
while (var12.hasNext()) {
String string = (String) var12.next();
List<Instruction> list2 = (List) factory.get(string);
if (list2 != null && list2.size() > 0) {
//deque.offerIfNotExists((Instruction)list2.get(0));
}
}

View File

@@ -17,16 +17,18 @@ public class DequeDefaultDeviceStrategy implements DeviceStrategy {
public DequeDefaultDeviceStrategy() {
}
@Override
public String getCode() {
return DequeDefaultDeviceStrategy.class.getSimpleName();
}
@Override
public String getName() {
return "默认队列策略";
}
@Override
public WaitingInstructionDeque strategy(List<Instruction> instructions, String device_code) {
//WaitingInstructionDeque deque = this.instructionService.findWaitingInstructionDequeByDeviceCode(device_code);
System.out.println("默认队列策略");
Map<String, List<Instruction>> factory = new HashMap();
@@ -46,14 +48,12 @@ public class DequeDefaultDeviceStrategy implements DeviceStrategy {
List<String> sort_keys = new LinkedList();
sort_keys.addAll(keys);
Collections.sort(sort_keys);
// SortUtlEx.sort(sort_keys, this.comparator);
Iterator var12 = sort_keys.iterator();
while (var12.hasNext()) {
String string = (String) var12.next();
List<Instruction> list2 = (List) factory.get(string);
if (list2 != null && list2.size() > 0) {
//deque.offerIfNotExists((Instruction)list2.get(0));
}
}

View File

@@ -5,10 +5,24 @@ import org.nl.acs.instruction.domain.Instruction;
import java.util.List;
public interface DeviceStrategy {
/**
* 获取名称
* @return
*/
String getName();
/**
* 获取Code
* @return
*/
String getCode();
/**
* 策略
* @param instructions
* @param device_code
* @return
*/
default WaitingInstructionDeque strategy(List<Instruction> instructions, String device_code) {
throw new RuntimeException("未实现");
}

View File

@@ -5,9 +5,13 @@ import java.util.List;
public class StackerStrategyDto {
private String deviceCode;
//策略
/**
* 策略
*/
private List<StackerInstruction> plan = new ArrayList();
//禁止策略 暂时未开发
/**
* 禁止策略 暂时未开发
*/
private List<StackerInstruction> forbid = new ArrayList();
public StackerStrategyDto() {

View File

@@ -16,16 +16,18 @@ public class StockinFirstDeviceStrategy implements DeviceStrategy {
public StockinFirstDeviceStrategy() {
}
@Override
public String getCode() {
return StockinFirstDeviceStrategy.class.getSimpleName();
}
@Override
public String getName() {
return "入库优先策略";
}
@Override
public WaitingInstructionDeque strategy(List<Instruction> instructions, String device_code) {
//WaitingInstructionDeque deque = this.instructionService.findWaitingInstructionDequeByDeviceCode(device_code);
System.out.println("入库优先策略");
Map<String, List<Instruction>> factory = new HashMap();
@@ -45,14 +47,12 @@ public class StockinFirstDeviceStrategy implements DeviceStrategy {
List<String> sort_keys = new LinkedList();
sort_keys.addAll(keys);
Collections.sort(sort_keys);
// SortUtlEx.sort(sort_keys, this.comparator);
Iterator var12 = sort_keys.iterator();
while (var12.hasNext()) {
String string = (String) var12.next();
List<Instruction> list2 = (List) factory.get(string);
if (list2 != null && list2.size() > 0) {
//deque.offerIfNotExists((Instruction)list2.get(0));
}
}

View File

@@ -16,16 +16,18 @@ public class StockoutFirstDeviceStrategy implements DeviceStrategy {
public StockoutFirstDeviceStrategy() {
}
@Override
public String getCode() {
return StockoutFirstDeviceStrategy.class.getSimpleName();
}
@Override
public String getName() {
return "出库优先策略";
}
@Override
public WaitingInstructionDeque strategy(List<Instruction> instructions, String device_code) {
//WaitingInstructionDeque deque = this.instructionService.findWaitingInstructionDequeByDeviceCode(device_code);
System.out.println("出库优先策略");
Map<String, List<Instruction>> factory = new HashMap();
@@ -45,14 +47,12 @@ public class StockoutFirstDeviceStrategy implements DeviceStrategy {
List<String> sort_keys = new LinkedList();
sort_keys.addAll(keys);
Collections.sort(sort_keys);
// SortUtlEx.sort(sort_keys, this.comparator);
Iterator var12 = sort_keys.iterator();
while (var12.hasNext()) {
String string = (String) var12.next();
List<Instruction> list2 = (List) factory.get(string);
if (list2 != null && list2.size() > 0) {
//deque.offerIfNotExists((Instruction)list2.get(0));
}
}

View File

@@ -77,8 +77,8 @@ public class CustomPolicyController {
}
@GetMapping("/updateOn")
@Log("自定义策略列表")
@ApiOperation("自定义策略列表")
@Log("是否启用")
@ApiOperation("是否启用")
public ResponseEntity<Object> updateOn(@RequestParam Long id, @RequestParam Integer is_on) {
customPolicyService.updateOn(id, is_on);
return new ResponseEntity<>(HttpStatus.OK);

View File

@@ -17,21 +17,56 @@ import java.util.Map;
*/
public interface CustomPolicyService extends CommonService<CustomPolicy> {
/**
* 分页查询
* @param whereJson
* @param page
* @return
*/
PageInfo<CustomPolicyDTO> queryAll(Map whereJson, Pageable page);
/**
* 新增
* @param dto
*/
void create(CustomPolicyDTO dto);
/**
* 更新
* @param dto
*/
void update(CustomPolicyDTO dto);
/**
* 删除
* @param ids
*/
void deleteAll(String[] ids);
/**
* 新增自定义策略
* @param customPolicyPlantVO
*/
void createPlant(CustomPolicyPlantVO customPolicyPlantVO);
/**
* 自定义策略列表
* @param id
* @return
*/
CustomPolicyPlantVO plantList(Long id);
/**
* 是否启用
* @param id
* @param is_on
*/
void updateOn(Long id, Integer is_on);
DeviceStrategy findByCode(String var1);
/**
* 获取设备策略
* @return
*/
List<Map> findDeviceStrategyOption();
}

View File

@@ -7,11 +7,21 @@ 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;

View File

@@ -143,7 +143,7 @@ public class CustomPolicyServiceImpl extends CommonServiceImpl<CustomPolicyMappe
customPolicyMapper.updateById(customPolicy);
}
@Override
public DeviceStrategy findByCode(String code) {
List<DeviceStrategy> strategys = this.findAllDeviceStrategy();
Iterator var3 = strategys.iterator();
@@ -160,6 +160,7 @@ public class CustomPolicyServiceImpl extends CommonServiceImpl<CustomPolicyMappe
return i;
}
@Override
public List<Map> findDeviceStrategyOption() {
List<DeviceStrategy> strategys = this.findAllDeviceStrategy();
List<Map> strings = new ArrayList<>();

View File

@@ -16,5 +16,9 @@ import java.util.Set;
@Repository
public interface CustomPolicyMapper extends CommonMapper<CustomPolicy> {
/**
* 批量更新
* @param idsSet
*/
void upBatchIds(@Param("ids") Set<String> idsSet);
}