Commit 38fdd1d2 sunke

架构调整

1 个父辈 78b0f051
正在显示 30 个修改的文件 包含 372 行增加91 行删除
package com.neotel.smfcore.common.base;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
......@@ -54,5 +55,7 @@ public interface IBaseDao {
void updateFirst(Query query, Update update);
MongoTemplate getMongoTemplate();
}
......@@ -209,56 +209,6 @@ public class StorageConstants {
EFFICIENCY,FIFO,USED_FIRST,EXPIRE_FIRST,PRODUCE_DATE;
}
/**
* 物料类型
*/
public static class COMPONENT_TYPE{
public static final int COMPONENT = 0;
/** 锡膏 */
public static final int SOLDERPASTE = 1;
/** PCB板 */
public static final int PCB = 2;
/** 其他物料*/
public static final int OTHERS = 3;
/** 夹具 */
public static final int FIXTURE = 4;
}
/**
* 二维码类型,用于在界面上展示对应的图片
*/
public static enum CODE_TYPE{
COMPONENT,
PCB,
OTHERS,
PCB_FIXTURE,
SOLDER_FIXTURE,
FIXTURE,
/**
* 管装锡膏
*/
TUBE_SOLDER,
/**
* 罐装锡膏
*/
CAN_SOLDER;
public static CODE_TYPE fromComponentType(int type){
switch (type){
case COMPONENT_TYPE.COMPONENT:
return COMPONENT;
case COMPONENT_TYPE.FIXTURE:
return FIXTURE;
case COMPONENT_TYPE.OTHERS:
return OTHERS;
case COMPONENT_TYPE.PCB:
return PCB;
}
return null;
}
}
/**
* 图表展示方式
*/
......
package com.neotel.smfcore.core.barcode.bean;
import com.neotel.smfcore.core.barcode.enums.CODE_TYPE;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
/**
* 用于解析条码
* Created by sunke on 2017/10/10.
*/
public class CodeBean {
/**
* 码类型
*/
private CODE_TYPE codeType;
/**
* 摄像头位置信息
*/
private int cameraIndex = 0;
//扫描到的二维码的位置信息
private float locationX = -1.0f;
private float locationY = -1.0f;
/**
* 用于显示的照片信息
*/
private String showImg = "";
/**
* 料盘宽度
*/
private int reelWidth = -1;
/**
* 料盘高度
*/
private int reelHeight = -1;
private String codeStr = "";
/**
* 错误消息,正常时为空
*/
private String error;
private String errorCode;
private String[] params;
private Barcode barcode;
public String getError() {
return error;
}
public void setError(String errorCode, String[] params,String error) {
this.error = error;
this.errorCode = errorCode;
this.params = params;
}
public void setError(String errorCode, String error) {
this.error = error;
this.errorCode = errorCode;
this.params = null;
}
public Barcode getBarcode() {
return barcode;
}
public void setBarcode(Barcode barcode) {
this.barcode = barcode;
}
public boolean isValid(){
return error == null && barcode != null;
}
/**
* 是否是夹具条码
*/
public boolean isFixtureCode(){
if(isValid()){
return COMPONENT_TYPE.FIXTURE == barcode.getType();
}
return false;
}
public float getLocationX() {
return locationX;
}
public void setLocationX(float locationX) {
this.locationX = locationX;
}
public float getLocationY() {
return locationY;
}
public void setLocationY(float locationY) {
this.locationY = locationY;
}
public CODE_TYPE getCodeType() {
return codeType;
}
public void setCodeType(CODE_TYPE codeType) {
this.codeType = codeType;
}
public String getCodeStr() {
return codeStr;
}
public void setCodeStr(String codeStr) {
this.codeStr = codeStr;
}
public int getCameraIndex() {
return cameraIndex;
}
public void setCameraIndex(int cameraIndex) {
this.cameraIndex = cameraIndex;
}
public int getReelWidth() {
return reelWidth;
}
public void setReelWidth(int reelWidth) {
this.reelWidth = reelWidth;
}
public int getReelHeight() {
return reelHeight;
}
public void setReelHeight(int reelHeight) {
this.reelHeight = reelHeight;
}
public boolean hasReelSizeInfo() {
return reelWidth > 0 && reelHeight > 0;
}
public String getShowImg() {
return showImg;
}
public void setShowImg(String showImg) {
this.showImg = showImg;
}
public void setError(String error) {
this.error = error;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String[] getParams() {
return params;
}
public void setParams(String[] params) {
this.params = params;
}
}
package com.neotel.smfcore.core.service.data;
package com.neotel.smfcore.core.barcode.bean;
import com.neotel.smfcore.common.utils.PLATE_SIZE;
import lombok.Getter;
......
package com.neotel.smfcore.core.barcode.enums;
import com.neotel.smfcore.common.utils.StorageConstants;
/**
* 二维码类型,用于在界面上展示对应的图片
* Created by sunke on 2021/7/13.
*/
public enum CODE_TYPE {
COMPONENT,
PCB,
OTHERS,
PCB_FIXTURE,
SOLDER_FIXTURE,
FIXTURE,
/**
* 管装锡膏
*/
TUBE_SOLDER,
/**
* 罐装锡膏
*/
CAN_SOLDER;
public static CODE_TYPE fromComponentType(int type){
switch (type){
case COMPONENT_TYPE.COMPONENT:
return COMPONENT;
case COMPONENT_TYPE.FIXTURE:
return FIXTURE;
case COMPONENT_TYPE.OTHERS:
return OTHERS;
case COMPONENT_TYPE.PCB:
return PCB;
}
return null;
}
}
package com.neotel.smfcore.core.barcode.enums;
/**
* 物料类型
* Created by sunke on 2021/7/13.
*/
public class COMPONENT_TYPE {
public static final int COMPONENT = 0;
/** 锡膏 */
public static final int SOLDERPASTE = 1;
/** PCB板 */
public static final int PCB = 2;
/** 其他物料*/
public static final int OTHERS = 3;
/** 夹具 */
public static final int FIXTURE = 4;
}
......@@ -3,7 +3,9 @@ package com.neotel.smfcore.core.barcode.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.core.barcode.service.dao.IBarcodeDao;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import org.springframework.stereotype.Service;
@Service
public class BarcodeDaoImpl extends AbstractBaseDao implements IBarcodeDao {
@Override
public Class getEntityClass() {
......
......@@ -5,9 +5,11 @@ import com.neotel.smfcore.core.barcode.service.dao.IComponentDao;
import com.neotel.smfcore.core.barcode.service.po.Component;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ComponentDaoImpl extends AbstractBaseDao implements IComponentDao {
@Override
public Class getEntityClass() {
......
......@@ -4,4 +4,7 @@ import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
public interface IBarcodeManager extends IBaseManager<Barcode> {
Barcode findByBarcode(String reelId);
}
......@@ -4,4 +4,5 @@ import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.barcode.service.po.Component;
public interface IComponentManager extends IBaseManager<Component> {
Component findByPartNumberAndProvider(String partNumber, String provider);
}
package com.neotel.smfcore.core.barcode.service.manager.impl;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.barcode.service.dao.IBarcodeDao;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@Service
public class BarcodeManagerImpl implements IBarcodeManager {
@Autowired
private IBarcodeDao barcodeDao;
@Override
public Barcode get(String id) {
return null;
......@@ -33,4 +42,9 @@ public class BarcodeManagerImpl implements IBarcodeManager {
public List<Barcode> findByQuery(Query query) {
return null;
}
@Override
public Barcode findByBarcode(String reelId) {
return barcodeDao.findOneByCondition(new String[]{"barcode"}, new String[]{reelId});
}
}
package com.neotel.smfcore.core.barcode.service.manager.impl;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.barcode.service.dao.IComponentDao;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Component;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ComponentManagerImpl implements IComponentManager {
@Autowired
private IComponentDao componentDao;
@Override
public Component get(String id) {
return null;
return componentDao.findOneById(id);
}
@Override
public Component save(Component object) throws ValidateException {
return null;
return componentDao.save(object);
}
@Override
......@@ -26,11 +35,28 @@ public class ComponentManagerImpl implements IComponentManager {
@Override
public List<Component> findByPage(Query query, Pageable pageable) {
return null;
return componentDao.findByQuery(query,pageable);
}
@Override
public List<Component> findByQuery(Query query) {
return componentDao.findOne(query);
}
@Override
public Component findByPartNumberAndProvider(String partNumber, String provider) {
if (StringUtils.isEmpty(partNumber))
return null;
else {
Component component = componentDao.findOneByCondition(new String[] {"partNumber","provider"}, new String[] {partNumber,provider});
if(component == null){
component = componentDao.findOneByCondition(new String[] {"partNumber","provider"}, new String[] {partNumber,null});
if(component != null){
component.setProvider(provider);
component = componentDao.save(component);
}
}
return component;
}
}
}
......@@ -4,6 +4,7 @@ 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 com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
......@@ -19,7 +20,7 @@ public class Barcode extends BasePo implements Serializable {
/**
* 物料类型:PCB,锡膏,或其他
*/
private int type = StorageConstants.COMPONENT_TYPE.COMPONENT;
private int type = COMPONENT_TYPE.COMPONENT;
//锡膏回温时间,小于回温时间不可出库
private int warmTime = 0;
......@@ -140,7 +141,7 @@ public class Barcode extends BasePo implements Serializable {
* 是否是锡膏
*/
public boolean isSolder(){
return type == StorageConstants.COMPONENT_TYPE.SOLDERPASTE;
return type == COMPONENT_TYPE.SOLDERPASTE;
}
public List<String> getRelationCodes() {
if (relationCodes == null) {
......@@ -227,7 +228,7 @@ public class Barcode extends BasePo implements Serializable {
*/
public long getReachWarmTime(){
long reachWarmTime = System.currentTimeMillis();
if(StorageConstants.COMPONENT_TYPE.SOLDERPASTE == type && putInTime != -1){
if(COMPONENT_TYPE.SOLDERPASTE == type && putInTime != -1){
reachWarmTime = putInTime + warmTime * 60 * 60 * 1000;
}
return reachWarmTime;
......
......@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.barcode.service.po;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.sun.istack.internal.NotNull;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -16,7 +17,7 @@ public class Component extends BasePo implements Serializable {
/**
* 产品类型:0元器件,1锡膏2PCB3其他4夹具
*/
private int type = StorageConstants.COMPONENT_TYPE.COMPONENT;
private int type = COMPONENT_TYPE.COMPONENT;
/**
* 产品型号
......@@ -142,7 +143,7 @@ public class Component extends BasePo implements Serializable {
if(plateSize == 0 || height == 0){
return "";
}
if(type == StorageConstants.COMPONENT_TYPE.FIXTURE){
if(type == COMPONENT_TYPE.FIXTURE){
return plateSize + "x" +height+"x" + partNumber;
}
......@@ -160,6 +161,6 @@ public class Component extends BasePo implements Serializable {
* 是否是锡膏
*/
public boolean isSolder(){
return type == StorageConstants.COMPONENT_TYPE.SOLDERPASTE;
return type == COMPONENT_TYPE.SOLDERPASTE;
}
}
......@@ -6,7 +6,7 @@ import com.neotel.smfcore.common.enums.DeviceType;
import com.neotel.smfcore.core.device.handler.IDeviceHandler;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.Storage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
......
package com.neotel.smfcore.core.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.service.po.StoragePos;
public interface IStoragePosManager extends IBaseManager<StoragePos> {
}
package com.neotel.smfcore.core.service.data;
package com.neotel.smfcore.core.storage.bean;
import lombok.Data;
......
package com.neotel.smfcore.core.service.dao;
package com.neotel.smfcore.core.storage.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
......
package com.neotel.smfcore.core.service.dao;
package com.neotel.smfcore.core.storage.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
......
package com.neotel.smfcore.core.service.dao.impl;
package com.neotel.smfcore.core.storage.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.core.service.dao.IStorageDao;
import com.neotel.smfcore.core.service.po.Storage;
import com.neotel.smfcore.core.storage.service.dao.IStorageDao;
import com.neotel.smfcore.core.storage.service.po.Storage;
import org.springframework.stereotype.Service;
@Service
......
package com.neotel.smfcore.core.storage.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.core.storage.service.dao.IStorageDao;
import com.neotel.smfcore.core.storage.service.dao.IStoragePosDao;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import org.springframework.stereotype.Service;
@Service
public class StoragePosDaoImpl extends AbstractBaseDao implements IStoragePosDao {
@Override
public Class getEntityClass() {
return StoragePos.class;
}
}
package com.neotel.smfcore.core.service.manager;
package com.neotel.smfcore.core.storage.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.Storage;
import java.util.List;
......
package com.neotel.smfcore.core.storage.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.barcode.bean.PlateSizeBean;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import java.util.List;
public interface IStoragePosManager extends IBaseManager<StoragePos> {
List<PlateSizeBean> getStoragePosUsage(String storageId);
}
package com.neotel.smfcore.core.service.manager.impl;
package com.neotel.smfcore.core.storage.service.manager.impl;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.service.dao.IStorageDao;
import com.neotel.smfcore.core.service.manager.IStorageManager;
import com.neotel.smfcore.core.service.po.Storage;
import com.neotel.smfcore.core.storage.service.dao.IStorageDao;
import com.neotel.smfcore.core.storage.service.manager.IStorageManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
......
package com.neotel.smfcore.core.service.manager.impl;
package com.neotel.smfcore.core.storage.service.manager.impl;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.service.po.StoragePos;
import com.neotel.smfcore.core.barcode.bean.PlateSizeBean;
import com.neotel.smfcore.core.storage.service.dao.IStoragePosDao;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class StoragePosManagerImpl implements IStoragePosManager {
@Autowired
private IStoragePosDao storagePosDao;
@Override
public List<PlateSizeBean> getStoragePosUsage(String storageId){
Aggregation agg = Aggregation.newAggregation(
Aggregation.match(Criteria.where("storageId").is(storageId).and("enabled").is(true)),
Aggregation.group("w","h","used").count().as("count"),
Aggregation.project("count").and("plateSize").previousOperation()
);
AggregationResults<PlateSizeBean> results = storagePosDao.getMongoTemplate().aggregate(agg, StoragePos.class, PlateSizeBean.class);
List<PlateSizeBean> beans = results.getMappedResults();
return beans;
}
@Override
public StoragePos get(String id) {
return null;
return storagePosDao.findOneById(id);
}
@Override
public StoragePos save(StoragePos object) throws ValidateException {
return null;
return storagePosDao.save(object);
}
@Override
......@@ -26,11 +50,11 @@ public class StoragePosManagerImpl implements IStoragePosManager {
@Override
public List<StoragePos> findByPage(Query query, Pageable pageable) {
return null;
return storagePosDao.findByQuery(query,pageable);
}
@Override
public List<StoragePos> findByQuery(Query query) {
return null;
return storagePosDao.findOne(query);
}
}
package com.neotel.smfcore.core.service.po;
package com.neotel.smfcore.core.storage.service.po;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.enums.DeviceType;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.service.data.PlateSizeBean;
import com.neotel.smfcore.core.service.data.UsageItem;
import com.neotel.smfcore.core.barcode.bean.PlateSizeBean;
import com.neotel.smfcore.core.storage.bean.UsageItem;
import com.sun.istack.internal.NotNull;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
......
package com.neotel.smfcore.core.service.po;
package com.neotel.smfcore.core.storage.service.po;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.base.BasePo;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!