Commit 615bb7f2 sunke

Merge remote-tracking branch 'origin/master'

2 个父辈 1a80e36c 553422f6
正在显示 27 个修改的文件 包含 246 行增加80 行删除
...@@ -148,4 +148,14 @@ public class Constants { ...@@ -148,4 +148,14 @@ public class Constants {
*/ */
public static final String CACHE_languageType="CACHE_languageType"; public static final String CACHE_languageType="CACHE_languageType";
/**
* 自动存档间隔Key
*/
public static final String BACKUP_MONTH_KEY = "db.backup.month";
/**
* 上次自动存档时间
*/
public static final String LAST_BACKUP_TIME_KEY = "db.backup.lastTime";
} }
...@@ -247,4 +247,8 @@ public class BarcodeDto implements Serializable { ...@@ -247,4 +247,8 @@ public class BarcodeDto implements Serializable {
@ApiModelProperty("第一次入库时间") @ApiModelProperty("第一次入库时间")
private Date firstPutInDate; private Date firstPutInDate;
@ApiModelProperty("入库时间+呆滞日期")
private Date sluggishTime;
} }
...@@ -318,7 +318,8 @@ public class Barcode extends BasePo implements Serializable { ...@@ -318,7 +318,8 @@ public class Barcode extends BasePo implements Serializable {
public void updateSluggishTime(int sluggishDay ){ public void updateSluggishTime(int sluggishDay ){
if(sluggishDay>0){ if(sluggishDay>0){
long maxTime = sluggishDay * 24 * 60 * 60 * 1000; long maxTime = sluggishDay * 24 * 60 * 60 * 1000;
setSluggishTime( new Date(putInTime + maxTime)); //使用最后一次入库时间+天数
setSluggishTime( new Date(putInDate.getTime() + maxTime));
}else{ }else{
setSluggishTime(null); setSluggishTime(null);
} }
......
...@@ -95,10 +95,6 @@ public class CodeResolve { ...@@ -95,10 +95,6 @@ public class CodeResolve {
boolean setSize=false; boolean setSize=false;
Component component = componentManager.findByPartNumberAndProvider(barcode.getPartNumber(),barcode.getProvider()); Component component = componentManager.findByPartNumberAndProvider(barcode.getPartNumber(),barcode.getProvider());
int validDay = 0; int validDay = 0;
if(defaultExpiresDay!=null&&defaultExpiresDay>0){
validDay=defaultExpiresDay;
}
if(component != null) { if(component != null) {
validDay = component.getValidDay(); validDay = component.getValidDay();
codeBeanFromRule.setShowImg(component.getShowImg()); codeBeanFromRule.setShowImg(component.getShowImg());
...@@ -122,6 +118,9 @@ public class CodeResolve { ...@@ -122,6 +118,9 @@ public class CodeResolve {
setSize = true; setSize = true;
} }
} }
if(validDay<=0&& defaultExpiresDay!=null&&defaultExpiresDay>0){
validDay=defaultExpiresDay;
}
if((!setSize)&& codeBeanFromRule.hasReelSizeInfo()){ if((!setSize)&& codeBeanFromRule.hasReelSizeInfo()){
//如果客户端传入的有尺寸,但尺寸不一致,使用上传上来的尺寸 //如果客户端传入的有尺寸,但尺寸不一致,使用上传上来的尺寸
if(barcode.getHeight() != codeBeanFromRule.getReelHeight() || barcode.getPlateSize() != codeBeanFromRule.getReelWidth()){ if(barcode.getHeight() != codeBeanFromRule.getReelHeight() || barcode.getPlateSize() != codeBeanFromRule.getReelWidth()){
...@@ -249,6 +248,9 @@ public class CodeResolve { ...@@ -249,6 +248,9 @@ public class CodeResolve {
Date produceDate = barcodeFromRule.getProduceDate(); Date produceDate = barcodeFromRule.getProduceDate();
if(produceDate != null && barcodeFromRule.getExpireDate() == null){ if(produceDate != null && barcodeFromRule.getExpireDate() == null){
int validDay = component.getValidDay(); int validDay = component.getValidDay();
if(validDay<=0&& defaultExpiresDay!=null&&defaultExpiresDay>0){
validDay=defaultExpiresDay;
}
if( validDay > 0){ if( validDay > 0){
log.info("设置"+barcodeFromRule.getBarcode()+"的过期时间"); log.info("设置"+barcodeFromRule.getBarcode()+"的过期时间");
Date expireDate = DateUtil.addDays(produceDate, validDay); Date expireDate = DateUtil.addDays(produceDate, validDay);
......
...@@ -160,7 +160,7 @@ public class BoxStatusBean { ...@@ -160,7 +160,7 @@ public class BoxStatusBean {
if (ObjectUtil.isNotEmpty(ar)) { if (ObjectUtil.isNotEmpty(ar)) {
String[] ar2 = ar.split("="); String[] ar2 = ar.split("=");
if (ar2.length == 2) { if (ar2.length == 2) {
caMap.put(ar2[0].toUpperCase(), Integer.valueOf(ar2[1])); caMap.put(ar2[0].toLowerCase(), Integer.valueOf(ar2[1]));
} }
} }
} }
......
...@@ -333,12 +333,12 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -333,12 +333,12 @@ public class BaseDeviceHandler implements IDeviceHandler {
storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds); storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds);
} else { } else {
log.info("料仓" + storageCid + "有出库任务未完成,不允许入库"); log.info("料仓" + storageCid + "有出库任务未完成,不允许入库");
throw new ValidateException("error.storage.outNotEnd", "料仓{0}有出库任务未完成,不允许入库", new String[]{storageCid}); throw new ValidateException("smfcore.error.storage.outNotEnd", "料仓{0}有出库任务未完成,不允许入库", new String[]{storageCid});
} }
} }
if (storagePos == null) { if (storagePos == null) {
throw new ValidateException("error.storage.noPos", storage.getName() + "的料格[" + barcode.getPlateSize() + "x" + barcode.getHeight() + "]已满,无法继续放入", new String[]{barcode.getPlateSize() + "x" + barcode.getHeight()}); throw new ValidateException("smfcore.error.storage.noPos", "{0}的料格[{1}]已满,无法继续放入", new String[]{ storage.getName(),barcode.getPlateSize() + "x" + barcode.getHeight()});
} }
log.info("[" + barcode.getBarcode() + "]寻找到" + storage.getName() + "的空仓位[" + storagePos.getPosName() + "]"); log.info("[" + barcode.getBarcode() + "]寻找到" + storage.getName() + "的空仓位[" + storagePos.getPosName() + "]");
return storagePos; return storagePos;
......
...@@ -11,6 +11,7 @@ import com.neotel.smfcore.core.device.enums.BOX_STATUS; ...@@ -11,6 +11,7 @@ import com.neotel.smfcore.core.device.enums.BOX_STATUS;
import com.neotel.smfcore.core.device.enums.OP; import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil; import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.storage.bean.UsageItem;
import com.neotel.smfcore.core.storage.enums.DeviceType; import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.po.Storage; import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
...@@ -92,7 +93,7 @@ public class ThirdBoxHandler extends BaseDeviceHandler{ ...@@ -92,7 +93,7 @@ public class ThirdBoxHandler extends BaseDeviceHandler{
for (DataLog queueTask : queueTasks) { for (DataLog queueTask : queueTasks) {
if (queueTask.getCid().equals(cid)) { if (queueTask.getCid().equals(cid)) {
//有入库任务不分配出库任务 //有入库任务不分配出库任务
if (queueTask.isPutInTask()) { if (queueTask.isPutInTask()) {
return statusBean; return statusBean;
} else { } else {
if (queueTask.isExecuting()) { if (queueTask.isExecuting()) {
...@@ -217,16 +218,69 @@ public class ThirdBoxHandler extends BaseDeviceHandler{ ...@@ -217,16 +218,69 @@ public class ThirdBoxHandler extends BaseDeviceHandler{
} }
return statusBean; return statusBean;
} }
//比较料仓容量,若不一样时返回一个新库位号
protected StoragePos UsePosProcess(DataLog task,Map<String,Integer> posCapMap) {
try {
if (task == null || (!task.isCheckOutTask())||posCapMap==null||posCapMap.size()<=0) {
return null;
}
Storage storage = dataCache.getStorage(task.getCid());
if (storage == null) {
log.error("入库任务完成时库存比对:未找到料仓:" + task.getCid());
}
protected void thirdBoxFinishedPutIn(String cid, Map<String,Integer> posCapMap,String posName,String barcode,int executeTime) throws ValidateException { String sizeStr = task.getW() + "x" + task.getH();
DataLog task = taskService.findExecutingTask(cid, posName, barcode); UsageItem item = storage.getUsageMap().getOrDefault(sizeStr, new UsageItem());
int updateCount = posCapMap.getOrDefault(sizeStr, 0);
int currCount = item.getTotalCount() - item.getUsedCount();
if (currCount - 1 == updateCount) {
log.info("入库任务完成时库存比对:料仓[" + storage.getCid() + "]尺寸[" + sizeStr + "]当前库存[" + currCount + "]上传库存[" + updateCount + "],不更改库位号");
//完全相等,不处理
return null;
} else if (currCount > updateCount) {
log.error("入库任务完成时库存比对:料仓[" + storage.getCid() + "]尺寸[" + sizeStr + "]当前库存[" + currCount + "]上传库存[" + updateCount + "],不更改库位号");
return null;
}
if (task != null && task.isPutInTask()) { //查找实时库存小于当前库存的尺寸
Map<String, UsageItem> currUseMap = storage.getUsageMap();
for (String key :
currUseMap.keySet()) {
item = currUseMap.get(key);
int sizeCount = posCapMap.getOrDefault(key, 0);
int sizeEmptyCount = item.getTotalCount() - item.getUsedCount();
if (sizeEmptyCount > sizeCount) {
Collection<String> operatingPosIds = taskService.excludePosIds();
//使用此尺寸的库位
StoragePos pos = storagePosManager.getEmptyPosByStorage(storage, item.getW(), item.getH(), operatingPosIds);
if (pos == null) {
//对比容量,更新库位号 log.info("入库任务完成时库存比对:料仓[" + storage.getCid() + "]新尺寸[" + key + "]当前库存[" + sizeEmptyCount + "]上传库存[" + sizeCount + "],尝试查找空库位失败");
} else {
log.info("入库任务完成时库存比对:料仓[" + storage.getCid() + "]新尺寸[" + key + "]当前库存[" + sizeEmptyCount + "]上传库存[" + sizeCount + "],查找到新库位[" + pos.getPosName() + "],更改任务为新库位");
return pos;
}
}
}
} catch (Exception ex) {
log.error("入库任务完成时库存比对:料仓[" + task.getCid() + "]id[" + task.getId() + "]条码[" + task.getBarcode() + "]库位号[" + task.getPosName() + "]出错:" + ex.getMessage());
}
return null;
}
protected void thirdBoxFinishedPutIn(String cid, Map<String,Integer> posCapMap,String posName,String barcode,int executeTime) throws ValidateException {
DataLog task = taskService.findExecutingTask(cid, posName, barcode);
if (task != null && task.isPutInTask()) {
//对比容量,更新库位号
StoragePos newPos=UsePosProcess(task,posCapMap);
if(newPos!=null){
log.error(cid + "入仓位[" + posName + "]ReelId[" + barcode + "] 更改库位号为["+newPos.getPosName()+"]");
task.setPosName(newPos.getPosName());
}
if (executeTime > 0) { if (executeTime > 0) {
task.setExecuteTime(executeTime); task.setExecuteTime(executeTime);
updatePosExecuteTime(task.getPosName(), executeTime); updatePosExecuteTime(task.getPosName(), executeTime);
...@@ -245,6 +299,14 @@ public class ThirdBoxHandler extends BaseDeviceHandler{ ...@@ -245,6 +299,14 @@ public class ThirdBoxHandler extends BaseDeviceHandler{
task = taskService.findFinishedPutInTask(cid, posName, barcode); task = taskService.findFinishedPutInTask(cid, posName, barcode);
if (task != null && task.isPutInTask()) { if (task != null && task.isPutInTask()) {
if (task.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成 if (task.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成
//对比容量,更新库位号
StoragePos newPos=UsePosProcess(task,posCapMap);
if(newPos!=null){
log.error(cid + "入仓位[" + posName + "]ReelId[" + barcode + "]完成,但任务已被取消, 更改库位号为["+newPos.getPosName()+"]");
task.setPosName(newPos.getPosName());
}
if (executeTime > 0) { if (executeTime > 0) {
task.setExecuteTime(executeTime); task.setExecuteTime(executeTime);
updatePosExecuteTime(task.getPosName(), executeTime); updatePosExecuteTime(task.getPosName(), executeTime);
......
...@@ -103,10 +103,10 @@ public class DataCache { ...@@ -103,10 +103,10 @@ public class DataCache {
@PostConstruct @PostConstruct
public void initialize() { public void initialize() {
settings = getSettings(); settings = getSettings();;
Integer caWarn=getCache(Constants.CACHE_CapacityWarn);
codeResolve.updateExpiresDay(caWarn);
initCacheItem(); initCacheItem();
Integer expireDay=getCache(Constants.CACHE_ExpiresDay);
codeResolve.updateExpiresDay(expireDay);
} }
private void initCacheItem() { private void initCacheItem() {
......
...@@ -23,6 +23,6 @@ public class HumitureQueryCriteria { ...@@ -23,6 +23,6 @@ public class HumitureQueryCriteria {
private String humitureId; private String humitureId;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "createDate") @QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "createDate")
@DateTimeFormat(pattern = "yyyy-MM-dd HH") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private BetweenData<Date> createDate; private BetweenData<Date> createDate;
} }
...@@ -162,15 +162,14 @@ public class BoxKanbanController { ...@@ -162,15 +162,14 @@ public class BoxKanbanController {
} }
} }
boolean statusOk = false; boolean statusOk = false;
Date lastUpdateTime = new Date((new Date().getTime()) - 10 * 60 * 1000);
//正常 //正常
if (criteria.getTaskStatus() == 1) { if (criteria.getTaskStatus() == 1) {
if (lastUpdateTime.before(datalog.getUpdateDate()) && datalog.getStatus().equals(OP_STATUS.EXECUTING.name())) { if(datalog.isNormal()){
statusOk = true; statusOk = true;
} }
}//异常 }//异常
else if (criteria.getTaskStatus() == 2) { else if (criteria.getTaskStatus() == 2) {
if (lastUpdateTime.after(datalog.getUpdateDate()) && datalog.getStatus().equals(OP_STATUS.EXECUTING.name())) { if(datalog.isAbnormal()){
statusOk = true; statusOk = true;
} }
}//等待 }//等待
......
...@@ -94,9 +94,12 @@ public class MaterialStockController { ...@@ -94,9 +94,12 @@ public class MaterialStockController {
} }
Query query = QueryHelp.getQuery(criteria); Query query = QueryHelp.getQuery(criteria);
Criteria baseCriteria = Criteria.where("used").is(true); Criteria baseCriteria = Criteria.where("used").is(true);
if (criteria.getExpireDate() != null && criteria.getExpireDate().getFrom() != null && criteria.getExpireDate().getTo() != null) {
//需要查询已经超过过期日期的物料 //根据过滤时间查询
baseCriteria.and("barcode.expireDate").lte(new Date()); } else {
//需要查询已经超过过期日期的物料
baseCriteria.and("barcode.expireDate").lte(new Date());
}
// baseCriteria.and("barcode.sluggishTime").gte(new Date()); // baseCriteria.and("barcode.sluggishTime").gte(new Date());
query.addCriteria(baseCriteria); query.addCriteria(baseCriteria);
...@@ -116,8 +119,12 @@ public class MaterialStockController { ...@@ -116,8 +119,12 @@ public class MaterialStockController {
Query query = QueryHelp.getQuery(criteria); Query query = QueryHelp.getQuery(criteria);
Criteria baseCriteria = Criteria.where("used").is(true); Criteria baseCriteria = Criteria.where("used").is(true);
//需要查询已经过呆滞日期的物料 if (criteria.getSluggishTime() != null && criteria.getSluggishTime().getFrom() != null && criteria.getSluggishTime().getTo() != null) {
baseCriteria.and("barcode.sluggishTime").exists(true).lte(new Date()); //根据过滤时间查询
} else {
//需要查询已经过呆滞日期的物料
baseCriteria.and("barcode.sluggishTime").exists(true).lte(new Date());
}
// baseCriteria.and("barcode.sluggishTime").gte(new Date()); // baseCriteria.and("barcode.sluggishTime").gte(new Date());
query.addCriteria(baseCriteria); query.addCriteria(baseCriteria);
......
...@@ -18,17 +18,21 @@ public class StoragePosFindCriteria { ...@@ -18,17 +18,21 @@ public class StoragePosFindCriteria {
private String blurry; private String blurry;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "barcode.putInDate") @QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "barcode.putInDate")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private BetweenData<Date> updateDate; private BetweenData<Date> updateDate;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "barcode.putInDate") @QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "barcode.putInDate")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private BetweenData<Date> putInDate; private BetweenData<Date> putInDate;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "barcode.expireDate") @QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "barcode.expireDate")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private BetweenData<Date> expireDate; private BetweenData<Date> expireDate;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "barcode.sluggishTime")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private BetweenData<Date> sluggishTime;
@QueryCondition @QueryCondition
......
...@@ -45,6 +45,8 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> { ...@@ -45,6 +45,8 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
StoragePos getEmptyPosByStorage(Storage storage, Barcode barcode, Collection<String> excludePosIds, String lastPosId) throws ValidateException; StoragePos getEmptyPosByStorage(Storage storage, Barcode barcode, Collection<String> excludePosIds, String lastPosId) throws ValidateException;
StoragePos getEmptyPosByStorage(Storage storage, int size, int height, Collection<String> excludePosIds) throws ValidateException;
List<StoragePos> findNotEmpty(); List<StoragePos> findNotEmpty();
List<StoragePos> findByStorage(String storageId); List<StoragePos> findByStorage(String storageId);
......
...@@ -421,10 +421,50 @@ public class StoragePosManagerImpl implements IStoragePosManager { ...@@ -421,10 +421,50 @@ public class StoragePosManagerImpl implements IStoragePosManager {
StoragePos pos = storagePosDao.findOne(query); StoragePos pos = storagePosDao.findOne(query);
if ((!ObjectUtil.isNotEmpty(msg) )&& (pos != null)) { if ((!ObjectUtil.isNotEmpty(msg) )&& (pos != null)) {
Point targetP = PointUtil.getPosPoint(lastPosId, false); Point targetP = PointUtil.getPosPoint(lastPosId, false);
log.info(msg + "结果:[" + pos.getPosName() + "][" + targetP.getX() + "," + targetP.getY() + "]"); log.debug(msg + "结果:[" + pos.getPosName() + "][" + targetP.getX() + "," + targetP.getY() + "]");
} }
return pos; return pos;
} }
@Override
public StoragePos getEmptyPosByStorage(Storage storage, int size,int height, Collection<String> excludePosIds ) throws ValidateException {
Criteria c = Criteria.where("storageId").is(storage.getId());
COMPATIBLE_TYPE compatibleType = storage.getCompatibleType();
if (compatibleType == COMPATIBLE_TYPE.EXACT_MATCH) {//完全匹配
c = c.and("w").is(size).and("h").is(height);
} else if (compatibleType == COMPATIBLE_TYPE.FULLY_COMPATIBLE) {//同厚度兼容
c = c.and("w").gte(size).and("h").gte(height);//除7寸外,完全兼容
} else if (compatibleType == COMPATIBLE_TYPE.SIZE_COMPATIBLE) {//同尺寸兼容
c = c.and("w").is(size).and("h").gte(height);//宽度等于料盘宽度,高度大于等于料盘高度
}
c = c.and("enabled").is(true)//可用
.and("used").is(false);//未使用
//去除的仓位
if (excludePosIds != null && !excludePosIds.isEmpty()) {
c = c.and("id").nin(excludePosIds);
}
Query query = new Query(c);
String msg = "";
// if (lastPosId == null || lastPosId.equals("")) {
//优先放入最合适的位置(根据尺寸),相同尺寸按优先级排序
query.with(Sort.by(Sort.Direction.ASC, "w").and(Sort.by(Sort.Direction.ASC, "h")).and(Sort.by(Sort.Direction.DESC, "priority")));
// } else {
// Point point = PointUtil.getPosPoint(lastPosId, false);
// query.addCriteria(Criteria.where("coordinate").nearSphere(point));
// msg += "getEmptyPosByStorage 根据就近坐标查询[" + lastPosId + "][" + point.getX() + "," + point.getY() + "]";
// }
StoragePos pos = storagePosDao.findOne(query);
return pos;
}
@Override @Override
public List<StoragePos> findNotEmpty(){ public List<StoragePos> findNotEmpty(){
return findNotEmptyByStorageId(null); return findNotEmptyByStorageId(null);
......
...@@ -18,6 +18,7 @@ import com.neotel.smfcore.core.system.rest.bean.dto.SettingsDto; ...@@ -18,6 +18,7 @@ import com.neotel.smfcore.core.system.rest.bean.dto.SettingsDto;
import com.neotel.smfcore.core.system.rest.bean.dto.SysSettingsDto; import com.neotel.smfcore.core.system.rest.bean.dto.SysSettingsDto;
import com.neotel.smfcore.core.system.rest.bean.mapstruct.SettingsMapper; import com.neotel.smfcore.core.system.rest.bean.mapstruct.SettingsMapper;
import com.neotel.smfcore.core.system.service.po.Settings; import com.neotel.smfcore.core.system.service.po.Settings;
import com.neotel.smfcore.core.system.util.DbBackupService;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.bean.FileProperties; import com.neotel.smfcore.security.bean.FileProperties;
import com.neotel.smfcore.security.rest.bean.dto.MenuDto; import com.neotel.smfcore.security.rest.bean.dto.MenuDto;
...@@ -57,6 +58,10 @@ public class SettingsController { ...@@ -57,6 +58,10 @@ public class SettingsController {
@Autowired @Autowired
private final FileProperties properties; private final FileProperties properties;
@Autowired
private DbBackupService dbBackupService;
/** /**
* 当前版本 * 当前版本
*/ */
...@@ -74,12 +79,14 @@ public class SettingsController { ...@@ -74,12 +79,14 @@ public class SettingsController {
Integer sluggishDay=dataCache.getCache(Constants.CACHE_SluggishDay); Integer sluggishDay=dataCache.getCache(Constants.CACHE_SluggishDay);
Integer expiresDay=dataCache.getCache(Constants.CACHE_ExpiresDay); Integer expiresDay=dataCache.getCache(Constants.CACHE_ExpiresDay);
Integer caWarn=dataCache.getCache(Constants.CACHE_CapacityWarn); Integer caWarn=dataCache.getCache(Constants.CACHE_CapacityWarn);
Integer backUpMonth = dataCache.getCache(Constants.BACKUP_MONTH_KEY);
SysSettingsDto dto = new SysSettingsDto(); SysSettingsDto dto = new SysSettingsDto();
dto.setStartJob(startJob); dto.setStartJob(startJob);
dto.setStopOut(stopOut); dto.setStopOut(stopOut);
dto.setSluggishDay(sluggishDay); dto.setSluggishDay(sluggishDay);
dto.setExpiresDay(expiresDay); dto.setExpiresDay(expiresDay);
dto.setCapacityWarn(caWarn); dto.setCapacityWarn(caWarn);
dto.setBackUpMonth(backUpMonth);
return dto; return dto;
} }
...@@ -92,8 +99,9 @@ public class SettingsController { ...@@ -92,8 +99,9 @@ public class SettingsController {
dataCache.updateCache(Constants.CACHE_SluggishDay,sysSettingsDto.getSluggishDay()); dataCache.updateCache(Constants.CACHE_SluggishDay,sysSettingsDto.getSluggishDay());
dataCache.updateCache(Constants.CACHE_ExpiresDay,sysSettingsDto.getExpiresDay()); dataCache.updateCache(Constants.CACHE_ExpiresDay,sysSettingsDto.getExpiresDay());
dataCache.updateCache(Constants.CACHE_CapacityWarn,sysSettingsDto.getCapacityWarn()); dataCache.updateCache(Constants.CACHE_CapacityWarn,sysSettingsDto.getCapacityWarn());
dataCache.updateCache(Constants.BACKUP_MONTH_KEY,sysSettingsDto.getBackUpMonth());
log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob()+",sluggishDay="+sysSettingsDto.getSluggishDay() log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob()+",sluggishDay="+sysSettingsDto.getSluggishDay()
+",expiresDay="+sysSettingsDto.getExpiresDay()+",capacityWarn="+sysSettingsDto.getCapacityWarn()); +",expiresDay="+sysSettingsDto.getExpiresDay()+",capacityWarn="+sysSettingsDto.getCapacityWarn()+",backUpMonth="+sysSettingsDto.getBackUpMonth());
return ResultBean.newOkResult("保存成功"); return ResultBean.newOkResult("保存成功");
} }
...@@ -173,7 +181,8 @@ public class SettingsController { ...@@ -173,7 +181,8 @@ public class SettingsController {
if(orderSetting.getOrderDir().toLowerCase().startsWith("smb")){ if(orderSetting.getOrderDir().toLowerCase().startsWith("smb")){
}else{ }else{
throw new ValidateException("smfcore.enterCorrectFolder", "请输入正确的文件夹" ); return ResultBean.newErrorResult(-1,"smfcore.enterCorrectFolder","请输入正确的文件夹");
// throw new ValidateException("smfcore.enterCorrectFolder", "请输入正确的文件夹" );
} }
} }
} }
......
...@@ -234,7 +234,7 @@ public class TaskController { ...@@ -234,7 +234,7 @@ public class TaskController {
if(task.isCancel()||task.isFinished()||task.isEnd()){ if(task.isCancel()||task.isFinished()||task.isEnd()){
throw new ValidateException("smfcore.taskHasEnd","任务{0}已取消或已结束",new String[]{task.getPosName()} ); throw new ValidateException("smfcore.taskHasEnd","任务{0}已取消或已结束",new String[]{task.getPosName()} );
} }
taskService.cancelTask(taskId); taskService.cancelTaskAndDisPos(taskId);
} }
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
......
...@@ -24,4 +24,7 @@ public class SysSettingsDto implements Serializable { ...@@ -24,4 +24,7 @@ public class SysSettingsDto implements Serializable {
@ApiModelProperty("容量预警") @ApiModelProperty("容量预警")
private Integer capacityWarn=0; private Integer capacityWarn=0;
@ApiModelProperty("备份时间")
private Integer backUpMonth=0;
} }
...@@ -417,11 +417,22 @@ public class DataLog extends BasePo implements Serializable { ...@@ -417,11 +417,22 @@ public class DataLog extends BasePo implements Serializable {
* 判断任务是否异常,执行中,且10分钟未更新的认为异常 * 判断任务是否异常,执行中,且10分钟未更新的认为异常
*/ */
public boolean isAbnormal(){ public boolean isAbnormal(){
if(isExecuting() ){ if(isExecuting() ||isInLine()||isInRobot()||isBoxdoor()||isOutBox() ){
if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 10 * 60 * 1000){ if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 10 * 60 * 1000){
return true; return true;
} }
} }
return false; return false;
} }
/**
* 是否正常执行中,执行中,且10分钟内有更新
*/
public boolean isNormal(){
if(isExecuting() ||isInLine()||isInRobot()||isBoxdoor() ||isOutBox()){
if(System.currentTimeMillis() - super.getUpdateDate().getTime() <= 10 * 60 * 1000){
return true;
}
}
return false;
}
} }
package com.neotel.smfcore.core.system.util; package com.neotel.smfcore.core.system.util;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.DateUtil; import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inList.service.po.InList; import com.neotel.smfcore.core.inList.service.po.InList;
...@@ -36,15 +37,6 @@ import java.util.concurrent.TimeUnit; ...@@ -36,15 +37,6 @@ import java.util.concurrent.TimeUnit;
@Service @Service
public class DbBackupService { public class DbBackupService {
/**
* 自动存档间隔Key
*/
private String BACKUP_MONTH_KEY = "db.backup.month";
/**
* 上次自动存档时间
*/
private String LAST_BACKUP_TIME_KEY = "db.backup.lastTime";
@Autowired @Autowired
DataCache dataCache; DataCache dataCache;
...@@ -62,10 +54,10 @@ public class DbBackupService { ...@@ -62,10 +54,10 @@ public class DbBackupService {
log.info("开启数据库定时存档任务"); log.info("开启数据库定时存档任务");
while(true){ while(true){
try{ try{
Integer dbBackupMonth = dataCache.getCache(BACKUP_MONTH_KEY); Integer dbBackupMonth = dataCache.getCache(Constants.BACKUP_MONTH_KEY);
dbBackupMonth = 1; //dbBackupMonth = 1;
if(dbBackupMonth != null && dbBackupMonth > 0){ if(dbBackupMonth != null && dbBackupMonth > 0){
Date lastBackupTime = dataCache.getCache(LAST_BACKUP_TIME_KEY); Date lastBackupTime = dataCache.getCache(Constants.LAST_BACKUP_TIME_KEY);
boolean needBackup = false; boolean needBackup = false;
if(lastBackupTime == null){ if(lastBackupTime == null){
needBackup = true; needBackup = true;
...@@ -99,12 +91,11 @@ public class DbBackupService { ...@@ -99,12 +91,11 @@ public class DbBackupService {
return false; return false;
} }
processing = true; processing = true;
Integer dbBackupMonth = dataCache.getCache(BACKUP_MONTH_KEY); Integer dbBackupMonth = dataCache.getCache(Constants.BACKUP_MONTH_KEY);
if(dbBackupMonth == null){ if(dbBackupMonth == null){
dbBackupMonth = 12;//默认备份12个月前的数据 dbBackupMonth = 12;//默认备份12个月前的数据
dataCache.updateCache(BACKUP_MONTH_KEY,dbBackupMonth); dataCache.updateCache(Constants.BACKUP_MONTH_KEY,dbBackupMonth);
} }
dataCache.updateCache(LAST_BACKUP_TIME_KEY,new Date());
backupTable(dbBackupMonth, backupTable(dbBackupMonth,
DataLog.class, DataLog.class,
Humiture.class, Humiture.class,
...@@ -115,6 +106,7 @@ public class DbBackupService { ...@@ -115,6 +106,7 @@ public class DbBackupService {
Message.class, Message.class,
AlarmInfo.class AlarmInfo.class
); );
dataCache.updateCache(Constants.LAST_BACKUP_TIME_KEY,new Date());
processing = false; processing = false;
return true; return true;
} }
...@@ -151,5 +143,4 @@ public class DbBackupService { ...@@ -151,5 +143,4 @@ public class DbBackupService {
} }
} }
} }
} }
...@@ -16,6 +16,7 @@ import com.neotel.smfcore.core.device.bean.StatusBean; ...@@ -16,6 +16,7 @@ import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP; import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder; import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE; import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
...@@ -243,6 +244,29 @@ public class TaskService { ...@@ -243,6 +244,29 @@ public class TaskService {
return cancelTask(task); return cancelTask(task);
} }
public boolean cancelTaskAndDisPos(String taskId) {
DataLog task = dataLogDao.findOneById(taskId);
boolean result = cancelTask(task);
if (result) {
if (task.isPutInTask()) {
//禁用库位
StoragePos pos = storagePosManager.get(task.getPosId());
if (pos != null) {
pos.setEnabled(false);
storagePosManager.save(pos);
dataCache.updateDisablePos(pos);
log.info("任务[" + task.getId() + "] posName[" + task.getPosName() + "] Reel Id[" + task.getBarcode() + "]取消成功,禁用库位[" + task.getPosName() + "]");
DeviceMessageUtil.addEnabledPosMessage(pos, SecurityUtils.getCurrentUsername());
Storage storage = dataCache.getStorageById(pos.getStorageId());
if (storage != null) {
dataCache.reloadStorage(storage, storage.getCid());
}
}
}
}
return result;
}
/** /**
* 清除某个已经完成或取消的任务 * 清除某个已经完成或取消的任务
*/ */
......
...@@ -14,13 +14,15 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,13 +14,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@RestController @RestController
@Api(tags = "1053:设备端接口") @Api(tags = "1053:设备端接口")
@RequestMapping("/rest/micron/service") @RequestMapping("/rest/micron/device")
public class MicronServiceController { public class MicronDeviceController {
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
...@@ -44,38 +46,28 @@ public class MicronServiceController { ...@@ -44,38 +46,28 @@ public class MicronServiceController {
} }
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
@ApiOperation(" 获取治具任务数量,料盘任务数量 ") @ApiOperation(" 获取任务数量 ")
@PostMapping(value = "/getTaskCount") @PostMapping(value = "/getTaskCount")
@ResponseBody @ResponseBody
@AnonymousAccess @AnonymousAccess
public ResultBean getTaskCount( HttpServletRequest request) { public ResultBean getTaskCount( HttpServletRequest request) {
String type = request.getParameter("type"); // String type = request.getParameter("type");
int count=0;
List<DataLog> dataLogs= taskService.getAllTasks(); List<DataLog> dataLogs = taskService.getAllTasks();
for (DataLog task :dataLogs // String[] types=new String[]{"pizzaBox","pcb","tray","reel"};
Map<String, Integer> resultMap = new HashMap<>();
for (DataLog task : dataLogs
) { ) {
String taskType=MicronDataCache.GetMaterialType(task); String taskType = MicronDataCache.GetMaterialType(task);
if(taskType.toLowerCase().equals(type.toLowerCase())){ String key = taskType + "_out";
count++; if (task.isPutInTask()) {
key = taskType + "_in";
} }
int count = resultMap.getOrDefault(key, 0) + 1;
resultMap.put(key, count);
} }
//SBSH1,SBSH2,SBDH1-1,SBDH1-2,SBDH2-1.SBDH2-2这些都是Pizza box,对应的料架是M01开头的,每个料架可以放5盘料 return ResultBean.newOkResult(resultMap);
//SBDH3-1里面有pcb,对应的料架是M02开头,每个料架可以放5盘料。
// tray对应的料架是M03开头,每个料架可以放4盘料,
// 还有reel料盘尺寸是13*44,13*56,13*72
//SBDH3-2里面是pcb物料
// 310*80是PCB
// 330*120是tray
// 13*72的入13*44,13*56,13*72的料盘
//pizzaBox (料架M01,每个料架5盘) SBSH1,SBSH2,SBDH1-1,SBDH1-2,SBDH2-1.SBDH2-2
//pcb (料架M02,每个料架5盘) SBDH3-2,SBDH3-1部分
//tray (料架M03,每个料架4盘) SBDH3-1 里
//reel (料架M01,每个料架5盘) SBDH3-1 13*44,13*56,13*72
return ResultBean.newOkResult(count);
} }
......
...@@ -84,7 +84,7 @@ public class MicronDataCache { ...@@ -84,7 +84,7 @@ public class MicronDataCache {
//reel (料架M01,每个料架5盘) SBDH3-1 13*44,13*56,13*72 //reel (料架M01,每个料架5盘) SBDH3-1 13*44,13*56,13*72
} }
public static String GetMaterialType(DataLog dataLog){ public static String GetMaterialType(DataLog dataLog){
return REEL; return GetMaterialType(dataLog.getCid(),dataLog.getStorageId(),dataLog.getW(),dataLog.getH());
} }
public static String getShelfType(String materialType){ public static String getShelfType(String materialType){
if(materialType.equals(PIZZABOX)){ if(materialType.equals(PIZZABOX)){
......
...@@ -302,6 +302,7 @@ smfcore.ml=MI1 ...@@ -302,6 +302,7 @@ smfcore.ml=MI1
smfcore.ml2=MI2 smfcore.ml2=MI2
smfcore.diagnosis=Diagnosis smfcore.diagnosis=Diagnosis
smfcore.helps=Help smfcore.helps=Help
smfcore.error.storage.noPos={0}\u7684\u6599\u683C[{1}]\u5DF2\u6EE1,\u65E0\u6CD5\u7EE7\u7EED\u653E\u5165
#smfclient.nlp.onlyOneTray=\u4E0D\u53EF\u540C\u65F6\u653E\u5165\u591A\u76D8\u7269\u6599:{0} #smfclient.nlp.onlyOneTray=\u4E0D\u53EF\u540C\u65F6\u653E\u5165\u591A\u76D8\u7269\u6599:{0}
#smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1} #smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1}
#smfclient.nlp.inputOk={0}\u5165\u5E93\u5230{1}\u6210\u529F #smfclient.nlp.inputOk={0}\u5165\u5E93\u5230{1}\u6210\u529F
......
...@@ -300,4 +300,5 @@ smfcore.mt=MT ...@@ -300,4 +300,5 @@ smfcore.mt=MT
smfcore.ml=MI1 smfcore.ml=MI1
smfcore.ml2=MI2 smfcore.ml2=MI2
smfcore.diagnosis=Diagnosis smfcore.diagnosis=Diagnosis
smfcore.helps=Help
\ No newline at end of file \ No newline at end of file
smfcore.helps=Help
smfcore.error.storage.noPos={0}'s cell [{1}] is full and cannot be added
\ No newline at end of file \ No newline at end of file
...@@ -298,3 +298,4 @@ smfcore.ml=MI1 ...@@ -298,3 +298,4 @@ smfcore.ml=MI1
smfcore.ml2=MI2 smfcore.ml2=MI2
smfcore.diagnosis=Diagnosis smfcore.diagnosis=Diagnosis
smfcore.helps=Help smfcore.helps=Help
smfcore.error.storage.noPos={0}\u7684\u6599\u683C[{1}]\u5DF2\u6EE1,\u65E0\u6CD5\u7EE7\u7EED\u653E\u5165
...@@ -297,4 +297,5 @@ smfcore.mt=MT ...@@ -297,4 +297,5 @@ smfcore.mt=MT
smfcore.ml=MI1 smfcore.ml=MI1
smfcore.ml2=MI2 smfcore.ml2=MI2
smfcore.diagnosis=Diagnosis smfcore.diagnosis=Diagnosis
smfcore.helps=Help
\ No newline at end of file \ No newline at end of file
smfcore.helps=Help
smfcore.error.storage.noPos={0}\u7684\u6599\u683C[{1}]\u5DF2\u6EE1,\u65E0\u6CD5\u7EE7\u7EED\u653E\u5165
\ No newline at end of file \ No newline at end of file
...@@ -298,4 +298,5 @@ smfcore.mt=MT ...@@ -298,4 +298,5 @@ smfcore.mt=MT
smfcore.ml=MI1 smfcore.ml=MI1
smfcore.ml2=MI2 smfcore.ml2=MI2
smfcore.diagnosis=Diagnosis smfcore.diagnosis=Diagnosis
smfcore.helps=Help
\ No newline at end of file \ No newline at end of file
smfcore.helps=Help
smfcore.error.storage.noPos={0}\u7684\u6599\u683C[{1}]\u5DF2\u6EFF,\u7121\u6CD5\u7E7C\u7E8C\u653E\u5165
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!