代码更新
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package org.nl;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
|
||||
import com.alicp.jetcache.anno.config.EnableMethodCache;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.nl.annotation.rest.AnonymousGetMapping;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
@@ -34,13 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@ServletComponentScan
|
||||
@EnableTransactionManagement
|
||||
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
|
||||
|
||||
@EnableMethodCache(basePackages = "org.nl")
|
||||
@EnableCreateCacheAnnotation
|
||||
public class AppRun implements CommandLineRunner {
|
||||
|
||||
private Cache<String, Object> userCache;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(AppRun.class, args);
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import com.alicp.jetcache.anno.CreateCache;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BothCacheManager extends NlCacheManager {
|
||||
/**
|
||||
* 使用 @CreateCache 注解创建Cache实例;
|
||||
* 未定义默认值的参数,将使用yml中指定的全局配置;
|
||||
* 缓存在 Local,也可以配置成 both 开启两级缓存
|
||||
*/
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.BOTH, localLimit = 10)
|
||||
private Cache<Object, Object> defaultCache;
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.BOTH, localLimit = 10)
|
||||
private Cache<Object, Object> systemCache;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.anno.CacheConsts;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class CacheConfig {
|
||||
@Value("${jetcache.defaultCacheType}")
|
||||
private String cacheType;
|
||||
|
||||
@Bean(name = "sysCacheManager")
|
||||
public NlCacheManager sysCacheManager() {
|
||||
CacheConsts.isUndefined(2);
|
||||
if (CacheType.BOTH.name().equals(cacheType)) return new BothCacheManager();
|
||||
if (CacheType.LOCAL.name().equals(cacheType)) return new LocalCacheManager();
|
||||
if (CacheType.REMOTE.name().equals(cacheType)) return new RemoteCacheManager();
|
||||
return new LocalCacheManager();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import com.alicp.jetcache.anno.CreateCache;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LocalCacheManager extends NlCacheManager {
|
||||
/**
|
||||
* 使用 @CreateCache 注解创建Cache实例;
|
||||
* 未定义默认值的参数,将使用yml中指定的全局配置;
|
||||
* 缓存在 Local,也可以配置成 both 开启两级缓存
|
||||
*/
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.LOCAL, localLimit = 10)
|
||||
private Cache<Object, Object> defaultCache;
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.LOCAL, localLimit = 10)
|
||||
private Cache<Object, Object> systemCache;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public abstract class NlCacheManager {
|
||||
private Cache<Object, Object> defaultCache;
|
||||
private Cache<Object, Object> systemCache;
|
||||
public void test(){
|
||||
System.out.println(this.getClass().getName());
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import com.alicp.jetcache.anno.CreateCache;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RemoteCacheManager extends NlCacheManager {
|
||||
/**
|
||||
* 使用 @CreateCache 注解创建Cache实例;
|
||||
* 未定义默认值的参数,将使用yml中指定的全局配置;
|
||||
* 缓存在 Local,也可以配置成 both 开启两级缓存
|
||||
*/
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.REMOTE, localLimit = 10)
|
||||
private Cache<Object, Object> defaultCache;
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.REMOTE, localLimit = 10)
|
||||
private Cache<Object, Object> systemCache;
|
||||
|
||||
@Override
|
||||
public void test() {
|
||||
System.out.println(this.getClass().getName());
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package org.nl.modules.log;
|
||||
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import org.bson.Document;
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* https://www.cnblogs.com/lzghyh/p/14913230.html
|
||||
* https://juejin.cn/post/6844903488896385037
|
||||
* https://cloud.tencent.com/developer/article/1384035
|
||||
* https://www.freesion.com/article/229560377/
|
||||
*/
|
||||
public class MongoDBAppender extends MongoDBAppenderBase<ILoggingEvent> {
|
||||
public MongoDBAppender() {
|
||||
super("loggingEvents");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Document toMongoDocument(ILoggingEvent eventObject) {
|
||||
final Document doc = new Document();
|
||||
doc.append("date", DateUtil.now());
|
||||
doc.append("source", source);
|
||||
|
||||
Marker marker = eventObject.getMarker();
|
||||
if (ObjectUtil.isEmpty(marker)) {
|
||||
doc.append("marker", "root");
|
||||
} else {
|
||||
doc.append("marker", marker.getName());
|
||||
}
|
||||
|
||||
doc.append("level", eventObject.getLevel().toString());
|
||||
doc.append("logger", eventObject.getLoggerName());
|
||||
doc.append("thread", eventObject.getThreadName());
|
||||
doc.append("message", eventObject.getFormattedMessage());
|
||||
if (eventObject.getMDCPropertyMap() != null && !eventObject.getMDCPropertyMap().isEmpty())
|
||||
doc.append("mdc", eventObject.getMDCPropertyMap());
|
||||
// ...
|
||||
return doc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package org.nl.modules.log;
|
||||
|
||||
import ch.qos.logback.core.UnsynchronizedAppenderBase;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoClientOptions;
|
||||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import lombok.Data;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* MongoDBAppender适配类
|
||||
*/
|
||||
@Data
|
||||
public abstract class MongoDBAppenderBase<E> extends UnsynchronizedAppenderBase<E> {
|
||||
private MongoClient mongo;
|
||||
private MongoCollection<Document> eventsCollection;
|
||||
|
||||
private String host = "10.10.8.10"; // 地址
|
||||
private int port = 27017; // 端口号
|
||||
private String dbName = "db"; // 库名
|
||||
private String collectionName; // 集合名
|
||||
private String username; // 用户名
|
||||
private String password; // 密码
|
||||
protected String source;
|
||||
|
||||
private int connectionsPerHost = 10; // 空闲线程池中最大链接数
|
||||
private int threadsAllowedToBlockForConnectionMultiplier = 5; //一个线程等待链接可用的最大等待毫秒数
|
||||
private int maxWaitTime = 1000 * 60 * 2; // 最长等待时间
|
||||
private int connectTimeout;
|
||||
private int socketTimeout;
|
||||
private int wtimeout;
|
||||
|
||||
MongoDBAppenderBase(String collectionName) {
|
||||
this.collectionName = collectionName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
/*try {
|
||||
connectToMongoDB();
|
||||
super.start();
|
||||
} catch (UnknownHostException e) {
|
||||
addError( "Error connecting to MongoDB server: " + host + ":" + port,
|
||||
e);
|
||||
}*/
|
||||
}
|
||||
|
||||
private void connectToMongoDB() throws UnknownHostException {
|
||||
// 用户名 数据库 密码
|
||||
if (username != null && password != null){
|
||||
|
||||
MongoCredential credential = MongoCredential.createCredential(
|
||||
username, dbName, password.toCharArray());
|
||||
|
||||
ServerAddress serverAddress = new ServerAddress(host, port);
|
||||
mongo = new MongoClient(serverAddress, Collections.singletonList(credential),buildOptions());
|
||||
System.out.println();
|
||||
|
||||
/* MongoCredential credential = MongoCredential.createCredential(username, dbName, password.toCharArray());
|
||||
mongo = new MongoClient(new ServerAddress(host, port), Collections.singletonList(credential), buildOptions());*/
|
||||
}else{
|
||||
mongo = new MongoClient(new ServerAddress(host, port), buildOptions());
|
||||
}
|
||||
|
||||
MongoDatabase db = mongo.getDatabase(dbName);
|
||||
eventsCollection = db.getCollection(collectionName);
|
||||
|
||||
}
|
||||
|
||||
private MongoClientOptions buildOptions() {
|
||||
final MongoClientOptions.Builder options = new MongoClientOptions.Builder();
|
||||
options.connectionsPerHost(connectionsPerHost) ;
|
||||
options.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier) ;
|
||||
options.maxWaitTime(maxWaitTime) ;
|
||||
options.connectTimeout(connectTimeout) ;
|
||||
options.socketTimeout(socketTimeout) ;
|
||||
options.maxWaitTime(wtimeout) ;
|
||||
return options.build();
|
||||
}
|
||||
|
||||
protected abstract Document toMongoDocument(E event);
|
||||
|
||||
@Override
|
||||
protected void append(E eventObject) {
|
||||
eventsCollection.insertOne(toMongoDocument(eventObject));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (mongo != null)
|
||||
mongo.close();
|
||||
super.stop();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
|
||||
package org.nl.modules.log.rest;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.annotation.Log;
|
||||
import org.nl.modules.log.service.RootLogService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @date 2021-08-19
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "系统日志")
|
||||
@RequestMapping("/api/rootLog")
|
||||
@Slf4j
|
||||
public class RootLogController {
|
||||
|
||||
private final RootLogService rootLogService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询系统日志")
|
||||
@ApiOperation("查询系统日志")
|
||||
//@PreAuthorize("@el.check('point:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(rootLogService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.nl.modules.log.service;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统日志查询
|
||||
*/
|
||||
public interface RootLogService {
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(Map whereJson, Pageable page);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package org.nl.modules.log.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.log.service.RootLogService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @description 服务实现
|
||||
* @date 2021-08-19
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class RootLogServiceImpl implements RootLogService {
|
||||
|
||||
private final MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
//查询条件
|
||||
Query query = Query.query(Criteria.where("level").is("INFO"));
|
||||
|
||||
//根据条件得到的总条数
|
||||
long totalSize = mongoTemplate.count(query, Map.class, "log_root");
|
||||
|
||||
//处理分页
|
||||
query.skip(page.getPageNumber()).limit(page.getPageSize());
|
||||
List<Map> list = mongoTemplate.find(query, Map.class, "log_root");
|
||||
|
||||
//封装前端分页查询结果
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("content", list);
|
||||
result.put("totalElements", totalSize);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,6 @@ package org.nl.modules.security.rest;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alicp.jetcache.Cache;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import com.alicp.jetcache.anno.CreateCache;
|
||||
import com.wf.captcha.base.Captcha;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -78,20 +75,15 @@ public class AuthorizationController {
|
||||
private LoginProperties loginProperties;
|
||||
|
||||
|
||||
@CreateCache(cacheType = CacheType.LOCAL)
|
||||
private Cache<String, Object> authCache;
|
||||
|
||||
@ApiOperation("登录授权")
|
||||
@AnonymousPostMapping(value = "/login")
|
||||
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
|
||||
// 密码解密
|
||||
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
|
||||
// 查询验证码
|
||||
// String code = (String) redisUtils.get(authUser.getUuid());
|
||||
String code = (String) authCache.get(authUser.getUuid());
|
||||
String code = (String) redisUtils.get(authUser.getUuid());
|
||||
// 清除验证码
|
||||
// redisUtils.del(authUser.getUuid());
|
||||
authCache.remove(authUser.getUuid());
|
||||
redisUtils.del(authUser.getUuid());
|
||||
if (StrUtil.isEmpty(code)) {
|
||||
throw new BadRequestException("验证码不存在或已过期");
|
||||
}
|
||||
@@ -137,8 +129,7 @@ public class AuthorizationController {
|
||||
captchaValue = captchaValue.split("\\.")[0];
|
||||
}
|
||||
// 保存
|
||||
// redisUtils.set(uuid, captchaValue, loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES);
|
||||
authCache.put(uuid, captchaValue, loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES);
|
||||
redisUtils.set(uuid, captchaValue, loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES);
|
||||
// 验证码信息
|
||||
Map<String, Object> imgResult = new HashMap<String, Object>(2) {{
|
||||
put("img", captcha.toBase64());
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package org.nl.wms.buss.service;
|
||||
|
||||
/**
|
||||
* 窑业务,主要包含入窑和出窑业务
|
||||
*/
|
||||
public interface KilnBuss {
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package org.nl.wms.buss.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* 混碾工序业务,主要包含混砂下料和混砂补空盅功能
|
||||
*/
|
||||
public interface MixBuss {
|
||||
/**
|
||||
* 满料请求参数
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void sendMaterial(JSONObject param);
|
||||
|
||||
void sendMaterialUpdateTaskStatus(JSONObject param);
|
||||
|
||||
/**
|
||||
* 呼叫空盅业务
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void callEmptyVehicle(JSONObject param);
|
||||
|
||||
|
||||
void callEmptyVehicleUpdateTaskStatus(JSONObject param);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package org.nl.wms.buss.service;
|
||||
|
||||
/**
|
||||
* 分拣业务,从钢托盘转换为木托的业务过程
|
||||
*/
|
||||
public interface SeparateBuss {
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package org.nl.wms.buss.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface SuppressBuss {
|
||||
/**
|
||||
* 压制叫料,从困料货架出
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void callMaterial(JSONObject param);
|
||||
|
||||
/**
|
||||
* 机械手码盘完成,送半成品
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void sendMaterial(JSONObject param);
|
||||
|
||||
/**
|
||||
* 机械手码盘缺钢托盘的时候,呼叫钢托盘请求
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void callEmptyVehicle(JSONObject param);
|
||||
|
||||
/**
|
||||
* 上料位完成以后送空载具
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void sendEmptyVehicle(JSONObject param);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package org.nl.wms.buss.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import org.nl.wms.buss.service.MixBuss;
|
||||
|
||||
/**
|
||||
* 混碾工序业务,主要包含混砂下料和混砂补空盅功能
|
||||
*/
|
||||
@Data
|
||||
public class MixBussImpl implements MixBuss {
|
||||
// 入库计量单位
|
||||
private String in_qty_unit_id = "";
|
||||
//入库重量单位
|
||||
private String in_weight_unit_id = "";
|
||||
|
||||
@Override
|
||||
public void sendMaterial(JSONObject param) {
|
||||
//1 入库单 2生成任务 (任务完成)
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMaterialUpdateTaskStatus(JSONObject param) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEmptyVehicle(JSONObject param) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void callEmptyVehicleUpdateTaskStatus(JSONObject param) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.nl.wms.buss.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.buss.service.SuppressBuss;
|
||||
|
||||
public class SuppressBussImpl implements SuppressBuss {
|
||||
@Override
|
||||
public void callMaterial(JSONObject param) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMaterial(JSONObject param) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEmptyVehicle(JSONObject param) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEmptyVehicle(JSONObject param) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
数据采集
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.nl.wms.collect.device;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public abstract class AbstractDevice {
|
||||
//设备属性
|
||||
private String device_id;
|
||||
private String device_code;
|
||||
private String device_name;
|
||||
|
||||
//工序属性
|
||||
private String workprocedure_id;
|
||||
private String workprocedure_code;
|
||||
private String workprocedure_name;
|
||||
|
||||
|
||||
public abstract void updateStatus(AbstractDevice device);
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package org.nl.wms.collect.device;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 混料设备
|
||||
*/
|
||||
@Data
|
||||
public class HLDevice extends StatusAndTimeDevice {
|
||||
//当前生产物料标识
|
||||
private String currentMaterialId;
|
||||
//当前生产数量
|
||||
private String currentProduceQty;
|
||||
//当前生产数量
|
||||
private String currentProduceWeight;
|
||||
|
||||
|
||||
@Override
|
||||
public void updateStatus(AbstractDevice device) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package org.nl.wms.collect.device;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 码盘机器人设备
|
||||
*/
|
||||
@Data
|
||||
public class MPJQRDevice {
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.nl.wms.collect.device;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 更新设备状态和对应的状态时间
|
||||
*/
|
||||
@Data
|
||||
public abstract class StatusAndTimeDevice extends AbstractDevice {
|
||||
//设备状态:生产,待机,故障,关机
|
||||
private String status;
|
||||
//待机时间、生产时间、故障时间、关机时间
|
||||
private String status_time;
|
||||
//开机时间
|
||||
private String open_time;
|
||||
|
||||
public void updateStatusAndTime() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.nl.wms.collect.device;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 压力设备
|
||||
*/
|
||||
@Data
|
||||
public class YLDevice {
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.nl.wms.collect.manage;
|
||||
|
||||
public class Context {
|
||||
private Strategy strategy;
|
||||
|
||||
public Context(Strategy strategy){
|
||||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
public int executeStrategy(int num1, int num2){
|
||||
return strategy.doOperation(num1, num2);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Context context = new Context(new OperationAdd());
|
||||
System.out.println("10 + 5 = " + context.executeStrategy(10, 5));
|
||||
|
||||
context = new Context(new OperationSubtract());
|
||||
System.out.println("10 - 5 = " + context.executeStrategy(10, 5));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package org.nl.wms.collect.manage;
|
||||
|
||||
public class OperationAdd implements Strategy{
|
||||
@Override
|
||||
public int doOperation(int num1, int num2) {
|
||||
return num1 + num2;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package org.nl.wms.collect.manage;
|
||||
|
||||
public class OperationSubtract implements Strategy{
|
||||
@Override
|
||||
public int doOperation(int num1, int num2) {
|
||||
return num1 - num2;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.nl.wms.collect.manage;
|
||||
|
||||
public interface Strategy {
|
||||
public int doOperation(int num1, int num2);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.nl.wms.collect.strategy;
|
||||
|
||||
public class BinaryObserver extends Observer{
|
||||
|
||||
public BinaryObserver(Subject subject){
|
||||
this.subject = subject;
|
||||
this.subject.attach(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
System.out.println( "Binary String: "
|
||||
+ Integer.toBinaryString( subject.getState() ) );
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.nl.wms.collect.strategy;
|
||||
|
||||
public class HexaObserver extends Observer{
|
||||
|
||||
public HexaObserver(Subject subject){
|
||||
this.subject = subject;
|
||||
this.subject.attach(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
System.out.println( "Hex String: "
|
||||
+ Integer.toHexString( subject.getState() ).toUpperCase() );
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package org.nl.wms.collect.strategy;
|
||||
|
||||
public abstract class Observer {
|
||||
protected Subject subject;
|
||||
public abstract void update();
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.nl.wms.collect.strategy;
|
||||
|
||||
public class ObserverPatternDemo {
|
||||
public static void main(String[] args) {
|
||||
Subject subject = new Subject();
|
||||
|
||||
new HexaObserver(subject);
|
||||
new OctalObserver(subject);
|
||||
new BinaryObserver(subject);
|
||||
|
||||
System.out.println("First state change: 15");
|
||||
subject.setState(15);
|
||||
System.out.println("Second state change: 10");
|
||||
subject.setState(10);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.nl.wms.collect.strategy;
|
||||
|
||||
public class OctalObserver extends Observer{
|
||||
|
||||
public OctalObserver(Subject subject){
|
||||
this.subject = subject;
|
||||
this.subject.attach(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
System.out.println( "Octal String: "
|
||||
+ Integer.toOctalString( subject.getState() ) );
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package org.nl.wms.collect.strategy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Subject {
|
||||
|
||||
private List<Observer> observers
|
||||
= new ArrayList<Observer>();
|
||||
private int state;
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
this.state = state;
|
||||
notifyAllObservers();
|
||||
}
|
||||
|
||||
public void attach(Observer observer){
|
||||
observers.add(observer);
|
||||
}
|
||||
|
||||
public void notifyAllObservers(){
|
||||
for (Observer observer : observers) {
|
||||
observer.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.utils.SecurityUtils;
|
||||
|
||||
Reference in New Issue
Block a user