Commit d1d1cd0f LN

增加po类及对应的dao接口和实现类,utils中增加Constants,DateUtil,PLATE_SIZE,StorageConstants

1 个父辈 93e6eae8
正在显示 43 个修改的文件 包含 2652 行增加0 行删除
package com.neotel.smfcore.common.utils;
public class Constants {
private Constants() {
// hide me
}
//~ Static fields/initializers =============================================
/**
* Assets Version constant
*/
public static final String ASSETS_VERSION = "assetsVersion";
/**
* The name of the ResourceBundle used in this application
*/
public static final String BUNDLE_KEY = "ApplicationResources";
/**
* File separator from System properties
*/
public static final String FILE_SEP = System.getProperty("file.separator");
/**
* User home from System properties
*/
public static final String USER_HOME = System.getProperty("user.home") + FILE_SEP;
/**
* The name of the configuration hashmap stored in application scope.
*/
public static final String CONFIG = "appConfig";
/**
* Session scope attribute that holds the locale set by the user. By setting this key
* to the same one that Struts uses, we get synchronization in Struts w/o having
* to do extra work or have two session-level variables.
*/
public static final String PREFERRED_LOCALE_KEY = "PREFERRED_LOCALE";
/**
* The request scope attribute under which an editable user form is stored
*/
public static final String USER_KEY = "userForm";
/**
* The request scope attribute that holds the user list
*/
public static final String USER_LIST = "userList";
/**
* The request scope attribute for indicating a newly-registered user
*/
public static final String REGISTERED = "registered";
/**
* The name of the Administrator role, as specified in web.xml
*/
// public static final String ADMIN_ROLE = "ROLE_ADMIN";
//
// /**
// * The name of the User role, as specified in web.xml
// */
// public static final String USER_ROLE = "ROLE_USER";
/**
* The name of the user's role list, a request-scoped attribute
* when adding/editing a user.
*/
public static final String USER_ROLES = "userRoles";
/**
* The name of the available roles list, a request-scoped attribute
* when adding/editing a user.
*/
public static final String AVAILABLE_ROLES = "availableRoles";
/**
* The name of the CSS Theme setting.
* @deprecated No longer used to set themes.
*/
public static final String CSS_THEME = "csstheme";
}
package com.neotel.smfcore.common.utils;
import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.i18n.LocaleContextHolder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class DateUtil {
private static Log log = LogFactory.getLog(DateUtil.class);
private static final String TIME_PATTERN = "HH:mm";
/**
* Checkstyle rule: utility classes should not have public constructor
*/
private DateUtil() {
}
/**
* Return default datePattern (MM/dd/yyyy)
*
* @return a string representing the date pattern on the UI
*/
public static String getDatePattern() {
Locale locale = LocaleContextHolder.getLocale();
String defaultDatePattern;
try {
defaultDatePattern = ResourceBundle.getBundle(Constants.BUNDLE_KEY, locale)
.getString("date.format");
} catch (MissingResourceException mse) {
defaultDatePattern = "MM/dd/yyyy";
}
return defaultDatePattern;
}
public static String getDateTimePattern() {
return DateUtil.getDatePattern() + " HH:mm:ss";
}
public static String toDateTimeString(Date aDate) {
return toDateString(aDate, getDateTimePattern());
}
public static String toDateString(Date aDate) {
return toDateString(aDate,getDatePattern());
}
public static String toDateString(long time, String aMask){
return toDateString(new Date(time),aMask);
}
public static String toDateString(Date aDate, String aMask) {
SimpleDateFormat df = null;
String returnValue = "";
if (aDate == null) {
log.warn("aDate is null!");
} else {
df = new SimpleDateFormat(aMask);
returnValue = df.format(aDate);
}
return (returnValue);
}
public static Date toDate(final String strDate) throws ParseException {
return toDate(strDate, getDatePattern());
}
public static Date toDate(String strDate,String aMask)
throws ParseException {
SimpleDateFormat df;
Date date;
df = new SimpleDateFormat(aMask);
if (log.isDebugEnabled()) {
log.debug("converting '" + strDate + "' to date with mask '" + aMask + "'");
}
try {
date = df.parse(strDate);
} catch (ParseException pe) {
//log.error("ParseException: " + pe);
throw new ParseException(pe.getMessage(), pe.getErrorOffset());
}
return (date);
}
/**
* 获取距离今天dayFromToday 天的不带时间的日期(今天是0,昨天是-1,明天是1)
*/
public static Date getNoTimeFromToday(int dayFromToday){
Calendar c = noTimeCalendar();
c.add(Calendar.DAY_OF_YEAR, dayFromToday);
return c.getTime();
}
private static Calendar noTimeCalendar(){
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND,0);
c.set(Calendar.MILLISECOND, 0);
return c;
}
/**
* 获取本周的第一天
*/
public static Date getFirstDayOfThisWeek(){
Calendar c = noTimeCalendar();
c.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
return c.getTime();
}
/**
* 将日期添加一天,时间设置为00:00:00
*/
public static Date addOneDayNoTime(Date date){
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND,0);
c.set(Calendar.MILLISECOND, 0);
c.add(Calendar.DAY_OF_YEAR, 1);
return c.getTime();
}
/**
* 日期+天数
* @param date
* @param days
* @return
*/
public static Date addDays(Date date, int days){
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DAY_OF_YEAR, days);
return c.getTime();
}
public static Date getMinDate(Date date0, Date date1){
return date0.before(date1)? date0 : date1;
}
public static Date getMaxDate(Date date0, Date date1){
return date0.after(date1)? date0 : date1;
}
public static class Req{
private String seq;
private int op;
private int step;
private Map<String,String> data;
public String getSeq() {
return seq;
}
public void setSeq(String seq) {
this.seq = seq;
}
public int getOp() {
return op;
}
public void setOp(int op) {
this.op = op;
}
public int getStep() {
return step;
}
public void setStep(int step) {
this.step = step;
}
public Map<String, String> getData() {
return data;
}
public void setData(Map<String, String> data) {
this.data = data;
}
}
public static void main(String args[]) throws Exception {
// Req req = new Req();
// req.setSeq("111");
// req.setOp(1);
// req.setStep(1);
// Map<String,String> codeMap = Maps.newHashMap();
// codeMap.put("CODEBBB","0");
// req.setData(codeMap);
//
// ObjectMapper mapper = new ObjectMapper();
// String json = mapper.writeValueAsString(req);
// System.out.println(json);
// CsvWriter csvWriter = new CsvWriter("/Volumes/SSD/code/storage/def.csv");
// csvWriter.writeRecord(new String[]{"AE","B","C","D"});
// csvWriter.flush();
// csvWriter.close();
String doors = "3-2|";
List<String> theDoorOpened = Lists.newArrayList(doors.split("\\|"));
if(theDoorOpened.contains("3-2")){
System.out.println("------");
};
}
}
package com.neotel.smfcore.common.utils;
import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
public class PLATE_SIZE {
/**
* 7英寸 x 8毫米
*/
public static PLATE_SIZE R7_H8 = new PLATE_SIZE(7, 8);
public static PLATE_SIZE R7_H15 = new PLATE_SIZE(7, 12);
public static PLATE_SIZE R13_H8 = new PLATE_SIZE(13, 8);
public static PLATE_SIZE R13_H12 = new PLATE_SIZE(13, 12);
public static PLATE_SIZE R13_H16 = new PLATE_SIZE(13, 16);
public static PLATE_SIZE R13_H24 = new PLATE_SIZE(13, 24);
public static PLATE_SIZE R13_H32 = new PLATE_SIZE(13, 32);
//TRAY盘
public static PLATE_SIZE TRAY13_H75 = new PLATE_SIZE("", 320, 75);
public static PLATE_SIZE TRAY13_H105 = new PLATE_SIZE("", 320, 105);
public static PLATE_SIZE R15_H16 = new PLATE_SIZE(15, 16);
public static PLATE_SIZE R15_H24 = new PLATE_SIZE(15, 24);
public static PLATE_SIZE R15_H32 = new PLATE_SIZE(15, 32);
//管状料 宽500 高70
public static PLATE_SIZE W500_H70 = new PLATE_SIZE("", 500, 70);
/**
* 自宝义
*/
public static PLATE_SIZE CUSTOMER = new PLATE_SIZE("自定义", -1, -1);
private static List<PLATE_SIZE> all = Lists.newArrayList(R7_H8, R7_H15, R13_H12, R13_H16, R13_H24, R13_H32, TRAY13_H75, TRAY13_H105, R15_H16, R15_H16, R15_H24, R15_H32, W500_H70, CUSTOMER);
public static List<PLATE_SIZE> values() {
return all;
}
PLATE_SIZE(){
}
PLATE_SIZE(int w, int h) {
this.w = w;
this.h = h;
}
PLATE_SIZE(String name, int w, int h) {
this.w = w;
this.h = h;
this.name = name;
}
public static PLATE_SIZE fromWH(int w, int h) {
for (PLATE_SIZE ps : PLATE_SIZE.values()) {
if (ps.getW() == w && ps.getH() == h) {
return ps;
}
}
return CUSTOMER;
}
private String name = "";
/**
* 用于统计料仓使用情况
*/
@Getter @Setter
private boolean used = false;
/**
* 尺寸(几寸盘)
*/
@Getter @Setter
private int w;
/**
* 盘高度
*/
@Getter @Setter
private int h;
public String getSizeStr(){
return w + "x" + h;
}
/**
* 展示
*/
public String getShowStr() {
if(CUSTOMER.equals(this)){
return name;
}
return name + " " + w + " x " + h;
}
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface IAlarmInfoDao extends IBaseDao {
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface IBarcodeDao extends IBaseDao {
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
import com.neotel.smfcore.security.service.po.Component;
import java.util.List;
public interface IComponentDao extends IBaseDao {
List<Component> findByType(int type);
List<String> distinctPcbFamily();
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface IDataLogDao extends IBaseDao {
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface IHumitureDao extends IBaseDao {
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface ILiteOrderDao extends IBaseDao {
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
import com.neotel.smfcore.security.service.po.LiteOrderItem;
import java.util.List;
public interface ILiteOrderItemDao extends IBaseDao {
List<LiteOrderItem> findByOrderNo(String orderNo);
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
import com.neotel.smfcore.security.service.po.Maintenance;
public interface IMaintenanceDao extends IBaseDao {
Maintenance findByCid(String cid);
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface ISettingsDao extends IBaseDao {
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface IStorageDao extends IBaseDao {
}
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface IStoragePosDao extends IBaseDao {
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.IAlarmInfoDao;
import com.neotel.smfcore.security.service.po.AlarmInfo;
public class AlarmInfoDaoImpl extends AbstractBaseDao implements IAlarmInfoDao {
@Override
public Class getEntityClass() {
return AlarmInfo.class;
}
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.IBarcodeDao;
import com.neotel.smfcore.security.service.po.Barcode;
public class BarcodeDaoImpl extends AbstractBaseDao implements IBarcodeDao {
@Override
public Class getEntityClass() {
return Barcode.class;
}
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.IComponentDao;
import com.neotel.smfcore.security.service.po.Component;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import java.util.List;
public class ComponentDaoImpl extends AbstractBaseDao implements IComponentDao {
@Override
public Class getEntityClass() {
return Component.class;
}
@Override
public List<Component> findByType(int type) {
Criteria c = Criteria.where("type").is(type);
return findByQuery(new Query(c));
}
@Override
public List<String> distinctPcbFamily() {
return null;
}
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.IDataLogDao;
import com.neotel.smfcore.security.service.po.DataLog;
public class DataLogDaoImpl extends AbstractBaseDao implements IDataLogDao {
@Override
public Class getEntityClass() {
return DataLog.class;
}
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.IHumitureDao;
import com.neotel.smfcore.security.service.po.Humiture;
public class HumitureDaoImpl extends AbstractBaseDao implements IHumitureDao {
@Override
public Class getEntityClass() {
return Humiture.class;
}
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.ILiteOrderDao;
import com.neotel.smfcore.security.service.po.LiteOrder;
public class LiteOrderDaoImpl extends AbstractBaseDao implements ILiteOrderDao {
@Override
public Class getEntityClass() {
return LiteOrder.class;
}
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.ILiteOrderItemDao;
import com.neotel.smfcore.security.service.po.LiteOrderItem;
import java.util.List;
public class LiteOrderItemDaoImpl extends AbstractBaseDao implements ILiteOrderItemDao {
@Override
public Class getEntityClass() {
return LiteOrderItem.class;
}
@Override
public List<LiteOrderItem> findByOrderNo(String orderNo) {
return findListByCondition(new String[]{"orderNo"}, new String[]{orderNo});
}
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.IMaintenanceDao;
import com.neotel.smfcore.security.service.po.Maintenance;
import org.springframework.stereotype.Service;
@Service
public class MaintenanceDaoImpl extends AbstractBaseDao implements IMaintenanceDao {
@Override
public Class getEntityClass() {
return Maintenance.class;
}
@Override
public Maintenance findByCid(String cid) {
return super.findOneByCondition(new String[] {"storageCid"}, new String[] {cid});
}
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.ISettingsDao;
import com.neotel.smfcore.security.service.po.Settings;
import org.springframework.stereotype.Service;
@Service
public class SettingsDaoImpl extends AbstractBaseDao implements ISettingsDao {
@Override
public Class getEntityClass() {
return Settings.class;
}
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.IStorageDao;
import com.neotel.smfcore.security.service.po.Storage;
public class StorageDaoImpl extends AbstractBaseDao implements IStorageDao {
@Override
public Class getEntityClass() {
return Storage.class;
}
}
package com.neotel.smfcore.security.service.po;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
import java.util.Date;
@Data
@Document
public class AlarmInfo extends BasePo implements Serializable {
/**
* 料仓名称
*/
private String storageName;
/// <summary>
/// 料仓ID,0表示流水线
/// </summary>
private String boxId;
/// <summary>
/// 报警类型,
/// </summary>
private String alarmType;
/// <summary>
/// 报警详情
/// </summary>
private String alarmDetail;
/// <summary>
/// 报警消息
/// </summary>
private String alarmMsg;
/// <summary>
/// 报警消息(英文)
/// </summary>
private String alarmMsgEn;
/// <summary>
/// 0,1=入库,2=出库
/// </summary>
private String inOutStatus;
/**
* 开始时间
*/
private Date startTime;
/**
* 结束时间
*/
private Date endTime;
}
package com.neotel.smfcore.security.service.po;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.StorageConstants;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
@Document
public class Barcode extends BasePo implements Serializable {
private String barcode;
/**
* 物料类型:PCB,锡膏,或其他
*/
private int type = StorageConstants.COMPONENT_TYPE.COMPONENT;
//锡膏回温时间,小于回温时间不可出库
private int warmTime = 0;
/**
* 搅拌时间(分钟)
*/
private int mixTime = 0;
private float maxStorageTime = 0;
/**
* 过期时间(入库时间+最大存储时间)
*/
private Date expTime;
/**
* 过期状态,-1未入库0在库,1已出库正常,2已出库且已过期
*/
private int status = StorageConstants.BARCODE_STATUS.NEW;
/**
* 锡膏状态
*/
private int solderStatus = StorageConstants.SOLDER_STATUS.NONE;
/**
* 锡膏指定时间出库
*/
private Date needOutDate;
//private int componentType = 0;
private String partNumber;
//"供应商编号"
private String providerNumber;
private int initialAmount;
private int amount;
/**
* 标签解析出来的数量,用于判断条码是否是重新打印的,重新打印的条码需要重新设置数量
*/
private int labelAmount = 0;
private int plateSize;
private int height;
private String provider;
private String batch;
private String msl;
//备用字段1(配套单号))或 family
private String otherField1;
//备用字段2 (产品型号)
private String otherField2;
//备用字段3 (组件型号)
private String otherField3;
//备用字段4 (元器件型号)
private String otherField4;
//备用字段5 (检验编号)
private String otherField5;
//备用字段5 (备注)
private String otherField6;
/**
* 包装上带的过期时间
*/
private Date expireDate;
private boolean used = false;
//备注信息
private String memo;
/**
* 库位信息
*/
private String posName;
/**
* 只能单盘出库
*/
private boolean onlySingleOut = false;
/**
* 贴片机补料信息
*/
private String nextBarcode;
/**
* 第一次入库时间戳
*/
private long putInTime = -1;
/**
* 开始回温时间
*/
private long startWarmTime = -1;
/**
* 入库时间
*/
private Date putInDate;
/**
* 入库操作人
*/
private String inOpor;
/**
* 出库操作人
*/
private String outOpor;
/**
* 最后一次出库的时间
*/
private Date checkOutDate;
/**
* 关联条码,夹具时关联相关的物料,用于入库完成时插入相关物料
*/
@Transient
private List<String> relationCodes;
/**
* 是否是锡膏
*/
public boolean isSolder(){
return type == StorageConstants.COMPONENT_TYPE.SOLDERPASTE;
}
public List<String> getRelationCodes() {
if (relationCodes == null) {
return Lists.newArrayList();
}
return relationCodes;
}
/**
* 上次使用时间(出入库时更改)
*/
private Date usedDate;
/**
* 使用次数(入库后+1)
*/
private int usedCount = 0;
/**
* 生产日期
*/
private Date produceDate;
/**
* 锁定ID(目前只有指定批次会锁定)
*/
private String lockId;
/**
* 添加相关联条码
*
* @param relationCode
*/
public void addRelationCode(String relationCode) {
if (relationCodes == null) {
relationCodes = Lists.newArrayList();
}
relationCodes.add(relationCode);
}
public long getPutInTime() {
return putInTime;
}
public void setPutInTime(long putInTime) {
if(this.putInTime == -1){
this.putInTime = putInTime;
this.putInDate = new Date(putInTime);
}
status = StorageConstants.BARCODE_STATUS.IN_STORE;
updateExpTime();
}
public Date getPutInDate() {
return putInDate;
}
public String getPutInDateStr(){
if(putInDate == null){
return "";
}
return DateUtil.toDateTimeString(putInDate);
}
public void setPutInDate(Date putInDate) {
this.putInDate = putInDate;
}
private void updateExpTime(){
if(expTime == null && maxStorageTime != 0F && putInTime != -1){
Float maxStorageTimeMill = maxStorageTime * 60 * 60 * 1000;
expTime = new Date(putInTime + maxStorageTimeMill.longValue());
if(expireDate != null){
//如果是在包装上的过期时间之前,使用包装上的过期时间
if(expireDate.getTime()< expTime.getTime()){
expTime = expireDate;
}
}
}
}
/**
* 到达回温的时间
*/
public long getReachWarmTime(){
long reachWarmTime = System.currentTimeMillis();
if(StorageConstants.COMPONENT_TYPE.SOLDERPASTE == type && putInTime != -1){
reachWarmTime = putInTime + warmTime * 60 * 60 * 1000;
}
return reachWarmTime;
}
/**
* 是否达到回温时间,只有锡膏才需要判定
*/
public boolean isReachedWarmTime(){
return getReachWarmTime() <= System.currentTimeMillis();
}
public long getInStoreHour(){
if(putInTime != -1){
return (System.currentTimeMillis() - putInTime) / 60 / 60 / 1000;
}
return 0;
}
public long getInStoreMiniute(){
if(putInTime != -1){
long minutes = (System.currentTimeMillis() - getPutInTime()) / 60000 % 60;
if(minutes == 0){
if(getInStoreHour() == 0){
minutes = 1;
}
}
return minutes;
}
return 0;
}
public void setCheckOutDate(Date checkOutDate, String opor) {
this.checkOutDate = checkOutDate;
this.outOpor = opor;
if(checkOutDate != null){//出库时判断是否过期
updateExpTime();
if(expTime != null && checkOutDate.after(expTime)){
//过期时间小于出库时间,说明出库的时候已经过期了
status = StorageConstants.BARCODE_STATUS.OUT_EXPIRED;
}else{
status = StorageConstants.BARCODE_STATUS.OUT_NORMAL;
}
}
}
public void setInOpor(String inOpor) {
if(putInTime == -1){
this.inOpor = inOpor;
}
}
public int getSolderStatus() {
if(solderStatus == StorageConstants.SOLDER_STATUS.REWARMING){
//如果状态是回温中,且回温时间已经大于warmTime,修改状态为待搅拌
long now = System.currentTimeMillis();
if(startWarmTime - now > warmTime * 60 * 60 * 1000){
solderStatus = StorageConstants.SOLDER_STATUS.TO_BE_MIXED;
}
}
return solderStatus;
}
public String getNeedOutDateStr(){
if(needOutDate == null){
return "";
}
return DateUtil.toDateTimeString(needOutDate);
}
public String getExpireDateStr(){
if(expireDate != null){
return DateUtil.toDateString(expireDate);
}
return "";
}
/**
* 是否已过期
*/
public boolean isExpired(){
if(expireDate != null){
return expireDate.before(new Date());
}
return false;
}
/**
* 是否即将(3天内)过期,已过期后,此字段变为false
*/
public boolean isWillExpired(){
if(isExpired()){
return false;
}
if(expireDate != null){
return expireDate.before(DateUtil.addDays(new Date(),3));
}
return false;
}
}
package com.neotel.smfcore.security.service.po;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.sun.istack.internal.NotNull;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
@Data
@Document
@NoArgsConstructor
public class Component extends BasePo implements Serializable {
/**
* 产品类型:0元器件,1锡膏2PCB3其他4夹具
*/
private int type = StorageConstants.COMPONENT_TYPE.COMPONENT;
/**
* 产品型号
*/
private String model;
//元器件型号
private String productionType;
//"封装"/组件型号
private String encapsulation;
/**
* 冰箱存储条件
*/
private int storageCondition;
/**
* 室温最多存储时间
*/
private int maxStorageTime;
/**
* 回温时间
*/
private int warmTime;
/**
* 搅拌时间(分钟)
*/
private int mixTime;
/**
* 夹具编号
*/
private String fixtureNumber;
/**
* 名称 用户输入文本
锡膏类型(productionType) 有铅/无铅 选择
型号 文本输入
包装方式(encapsulation) 罐装/管装 选择
冰箱存储条件 默认单位是摄氏度,仅作输入显示
室温最多存储时间 用户输入数字,单位为小时,此时间为锡膏在料仓内最大存储时间,报警提示
回温时间 用户输入数字,单位为小时,达到回温时间按才能出库
开封后可以保存时间 室温最多存储时间-回温时间,第一次出库,就认为是开封
*/
//名称
private String name;
//料号
//@NotEmpty(message = "{component.partNumber.empty}")
// @NotEmpty(message = "{component.partNumber.empty}")
@NotNull
private String partNumber;
/**
* 供应商PN,用于扫码贴标机转换PN
*/
// private String supplierPn;
//uid
private String uid;
//物料描述
private String description;
//单耗
private String unitCost;
//"MSL等级"
private String msl;
//"单位"
private String unit;
//"厂商"
private String producer;
//"厂商编号"
private String producerNumber;
//"供应商"
private String provider;
//"供应商编号"
private String providerNumber;
private int amount;
/**
* 报警值,与贴片机连机时使用,值小于1时为初始数量amount百分比,大于等于1时为数量,小于此值时会根据贴片机信息自动出料
*/
private float alarmValue = 0.5f;
private int plateSize;
private int height;
/**
* 单台料仓可存储此种物料的最大数量
*/
private int maxStoreNum = 999999999;
/**
* 单台料仓存储此种物料的最小数量
*/
private int minStoreNum = 0;
/**
* 出库时是否需要授权
*/
private boolean needAuth = false;
/**
* 展示的图片
*/
private String showImg = "";
/**
* 有效时长(生产日期+此天数为过期日期),设置默认有效期为2年
*/
private int validDay = 0;
public String getPSize(){
if(plateSize == 0 || height == 0){
return "";
}
if(type == StorageConstants.COMPONENT_TYPE.FIXTURE){
return plateSize + "x" +height+"x" + partNumber;
}
return plateSize + "x" +height;
}
public int getAlarmAmount(){
if(alarmValue < 1){
return Float.valueOf(getAmount() * alarmValue).intValue();
}else{
return Float.valueOf(alarmValue).intValue();
}
}
/**
* 是否是锡膏
*/
public boolean isSolder(){
return type == StorageConstants.COMPONENT_TYPE.SOLDERPASTE;
}
}
package com.neotel.smfcore.security.service.po;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.StorageConstants;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
import java.util.List;
@Data
@Document
public class DataLog extends BasePo implements Serializable {
/**
* 是否是单盘出库(联电指出库项目,默认为false即默认批量出库)
*/
private boolean singleOut = false;
/**
* 所属料仓
*/
private String storageName;
/**
* 料仓 cid
*/
private String cid;
/**
* 料仓 ID
*/
private String storageId;
/**
* 仓位 ID
*/
private String posId;
/**
* 仓位名称
*/
private String posName;
//二维码(Reel ID)
private String barcode;
/**
* 物料编号
*/
private String partNumber;
/**
*数量(从 barCode 中读取)
*/
private int num;
/**
* 类型:入库StorageConstants.OP.PUT_IN,出库StorageConstants.OP.CHECKOUT
*/
private int type;
/**
* 状态:StorageConstants.OP_STATUS
*/
private String status;
/**
* 指定批次Id
*/
private String batchId;
/**
* 批次显示内容
*/
private String batchInfo;
/**
* 指令来源:站位列表 指定订单工单 MES
*/
private String sourceType;
/**
* 来源 id,
*/
private String sourceId;
/**
* 来源名称
*/
private String sourceName;
/**
* 子来源 ID(单个站位)
*/
private String subSourceId;
/**
* 子来源名称
*/
private String subSourceInfo;
/**
* 创建人
*/
private String creator;
/**
* 操作人
*/
private String operator;
/**
* 关联条码,夹具时关联相关的物料,用于入库完成时插入相关物料
*/
private List<String> relationCodes;
private String memo;
/**
* 搅拌时间(锡膏搅拌任务使用)
*/
private int mixTime;
/**
* 亮灯料架颜色
*/
private String lightColor = "FF0000";
public String getBarcode() {
if(barcode == null){
return "";
}
return barcode;
}
public String getStorageId() {
if(storageId == null){
return "";
}
return storageId;
}
public String getPosId() {
if(posId == null){
return "";
}
return posId;
}
/**
* 是否被取消
*/
public boolean isCancel(){
return StorageConstants.OP_STATUS.CANCEL.name().equals(status);
}
public boolean isExecuting(){
return StorageConstants.OP_STATUS.EXECUTING.name().equals(status);
}
public boolean isFinished(){
return StorageConstants.OP_STATUS.FINISHED.name().equals(status);
}
public boolean isWait(){
return StorageConstants.OP_STATUS.WAIT.name().equals(status);
}
public boolean isEnd(){
return StorageConstants.OP_STATUS.END.name().equals(status);
}
/**
* 是否是入库任务
*/
public boolean isPutInTask(){
return StorageConstants.OP.PUT_IN == type;
}
/**
* 是否是回温取料任务
*/
public boolean isRewarmTakingTask(){
return StorageConstants.OP.REWARM_TAKING == type;
}
/**
* 是否是搅拌任务
*/
public boolean isMixTask(){
return StorageConstants.OP.MIX == type;
}
/**
* 是否是回温放料任务
*/
public boolean isRewarmPuttingTask(){
return StorageConstants.OP.REWARM_PUTTING == type;
}
/**
* 是否是出库任务
*/
public boolean isCheckOutTask(){
return StorageConstants.OP.CHECKOUT == type;
}
/**
* 超过5分钟的已完成,已取消的任务都不再
*/
public boolean needRemoveFromCache(){
if(isFinished() || isCancel()){
if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 3 * 60 * 1000){
return true;
}
}
return false;
}
/**
* 超过5秒的任务不再显示
* @return
*/
public boolean needRemoveFromShow(){
if(isFinished() || isCancel()){
if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 25 * 1000){
return true;
}
}
return false;
}
/**
* 正在执行的出库任务,如果60秒还未完成,再次发送到客户端
*/
public boolean needReSendToClient(){
if(isCheckOutTask() && isExecuting()){
return System.currentTimeMillis() - super.getUpdateDate().getTime() >= 60 * 1000;
}
return false;
}
public String getSourceStr(){
String sourceStr = "";
if (!Strings.isNullOrEmpty(sourceName)){
sourceStr = sourceName;
if(!Strings.isNullOrEmpty(subSourceInfo)){
sourceStr = sourceName + "【"+subSourceInfo+"】";
}
}
return sourceStr;
}
public String getPosStr(){
return storageName +"["+posName +"]";
}
/**
* 任务展示字符串
*/
public String getShowStr(){
String msg = "";
if(isPutInTask()){//入库
msg = "物料["+ partNumber + "] 入库到"+ getPosStr();
}else{
String sourceInfo = "";
if(!Strings.isNullOrEmpty(subSourceInfo)){
sourceInfo = "站位 ["+subSourceInfo+"] 的";
}
if(!Strings.isNullOrEmpty(storageName)){
msg = sourceInfo + "物料["+partNumber + "] 从"+ getPosStr() + "出库";
}else{
msg = sourceInfo + "物料["+partNumber + "] 出库";
}
}
return msg;
}
/**
* 是否是站位列表任务
*/
public boolean isFeederTask(){
return StorageConstants.TASK_SOURCE.FEEDER.name().equals(getSourceType());
}
/**
* 是否是呆滞料出库任务
*/
public boolean isInactionTask(){
return StorageConstants.TASK_SOURCE.INACTION.name().equals(getSourceType());
}
@Override
public boolean equals(Object o) {
boolean eq = super.equals(o);
if(!eq && o != null){
if(o instanceof DataLog){
return ((DataLog) o).getId().equals(this.getId());
}
}
return eq;
}
@Override
public int hashCode() {
return getId().hashCode();
}
public List<String> getRelationCodes() {
return relationCodes;
}
public void setRelationCodes(List<String> relationCodes) {
this.relationCodes = relationCodes;
}
public void addRelationCode(String relationCode){
if(relationCodes == null){
relationCodes = Lists.newArrayList();
}
relationCodes.add(relationCode);
}
}
package com.neotel.smfcore.security.service.po;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Data;
import java.io.Serializable;
@Data
public class Humiture extends BasePo implements Serializable {
/**
* 料仓号
*/
private String cid;
/**
* BOX 的 ID
*/
private Integer boxId;
/**
* 温度
*/
private String temperature;
/**
* 湿度
*/
private String humidity;
public String getBoxKey(){
return cid +"-"+ boxId;
}
}
package com.neotel.smfcore.security.service.po;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.StorageConstants;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
import java.util.List;
@Data
@Document
public class LiteOrder extends BasePo implements Serializable {
public LiteOrder() {
}
public LiteOrder(String orderNo, List<LiteOrderItem> orderItems) {
this.orderItems = orderItems;
this.orderNo = orderNo;
}
/**
* 订单号
*/
private String orderNo;
/**
* 当前任务盘数
*/
private int taskReelCount = 0;
/**
* 当前任务已完成盘数
*/
private int finishedReelCount = 0;
/**
* 订单状态
*/
private int status = StorageConstants.LITEORDER_STATUS.NEW;
/**
* 出库状态, 2表示已完成
*/
private boolean closed = false;
/**
* 工单来源
*/
private String source = "";
/**
* 任务完成时间(用于关闭页面显示)
*/
@Transient
private long taskFinishedTime = -1;
/**
* 套(倍)数
*/
private float orderTimes = 1f;
/**
* 订单的详细信息
*/
@Transient
private List<LiteOrderItem> orderItems;
/**
* 结束当前的任务
*/
public void finishedTasks(){
if(isOutOne()){
setStatus(StorageConstants.LITEORDER_STATUS.ONE_FINISHED);
}else if(isOutBom()){
setStatus(StorageConstants.LITEORDER_STATUS.BOM_FINISHED);
}else if(isOutTails()){
setStatus(StorageConstants.LITEORDER_STATUS.TAILS_FINISHED);
}
setTaskFinishedTime(System.currentTimeMillis());
}
/**
* 是否正在出首套料
* @return
*/
public boolean isOutBom(){
return status == StorageConstants.LITEORDER_STATUS.BOM;
}
/**
* 是否是未执行过的工单
*/
public boolean isNew(){
return status == StorageConstants.LITEORDER_STATUS.NEW;
}
public boolean isOutOne(){
return status == StorageConstants.LITEORDER_STATUS.ONE;
}
/**
* 补料任务完成
* @return
*/
public boolean isOutOneFinished(){
return status == StorageConstants.LITEORDER_STATUS.ONE_FINISHED;
}
/**
* 是否正在出尾料
*/
public boolean isOutTails(){
return status == StorageConstants.LITEORDER_STATUS.TAILS;
}
/**
* 任务料盘是否已出完
*/
public boolean isTaskFinished(){
return status == StorageConstants.LITEORDER_STATUS.BOM_FINISHED || status == StorageConstants.LITEORDER_STATUS.TAILS_FINISHED || status == StorageConstants.LITEORDER_STATUS.ONE_FINISHED;
}
public void setTaskReelCount(int taskReelCount) {
if(taskReelCount < 0) taskReelCount = 0;
this.taskReelCount = taskReelCount;
}
/**
* 是否需要展示(已完成的,过20 秒自动清除)
*/
public boolean needToShow(){
if(isTaskFinished()){
if(taskFinishedTime != -1){
long now = System.currentTimeMillis();
return now - taskFinishedTime <= 20 * 1000;
}
}
return true;
}
public float getOrderTimes() {
if(orderTimes == 0){
orderTimes = 1f;
}
return orderTimes;
}
}
package com.neotel.smfcore.security.service.po;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
@Data
@Document
public class LiteOrderItem extends BasePo implements Serializable {
//物料编号
private String pn;
//需求数量
private int needNum = 0;
//已出数量
private int outNum = 0;
//已出盘数
private int outReelCount = 0;
/**
* 订单信息
*/
private String orderNo = "";
/**
* 站位信息
*/
private String feederInfo = "";
/**
* 库存信息
*/
@Transient
private int inventoryNum = 0;
/**
* 出库是否满足要求,已出库数量大于需求数量
*/
public boolean isOutFinished(){
return outNum - needNum >=0;
}
}
package com.neotel.smfcore.security.service.po;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.security.service.po.data.DeviceStatusBean;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
@Data
@Document
public class Maintenance extends BasePo implements Serializable {
/**
* 料仓CID
*/
private String storageCid;
/**
* 料仓名称
*/
private String storageName;
/**
* 下次维护时间
*/
private Date nextTime;
/**
* 提前多少小时邮件通知
*/
private int hoursInAdvance = 10;
/**
* 邮件地址
*/
private String emails = "";
/**
* 设备运行信息,key为设备名称,设备状态
*/
private Map<String, DeviceStatusBean> deviceData = Maps.newHashMap();
public String getNextTimeStr(){
if(nextTime != null){
return DateUtil.toDateString(nextTime);
}
return "";
}
/**
* 更新设备的运行状态,返回值表示是否需要保存到数据库
*/
public boolean updateDeviceStatus(String device, int status){
boolean needSaveToDb = false;
DeviceStatusBean deviceInfo = deviceData.get(device);
if(deviceInfo == null){
deviceInfo = new DeviceStatusBean();
deviceInfo.setDeviceName(device);
needSaveToDb = true;
}
long now = System.currentTimeMillis();
//状态改变
if(status != deviceInfo.getStatus()){
//如果当前状态是0(即上一状态是运动,现在是停止),更新轴运行时间, 同时要满足上次更新时间小于5秒,即设备在线
if(status == 0){
if(now - deviceInfo.getStatusUpdateTime() < 5000){
long runTime = now - deviceInfo.getStatusStartTime();
deviceInfo.setRunTimes(deviceInfo.getRunTimes() + runTime);
needSaveToDb = true;
}
}
deviceInfo.setStatus(status);
deviceInfo.setStatusStartTime(now);
}
deviceInfo.setStatusUpdateTime(now);
deviceData.put(device,deviceInfo);
return needSaveToDb;
}
}
package com.neotel.smfcore.security.service.po;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class Settings extends BasePo implements Serializable {
/**
* 脱机调试
*/
private boolean debugTest = false;
/**
* 指定软件是为哪个客户单独定制的
*/
private String productCustom = "";
/**
* 出库方式
*/
private String outType;
/**
* 打印条码的纸张宽度(条码为方形,大小是长宽中最小的)
*/
private int pageWidth = 500;
/**
* 打印条码的纸张高度
*/
private int pageHeight = 160;
/**
* 最低温度
*/
private float minTemperature = 22.0F;
/**
* 仪表显示最低温度
*/
private float minTemperatureShow = 20.0F;
/**
* 最高温度
*/
private float maxTemperature = 38.0F;
/**
* 仪表显示最高温度
*/
private float maxTemperatureShow = 30.0F;
/**
* 最低湿度值
*/
private float minHumidity = 0.0F;
/**
* 仪表显示最低湿度值
*/
private float minHumidityShow = 0.0F;
/**
* 湿度值
*/
private float maxHumidity = 100.0F;
/**
* 仪表显示最高湿度值
*/
private float maxHumidityShow = 15.0F;
/**
* 条码规则,可用字段有: PN为物料编号即 PartNumber, RI 为唯一码即ReelId, QTY 为数量,SP 为供应商,SPC供应商代码,BATCH 为批次,xx或空为无对应的字段其中必须含有PN和 RI, QTY为空时使用输入产器时的封装数量
* 1@2@3@PN@5@6@7@8@9@10@11@12@13@14@15@16@RI@18@19@20@21@22@23@24
* [)>@06@12S0002@P5292001000@1P1690215@31P1690215@12V527973628@10VCHN-YANTAI@2P@20P@6D20170626@14D20171223@30PY@ZN@K0@16K0@V815@3SB370000000EZZ@Q500GRM000@20T1@1TMT72543954@2T@1Z@@'
*/
@Deprecated
private String codeRule = "";
/**
* 多条条码规则
*/
private List<String> codeRuleList = Lists.newArrayList();
/**
* 打印条码纸张的页边距
*/
private int pageSpace = 5;
/**
* 打印条码时的字体大小
*/
private int fontSize = 18;
/**
* 条码检查 API
*/
private String reelCheckApi;
/**
* 呆滞物料提醒时间(天)
*/
private int inactionDay = 0;
/**
* 入库通知api地址
*/
private String inNotifyApi;
/**
* 出库通知api地址
*/
private String outNotifyApi;
/**
* PCB 过期提醒提前天数
*/
private int pcbExpireDay = 0;
/**
* PCB 过期提醒邮件地址
*/
private String pcbExpireEmail;
/**
* 备份路径
*/
private String backupPath = "";
/**
* 备份周期
*/
private int backupHours = 0;
/**
* 维护周期
*/
private int maintenanceDays = 60;
/**
* 维护通知邮件地址
*/
private String maintenanceEmail;
/**
* PCB 过期提醒时间(0-23)
*/
private int pcbExpireTime = 0;
/**
* 过期 PCB 上次检测时间
*/
private Date lastPcbCheckDate;
/**
* 订单文件的路径
*/
private String orderFileDir;
}
package com.neotel.smfcore.security.service.po;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.security.service.po.data.PlateSizeBean;
import com.neotel.smfcore.security.service.po.data.UsageItem;
import com.sun.istack.internal.NotNull;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Data
@Document
public class Storage extends BasePo implements Serializable {
// @NotEmpty(message = "{storage.name.empty}")
@NotNull
private String name;
/**
* 程序路径
*/
private String sourcePath;
// @NotEmpty(message = "{storage.cid.empty}")
@NotNull
private String cid;
private int totalSlots;
private int emptySlots;
/**
* 兼容类型:完全匹配,完全兼容,同尺寸兼容
*/
private StorageConstants.COMPATIBLE_TYPE compatibleType = StorageConstants.COMPATIBLE_TYPE.EXACT_MATCH;
/**
* 料仓类型:单台自动料仓,手动料仓流水线料仓
*/
private String type = StorageConstants.TYPE.AUTO.name();
//包含料仓 Box数量
private Integer boxCount=1;
public Integer getBoxCount() {
if (boxCount == null){
boxCount = 1;
}
return boxCount;
}
/**
* 使用情况
*/
private Map<String, UsageItem> usageMap = new ConcurrentHashMap<>();
private boolean available = true;
/**
* 是否是上下层的在线料仓
* @return
*/
public boolean isOnlineStorage(){
return StorageConstants.TYPE.ONLINE.name().equals(type);
}
/**
* 是否是指上下料的料仓
* @return
*/
public boolean isBatchStorage(){
return StorageConstants.TYPE.BATCH.name().equals(type);
}
/**
* 是否是单台自动仓
*/
public boolean isAuto(){
return StorageConstants.TYPE.AUTO.name().equals(type);
}
/**
* 是否是虚拟仓
*/
public boolean isVirtual(){
return StorageConstants.TYPE.VIRTUAL.name().equals(type);
}
/**
* 是否是流水线料仓
*/
public boolean isLine() {
return StorageConstants.TYPE.LINE.name().equals(type);
}
/**
* 是否是智能料架
*/
public boolean isShelf() {
return StorageConstants.TYPE.SHELF.name().equals(type);
}
/**
* 是否是ACC智能料架
*/
public boolean isAccShelf() {
return StorageConstants.TYPE.ACCSHELF.name().equals(type);
}
/**
* 是否是扫码料架
*/
public boolean isCodeShelf() {
return StorageConstants.TYPE.CODESHELF.name().equals(type);
}
/**
* 是否是垂直货柜
*/
public boolean isVerticalBox(){
return StorageConstants.TYPE.VERTICALBOX.name().equals(type);
}
/**
* 是否是锡膏料仓
*/
public boolean isSolderPaste(){
return StorageConstants.TYPE.SOLDERPASTE.name().equals(type);
}
/**
* 是否是料柜
*/
public boolean isCabinet() {
return StorageConstants.TYPE.CABINET.name().equals(type);
}
/**
* 是否是方仓
*/
public boolean isSmdXl() {
return StorageConstants.TYPE.SMD_XL.name().equals(type);
}
/**
* 是否是Duo料仓
*/
public boolean isSmdDuo() {
return StorageConstants.TYPE.SMD_DUO.name().equals(type);
}
public boolean canPutInPos(int w, int h, int PosW, int posH){
if(compatibleType == StorageConstants.COMPATIBLE_TYPE.EXACT_MATCH){//完全匹配
if(w == PosW && h == posH){
return true;
}
}else if(compatibleType == StorageConstants.COMPATIBLE_TYPE.FULLY_COMPATIBLE){//完全兼容
if(w <= PosW && h <= posH){
return true;
}
}else if(compatibleType == StorageConstants.COMPATIBLE_TYPE.SIZE_COMPATIBLE){//同尺寸兼容
if(w == PosW && h <= posH){
return true;
}
}
return false;
}
/**
* 判断料盘是否能够放入该仓库: 0=完全匹配,1=完全兼容,2=同尺寸兼容
*/
public boolean canPutIn(int w, int h){
if(usageMap != null){
for (UsageItem usageItem : usageMap.values()) {
if(canPutInPos(w,h, usageItem.getW(), usageItem.getH())){
return true;
}
}
}
return false;
}
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);
}
}
package com.neotel.smfcore.security.service.po;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class StoragePos extends BasePo implements Serializable {
private String storageId;
private Barcode barcode;
private String posName;
/**
* 扩展库位的主库位
*/
private String hostPosId;
/**
* 该仓位是否限制物编,虚拟仓使用
*/
private List<String> limitPnList;
//进料优先级,数字越大优先级越高,例:1-1的优先级为100 仓1-2的优先级200,那么入仓时就会优先进入1-2仓
private double priority = 0f;
//高度
private int h;
//是否可用了
private boolean enabled = true;
//是否使用了
private boolean used = false;
/**
* 是否是回温库位,条码第一次入库是入库到冷藏库位,回温或二次入库时才入到回温库位
*/
private boolean warmPos = false;
//Width
private int w;
//可出库时间,类型的锡膏时,可出库时间为最新放入的锡膏的可出库时间
private long canCheckOutTime = 0;
/**
* 并联的其他库位,合并入主库位的库位
*/
private List<String> mergePosList;
public String getLabelStr(){
String posNameLabel = posName;
int index = posNameLabel.lastIndexOf(":");
if(index > 0){
posNameLabel = posNameLabel.substring(0,index);
}
return posNameLabel;
}
public int getLabelIndex(){
int index = posName.lastIndexOf(":");
if(index > 0){
String posIndex = posName.substring(index+1);
try{
return Integer.valueOf(posIndex);
}catch (Exception e){
}
}
return 1;
}
public boolean isEnabled() {
return enabled;
}
public boolean isUsed() {
return used;
}
public boolean isLocked(){
return getBarcode() != null && !Strings.isNullOrEmpty(getBarcode().getLockId());
}
@Override
public boolean equals(Object o) {
boolean eq = super.equals(o);
if(!eq && o != null){
if(o instanceof StoragePos){
return ((StoragePos) o).getId().equals(this.getId());
}
}
return eq;
}
@Override
public int hashCode() {
return getId().hashCode();
}
/**
* 在库分钟数
*/
public long getInStoreMiniute(){
if(barcode != null){
return barcode.getInStoreMiniute();
}
return 0;
}
/**
* 在库小时数
*/
public long getInStoreHour(){
if(barcode != null){
return barcode.getInStoreHour();
}
return 0;
}
/**
* 是否达到回温时间(只有锡膏需要判断)
*/
public boolean isReachedWarmTime(){
if(barcode != null){
return barcode.isReachedWarmTime();
}
return true;
}
public String getSizeStr(){
return w + "x" + h;
}
public boolean isWarmPos() {
return warmPos;
}
public boolean isExpandPos(){
return !Strings.isNullOrEmpty(hostPosId);
}
}
package com.neotel.smfcore.security.service.po.data;
import lombok.Data;
@Data
public class DeviceStatusBean {
/**
* 设备名称
*/
private String deviceName;
/**
* 当前状态
*/
private int status;
/**
* 状态开始时间
*/
private long statusStartTime;
/**
* 状态更新时间(用于判断设备是否离线)
*/
private long statusUpdateTime;
/**
* 运行时长
*/
private long runTimes;
}
package com.neotel.smfcore.security.service.po.data;
import com.neotel.smfcore.common.utils.StorageConstants;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
@Data
@Document
public class InactionTaskSet extends TaskSet {
public static InactionTaskSet create(String areaId, int day){
InactionTaskSet inactionTaskSet = new InactionTaskSet();
inactionTaskSet.setName(day + "天前呆滞物料出库");
inactionTaskSet.setStatus(StorageConstants.OP_STATUS.WAIT.name());
inactionTaskSet.setId("-1");
inactionTaskSet.setDay(day);
return inactionTaskSet;
}
/**
* 总共的物料数量
*/
private int totalOp;
/**
* 几天前的呆滞料
*/
private int day;
/**
* 返回总任务数
* @return
*/
@Override
public int getOpNum() {
return totalOp;
}
@Override
public StorageConstants.TASK_SOURCE getTaskSource() {
return StorageConstants.TASK_SOURCE.INACTION;
}
@Override
public String getTitle() {
return getName();
}
}
package com.neotel.smfcore.security.service.po.data;
import com.neotel.smfcore.common.utils.PLATE_SIZE;
import lombok.Getter;
import lombok.Setter;
public class PlateSizeBean {
@Getter
private PLATE_SIZE plateSize;
@Getter @Setter
private int count;
public String getSizeStr(){
return plateSize.getSizeStr();
}
}
package com.neotel.smfcore.security.service.po.data;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Data;
import java.io.Serializable;
@Data
public class PreWareHousing extends BasePo implements Serializable {
private String storageId;
private String barcodeId;
private int amount;
}
package com.neotel.smfcore.security.service.po.data;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Data;
import java.io.Serializable;
@Data
public class ProviderPattern extends BasePo implements Serializable {
private String provider;
private String providerNumber;
private String regex;
}
package com.neotel.smfcore.security.service.po.data;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.StorageConstants;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
@Data
@Document
public abstract class TaskSet extends BasePo implements Serializable {
/**
* 显示的任务集合名称
*/
private String name;
/**
* 操作出库的站位数量
*/
private int opNum;
/**
* 已完成出库的站位数量
*/
private int finishOpNum;
/**
* 任务创建人
*/
private String creator;
/**
* 状态
*/
private String status = StorageConstants.OP_STATUS.NONE.name();
public abstract StorageConstants.TASK_SOURCE getTaskSource();
public abstract String getTitle();
public String getKey(){
return getTaskSource().name() + getId();
}
public boolean isFeeder(){
return StorageConstants.TASK_SOURCE.FEEDER.name().equals(getTaskSource().name());
}
/**
* 是否被取消
*/
public boolean isCancel(){
return StorageConstants.OP_STATUS.CANCEL.name().equals(getStatus());
}
public boolean isEnd(){
return StorageConstants.OP_STATUS.END.name().equals(getStatus());
}
public boolean isExecuting(){
return StorageConstants.OP_STATUS.EXECUTING.name().equals(getStatus());
}
public boolean isFinished(){
return StorageConstants.OP_STATUS.FINISHED.name().equals(getStatus());
}
public boolean isWait(){
return StorageConstants.OP_STATUS.WAIT.name().equals(getStatus());
}
public boolean isPause(){
return StorageConstants.OP_STATUS.PAUSE.name().equals(getStatus());
}
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
/**
* 没有操作过的才可以删除
*/
public boolean isCanRemove(){
return StorageConstants.OP_STATUS.NONE.name().equals(getStatus()) && getOpNum() == 0 && getFinishOpNum() == 0;
}
@Override
public boolean equals(Object o) {
boolean eq = super.equals(o);
if(!eq && o != null){
if(o instanceof TaskSet){
eq = ((TaskSet)o).getId().equals(this.getId());
}
}
return eq;
}
}
package com.neotel.smfcore.security.service.po.data;
import lombok.Data;
@Data
public class UsageItem {
/**
* 直径
*/
private int w;
/**
* 高度
*/
private int h;
/**
* 使用仓位数
*/
private int usedCount;
/**
* 总仓位数
*/
private int totalCount;
public String getSizeStr(){
return w+"x"+h;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!