Commit 611e96e8 LN

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

1 个父辈 ab9dcf15
......@@ -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.handler.IDeviceHandler;
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.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.msd.bean.MSDSettiings;
......@@ -102,6 +104,8 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected IComponentManager componentManager;
@Autowired
private SelfAuditUtil selfAuditUtil;
@Autowired
private IInOutDataManager inOutDataManager;
/**
* CID的服务器消息(key 为 cid)
......@@ -614,6 +618,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (executeTime > 0) {
task.setExecuteTime(executeTime);
updatePosExecuteTime(task.getPosName(), executeTime);
updateInOutDateExecuteTime(task.getPosName(),executeTime);
}
log.info(task.getBarcode() + "入仓位[" + task.getPosName() + "]完成,执行时间[" + executeTime + "]秒");
List<DataLog> taskList = taskService.findFinishedTaskList(cid, task.getPosName(), task.getBarcode(), true);
......@@ -636,6 +641,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (executeTime > 0) {
task.setExecuteTime(executeTime);
updatePosExecuteTime(task.getPosName(), executeTime);
updateInOutDateExecuteTime(task.getPosName(),executeTime);
}
log.info(task.getBarcode() + "入仓位[" + task.getPosName() + "]完成,但任务已被取消,修改为完成,执行时间[" + executeTime + "]秒");
updatePutInData(task);
......@@ -675,6 +681,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (task != null && task.isCheckOutTask()) {
if (executeTime > 0) {
task.setExecuteTime(executeTime);
updateInOutDateExecuteTime(task.getPosName(),executeTime);
}
log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,执行时间[" + executeTime + "]秒");
DataLog cancelTask = taskService.findFinishedOutTask(cid, task.getPosName(),task.getBarcode());
......@@ -692,6 +699,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (task.isCancel()) {//被取消的任务,客户端发完成信号过来,修改取消状态为已完成
if (executeTime > 0) {
task.setExecuteTime(executeTime);
updateInOutDateExecuteTime(task.getPosName(),executeTime);
}
log.info(task.getBarcode() + "出仓位[" + task.getPosName() + "]完成,但任务已被取消,修改为完成,执行时间[" + executeTime + "]秒");
updateCheckoutData(task,outBoxStatus);
......@@ -1067,6 +1075,20 @@ public class BaseDeviceHandler implements IDeviceHandler {
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
public DeviceType getDeviceType() {
return DeviceType.DEFAULT;
......
package com.neotel.smfcore.core.device.util;
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 com.google.common.base.Strings;
import com.google.common.collect.Lists;
......@@ -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.inList.util.InListCache;
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.util.MessageUtils;
import com.neotel.smfcore.core.storage.bean.InventoryItem;
......@@ -737,6 +740,7 @@ public class DataCache {
storage.setFullReelCount(fullReelCount);
updateSpUsePosCount(storage, pos, -1);
removeUsedPosList(cid, pos );
updateInOutData(cid, storage.getId(), -1);
} else {
//入库
amount = barcode.getAmount();
......@@ -747,6 +751,7 @@ public class DataCache {
if (ObjectUtil.isNotEmpty(storage.getInListName())) {
inListCache.UpdateInList(storage.getInListName(), pos, barcode);
}
updateInOutData(cid, storage.getId(), 1);
// if(ObjectUtil.isNotEmpty(barcode.getInListName())){
// loadingUtil.puEndUpdateTime(barcode.getBarcode(),pos.getPosName());
// }
......@@ -1012,4 +1017,34 @@ public class DataCache {
}
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;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.inout.service.po.InOutData;
import org.springframework.data.mongodb.core.query.Query;
import java.util.Date;
import java.util.List;
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 {
}
@Override
public InOutData findOneByDate(Date startDate,Date endDate) {
public List<InOutData> findByDate(Date startDate, Date endDate, List<String> storageIdList) {
Query q = new Query();
Criteria c = Criteria.where("createDate").gte(startDate);
if (endDate != null){
c.and("createDate").lt(endDate);
Criteria c = Criteria.where("createDate").gte(startDate).lt(endDate);
if (storageIdList != null && !storageIdList.isEmpty()) {
c.and("storageId").in(storageIdList);
}
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;
import com.neotel.smfcore.common.base.BasePo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.mapping.Document;
@Data
@Document
@AllArgsConstructor
@NoArgsConstructor
public class InOutData extends BasePo {
/**
* 设备cid
......@@ -26,4 +30,9 @@ public class InOutData extends BasePo {
* 出库数量
*/
private int outCount = 0;
/**
* 执行时间
*/
private int executeTime = 0;
}
......@@ -85,7 +85,8 @@ public class ReportController {
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();
for (ChartItem item :chartItemList) {
......
......@@ -7,10 +7,13 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class ReportQuery implements Serializable {
@DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> updateDate;
private String pn;
private List<String> cidList;
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!