Commit 92eebe0a zshaohui

3f逻辑修改

1 个父辈 ea01bade
正在显示 81 个修改的文件 包含 83 行增加3803 行删除
......@@ -4,7 +4,6 @@ import com.google.common.base.Strings;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel;
import com.neotel.smfcore.custom.lizhen.setting.util.ExpireDateUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -683,75 +682,6 @@ public class BarcodeRule {
}
public GrLabel toGrLable(String codeStr) {
log.info("开始解析条码[" + codeStr + "]");
String[] codeArr = new String[]{codeStr};
if (!Strings.isNullOrEmpty(separator)) {
codeArr = codeStr.split(separator, -1);
//条码与规则长度对应不上
if (codeArr.length != length) {
log.info("条码[" + codeStr + "]与规则【" + ruleStr + "】长度不同");
return null;
} else {
codeArr = codeStr.split(separator, length);
}
}
GrLabel grLabel = new GrLabel();
grLabel.setFullCode(codeStr);
//得到gr标签唯一与行号
String reelId = "";
if (whole_reelId_item.hasThisField()) {
reelId = codeStr;
} else {
reelId = reelId_item.getStrValue(codeArr);
}
if (Strings.isNullOrEmpty(reelId)) {
log.info("条码解析失败,未找到RI字段");
//codeBean.setError("smfcore.error.barcode.noField",new String[]{"RI"},"条码解析失败,未找到{0}字段");
return null;
}
grLabel.setLabelId(reelId);
String memo = "";
if (memo_item.hasThisField()) {
memo = memo_item.getStrValue(codeArr);
}
if (Strings.isNullOrEmpty(memo)){
log.info("条码解析失败,未找到MEMO字段");
return null;
}
grLabel.setLabelItem(memo);
String partNumber = partNumber_item.getStrValue(codeArr);
if (Strings.isNullOrEmpty(partNumber)) {
log.info("条码解析失败,未找到PN字段");
return null;
}
grLabel.setPartNumber(partNumber);
int quantity = 0;
if (quantity_item.hasThisField()) {
quantity = quantity_item.getIntValue(codeArr);
if (quantity == -1) {
log.info("条码解析失败,未找到QTY 字段");
return null;
}
}
grLabel.setAmount(quantity);
grLabel.setRemainingAmount(quantity);
String supplier = supplier_item.getStrValue(codeArr);
grLabel.setProvider(supplier);
return grLabel;
}
/**
* 转义正则特殊字符 ($()*+.[]?\^{}
* @return
......
......@@ -5,7 +5,6 @@ import com.google.common.collect.Lists;
import com.neotel.smfcore.common.exception.ValidateException;
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.barcode.bean.BarcodeRule;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
......@@ -13,16 +12,14 @@ import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel;
import com.neotel.smfcore.custom.lizhen.setting.bean.ExpiredSetting;
import com.neotel.smfcore.custom.lizhen.setting.service.manager.ExpiredSettingManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yaml.snakeyaml.comments.CommentType;
import java.util.*;
import java.util.Collection;
import java.util.Date;
import java.util.List;
/**
* Created by sunke on 2021/7/13.
......@@ -434,15 +431,4 @@ public class CodeResolve {
return barcode;
}
public GrLabel resolveGrLable(String codeStr) {
for (BarcodeRule codeRule : barcodeRuleList) {
GrLabel grLabel = codeRule.toGrLable(codeStr);
if (grLabel != null) {
return grLabel;
}
}
return null;
}
}
......@@ -596,6 +596,7 @@ public class LiteOrderCache {
task.setDescribe(pos.getBarcode().getDescribe());
task.setKeeperCode(pos.getBarcode().getKeeperCode());
task.setExport(exportStr);
task.setPickingId(orderItem.getPickingId());
// task = dataLogDao.save(task);
taskService.addTaskToExecute(task);
}
......
......@@ -241,6 +241,9 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
private List<String> positionList;
private String pickingId;
public void setOutReelList(String reel) {
if (outReelList == null){
outReelList = new ArrayList<>();
......
......@@ -368,6 +368,11 @@ public class DataLog extends BasePo implements Serializable {
*/
private String export = "";
/**
* 出库pickingId
*/
private String pickingId;
public String getBarcode() {
if(barcode == null){
return "";
......
......@@ -42,7 +42,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
@RestController
@RequestMapping("/api/Mes")
@RequestMapping("wcs")
public class LizhenController {
@Autowired
......@@ -107,89 +107,6 @@ public class LizhenController {
}
@ApiOperation("外仓:发料明细")
@PostMapping("/EPickingList")
@AnonymousAccess
public ResultBean EPickingList(@RequestBody List<Map<String, Object>> params) {
log.info("发料明细数据--" + JsonUtil.toJsonStr(params));
for (Map<String, Object> param : params) {
//pickingId
String pickingId = param.get("picking_id") == null ? "" : param.get("picking_id").toString();
if (StringUtils.isBlank(pickingId)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"picking_id"});
}
//厂区
String plantCode = param.get("plant_code") == null ? "" : param.get("plant_code").toString();
if (StringUtils.isBlank(plantCode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"plant_code"});
}
//线别
String line = param.get("line") == null ? "" : param.get("line").toString();
if (StringUtils.isBlank(line)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"line"});
}
//判断是否已经生成过pickingId
LiteOrder liteOrderPic = liteOrderManager.findByOrderNo(pickingId);
if (liteOrderPic != null) {
return ResultBean.newErrorResult(-1, "", pickingId + "已经生成,请确认");
}
LiteOrder liteOrder = new LiteOrder();
liteOrder.setOrderNo(pickingId);
liteOrder.setLine(line);
liteOrder.setType(1);
liteOrder.setSource(LITEORDER_SOURCE.OUTTER.name());
List<LiteOrderItem> orderItems = new ArrayList<>();
String itemStr = param.get("ITEM") == null ? "" : param.get("ITEM").toString();
if (StringUtils.isBlank(itemStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"ITEM"});
}
int taskBarcodeCount = 0;
int allReelCount = 0;
List<Map> items = JsonUtil.toList(itemStr, Map.class);
for (Map item : items) {
String face = item.get("face") == null ? "" : item.get("face").toString();
String mo = item.get("mo") == null ? "" : item.get("mo").toString();
String materialCode = item.get("material_code") == null ? "" : item.get("material_code").toString();
String brand = item.get("brand") == null ? "" : item.get("brand").toString();
String batchCode = item.get("batch_code") == null ? "" : item.get("batch_code").toString();
int reqQty = item.get("req_qty") == null ? 0 : Integer.valueOf(item.get("req_qty").toString());
int reqReel = item.get("req_reel") == null ? 0 : Integer.valueOf(item.get("req_reel").toString());
String warehouse = item.get("warehouse") == null ? "" : item.get("warehouse").toString();
allReelCount = allReelCount + reqReel;
taskBarcodeCount = taskBarcodeCount + reqQty;
LiteOrderItem orderItem = new LiteOrderItem();
orderItem.setSide(face);
orderItem.setPn(materialCode);
orderItem.setBrand(brand);
orderItem.setBatchCode(batchCode);
orderItem.setWarehouseCode(warehouse);
orderItem.setNeedNum(reqQty);
orderItem.setNeedReelCount(reqReel);
orderItem.setMo(mo);
orderItem.setOrderNo(pickingId);
orderItem.setLine(line);
orderItem.setPlantCode(plantCode);
orderItems.add(orderItem);
}
if (orderItems != null && !orderItems.isEmpty()) {
liteOrder.setTaskReelCount(allReelCount);
//liteOrder.setTotalTaskReelCount(allReelCount);
liteOrder.setOrderItems(orderItems);
liteOrderManager.createWithItems(liteOrder);
liteOrderCache.addOrderToMap(liteOrder);
}
}
return ResultBean.newOkResult("");
}
ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
@PostConstruct
......@@ -234,12 +151,15 @@ public class LizhenController {
@ApiOperation("内仓:机台叫料")
@PostMapping("/mPickingList")
@PostMapping("/ReelWarningInfo")
@AnonymousAccess
public ResultBean mPickingList(@RequestBody List<Map<String, String>> params) {
if (params == null || params.isEmpty()) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"参数"});
}
log.info("收到缺料预警信息为:"+ JSONObject.toJSONString(params));
for (Map<String, String> param : params) {
String line = param.get("LINE");
String forwardUrl = getForwardUrl(line);
......@@ -277,6 +197,7 @@ public class LizhenController {
item.setPartnumber(data.get("PARTNUMBER"));
item.setLine(data.get("LINE"));
item.setItemId(data.get("ID"));
item.setPickingId(data.get("PICKING_ID"));
try {
item.setPriority(Integer.valueOf(data.get("PRIORITY")));
} catch (NumberFormatException e) {
......
package com.neotel.smfcore.custom.lizhen;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
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.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RequestMapping("/exp")
@RestController
public class OrderExpRestController {
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private ILiteOrderManager orderManager;
@Autowired
private IStoragePosManager storagePosManager;
@RequestMapping("/orderExp")
@AnonymousAccess
public ResultBean order(String orderNo) {
LiteOrder liteOrder = orderManager.findByOrderNo(orderNo);
List<LiteOrderItem> orderItems = liteOrder.getOrderItems();
//开始处理数据
for (LiteOrderItem orderItem : orderItems) {
//根据工单查找item
Query query = new Query(Criteria.where("orderItemId").is(orderItem.getId()));
List<Barcode> barcodes = barcodeManager.findByQuery(query);
int count = 0;
if (barcodes != null && !barcodes.isEmpty()) {
for (Barcode barcode : barcodes) {
barcode.setOut(false);
barcode.setOrderItemId(null);
barcode.setSelectMsg(null);
barcodeManager.save(barcode);
count++;
System.out.println("修改barcode数量为:" + count);
}
}
}
//开始处理料箱数据
for (LiteOrderItem orderItem : orderItems) {
Query query = new Query(Criteria.where("subCodeList.orderItemId").is(orderItem.getId()));
List<Barcode> barcodes = barcodeManager.findByQuery(query);
int count = 0;
for (Barcode barcode : barcodes) {
List<Barcode> subCodeList = barcode.getSubCodeList();
for (Barcode subCode : subCodeList) {
subCode.setOut(false);
subCode.setOrderItemId(null);
subCode.setSelectMsg(null);
}
barcode.setSubCodeList(subCodeList);
barcodeManager.save(barcode);
count++;
System.out.println("修改barcode数量为:" + count);
}
}
//开始处理料cang
for (LiteOrderItem orderItem : orderItems) {
Query query = new Query(Criteria.where("barcode.subCodeList.orderItemId").is(orderItem.getId()));
List<StoragePos> storagePosList = storagePosManager.findByQuery(query);
int count = 0;
for (StoragePos storagePos : storagePosList) {
Barcode barcode = storagePos.getBarcode();
List<Barcode> subCodeList = barcode.getSubCodeList();
for (Barcode subCode : subCodeList) {
subCode.setOut(false);
subCode.setOrderItemId(null);
subCode.setSelectMsg(null);
}
barcode.setSubCodeList(subCodeList);
storagePos.setBarcode(barcode);
storagePosManager.save(storagePos);
count++;
System.out.println("修改库位数量为:" + count);
}
}
//再补一刀
List<Barcode> barcodeList = barcodeManager.findByQuery(new Query(Criteria.where("isOut").is(true)));
if (barcodeList != null && !barcodeList.isEmpty()){
for (Barcode barcode : barcodeList) {
barcode.setOut(false);
barcode.setOrderItemId(null);
barcode.setSelectMsg(null);
barcodeManager.save(barcode);
}
}
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.core.barcode.bean.BarcodeRule;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class GrLabel extends BasePo {
/**
* 标签id
*/
private String labelId;
/**
* 行号
*/
private String labelItem;
/**
* 标签总数量
*/
private int amount = 0;
/**
* 剩余数量
*/
private int remainingAmount = 0;
/**
* 厂商
*/
private String provider;
/**
* pn
*/
private String partNumber;
/**
* keeperCode
*/
private String keeperCode;
/**
* 库别
*/
private String warehouseCode;
/**
* 完整二维码信息
*/
private String fullCode;
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.enums.InventoryStatus;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 盘点数据
*/
@Data
public class InventoryData extends BasePo {
/**
* 原始库位
*/
private String oriPosName;
/**
* 料箱号
*/
private String box;
/**
* 隔口码
*/
private String boxPartition;
/**
* 料号
*/
private String partNumber;
/**
* 物料描述
*/
private String describe;
/**
* 储位
*/
private String posName = "";
/**
* 卷数
*/
private int reelCount = 0;
/**
* 数量
*/
private int amout = 0;
/**
* 已盘点卷数
*/
private int inventoryReelCount = 0;
/**
* 已盘点数量
*/
private int inventoryAmout = 0;
/**
* 是否匹配
*/
private boolean isMatch = false;
/**
* 创建人
*/
private String creator;
/**
* 状态
*/
private String status = InventoryStatus.NEW.name();
/**
* 盘点批次
*/
private String inventoryBatch;
/**
* 盘点的barcode集合
*/
private List<Barcode> barcodeList;
/**
* 是否需要盘点,默认false
*/
private boolean needInventory = false;
public synchronized void updateBarcodeList(Barcode barcode) {
if (barcodeList == null) {
barcodeList = new ArrayList<>();
}
int index = -1;
for (int i = 0; i < barcodeList.size(); i++) {
if (barcodeList.get(i).getBarcode().equals(barcode.getBarcode())) {
index = i;
break;
}
}
if (index >= 0){
barcodeList.set(index,barcode);
} else {
barcodeList.add(barcode);
}
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 盘点箱子信息
*/
@Data
public class PartitionInfo {
/**
* 隔口信息
*/
private String partition;
/**
* 盘数
*/
private int reelCount = 0;
/**
* 是否盘点
*/
private boolean isInventory = false;
/**
* 料号
*/
private String partNumber;
/**
* 数量
*/
private int num = 0;
/**
* 盘点盘数
*/
private int inventoryReelCount = 0;
/**
* 盘点数量
*/
private int inventoryAmount = 0;
/**
* 盘点物料信息
*/
private List<Barcode> barcodeList = new ArrayList<>();
private int status = 0;
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author sunke
* @date 2022/9/22 4:32 PM
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Station {
/**
* 工位名称
*/
private String name;
/**
* 当前料箱的RFID
*/
private String currentRfid = "";
/**
* 物料当前扫描数量
*/
private int reelCurrentNum = 0;
/**
* 物料总数量
*/
private int reelNum;
/**
* 料箱当前数量
*/
private int boxCurrentNum = 0;
/**
* 料箱数量
*/
private int boxNum;
/**
* 宽
*/
private int platsize;
/**
* 高
*/
private int height;
/**
* gr标签
*/
private String grLabel;
/**
* gr行
*/
private String labelItem;
/**
* 上一个隔扣码
*/
private String lastScanBoxCode = "";
/**
* 是否已经入库
*/
private boolean isPutIn = true;
/**
* 料箱隔口数量
*/
private List<Integer> boxPartitionCounts;
/**
* 提示信息
*/
//private String msg;
/**
* 库别
*/
private String warehouseCode;
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Setter
@Getter
public class WareHouseCode extends BasePo implements Serializable {
/**
* 厂区
*/
private String plant;
/**
* 库别
*/
private String wareHouseCode;
/**
* 描述
*/
private String description;
/**
* 创建人
*/
private String createBy;
/**
* 修改人
*/
private String updateBy;
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean.dto;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
@Getter
@Setter
@ToString
public class WareHouseCodeDto implements Serializable {
@ApiModelProperty("ID")
private String id;
@ApiModelProperty("厂别")
private String plant;
@ApiModelProperty("库别")
private String wareHouseCode;
@ApiModelProperty("描述")
private String description;
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean.enums;
/**
* 盘点出库状态
*/
public enum InventoryStatus {
/**
* 新建
*/
NEW("新建"),
/**
* 正在执行中
*/
EXECUTING("正在执行"),
/**
* 完成
*/
FINISHED("已完成");
private String value;
InventoryStatus(String value) {
this.value = value;
}
public static String getValue(String name){
for (InventoryStatus status : InventoryStatus.values()) {
if (name.equals(status.name())){
return status.value;
}
}
return "";
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean.mapstruct;
import com.neotel.smfcore.common.base.BaseMapper;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.WareHouseCode;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.dto.WareHouseCodeDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring" ,unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface WareHouseCodeMapper extends BaseMapper<WareHouseCodeDto, WareHouseCode> {
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean.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 InventoryQuery {
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "createDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> createDate;
private String type;
}
package com.neotel.smfcore.custom.lizhen.agvBox.bean.query;
import com.neotel.smfcore.common.annotation.QueryCondition;
import lombok.Data;
@Data
public class WareHouseCodeQueryCriteria {
@QueryCondition(blurry = "plant,wareHouseCode,description,createBy,updateBy")
private String blurry;
}
package com.neotel.smfcore.custom.lizhen.agvBox.enums;
/*
出入库类型
*/
public enum INOUT_TYPE {
/**
* 单盘入库
*/
IN_ONE,
/**
* 整箱入库
*/
IN_BOX,
/**
* 单盘出库
*/
OUT_ONE,
/**
* 隔口出库
*/
OUT_PARTITION,
/**
* 整箱出库
*/
OUT_BOX,
/**
* 单盘取消
*/
CANCEL_ONE
}
package com.neotel.smfcore.custom.lizhen.agvBox.rest;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.JsonUtil;
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.order.service.manager.ILiteOrderItemManager;
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.lizhen.agvBox.bean.WareHouseCode;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.dto.WareHouseCodeDto;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.mapstruct.WareHouseCodeMapper;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.query.WareHouseCodeQueryCriteria;
import com.neotel.smfcore.custom.lizhen.agvBox.service.manager.WareHouseCodeManager;
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.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
@ApiOperation("库别维护页面")
@Slf4j
@RestController
@RequestMapping("/api/wareHouseCode")
public class CodeController {
@Autowired
private WareHouseCodeManager codeManager;
@Autowired
private WareHouseCodeMapper codeMapper;
@Autowired
private ILiteOrderManager liteOrderManager;
@Autowired
private ILiteOrderItemManager liteOrderItemManager;
/*@ApiOperation("根据id查找库别信息")
@RequestMapping("/getById")
@AnonymousAccess
public ResultBean getWareHouseCodeById(String id) {
WareHouseCode wareHouseCode = codeManager.get(id);
return ResultBean.newOkResult(codeMapper.toDto(wareHouseCode));
}*/
@ApiOperation("保存库别信息")
@PostMapping
@AnonymousAccess
public ResultBean saveWareHouseCode(@RequestBody WareHouseCodeDto wareHouseCodeDto) {
WareHouseCode wareHouseCode = codeMapper.toEntity(wareHouseCodeDto);
wareHouseCode.setCreateBy(SecurityUtils.getCurrentUsername());
codeManager.save(wareHouseCode);
return ResultBean.newOkResult("");
}
@ApiOperation("修改库别信息")
@PutMapping
@AnonymousAccess
private ResultBean updateWareHouseCode(@RequestBody WareHouseCodeDto wareHouseCodeDto){
if (wareHouseCodeDto.getId() == null) {
return ResultBean.newErrorResult(-1,"smfcore.valueCanotNull","{0}不能为空",new String[]{"id"} );
}
WareHouseCode wareHouseCode = codeMapper.toEntity(wareHouseCodeDto);
wareHouseCode.setId(wareHouseCodeDto.getId());
wareHouseCode.setUpdateBy(SecurityUtils.getCurrentUsername());
wareHouseCode.setUpdateDate(new Date());
codeManager.save(wareHouseCode);
return ResultBean.newOkResult("");
}
@ApiOperation("删除库别信息")
@DeleteMapping
@AnonymousAccess
private ResultBean deleteWareHouseCodeById(@RequestBody Set<String> ids){
List<WareHouseCode> codes = new ArrayList<>();
for (String id : ids) {
if (id == null) {
return ResultBean.newErrorResult(-1,"smfcore.valueCanotNull","{0}不能为空",new String[]{"ID"} );
}
WareHouseCode wareHouseCode = codeManager.get(id);
if (wareHouseCode == null){
return ResultBean.newErrorResult(-1,"smfcore.valueNotExist","{0}[{1}]不存在",new String[]{"id",id});
}
codes.add(wareHouseCode);
}
for (WareHouseCode code : codes) {
log.info(SecurityUtils.getCurrentUsername()+"删除的信息为:"+ JsonUtil.toJsonStr(code));
codeManager.delete(code);
}
return ResultBean.newOkResult("");
}
@ApiOperation("库别列表")
@GetMapping("/list")
@AnonymousAccess
private PageData getWareHouseCodeList(WareHouseCodeQueryCriteria criteria, Pageable pageable){
Query query = QueryHelp.getQuery(criteria);
PageData<WareHouseCode> codePageData = codeManager.findByPage(query, pageable);
List<WareHouseCodeDto> codeDtos = new ArrayList<>();
List<WareHouseCode> codes = codePageData.getContent();
for (WareHouseCode code : codes) {
WareHouseCodeDto codeDto = codeMapper.toDto(code);
codeDto.setId(code.getId());
codeDtos.add(codeDto);
}
return new PageData(codeDtos,codePageData.getTotalElements());
}
@ApiOperation("获取库别列表下拉")
@RequestMapping("/pullDown")
@AnonymousAccess
private List<String> getWareHouseCodePullDown(String orderNo){
List<WareHouseCode> wareHouseCodes = codeManager.findAll();
List<String> pullDowns = new ArrayList<>();
List<String> warehouseCodes = new ArrayList<>();
if (StringUtils.isNotBlank(orderNo)){
LiteOrder liteOrder = liteOrderManager.findByOrderNo(orderNo);
if (liteOrder != null){
List<LiteOrderItem> orderItems = liteOrderItemManager.findOrderItems(liteOrder.getId());
for (LiteOrderItem orderItem : orderItems) {
if (StringUtils.isNotBlank(orderItem.getWarehouseCode())){
if (!warehouseCodes.contains(orderItem.getWarehouseCode())) {
warehouseCodes.add(orderItem.getWarehouseCode());
}
}
}
}
}
for (WareHouseCode wareHouseCode : wareHouseCodes) {
String code = wareHouseCode.getWareHouseCode();
if (warehouseCodes != null && !warehouseCodes.isEmpty()){
if (warehouseCodes.contains(code)) {
pullDowns.add(code);
}
} else {
pullDowns.add(code);
}
}
return pullDowns;
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.rest;
import cn.hutool.core.date.DateUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
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;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.setting.util.ExpireDateUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@RestController
@Slf4j
@RequestMapping("/task")
public class TaskRestController {
@Autowired
private IDataLogManager dataLogManager;
@Autowired
private DataCache dataCache;
@Autowired
private TaskService taskService;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private ILiteOrderItemManager liteOrderItemManager;
@Autowired
private IBarcodeManager barcodeManager;
@AnonymousAccess
@RequestMapping("/getOutBarcodeByPkId")
public ResultBean getOutBarcodeByPkId(String pkId) {
List<Map<String, String>> results = new ArrayList<>();
List<LiteOrderItem> orderItems = liteOrderItemManager.findByQuery(new Query(Criteria.where("orderNo").is(pkId)));
if (orderItems != null && !orderItems.isEmpty()) {
List<String> itemIds = new ArrayList<>();
for (LiteOrderItem orderItem : orderItems) {
itemIds.add(orderItem.getId());
}
Query query = new Query(Criteria.where("isOut").is(true).and("orderItemId").in(itemIds));
List<Barcode> barcodes = barcodeManager.findByQuery(query);
for (Barcode barcode : barcodes) {
Map<String, String> resultMap = new HashMap<>();
resultMap.put("唯一码", barcode.getBarcode());
resultMap.put("隔口码", barcode.getPosName());
results.add(resultMap);
}
}
return ResultBean.newOkResult(results);
}
@RequestMapping("/putIn")
@AnonymousAccess
public ResultBean putIn(@RequestBody Map<String, String> paramMap) {
String barcode = paramMap.get("barcode");
String posName = paramMap.get("posName");
String cid = paramMap.get("cid");
Storage storage = dataCache.getStorage(cid);
DataLog dataLog = new DataLog();
dataLog.setStorageId(storage.getId());
dataLog.setPosName(posName);
dataLog.setPosId(storagePosManager.getByPosName(posName).getId());
dataLog.setCid(cid);
dataLog.setBarcode(barcode);
dataLog.setPartNumber(barcode);
dataLog.setType(1);
dataLog.setStatus(OP_STATUS.WAIT.name());
taskService.addTaskToExecute(dataLog);
return ResultBean.newOkResult("");
}
@RequestMapping("/outIn")
@AnonymousAccess
public ResultBean outIn(@RequestBody Map<String, String> paramMap) {
String barcode = paramMap.get("barcode");
String posName = paramMap.get("posName");
String cid = paramMap.get("cid");
String name = paramMap.get("name");
Storage storage = dataCache.getStorage(cid);
DataLog dataLog = new DataLog();
dataLog.setStorageId(storage.getId());
dataLog.setPosName(posName);
dataLog.setPosId(storagePosManager.getByPosName(posName).getId());
dataLog.setCid(cid);
dataLog.setBarcode(barcode);
dataLog.setPartNumber(barcode);
dataLog.setType(2);
dataLog.setStatus(OP_STATUS.WAIT.name());
dataLog.setLoc(name);
log.info("工位信息--" + name);
taskService.addTaskToExecute(dataLog);
return ResultBean.newOkResult("");
}
/**
* 初始化,刷新过期时间
*/
@GetMapping("/flushExpireData")
@AnonymousAccess
public void flushExpireData() {
List<StoragePos> storagePosList = storagePosManager.findNotEmpty();
if (storagePosList != null && !storagePosList.isEmpty()) {
for (StoragePos storagePos : storagePosList) {
Barcode barcode = storagePos.getBarcode();
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
for (Barcode subCode : subCodeList) {
if (subCode.getExpireDate() == null) {
String provider = subCode.getProvider();
String dateCode = subCode.getDateCode();
Date produceDate = ExpireDateUtil.getExpireDate(dateCode, provider);
if (produceDate != null) {
subCode.setProduceDate(produceDate);
subCode.setExpireDate(DateUtil.offsetMonth(produceDate, 12));
barcodeManager.save(subCode);
}
}
}
barcode.setSubCodeList(subCodeList);
barcodeManager.save(barcode);
storagePos.setBarcode(barcode);
storagePosManager.save(storagePos);
}
}
}
}
/**
* 初始化内仓,过期时间
*/
@GetMapping("/flushInnerExpireData")
@AnonymousAccess
public void flushInnerExpireData() {
List<StoragePos> storagePosList = storagePosManager.findNotEmpty();
if (storagePosList != null && !storagePosList.isEmpty()) {
for (StoragePos storagePos : storagePosList) {
Barcode barcode = storagePos.getBarcode();
// if (barcode.getExpireDate() == null) {
String provider = barcode.getProvider();
String dateCode = barcode.getDateCode();
Date produceDate = ExpireDateUtil.getExpireDate(dateCode, provider);
if (produceDate != null) {
barcode.setProduceDate(produceDate);
barcode.setExpireDate(DateUtil.offsetMonth(produceDate, 12));
barcodeManager.save(barcode);
}
// }
storagePos.setBarcode(barcode);
storagePosManager.save(storagePos);
}
}
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.rest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.lizhen.report.merge.utils.FloorUtils;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* 外仓外部接口控制类
*/
@RestController
@RequestMapping("/ext")
public class WarehouseExtController {
@Autowired
private IDataLogManager dataLogManager;
@Autowired
private FloorUtils floorUtils;
@RequestMapping("/forward/getDataLogs")
@AnonymousAccess
public List<DataLog> forwardGetDataLogs(String orderNo, String line, Pageable pageable){
String url = "";
Map<String, String> allFloor = floorUtils.getAllFloor(2);
for (String floor : allFloor.values()) {
if (floorUtils.isB15(floor)){
url = floorUtils.getUrlByFloor(floor);
break;
}
}
if (StringUtils.isNotBlank(url)){
url = url + "/ext/getDatalogs"+"?orderNo=" + orderNo + "&line=" + line + "&page=" + pageable.getPageNumber() + "&size=" + pageable.getPageSize();
String result = HttpUtil.get(url);
if (StringUtils.isNotBlank(result)){
return JSONArray.parseArray(result,DataLog.class);
}
}
return null;
}
@RequestMapping("/getDatalogs")
@AnonymousAccess
public List<DataLog> getDatalogs(String orderNo, String line, Pageable pageable) {
List<DataLog> dataLogs = dataLogManager.getDatalogs(orderNo, line, pageable);
return dataLogs;
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface GrLabelDao extends IBaseDao {
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface InventoryDataDao extends IBaseDao {
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface WareHouseCodeDao extends IBaseDao {
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel;
import com.neotel.smfcore.custom.lizhen.agvBox.service.dao.GrLabelDao;
import org.springframework.stereotype.Service;
@Service
public class GrLabelDaoImpl extends AbstractBaseDao implements GrLabelDao {
@Override
public Class getEntityClass() {
return GrLabel.class;
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.InventoryData;
import com.neotel.smfcore.custom.lizhen.agvBox.service.dao.InventoryDataDao;
import org.springframework.stereotype.Service;
@Service
public class InventoryDataDaoImpl extends AbstractBaseDao implements InventoryDataDao {
@Override
public Class getEntityClass() {
return InventoryData.class;
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.WareHouseCode;
import com.neotel.smfcore.custom.lizhen.agvBox.service.dao.GrLabelDao;
import com.neotel.smfcore.custom.lizhen.agvBox.service.dao.WareHouseCodeDao;
import org.springframework.stereotype.Service;
@Service
public class WareHouseCodeDaoImpl extends AbstractBaseDao implements WareHouseCodeDao {
@Override
public Class getEntityClass() {
return WareHouseCode.class;
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Set;
public interface GrLabelManager extends IBaseManager<GrLabel> {
GrLabel findLabelBylabelId(String labelId,String labelItem);
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.InventoryData;
import org.springframework.data.mongodb.core.query.Query;
public interface InventoryDataManager extends IBaseManager<InventoryData> {
InventoryData findOne(Query query);
int countByQuery(Query query);
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.WareHouseCode;
import java.util.List;
public interface WareHouseCodeManager extends IBaseManager<WareHouseCode> {
List<WareHouseCode> findAll();
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.manager.impl;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.core.barcode.service.dao.IBarcodeDao;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel;
import com.neotel.smfcore.custom.lizhen.agvBox.service.dao.GrLabelDao;
import com.neotel.smfcore.custom.lizhen.agvBox.service.manager.GrLabelManager;
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.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
@Slf4j
@Service
public class GrLabelManagerImpl implements GrLabelManager {
@Autowired
private GrLabelDao grLabelDao;
@Override
public GrLabel get(String id) {
return null;
}
@Override
public GrLabel save(GrLabel object) throws ValidateException {
return grLabelDao.save(object);
}
@Override
public void delete(GrLabel object) throws ValidateException {
}
@Override
public PageData<GrLabel> findByPage(Query query, Pageable pageable) {
return null;
}
@Override
public List<GrLabel> findByQuery(Query query) {
return null;
}
public GrLabel findLabelBylabelId(String labelId,String labelItem){
return grLabelDao.findOne(new Query(Criteria.where("labelId").is(labelId).and("labelItem").is(labelItem)));
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.manager.impl;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.InventoryData;
import com.neotel.smfcore.custom.lizhen.agvBox.service.dao.InventoryDataDao;
import com.neotel.smfcore.custom.lizhen.agvBox.service.manager.InventoryDataManager;
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 InventoryDataManagerImpl implements InventoryDataManager {
@Autowired
private InventoryDataDao inventoryDataDao;
@Override
public InventoryData get(String id) {
return null;
}
@Override
public InventoryData save(InventoryData object) throws ValidateException {
return inventoryDataDao.save(object);
}
@Override
public void delete(InventoryData object) throws ValidateException {
}
@Override
public PageData<InventoryData> findByPage(Query query, Pageable pageable) {
int count = inventoryDataDao.countByQuery(query);
List list = inventoryDataDao.findByQuery(query, pageable);
return new PageData<InventoryData>(list, count);
}
@Override
public List<InventoryData> findByQuery(Query query) {
return inventoryDataDao.findByQuery(query);
}
@Override
public InventoryData findOne(Query query) {
return inventoryDataDao.findOne(query);
}
@Override
public int countByQuery(Query query) {
return inventoryDataDao.countByQuery(query);
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.service.manager.impl;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.WareHouseCode;
import com.neotel.smfcore.custom.lizhen.agvBox.service.dao.WareHouseCodeDao;
import com.neotel.smfcore.custom.lizhen.agvBox.service.manager.WareHouseCodeManager;
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 WareHouseCodeManagerImpl implements WareHouseCodeManager {
@Autowired
private WareHouseCodeDao codeDao;
@Override
public WareHouseCode get(String id) {
return codeDao.findOneById(id);
}
@Override
public WareHouseCode save(WareHouseCode object) throws ValidateException {
return codeDao.save(object);
}
@Override
public void delete(WareHouseCode object) throws ValidateException {
codeDao.removeOne(object);
}
@Override
public PageData<WareHouseCode> findByPage(Query query, Pageable pageable) {
int totalCount = codeDao.countByQuery(query);
List<WareHouseCode> wareHouseCodes= codeDao.findByQuery(query,pageable);
return new PageData(wareHouseCodes,totalCount);
}
@Override
public List<WareHouseCode> findByQuery(Query query) {
return null;
}
@Override
public List<WareHouseCode> findAll() {
return codeDao.findAll();
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.util;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.InventoryData;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.PartitionInfo;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.enums.InventoryStatus;
import com.neotel.smfcore.custom.lizhen.agvBox.service.manager.InventoryDataManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class BoxUtil {
private static DataCache dataCache;
@Autowired
private void setDataCache(DataCache cache) {
this.dataCache = cache;
}
private static InventoryDataManager inventoryDataManager;
@Autowired
private void setInventoryDataManager(InventoryDataManager manager) {
this.inventoryDataManager = manager;
}
/**
* 盘点数据key
*/
private static final String INVENTORY_DATA = "barcode.inventory.data";
/**
* 解析料箱信息
*
* @param str
* @return
*/
public static String getBoxStr(String str) {
String boxStr = "";
if (StringUtils.isNotBlank(str)) {
if (str.startsWith("CS") || str.startsWith("CM") || str.startsWith("CB")) {
if (str.endsWith("A") || str.endsWith("B")) {
boxStr = str.substring(0, str.length() - 1);
} else if (str.indexOf("-") != -1) {
boxStr = str.substring(0, str.indexOf("-"));
} else {
boxStr = str;
}
}
}
return boxStr;
}
/**
* 隔口数量
*
* @param partition
* @param subCodeList
* @return
*/
public static int getPartitionNum(String partition, List<Barcode> subCodeList) {
if (subCodeList != null && !subCodeList.isEmpty()) {
int num = subCodeList.stream().filter(item -> partition.equals(item.getPosName())).mapToInt(Barcode::getAmount).sum();
return num;
}
return 0;
}
/**
* 获取隔口料号
*
* @param partition
* @param subCodeList
* @return
*/
public static String getPartitionPartNumber(String partition, List<Barcode> subCodeList) {
String partNumber = "";
for (Barcode subCode : subCodeList) {
if (partition.equals(subCode.getPosName())) {
partNumber = subCode.getPartNumber();
break;
}
}
return partNumber;
}
/**
* 获取隔口数量
*
* @param partition
* @param subCodeList
* @return
*/
public static int getPartitionCount(String partition, List<Barcode> subCodeList) {
if (subCodeList != null && !subCodeList.isEmpty()) {
int partitionCount = (int) subCodeList.stream().filter(item -> partition.equals(item.getPosName())).count();
return partitionCount;
}
return 0;
}
/**
* 获取隔口的信息
*
* @param boxSideStr
* @param barcode
* @return
*/
public static List<PartitionInfo> getPartitionInfo(String boxSideStr, Barcode barcode) {
List<PartitionInfo> infoList = new ArrayList<>();
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
Map<String, PartitionInfo> infoMap = new HashMap<>();
String boxStr = getBoxStr(boxSideStr);
for (int i = 1; i < 9; i++) {
String partition = boxStr + "-" + i;
PartitionInfo info = new PartitionInfo();
info.setPartition(partition);
info.setReelCount(getPartitionCount(partition, subCodeList));
info.setPartNumber(getPartitionPartNumber(partition, subCodeList));
info.setNum(getPartitionNum(partition, subCodeList));
infoMap.put(partition, info);
}
if (boxSideStr.endsWith("A")) {
if (boxSideStr.startsWith("CS") || boxSideStr.startsWith("CB")) {
for (int i = 8; i > 4; i--) {
String partition = boxStr + "-" + i;
infoList.add(infoMap.get(partition));
}
for (int i = 1; i < 5; i++) {
String partition = boxStr + "-" + i;
infoList.add(infoMap.get(partition));
}
} else {
for (int i = 2; i > 0; i--) {
String partition = boxStr + "-" + i;
infoList.add(infoMap.get(partition));
}
}
} else if (boxSideStr.endsWith("B")) {
if (boxSideStr.startsWith("CS") || boxSideStr.startsWith("CB")) {
for (int i = 4; i > 0; i--) {
String partition = boxStr + "-" + i;
infoList.add(infoMap.get(partition));
}
for (int i = 5; i < 9; i++) {
String partition = boxStr + "-" + i;
infoList.add(infoMap.get(partition));
}
} else {
for (int i = 1; i < 3; i++) {
String partition = boxStr + "-" + i;
infoList.add(infoMap.get(partition));
}
}
}
}
return infoList;
}
/**
* 判断是否盘点完成
* @param boxStr
* @return
*/
public static boolean isInventoryFinished(String boxStr) {
String inventoryBatch = dataCache.getCache(INVENTORY_DATA) +"";
if (StringUtils.isBlank(inventoryBatch) || "-1".equals(inventoryBatch)) {
return true;
}
List<InventoryData> dataList = inventoryDataManager.findByQuery(new Query(Criteria.where("inventoryBatch").is(inventoryBatch).and("box").is(boxStr)));
if (dataList != null && !dataList.isEmpty()) {
for (InventoryData data : dataList) {
if (!data.getStatus().equals(InventoryStatus.FINISHED.name())) {
return false;
}
}
}
return true;
}
/**
* 判断是否可以入库
* @param partitionStr
* @return
*/
public static boolean isCanPutIn(String partitionStr) {
List<String> partitionList = new ArrayList<>();
String boxStr = getBoxStr(partitionStr);
if (partitionStr.startsWith("CS") || partitionStr.startsWith("CB")) {
for (int i = 1; i < 9; i++) {
partitionList.add(boxStr+"-"+i);
}
} else {
for (int i = 1; i < 3; i++) {
partitionList.add(boxStr+"-"+i);
}
}
if (partitionList != null && !partitionList.isEmpty()){
if (partitionList.contains(partitionStr)){
return true;
}
}
return false;
}
}
package com.neotel.smfcore.custom.lizhen.agvBox.util;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.Station;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Service
@Slf4j
public class StationCacheUtil {
private static DataCache dataCache;
/**
* 工位缓存信息
*/
private static Map<String, Station> stationMap = new ConcurrentHashMap<>();
public static void saveBoxToBoxCode(Station station){
int boxCurrentNum = station.getBoxCurrentNum();
boxCurrentNum ++;
station.setBoxCurrentNum(boxCurrentNum);
StationCacheUtil.updateStation(station);
}
public static void saveReelToBoxCode(Station station) {
int reelCurrentNum = station.getReelCurrentNum();
reelCurrentNum++;
station.setReelCurrentNum(reelCurrentNum);
StationCacheUtil.updateStation(station);
}
@PostConstruct
public void init() {
log.info("开始工位缓存信息");
for (int i = 1; i <= 5; i++) {
String stationName = "s" + i;
Station station = dataCache.getCache(stationName);
if(station == null){
station = new Station();
station.setName(stationName);
}
stationMap.put(stationName,station);
dataCache.updateCache(stationName, station);
}
}
public static synchronized void updateStation(Station station){
stationMap.put(station.getName(),station);
dataCache.updateCache(station.getName(), station);
}
/**
* 更新工位当前的RFID信息
* @param stationName 工位名称
* @param rfid 料箱RFID信息
*/
public static void updateCurrentRfid(String stationName, String rfid){
if(rfid == null){
rfid = "";
}
Station station = getStation(stationName);
if(station != null){
String oldRfid = station.getCurrentRfid();
if (!rfid.equals(oldRfid)) {
log.info("工位" + stationName + " 切换料箱,当前料箱:" + rfid + ",上一料箱:" + oldRfid);
station.setCurrentRfid(rfid);
updateStation(station);
}
} else {
station = new Station();
station.setName(stationName);
station.setCurrentRfid(rfid);
updateStation(station);
}
}
/**
* 获取所有工位的缓存信息
*/
public static Collection<Station> getAllStations(){
return stationMap.values();
}
/**
* 获取工位信息
* @param stationName 工位名称
* @return
*/
public static Station getStation(String stationName){
return stationMap.get(stationName);
}
@Autowired
public void setDataCache(DataCache dataCache) {
StationCacheUtil.dataCache = dataCache;
}
}
......@@ -39,4 +39,6 @@ public class PreWarningItem extends BasePo {
* 接收时间
*/
private Date receiveDate = new Date();
private String pickingId;
}
package com.neotel.smfcore.custom.lizhen.innerBox.util;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class CommonUtil {
public static String plantCode;
@Value("${api.plantCode}")
private void setPlantCode(String code){
CommonUtil.plantCode = code;
}
}
package com.neotel.smfcore.custom.lizhen.innerBox.util;
import com.alibaba.fastjson.JSON;
import com.mks.api.response.Item;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
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.rest.bean.LineConfig;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem;
import com.neotel.smfcore.custom.lizhen.innerBox.service.manager.IPreWarningItemManager;
import com.neotel.smfcore.custom.lizhen.innerBox.util.service.PreWarningItemCacheManager;
import com.neotel.smfcore.custom.lizhen.third.maicheng.bean.StationStatus;
import com.neotel.smfcore.custom.lizhen.third.maicheng.util.StationStatusCache;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
......@@ -75,70 +69,13 @@ public class PreWarningItemCache {
queueItemList = preWarningItemManager.findAll();
}
if (queueItemList != null && !queueItemList.isEmpty()) {
//迈征集合
List<PreWarningItem> maiZhengItemList = new ArrayList<>();
//其他工单集合
List<PreWarningItem> otherItemList = new ArrayList<>();
//挑出迈征和其他工单
Map<String, String> stationStatusMap = StationStatusCache.getStationStatusMap();
for (PreWarningItem item : queueItemList) {
/*String station = item.getStation();
String partnumber = item.getPartnumber();
String slot = item.getSlot();
String line = item.getLine();
String side = item.getSide();
String key = station + "_" + partnumber + "_" + slot + "_" + line+"_"+side;
String value = stationStatusMap.get(key);
if (StringUtils.isNotBlank(value)) {
maiZhengItemList.add(item);
} else {
otherItemList.add(item);
}*/
otherItemList.add(item);
}
//处理迈征工单信息
/*if (maiZhengItemList != null && !maiZhengItemList.isEmpty()) {
maiZhengItemList = maiZhengItemList.stream().sorted(Comparator.comparing(PreWarningItem::getReceiveDate)).collect(Collectors.toList());
int minute = dataCache.getCache(Constants.CACHE_maiZhengMinute);
if (minute == 0) {
minute = 20;
}
//如果第一条接受的时间和当前时间相差超过设定时间
PreWarningItem firstItem = maiZhengItemList.get(0);
if (System.currentTimeMillis() - firstItem.getReceiveDate().getTime() > 1000 * 60 * minute) {
//获取迈征的线体
List<String> lineList = StationStatusCache.getStationStatusLineList();
if (lineList != null && !lineList.isEmpty()) {
for (String cacheLine : lineList) {
List<PreWarningItem> itemList = new ArrayList<>();
for (PreWarningItem item : maiZhengItemList) {
String line = item.getLine();
String station = item.getStation();
String side = item.getSide();
String trackNumber = "";
if (StringUtils.isNotBlank(station)) {
trackNumber = station.substring(station.length() - 1);
}
line = line + "_" + side + "_" + trackNumber;
if (line.equals(cacheLine)) {
itemList.add(item);
}
}
if (itemList != null && !itemList.isEmpty()) {
createAndExecuteLiteOrder(itemList, true);
}
}
}
}
}*/
//处理其他工单信息
if (otherItemList != null && !otherItemList.isEmpty()) {
Map<String, List<PreWarningItem>> otherItemGroupMap = otherItemList.stream().collect(Collectors.groupingBy(PreWarningItem::getLine));
......@@ -174,14 +111,6 @@ public class PreWarningItemCache {
public static synchronized LiteOrder createAndExecuteLiteOrder(List<PreWarningItem> lineItems, boolean maiZheng) {
//1.得到优先级比较高的
LiteOrder liteOrder = new LiteOrder();
//List<PreWarningItem> itemsPri = new ArrayList<>();
/*if (priority == 1){
lineItems = lineItems.stream().filter(t -> 1 == t.getPriority()).collect(Collectors.toList());
liteOrder.setPriority(1);
} else if (priority == 2){
lineItems = lineItems.stream().filter(t -> 1 != t.getPriority()).collect(Collectors.toList());
liteOrder.setPriority(0);
}*/
//2 如果优先级不为空,则优先生成优先级高的工单
List<LiteOrderItem> orderItems = new ArrayList<>();
if (lineItems != null && !lineItems.isEmpty()) {
......@@ -204,6 +133,7 @@ public class PreWarningItemCache {
orderItem.setReel(item.getReel());
orderItem.setBrand(item.getBrand());
orderItem.setReceiveDate(item.getReceiveDate());
orderItem.setPickingId(item.getPickingId());
orderItems.add(orderItem);
}
}
......
......@@ -58,7 +58,7 @@ public class KafkaService {
/**
* 设备状态发送
*/
@Scheduled(fixedRate = 1000 * 60 * 1)
//@Scheduled(fixedRate = 1000 * 60 * 1)
public void setMachineStatus() {
log.info("发送设备状态开始");
Collection<Storage> storages = dataCache.getAllStorage().values();
......@@ -158,7 +158,7 @@ public class KafkaService {
/**
* 心跳数据发送
*/
@Scheduled(fixedRate = 1000 * 60 * 5)
//@Scheduled(fixedRate = 1000 * 60 * 5)
public void setHeartbeat() {
log.info("发送心跳开始");
//根据machineId,找到设备状态,是否正常
......@@ -203,7 +203,7 @@ public class KafkaService {
/**
* 设备状态发送
*/
@Scheduled(fixedRate = 1000 * 60 * 1)
//@Scheduled(fixedRate = 1000 * 60 * 1)
public void setStorageExportStatus() {
log.info("发送出料口信息开始");
......@@ -272,7 +272,7 @@ public class KafkaService {
/**
* 发送出料口心跳
*/
@Scheduled(fixedRate = 1000 * 60 * 5)
//@Scheduled(fixedRate = 1000 * 60 * 5)
public void setStorageHeartbeat() {
log.info("发送出料口心跳开始");
EquipStatusBean statusBean = EquipStatusUtil.getStatusBean(KafkaConfig.LINE_CID);
......@@ -308,7 +308,7 @@ public class KafkaService {
/**
* MachineParameter发送
*/
@Scheduled(fixedRate = 1000 * 60 * 5)
//@Scheduled(fixedRate = 1000 * 60 * 5)
public void setMachineParameter() {
log.info("MachineParameter开始发送");
List<String> machineIdList = getMachineIdList();
......
package com.neotel.smfcore.custom.lizhen.kanban.bacheng.bean;
import lombok.Data;
@Data
public class Status {
/**
* 空闲
*/
public static final int idle = 1;
/**
* 执行任务
*/
public static final int performTask = 2;
/**
* 故障
*/
public static final int fault = 3;
}
package com.neotel.smfcore.custom.lizhen.kanban.bacheng.bean.dto;
import lombok.Data;
@Data
public class BcStationDto {
private String name;
private int status;
}
package com.neotel.smfcore.custom.lizhen.kanban.bacheng.bean.dto;
import lombok.Data;
@Data
public class BcStorageDto {
private String cid;
private int status;
private int total;
private int use;
private int noUse;
}
package com.neotel.smfcore.custom.lizhen.kanban.common;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.custom.lizhen.kanban.common.bean.dto.InOutDataDto;
import com.neotel.smfcore.custom.lizhen.kanban.service.manager.InOutDataDtoManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.*;
@RestController
@Slf4j
public class KanbanUtils {
private static String F2;
private static String F3;
private static String F5;
private static String F4;
private static IDataLogManager dataLogManager;
private static IStoragePosManager storagePosManager;
private static DataCache dataCache;
private static InOutDataDtoManager inOutDataManager;
/**
* 今日出入库缓存
*/
private static InOutDataDto todayInOutDto = null;
/**
* 得到当日的出入库完成统计
*
* @return
*/
public static Map<String, Integer> getTodayInAndOutAmount() throws ParseException {
Map<String, Integer> resultMap = new HashMap<>();
int inCount = 0;
int outCount = 0;
if (todayInOutDto == null || System.currentTimeMillis() - todayInOutDto.getCreateDate().getTime() >= 1000 * 60 * 1) {
todayInOutDto = new InOutDataDto();
//得到当前日期与结束日期
Date startDate = getCurrentDate();
Date endDate = DateUtil.addDays(startDate, 1);
//得到出入库数据
inCount = dataLogManager.getInOutData(startDate, endDate, OP.PUT_IN, "", -1, "");
outCount = dataLogManager.getInOutData(startDate, endDate, OP.CHECKOUT, "", -1, "");
todayInOutDto.setInValue(inCount);
todayInOutDto.setOutValue(outCount);
todayInOutDto.setCreateDate(new Date());
} else {
inCount = todayInOutDto.getInValue();
outCount = todayInOutDto.getOutValue();
}
resultMap.put("in", inCount);
resultMap.put("out", outCount);
return resultMap;
}
/**
* 得到近7天的出入库数量
*
* @return
*/
public static InOutDataDto getSevenDaysInAndOutAmount() throws ParseException {
InOutDataDto dataDto = getSixDaysAgoData();
Date currentDate = getCurrentDate(); //当前时间
//增加当天出入库记录
List<String> labelList = dataDto.getLabelList();
labelList.add(DateUtil.toDateString(currentDate, "MM/dd"));
dataDto.setLabelList(labelList);
Map<String, Integer> todayInAndOutAmount = getTodayInAndOutAmount();
Integer inValue = todayInAndOutAmount.get("in");
Integer outValue = todayInAndOutAmount.get("out");
List<Integer> putInValueList = dataDto.getPutInValueList();
putInValueList.add(inValue);
dataDto.setPutInValueList(putInValueList);
List<Integer> checkOutValueList = dataDto.getCheckOutValueList();
checkOutValueList.add(outValue);
dataDto.setCheckOutValueList(checkOutValueList);
return dataDto;
}
private static InOutDataDto getSixDaysAgoData() throws ParseException {
Date currentDate = getCurrentDate();
InOutDataDto dataDto = inOutDataManager.getSixDaysAgoData(currentDate);
if (dataDto == null) {
dataDto = new InOutDataDto();
List<String> labelList = new ArrayList<>();
List<Integer> putInValueList = new ArrayList<>();
List<Integer> checkOutValueList = new ArrayList<>();
Date startDate = DateUtil.addDays(currentDate, -6); //开始时间(与当前时间相差7天)
for (int day = 1; day < 7; day++) {
Date endDate = DateUtil.addDays(startDate, 1);
int inData = dataLogManager.getInOutData(startDate, endDate, OP.PUT_IN, "", -1, "");
int outData = dataLogManager.getInOutData(startDate, endDate, OP.CHECKOUT, "", -1, "");
labelList.add(DateUtil.toDateString(startDate, "MM/dd"));
putInValueList.add(inData);
checkOutValueList.add(outData);
startDate = endDate;
}
dataDto.setCheckOutValueList(checkOutValueList);
dataDto.setPutInValueList(putInValueList);
dataDto.setLabelList(labelList);
inOutDataManager.save(dataDto);
}
return dataDto;
}
/**
* 得到当前日期
*
* @return
*/
public static Date getCurrentDate() throws ParseException {
Date date = new Date();
//获取当天的7点时间
String currentDayStr = DateUtil.toDateString(date, "yyyy-MM-dd");
currentDayStr += " 07:00:00";
Date currentDay = DateUtil.toDate(currentDayStr, "yyyy-MM-dd HH:mm:ss");
//获取第二天时间
Date lastDay = DateUtil.addDays(currentDay, -1);
if (date.getTime() > currentDay.getTime()) {
return currentDay;
} else {
return lastDay;
}
}
/**
* 根据楼层得到线体
*
* @param floor
* @return
*/
public static List<String> getLineByFloor(String floor) {
List<String> lineList = new ArrayList<>();
//得到每一个楼层的线体
String f2Line = dataCache.getCache("F2Line").toString();
String f3Line = dataCache.getCache("F3Line").toString();
String f5Line = dataCache.getCache("F5Line").toString();
String f4Line = dataCache.getCache("F4Line").toString();
if (F2.equals(floor)) {
lineList = new ArrayList<>(Arrays.asList(f2Line.split(",")));
} else if (F3.equals(floor)) {
lineList = new ArrayList<>(Arrays.asList(f3Line.split(",")));
} else if (F5.equals(floor)) {
lineList = new ArrayList<>(Arrays.asList(f5Line.split(",")));
} else if (F4.equals(floor)) {
lineList = new ArrayList<>(Arrays.asList(f4Line.split(",")));
}
return lineList;
}
@Autowired
private void setDataLogManager(IDataLogManager dataLogManager) {
this.dataLogManager = dataLogManager;
}
@Autowired
private void setStoragePosManager(IStoragePosManager storagePosManager) {
this.storagePosManager = storagePosManager;
}
@Autowired
private void setDataCache(DataCache dataCache) {
this.dataCache = dataCache;
}
@Autowired
private void setInOutDataManager(InOutDataDtoManager manager) {
this.inOutDataManager = manager;
}
@Value("${lizhen.F2.name}")
private void setF2Floor(String floor) {
F2 = floor;
}
@Value("${lizhen.F3.name}")
private void setF3Floor(String floor) {
F3 = floor;
}
@Value("${lizhen.F5.name}")
private void setF5Floor(String floor) {
F5 = floor;
}
@Value("${lizhen.F4.name}")
private void setF4Floor(String floor) {
F4 = floor;
}
}
package com.neotel.smfcore.custom.lizhen.kanban.common.bean.dto;
import com.neotel.smfcore.common.base.BasePo;
import lombok.Data;
import lombok.Setter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
public class InOutDataDto extends BasePo {
public InOutDataDto() {
this.labelList = new ArrayList<>();
this.putInValueList = new ArrayList<>();
this.checkOutValueList = new ArrayList<>();
}
/**
* 日期
*/
private List<String> labelList;
/**
* 入库量
*/
private List<Integer> putInValueList;
/**
* 出库量
*/
private List<Integer> checkOutValueList;
/**
* 当前时间
*/
private String dateStr;
/**
* 入库量
*/
private int inValue;
/**
* 出库量
*/
private int outValue;
}
package com.neotel.smfcore.custom.lizhen.kanban.inner;
import cn.hutool.core.date.DateUnit;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
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;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.kanban.common.KanbanUtils;
import com.neotel.smfcore.custom.lizhen.kanban.common.bean.dto.InOutDataDto;
import com.neotel.smfcore.custom.lizhen.kanban.inner.bean.dto.DevicesStatusDto;
import com.neotel.smfcore.custom.lizhen.kanban.inner.bean.dto.LackPickingDto;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.*;
@RestController
@RequestMapping("/innerKanban")
public class InnerKanbanController {
@Autowired
private DataCache dataCache;
@Autowired
private ILiteOrderItemManager liteOrderItemManager;
@Autowired
private IDataLogManager dataLogManager;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private TaskService taskService;
public static final Map<String,Long> expireMap = Maps.newConcurrentMap();
/**
* 获取近7天出入库统计
* @return
*/
@RequestMapping("/getSevenDaysInAndOutAmount")
@AnonymousAccess
public ResultBean getSevenDaysInAndOutAmount() throws ParseException {
InOutDataDto dto = KanbanUtils.getSevenDaysInAndOutAmount();
return ResultBean.newOkResult(dto);
}
/**
* 获取当天出入库统计
* @return
*/
@RequestMapping("/getTodayInAndOutAmount")
@AnonymousAccess
public ResultBean getTodayInAndOutAmount() throws ParseException {
Map<String, Integer> map = KanbanUtils.getTodayInAndOutAmount();
return ResultBean.newOkResult(map);
}
/**
* 获取线体缺料预警信息
*
* @param floor 楼层
* @return
*/
@RequestMapping("/getLineInfo")
@AnonymousAccess
public ResultBean getLineLackPickingInfo(String floor) throws ParseException {
List<String> lineList = KanbanUtils.getLineByFloor(floor);
List<LackPickingDto> resultList = new ArrayList<>();
for (String line : lineList) {
LackPickingDto dto = new LackPickingDto();
dto.setLine(line);
//统计缺料数量
dto.setTotalNeedCount(getLackPickingCount(0, line));
//统计已发数量
dto.setTotalOutCount(getLackPickingCount(-1, line));
//待出数量
dto.setReadyOutCount(dto.getTotalNeedCount() - dto.getTotalOutCount());
resultList.add(dto);
}
return ResultBean.newOkResult(resultList);
}
/**
* 获取设备状态信息
*
* @return
*/
@RequestMapping("/getDevicesStatus")
@AnonymousAccess
public ResultBean getDevicesStatus() throws ParseException {
List<DevicesStatusDto> resultList = new ArrayList<>();
//开始时间与结束时间
Date currentDate = KanbanUtils.getCurrentDate();
currentDate = DateUtil.addDays(currentDate, -2);
Date endDate = DateUtil.addDays(currentDate, 1);
for (Storage storage : dataCache.getAllStorage().values()) {
//排除虚拟仓的
if (!storage.isVirtual()) {
int emptySlots = storage.getEmptySlots(); //空库位
int totalSlots = storage.getTotalSlots(); //所有库位
int useSlots = totalSlots - emptySlots; //使用库位
String name = storage.getName(); //库位名称
int usage = (int) (((double) useSlots / totalSlots) * 100); //库位使用率
//获取设备状态
int status = 0;
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean != null){
status = bean.getStatus();
}
//出入库数据
//int inCount = dataLogManager.getInOutData(currentDate, endDate, OP.PUT_IN, "", -1, storage.getId());
//int outCount = dataLogManager.getInOutData(currentDate, endDate, OP.CHECKOUT, "", -1, storage.getId());
DevicesStatusDto dto = new DevicesStatusDto();
dto.setName(name);
dto.setPosUseCount(useSlots);
dto.setPosAllCount(totalSlots);
//dto.setInCount(inCount);
//dto.setOutCount(outCount);
dto.setUsage(usage);
dto.setStatus(status);
if (storage.isNLShelf()){
dto.setType(0);
} else {
dto.setType(1);
}
resultList.add(dto);
}
}
return ResultBean.newOkResult(resultList);
}
/**
* 所有设备库位使率汇总
* @return
*/
@RequestMapping("/getAllUsage")
@AnonymousAccess
public ResultBean getAllUsage(){
int usage = 0;
int total = 0;
int use = 0;
List<Storage> resultList = new ArrayList<>();
Collection<Storage> collection = dataCache.getAllStorage().values();
for (Storage storage : collection) {
if (!storage.isVirtual()){
resultList.add(storage);
}
}
if (resultList != null && !resultList.isEmpty()){
int totalSlots = resultList.stream().mapToInt(Storage::getTotalSlots).sum();
int emptySlots = resultList.stream().mapToInt(Storage::getEmptySlots).sum();
usage = (int) (((double) (totalSlots - emptySlots) / totalSlots) * 100); //库位使用率
total = totalSlots;
use = totalSlots - emptySlots;
}
Map<String,Integer> resultMap = new HashMap<>();
resultMap.put("usage",usage);
resultMap.put("total",total);
resultMap.put("use",use);
return ResultBean.newOkResult(resultMap);
}
/**
* 过期时间信息
*
* @return
*/
@RequestMapping("/getExpireInfo")
@AnonymousAccess
public ResultBean getExpireInfo() throws ParseException {
Long lastSaveTime = expireMap.get("lastSaveTime");
if (lastSaveTime == null || System.currentTimeMillis() - lastSaveTime >= 1000 * 60 * 10) {
expireMap.put("noExpire", getNoExpireCount());
expireMap.put("zeroToServen", getZeroToServenExpireCount());
expireMap.put("servenToThirty", getServenToThrityExpireCount());
expireMap.put("expire", getExpireCount());
expireMap.put("lastSaveTime", System.currentTimeMillis());
}
return ResultBean.newOkResult(expireMap);
}
public static void main(String[] args) {
int i = (int) (((double) (99 - 88) / 99) * 100);
System.out.println(i);
}
private int getLackPickingCount(int num, String line) throws ParseException {
Query q = new Query();
Criteria c = Criteria.where("line").is(line);
if (num == 0) {
c.and("needReelCount").gt(0);
} else if (num == -1) {
c.and("outReelCount").gt(0);
}
//默认是当天时间
Date currentDate = KanbanUtils.getCurrentDate();
//currentDate = DateUtil.addDays(currentDate,-2);
c.andOperator(Criteria.where("updateDate").gte(currentDate), Criteria.where("updateDate").lt(DateUtil.addDays(currentDate, 1)));
return liteOrderItemManager.countByQuery(q.addCriteria(c));
}
private long getExpireCount() {
Query query = new Query().addCriteria(Criteria.where("barcode").exists(true).and("barcode.expireDate").lte(new Date()));
return storagePosManager.countByQuery(query);
}
private long getNoExpireCount() {
List<Criteria> orCriList = new ArrayList<>();
orCriList.add(Criteria.where("barcode").exists(true).and("barcode.expireDate").gt(new Date()));
orCriList.add(Criteria.where("barcode").exists(true).and("barcode.expireDate").exists(false));
return storagePosManager.countByQuery(new Query(new Criteria().orOperator(orCriList)));
}
private long getZeroToServenExpireCount() {
Date startDate = new Date();
Date endDate = DateUtil.addDays(startDate, 7);
Query query = new Query().addCriteria(Criteria.where("barcode").exists(true).and("barcode.expireDate").gte(startDate).lt(endDate));
return storagePosManager.countByQuery(query);
}
private long getServenToThrityExpireCount() {
Date date = new Date();
Date startDate = DateUtil.addDays(date, 7);
Date endDate = DateUtil.addDays(date, 30);
Query query = new Query().addCriteria(Criteria.where("barcode").exists(true).and("barcode.expireDate").gte(startDate).lt(endDate));
return storagePosManager.countByQuery(query);
}
}
package com.neotel.smfcore.custom.lizhen.kanban.inner.bean.dto;
import lombok.Data;
/**
* 设备状态信息
*/
@Data
public class DevicesStatusDto {
/**
* 设备名称
*/
private String name;
/**
* 库位使用率
*/
private int usage;
/**
* 入库数据
*/
private int inCount;
/**
* 出库数据
*/
private int outCount;
/**
* 设备状态
*/
private int status;
/**
* 所有库位
*/
private int posAllCount;
/**
* 已使用库位
*/
private int posUseCount;
/**
* 0是料仓 1是料架
*/
private int type;
}
package com.neotel.smfcore.custom.lizhen.kanban.inner.bean.dto;
import lombok.Data;
/**
* 缺料信息(内仓)
*/
@Data
public class LackPickingDto {
/**
* 线体信息
*/
private String line;
/**
* 需要出库的数量
*/
private int totalNeedCount;
/**
* 已经出库的数量
*/
private int totalOutCount;
/**
* 待出数量
*/
private int readyOutCount;
/**
* 上一次保存时间
*/
private Long lastTime;
}
package com.neotel.smfcore.custom.lizhen.kanban.outer;
import cn.hutool.core.date.DateUnit;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP;
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.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.kanban.common.KanbanUtils;
import com.neotel.smfcore.custom.lizhen.kanban.common.bean.dto.InOutDataDto;
import com.neotel.smfcore.custom.lizhen.kanban.outer.bean.dto.PickingProgressDto;
import com.neotel.smfcore.custom.lizhen.kanban.outer.bean.dto.StationInOutDto;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.*;
@RestController
@RequestMapping("/outer")
public class OuterKanbanController {
@Autowired
private IDataLogManager dataLogManager;
@Autowired
private DataCache dataCache;
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private TaskService taskService;
@Autowired
private IBarcodeManager barcodeManager;
public static Map<String,Long> expireMap = Maps.newConcurrentMap();
public static Long stationInOutTime = null;
public static List<StationInOutDto> dtoList = new ArrayList<>();
/**
* 获取近7天出入库统计
*
* @return
*/
@RequestMapping("/getSevenDaysInAndOutAmount")
@AnonymousAccess
public ResultBean getSevenDaysInAndOutAmount() throws ParseException {
InOutDataDto dto = KanbanUtils.getSevenDaysInAndOutAmount();
return ResultBean.newOkResult(dto);
}
/**
* 获取当天出入库统计
*
* @return
*/
@RequestMapping("/getTodayInAndOutAmount")
@AnonymousAccess
public ResultBean getTodayInAndOutAmount() throws ParseException {
Map<String, Integer> map = KanbanUtils.getTodayInAndOutAmount();
return ResultBean.newOkResult(map);
}
/**
* 获取工位的出入库统计数据
*
* @return
*/
@RequestMapping("/getStationInAndOutAmout")
@AnonymousAccess
public ResultBean getStationInAndOutAmout() throws ParseException {
if (stationInOutTime == null || System.currentTimeMillis() - stationInOutTime >= 1000 * 60 * 5) {
//先把缓存清空
dtoList.clear();
//开始统计值
Date currentDate = KanbanUtils.getCurrentDate();
Date endDate = DateUtil.addDays(currentDate, 1);
for (int i = 1; i < 6; i++) {
StationInOutDto dto = new StationInOutDto();
String stationName = "s" + i;
int inCount = dataLogManager.getInOutData(currentDate, endDate, OP.PUT_IN, stationName);
int outCount = dataLogManager.getInOutData(currentDate, endDate, OP.CHECKOUT, stationName);
dto.setName(stationName.toUpperCase(Locale.ROOT));
dto.setInCount(inCount);
dto.setOutCount(outCount);
dtoList.add(dto);
}
stationInOutTime = System.currentTimeMillis();
}
return ResultBean.newOkResult(dtoList);
}
/**
* 获取库位使用率
*/
@RequestMapping("/getPosUsage")
@AnonymousAccess
public ResultBean getPosUsage() {
Map<String, Object> resultMap = new HashMap<>();
Storage storage = null;
for (Storage stor : dataCache.getAllStorage().values()) {
if (!stor.isVirtual()) {
storage = stor;
break;
}
}
int totalSlots = storage.getTotalSlots(); //全部库位
int emptySlots = storage.getEmptySlots(); //空库位
int usage = (int) (((double) (totalSlots - emptySlots) / totalSlots) * 100); //库位使用率
resultMap.put("usage", usage);
resultMap.put("noUsage", 100 - usage);
resultMap.put("use", (totalSlots - emptySlots));
resultMap.put("noUse", emptySlots);
return ResultBean.newOkResult(resultMap);
}
/**
* 获取picking进度信息
*/
@RequestMapping("/getPickingProgress")
@AnonymousAccess
public ResultBean getPickingProgress() {
LiteOrder liteOrder = new LiteOrder();
Collection<LiteOrder> liteOrders = liteOrderCache.getAllLiteOrder();
for (LiteOrder order : liteOrders) {
if (order.isOutTails()) {
liteOrder = order;
break;
}
}
PickingProgressDto dto = new PickingProgressDto();
if (liteOrder != null) {
dto.setPickingId(liteOrder.getOrderNo());
int progress = (int) (((double) (/*liteOrder.getTaskReelCount() -*/ liteOrder.getFinishedReelCount()) / liteOrder.getTaskReelCount()) * 100); //库位使用率
dto.setProgress(progress);
dto.setOut(liteOrder.getFinishedReelCount());
dto.setTotal(liteOrder.getTaskReelCount());
}
return ResultBean.newOkResult(dto);
}
/**
* 获取出入库记录
*/
@RequestMapping("/getQueueTask")
@AnonymousAccess
public ResultBean getQueueTask() {
List<DataLog> dataLogList = new ArrayList<>();
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
if (!queueTask.isWait()) {
dataLogList.add(queueTask);
}
}
return ResultBean.newOkResult(dataLogList);
}
/**
* 过期时间信息
*
* @return
*/
@RequestMapping("/getExpireInfo")
@AnonymousAccess
public ResultBean getExpireInfo() throws ParseException {
Long lastSaveTime = expireMap.get("lastSaveTime");
if (lastSaveTime == null || System.currentTimeMillis() - lastSaveTime >= 1000 * 60 * 10) {
expireMap.put("noExpire", getNoExpireCount());
expireMap.put("zeroToServen", getZeroToServenExpireCount());
expireMap.put("servenToThirty", getServenToThrityExpireCount());
expireMap.put("expire", getExpireCount());
expireMap.put("lastSaveTime", System.currentTimeMillis());
}
return ResultBean.newOkResult(expireMap);
}
private long getExpireCount() {
Query query = new Query().addCriteria(Criteria.where("posName").exists(true).ne("").and("expireDate").lt(new Date()));
return barcodeManager.countByQuery(query);
}
private long getNoExpireCount() {
List<Criteria> orCriList = new ArrayList<>();
orCriList.add(Criteria.where("expireDate").gt(new Date()).and("posName").exists(true).ne("").and("partNumber").nin(Arrays.asList("CS", "CM", "CB")));
orCriList.add(Criteria.where("expireDate").exists(false).and("posName").exists(true).ne("").and("partNumber").nin(Arrays.asList("CS", "CM", "CB")));
return barcodeManager.countByQuery(new Query(new Criteria().orOperator(orCriList)));
}
private long getZeroToServenExpireCount() {
Date startDate = new Date();
Date endDate = DateUtil.addDays(startDate, 7);
Query query = new Query().addCriteria(Criteria.where("posName").exists(true).ne("").and("expireDate").gte(startDate).lt(endDate));
return barcodeManager.countByQuery(query);
}
private long getServenToThrityExpireCount() {
Date date = new Date();
Date startDate = DateUtil.addDays(date, 7);
Date endDate = DateUtil.addDays(date, 30);
Query query = new Query().addCriteria(Criteria.where("posName").exists(true).ne("").and("expireDate").gte(startDate).lt(endDate));
return barcodeManager.countByQuery(query);
}
}
package com.neotel.smfcore.custom.lizhen.kanban.outer.bean.dto;
import lombok.Data;
@Data
public class PickingProgressDto {
/**
* pickingId
*/
private String pickingId = "";
/**
* 进度
*/
private int progress;
private int out;
private int total;
}
package com.neotel.smfcore.custom.lizhen.kanban.outer.bean.dto;
import lombok.Data;
/**
* 工位出入库数据
*/
@Data
public class StationInOutDto {
/**
* 工位名称
*/
private String name;
/**
* 入库数量
*/
private int inCount;
/**
* 出库数量
*/
private int outCount;
/**
* 状态
*/
private String status = "正常";
}
package com.neotel.smfcore.custom.lizhen.kanban.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
import com.neotel.smfcore.custom.lizhen.kanban.common.bean.dto.InOutDataDto;
import java.util.Date;
public interface InOutDataDtoDao extends IBaseDao {
}
package com.neotel.smfcore.custom.lizhen.kanban.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.WareHouseCode;
import com.neotel.smfcore.custom.lizhen.agvBox.service.dao.WareHouseCodeDao;
import com.neotel.smfcore.custom.lizhen.kanban.common.bean.dto.InOutDataDto;
import com.neotel.smfcore.custom.lizhen.kanban.service.dao.InOutDataDtoDao;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class InOutDataDtoImpl extends AbstractBaseDao implements InOutDataDtoDao {
@Override
public Class getEntityClass() {
return InOutDataDto.class;
}
}
package com.neotel.smfcore.custom.lizhen.kanban.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.WareHouseCode;
import com.neotel.smfcore.custom.lizhen.kanban.common.bean.dto.InOutDataDto;
import java.util.Date;
import java.util.List;
public interface InOutDataDtoManager extends IBaseManager<InOutDataDto> {
InOutDataDto getSixDaysAgoData(Date currentDate);
}
package com.neotel.smfcore.custom.lizhen.kanban.service.manager.impl;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.custom.lizhen.kanban.common.bean.dto.InOutDataDto;
import com.neotel.smfcore.custom.lizhen.kanban.service.dao.InOutDataDtoDao;
import com.neotel.smfcore.custom.lizhen.kanban.service.manager.InOutDataDtoManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class InOutDataDtoManagerImpl implements InOutDataDtoManager {
@Autowired
private InOutDataDtoDao inOutDataDtoDao;
@Override
public InOutDataDto get(String id) {
return null;
}
@Override
public InOutDataDto save(InOutDataDto object) throws ValidateException {
return inOutDataDtoDao.save(object);
}
@Override
public void delete(InOutDataDto object) throws ValidateException {
}
@Override
public PageData<InOutDataDto> findByPage(Query query, Pageable pageable) {
return null;
}
@Override
public List<InOutDataDto> findByQuery(Query query) {
return null;
}
@Override
public InOutDataDto getSixDaysAgoData(Date currentDate) {
Query query = Query.query(Criteria.where("createDate").gte(currentDate));
return inOutDataDtoDao.findOne(query);
}
}
package com.neotel.smfcore.custom.lizhen.kanban.utils;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.custom.lizhen.kanban.common.KanbanUtils;
import com.neotel.smfcore.custom.lizhen.kanban.utils.bean.AgvInfo;
import com.neotel.smfcore.custom.lizhen.kanban.utils.enums.Location;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import org.springframework.beans.factory.annotation.Value;
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.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* agv小车状态信息缓存
*/
@RestController
public class AgvStatusCache {
@Value("${lizhen.F2.name}")
private String F2;
@Value("${lizhen.F3.name}")
private String F3;
@Value("${lizhen.F5.name}")
private String F5;
private static List<AgvInfo> agvInfoCacheList = new CopyOnWriteArrayList<>();
/**
* agv状态信息上报
*
* @param infoList
* @return
*/
@RequestMapping("/service/store/agvStatus/agvInfo")
@AnonymousAccess
public ResultBean agvInfo(@RequestBody List<AgvInfo> infoList) {
AgvInfo agvInfo = infoList.get(0);
boolean hasAgvInfo = false;
if (agvInfoCacheList != null && !agvInfoCacheList.isEmpty()) {
for (int i = 0; i < agvInfoCacheList.size(); i++) {
AgvInfo info = agvInfoCacheList.get(i);
if (info.getName().equals(agvInfo.getName())) {
agvInfoCacheList.remove(i);
agvInfoCacheList.add(i,agvInfo);
hasAgvInfo = true;
}
}
} else {
agvInfoCacheList = infoList;
hasAgvInfo = true;
}
if (!hasAgvInfo){
agvInfoCacheList.addAll(infoList);
}
return ResultBean.newOkResult(null);
}
/**
* 获取agv状态信息
*
* @param floor
* @return
*/
@RequestMapping("/agvStatus/getAgvInfoBySource")
@AnonymousAccess
public ResultBean getAgvInfoBySource(String floor) {
List<String> locList = new ArrayList<>();
List<String> locCnList = new ArrayList<>();
if (F2.equals(floor) || F3.equals(floor) || F5.equals(floor)) {
locList = KanbanUtils.getLineByFloor(floor);
locList.addAll(getLocByType(0));
locCnList = KanbanUtils.getLineByFloor(floor);
locCnList.addAll(getLocCnByType(0));
} else {
locList.addAll(getLocByType(2));
locCnList.addAll(getLocCnByType(2));
}
for (AgvInfo agvInfo : agvInfoCacheList) {
String loc = agvInfo.getLoc();
if (StringUtils.isNotBlank(Location.getLoc(loc))) {
agvInfo.setLocCn(Location.getLoc(loc));
} else {
agvInfo.setLocCn(agvInfo.getLoc());
}
agvInfo.setLocList(locList);
agvInfo.setLocCnList(locCnList);
}
return ResultBean.newOkResult(agvInfoCacheList);
}
private List<String> getLocByType(int type) {
List<String> locList = new ArrayList<>();
for (Location loc : Location.values()) {
int locType = Location.getType(loc.name());
if (locType == 0 || locType == type) {
locList.add(loc.name());
}
}
return locList;
}
private List<String> getLocCnByType(int type) {
List<String> locList = new ArrayList<>();
for (Location loc : Location.values()) {
int locType = Location.getType(loc.name());
if (locType == 0 || locType == type) {
locList.add(Location.getLoc(loc.name()));
}
}
return locList;
}
}
package com.neotel.smfcore.custom.lizhen.kanban.utils.bean;
import lombok.Data;
import java.util.List;
@Data
public class AgvInfo {
/**
* 小车名称
*/
private String name;
/**
* 小车电量
*/
private String elec;
/**
* 小车位置
*/
private String loc;
/**
* 小车位置 中文
*/
private String locCn;
/**
* 位置集合
*/
private List<String> locList;
/**
* 位置集合 中文
*/
private List<String> locCnList;
int type = 0;
}
package com.neotel.smfcore.custom.lizhen.kanban.utils.enums;
/**
* 点位 AGV
*/
public enum Location {
//外仓点位
WAREHOUSE("仓库", 2),
PUT("放料点", 2),
//内外仓,通用点位
STANDBY("待机点", 0),
CHARGE("充电点", 0),
TAKE("取料点", 0);
private String loc;
private int type;
Location(String loc, int type) {
this.loc = loc;
this.type = type;
}
/**
* 根据名称获取位置
*
* @param name
* @return
*/
public static String getLoc(String name) {
for (Location location : Location.values()) {
if (location.name().equals(name)) {
return location.loc;
}
}
return null;
}
/**
* 根据名称获取类别
*
* @param name
* @return
*/
public static int getType(String name) {
for (Location location : Location.values()) {
if (location.name().equals(name)) {
return location.type;
}
}
return -1;
}
}
package com.neotel.smfcore.custom.lizhen.report.bacheng.bean.dto;
import lombok.Data;
import java.util.Date;
/**
* 异动报表
*/
@Data
public class BCChange {
//厂别
private String plant;
//厂区
private String factory;
//库别
private String warehouseCode;
//料号
private String partNumber;
//物料描述
private String describe;
//异动数量
private int num;
//卷数
private int reelAmount;
//储位
private String posName;
//异动类型
private String type;
//ID NO
private String barcode;
//LOT
private String batch;
//D/C
private String dateCode;
//厂商
private String provider;
//厂商代码
private String providerNumber;
//Keeper
private String keeperCode;
//事务日期
private Date createDate;
//工号
private String creator;
}
package com.neotel.smfcore.custom.lizhen.report.bacheng.bean.dto;
import lombok.Data;
import java.util.Date;
@Data
public class BCExpire {
/**
* 厂别
*/
private String plant;
/**
* 厂区
*/
private String factory;
/**
* 料号
*/
private String partNumber;
/**
* 描述
*/
private String describe;
/**
* ID NO
*/
private String barcode;
/**
* 储位
*/
private String posName;
/**
* 数量
*/
private int amount;
/**
* 卷数
*/
private int reelAmount = 1;
/**
* 厂商
*/
private String provider;
/**
* lot
*/
private String batch = "";
/**
* d/c
*/
private String dateCode;
/**
* keeper
*/
private String keeperCode;
/**
* 物料保质期(年)
*/
private int expireYear = 1;
/**
* 过期天数
*/
private long expireDays;
/**
* 过期时间
*/
private Date expireDate;
/**
* 备注
*/
private String remark;
/**
* 库别
*/
private String warehouseCode;
}
package com.neotel.smfcore.custom.lizhen.report.bacheng.bean.dto;
import lombok.Data;
import java.util.Date;
@Data
public class BCInventory {
/**
* 厂别
*/
private String plant;
/**
* 厂区
*/
private String factory;
/**
* 库别
*/
private String warehouseCode;
/**
* 料号
*/
private String partNumber;
/**
* 描述
*/
private String describe;
/**
* ID NO
*/
private String barcode;
/**
* 储位
*/
private String posName;
/**
* 数量
*/
private int amount;
/**
* 卷数
*/
private int reelAmount = 1;
/**
* 厂商
*/
private String provider;
/**
* lot
*/
private String batch="";
/**
* d/c
*/
private String dateCode;
/**
* keeper
*/
private String keeperCode;
/**
* 禁用信息
*/
private String disableMsg;
/**
* 入库时间
*/
private Date putInDate;
/**
* 工号
*/
private String creator;
}
package com.neotel.smfcore.custom.lizhen.report.bacheng.bean.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 BcQuery {
@QueryCondition(blurry = "barcode.partNumber,partNumber")
private String pn;
@QueryCondition(blurry = "barcode.partNumber")
private String partNumber;
@QueryCondition(blurry = "barcode.provider")
private String provider;
@QueryCondition(blurry = "barcode.warehouseCode,warehouseCode")
private String warehouseCode;
@QueryCondition(blurry = "posName")
private String posName;
@QueryCondition(blurry = "barcode.barcode,barcode")
private String barcode;
@QueryCondition(blurry = "barcode.dateCode")
private String dateCode;
@QueryCondition(blurry = "barcode.batch")
private String batch;
@QueryCondition(blurry = "barcode.keeperCode")
private String keeperCode;
@QueryCondition(propName = "extendType",type = QueryCondition.Type.EQ)
private Integer extendType;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "updateDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> updateDate;
}
package com.neotel.smfcore.custom.lizhen.report.bean.dto;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import lombok.Data;
import java.util.Date;
@Data
public class ExpireDto extends Barcode {
/**
* 过期天数
*/
private long expireDays;
/**
* 厂别
*/
private String plant;
/**
* 厂区
*/
private String factory;
/**
* 楼层
*/
private String floor;
/**
* 首次入库时间
*/
private Date firstPutInDate;
/**
* 来源
*/
private String source;
/**
* 隔口数量
*/
private Integer partitionCount;
/**
* 备注
*/
private String remark;
}
package com.neotel.smfcore.custom.lizhen.report.bean.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
/**
* 外仓库存报表展示
*/
@Getter
@Setter
public class InventoryDto {
/**
* 厂别
*/
private String plant;
/**
* 厂区
*/
private String factory;
/**
* 库别
*/
private String warehouseCode;
/**
* 楼层
*/
private String floor = "1F";
/**
* 料号
*/
private String partNumber;
/**
* 物料隔扣码
*/
private String posName;
/**
* 隔口数量
*/
private long posNameCount;
/**
* 卷数
*/
private int reelCount = 1;
/**
* 厂商
*/
private String provider;
/**
* 厂商代码
*/
private String providerNumber;
/**
* lot
*/
private String batch;
/**
* D/C
*/
private String dateCode;
/**
* keeper
*/
private String keeperCode;
/**
* 储位
*/
private String storagePosName;
/**
* 禁用信息
*/
private String disableMsg;
/**
* 首次入库时间
*/
private Date firstPutInDate;
/**
* 当前入库时间
*/
private Date putInDate;
/**
* 姓名
*/
private String creator;
/**
* 唯一码
*/
private String barcode;
/**
* 每卷数量
*/
private int amount;
/**
* 来源
*/
private String source;
}
package com.neotel.smfcore.custom.lizhen.report.bean.dto;
import lombok.Data;
@Data
public class MergeInventoryDto extends InventoryDto{
}
package com.neotel.smfcore.custom.lizhen.report.bean.query;
import com.neotel.smfcore.common.annotation.QueryCondition;
import com.neotel.smfcore.common.bean.BetweenData;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
@Data
@ApiModel("查询条件")
public class ReportQueryCondition {
@QueryCondition(blurry = "pn,partNumber,barcode.partNumber")
@ApiModelProperty("料号")
private String pn;
@QueryCondition(blurry = "pn,partNumber,barcode.partNumber")
@ApiModelProperty("料号")
private String partNumber;
@QueryCondition(blurry = "orderNo,sourceName")
@ApiModelProperty("挑料单号")
private String orderNo;
@QueryCondition(type = QueryCondition.Type.IN, propName = "orderNo")
@ApiModelProperty("挑料单号集合")
private List<String> orderNoList;
@QueryCondition(propName = "mo")
@ApiModelProperty("工单号")
private String mo;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "updateDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> updateDate;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "updateDate")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
private BetweenData<Date> updateDateHHmm;
@QueryCondition
@ApiModelProperty("厂别")
private String plantCode;
@QueryCondition
@ApiModelProperty("库别")
private String warehouse;
@ApiModelProperty("唯一码")
@QueryCondition(blurry = "barcode.barcode,barcode")
private String barcode;
@QueryCondition(blurry = "posName")
@ApiModelProperty("库位")
private String posName;
@QueryCondition(blurry = "batch")
@ApiModelProperty("批次")
private String batch;
@ApiModelProperty("线别")
@QueryCondition(propName = "line")
private String line;
@ApiModelProperty("厂商")
@QueryCondition(blurry = "barcode.provider,provider")
private String provider;
@ApiModelProperty("日期代码")
@QueryCondition(blurry = "dateCode")
private String dateCode;
@ApiModelProperty("料仓id")
@QueryCondition(type = QueryCondition.Type.IN, propName = "storageId")
private List<String> storageIdList;
@ApiModelProperty("库别")
@QueryCondition(blurry = "warehouseCode")
private String warehouseCode;
@ApiModelProperty("储位")
@QueryCondition(blurry = "posName")
private String storagePosName;
@ApiModelProperty("隔口")
@QueryCondition(blurry = "boxPartition")
private String boxPartition;
@ApiModelProperty("是否匹配")
@QueryCondition(type = QueryCondition.Type.EQ, propName = "isMatch")
private Boolean match;
@ApiModelProperty("状态")
@QueryCondition(blurry = "status")
private String status;
@ApiModelProperty("盘点批次")
@QueryCondition(blurry = "inventoryBatch")
private String inventoryBatch;
//楼层
private String floor;
//过期状态
private String expireStatus;
private int page;
private int size;
private String sort;
}
package com.neotel.smfcore.custom.lizhen.report.merge.bean.query;
import com.neotel.smfcore.custom.lizhen.report.bacheng.bean.query.BcQuery;
import lombok.Data;
@Data
public class MergeBcQuery extends BcQuery {
private int page;
private int size;
private String sort;
}
package com.neotel.smfcore.custom.lizhen.report.merge.utils;
import com.neotel.smfcore.core.device.util.DataCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 楼层工具类
*/
@Service
public class FloorUtils {
@Autowired
private DataCache dataCache;
@Value("${forward.f2.name}")
private String forwardF2Name;
@Value("${forward.f2.url}")
private String forwardF2Url;
@Value("${forward.f3.name}")
private String forwardF3Name;
@Value("${forward.f3.url}")
private String forwardF3Url;
@Value("${forward.f5.name}")
private String forwardF5Name;
@Value("${forward.f5.url}")
private String forwardF5Url;
@Value("${forward.b15.name}")
private String forwardB15Name;
@Value("${forward.b15.url}")
private String forwardB15Url;
@PostConstruct
public void init() {
forwardF2Name = dataCache.getConfigCache("forward.f2.name", forwardF2Name);
forwardF2Url = dataCache.getConfigCache("forward.f2.url", forwardF2Url);
forwardF3Name = dataCache.getConfigCache("forward.f3.name", forwardF3Name);
forwardF3Url = dataCache.getConfigCache("forward.f3.url", forwardF3Url);
forwardF5Name = dataCache.getConfigCache("forward.f5.name", forwardF5Name);
forwardF5Url = dataCache.getConfigCache("forward.f5.url", forwardF5Url);
forwardB15Name = dataCache.getConfigCache("forward.b15.name", forwardB15Name);
forwardB15Url = dataCache.getConfigCache("forward.b15.url", forwardB15Url);
}
public Map<String, String> getAllFloor(int type) {
Map<String, String> resultMap = new LinkedHashMap<>();
if (type == 0) {
resultMap.put(forwardF2Name, forwardF2Name);
resultMap.put(forwardF3Name, forwardF3Name);
resultMap.put(forwardF5Name, forwardF5Name);
resultMap.put(forwardB15Name, forwardB15Name);
} else if (type == 1){
resultMap.put(forwardF2Name, forwardF2Name);
resultMap.put(forwardF3Name, forwardF3Name);
resultMap.put(forwardF5Name, forwardF5Name);
} else if (type == 2){
resultMap.put(forwardB15Name, forwardB15Name);
}
return resultMap;
}
public String getUrlByFloor(String floor) {
String url = "";
if (forwardF2Name.equals(floor)) {
url = forwardF2Url;
} else if (forwardF3Name.equals(floor)) {
url = forwardF3Url;
} else if (forwardF5Name.equals(floor)) {
url = forwardF5Url;
} else if (forwardB15Name.equals(floor)) {
url = forwardB15Url;
}
return url;
}
public boolean isB15(String floor){
return floor.equals(forwardB15Name);
}
}
......@@ -31,7 +31,7 @@ public class StationStatusCache {
private static Map<String, String> stationStatusMap = Maps.newConcurrentMap();
@PostConstruct
/*@PostConstruct
public void init() {
try {
List<StationStatus> statusList = maiZhengApi.StationStatus();
......@@ -50,7 +50,7 @@ public class StationStatusCache {
} catch (Exception e) {
e.printStackTrace();
}
}
}*/
public void updateStatusList(List<StationStatus> statusList) {
stationStatusMap.clear();
......
api:
plantCode: W339
name: Lizhen
inCheckUrl: http://10.190.25.124:8001/Npm/WmsCheckReelfob #禁用料接口
outNotifyUrl: http://10.68.30.22:8082/api/mlb/TowerIssue
inNotifyUrl: http://10.68.30.22:8082/api/mlb/BackToWarehouse
\ No newline at end of file
api:
plantCode: W339
name: Lizhen
inCheckUrl: http://10.190.25.124:8001/Npm/WmsCheckReelfob #禁用料接口
outNotifyUrl: http://10.42.220.171:8082/api/mlb/TowerIssue
inNotifyUrl: http://10.42.220.171:8082/api/mlb/BackToWarehouse
\ No newline at end of file
......@@ -3,45 +3,45 @@ server:
api:
name: Lizhen
inCheckUrl: #http://10.190.25.124:8001/Npm/WmsCheckReelfob #禁用料
batchCheckUrl: #http://172.30.60.117:8001/Npm/WmsCheckReelfob_Batch #批量禁用料
outNotifyUrl: #http://172.30.170.148:8082/SmtAutoWH/Save2DReelInfo #保存物料(外仓配置)
outNotifyUrlPK: #http://172.30.170.148:8001/Sct/SaveReelInfo #PK发料保存(外仓配置)
inNotifyUrl: #http://10.190.25.124:8082/SmtAutoWH/Save2DReelInfo #保存物料(内仓配置)
fetchOrderUrl: #http://172.30.170.148:8082/SmtAutoWH/GetWoPickingList #获取工单
barcodeInfoUrl: #http://10.190.25.124:8001/Sct/GetReelInfo #mes数量
fetchGRUrl: #http://10.42.25.199:8082/api/wcs/fetchGR #gr标签
brandQtyUrl: #http://172.30.170.199:8082/api/wcs/brandQty #gr标签满卷数
importUrl: #http://10.42.222.52:8001/smf-core/ext/forward/getDataLogs #内仓导入外仓picking虚拟仓数据
checkReelMeasure: #http://10.190.25.124:8001/Sct/CheckReelMeasure #散料量测接口
plant: 2810
werks: 2810
inCheckUrl:
batchCheckUrl:
outNotifyUrl:
outNotifyUrlPK:
inNotifyUrl:
fetchOrderUrl:
barcodeInfoUrl:
fetchGRUrl:
brandQtyUrl:
importUrl:
checkReelMeasure:
plant:
werks:
outerFactory:
bc:
plant: 2810
factory: B3
plant:
factory:
#缺料预警对应的地址
lizhen:
F2:
name: 2F
line: A05-2FSMT-16S,A05-2FSMT-17S,A05-2FSMT-06S,A05-2FSMT-07S
url: http://172.30.88.19:8001/smf-core/api/Mes/machineCallMaterial
name:
line:
url:
F3:
name: 3F
line: A05-3FSMT-04S,A05-3FSMT-14S,A05-3FSMT-15S,A05-3FSMT-05S
url: http://172.30.97.99:8001/smf-core/api/Mes/machineCallMaterial
line:
url: http://10.68.27.85/smf-core/wcs/ReelWarningInfo
F5:
name: 5F
line: A05-5FSMT-13S,A05-5FSMT-03S,A05-5FSMT-02S,A05-5FSMT-12S #,A05-5FARF-06,A05-5FSMT-01S,A05-5FSMT-11S
url: http://172.30.97.63:8001/smf-core/api/Mes/machineCallMaterial
name:
line:
url:
F4:
name: 4F
line: B03-4FSMT-11,B03-4FSMT-01,B03-4FSMT-13,B03-4FSMT-03,B03-4FSMT-14,B03-4FSMT-04
url: http://172.25.252.12:8001/smf-core/api/Mes/machineCallMaterial
name:
line:
url:
#转发地址
......@@ -80,6 +80,7 @@ spring:
check-template-location: false
profiles:
active: 'prod'
include: 21088test
jackson:
time-zone: GMT+8
data:
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!