Commit 4051b347 孙克
2 个父辈 d600bc96 3ecd8bf2
正在显示 106 个修改的文件 包含 2054 行增加509 行删除
......@@ -31,3 +31,4 @@ build/
### VS Code ###
.vscode/
!/src/main/java/com/neotel/smfcore/core/order/rest/OrderController.java
......@@ -118,10 +118,10 @@ public class MenuInit {
//AGV看板
//addDefaultFunctionMenu(1,null,"AGV看板","agvkanban", "agv/agvkanban/index","agv");
addDefaultFunctionMenu(-1,null,"Neo Ai","neoai","neoai/index","neoai");
//addDefaultFunctionMenu(-1,null,"Neo Ai","neoai","neoai/index","neoai");
//Mimo看板
addDefaultFunctionMenu(0,null,"SMD BOX MIMO","SMDBOXMIMO", "smdBoxMimo/index","smdMimo");
//addDefaultFunctionMenu(0,null,"SMD BOX MIMO","SMDBOXMIMO", "smdBoxMimo/index","smdMimo");
Menu boardMap = Menu.CreatePMenu("仪表盘", 0, "dashBoard", "kanban", null);
......@@ -134,9 +134,13 @@ public class MenuInit {
addDefaultFunctionMenu(0, boardMap, "SP仪表盘", "spkanban", "kanban/spkanban/index", "kanban");
//设备看板
addDefaultFunctionMenu(1,null,"设备互联","lockMaterial", "lockMaterial/material/index","kanban",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(1,null,"设备互联","lockMaterial", "lockMaterial/material/index","sKanban",DEFAULT_SHOW_MENU);
Menu selfAudit = Menu.CreatePMenu("盘点管理", 2, "selfAuditManagerment", "selfAudit",null);
addDefaultFunctionMenu(121,selfAudit, "盘点", "selfAudit", "system/selfAudit/index","selfAudit");
addDefaultFunctionMenu(122, selfAudit, "盘点记录","selfAuditLog", "system/selfAuditLog/index", "selfAuditLog");
//设备互联
addDefaultFunctionMenu(2,null,"设备互联","equipmentView", "neolight/equipmentView/index","sKanban");
//addDefaultFunctionMenu(2,null,"设备互联","equipmentView", "neolight/equipmentView/index","sKanban");
//物料管理:工单出库,查找出库(UID出库,PN出库),物料标签,料盒操作,出库策略,工单设置
Menu poutOut = Menu.CreatePMenu("物料管理", 3, "order", "workOrder", null);
......@@ -158,9 +162,7 @@ public class MenuInit {
// addDefaultFunctionMenu(11, poutOut, "转储入库", "dumpWarehousing", "system/dumpWarehousing/index", "headIcon");
// addDefaultFunctionMenu(12, poutOut, "单盘入库", "singleDiskWarehousing", "system/singleDiskWarehousing/index", "headIcon");
addDefaultFunctionMenu(13, poutOut, "呆滞物料", "sluggishMaterials", "system/sluggishMaterials/index", "sMaterial");
addDefaultFunctionMenu(14,poutOut, "安全库存", "safetyInventory", "system/safetyInventory/index", "safeInventory");
addDefaultFunctionMenu(15, poutOut,"过期物料", "expireMaterials", "system/expireMaterials/index", "sMaterial");
addDefaultFunctionMenu(16, poutOut,"生成工单", "createOrder", "system/createOrder/index", "createOrder");
//addDefaultFunctionMenu(16, poutOut,"生成工单", "createOrder", "system/createOrder/index", "createOrder");
addDefaultFunctionMenu(91,poutOut, "共享文件夹", "orderSetting", "system/orderSetting/index", "sysSet",DEFAULT_SHOW_MENU);
......@@ -185,7 +187,7 @@ public class MenuInit {
addDefaultFunctionMenu(41, pMenuWl,"元器件","componentParts", "parts/component/index","server",DEFAULT_SHOW_MENU);
//条形码:条码管理,条码设置
Menu pMenuBarcode = Menu.CreatePMenu("条形码", 7, "barcodes ", "barcodeMenu",null);
Menu pMenuBarcode = Menu.CreatePMenu("条形码", 7, "barcodes", "barcodeMenu",null);
addDefaultFunctionMenu(51,pMenuBarcode, "条码管理", "barcode", "barcode/barcode/index","chart",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(52, pMenuBarcode, "条码设置","barcodeSetting", "system/barcodeSetting/index", "barcode",DEFAULT_SHOW_MENU);
......@@ -204,17 +206,24 @@ public class MenuInit {
addDefaultFunctionMenu(72, pMenuReport,"库存", "inventory", "neolight/inventory/index", "inventory");
addDefaultFunctionMenu(73, pMenuReport,"温湿度", "humiture", "humiture/humitureReport/index", "humiture");
addDefaultFunctionMenu(73, pMenuReport,"温湿度", "spHumiture", "humiture/spHumitureReport/index", "humiture");
addDefaultFunctionMenu(74,pMenuReport, "安全库存", "safetyInventory", "system/safetyInventory/index", "safeInventory");
addDefaultFunctionMenu(75, pMenuReport,"过期物料", "expireMaterials", "system/expireMaterials/index", "sMaterial");
addDefaultFunctionMenu(81,pMenuReport, "物料追踪", "materialChart", "neolight/materialChart/index", "maChart");
//可观测性:物料追踪
Menu guanceMenu = Menu.CreatePMenu("可观测性", 10, "observability", "scanKey",null);
addDefaultFunctionMenu(81,guanceMenu, "物料追踪", "materialChart", "neolight/materialChart/index", "maChart");
//Menu guanceMenu = Menu.CreatePMenu("可观测性", 10, "observability", "scanKey",null);
//addDefaultFunctionMenu(81,guanceMenu, "物料追踪", "materialChart", "neolight/materialChart/index", "maChart");
//物联网:共享文件夹
//Menu pMenuWulian = Menu.CreatePMenu("物联网", 11, "internet", "interMenu",null);
//用户管理:用户管理,角色管理
Menu pMenuUser = Menu.CreatePMenu("用户管理", 12, "userManager", "Steve-Jobs", null);
addDefaultFunctionMenu(111, pMenuUser,"用户管理", "peoples", "system/user/index", "peoples",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(112, pMenuUser,"角色管理", "role", "system/role/index", "role",DEFAULT_SHOW_MENU);
//设置:料仓管理,菜单管理
Menu poutSet = Menu.CreatePMenu("设置", 12, "system","system",null);
Menu poutSet = Menu.CreatePMenu("设置", 13, "system","system",null);
addDefaultFunctionMenu(101, poutSet, "设备管理", "bunker", "storage/storage/index", "database",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(102,poutSet, "库位管理", "storagePos", "storagePos/storagePos/index", "tree-table",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(103, poutSet, "菜单管理", "menu", "system/menu/index", "menu");
......@@ -224,16 +233,7 @@ public class MenuInit {
addDefaultFunctionMenu(105,poutSet, "资源翻译", "translation", "system/translation/index", "translation");
// Menu orderSet = new Menu(, "orderSetting", "工单设置", "orderSetting", "system/orderSetting/index", "sysSet");
addDefaultFunctionMenu(106,poutSet, "料架设置", "shelfSetting", "system/shelfSetting/index", "translation",NL_SHOW_MENU);
//用户管理:用户管理,角色管理
Menu pMenuUser = Menu.CreatePMenu("用户管理", 13, "userManager", "Steve-Jobs", null);
addDefaultFunctionMenu(111, pMenuUser,"用户管理", "peoples", "system/user/index", "peoples",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(112, pMenuUser,"角色管理", "role", "system/role/index", "role",DEFAULT_SHOW_MENU);
//条形码:条码管理,条码设置
Menu selfAudit = Menu.CreatePMenu("盘点管理", 14, "selfAuditManagerment", "selfAudit",null);
addDefaultFunctionMenu(121,selfAudit, "盘点", "selfAudit", "system/selfAudit/index","selfAudit");
addDefaultFunctionMenu(122, selfAudit, "盘点记录","selfAuditLog", "system/selfAuditLog/index", "selfAuditLog");
addDefaultFunctionMenu(107,poutSet, "其他设备", "storageOther", "storage/storageOther/index", "storageOther");
Menu helpAbout = Menu.CreatePMenu("帮助", 9999, "help", "help",null);
addDefaultFunctionMenu(99991, helpAbout, "说明书", "instruction", "system/instruction/index","aboutBook");
......
package com.neotel.smfcore.core.apiInteraction.bean.query;
import com.neotel.smfcore.core.apiInteraction.enums.ApiInteraction_Status;
import lombok.Data;
import java.util.Date;
@Data
public class ApiInteractionQuery {
private Date requestDate;
//private String url;
//private String param;
//private String result;
private String status = ApiInteraction_Status.OK;
}
package com.neotel.smfcore.core.apiInteraction.controller;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.core.apiInteraction.bean.query.ApiInteractionQuery;
import com.neotel.smfcore.core.apiInteraction.service.manager.IApiInteractionManager;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RequestMapping("/apiInteraction")
@RestController
public class ApiInteractionController {
@Autowired
private IApiInteractionManager apiInteractionManager;
@ApiOperation("接口情况记录查询")
@RequestMapping("/list")
@AnonymousAccess
public PageData list(ApiInteractionQuery query, Pageable pageable){
Query q = QueryHelp.getQuery(query);
return apiInteractionManager.findByPage(q,pageable);
}
}
package com.neotel.smfcore.core.apiInteraction.enums;
public class ApiInteraction_Status {
public static String OK = "ok";
public static String ERROE = "error";
}
package com.neotel.smfcore.core.apiInteraction.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface IApiInteractionDao extends IBaseDao {
}
package com.neotel.smfcore.core.apiInteraction.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.core.apiInteraction.service.dao.IApiInteractionDao;
import com.neotel.smfcore.core.apiInteraction.service.po.ApiInteraction;
import org.springframework.stereotype.Service;
@Service
public class ApiInteractionDaoImpl extends AbstractBaseDao implements IApiInteractionDao {
@Override
public Class getEntityClass() {
return ApiInteraction.class;
}
}
package com.neotel.smfcore.core.apiInteraction.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.apiInteraction.service.po.ApiInteraction;
public interface IApiInteractionManager extends IBaseManager<ApiInteraction> {
}
package com.neotel.smfcore.core.apiInteraction.service.manager.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.apiInteraction.service.dao.IApiInteractionDao;
import com.neotel.smfcore.core.apiInteraction.service.manager.IApiInteractionManager;
import com.neotel.smfcore.core.apiInteraction.service.po.ApiInteraction;
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 ApiInteractionManagerImpl extends AbstractBaseDao implements IApiInteractionManager {
@Autowired
private IApiInteractionDao apiInteractionDao;
@Override
public Class getEntityClass() {
return ApiInteraction.class;
}
@Override
public ApiInteraction get(String id) {
return apiInteractionDao.findOneById(id);
}
@Override
public ApiInteraction save(ApiInteraction object) throws ValidateException {
return apiInteractionDao.save(object);
}
@Override
public void delete(ApiInteraction object) throws ValidateException {
apiInteractionDao.removeOne(object);
}
@Override
public PageData<ApiInteraction> findByPage(Query query, Pageable pageable) {
int totalCount = apiInteractionDao.countByQuery(query);
List<ApiInteraction> list = apiInteractionDao.findByQuery(query, pageable);
return new PageData<>(list, totalCount);
}
}
package com.neotel.smfcore.core.apiInteraction.service.po;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.core.apiInteraction.enums.ApiInteraction_Status;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiInteraction extends BasePo implements Serializable {
private Date requestDate;
private String url;
private String param;
private String result;
private String status = ApiInteraction_Status.OK;
}
......@@ -230,7 +230,11 @@ public class SmdBoxMimoController {
} else {
dto.setType(1);
}
int usage = (storage.getTotalSlots() - storage.getEmptySlots()) * 100 / storage.getTotalSlots();
int usage = 0;
if(storage.getTotalSlots()>0){
usage= (storage.getTotalSlots() - storage.getEmptySlots()) * 100 / storage.getTotalSlots();
}
dto.setUsage(usage);
int inCount = getTodayInOutCount(storage.getId(), inOutDataList, true);
......@@ -346,8 +350,8 @@ public class SmdBoxMimoController {
// }
int allCount = inTask + outTask;
BoxStatusDto boxDto = new BoxStatusDto(storage.getId(), storage.getName(), storage.getCid(), false, 0,
"0", "0","0", "", allCount, inTask, outTask,
0, "", "", "", "", "",storage.getType(),storage.getUsageMap(),new HashMap<>(),storage.getInListName());
"0", "0","0","", "", allCount, inTask, outTask,
0, "", "", "", "", "",storage.getType(),storage.getUsageMap(),new HashMap<>(),storage.getInListName(),"","","","");
//获取设备状态,设置状态和当前任务信息
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
......@@ -371,10 +375,12 @@ public class SmdBoxMimoController {
} else {
boxDto.setOnLine(true);
for (BoxStatusBean boxStatus : bean.getBoxStatus().values()) {
String humidity = boxStatus.getHumidity();
String temperature = boxStatus.getTemperature();
boxDto.setHumidity(humidity);
boxDto.setTemperature(temperature);
// String humidity = boxStatus.getHumidity();
// String temperature = boxStatus.getTemperature();
// boxDto.setHumidity(humidity);
// boxDto.setTemperature(temperature);
boxDto.UpdateTemp(boxStatus);
MSDSettiings settiings = dataCache.getCache(Constants.CACHE_msdSetting);
if (settiings != null) {
if (settiings.getMinHumidity() == -1f) {
......@@ -384,7 +390,8 @@ public class SmdBoxMimoController {
boxDto.setTemperature(0 + "");
}
}
boxDto.setCodeAirTemp(boxStatus.getCodeAirTemp());
// boxDto.setCodeAirTemp(boxStatus.getCodeAirTemp());
// boxDto.setCodeAirTemp2(boxStatus.getCodeAirTemp2());
boxDto.setStatus(bean.getStatus());
boxDto.setMsg(bean.getShowMsg(locale));
boxDto.setBarcode(bean.getCode());
......
......@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.device.bean;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.core.device.enums.BOX_STATUS;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
......@@ -9,6 +10,7 @@ import java.util.Map;
/**
* Created by sunke on 17/2/13.
*/
@Data
public class BoxStatusBean {
/// <summary>
......@@ -46,18 +48,41 @@ public class BoxStatusBean {
public String[] msgParam ;
/// <summary>
/// 温度
/// 温度/锡膏料仓为冷藏区温度
/// </summary>
public String temperature;
/// <summary>
/// 湿度
/// 湿度/锡膏料仓为冷藏区湿度
/// </summary>
public String humidity;
/**
* 冷气机温度
* 制冷温度1
*/
public String codeAirTemp;
/**
* 制冷温度2
*/
public String codeAirTemp2 ;
/**
* 冷藏区温度2
*/
public String temperature2 ;
/**
* 冷藏区湿度
*/
public String humidity2 ;
/**
* 回温区温度
*/
public String wTemp ;
/**
* 回温区湿度
*/
public String wHum ;
public int getBoxId() {
return boxId;
......@@ -191,11 +216,19 @@ public class BoxStatusBean {
return -1;
}
public String getCodeAirTemp() {
return codeAirTemp;
}
// public String getCodeAirTemp() {
// return codeAirTemp;
// }
public void setCodeAirTemp(String codeAirTemp) {
this.codeAirTemp = codeAirTemp;
}
// public String getCodeAirTemp2() {
// return codeAirTemp2;
// }
//
// public void setCodeAirTemp2(String codeAirTemp2) {
// this.codeAirTemp2 = codeAirTemp2;
// }
}
......@@ -703,15 +703,23 @@ public class StatusBean {
return returnMsg;
}
public String getErrorMsg(Locale locale) {
public String getErrorMsg(Locale locale){
String msg=getMsgByType(locale,MessageType.ERROR.name() );
if(ObjectUtil.isEmpty(msg)){
msg=getMsgByType(locale,MessageType.WARNING.name());
}
return msg;
}
public String getMsgByType(Locale locale,String msgType) {
if (ObjectUtil.isEmpty(this.msgList)) {
return "";
}
for (MsgInfo msg :
msgList) {
if (msg.getType().toUpperCase().equals(MessageType.ERROR.name())) {
return msg.getMsg();
if (msg.getType().toUpperCase().equals(msgType)) {
return GetMsgStr(msg,locale);
}
}
return "";
......
......@@ -432,6 +432,10 @@ public class BaseDeviceHandler implements IDeviceHandler {
if (pos != null) {
Storage storage = dataCache.getStorageById(pos.getStorageId());
log.info("出库已在库位中的物料[" + barcodeSave.getBarcode() + "]");
String msg=MessageUtils.getText("smfcore.error.barcode.inStorage",new String[]{barcodeSave.getBarcode(), storage.getName(), pos.getPosName()},MessageUtils.getDefaultLocal(),
"[ " + barcodeSave.getBarcode() + "]已在" + storage.getName() + "[" + pos.getPosName() + "]中");
taskService.checkout(storage, pos, true, true, "", "", msg);
throw new ValidateException("smfcore.error.barcode.inStorage", "[ " + barcodeSave.getBarcode() + "]已在" + storage.getName() + "[" + pos.getPosName() + "]中", new String[]{barcodeSave.getBarcode(), storage.getName(), pos.getPosName()});
}
......@@ -949,10 +953,26 @@ public class BaseDeviceHandler implements IDeviceHandler {
String humidity = boxStatus.getHumidity();
String temperature = boxStatus.getTemperature();
String codeAirTemp = boxStatus.getCodeAirTemp();
String codeAirTemp2=boxStatus.getCodeAirTemp2();
if (!Strings.isNullOrEmpty(humidity) && !Strings.isNullOrEmpty(temperature)) {
humiture.setHumidity(humidity);
humiture.setTemperature(temperature);
humiture.setCodeAirTemp(codeAirTemp);
if(ObjectUtil.isNotEmpty(codeAirTemp2)){
humiture.setCodeAirTemp2(codeAirTemp2);
}
if(ObjectUtil.isNotEmpty(boxStatus.getWHum())){
humiture.setWHum(boxStatus.getWHum());
}
if(ObjectUtil.isNotEmpty(boxStatus.getWTemp())){
humiture.setWTemp(boxStatus.getWTemp());
}
if(ObjectUtil.isNotEmpty(boxStatus.getTemperature2())){
humiture.setTemperature2(boxStatus.getTemperature2());
}
if(ObjectUtil.isNotEmpty(boxStatus.getHumidity2())){
humiture.setHumidity2(boxStatus.getHumidity2());
}
try {
humitureManager.save(humiture);
statusBean.setLastSaveTime(System.currentTimeMillis());
......
package com.neotel.smfcore.core.device.handler.impl;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class XLROneBoxHandler extends XLRBoxHandler{
@Override
public DeviceType getDeviceType() {
return DeviceType.SMD_ONE;
}
}
......@@ -1011,6 +1011,8 @@ public class DeviceController {
//生成一条入库任务
barcode.setPosName(targetPos.getPosName());
barcodeManager.save(barcode);
DataLog targetPosTask = new DataLog(storage, barcode, targetPos);
targetPosTask.setOperator("admin-move");
targetPosTask.setType(OP.PUT_IN);
......
......@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.device.rest;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.system.util.EquipStatusUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -27,6 +28,19 @@ public class VideoController {
String cid = params.get("cid");
String img = params.get("img");
updateVideo(cid,img);
if(params.size()>2){
Map<String, String> data=new HashMap<>();
for (String key :params.keySet()){
if(key.equals("cid")||key.equals("img")){
continue;
}
data.put(key, params.get(key));
}
if(data.size()>0){
EquipStatusUtil.updateData(cid,data);
}
}
} catch (Exception e) {
log.error("出错:", e);
......
......@@ -669,8 +669,21 @@ public class DataCache {
return storageInventoryMap;
}
public List<InventoryItem> getInventoryByPN(String pn) {
Map<String, InventoryItem> inventoryItemMap = getAllInventory(null, "");
public List<InventoryItem> getInventoryByPN(String pn,List<String> cids) {
List<String> storageIds=new ArrayList<>();
if(cids.size()>0){
for (String cid :
cids) {
Storage storage=getStorage(cid);
if(storage!=null){
storageIds.add(storage.getId());
}
}
}
if(storageIds.size()<=0){
storageIds=null;
}
Map<String, InventoryItem> inventoryItemMap = getAllInventory(storageIds, "");
List<InventoryItem> list = Lists.newArrayList(inventoryItemMap.values());
List<InventoryItem> resultList = new ArrayList<>();
......@@ -810,6 +823,23 @@ public class DataCache {
}
return availableStorageIds;
}
public List<String> getAvailableStorageIds(List<String> cidList) {
if(cidList==null||cidList.size()<=0){
return getAvailableStorageIds();
}
List<String> availableStorageIds = new ArrayList<>();
for (Storage storage : getAllStorage().values()) {
if(!cidList.contains(storage.getCid())){
continue;
}
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean == null || bean.timeOut() || !bean.isAvailable()) {
continue;
}
availableStorageIds.add(storage.getId());
}
return availableStorageIds;
}
public List<String> getAvailableStorageIds(DeviceType deviceType) {
List<String> availableStorageIds = new ArrayList<>();
for (Storage storage : getAllStorage().values()) {
......
......@@ -2,13 +2,17 @@ package com.neotel.smfcore.core.equipment.bean;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.core.language.util.MessageUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.Locale;
@ToString
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EquipMsg {
/**
* 设备模块
......
package com.neotel.smfcore.core.equipment.enums;
import com.google.common.collect.Lists;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import java.util.List;
/**
* 设备类型(非料仓)
*/
......@@ -50,5 +55,15 @@ public enum EquipmentType {
/**
* 韩华
*/
HANWHA()
HANWHA(),
/**
* NEXIM
*/
NEXIM();
public static List<EquipmentType> availableTypeList(){
return Lists.newArrayList(AUTO,NEOSCAN,NS200,COUNTING,NEOSTATION,FUJINEOLINK,PANACIMNEOLINK,AGV,HANWHA,NEXIM);
}
}
......@@ -54,6 +54,8 @@ public class EquipCommunicationController {
log.error("设备cid: [" + cid + "]不存在,自动创建设备失败");
return null;
}
/*log.info("设备cid: [" + cid + "]不存在");
return null;*/
} else {
if (StringUtils.isNotBlank(name)) {
if (!name.equals(equipment.getName())) {
......
......@@ -16,6 +16,8 @@ import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.EquipStatusUtil;
import com.neotel.smfcore.custom.fuji.bean.FujiConfig;
import com.neotel.smfcore.custom.fuji.config.FujiCacheConfig;
import com.neotel.smfcore.custom.hanwha.handler.TMSCommunicator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -57,7 +59,7 @@ public class EquipViewController {
Map<String,Equipment> allEquipList= equipmentCache.getAllEquipment();
for (Equipment equip :
allEquipList.values()) {
EquipStatusDto dto=new EquipStatusDto(equip.getId(),equip.getName(),equip.getCid(),false,0,"",equip.getType());
EquipStatusDto dto=new EquipStatusDto(equip.getId(),equip.getName(),equip.getCid(),false,0,"",equip.getType(),false);
EquipStatusBean bean= EquipStatusUtil.getStatusBean(equip.getCid());
if(bean!=null){
if(bean.timeOut()){
......@@ -74,6 +76,11 @@ public class EquipViewController {
dto.setOnLine(true);
dto.setStatus(1);
}
} else if (equip.getType().equalsIgnoreCase(EquipmentType.NEXIM.name())){
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config != null){
dto.setActivate(true);
}
}
resultList.add(dto);
......@@ -83,7 +90,7 @@ public class EquipViewController {
Collection<Storage> storages = dataCache.getAllStorage().values();
for (Storage storage : storages) {
if (storage.getType().equals(DeviceType.NLL.name())){
EquipStatusDto dto=new EquipStatusDto(storage.getId(),storage.getName(),storage.getCid(),false,0,"",storage.getType());
EquipStatusDto dto=new EquipStatusDto(storage.getId(),storage.getName(),storage.getCid(),false,0,"",storage.getType(),false);
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean == null || bean.timeOut()){
dto.setOnLine(false);
......@@ -126,6 +133,17 @@ public class EquipViewController {
}
}
Map<String,String> data=EquipStatusUtil.getData(equip.getCid());
if(data==null||data.size()<=0){
data=new HashMap<>();
// data.put("RI","RI9793003");
// data.put("PN","STX8374");
// data.put("QTY","9870");
dto.setPrintData(data);
}else {
dto.setPrintData(data);
}
// if(dto.getShowLogs().size()<=0){
// EquipMsg msg=new EquipMsg();
// msg.setModule("module1");
......
package com.neotel.smfcore.core.equipment.rest;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import com.neotel.smfcore.core.equipment.rest.dto.EquipmentDto;
import com.neotel.smfcore.core.equipment.rest.mapstruct.EquipmentMapper;
import com.neotel.smfcore.core.equipment.rest.query.EquipmentQueryCriteria;
import com.neotel.smfcore.core.equipment.service.manager.IEquipmentManager;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import com.neotel.smfcore.core.equipment.util.EquipmentCache;
import com.neotel.smfcore.core.storage.rest.dto.StorageDto;
import com.neotel.smfcore.core.storage.rest.query.StorageQueryCriteria;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@Slf4j
@RestController
......@@ -12,4 +39,118 @@ import org.springframework.web.bind.annotation.RestController;
@Api(tags = "设备管理(非料仓)")
@RequestMapping("api/equipment")
public class EquipmentController {
@Autowired
private IEquipmentManager equipmentManager;
@Autowired
private EquipmentMapper equipmentMapper;
@Autowired
private EquipmentCache equipmentCache;
@ApiOperation("查询非料仓设备")
@GetMapping
//@AnonymousAccess
public PageData<EquipmentDto> query(EquipmentQueryCriteria criteria, Pageable pageable){
Query query= QueryHelp.getQuery(criteria);
PageData<Equipment> pages = equipmentManager.findByPage(query, pageable);
List<EquipmentDto> equipmentDtos =equipmentMapper.toDto(pages.getContent());
return new PageData(equipmentDtos,pages.getTotalElements());
}
@ApiOperation("新增非料仓")
@PostMapping
//@AnonymousAccess
public ResponseEntity<Object> create(@Validated @RequestBody EquipmentDto equipmentDto) {
Equipment equipment = equipmentMapper.toEntity(equipmentDto);
if(StringUtils.isEmpty(equipment.getName())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"name"} );
} if(StringUtils.isEmpty(equipment.getCid())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"cid"} );
} if(StringUtils.isEmpty(equipment.getType())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"type"} );
}
for (Equipment equ : equipmentCache.getAllEquipment().values()) {
if (!equipment.getId().equals(equ.getId())){
if(equipment.getName().equals(equ.getName())){
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"name",equipment.getName()});
}
if(equipment.getCid().equals(equ.getCid())){
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"cid",equipment.getCid()});
}
}
}
equipment = equipmentManager.save(equipment);
equipmentCache.reloadEquipment(equipment,equipment.getCid());
return new ResponseEntity<>(HttpStatus.CREATED);
}
@ApiOperation("修改非料仓")
@PutMapping
//@AnonymousAccess
public ResponseEntity<Object> update(@Validated @RequestBody EquipmentDto equipmentDto) {
Equipment equipment=equipmentMapper.toEntity(equipmentDto);
if (StringUtils.isEmpty(equipment.getId())) {
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"ID"} );
}
if(StringUtils.isEmpty(equipment.getName())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"name"} );
} if(StringUtils.isEmpty(equipment.getCid())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"cid"} );
} if(StringUtils.isEmpty(equipment.getType())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"type"} );
}
for (Equipment equ : equipmentCache.getAllEquipment().values()) {
if (!equipment.getId().equals(equ.getId())){
if(equipment.getName().equals(equ.getName())){
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"name",equipment.getName()});
}
if(equipment.getCid().equals(equ.getCid())){
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"cid",equipment.getCid()});
}
}
}
equipmentManager.save(equipment);
equipmentCache.reloadEquipment(equipment,equipment.getCid());
return new ResponseEntity<>(HttpStatus.OK);
}
@ApiOperation("删除非料仓设备")
@DeleteMapping
//@AnonymousAccess
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
for (String id : ids) {
if (id == null) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"ID"});
}
}
for (String id : ids) {
Equipment equipment = equipmentManager.get(id);
if (equipment == null){
continue;
}
equipmentCache.removeEquipment(equipment);
equipmentManager.deleteById(id);
log.info(SecurityUtils.getLoginUsername()+"手动删除设备[{}]",equipment.getName());
}
return new ResponseEntity<>(HttpStatus.OK);
}
@ApiOperation("返回所有非料仓类型")
@GetMapping(value = "/typeList")
//@AnonymousAccess
public List<String> typeList() {
List<EquipmentType> availableTypeList= EquipmentType.availableTypeList();
List<String> allList=new ArrayList<>();
for (EquipmentType type :
availableTypeList) {
allList.add(type.name());
}
return allList;
}
}
......@@ -33,5 +33,6 @@ public class EquipStatusDto implements Serializable {
@ApiModelProperty("设备类型,NEOSCAN=扫码贴标,COUNTING=点料机")
private String type = EquipmentType.AUTO.name();
@ApiModelProperty("是否激活")
private boolean activate = false;
}
......@@ -20,4 +20,6 @@ public class EquipmentDto {
@ApiModelProperty("是否可用")
private boolean available = true;
private String id;
}
......@@ -45,4 +45,8 @@ public class NsViewDto implements Serializable {
* key=MES,value=MES最后一次对接信息:格式参考NsMesInfo
*/
private Map<String, Object> data = new HashMap<>();
/**
* NS打印数据
*/
private Map<String, String> printData = new HashMap<>();
}
package com.neotel.smfcore.core.equipment.rest.mapstruct;
import com.neotel.smfcore.common.base.BaseMapper;
import com.neotel.smfcore.core.equipment.rest.dto.EquipmentDto;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring" ,unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface EquipmentMapper extends BaseMapper<EquipmentDto, Equipment> {
}
package com.neotel.smfcore.core.equipment.rest.query;
import com.neotel.smfcore.common.annotation.QueryCondition;
import com.neotel.smfcore.common.bean.BetweenData;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class EquipmentQueryCriteria {
@QueryCondition(blurry = "name,cid")
private String blurry;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "updateDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> createDate;
}
package com.neotel.smfcore.core.equipment.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import java.util.List;
public interface IEquipmentManager extends IBaseManager<Equipment> {
List<Equipment> findAll();
void deleteById(String id);
}
......@@ -50,4 +50,9 @@ public class EquipmentManagerImpl implements IEquipmentManager {
public List<Equipment> findAll(){
return equipmentDao.findAll();
}
@Override
public void deleteById(String id) {
equipmentDao.removeOneById(id);
}
}
......@@ -28,6 +28,6 @@ public class Equipment extends BasePo implements Serializable {
private boolean available = true;
public boolean isNEOSCAN() {
return EquipmentType.NEOSCAN.name().equals(type);
return EquipmentType.NEOSCAN.name().equals(type)||EquipmentType.NS200.name().equals(type);
}
}
......@@ -423,8 +423,8 @@ public class BoxKanbanController {
// }
int allCount = inTask + outTask;
BoxStatusDto boxDto = new BoxStatusDto(storage.getId(), storage.getName(), storage.getCid(), false, 0,
"0", "0", "0", "", allCount, inTask, outTask,
0, "", "", "", "", "", storage.getType(), storage.getUsageMap(), new HashMap<>(), storage.getInListName());
"0", "0", "0","", "", allCount, inTask, outTask,
0, "", "", "", "", "", storage.getType(), storage.getUsageMap(), new HashMap<>(), storage.getInListName(),"","","","");
//获取设备状态,设置状态和当前任务信息
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
......@@ -448,10 +448,11 @@ public class BoxKanbanController {
} else {
boxDto.setOnLine(true);
for (BoxStatusBean boxStatus : bean.getBoxStatus().values()) {
String humidity = boxStatus.getHumidity();
String temperature = boxStatus.getTemperature();
boxDto.setHumidity(humidity);
boxDto.setTemperature(temperature);
// String humidity = boxStatus.getHumidity();
// String temperature = boxStatus.getTemperature();
// boxDto.setHumidity(humidity);
// boxDto.setTemperature(temperature);
boxDto.UpdateTemp(boxStatus);
MSDSettiings settiings = dataCache.getCache(Constants.CACHE_msdSetting);
if (settiings != null) {
if (settiings.getMinHumidity() == -1f) {
......@@ -461,7 +462,8 @@ public class BoxKanbanController {
boxDto.setTemperature(0 + "");
}
}
boxDto.setCodeAirTemp(boxStatus.getCodeAirTemp());
// boxDto.setCodeAirTemp(boxStatus.getCodeAirTemp());
// boxDto.setCodeAirTemp2(boxStatus.getCodeAirTemp2());
boxDto.setStatus(bean.getStatus());
boxDto.setMsg(bean.getShowMsg(locale));
boxDto.setBarcode(bean.getCode());
......
package com.neotel.smfcore.core.kanban.rest.bean.dto;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.storage.bean.UsageItem;
import com.neotel.smfcore.core.storage.enums.DeviceType;
......@@ -31,12 +32,14 @@ public class BoxStatusDto {
@ApiModelProperty("单台BOX状态,0=离线,1=正常运行中, 2=急停,3=故障,4=警告,5=调试中,6入库执行中,7入仓位完成,8入库失败, 9出库执行中,10出仓位完成,11出库失败,12移栽出库,13 重置中,14 扫码入库失败 ")
private int status=0;
@ApiModelProperty("温度")
@ApiModelProperty("温度/锡膏料仓冷藏区温度")
private String temperature;
@ApiModelProperty("湿度")
@ApiModelProperty("湿度/锡膏料仓冷藏区湿度")
private String humidity;
@ApiModelProperty("冷气机温度")
@ApiModelProperty("制冷温度1")
private String codeAirTemp;
@ApiModelProperty("制冷温度2")
private String codeAirTemp2;
@ApiModelProperty("文字显示")
private String msg = "";
......@@ -77,9 +80,33 @@ public class BoxStatusDto {
//取出出库料盘:takeOutReel
//关闭仓门:confirmReelOut
// 状态显示: disable:不可用,enable:可用,点击按钮后发送 doit
//mixingSpeed !=0表示工作中
private Map<String, String> data = new HashMap<>();
@ApiModelProperty("当前绑定的入库单名称")
private String inListName="";
@ApiModelProperty("冷藏区温度2")
public String temperature2 ;
@ApiModelProperty("冷藏区湿度")
public String humidity2 ;
@ApiModelProperty("回温区温度")
public String wTemp ;
@ApiModelProperty("回温区湿度")
public String wHum ;
public void UpdateTemp(BoxStatusBean boxStatus) {
String humidity = boxStatus.getHumidity();
String temperature = boxStatus.getTemperature();
setHumidity(humidity);
setTemperature(temperature);
setWTemp(boxStatus.getWTemp());
setWHum(boxStatus.getWHum());
setCodeAirTemp(boxStatus.getCodeAirTemp());
setCodeAirTemp2(boxStatus.getCodeAirTemp2());
setTemperature2(boxStatus.getTemperature2());
setHumidity2(boxStatus.getHumidity2());
}
}
......@@ -471,7 +471,7 @@ public class OrderController {
}
String result = liteOrderCache.closeOrder(orderNo);
if (ObjectUtil.isEmpty(result)) {
if (ObjectUtil.isEmpty(result) || "smfcore.order.close.success".equals(result)) {
return ResultBean.newOkResult(result, result);
} else {
return ResultBean.newErrorResult(-1, result, result);
......
......@@ -9,7 +9,9 @@ import org.springframework.data.annotation.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Getter
@Setter
......@@ -89,4 +91,7 @@ public class OrderDto implements Serializable {
@ApiModelProperty("工单线别")
private String line = "";
@ApiModelProperty("附加字段")
private Map<String,String> appendData = new HashMap<>();
}
package com.neotel.smfcore.core.order.service.po;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.order.enums.LITEORDER_STATUS;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
......@@ -92,6 +94,13 @@ public class LiteOrder extends BasePo implements Serializable {
@Transient
private List<LiteOrderItem> orderItems;
/**
* 锁定的物料,关闭工单时,TMS需要更新锁定物料状态
*/
@Transient
private List<StoragePos> lockReelList;
/**
* 建议出仓时间
*/
......@@ -220,4 +229,28 @@ public class LiteOrder extends BasePo implements Serializable {
}
return "";
}
public void setCidList(List<String> rackList){
String cids=String.join(",",rackList);
addAppendDate("cids",cids);
}
public List<String> getCidList() {
String cids = getAppend("cids");
if (ObjectUtil.isEmpty(cids)) {
return new ArrayList<>();
} else {
String[] cidList = cids.split(",");
List<String> rackList = new ArrayList<>();
for (String cid :
cidList) {
rackList.add(cid);
}
return rackList;
}
}
}
......@@ -381,6 +381,9 @@ public class SpBoxController {
//入库验证
try {
Barcode barcodeSave = smfApi.canPutInBeforeResolve(params);
if(barcodeSave == null){
barcodeSave = barcode;
}
if (barcodeSave == null) {
log.info("库位【" + storagePos.getPosName() + "】" + barcode.getBarcode() + " 回库验证失败:条码为空,直接出库");
outMsg= MessageUtils.getText("smfcore.spbox.backFail",MessageUtils.getDefaultLocal(),"回库验证失败");
......
......@@ -154,6 +154,11 @@ public enum DeviceType {
* 25 SMD_MIMO_G3
*/
SMD_MIMO_G3("storage.type.smdMimoG3"),
/**
* 26 smdOne
*/
SMD_ONE("storage.type.smdOne"),
;
private String key;
......@@ -175,6 +180,6 @@ public enum DeviceType {
}
public static List<DeviceType> availableTypeList(){
return Lists.newArrayList(AUTO,LINE,BATCH,SOLDERPASTE,VERTICALBOX,SMD_XL,SMD_DUO,SMD_XLC,SMD_XLR,VIRTUAL,NL,NLP,NLM,NLL,NLS,NLSM,SMDBOX_THIRD,SMD_MIMO_G2,SMD_MIMO_G3);
return Lists.newArrayList(AUTO,LINE,BATCH,SOLDERPASTE,VERTICALBOX,SMD_XL,SMD_DUO,SMD_XLC,SMD_XLR,SMD_ONE,VIRTUAL,NL,NLP,NLM,NLL,NLS,NLSM,SMDBOX_THIRD,SMD_MIMO_G2,SMD_MIMO_G3);
}
}
......@@ -435,6 +435,10 @@ public class StorageController {
titles.add("pri");
titles.add(("h"));
titles.add("w");
titles.add("column"); //列
titles.add("magazine"); //模组
titles.add("layer"); //层
titles.add("slot"); //槽位
for(int i=1;i<=10;i++) {
Map<String, Object> map = new LinkedHashMap<>();
......@@ -443,6 +447,10 @@ public class StorageController {
map.put("pri", i);
map.put("h", 8);
map.put("w", 7);
map.put("column", "");
map.put("magazine", "");
map.put("layer", "");
map.put("slot", "");
maps.add(map);
}
......@@ -477,6 +485,10 @@ public class StorageController {
int warmPosIndex = csvRead.getHasCsvIndex("回温库位","warmPos");//true表示回温区库位,
int areaIndex = csvRead.getHasCsvIndex("区域","area");
int posTypeIndex = csvRead.getHasCsvIndex("库位类型","posType");
int columnIndex = csvRead.getHasCsvIndex("列","column");
int magazineIndex = csvRead.getHasCsvIndex("模组","magazine");
int layerIndex = csvRead.getHasCsvIndex("层","layer");
int slotIndex = csvRead.getHasCsvIndex("槽位","slot");
int row = 1;
......@@ -495,6 +507,22 @@ public class StorageController {
Integer width =0;
String labelName="";
Integer posType=0;
String column = "";
String magazine="";
String layer="";
String slot="";
if(columnIndex>=0){
column=lineValues[columnIndex]; //lie
}
if(magazineIndex>=0) {
magazine = lineValues[magazineIndex]; //模组
}
if(layerIndex>=0) {
layer = lineValues[layerIndex]; //层
}
if(slotIndex>=0) {
slot = lineValues[slotIndex]; //槽位
}
try {
priority =Integer.parseInt(lineValues[priIndex]) ;
height = Integer.parseInt(lineValues[hIndex]);
......@@ -535,6 +563,10 @@ public class StorageController {
posInfo=new StoragePos(storageId,posName,height,width,priority);
posInfo.setWarmPos(isWarmPos);
posInfo.setLabelName(labelName);
posInfo.setColumn(column);
posInfo.setMagazine(magazine);
posInfo.setSlot(slot);
posInfo.setLayer(layer);
newRowCount++;
newList.add(posInfo);
}else{
......@@ -553,6 +585,26 @@ public class StorageController {
posInfo.setLabelName(labelName);
needUpdate=true;
}
column = column == null ? "" : column;
magazine = magazine == null ? "" : magazine;
layer = layer == null ? "" : layer;
slot = slot == null ? "" : slot;
if (!column.equals(posInfo.getColumn())){
posInfo.setColumn(column);
needUpdate = true;
}
if (!magazine.equals(posInfo.getMagazine())){
posInfo.setMagazine(magazine);
needUpdate = true;
}
if (!layer.equals(posInfo.getLayer())){
posInfo.setLayer(layer);
needUpdate = true;
}
if (!slot.equals(posInfo.getSlot())){
posInfo.setSlot(slot);
needUpdate = true;
}
if(needUpdate){
updateRowCount++;
storagePosManager.save(posInfo);
......
......@@ -116,6 +116,92 @@ public class StoragePosController {
}
@ApiOperation("导出库位列表")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('storagePos:list')")
public void download(HttpServletResponse response, StoragePosQueryCriteria criteria, Pageable pageable, HttpServletRequest request) throws IOException {
if (criteria.getStorageIdList() != null && criteria.getStorageIdList().contains("0")) {
criteria.setStorageIdList(null);
}
criteria.setStorageIdList(QueryHelp.getGroupStorageIdList(criteria.getStorageIdList()));
String blurry = criteria.getBlurry();
if(!Strings.isNullOrEmpty(blurry)){
//去除库位中的SOxxxx
blurry = blurry.substring(blurry.indexOf("-")+1);
criteria.setBlurry(blurry);
}
Locale locale = request.getLocale();
String enable=MessageUtils.getText("smfcore.storagePos.yes",locale,"是");
String noEnable= MessageUtils.getText("smfcore.storagePos.no",locale,"否");
Query query = QueryHelp.getQuery(criteria);
FileUtil.downloadExcel(query, pageable, response, new IExcelDownLoad() {
@Override
public List<List<String>> getHeader() {
List<List<String>> header = new ArrayList<>();
Locale locale = request.getLocale();
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.storageName",locale,"设备名称")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.posName",locale,"库位号")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.column",locale,"列")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.magazine",locale,"模组")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.layer",locale,"层")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.slot",locale,"槽位")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.available",locale,"是否可用")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.barcode",locale,"条码")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.partNumber",locale,"料件编号")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.plateSize",locale,"料盘尺寸")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.w",locale,"直径")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.h",locale,"厚度")));
return header;
}
@Override
public List<List<Object>> getPageData(Query query, Pageable pageable) {
List<List<Object>> dataList = new ArrayList<>();
List<Map<String, Object>> list = new ArrayList<>();
PageData<StoragePos> pages = storagePosManager.findByPage(query, pageable);
List<StoragePosDto> StoragePosDtos = storagePosMapper.toDto(pages.getContent());
for (int i=0;i<StoragePosDtos.size();i++){
Storage storage=dataCache.getStorageById(StoragePosDtos.get(i).getStorageId());
if(storage!=null){
StoragePosDtos.get(i).setStorageName(storage.getName());
}
}
for (StoragePosDto pos : StoragePosDtos) {
List<Object> data = new ArrayList<>();
data.add(pos.getStorageName());
data.add(pos.getPosName());
data.add(pos.getColumn());
data.add(pos.getMagazine());
data.add(pos.getLayer());
data.add(pos.getSlot());
data.add(pos.isEnabled()?(enable):noEnable);
if(pos.getBarcode()!=null){
data.add(pos.getBarcode().getBarcode());
data.add(pos.getBarcode().getPartNumber());
data.add(pos.getBarcode().getPlateSize()+"X"+pos.getBarcode().getHeight());
}else{
data.add("");
data.add("");
data.add("");
}
data.add(pos.getW());
data.add(pos.getH());
dataList.add(data);
}
return dataList;
}
});
}
@ApiOperation("删除指定料仓所有库位")
@PutMapping("/removeAllPos")
@PreAuthorize("@el.check('storagePos:edit')")
......@@ -410,6 +496,9 @@ public class StoragePosController {
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.posName",locale,"库位号")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.lockName",locale,"工单号")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.amount",locale,"数量")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.plateSize",locale,"料盘尺寸")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.w",locale,"直径")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.h",locale,"厚度")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.putInTime",locale,"首次入库时间")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.storagePos.putInDate",locale,"入库时间")));
......@@ -441,6 +530,9 @@ public class StoragePosController {
data.add(pos.getPosName());
data.add(pos.getBarcode().getLockName());
data.add(pos.getBarcode().getAmount());
data.add(pos.getBarcode().getPlateSize()+"X"+pos.getBarcode().getHeight());
data.add(pos.getW());
data.add(pos.getH());
data.add(putInTime);
data.add(dateFormat.format(pos.getBarcode().getPutInDate()));
dataList.add(data);
......@@ -470,6 +562,13 @@ public class StoragePosController {
// throw new ValidateException("位置[" + pid + "]不存在");
continue;
}
Barcode posBarcode = pos.getBarcode();
if (posBarcode == null){
log.info(pos.getPosName()+"库位上没有物料,跳过");
continue;
}
Storage storage = dataCache.getStorageById(pos.getStorageId());
if (storage == null) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"storageId", pos.getStorageId()});
......
......@@ -78,5 +78,15 @@ public class StoragePosDto implements Serializable {
@ApiModelProperty("组名称")
private String groupName = "";
@ApiModelProperty("列")
private String column;
@ApiModelProperty("模组")
private String magazine;
@ApiModelProperty("层")
private String layer;
@ApiModelProperty("槽位")
private String slot;
}
......@@ -14,7 +14,7 @@ import java.util.List;
@Data
public class StoragePosFindCriteria {
@QueryCondition(blurry = "barcode.partNumber,barcode.barcode,barcode.subCodeList.barcode,barcode.subCodeList.partNumber,posName,barcode.batch")
@QueryCondition(blurry = "barcode.partNumber,barcode.barcode,barcode.subCodeList.barcode,barcode.subCodeList.partNumber,posName,barcode.batch,barcode.provider")
private String blurry;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "barcode.putInDate")
......
......@@ -116,6 +116,26 @@ public class StoragePos extends BasePo implements Serializable {
*/
private List<String> mergePosList;
/**
* 列
*/
private String column;
/**
* 模组
*/
private String magazine;
/**
* 层
*/
private String layer;
/**
* 槽位
*/
private String slot;
public String getLabelStr(){
String posNameLabel = posName;
......
......@@ -81,7 +81,7 @@ public class SettingsController {
Integer expiresDay=dataCache.getCache(Constants.CACHE_ExpiresDay);
Integer caWarn=dataCache.getCache(Constants.CACHE_CapacityWarn);
Integer backUpMonth = dataCache.getCache(Constants.BACKUP_MONTH_KEY);
boolean closeWorkOrder = dataCache.getCache(Constants.CACHE_closeWorkOrder);
Boolean closeWorkOrder = dataCache.getCache(Constants.CACHE_closeWorkOrder);
SysSettingsDto dto = new SysSettingsDto();
dto.setStartJob(startJob);
dto.setStopOut(stopOut);
......@@ -89,7 +89,9 @@ public class SettingsController {
dto.setExpiresDay(expiresDay);
dto.setCapacityWarn(caWarn);
dto.setBackUpMonth(backUpMonth);
if (closeWorkOrder != null) {
dto.setCloseWorkOrder(closeWorkOrder);
}
return dto;
}
......
......@@ -17,18 +17,40 @@ public class Humiture extends BasePo implements Serializable {
* 料仓号
*/
private String cid;
/// <summary>
/// 温度/锡膏料仓为冷藏区温度
/// </summary>
public String temperature;
/// <summary>
/// 湿度/锡膏料仓为冷藏区湿度
/// </summary>
public String humidity;
/**
* 制冷温度1
*/
public String codeAirTemp="";
/**
* 制冷温度2
*/
public String codeAirTemp2="";
/**
* 冷藏区温度2
*/
public String temperature2="" ;
/**
*
* 冷藏区湿
*/
private String temperature;
public String humidity2="" ;
/**
* 温度2,用于锡膏料仓冷藏温度保存
* 回温区温度
*/
private String codeAirTemp;
public String wTemp="";
/**
* 湿度
* 回温区湿度
*/
private String humidity;
public String wHum="";
}
......@@ -195,7 +195,11 @@ public class DevicesStatusUtil {
}
}
if (newMsg) {
DeviceMessageUtil.addDeviceMessage(cid, MessageType.ERROR.name(), msg.getMoudle(), msg.getMsgKey(), msg.getMsg(), msg.getMsgParam(),msg.getAlarmType(),msg.getAlarmCode());
String msgType= msg.getType();
if(ObjectUtil.isEmpty(msgType)){
msgType=MessageType.ERROR.name();
}
DeviceMessageUtil.addDeviceMessage(cid, msgType, msg.getMoudle(), msg.getMsgKey(), msg.getMsg(), msg.getMsgParam(),msg.getAlarmType(),msg.getAlarmCode());
}
}
......
......@@ -102,4 +102,28 @@ public class EquipStatusUtil {
}
return lastAgvMesMap.get("");
}
public static Map<String,Map<String,String>> dataMap=new HashMap<>();
public static void updateData(String cid, Map<String,String> data) {
if (dataMap.containsKey(cid)) {
dataMap.remove(cid);
}
dataMap.put(cid, data);
}
public static Map<String,String> getData(String cid) {
Map<String, String> data = dataMap.getOrDefault(cid, new HashMap<>());
if (data == null || data.size() <= 0) {
//默认查找cid_1的视频
String nCid = cid + "_2";
data = dataMap.getOrDefault(cid, new HashMap<>());
}
if (data == null || data.size() <= 0) {
//默认查找cid_1的视频
String nCid = cid + "_1";
data = dataMap.getOrDefault(cid, new HashMap<>());
}
return data;
}
}
......@@ -915,6 +915,7 @@ public class TaskService {
private synchronized StoragePos findEmptyPosInStorages(Barcode barcode, List<Storage> availbleStorageList, final Set<String> hasOutTaskStorageIds, String lastPosId) {
StoragePos findPos=null;
//第一遍查找,先不查找有出库任务的料仓
for (Storage storage : availbleStorageList) {
if(!storage.isSmdDuo()){//DUO料仓无论是否有出库任务,都可以查找空库位
......@@ -927,7 +928,17 @@ public class TaskService {
log.debug("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找空位");
StoragePos pos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds, lastPosId);
if (pos != null) {
//判断尺寸是否一致
if(isSameSize(barcode,pos)){
log.info("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找到空位["+pos.getPosName()+"],尺寸与条码一致,直接返回");
return pos;
}else if(findPos==null){
log.info("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找到空位["+pos.getPosName()+"],尺寸不一致,先暂存库位");
findPos=pos;
}else if(findPos.getW()> pos.getW()||findPos.getH()>pos.getH()){
log.info("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找到空位["+pos.getPosName()+"],比暂存库位["+findPos.getPosName()+"]跟匹配,替换为暂存库位");
findPos=pos;
}
}
} catch (Exception e) {
log.error("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找空位失败:" + e.getMessage());
......@@ -940,12 +951,25 @@ public class TaskService {
log.debug("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找空位");
StoragePos pos = storagePosManager.getEmptyPosByStorage(storage, barcode, operatingPosIds, lastPosId);
if (pos != null) {
if(isSameSize(barcode,pos)){
log.info("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找到空位["+pos.getPosName()+"],尺寸与条码一致,直接返回");
return pos;
}else if(findPos==null){
log.info("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找到空位["+pos.getPosName()+"],尺寸不一致,先暂存库位");
findPos=pos;
}else if(findPos.getW()> pos.getW()||findPos.getH()>pos.getH()){
log.info("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找到空位["+pos.getPosName()+"],比暂存库位["+findPos.getPosName()+"]跟匹配,替换为暂存库位");
findPos=pos;
}
}
} catch (Exception e) {
log.error("尝试从[" + storage.getCid() + "]中为[" + barcode.getBarcode() + "]查找空位失败:" + e.getMessage());
}
}
if(findPos!=null){
log.info("为[" + barcode.getBarcode() + "]未查找到尺寸一直的库位,返回暂存的库位["+findPos.getPosName()+"]");
return findPos;
}
try {
String cids = "";
for (Storage storage : availbleStorageList) {
......@@ -959,6 +983,12 @@ public class TaskService {
return null;
}
private boolean isSameSize(Barcode barcode,StoragePos pos){
if(barcode.getPlateSize()==pos.getW()&&barcode.getHeight()==pos.getH()){
return true;
}
return false;
}
/**
* 检查二维码是否合法并且可以入库,没问题的话存入到数据库
......
package com.neotel.smfcore.custom.Inventec1562.bean;
import lombok.Data;
@Data
public class AllLightsTurnOff {
private String ledBoard;
private String color;
private String reelShelfIp;
}
package com.neotel.smfcore.custom.Inventec1562.bean;
import lombok.Data;
@Data
public class AllLightsTurnOn {
private String ledBoard;
private String color;
private String reelShelfIp;
}
package com.neotel.smfcore.custom.Inventec1562.bean;
import lombok.Data;
@Data
public class LighthouseControl {
/**
* Return value:True/False
* Parameters:
* LedBoard:Shelf number, take the first 3 digits of the Storage location number , do not accept arrays.
* Color:R/Y -red,G/P-green,B/C-blue
* On the side of shelf location 1-700: R-red,G-green,B-blue
* On the side of shelf location 701-1400: Y-red,P-green,C-blue
* Action: 0 - off, 1 - on
* ReelShelfIP: Server IP connected to the material rack
*/
private String ledBoard;
private String color;
private Integer action;
private String reelShelfIp;
}
package com.neotel.smfcore.custom.Inventec1562.bean;
import lombok.Data;
@Data
public class MultiLight {
private String phwCode;
private String color;
private String reelShelfIp;
}
package com.neotel.smfcore.custom.Inventec1562.bean;
import lombok.Data;
@Data
public class SingleLight {
/**
* pHW_Code:Storage location number
* Color:R-red,G-green,B-blue
* Action: 0 – off, 1 – on, 2 - flashing
* Cycle:Each unit flashes for 1 second
* ReelShelfIP: Server IP connected to the material rack
*/
private String phwCode;
private String color;
private Integer action;
private Integer cycle;
private String reelShelfIp;
}
package com.neotel.smfcore.custom.Inventec1562.enums;
public enum LightAction {
close(0),
open(1),
flashing(2),
openAll(3),
closeAll(4);
private final int stateCode;
LightAction(int stateCode) {
this.stateCode = stateCode;
}
public static String getOpName(int stateCode) {
if (stateCode == 2) {
stateCode = 1;
}
for (LightAction action : LightAction.values()) {
if (action.stateCode == stateCode) {
return action.name();
}
}
return "";
}
}
package com.neotel.smfcore.custom.Inventec1562.enums;
public enum LightColor {
R("red"),
G("green"),
B("blue"),
O("yellow"),
Y("red"),
P("green"),
C("blue"),
W("yellow");
private final String blue;
LightColor(String blue) {
this.blue = blue;
}
public static String getColor(String name){
for (LightColor color : LightColor.values()) {
if (color.name().equals(name)){
return color.blue;
}
}
return "";
}
}
......@@ -8,6 +8,7 @@ import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.equipment.bean.EquipStatusBean;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import com.neotel.smfcore.core.equipment.util.EquipmentCache;
import com.neotel.smfcore.core.storage.service.po.Storage;
......@@ -52,7 +53,7 @@ public class DEIF20861Controller {
}
Map<String, BoxStatusBean> boxStatusMap = statusBean.getBoxStatus();
int status = -1;
String shelfS = statusBean.getData().getOrDefault("shelfState", "OFFLINE");
String shelfS = statusBean.getData().getOrDefault("shelfStatus", "");
String hserial = statusBean.getData().getOrDefault("hSerial", "");
String shelfType = statusBean.getData().getOrDefault("shelfType", "");
if (boxStatusMap != null) {
......@@ -62,9 +63,20 @@ public class DEIF20861Controller {
}
}
if (status == StorageConstants.STATUS.OFFLINE || statusBean.timeOut()) {
//离线
// OFFLINE=离线;
// IDLE=空闲;
// LOADING=入库中;
// UNLOADING=出库中;
// NEED_EMPTY=需要空料串出库;
// EMPTY_OUT=空料串需要取走
// FULL_OUT=满料串需要取走
if (status==-1|| status == StorageConstants.STATUS.OFFLINE || statusBean.timeOut()) {
//设备离线
shelfS = "OFFLINE";
}else{
if(ObjectUtil.isEmpty(shelfS)){
shelfS="IDLE";
}
}
Map<String, Object> itemMap = new HashMap<>();
itemMap.put("cid", storage.getCid());
......@@ -137,6 +149,20 @@ public class DEIF20861Controller {
@RequestMapping("/nsShelfInfo")
@AnonymousAccess
public ResultBean nsShelfInfo( @RequestBody Map<String, Object> paramMap) {
// 定时通信,data需要增加料串状态
//
// * key=inShelfStatus ,表示入口料串状态:
// * key=inShelfType 表示入口料串类型 smallReel, bigReel, tray
// *
// * key=outShelfStatus ,表示出口料串状态:
// * key=outShelfType 表示出口料串类型 smallReel, bigReel, tray
// 料串状态定义 IDLE=空闲;
// LOADING=入库中;
// UNLOADING=出库中;
// NEED_EMPTY=需要空料串出库;
// EMPTY_OUT=空料串需要取走
// FULL_OUT=满料串需要取走
Collection<Equipment> storageList = Lists.newArrayList();
storageList.addAll(equipmentCache.getAllEquipment().values());
......@@ -145,24 +171,26 @@ public class DEIF20861Controller {
if(!equipment.isNEOSCAN()){
continue;
}
StatusBean statusBean = DevicesStatusUtil.getStatusBean(equipment.getCid());
if (statusBean == null) {
statusBean = new StatusBean();
}
Map<String, BoxStatusBean> boxStatusMap = statusBean.getBoxStatus();
EquipStatusBean equipStatus = EquipStatusUtil.getStatusBean(equipment.getCid());
int status = -1;
String outShelfStatus = statusBean.getData().getOrDefault("outShelfStatus ", "OFFLINE");
String inShelfStatus = statusBean.getData().getOrDefault("inShelfStatus ", "OFFLINE");
if (boxStatusMap != null) {
BoxStatusBean boxStatusBean = boxStatusMap.get("1");
if (boxStatusBean != null) {
status = boxStatusBean.getStatus();
}
}
if (status == StorageConstants.STATUS.OFFLINE || statusBean.timeOut()) {
//离线
if (equipStatus == null) {
equipStatus = new EquipStatusBean();
}else{
status=equipStatus.getStatus();
}
String outShelfStatus = equipStatus.getData().getOrDefault("outShelfStatus", "").toString();
String inShelfStatus = equipStatus.getData().getOrDefault("inShelfStatus", "").toString();
if(status==1&&(!equipStatus.timeOut())){
if(ObjectUtil.isEmpty(outShelfStatus)){
outShelfStatus="IDLE";
}
if(ObjectUtil.isEmpty(inShelfStatus))
{
inShelfStatus="IDLE";
}
}else {
outShelfStatus = "OFFLINE";
inShelfStatus="OFFLINE";
inShelfStatus = "OFFLINE";
}
Map<String, Object> itemMap = new HashMap<>();
itemMap.put("cid", equipment.getCid());
......
......@@ -9,15 +9,22 @@ import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.apiInteraction.enums.ApiInteraction_Status;
import com.neotel.smfcore.core.apiInteraction.service.manager.IApiInteractionManager;
import com.neotel.smfcore.core.apiInteraction.service.po.ApiInteraction;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.fuji.config.FileDirectoryConfig;
import com.neotel.smfcore.custom.fuji.bean.FujiConfig;
import com.neotel.smfcore.custom.fuji.config.FujiCacheConfig;
import com.neotel.smfcore.custom.fuji.config.FujiUrlConfig;
import com.neotel.smfcore.custom.fuji.util.NotifyUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
......@@ -26,6 +33,12 @@ import java.util.Map;
@Slf4j
public class FujiApi extends BaseSmfApiListener {
@Autowired
private DataCache dataCache;
@Autowired
private IApiInteractionManager apiInteractionManager;
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("fuji");
......@@ -54,16 +67,19 @@ public class FujiApi extends BaseSmfApiListener {
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (task.isFinished()) {
NotifyUtil.createLoadEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
NotifyUtil.createLoadEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getStorageName(),getNotifyEtn());
}
}
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if (task.isFinished()) {
NotifyUtil.createLoadEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
NotifyUtil.createProvideEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getSourceName(),task.getLine(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
NotifyUtil.createDeleteEtn(task.getBarcode(),task.getW(),task.getH(),task.getPartNumber(),FileDirectoryConfig.NOTIFY);
String fileName = task.getAppendData("fileName") == null ? "" : task.getAppendData("fileName").toString();
String sourceName = task.getAppendData("jobName") == null ? "" : task.getAppendData("jobName").toString();
NotifyUtil.createProvideEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),sourceName,task.getLine(),task.getStorageName(),getNotifyEtn(),fileName);
//NotifyUtil.createDeleteEtn(task.getBarcode(),task.getW(),task.getH(),task.getPartNumber(),FileDirectoryConfig.NOTIFY);
}
}
......@@ -74,11 +90,11 @@ public class FujiApi extends BaseSmfApiListener {
Map<String, Object> params = new HashMap<>();
params.put("did",barcode.getBarcode());
params.put("partBarcode",barcode.getFullCode());
params.put("partBarcode",barcode.getPartNumber());
params.put("quantity",barcode.getAmount());
params.put("packageType","paper"); //默认是paper,
params.put("partsoutWarning",0);
params.put("splicingWarning",0);
params.put("partsoutWarning",barcode.getAmount());
params.put("splicingWarning",barcode.getAmount());
params.put("partNumber",barcode.getPartNumber());
params.put("vendorName",barcode.getProvider());
params.put("lotName",barcode.getBatch());
......@@ -96,25 +112,27 @@ public class FujiApi extends BaseSmfApiListener {
params.put("trayPickupPositionY",1);
params.put("traySizeX",0);
params.put("traySizeY",0);
log.info("注册Fuji的did参数为:"+JSON.toJSONString(params));
String paramStr = JSON.toJSONString(params);
log.info("注册Fuji的did参数为:"+paramStr);
String result = "";
try {
String result = HttpHelper.postJsonWithAuth(FujiUrlConfig.inventoryDids(), Arrays.asList(params), "", headerMap);
result = HttpHelper.postJsonWithAuth(inventoryDids(), Arrays.asList(params), "", headerMap);
log.info("注册Fuji的did结果为:"+result);
JSONObject resultObj = JSONObject.parseObject(result);
Integer addedCount = resultObj.getInteger("addedCount");
if (addedCount != null && addedCount > 0){
apiInteractionManager.save(new ApiInteraction(new Date(),getAuthLogin(),paramStr,result,ApiInteraction_Status.OK));
return true;
} else {
String details = resultObj.getString("details");
apiInteractionManager.save(new ApiInteraction(new Date(),getAuthLogin(),paramStr,result,ApiInteraction_Status.ERROE));
throw new ValidateException("smfcore.registerdid.false",barcode.getBarcode()+"注册失败:"+details);
}
} catch (ApiException e) {
log.info("注册Fuji的did失败:",e);
}
apiInteractionManager.save(new ApiInteraction(new Date(),getAuthLogin(),paramStr,result,ApiInteraction_Status.ERROE));
return false;
}
......@@ -134,8 +152,10 @@ public class FujiApi extends BaseSmfApiListener {
paramMap.put("search", search);
paramMap.put("orderBy", orderBy);
String paramStr = JSON.toJSONString(paramMap);
String result = "";
try {
String result = HttpHelper.getParam(FujiUrlConfig.inventoryDids(), headerMap, paramMap);
result = HttpHelper.getParam(getInventoryDids(), headerMap, paramMap);
log.info(barcode + "获取Fuji的inventory/dids结果为:" + result);
JSONObject resultObj = JSONObject.parseObject(result);
JSONArray dataArray = resultObj.getJSONArray("datas");
......@@ -143,6 +163,7 @@ public class FujiApi extends BaseSmfApiListener {
for (int i = 0; i < dataArray.size(); i++) {
JSONObject data = dataArray.getJSONObject(i);
if (barcode.equals(data.getString("did"))){
apiInteractionManager.save(new ApiInteraction(new Date(),getAuthLogin(),paramStr,result,ApiInteraction_Status.OK));
return true;
}
}
......@@ -150,6 +171,7 @@ public class FujiApi extends BaseSmfApiListener {
} catch (ApiException e) {
log.info(barcode + "获取Fuji的inventory/dids失败:", e.getMessage());
}
apiInteractionManager.save(new ApiInteraction(new Date(),getAuthLogin(),paramStr,result,ApiInteraction_Status.ERROE));
return false;
}
......@@ -158,14 +180,16 @@ public class FujiApi extends BaseSmfApiListener {
* 获取登录的token
* @return
*/
private String getAccessToken() {
public String getAccessToken() {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("userName", FujiUrlConfig.userName);
paramMap.put("password", FujiUrlConfig.password);
log.info("获取Fuji的token参数为:" + JSON.toJSONString(paramMap));
String paramStr = JSON.toJSONString(paramMap);
log.info("获取Fuji的token参数为:" + paramStr);
String accessToken = "";
String result = "";
try {
String result = HttpHelper.postJson(FujiUrlConfig.getAuthLogin(), paramMap);
result = HttpHelper.postJson(getAuthLogin(), paramMap);
log.info("获取Fuji的token结果为:" + result);
JSONObject resultObj = JSONObject.parseObject(result);
accessToken = resultObj.getString("accessToken");
......@@ -173,11 +197,49 @@ public class FujiApi extends BaseSmfApiListener {
log.info("获取Fuji的token异常:", e);
accessToken = "";
}
String status = "";
if (StringUtils.isEmpty(accessToken)){
status = ApiInteraction_Status.ERROE;
}
apiInteractionManager.save(new ApiInteraction(new Date(),getAuthLogin(),paramStr,result,status));
if (StringUtils.isEmpty(accessToken)) {
throw new ValidateException("smfcore.accessToken.ng", "获取AccessToken失败");
}
return accessToken;
}
private String getAuthLogin(){
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config == null) {
config = new FujiConfig();
}
return config.getAuthUrl();
}
private String getInventoryDids(){
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config == null) {
config = new FujiConfig();
}
return config.getGetDidInfoUrl();
}
private String inventoryDids(){
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config == null) {
config = new FujiConfig();
}
return config.getRegisterDidInfoUrl();
}
private String getNotifyEtn(){
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config == null) {
config = new FujiConfig();
}
return config.getOutputEtn();
}
}
package com.neotel.smfcore.custom.fuji;
import com.neotel.smfcore.common.init.MenuInit;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.security.service.po.Menu;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class FujiMenu {
@Autowired
MenuInit menuInit;
@Autowired
SmfApi smfApi;
@PostConstruct
public void init(){
String menuLabel = "fuji";
Menu nexim = Menu.CreatePMenu("Nexim", 3, "nexim", "nexim", null);
MenuInit.addMenu(menuLabel,nexim,3, "Nexim 工单","neximWorkOrder", "neolight/neximWorkOrder/index","neximWorkOrder");
String apiName = smfApi.getApiName();
if(Strings.isNotBlank(apiName) && apiName.equals(menuLabel)){
menuInit.showMenu(apiName);
}
}
}
package com.neotel.smfcore.custom.fuji.bean;
import lombok.Data;
import java.util.Date;
@Data
public class FujiConfig {
private String authUrl = "";
private String getDidInfoUrl = "";
private String registerDidInfoUrl = "";
private String result = "";
private String lastUpdateTime = "";
private String inputEto = "";
private String outputEtn = "";
private int time = 10;
}
package com.neotel.smfcore.custom.fuji.bean;
import lombok.Data;
import java.io.Serializable;
@Data
public class Notify implements Serializable {
/**
* action NEW = Object (item or carrier) creation
* DELETE = Object (item or carrier) deletion
* LOAD = Carrier check in
* PROVIDE = Carrier check out
*/
private String action;
/**
* object ARTICLE or CARRIER
*/
private String object;
/**
* objectname Item or carrier name(DID)
*/
private String name;
/**
* Date of Action、yyyymmdd format
*/
private String date;
/**
* Action Time
*/
private String time;
/**
* Job name
*/
private String jobName;
/**
* storage location (Only if object=CARRIER)
*/
private String depot;
/**
* Item designation (Only if object=CARRIER)
*/
private String demand;
/**
* Current carrier's parts inventory or total inventory of the item
*/
private int stock;
}
\ No newline at end of file
package com.neotel.smfcore.custom.fuji.bean;
import lombok.Data;
@Data
public class OrderReq {
private String action;
private String object;
private String name;
private String date;
private String time;
private String depot;
private String stock;
private String expiry;
private String mSL;
private String mSLWATCH;
private String stockMin;
private String stockMax;
private String reelsMin;
private String reelsMax;
private String height;
private String diameter;
private String supply;
private String stockNew;
private String article;
private String units;
private String target;
private String forceTower;
private String demand;
private String los;
}
package com.neotel.smfcore.custom.fuji.bean;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class OrderResp extends OrderReq {
private String answer = "TRUE";
private int error;
private String carrier;
private String values;
private List<String> carrierNameList;
public void setCarrierNameList(String carrierName) {
if (carrierNameList == null || carrierNameList.isEmpty()){
carrierNameList = new ArrayList<>();
}
this.carrierNameList.add(carrierName);
}
}
package com.neotel.smfcore.custom.fuji.config;
public class FileDirectoryConfig {
public static final String NOTIFY = "\\\\175.41.238.212\\remoteorder\\notify\\";
public class FujiCacheConfig {
public static final String FujiConfig_Cache_Name = "FujiConfig_Cache_Name";
}
......@@ -5,23 +5,14 @@ import lombok.Data;
@Data
public class FujiUrlConfig {
private static final String baseUrl = "http://175.41.238.212/fujiopenwebapi/api/v1";
//private static final String baseUrl = "http://175.41.238.212/fujiopenwebapi/api/v1";
public static final String userName = "Neotel";
public static final String password = "Neotel";
private static final String authLogin = "/auth/login";
//private static final String authLogin = "/auth/login";
private static final String inventoryDids = "/inventory/dids";
public static String getAuthLogin() {
return baseUrl + authLogin;
}
public static String inventoryDids() {
return baseUrl + inventoryDids;
}
//private static final String inventoryDids = "/inventory/dids";
}
package com.neotel.smfcore.custom.fuji.controller;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.custom.fuji.FujiApi;
import com.neotel.smfcore.custom.fuji.bean.FujiConfig;
import com.neotel.smfcore.custom.fuji.config.FujiCacheConfig;
import com.neotel.smfcore.custom.fuji.order.service.JobService;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@RestController
@RequestMapping("/fuji")
public class FujiController {
@Autowired
private DataCache dataCache;
@Autowired
private CodeResolve codeResolve;
@Autowired
private FujiApi fujiApi;
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private JobService jobService;
@ApiOperation("修改配置")
@RequestMapping("/updateFujiConfig")
//@AnonymousAccess
public ResultBean updateFujiConfig(@RequestBody FujiConfig newConfig) {
log.info("修改配置信息为:" + JSON.toJSONString(newConfig));
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config == null) {
config = new FujiConfig();
}
config.setAuthUrl(newConfig.getAuthUrl());
config.setGetDidInfoUrl(newConfig.getGetDidInfoUrl());
config.setRegisterDidInfoUrl(newConfig.getRegisterDidInfoUrl());
config.setInputEto(newConfig.getInputEto());
config.setOutputEtn(newConfig.getOutputEtn());
config.setTime(newConfig.getTime());
dataCache.updateCache(FujiCacheConfig.FujiConfig_Cache_Name, config);
return ResultBean.newOkResult("");
}
@ApiOperation("获取配置")
@RequestMapping("/getFujiConfig")
//@AnonymousAccess
public ResultBean getFujiConfig() {
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config == null) {
config = new FujiConfig();
}
return ResultBean.newOkResult(config);
}
@ApiOperation("did注册")
@RequestMapping("/didRegister")
//@AnonymousAccess
public ResultBean didRegister(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("code");
if (StringUtils.isEmpty(code)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
}
Barcode barcode = codeResolve.resolveCode(code);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
}
String accessToken = fujiApi.getAccessToken();
boolean hasDid = fujiApi.inventoryHasDid(barcode.getBarcode(), accessToken);
if (!hasDid){
fujiApi.registerNewDid(barcode, accessToken);
}
return ResultBean.newOkResult("");
}
@ApiOperation("job出库")
@RequestMapping("/jobCheckOut")
@AnonymousAccess
public synchronized ResultBean jobCheckOut(String orderNo) {
LiteOrder liteOrder = liteOrderCache.getLiteOrder(orderNo);
if (liteOrder == null){
return ResultBean.newErrorResult(-1,"smfcore.order.out.notFound","工单未找到");
}
if (liteOrder.isClosed()){
return ResultBean.newErrorResult(-1,"smfcore.order.hasClose","工单已关闭");
}
if (!liteOrder.isNew()){
return ResultBean.newErrorResult(-1,"smfcore.order.out.executing","工单正在执行");
}
liteOrder = jobService.executeJob(liteOrder);
jobService.writeAns(liteOrder);
return ResultBean.newOkResult("");
}
@ApiOperation("获取需要出库/正在执行中的job任务")
@RequestMapping("/jobInfo")
@AnonymousAccess
public ResultBean getJobInfo() {
List<Map<String, Object>> resultList = new ArrayList<>();
Collection<LiteOrder> allLiteOrder = liteOrderCache.getAllLiteOrder();
if (allLiteOrder != null && !allLiteOrder.isEmpty()) {
List<LiteOrder> liteOrderList = new ArrayList<>();
for (LiteOrder liteOrder : allLiteOrder) {
if (liteOrder.isNew() || liteOrder.isOutTails()) {
liteOrderList.add(liteOrder);
} else {
//其他的默认超过2个小时 不展示
if (System.currentTimeMillis() - liteOrder.getUpdateDate().getTime() <= 1000 * 60 * 60 * 2){
liteOrderList.add(liteOrder);
}
}
}
liteOrderList = liteOrderList.stream().sorted(Comparator.comparing(LiteOrder::getCreateDate).reversed()).collect(Collectors.toList());
for (LiteOrder liteOrder : liteOrderList) {
Map<String, Object> resultMap = new HashMap<>();
String jobState = liteOrder.getAppend("jobState");
String jobName = liteOrder.getAppend("jobName");
String fileName = liteOrder.getAppend("fileName");
resultMap.put("jobState", jobState);
resultMap.put("jobName", jobName);
resultMap.put("fileName", fileName);
List<Map<String,String>> itemList = new ArrayList<>();
for (LiteOrderItem orderItem : liteOrder.getOrderItems()) {
Map<String,String> itemMap = new HashMap<>();
String item = orderItem.getAppend("item");
String errorCode = orderItem.getAppend("errorCode");
String errorText = orderItem.getAppend("errorText");
String ri = orderItem.getRi();
String pn = orderItem.getPn();
int needReelCount = orderItem.getNeedReelCount();
itemMap.put("item",item);
itemMap.put("errorCode","");
if (!"0".equals(errorCode)){
itemMap.put("errorCode",errorCode);
}
itemMap.put("errorText",errorText);
itemMap.put("ri",ri);
itemMap.put("pn",pn);
itemMap.put("needReelCount",needReelCount+"");
itemList.add(itemMap);
}
resultMap.put("itemList",itemList);
resultList.add(resultMap);
}
}
return ResultBean.newOkResult(resultList);
}
}
package com.neotel.smfcore.custom.fuji.enums;
/**
* Action 类型
*/
public enum Action {
/**
* Object (item or carrier) creation
*/
NEW,
/**
* Object (item or carrier) deletion
*/
DELETE,
/**
* Carrier check in
*/
LOAD,
/**
* Carrier check out
*/
PROVIDE,
/**
* 修改
*/
UPDATE,
/**
* 读取
*/
READ
}
package com.neotel.smfcore.custom.fuji.enums;
public class ErrorCode {
public static final int ok = 0;
public static final int lockingError = 1;
public static final int unknownAction = 9;
}
package com.neotel.smfcore.custom.fuji.enums;
public enum NexObject {
/**
* 料号
*/
ARTICLE,
/**
* 唯一码
*/
CARRIER,
/**
* 工单
*/
JOBLIST
}
package com.neotel.smfcore.custom.fuji.enums;
public class OrderType {
public static final String order = "[Order]";
public static final String result = "[Result]";
public static final String data = "[Data]";
}
package com.neotel.smfcore.custom.fuji.order;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.fuji.bean.FujiConfig;
import com.neotel.smfcore.custom.fuji.config.FujiCacheConfig;
import com.neotel.smfcore.custom.fuji.order.bean.Job;
import com.neotel.smfcore.custom.fuji.order.bean.JobItem;
import com.neotel.smfcore.custom.fuji.order.service.JobService;
import com.neotel.smfcore.custom.fuji.util.NotifyUtil;
import com.neotel.smfcore.custom.fuji.util.OrderUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Slf4j
@Component
public class JobHandler {
@Autowired
private SmfApi smfApi;
@Autowired
private JobService jobService;
@Autowired
private TaskService taskService;
@Autowired
private DataCache dataCache;
ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
private static long lastHandleTime = 0l;
@PostConstruct
public void init() {
if ("fuji".equals(smfApi.getApiName())) {
scheduledThreadPool.scheduleAtFixedRate(() -> {
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config == null) {
config = new FujiConfig();
}
if (System.currentTimeMillis()-lastHandleTime >= 1000 * config.getTime()){
//log.info(DateUtil.toDateString(System.currentTimeMillis(),"yyyy-MM-dd HH:mm:ss"));
try {
handler();
} catch (Exception e) {
log.info("执行fuji工单失败:", e);
}
lastHandleTime = System.currentTimeMillis();
}
}, 10, 1, TimeUnit.SECONDS);
}
}
public static void main(String[] args) throws IOException {
new JobHandler().handler();
}
public void handler() throws IOException {
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config == null) {
config = new FujiConfig();
}
String path = config.getInputEto();
if (StringUtils.isEmpty(path)){
return;
}
log.info("开始执行工单,路径为:" + path);
File file = new File(path);
if (file.exists() && file.isDirectory()) {
//获取到最近的一个文件
File[] files = file.listFiles();
if (files == null || files.length == 0){
return;
}
List<File> fileList = Arrays.stream(files).sorted(Comparator.comparing(File::lastModified).reversed()).collect(Collectors.toList());
File currentFile = fileList.get(0);
String name = currentFile.getName();
if (!name.endsWith("ETO")) {
return;
}
//解析出来每行数据
List<String> lineList = OrderUtil.getLines(currentFile.getAbsolutePath(), StandardCharsets.US_ASCII);
log.info("获取到line为:" + JSON.toJSONString(lineList));
//开始处理每行数据
Job job = jobService.getJob(lineList);
String ansName = currentFile.getName();
int pos = ansName.lastIndexOf(".");
ansName = pos > 0 ? ansName.substring(0,pos) :ansName;
//判断是否已经存在job
boolean existJob = jobService.isExistJob(job.getName(),ansName);
if (existJob){
return;
}
LiteOrder liteOrder = jobService.getJobResultInfo(job,ansName,lineList);
//旧的文件,移除到其他文件夹,写入ANS文件
String newFilePath = "nexim/eto/"+currentFile.getName();
FileUtil.move(currentFile,new File(newFilePath),true);
//判断是否为自动出库
if ("PROVIDE_DELETE".equals(job.getJobState())){
jobService.writeAns(liteOrder);
}
}
}
}
package com.neotel.smfcore.custom.fuji.order;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.custom.fuji.util.NotifyUtil;
import com.neotel.smfcore.custom.fuji.util.OrderUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Slf4j
@Component
public class OrderHandler {
private static DataCache dataCache;
@Autowired
public void setDataCache(DataCache cache) {
dataCache = cache;
}
private static ILiteOrderManager liteOrderManager;
@Autowired
public void setLiteOrderManager(ILiteOrderManager manager) {
liteOrderManager = manager;
}
private static LiteOrderCache liteOrderCache;
@Autowired
public void setLiteOrderCache(LiteOrderCache cache) {
liteOrderCache = cache;
}
public static SmfApi smfApi;
@Autowired
public void setSmfApi(SmfApi api) {
smfApi = api;
}
ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
@PostConstruct
public void init() {
if ("nexim".equals(smfApi.getApiName())){
scheduledThreadPool.scheduleAtFixedRate(() -> {
try {
handler();
} catch (Exception e) {
log.info("执行fuji工单失败:",e);
}
},60, 10, TimeUnit.SECONDS);
}
}
public static void handler() throws IOException {
String path = dataCache.getOrderSetting().getOrderDir();
log.info("开始执行工单,路径为:" + path);
File file = new File(path);
if (file.exists() && file.isDirectory()) {
String resultStr = "";
File[] files = file.listFiles();
List<File> fileList = Arrays.stream(files).sorted(Comparator.comparing(File::lastModified).reversed()).collect(Collectors.toList());
File currentFile = fileList.get(0);
List<String> lineList = OrderUtil.getLines(currentFile.getAbsolutePath(), StandardCharsets.US_ASCII);
log.info("获取到line为:" + JSON.toJSONString(lineList));
String orderName = "";
String orderLine = "";
List<LiteOrderItem> orderItemList = new ArrayList<>();
for (String line : lineList) {
resultStr = resultStr + line;
if (line.split("=").length < 2) {
continue;
}
String value = line.split("=")[1];
if (line.startsWith("Name")) {
orderName = value;
}
if (line.startsWith("ProdSite")){
orderLine = value;
}
if (line.startsWith("Item")) {
String[] itemStr = value.split("\\|", -1);
LiteOrderItem item = new LiteOrderItem();
item.setPn(itemStr[0]);
item.setRi(itemStr[1]);
int needNum = 1;
try {
needNum = Integer.valueOf(itemStr[2]);
} catch (NumberFormatException e) {
e.printStackTrace();
}
item.setNeedNum(needNum);
int needReelCount = 1;
try {
needReelCount = Integer.valueOf(itemStr[3]);
} catch (NumberFormatException e) {
e.printStackTrace();
}
item.setNeedReelCount(needReelCount);
orderItemList.add(item);
}
}
int error = 0;
LiteOrder liteOrder = liteOrderManager.findByOrderNo(orderName);
if (liteOrder == null) {
LiteOrder order = new LiteOrder();
order.setOrderItems(orderItemList);
order.setOrderNo(orderName);
order.setLine(orderLine);
liteOrderManager.createWithItems(order);
liteOrderCache.addOrderToMap(order);
} else {
return;
}
resultStr = resultStr + "\n";
resultStr = resultStr +"[Result]";
resultStr = resultStr + "\n";
resultStr = resultStr + "Error="+error;
NotifyUtil.createOrderAns(file.getName(),resultStr);
}
}
}
package com.neotel.smfcore.custom.fuji.order.bean;
import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.Data;
import java.util.List;
@Data
public class Job {
private String Action;
private String Object;
private String Name;
private String Los;
private String JobState;
private String ProdSite;
private String Answer;
private int Error = 0;
private List<JobItem> Data;
private List<DataLog> dataLogList;
}
package com.neotel.smfcore.custom.fuji.order.bean;
import lombok.Data;
@Data
public class JobItem {
private String item;
private String part;
private String carrier;
private int needNum;
private int needReelCount;
private int errorCode;
private String errorText;
}
package com.neotel.smfcore.custom.fuji.util;
import com.neotel.smfcore.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
......@@ -28,7 +29,8 @@ public class NotifyUtil {
String localFilePath = "";
try {
//CARRIER_1608R-00002_LOAD_20240524_15_00_02.ETN
localFilePath = path + "CARRIER_" + barcode + "_LOAD_" + new SimpleDateFormat("yyyyMMdd_HH_mm_ss").format(new Date()) + ".ETN";
//localFilePath = path + "CARRIER_" + barcode + "_LOAD_" + new SimpleDateFormat("yyyyMMdd_HH_mm_ss").format(new Date()) + ".ETN";
localFilePath = path +barcode+"_LOAD"+".ETN";
log.info("本地文件路径为:" + localFilePath);
//log.info("内容为:" + JSON.toJSONString(notify));
......@@ -45,7 +47,8 @@ public class NotifyUtil {
"Name=" + barcode + "\n" +
"Date=" + new SimpleDateFormat("yyyyMMdd").format(new Date()) + "\n" +
"Time=" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "\n" +
"Depot=" + posName + "\n" +
"JOBNAME=\n" +
"Depot=" + storageName + "\n" +
"Stock=" + num + "\n" +
"Station=" + station + "\n" +
"EXPIRY=\n" +
......@@ -55,8 +58,8 @@ public class NotifyUtil {
"SUPPLY=\n" +
"STOCKNEW=0\n" +
"ARTICLE=" + partNumber + "\n" +
"DEPOTLONG="+storageName+" " + posName + "\n" +
"DEPOTOLD=Unknown\n" +
"DEPOTLONG=\n" +
"DEPOTOLD=\n" +
"custom1=\n" +
"custom2=\n" +
"custom3=\n" +
......@@ -88,12 +91,19 @@ public class NotifyUtil {
String sourceName,
String line,
String storageName,
String path) {
String path,
String fileName) {
OutputStreamWriter out = null;
String localFilePath = "";
try {
//CARRIER_1608R-00002_LOAD_20240524_15_00_02.ETN
localFilePath = path + "CARRIER_" + barcode + "_PROVIDE_" + new SimpleDateFormat("yyyyMMdd_HH_mm_ss").format(new Date()) + ".ETN";
//localFilePath = path + "CARRIER_" + barcode + "_PROVIDE_" + new SimpleDateFormat("yyyyMMdd_HH_mm_ss").format(new Date()) + ".ETN";
if (StringUtils.isEmpty(sourceName)) {
localFilePath = path + "\\" + barcode + "_PROVIDE" + ".ETN";
} else {
localFilePath = path + "\\" + fileName + ".ETN";
}
//localFilePath = path +"\\"+barcode+"_PROVIDE"+".ETN";
log.info("本地文件路径为:" + localFilePath);
//log.info("内容为:" + JSON.toJSONString(notify));
......@@ -103,6 +113,10 @@ public class NotifyUtil {
file.createNewFile();
}
if (StringUtils.isEmpty(sourceName)){
sourceName = "";
}
out = new OutputStreamWriter(new FileOutputStream(file), CHARSET_NAME); //打开文件输出流
out.write("[Notify]\n" +
"Action=PROVIDE\n" +
......@@ -111,7 +125,7 @@ public class NotifyUtil {
"Date=" + new SimpleDateFormat("yyyyMMdd").format(new Date()) + "\n" +
"Time=" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "\n" +
"JOBNAME=" + sourceName + "\n" +
"Depot=" + line + "\n" +
"Depot=" + storageName + "\n" +
"Stock=" + num + "\n" +
"Station=" + station + "\n" +
"EXPIRY=\n" +
......@@ -121,8 +135,8 @@ public class NotifyUtil {
"SUPPLY=\n" +
"STOCKNEW=0\n" +
"ARTICLE=" + partNumber + "\n" +
"DEPOTOLD=" + posName + "\n" +
"DEPOTLONG="+storageName+" " + posName + "\n" +
"DEPOTOLD=\n" +
"DEPOTLONG=\n" +
"custom1=\n" +
"custom2=\n" +
"custom3=\n" +
......
......@@ -2,7 +2,6 @@ package com.neotel.smfcore.custom.fuji.util;
import com.neotel.smfcore.common.utils.SmbUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.custom.fuji.bean.OrderResp;
import jcifs.smb.SmbFile;
import lombok.extern.slf4j.Slf4j;
......@@ -85,18 +84,4 @@ public class OrderUtil {
}
return localFilePath;
}
public static void uploadRemoteFilePath(List<String> lineList, String localRespFilePath, String writeRemoteFilePath, OrderResp resp) {
if (lineList != null && !lineList.isEmpty()) {
//开始写入本地文件
String localFilePath = OrderUtil.getLocalFilePathByOrder(localRespFilePath, resp.getName() + ".ANS", lineList, StandardCharsets.US_ASCII);
//同步到远程
if (StringUtils.isNotBlank(localFilePath)) {
SmbUtil.smbPut(writeRemoteFilePath, localFilePath);
//TODO 暂时不删除本地文件
//FileUtil.del(new File(localFilePath));
}
}
}
}
package com.neotel.smfcore.custom.hanwha.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.custom.hanwha.util.HanwhaApiInfoUtil;
import com.neotel.smfcore.custom.hanwha.util.bean.HanwhaApiInfo;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/hanwhaApiInfo")
public class HanwhaApiInfoController {
@Autowired
private HanwhaApiInfoUtil hanwhaApiInfoUtil;
@ApiOperation("获取列表")
@RequestMapping("/getApiInfoList")
public ResultBean getApiInfoList(){
List<HanwhaApiInfo> apiInfoList = hanwhaApiInfoUtil.getApiInfoList();
return ResultBean.newOkResult(apiInfoList);
}
}
package com.neotel.smfcore.custom.hanwha.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.custom.hanwha.util.HanwhaCacheUtil;
import com.neotel.smfcore.custom.hanwha.util.bean.HanwhaCacheConfig;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/hanwhaConfig")
public class HanwhaConfigController {
@Autowired
private HanwhaCacheUtil hanwhaCacheUtil;
@ApiOperation("获取ip和端口号")
@RequestMapping("/getCacheConfig")
public ResultBean getCacheConfig(){
return ResultBean.newOkResult(hanwhaCacheUtil.getHostAndPortCache());
}
@ApiOperation("修改ip和端口号")
@RequestMapping("/updateCacheConfig")
public ResultBean updateCacheConfig(@RequestBody HanwhaCacheConfig cacheConfig) {
String host = cacheConfig.getHost();
String apiPort = cacheConfig.getApiPort();
String webPort = cacheConfig.getWebPort();
log.info("收到修改ip和端口号,host为[{}],apiPort为[{}],webPort为[{}]",host,apiPort,webPort);
if (StringUtils.isEmpty(host)){
return ResultBean.newErrorResult(1,"smfcore.valueCanotNull", "{0}不能为空", new String[]{"host"});
}
if (StringUtils.isEmpty(webPort)){
return ResultBean.newErrorResult(1,"smfcore.valueCanotNull", "{0}不能为空", new String[]{"webPort"});
}
if (StringUtils.isEmpty(apiPort)){
return ResultBean.newErrorResult(1,"smfcore.valueCanotNull", "{0}不能为空", new String[]{"apiPort"});
}
hanwhaCacheUtil.updateHostAndPort(cacheConfig);
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.hanwha.controller;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.custom.hanwha.handler.TMSApis;
import com.neotel.smfcore.custom.hanwha.handler.bean.TMSPart;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
......@@ -26,6 +30,10 @@ public class HanwhaController {
@Autowired
private TMSApis apis;
@Autowired
private LiteOrderCache liteOrderCache;
@ApiOperation("requestGetPartInfo")
@GetMapping("/requestGetPartInfo")
@AnonymousAccess
......@@ -34,4 +42,18 @@ public class HanwhaController {
List<TMSPart> result= apis.RequestGetPartInfo(0,barcode);
return ResultBean.newOkResult(result);
}
@ApiOperation("更新最大工单数")
@GetMapping("/UpdateOrderMode")
@AnonymousAccess
public ResultBean UpdateOrderMode(@RequestParam Integer maxOrderCount) {
if(ObjectUtil.isEmpty(maxOrderCount)){
return ResultBean.newErrorResult(-1,"Error","Error");
}
liteOrderCache.MaxOrderCount=maxOrderCount;
log.info("UpdateOrderMode 设置 liteOrderCache.MaxOrderCount="+liteOrderCache.MaxOrderCount);
return ResultBean.newOkResult(maxOrderCount);
}
}
......@@ -55,6 +55,8 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
private IStoragePosManager storagePosManager;
@Autowired
private TMSCommunicator tmsCommunicator;
@Autowired
private TMSUtil tmsUtil;
@Autowired
private IComponentManager componentManager;
......@@ -70,12 +72,16 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
@Override
public Barcode canPutInBeforeResolve(String codeResolveUrl, CodeValidateParam params) throws ValidateException {
log.info("barcode[" + params.getCode() + "] 解析条码");
CodeBean codeBean = BarcodeRule.splitCodeAndSize(params.getCode());
String[] codeStr = params.getCode().split("##");
for (int i = codeStr.length-1; i >= 0; i--) {
String codeStr1 = codeStr[i];
CodeBean codeBean = BarcodeRule.splitCodeAndSize(codeStr1);
String fullCode = codeBean.getCodeStr();
if (fullCode.endsWith("##")) {
fullCode = fullCode.substring(0, fullCode.length() - 2);
}
log.info("barcode[" + params.getCode() + "] 解析条码到完整条码:"+fullCode+",调用 RequestGetPartInfo");
log.info("barcode[" + params.getCode() + "] 解析条码到完整条码:" + fullCode + ",调用 RequestGetPartInfo");
List<TMSPart> result = tmsApis.RequestGetPartInfo(0, fullCode);
if (result.size() > 0) {
String pn = result.get(0).getPartName();
......@@ -107,6 +113,7 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
barcode.setHeight(height);
barcode.setPlateSize(width);
Date proDate = getDate(result.get(0).getProductionDate());
if (proDate != null) {
barcode.setProduceDate(proDate);
......@@ -117,6 +124,10 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
barcode.setExpireDate(expDate);
}
Date lDate=getDate(result.get(0).getWarehousingDate());
if(lDate!=null){
barcode.setPutInDate(lDate);
}
//判断Pn是否存在
Component component = componentManager.findOneByPN(pn);
......@@ -136,7 +147,12 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
barcode = barcodeManager.saveBarcode(barcode);
log.info("barcode[" + params.getCode() + "] RequestGetPartInfo ,PN=[" + pn + "],code=[" + code + "],count=[" + count + "]新增条码准备入库");
return barcode;
} else {
log.info("barcode[" + params.getCode() + "] 解析条码到完整条码:" + fullCode + ",调用 RequestGetPartInfo 未收到反馈");
throw new ValidateException("smfcore.mesApi.inCheck.error", "RequestGetPartInfo no data",new String[]{" no data "});
}
}
return null;
}
......@@ -152,7 +168,7 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
@Override
public Barcode canPutInAfterResolve(String inCheckUrl, CodeValidateParam params, Barcode barcode) throws ValidateException {
log.info("barcode[" + barcode.getBarcode() + "] 准备入库,调用 RequestGetPartInfo");
log.info("barcode[" + barcode.getBarcode() + "] 准备入库, 直接返回");
// List<TMSPart> result = tmsApis.RequestGetPartInfo(0, barcode.getFullCode());
// if (result.size() > 0) {
// String pn = result.get(0).getPartName();
......@@ -190,7 +206,7 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
}
if (task.isFinished()||task.isEnd()) {
List<TMSPartReelPos> list = new ArrayList<>();
TMSPartReelPos bean = TMSPartReelPos.newBean(task.getPartNumber(), task.getBarcode(), task.getNum(), task.getCid(), task.getPosName(), 1, task.getUpdateDate().getTime(), -1);
TMSPartReelPos bean = TMSPartReelPos.newBean(task.getPartNumber(), task.getBarcode(), task.getNum(), task.getCid(), task.getPosName(), 1, task.getUpdateDate().getTime(), -1,0);
list.add(bean);
log.info("barcode[" + task.getBarcode() + "],pn[" + task.getPartNumber() + "],posName[" + task.getPosName() + "]入库完成,调用 RequestSyncPartReelPosInfo");
......@@ -205,7 +221,7 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
}
if (task.isFinished()||task.isEnd()) {
List<TMSPartReelPos> list = new ArrayList<>();
TMSPartReelPos bean = TMSPartReelPos.newBean(task.getPartNumber(), task.getBarcode(), task.getNum(), task.getCid(), task.getPosName(), 2, -1, task.getUpdateDate().getTime());
TMSPartReelPos bean = TMSPartReelPos.newBean(task.getPartNumber(), task.getBarcode(), task.getNum(), task.getCid(), task.getPosName(), 2, -1, task.getUpdateDate().getTime(),0);
list.add(bean);
log.info("barcode[" + task.getBarcode() + "],pn[" + task.getPartNumber() + "],posName[" + task.getPosName() + "]出库完成,调用 RequestSyncPartReelPosInfo");
......@@ -218,17 +234,23 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
}
@Override
public void onOrderStatusChange(String orderNotifyUrl, LiteOrder liteOrder) {
public void onOrderStatusChange(String orderNotifyUrl, LiteOrder liteOrder ) {
//ResponseUpdateDeliveryReserveState-all work order
if (liteOrder.isClosed()) {
//工单取消,且解锁了物料,需要通知TMS
if(liteOrder.getLockReelList() !=null&&liteOrder.getLockReelList().size()>0){
tmsUtil.SyncReelLockS(liteOrder.getLockReelList());
}
String isCancel=liteOrder.getAppend("cancel");
if(isCancel.equals("true")){
log.info("工单取消处理中,此处不通知TMS");
}else{
log.info("工单关闭,通知TMS");
TMSReserve tmsReserve = tmsCommunicator.GetOrderInfo(liteOrder);
TMSReserve tmsReserve = tmsUtil.GetOrderInfo(liteOrder);
List<TMSReserve> list = new ArrayList<>();
list.add(tmsReserve);
tmsCommunicator.ResponseUpdateDeliveryReserveState(0, list, 0);
......@@ -342,13 +364,14 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
if (pos.getBarcode() == null) {
TMSPartReelPos bean = TMSPartReelPos.newBean("", "", -1,
storage.getCid(), pos.getPosName(), 4, -1, -1);
storage.getCid(), pos.getPosName(), 4, -1, -1,0);
list.add(bean);
} else {
Barcode barcode = pos.getBarcode();
int s=ObjectUtil.isNotEmpty(barcode.getLockId())?1:0;
TMSPartReelPos bean = TMSPartReelPos.newBean(barcode.getPartNumber(), barcode.getBarcode(), barcode.getAmount(),
storage.getCid(), pos.getPosName(), 4, barcode.getPutInDate().getTime(), -1);
storage.getCid(), pos.getPosName(), 4, barcode.getPutInDate().getTime(), -1,s);
list.add(bean);
}
......
......@@ -153,6 +153,7 @@ public class TMSApis {
TMSRackStatus item = new TMSRackStatus();
item.setRackID (getMapValue(map, "RackID")) ;
item.setRowID (getMapValue(map, "RowID")) ;
item.setPosId(getMapValue(map,"PosId"));
item.setColID (getMapValue(map, "ColID")) ;
item.setIndate (getMapValue(map, "Indate"));
item.setOutdate (getMapValue(map, "Outdate"));
......
......@@ -84,11 +84,13 @@ public class TMS_Code {
/**
* 2002 Out of part 无材料
* 从来没有的PN
*/
public static final String CODE_2002 = "2002";
/**
* 2003 Registered part but not on the rack 缺料
* 有PN,但是当前无库存
*/
public static final String CODE_2003 = "2003";
......
......@@ -25,11 +25,12 @@ public class TMSPart extends TMSPos implements Serializable {
private String resultCode = "";
//生产日期
public String ProductionDate ="";
//过期日期
public String ExpiryDate = "";
//登录韩华系统的日期。 需要保存下来,需要登录日期做先进先出。 已保存在最后一次入库时间中
public String WarehousingDate = "";
public static TMSPart newBean(int index, String pn,String barcode,int requestCount,int responseCount,String resultCode,String cid,String posName ) {
......@@ -66,6 +67,7 @@ public class TMSPart extends TMSPos implements Serializable {
dataMap.put("RackID", getRackID());
dataMap.put("RowID", getRowID());
dataMap.put("ColID", getColID());
dataMap.put("PosId", getPosId());
return dataMap;
}
}
......@@ -22,7 +22,10 @@ public class TMSPartReelPos extends TMSPos implements Serializable {
*/
private int flag = 0;
private int state = 0;
/**
* 1=锁定,0=未锁定
*/
private int state=0;
//yyyy-MM-dd HH:mm:ss
private String indate;
......@@ -48,20 +51,22 @@ public class TMSPartReelPos extends TMSPos implements Serializable {
map.put("Count", getCount());
map.put("RowID", getRowID());
map.put("ColID", getColID());
map.put("PosId", getPosId());
map.put("Flag", getFlag());
map.put("Indate", getIndate());
map.put("Outdate", getOutdate());
map.put("State",getState());
return map;
}
public static TMSPartReelPos newBean(String pn,String barcode,int count,String cid,String posName,int flag,long inTime,long outTime) {
public static TMSPartReelPos newBean(String pn,String barcode,int count,String cid,String posName,int flag,long inTime,long outTime,int reelS) {
TMSPartReelPos bean = new TMSPartReelPos();
bean.setPartName(pn);
bean.setReelCode(barcode);
bean.setCount(count);
bean.setRackID(cid);
bean.setFlag(flag);
bean.setState(0);
bean.setState(reelS);
bean.setPosName(posName);
String format="yyyy-MM-dd HH:mm:ss";
if (inTime > 0) {
......
......@@ -33,6 +33,7 @@ public class TMSPartReelStatus extends TMSPart implements Serializable {
map.put("RackID", getRackID());
map.put("RowID", getRowID());
map.put("ColID", getColID());
map.put("PosId", getPosId());
map.put("ResultCode", getResultCode());
map.put("TowerLamp", isTowerLamp());
return map;
......
......@@ -20,47 +20,94 @@ public class TMSPos implements Serializable {
private String ColID;
private String PosId;
public Map<String,Object> getJson()
{
Map<String,Object> jObject = new HashMap<>();
jObject.put("RackID", RackID);
jObject.put("RowID", RowID);
jObject.put("ColID", ColID);
jObject.put("PosId", PosId);
return jObject;
}
public static TMSPos ToBean(Map<String,Object> map) {
try {
TMSPos obj = new TMSPos();
obj.setRackID(getMapValue(map,"RackID"));
obj.setRowID(getMapValue(map,"RowID"));
obj.setColID(getMapValue(map,"ColID"));
obj.setPosId(getMapValue(map,"PosId"));
return obj;
} catch (Exception ex) {
log.error("转换为TMSPos出错:" + ex.toString());
return null;
}
}
private static <T> T getMapValue(Map<String,Object> resultMap, String key ) {
if (key != null && !key.isEmpty()) {
Object value = resultMap.get(key);
if (value != null) {
return (T) value;
}
}
return null;
}
public String getPosName(){
return getRowID()+"_"+getColID();
return getRackID()+"_"+getRowID()+"_"+getColID();
}
public void setPosName(String posName) {
//如果库位是 01_01_11_05 , 01作为rackID, 01_11是 RowID, 05 是ColId
// 1284M02_01_11_01
//如果下划线分割只有三列,第一列是rackID, 第二列是rowID,第三列是colID
setPosId(posName);
if (ObjectUtil.isEmpty(posName)) {
setColID("");
setRowID("");
return;
}
//posName=rowId_colId
// int index=posName.indexOf('_');
// if(index>0){
// setRowID(posName.substring(0,index-1));
// setColID(posName.substring(index+1,posName.length()-1));
// }
String rowId = proStr(posName);
String rowId = "";
String colId = "";
String spit = "_";
String[] posArray = posName.split(spit);
if (posArray.length >= 3) {
if (posArray.length == 4) {
rowId = posArray[1] + spit + posArray[2];
colId = posArray[3];
} else if (posArray.length == 3) {
rowId = posArray[1];
colId = posArray[2];
} else {
spit = "-";
posArray = posName.split(spit);
}
if (posArray.length == 4) {
rowId = posArray[1] + spit + posArray[2];
colId = posArray[3];
} else if (posArray.length == 3) {
rowId = posArray[1];
colId = posArray[2];
} else {
try {
if (posArray.length == 3) {
rowId = Convert.toInt(proStr(posArray[1])) + "";
colId = Convert.toInt(posArray[2]) + "";
}else if(posArray.length==4){
rowId = Convert.toInt(proStr(posArray[1]+posArray[2])) + "";
} else if (posArray.length == 4) {
rowId = Convert.toInt(proStr(posArray[1] + posArray[2])) + "";
colId = Convert.toInt(posArray[3]) + "";
}
} catch (Exception ex) {
......@@ -87,9 +134,12 @@ public class TMSPos implements Serializable {
log.error("解析位置的行列失败 " + posName + "," + ex2.toString());
}
}
}
}
setRowID(proStr(rowId));
setColID(proStr(colId));
setRowID(rowId);
setColID(colId);
}
private String proStr(String input) {
......
......@@ -42,6 +42,7 @@ public class TMSRackStatus extends TMSPos implements Serializable {
jObject.put("RackID", getRackID());
jObject.put("RowID", getRowID());
jObject.put("ColID", getColID());
jObject.put("PosId", getPosId());
jObject.put("Flag", Flag);
jObject.put("Indate", Indate);
jObject.put("Outdate", Outdate);
......
package com.neotel.smfcore.custom.hanwha.util;
import com.google.common.collect.Maps;
import com.neotel.smfcore.custom.hanwha.util.bean.HanwhaApiInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
@Slf4j
@Service
public class HanwhaApiInfoUtil {
//api接口信息,默认返回10条
public static List<HanwhaApiInfo> apiInfoList = new CopyOnWriteArrayList<>();
public void updateApiInfoList(String url, String requestParam, String resultReturn) {
HanwhaApiInfo info = new HanwhaApiInfo();
info.setCreateDate(new Date());
info.setUrl(url);
info.setRequestParam(requestParam);
info.setResultReturn(resultReturn);
apiInfoList.add(info);
if (apiInfoList != null && apiInfoList.size() > 10) {
apiInfoList.remove(0);
}
}
public List<HanwhaApiInfo> getApiInfoList(){
List<HanwhaApiInfo> resultList = new ArrayList<>();
if (apiInfoList != null && !apiInfoList.isEmpty()){
resultList = apiInfoList.stream().sorted(Comparator.comparing(HanwhaApiInfo::getCreateDate).reversed()).collect(Collectors.toList());
}
return resultList;
}
}
package com.neotel.smfcore.custom.hanwha.util;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.hanwha.util.bean.HanwhaCacheConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class HanwhaCacheUtil {
@Autowired
private DataCache dataCache;
public static final String Cache_Hanwha_HostAndPost = "Cache_Hanwha_HostAndPost";
public void updateHostAndPort(HanwhaCacheConfig cacheConfig) {
HanwhaCacheConfig hanwhaCacheConfig = dataCache.getCache(Cache_Hanwha_HostAndPost);
if (hanwhaCacheConfig == null) {
hanwhaCacheConfig = new HanwhaCacheConfig();
}
hanwhaCacheConfig.setHost(cacheConfig.getHost());
hanwhaCacheConfig.setWebPort(cacheConfig.getWebPort());
hanwhaCacheConfig.setApiPort(cacheConfig.getApiPort());
hanwhaCacheConfig.setSingleOrder(cacheConfig.isSingleOrder());
dataCache.updateCache(Cache_Hanwha_HostAndPost, hanwhaCacheConfig);
}
public HanwhaCacheConfig getHostAndPortCache(){
HanwhaCacheConfig hostAndPortCache = dataCache.getCache(Cache_Hanwha_HostAndPost);
if (hostAndPortCache == null) {
hostAndPortCache = new HanwhaCacheConfig();
}
return hostAndPortCache;
}
}
package com.neotel.smfcore.custom.hanwha.util.bean;
import lombok.Data;
import java.util.Date;
@Data
public class HanwhaApiInfo {
private String url;
private String requestParam;
private String resultReturn;
private Date createDate;
}
package com.neotel.smfcore.custom.hanwha.util.bean;
import lombok.Data;
@Data
public class HanwhaCacheConfig {
private String host;
private String webPort;
private String apiPort;
private boolean singleOrder = false;
}
package com.neotel.smfcore.custom.keboda1335;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
......@@ -169,7 +170,35 @@ public class KebodaController {
}
}
//如果两个cid相同的话,直接返回原库位号,不移除锁定信息
for (String cid : cidList) {
ReelLockPosInfo reelLockPosInfo = ReelLockPosUtil.getLockPosInfoByCode(barcode.getBarcode());
if (reelLockPosInfo != null){
String lockCid = reelLockPosInfo.getCid();
if (cid.equals(lockCid)){
String lockPosName = reelLockPosInfo.getLockPosName();
//判断锁定的库位尺寸和barcode 尺寸是否一样,如果不一样,则重新找个库位
boolean hasRemoveLock = false;
StoragePos pos = storagePosManager.getByPosName(lockPosName);
if (pos != null){
if (pos.getW() != barcode.getPlateSize() || pos.getH() != barcode.getHeight()){
ReelLockPosUtil.removeReelLockPosInfo(barcode.getBarcode());
hasRemoveLock = true;
}
}
if (!hasRemoveLock) {
resultMap.put("result", "0");
resultMap.put("msg", "");
resultMap.put("pos", lockPosName);
resultMap.put("barcode", barcode.getBarcode());
resultMap.put("cid", cid);
log.info("当前库位锁定的cid相同,直接返回客户端,返回结果为:" + JSON.toJSONString(resultMap));
return resultMap;
}
}
}
}
//先移除被锁定的库位
ReelLockPosUtil.removeReelLockPosInfo(barcode.getBarcode());
......
......@@ -44,6 +44,11 @@ import java.util.concurrent.atomic.AtomicLong;
@Controller
@RequestMapping("/rest/api")
public class PanaApiController extends BaseSmfApiListener {
// api:
// name: PanaCIM
// codeResolveUrl: PanaCIM
// outNotifyUrl: PanaCIM
// inNotifyUrl: PanaCIM
@Autowired
protected TaskService taskService;
......@@ -466,7 +471,8 @@ public class PanaApiController extends BaseSmfApiListener {
return barcode;
}else{
String errorMsg = "PanaCIM [" + barcode.getBarcode() + "] NG:"+ ErrorCode;
throw new ValidateException(errorMsg, "PanaCIM验证失败");
log.error(errorMsg);
throw new ValidateException(errorMsg, errorMsg);
}
}
......@@ -551,7 +557,12 @@ public class PanaApiController extends BaseSmfApiListener {
}
}
}
throw new ValidateException(errorMsg, "PanaCIM验证失败");
if(ObjectUtil.isEmpty(errorMsg)){
//
errorMsg="PanaCIM verification failure";
log.error(errorMsg);
}
throw new ValidateException(errorMsg, errorMsg);
}else{
log.info("没有配置PanaCIM条码检测接口,查找setConfiguration注册的IP 及端口");
......
......@@ -62,7 +62,7 @@ public class SiemensApi extends BaseSmfApiListener {
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if(task.isFinished()){
if(task.isFinished() || task.isEnd()){
if(task.isPutInTask()){
}else{
......@@ -176,7 +176,7 @@ public class SiemensApi extends BaseSmfApiListener {
barcode.setPlateSize(codebean.getReelWidth());
barcode.setHeight(codebean.getReelHeight());
barcode.setBarcode(codebean.getCodeStr());
barcode.setAmount(component.getAmount());
barcode.setAmount(info.getQuantity());
barcode.setFullCode(codebean.getCodeStr());
barcode.setPartNumber(component.getPartNumber());
barcode = barcodeManager.saveBarcode(barcode);
......@@ -185,7 +185,7 @@ public class SiemensApi extends BaseSmfApiListener {
barcode.setPlateSize(codebean.getReelWidth());
barcode.setHeight(codebean.getReelHeight());
barcode.setBarcode(codebean.getCodeStr());
barcode.setAmount(component.getAmount());
barcode.setAmount(info.getQuantity());
barcode.setPartNumber(component.getPartNumber());
log.info("siemensCheckCode 修改 条码:[" + barcode.getBarcode() + "] pn为 ["+barcode.getPartNumber()+"] ");
}
......
......@@ -4,6 +4,8 @@ import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
......@@ -18,7 +20,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(tags = "西门子对接")
......@@ -53,7 +57,7 @@ public class SiemensController {
if (StringUtils.isNotEmpty(lotID)) {
StoragePos storagePos = storagePosManager.getByBarcode(lotID);
if (storagePos != null) {
Barcode barcode = storagePos.getBarcode();
/*Barcode barcode = storagePos.getBarcode();
//log.info("清理库位[" + storagePos.getPosName() + "]中的库存" + barcode.getBarcode());
String opUser = SecurityUtils.getCurrentUsername();
log.info(opUser + "清理库位[" + storagePos.getPosName() + "]中的库存" + barcode.getBarcode());
......@@ -70,7 +74,14 @@ public class SiemensController {
log.info("操作库位[" + storagePos.getPosName() + "]" + opKey + " : " + opStr);
}
resultMap.put("CID", storage.getCid());
}
}*/
storagePos.setEnabled(false);
storagePosManager.save(storagePos);
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
dataCache.reloadStorage(storage, "");
dataCache.updateDisablePos(storagePos);
DeviceMessageUtil.addDeviceMessage(storage.getCid(), MessageType.INFO.name(),
storage.getName(), "smfcore.siements.deleteUid", "删除UID[{0}],屏蔽库位[{1}]", new String[]{lotID,storagePos.getPosName()});
resultMap.put("ReturnCode", 1);
} else {
log.info("未找到UID[" + lotID + "]对应的库存信息");
......@@ -81,4 +92,46 @@ public class SiemensController {
return resultMap;
}
@ApiOperation("获取所有库存信息")
@RequestMapping("/getAllInventory")
@AnonymousAccess
public List<Map<String,String>> getAllInventory(@RequestBody Map<String,String> paramMap){
String deviceID = paramMap.get("DeviceID");
log.info("收到获取库存信息指令,deviceID为:"+deviceID);
List<String> deviceIdList = new ArrayList<>();
if (StringUtils.isEmpty(deviceID)){
for (Storage storage : dataCache.getAllStorage().values()) {
deviceIdList.add(storage.getCid());
}
} else {
String[] deviceIdStr = deviceID.split(",");
for (String id : deviceIdStr) {
deviceIdList.add(id);
}
}
List<Map<String,String>> resultList = new ArrayList<>();
for (String deviceId : deviceIdList) {
Map<String, StoragePos> usePosMap = dataCache.getUsedPosList(deviceId);
if (usePosMap != null && !usePosMap.isEmpty()){
for (StoragePos pos : usePosMap.values()) {
if (pos != null){
Barcode barcode = pos.getBarcode();
if (barcode != null){
Map<String,String> resultMap = new HashMap<>();
resultMap.put("LOTID",barcode.getBarcode());
resultMap.put("DEVICEID",deviceId);
resultMap.put("quantity",barcode.getAmount()+"");
resultList.add(resultMap);
}
}
}
}
}
return resultList;
}
}
......@@ -33,7 +33,7 @@ public class ReplaceQtyApiHandler extends DefaultSmfApiListener {
*
api:
#name: SO21476
#inCheckUrl: /Volumes/E/项目文件/21476&SO1442DUO
#inCheckUrl: \\192.168.5.5\SettingInfo\ReelID
*/
@Override
......@@ -78,8 +78,8 @@ public class ReplaceQtyApiHandler extends DefaultSmfApiListener {
return barcode;
}
} catch (Exception e) {
log.error("入库修改数量接口出错:" + e.getMessage());
throw new ValidateException("smfcore.mesApi.inCheck.error","修改数量出错:" + e.getMessage());
log.error("入库修改数量接口出错:" + e.toString());
throw new ValidateException("smfcore.mesApi.inCheck.error","修改数量出错:"+e.toString());
}
return null;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!