Commit c0ee5aca sunke

读取料仓使用状态时从缓存中读取

传给纬创时,仓位改为固定6位,不够补0
1 个父辈 10831937
package com.myproject.bean.update; package com.myproject.bean.update;
import com.myproject.bean.BaseMongoBean; import com.myproject.bean.BaseMongoBean;
import com.myproject.bean.json.PlateSizeBean;
import com.myproject.bean.json.UsageItem;
import com.myproject.util.PLATE_SIZE; import com.myproject.util.PLATE_SIZE;
import com.myproject.util.StorageConstants; import com.myproject.util.StorageConstants;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* Created by kangmor on 2015/12/3. * Created by kangmor on 2015/12/3.
...@@ -214,9 +218,9 @@ public class Storage extends BaseMongoBean { ...@@ -214,9 +218,9 @@ public class Storage extends BaseMongoBean {
* 判断料盘是否能够放入该仓库: 0=完全匹配,1=完全兼容,2=同尺寸兼容 * 判断料盘是否能够放入该仓库: 0=完全匹配,1=完全兼容,2=同尺寸兼容
*/ */
public boolean canPutIn(int w, int h){ public boolean canPutIn(int w, int h){
if(plateSizes != null){ if(usageMap != null){
for (PLATE_SIZE plateSize : plateSizes) { for (UsageItem usageItem : usageMap.values()) {
if(canPutInPos(w,h, plateSize.getW(), plateSize.getH())){ if(canPutInPos(w,h, usageItem.getW(), usageItem.getH())){
return true; return true;
} }
} }
...@@ -239,4 +243,75 @@ public class Storage extends BaseMongoBean { ...@@ -239,4 +243,75 @@ public class Storage extends BaseMongoBean {
public void setCompatibleType(StorageConstants.COMPATIBLE_TYPE compatibleType) { public void setCompatibleType(StorageConstants.COMPATIBLE_TYPE compatibleType) {
this.compatibleType = compatibleType; this.compatibleType = compatibleType;
} }
/**
* 使用情况
*/
private Map<String, UsageItem> usageMap = new ConcurrentHashMap<>();
public Map<String, UsageItem> getUsageMap() {
return usageMap;
}
public void setUsageMap(Map<String, UsageItem> usageMap) {
this.usageMap = usageMap;
}
/**
* 使用一个仓位,更新使用情况
*/
public void useOnePos(StoragePos pos){
if(usageMap != null){
String sizeStr = pos.getSizeStr();
UsageItem usageItem = usageMap.get(sizeStr);
if(usageItem != null){
this.emptySlots = this.emptySlots - 1;
int usedCount = usageItem.getUsedCount();
usageItem.setUsedCount(usedCount + 1);
usageMap.put(sizeStr, usageItem);
}
}
}
public void emptyOnePos(StoragePos pos){
if(usageMap != null){
String sizeStr = pos.getSizeStr();
UsageItem usageItem = usageMap.get(sizeStr);
if(usageItem != null){
this.emptySlots = this.emptySlots + 1;
int usedCount = usageItem.getUsedCount();
usageItem.setUsedCount(usedCount - 1);
usageMap.put(sizeStr, usageItem);
}
}
}
public void initUsage(List<PlateSizeBean> plateSizeBeanList){
usageMap = new ConcurrentHashMap<>();
int totalPosCount = 0;
int emptyPosCount = 0;
for (PlateSizeBean plateSizeBean : plateSizeBeanList) {
String sizeStr = plateSizeBean.getSizeStr();
UsageItem usageItem = usageMap.get(sizeStr);
if(usageItem == null){
usageItem = new UsageItem();
usageItem.setW(plateSizeBean.getPlateSize().getW());
usageItem.setH(plateSizeBean.getPlateSize().getH());
}
if(plateSizeBean.getPlateSize().isUsed()){
int usedCount = plateSizeBean.getCount();
usageItem.setUsedCount(usedCount);
usageItem.setTotalCount(usedCount + usageItem.getTotalCount());
}else{
//未使用的数量
int idleCount = plateSizeBean.getCount();
usageItem.setTotalCount(idleCount + usageItem.getTotalCount());
emptyPosCount = emptyPosCount + idleCount;
}
totalPosCount = totalPosCount + plateSizeBean.getCount();
usageMap.put(sizeStr, usageItem);
}
this.setEmptySlots(emptyPosCount);
this.setTotalSlots(totalPosCount);
}
} }
...@@ -186,4 +186,8 @@ public class StoragePos extends BaseMongoBean { ...@@ -186,4 +186,8 @@ public class StoragePos extends BaseMongoBean {
public void setCanCheckOutTime(long canCheckOutTime) { public void setCanCheckOutTime(long canCheckOutTime) {
this.canCheckOutTime = canCheckOutTime; this.canCheckOutTime = canCheckOutTime;
} }
public String getSizeStr(){
return w + "x" + h;
}
} }
...@@ -76,7 +76,7 @@ public interface IStoragePosManager extends IManager<StoragePos> { ...@@ -76,7 +76,7 @@ public interface IStoragePosManager extends IManager<StoragePos> {
Map<String, InventoryItem> getInventory(int type,String... storageIds); Map<String, InventoryItem> getInventory(int type,String... storageIds);
List<PLATE_SIZE> distinctPlateSize(String storageId); //List<PLATE_SIZE> distinctPlateSize(String storageId);
StoragePos getByBarcode(String barcode); StoragePos getByBarcode(String barcode);
......
...@@ -307,10 +307,10 @@ public class StoragePosManagerImpl implements IStoragePosManager { ...@@ -307,10 +307,10 @@ public class StoragePosManagerImpl implements IStoragePosManager {
return storagePosDao.getInventory(type,storageIds); return storagePosDao.getInventory(type,storageIds);
} }
@Override // @Override
public List<PLATE_SIZE> distinctPlateSize(String storageId) { // public List<PLATE_SIZE> distinctPlateSize(String storageId) {
return storagePosDao.distinctPlateSize(storageId); // return storagePosDao.distinctPlateSize(storageId);
} // }
@Override @Override
public StoragePos findOneLockPos(String partNumber, String lockId, Collection<String> excludePosIds){ public StoragePos findOneLockPos(String partNumber, String lockId, Collection<String> excludePosIds){
......
...@@ -308,7 +308,7 @@ public class FileUploadController extends BaseFormController { ...@@ -308,7 +308,7 @@ public class FileUploadController extends BaseFormController {
storagePosManager.save(storagePos); storagePosManager.save(storagePos);
} }
} }
dataCache.updateStorage(storage); dataCache.reloadStorage(storage);
String msg = "读取到["+list.size()+"]个位置信息:新增【"+newRowCount+"】更新【" +updateRowCount +"】"; String msg = "读取到["+list.size()+"]个位置信息:新增【"+newRowCount+"】更新【" +updateRowCount +"】";
log.info(msg); log.info(msg);
......
...@@ -85,13 +85,13 @@ public class StorageCloudUpdateController extends BaseUpdateController { ...@@ -85,13 +85,13 @@ public class StorageCloudUpdateController extends BaseUpdateController {
} else { } else {
try { try {
Storage storage = storageUpdateForm.getStorage(); Storage storage = storageUpdateForm.getStorage();
storage = dataCache.updateStorage(storage); storage = dataCache.reloadStorage(storage);
fileUpload.setParam(storage.getId()); fileUpload.setParam(storage.getId());
saveMessage(request, getText("storage.saveSuccess", request.getLocale())); saveMessage(request, getText("storage.saveSuccess", request.getLocale()));
return "redirect:storageUpdate.html?id="+storage.getId(); return "redirect:storageUpdate.html?id="+storage.getId();
} catch (ValidateException e) { } catch (Exception e) {
log.error(e); log.error(e);
String errormsg = getText(e.getMessage(), e.getParams(), request.getLocale()); String errormsg = getText(e.getMessage(), request.getLocale());
log.error(errormsg); log.error(errormsg);
saveError(request, errormsg); saveError(request, errormsg);
} }
......
...@@ -66,13 +66,13 @@ public class StorageUpdateController extends BaseUpdateController { ...@@ -66,13 +66,13 @@ public class StorageUpdateController extends BaseUpdateController {
return getSuccessView(); return getSuccessView();
} else { } else {
try { try {
dataCache.updateStorage(storage); dataCache.reloadStorage(storage);
//fileUpload.setParam(storage.getId()); //fileUpload.setParam(storage.getId());
saveMessage(request, getText("storage.saveSuccess", request.getLocale())); saveMessage(request, getText("storage.saveSuccess", request.getLocale()));
return "redirect:storageUpdate.html?id="+storage.getId(); return "redirect:storageUpdate.html?id="+storage.getId();
} catch (ValidateException e) { } catch (Exception e) {
log.error(e); log.error(e);
String errormsg = getText(e.getMessage(), e.getParams(), request.getLocale()); String errormsg = getText(e.getMessage(), request.getLocale());
log.error(errormsg); log.error(errormsg);
saveError(request, errormsg); saveError(request, errormsg);
} }
......
...@@ -107,7 +107,7 @@ public class StorageViewController extends BaseController{ ...@@ -107,7 +107,7 @@ public class StorageViewController extends BaseController{
} }
storagePosManager.insertAll(posList); storagePosManager.insertAll(posList);
dataCache.updateStorage(virtualStorage); dataCache.reloadStorage(virtualStorage);
return "保存成功"; return "保存成功";
......
...@@ -9,6 +9,7 @@ import com.google.common.collect.Maps; ...@@ -9,6 +9,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Multiset; import com.google.common.collect.Multiset;
import com.myproject.bean.CodeBean; import com.myproject.bean.CodeBean;
import com.myproject.bean.json.InventoryItem; import com.myproject.bean.json.InventoryItem;
import com.myproject.bean.json.PlateSizeBean;
import com.myproject.bean.update.*; import com.myproject.bean.update.*;
import com.myproject.dao.mongo.*; import com.myproject.dao.mongo.*;
import com.myproject.exception.ValidateException; import com.myproject.exception.ValidateException;
...@@ -521,27 +522,6 @@ public class DataCache{ ...@@ -521,27 +522,6 @@ public class DataCache{
return storageIds; return storageIds;
} }
public Map<String, Storage> getAllStorage(){
if(allStorage.isEmpty()){
synchronized (allStorage){
if(allStorage.isEmpty()){
List<Storage> all = storageManager.findAll();
if(all != null){
Map<String, Storage> map = new ConcurrentHashMap<>();
for(Storage storage : all){
List<PLATE_SIZE> plateSizes = storagePosManager.distinctPlateSize(storage.getId());
storage.setPlateSizes(plateSizes);
map.put(storage.getCid(), storage);
}
allStorage = map;
log.info("加载所有料仓["+all.size()+"]信息到缓存");
}
}
}
}
return allStorage;
}
/** /**
* 获取某区域可以放入该尺寸料盘的所有料仓名称 * 获取某区域可以放入该尺寸料盘的所有料仓名称
...@@ -576,24 +556,10 @@ public class DataCache{ ...@@ -576,24 +556,10 @@ public class DataCache{
return null; return null;
} }
/** public Storage reloadStorage(Storage storage){
* 更新料仓信息 List<PlateSizeBean> plateSizeBeanList = storagePosManager.getStoragePosUsage(storage.getId());
*/ storage.initUsage(plateSizeBeanList);
public Storage updateStorage(String cid) throws ValidateException { allStorage.put(storage.getCid(), storage);
Storage storage = getStorage(cid);
return updateStorage(storage);
}
/**
* 更新料仓信息
*/
public Storage updateStorage(Storage storage) throws ValidateException {
storage.setTotalSlots(storagePosManager.countTotalStorageSize(storage.getId()));
storage.setEmptySlots(storagePosManager.countEmptyStorageSize(storage.getId()));
storageManager.save(storage);
List<PLATE_SIZE> plateSizes = storagePosManager.distinctPlateSize(storage.getId());
storage.setPlateSizes(plateSizes);
getAllStorage().put(storage.getCid(), storage);
return storage; return storage;
} }
...@@ -701,7 +667,24 @@ public class DataCache{ ...@@ -701,7 +667,24 @@ public class DataCache{
/** /**
* 修改库存,出库为负,入库为正 * 修改库存,出库为负,入库为正
*/ */
public int updateInventory(String cid, String partNumber, int amount){ public int updateInventory(StoragePos pos, Barcode barcode){
Storage storage = getStorageById(pos.getStorageId());
String cid = storage.getCid();
String partNumber = barcode.getPartNumber();
int amount = 0;
String sizeStr = pos.getSizeStr();
if(pos.getBarcode() == null){
//出库
amount = - barcode.getAmount();
storage.emptyOnePos(pos);
}else{
//入库
amount = barcode.getAmount();
storage.useOnePos(pos);
}
allStorage.put(cid, storage);
if(amount != 0){ if(amount != 0){
InventoryItem inventoryItem = getStorageInventoryByPartNumber(cid,partNumber); InventoryItem inventoryItem = getStorageInventoryByPartNumber(cid,partNumber);
if(inventoryItem == null){ if(inventoryItem == null){
...@@ -735,4 +718,29 @@ public class DataCache{ ...@@ -735,4 +718,29 @@ public class DataCache{
return allBoxMap; return allBoxMap;
} }
public Map<String, Storage> getAllStorage(){
if(allStorage.isEmpty()){
synchronized (allStorage){
if(allStorage.isEmpty()){
List<Storage> all = storageManager.findAll();
if(all != null){
Map<String, Storage> map = new ConcurrentHashMap<>();
for(Storage storage : all){
List<PlateSizeBean> plateSizeBeanList = storagePosManager.getStoragePosUsage(storage.getId());
storage.initUsage(plateSizeBeanList);
map.put(storage.getCid(), storage);
}
allStorage = map;
log.info("加载所有料仓["+all.size()+"]信息到缓存");
}
}
}
}
return allStorage;
}
} }
...@@ -42,16 +42,14 @@ public class StatusController extends BaseController{ ...@@ -42,16 +42,14 @@ public class StatusController extends BaseController{
@ResponseBody @ResponseBody
public StatusBean readStatus(@RequestParam String cid, HttpServletRequest request) { public StatusBean readStatus(@RequestParam String cid, HttpServletRequest request) {
if(Strings.isNullOrEmpty(cid)){ if(Strings.isNullOrEmpty(cid)){
//cid = dataCache.defaultStorageCid(); cid = dataCache.defaultStorageCid();
} }
return getStatus(cid,request);
}
private StatusBean getStatus(String cid, HttpServletRequest request){
StatusBean statusBean = taskService.getStatus(cid); StatusBean statusBean = taskService.getStatus(cid);
// if(!Strings.isNullOrEmpty(statusBean.getMsgCode())){
// String localeMsg = getText("client."+statusBean.getMsgCode(),statusBean.getMsgParam(),request.getLocale(),statusBean.msg);
// statusBean.setMsg(localeMsg);
// statusBean.setMsgEn(localeMsg);
// }
//log.debug("Get cid: " + cid + " status: " + statusBean.getStatus() + " and error: " + statusBean.getError());
Exception e = taskService.getServerException(cid); Exception e = taskService.getServerException(cid);
if(e != null){ if(e != null){
if(e instanceof ValidateException){ if(e instanceof ValidateException){
...@@ -63,9 +61,32 @@ public class StatusController extends BaseController{ ...@@ -63,9 +61,32 @@ public class StatusController extends BaseController{
statusBean.setMsgEn(e.getMessage()); statusBean.setMsgEn(e.getMessage());
} }
} }
//log.debug("Get cid: " + cid + " status: " + statusBean.getStatus() + " and error: " + statusBean.getError());
return statusBean; return statusBean;
} }
@RequestMapping(value = "/statusList")
@ResponseBody
public List<StatusBean> statusList(HttpServletRequest request){
String cids = request.getParameter("cids");
Collection<String> cidList;
if(Strings.isNullOrEmpty(cids)){
cidList = dataCache.getAllStorage().keySet();
}else{
cidList = Lists.newArrayList(cids.split(","));
}
List<StatusBean> statusList = Lists.newArrayList();
for (String cid : cidList) {
if(cid.isEmpty()){
continue;
}
StatusBean statusBean = getStatus(cid, request);
statusList.add(statusBean);
}
return statusList;
}
@RequestMapping(value = "/latestStatus") @RequestMapping(value = "/latestStatus")
@ResponseBody @ResponseBody
......
...@@ -607,18 +607,6 @@ public class StorageDataController extends BaseController { ...@@ -607,18 +607,6 @@ public class StorageDataController extends BaseController {
return componentList.getList(); return componentList.getList();
} }
@RequestMapping("/getStorageUseage")
@ResponseBody
public List<PlateSizeBean> getStorageUseage(HttpServletRequest request, HttpServletResponse response){
String cid = request.getParameter("cid");
Storage storage = dataCache.getStorage(cid);
if(storage == null){
return null;
}
String storageId = storage.getId();
return storagePosManager.getStoragePosUsage(storageId);
}
@RequestMapping("/deviceInfos") @RequestMapping("/deviceInfos")
@ResponseBody @ResponseBody
...@@ -716,4 +704,32 @@ public class StorageDataController extends BaseController { ...@@ -716,4 +704,32 @@ public class StorageDataController extends BaseController {
out.close(); out.close();
} }
@RequestMapping("/getStorage")
@ResponseBody
public Storage getStorageUseage(HttpServletRequest request, HttpServletResponse response){
String cid = request.getParameter("cid");
return dataCache.getStorage(cid);
}
@RequestMapping("/storageList")
@ResponseBody
public Collection<Storage> usageMap(HttpServletRequest request, HttpServletResponse response){
String cids = request.getParameter("cids");
Collection<Storage> storageList = null;
if(Strings.isNullOrEmpty(cids)){
storageList = dataCache.getAllStorage().values();
}else{
storageList = new ArrayList<>();
for (String cid : Lists.newArrayList(cids.split(","))) {
Storage storage = dataCache.getStorage(cid);
if(storage == null){
continue;
}
storageList.add(storage);
}
}
return storageList;
}
} }
...@@ -1416,8 +1416,9 @@ public class TaskService implements ITaskService { ...@@ -1416,8 +1416,9 @@ public class TaskService implements ITaskService {
task.setNum(barcode.getAmount()); task.setNum(barcode.getAmount());
task.setMemo(barcode.getMemo()); task.setMemo(barcode.getMemo());
dataCache.updateInventory(task.getCid(), barcode.getPartNumber(),barcode.getAmount()); //dataCache.updateInventory(task.getCid(), barcode.getPartNumber(),barcode.getAmount());
dataCache.updateStorage(task.getCid()); //dataCache.updateStorage(task.getCid());
dataCache.updateInventory(pos, barcode);
}else{ }else{
barcode = pos.getBarcode(); barcode = pos.getBarcode();
...@@ -1435,8 +1436,10 @@ public class TaskService implements ITaskService { ...@@ -1435,8 +1436,10 @@ public class TaskService implements ITaskService {
storagePosManager.save(pos); storagePosManager.save(pos);
dataCache.updateInventory(task.getCid(), barcode.getPartNumber(), - barcode.getAmount()); //dataCache.updateInventory(task.getCid(), barcode.getPartNumber(), - barcode.getAmount());
dataCache.updateStorage(task.getCid()); //dataCache.updateStorage(task.getCid());
dataCache.updateInventory(pos, barcode);
} }
...@@ -1574,9 +1577,10 @@ public class TaskService implements ITaskService { ...@@ -1574,9 +1577,10 @@ public class TaskService implements ITaskService {
//更新缓存中的库存信息 //更新缓存中的库存信息
int stockReel = dataCache.updateInventory(task.getCid(), componentBarcode.getPartNumber(),componentBarcode.getAmount()); //int stockReel = dataCache.updateInventory(task.getCid(), componentBarcode.getPartNumber(),componentBarcode.getAmount());
int stockReel = dataCache.updateInventory(storagePos,componentBarcode);
dataCache.updateStorage(task.getCid()); //dataCache.updateStorage(task.getCid());
log.info("入库"+componentBarcode.getPartNumber()+"["+componentBarcode.getBarcode()+"]当前库存:"+stockReel+"到"+componentPos.getPosName()+"可出库时间:"+new Date(canCheckOutTime)); log.info("入库"+componentBarcode.getPartNumber()+"["+componentBarcode.getBarcode()+"]当前库存:"+stockReel+"到"+componentPos.getPosName()+"可出库时间:"+new Date(canCheckOutTime));
componentPos.setBarcode(componentBarcode); componentPos.setBarcode(componentBarcode);
...@@ -1609,9 +1613,10 @@ public class TaskService implements ITaskService { ...@@ -1609,9 +1613,10 @@ public class TaskService implements ITaskService {
storagePosManager.save(storagePos); storagePosManager.save(storagePos);
//更新缓存中的库存信息 //更新缓存中的库存信息
dataCache.updateInventory(task.getCid(), task.getPartNumber(),barcode.getAmount()); //dataCache.updateInventory(task.getCid(), task.getPartNumber(),barcode.getAmount());
dataCache.updateInventory(storagePos,barcode);
dataCache.updateStorage(task.getCid()); //dataCache.updateStorage(task.getCid());
Storage storage = dataCache.getStorage(task.getCid()); Storage storage = dataCache.getStorage(task.getCid());
if(storage != null){ if(storage != null){
...@@ -1717,9 +1722,10 @@ public class TaskService implements ITaskService { ...@@ -1717,9 +1722,10 @@ public class TaskService implements ITaskService {
storagePosManager.save(storagePos); storagePosManager.save(storagePos);
log.info("出库完成,清空仓位: " + storagePos.getId() + "[" + storagePos.getPosName() + "]"); log.info("出库完成,清空仓位: " + storagePos.getId() + "[" + storagePos.getPosName() + "]");
dataCache.updateStorage(task.getCid()); //dataCache.updateStorage(task.getCid());
//更新缓存中的库存信息 //更新缓存中的库存信息
dataCache.updateInventory(task.getCid(), task.getPartNumber(),0-task.getNum()); //dataCache.updateInventory(task.getCid(), task.getPartNumber(),0-task.getNum());
dataCache.updateInventory(storagePos,barcode);
//通知消息 //通知消息
...@@ -1739,7 +1745,7 @@ public class TaskService implements ITaskService { ...@@ -1739,7 +1745,7 @@ public class TaskService implements ITaskService {
finishedTaskMap.put(task.getBarcode(),task); finishedTaskMap.put(task.getBarcode(),task);
//notifyTask(task); //notifyTask(task);
dataCache.updateStorage(task.getCid()); //dataCache.updateStorage(task.getCid());
finishedOrderTask(task); finishedOrderTask(task);
//checkTaskSetFinished(task); //checkTaskSetFinished(task);
......
...@@ -746,41 +746,19 @@ ...@@ -746,41 +746,19 @@
return html; return html;
} }
//刷新库存情况
var maxItemCount = 0; function flushUsageItem(){
function flushUsageItem(cid){ $.post("${ctx}/service/store/storageList", {cids:"${cids}"}, function (storageList) {
$.post("${ctx}/service/store/getStorageUseage", {cid: cid}, function (data) { for(var i in storageList){
var sizeData = {}; var storage = storageList[i];
var itemCount = 0; var sizeData = storage.usageMap;
for(var i in data){
itemCount = itemCount + 1;
var itemData = data[i];
var sizeItem = sizeData[itemData.sizeStr];
if(!sizeItem){
sizeItem = {};
sizeItem["w"] = itemData.plateSize.w;
sizeItem["h"] = itemData.plateSize.h;
sizeItem["usedCount"] = 0;
sizeItem["idleCount"] = 0;
}
if(itemData.plateSize.used){
sizeItem["usedCount"] = itemData.count;
}else{
sizeItem["idleCount"] = itemData.count;
}
sizeData[itemData.sizeStr] = sizeItem;
}
if(itemCount > maxItemCount){
maxItemCount = itemCount;
}
var sizeList = new Array(); var sizeList = new Array();
for(var sizeStr in sizeData){ for(var sizeStr in sizeData){
var item = sizeData[sizeStr]; sizeList.push(sizeData[sizeStr]);
item["sizeStr"] = sizeStr;
sizeList.push(item);
} }
sizeList.sort(function(a,b){ sizeList.sort(function(a,b){
var w1 = a.w,w2 = b.w; var w1 = a.w,w2 = b.w;
if(w1 === w2){ if(w1 === w2){
...@@ -789,12 +767,12 @@ ...@@ -789,12 +767,12 @@
return w1 - w2; return w1 - w2;
}); });
var totalCount = 0; var cid = storage.cid;
for(var i in sizeList){ for(var i in sizeList){
var sizeItem = sizeList[i]; var sizeItem = sizeList[i];
var sizeStr = sizeItem["sizeStr"]; var sizeStr = sizeItem.sizeStr;
totalCount = totalCount + sizeItem["usedCount"] + sizeItem["idleCount"]; var idleCount = sizeItem.totalCount - sizeItem.usedCount;
var html = getItemBar(sizeItem["w"],sizeItem["h"],sizeItem["usedCount"],sizeItem["idleCount"]); var html = getItemBar(sizeItem["w"],sizeItem["h"],sizeItem["usedCount"],idleCount);
var sizeDom = $("#"+cid+" ."+sizeStr); var sizeDom = $("#"+cid+" ."+sizeStr);
if(sizeDom.length == 0){ if(sizeDom.length == 0){
...@@ -803,6 +781,26 @@ ...@@ -803,6 +781,26 @@
sizeDom.html(html); sizeDom.html(html);
} }
} }
}
var allContent = $(".task-content");
allContent.each(function(index){
if(index % 2 == 1){
var height = $(this).attr("style");
if(height){
return;
}
var itemCount = $(this).children(".itembox").size();
var lastContent = allContent.eq(index -1);
var lastItemCount = lastContent.children(".itembox").size();
if(itemCount < lastItemCount){
itemCount = lastItemCount;
}
$(this).attr("style","height:"+itemCount*34+"px;");
lastContent.attr("style","height:"+itemCount*34+"px;");
}
});
}); });
} }
...@@ -825,8 +823,11 @@ ...@@ -825,8 +823,11 @@
}; };
function flushStatus(cid){ function flushStatus(){
$.get('${ctx}/service/store/status?cid='+cid, function (statusBean) { $.post('${ctx}/service/store/statusList', {cids: "${cids}"}, function (list) {
for(var i in list){
var statusBean = list[i];
var cid = statusBean.cid;
if(statusBean && statusBean.boxStatus["1"]){ if(statusBean && statusBean.boxStatus["1"]){
var boxStatusBean = statusBean.boxStatus["1"]; var boxStatusBean = statusBean.boxStatus["1"];
var statusTxt = statusMsg[boxStatusBean.status]; var statusTxt = statusMsg[boxStatusBean.status];
...@@ -862,9 +863,13 @@ ...@@ -862,9 +863,13 @@
$("#"+cid+" .boxtemperature").html("${temperature_label}:--"); $("#"+cid+" .boxtemperature").html("${temperature_label}:--");
$("#"+cid+" .boxhumidity").html("${humidity_label}:--"); $("#"+cid+" .boxhumidity").html("${humidity_label}:--");
} }
}
}); });
} }
function showAlarmWindow(alarmWindow, title, msg){ function showAlarmWindow(alarmWindow, title, msg){
var windowOptions = { var windowOptions = {
delay: false, delay: false,
...@@ -1041,11 +1046,12 @@ ...@@ -1041,11 +1046,12 @@
}, 2000); }, 2000);
setInterval(function(){ setInterval(function(){
flushUsageItem();
flushStatus();
var hasTask = false; var hasTask = false;
<c:forEach items="${allStorage}" var="storage"> <c:forEach items="${allStorage}" var="storage">
var cid = '${storage.cid}'; var cid = '${storage.cid}';
updateTasks(cid); updateTasks(cid);
flushUsageItem(cid);
var cidTasks = allTasks[cid]; var cidTasks = allTasks[cid];
if(cidTasks){ if(cidTasks){
var taskCount = Object.getOwnPropertyNames(cidTasks).length; var taskCount = Object.getOwnPropertyNames(cidTasks).length;
...@@ -1061,16 +1067,8 @@ ...@@ -1061,16 +1067,8 @@
$(".box").parent().attr("class", "col-md-6 col-sm-6 "); $(".box").parent().attr("class", "col-md-6 col-sm-6 ");
$(".box").parent().attr("style", ""); $(".box").parent().attr("style", "");
} }
$(".task-content").attr("style","height:"+maxItemCount*34+"px;");
}, 1000); }, 1000);
setInterval(function(){
<c:forEach items="${allStorage}" var="storage">
var cid = '${storage.cid}';
flushStatus(cid);
</c:forEach>
}, 1000);
}); });
</script> </script>
......
...@@ -483,48 +483,16 @@ ...@@ -483,48 +483,16 @@
} }
function flushUsageItem(){ function flushUsageItem(){
$.post("${ctx}/service/store/getStorageUseage", {cid: '${show}'}, function (data) { $.post("${ctx}/service/store/getStorage", {cid: '${show}'}, function (storage) {
if(!isLimitOpt(data)){ if(!isLimitOpt(storage)){
var sizeData = {}; var sizeData = storage.usageMap;
for(var i in data){
var itemData = data[i];
var sizeItem = sizeData[itemData.sizeStr];
if(!sizeItem){
sizeItem = {};
sizeItem["w"] = itemData.plateSize.w;
sizeItem["h"] = itemData.plateSize.h;
sizeItem["usedCount"] = 0;
sizeItem["idleCount"] = 0;
}
if(itemData.plateSize.used){
sizeItem["usedCount"] = itemData.count;
}else{
sizeItem["idleCount"] = itemData.count;
}
sizeData[itemData.sizeStr] = sizeItem;
}
var sizeList = new Array(); var cid = storage.cid;
var totalCount = storage.totalSlots;
for(var sizeStr in sizeData){ for(var sizeStr in sizeData){
var item = sizeData[sizeStr]; var sizeItem = sizeData[sizeStr];
item["sizeStr"] = sizeStr; var idleCount = sizeItem.totalCount - sizeItem.usedCount;
sizeList.push(item); var html = getItemBar(sizeItem["w"],sizeItem["h"],sizeItem["usedCount"],idleCount);
}
sizeList.sort(function(a,b){
var w1 = a.w,w2 = b.w;
if(w1 === w2){
return a.h - b.h;
}
return w1 - w2;
});
var totalCount = 0;
for(var i in sizeList){
var sizeItem = sizeList[i];
var sizeStr = sizeItem["sizeStr"];
totalCount = totalCount + sizeItem["usedCount"] + sizeItem["idleCount"];
var html = getItemBar(sizeItem["w"],sizeItem["h"],sizeItem["usedCount"],sizeItem["idleCount"]);
var sizeDom = $("#"+sizeStr); var sizeDom = $("#"+sizeStr);
if(sizeDom.length == 0){ if(sizeDom.length == 0){
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!