Commit 611e96e8 LN

1.出入库次数记录。2.records报表增加设备过滤下拉框

1 个父辈 ab9dcf15
...@@ -22,6 +22,8 @@ import com.neotel.smfcore.core.device.enums.OP; ...@@ -22,6 +22,8 @@ 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.handler.IDeviceHandler; import com.neotel.smfcore.core.device.handler.IDeviceHandler;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager;
import com.neotel.smfcore.core.inout.service.po.InOutData;
import com.neotel.smfcore.core.language.util.MessageUtils; import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil; import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.msd.bean.MSDSettiings; import com.neotel.smfcore.core.msd.bean.MSDSettiings;
...@@ -102,6 +104,8 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -102,6 +104,8 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected IComponentManager componentManager; protected IComponentManager componentManager;
@Autowired @Autowired
private SelfAuditUtil selfAuditUtil; private SelfAuditUtil selfAuditUtil;
@Autowired
private IInOutDataManager inOutDataManager;
/** /**
* CID的服务器消息(key 为 cid) * CID的服务器消息(key 为 cid)
...@@ -614,6 +618,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -614,6 +618,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (executeTime > 0) { if (executeTime > 0) {
task.setExecuteTime(executeTime); task.setExecuteTime(executeTime);
updatePosExecuteTime(task.getPosName(), executeTime); updatePosExecuteTime(task.getPosName(), executeTime);
updateInOutDateExecuteTime(task.getPosName(),executeTime);
} }
log.info(task.getBarcode() + "入仓位[" + task.getPosName() + "]完成,执行时间[" + executeTime + "]秒"); log.info(task.getBarcode() + "入仓位[" + task.getPosName() + "]完成,执行时间[" + executeTime + "]秒");
List<DataLog> taskList = taskService.findFinishedTaskList(cid, task.getPosName(), task.getBarcode(), true); List<DataLog> taskList = taskService.findFinishedTaskList(cid, task.getPosName(), task.getBarcode(), true);
...@@ -636,6 +641,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -636,6 +641,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (executeTime > 0) { if (executeTime > 0) {
task.setExecuteTime(executeTime); task.setExecuteTime(executeTime);
updatePosExecuteTime(task.getPosName(), executeTime); updatePosExecuteTime(task.getPosName(), executeTime);
updateInOutDateExecuteTime(task.getPosName(),executeTime);
} }
log.info(task.getBarcode() + "入仓位[" + task.getPosName() + "]完成,但任务已被取消,修改为完成,执行时间[" + executeTime + "]秒"); log.info(task.getBarcode() + "入仓位[" + task.getPosName() + "]完成,但任务已被取消,修改为完成,执行时间[" + executeTime + "]秒");
updatePutInData(task); updatePutInData(task);
...@@ -675,6 +681,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -675,6 +681,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (task != null && task.isCheckOutTask()) { if (task != null && task.isCheckOutTask()) {
if (executeTime > 0) { if (executeTime > 0) {
task.setExecuteTime(executeTime); task.setExecuteTime(executeTime);
updateInOutDateExecuteTime(task.getPosName(),executeTime);
} }
log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,执行时间[" + executeTime + "]秒"); log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,执行时间[" + executeTime + "]秒");
DataLog cancelTask = taskService.findFinishedOutTask(cid, task.getPosName(),task.getBarcode()); DataLog cancelTask = taskService.findFinishedOutTask(cid, task.getPosName(),task.getBarcode());
...@@ -692,6 +699,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -692,6 +699,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (task.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成 if (task.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成
if (executeTime > 0) { if (executeTime > 0) {
task.setExecuteTime(executeTime); task.setExecuteTime(executeTime);
updateInOutDateExecuteTime(task.getPosName(),executeTime);
} }
log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,但任务已被取消,修改为完成,执行时间[" + executeTime + "]秒"); log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,但任务已被取消,修改为完成,执行时间[" + executeTime + "]秒");
updateCheckoutData(task,outBoxStatus); updateCheckoutData(task,outBoxStatus);
...@@ -1067,6 +1075,20 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -1067,6 +1075,20 @@ public class BaseDeviceHandler implements IDeviceHandler {
return false; return false;
} }
private void updateInOutDateExecuteTime(String posName, int executeTime) {
try {
StoragePos storagePos = storagePosManager.getByPosName(posName);
if (storagePos != null) {
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
InOutData inOutData = dataCache.getLastSaveInOutData(storage.getCid(), storage.getId());
inOutData.setExecuteTime(inOutData.getExecuteTime() + executeTime);
inOutDataManager.save(inOutData);
}
} catch (Exception exception) {
log.error(exception.toString());
}
}
@Override @Override
public DeviceType getDeviceType() { public DeviceType getDeviceType() {
return DeviceType.DEFAULT; return DeviceType.DEFAULT;
......
package com.neotel.smfcore.core.device.util; package com.neotel.smfcore.core.device.util;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -16,6 +18,7 @@ import com.neotel.smfcore.core.device.bean.BoxStatusBean; ...@@ -16,6 +18,7 @@ import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.inList.util.InListCache; import com.neotel.smfcore.core.inList.util.InListCache;
import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager; import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager;
import com.neotel.smfcore.core.inout.service.po.InOutData;
import com.neotel.smfcore.core.language.service.bean.LanguageInfo; import com.neotel.smfcore.core.language.service.bean.LanguageInfo;
import com.neotel.smfcore.core.language.util.MessageUtils; import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.storage.bean.InventoryItem; import com.neotel.smfcore.core.storage.bean.InventoryItem;
...@@ -737,6 +740,7 @@ public class DataCache { ...@@ -737,6 +740,7 @@ public class DataCache {
storage.setFullReelCount(fullReelCount); storage.setFullReelCount(fullReelCount);
updateSpUsePosCount(storage, pos, -1); updateSpUsePosCount(storage, pos, -1);
removeUsedPosList(cid, pos ); removeUsedPosList(cid, pos );
updateInOutData(cid, storage.getId(), -1);
} else { } else {
//入库 //入库
amount = barcode.getAmount(); amount = barcode.getAmount();
...@@ -747,6 +751,7 @@ public class DataCache { ...@@ -747,6 +751,7 @@ public class DataCache {
if (ObjectUtil.isNotEmpty(storage.getInListName())) { if (ObjectUtil.isNotEmpty(storage.getInListName())) {
inListCache.UpdateInList(storage.getInListName(), pos, barcode); inListCache.UpdateInList(storage.getInListName(), pos, barcode);
} }
updateInOutData(cid, storage.getId(), 1);
// if(ObjectUtil.isNotEmpty(barcode.getInListName())){ // if(ObjectUtil.isNotEmpty(barcode.getInListName())){
// loadingUtil.puEndUpdateTime(barcode.getBarcode(),pos.getPosName()); // loadingUtil.puEndUpdateTime(barcode.getBarcode(),pos.getPosName());
// } // }
...@@ -1012,4 +1017,34 @@ public class DataCache { ...@@ -1012,4 +1017,34 @@ public class DataCache {
} }
return cache; return cache;
} }
private synchronized void updateInOutData(String cid, String storageId, int amount) {
InOutData inOutData = getLastSaveInOutData(cid, storageId);
//如果amount小于0,则是出库,否则入库
if (amount < 0) {
inOutData.setOutCount(inOutData.getOutCount() + 1);
} else if (amount > 0) {
inOutData.setInCount(inOutData.getInCount() + 1);
}
inOutData.setUpdateDate(new Date());
inOutDataManager.save(inOutData);
}
public InOutData getLastSaveInOutData(String cid, String storageId) {
InOutData inOutData = inOutDataManager.findOneByCidAndStorageId(cid,storageId);
if (inOutData == null) {
inOutData = new InOutData();
} else {
Date createDate = inOutData.getCreateDate();
//判断当前是否超过1个小时
String createDateStr = DateUtil.format(createDate, "yyyy-MM-dd HH");
String currentDateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH");
long between = DateUtil.between(DateUtil.parse(createDateStr,"yyyy-MM-dd HH"), DateUtil.parse(currentDateStr,"yyyy-MM-dd HH"), DateUnit.HOUR);
if (between >= 1) {
inOutData = new InOutData();
}
}
inOutData.setCid(cid);
inOutData.setStorageId(storageId);
return inOutData;
}
} }
...@@ -2,9 +2,15 @@ package com.neotel.smfcore.core.inout.service.manager; ...@@ -2,9 +2,15 @@ package com.neotel.smfcore.core.inout.service.manager;
import com.neotel.smfcore.common.base.IBaseManager; import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.inout.service.po.InOutData; import com.neotel.smfcore.core.inout.service.po.InOutData;
import org.springframework.data.mongodb.core.query.Query;
import java.util.Date; import java.util.Date;
import java.util.List;
public interface IInOutDataManager extends IBaseManager<InOutData> { public interface IInOutDataManager extends IBaseManager<InOutData> {
InOutData findOneByDate(Date startDate,Date endDate); List<InOutData> findByDate(Date startDate, Date endDate, List<String> storageIdList);
InOutData findOne(Query query);
InOutData findOneByCidAndStorageId(String cid, String storageId);
} }
...@@ -48,13 +48,24 @@ public class InOutDataManagerImpl implements IInOutDataManager { ...@@ -48,13 +48,24 @@ public class InOutDataManagerImpl implements IInOutDataManager {
} }
@Override @Override
public InOutData findOneByDate(Date startDate,Date endDate) { public List<InOutData> findByDate(Date startDate, Date endDate, List<String> storageIdList) {
Query q = new Query(); Query q = new Query();
Criteria c = Criteria.where("createDate").gte(startDate); Criteria c = Criteria.where("createDate").gte(startDate).lt(endDate);
if (endDate != null){ if (storageIdList != null && !storageIdList.isEmpty()) {
c.and("createDate").lt(endDate); c.and("storageId").in(storageIdList);
} }
Sort s = Sort.by(Sort.Direction.DESC, "createDate"); Sort s = Sort.by(Sort.Direction.DESC, "createDate");
return inOutDataDao.findOne(q.addCriteria(c).with(s)); return inOutDataDao.findByQuery(q.addCriteria(c).with(s));
}
@Override
public InOutData findOne(Query query) {
return inOutDataDao.findOne(query);
}
@Override
public InOutData findOneByCidAndStorageId(String cid, String storageId) {
Query query = new Query(Criteria.where("cid").is(cid).and("storageId").is(storageId)).with(Sort.by(Sort.Direction.DESC, "createDate"));
return inOutDataDao.findOne(query);
} }
} }
package com.neotel.smfcore.core.inout.service.po; package com.neotel.smfcore.core.inout.service.po;
import com.neotel.smfcore.common.base.BasePo; import com.neotel.smfcore.common.base.BasePo;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
@Data @Data
@Document @Document
@AllArgsConstructor
@NoArgsConstructor
public class InOutData extends BasePo { public class InOutData extends BasePo {
/** /**
* 设备cid * 设备cid
...@@ -26,4 +30,9 @@ public class InOutData extends BasePo { ...@@ -26,4 +30,9 @@ public class InOutData extends BasePo {
* 出库数量 * 出库数量
*/ */
private int outCount = 0; private int outCount = 0;
/**
* 执行时间
*/
private int executeTime = 0;
} }
...@@ -85,7 +85,8 @@ public class ReportController { ...@@ -85,7 +85,8 @@ public class ReportController {
String pn = query.getPn(); String pn = query.getPn();
List<ChartItem> chartItemList = storageManager.getRunStatusData(startDay, endDay, pn,null);
List<ChartItem> chartItemList = storageManager.getRunStatusData(startDay, endDay, pn,query.getCidList());
InoutDataDto dto = new InoutDataDto(); InoutDataDto dto = new InoutDataDto();
for (ChartItem item :chartItemList) { for (ChartItem item :chartItemList) {
......
...@@ -7,10 +7,13 @@ import org.springframework.format.annotation.DateTimeFormat; ...@@ -7,10 +7,13 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
@Data @Data
public class ReportQuery implements Serializable { public class ReportQuery implements Serializable {
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> updateDate; private BetweenData<Date> updateDate;
private String pn; private String pn;
private List<String> cidList;
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!