Commit 372e7979 zshaohui

1.增加物料基础数据维护和线体维护数据

1 个父辈 2d0ee41f
......@@ -265,6 +265,9 @@ public class DataInitManager {
// Menu orderSet = new Menu(, "orderSetting", "工单设置", "orderSetting", "system/orderSetting/index", "sysSet");
addNewFunctionMenu(106,poutSet, "shelfSetting", "料架设置", "shelfSetting", "system/shelfSetting/index", "translation",functionMenuMap);
addNewFunctionMenu(107,poutSet, "warehouseMaintenance", "库别维护", "warehouseMaintenance", "system/warehouseMaintenance/index", "translation",functionMenuMap);
addNewFunctionMenu(108,poutSet, "partMasterData", "料号基础数据", "partMasterData", "system/partMasterData/index", "partMasterData",functionMenuMap);
addNewFunctionMenu(109,poutSet, "wireQtyMaint", "开线数量维护", "wireQtyMaint", "system/wireQtyMaint/index", "wireQtyMaint",functionMenuMap);
//addNewFunctionMenu(107,poutSet, "warehouseMaintenance", "库别维护", "warehouseMaintenance", "system/warehouseMaintenance/index", "translation",functionMenuMap);
//内外仓都有
addNewFunctionMenu(108,poutSet,"expiredMaintenance","过期维护","expiredMaintenance","system/expiredMaintenance/index","translation",functionMenuMap);
......
package com.neotel.smfcore.common.utils;
public class Constants {
private Constants() {
// hide me
}
......@@ -198,4 +200,8 @@ public class Constants {
public static final String CACHE_printSeq = "CACHE_printSeq";
public static final String Cache_reelConsumption = "Cache_reelConsumption";
public static final String CACHE_wireQtyMaint = "CACHE_wireQtyMaint";
}
package com.neotel.smfcore.custom.lizhen.innerBox.bean;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
@Data
public class ReelConsumption {
private String partNumber;
private String replacementPartNumber;
private String warehouseCode;
private Map<String,ReelConsumptionInventory> inventoryMap = new HashMap<>();
}
package com.neotel.smfcore.custom.lizhen.innerBox.bean;
import lombok.Data;
@Data
public class ReelConsumptionInventory {
private int min;
private int max;
}
package com.neotel.smfcore.custom.lizhen.innerBox.rest;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.ReelConsumption;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.ReelConsumptionInventory;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.bean.FileProperties;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.yaml.snakeyaml.scanner.Constant;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@Api(tags = "物料基础数据维护")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/reelConsumption")
public class ReelConsumptionController {
@Autowired
private final FileProperties properties;
@Autowired
private DataCache dataCache;
//下载模板
@ApiOperation("下载模板")
@RequestMapping("/download")
@AnonymousAccess
public void download(HttpServletResponse response) throws IOException {
List<List<String>> headerList = new ArrayList<>();
headerList.add(Arrays.asList("料号"));
headerList.add(Arrays.asList("替代料"));
headerList.add(Arrays.asList("库别"));
headerList.add(Arrays.asList("Everst1340最小库存"));
headerList.add(Arrays.asList("Everst1340最大库存"));
headerList.add(Arrays.asList("Everst770最小库存"));
headerList.add(Arrays.asList("Everst770最大库存"));
headerList.add(Arrays.asList("X81340最小库存"));
headerList.add(Arrays.asList("X81340最大库存"));
headerList.add(Arrays.asList("X8770最小库存"));
headerList.add(Arrays.asList("X8770最大库存"));
headerList.add(Arrays.asList("OPAL最小库存"));
headerList.add(Arrays.asList("OPAL最大库存"));
List<List<Object>> datas = new ArrayList<>();
for (int i = 0; i < 10; i++) {
List<Object> dataList = new ArrayList<>();
dataList.add("料号"+i);
dataList.add("替代料"+i);
dataList.add("库别"+i);
dataList.add(i);
dataList.add(i+10);
dataList.add(i);
dataList.add(i+10);
dataList.add(i);
dataList.add(i+10);
dataList.add(i);
dataList.add(i+10);
dataList.add(i);
dataList.add(i+10);
datas.add(dataList);
}
FileUtil.downloadExcel(headerList, datas, response);
}
@ApiOperation("上传模板信息")
@PostMapping(value = "/upload")
@AnonymousAccess
public ResultBean upload(@RequestParam MultipartFile uploadFile) throws Exception {
// 验证文件上传的格式
String image = "xlsx";
String fileType = FileUtil.getExtensionName(uploadFile.getOriginalFilename());
if (fileType != null && !image.contains(fileType)) {
throw new ValidateException("smfcore.feleFormatError", "文件格式错误!, 仅支持{0}格式", new String[]{image});
}
File folder = new File(properties.getPath(), "reelCons");
File file = FileUtil.upload(uploadFile, folder.getAbsolutePath());
//开始解析表格
FileInputStream fis = new FileInputStream(file.getAbsolutePath());
Workbook workbook = new XSSFWorkbook(fis);
Sheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(0);
List<String> headerList = new ArrayList<>();
Map<String, Integer> headerMap = new HashMap<>();
for (Cell cell : row) {
String header = cell.getStringCellValue();
headerMap.put(header, cell.getColumnIndex());
if (header.endsWith("最大库存") || header.endsWith("最小库存")) {
header = header.replaceAll("最大库存", "");
header = header.replaceAll("最小库存", "");
}
headerList.add(header);
}
headerList = headerList.stream().distinct().collect(Collectors.toList());
List<ReelConsumption> resultList = new ArrayList<>();
//开始处理具体表格数据
for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
Row dataRaw = sheet.getRow(rowIndex);
ReelConsumption reelConsumption = new ReelConsumption();
for (String header : headerList) {
if ("料号".equals(header)) {
Integer index = headerMap.get(header);
if (index == null || index == -1) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"料号"});
}
Cell cell = dataRaw.getCell(index);
String value = cell.getStringCellValue();
if (StringUtils.isEmpty(value)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"料号"});
}
reelConsumption.setPartNumber(value);
} else if ("替代料".equals(header)) {
Integer index = headerMap.get(header);
if (index == null || index == -1) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"替代料"});
}
Cell cell = dataRaw.getCell(index);
String value = cell.getStringCellValue();
if (StringUtils.isEmpty(value)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"替代料"});
}
reelConsumption.setReplacementPartNumber(value);
} else if ("库别".equals(header)) {
Integer index = headerMap.get(header);
if (index == null || index == -1) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"库别"});
}
Cell cell = dataRaw.getCell(index);
String value = cell.getStringCellValue();
if (StringUtils.isEmpty(value)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"库别"});
}
reelConsumption.setWarehouseCode(value);
} else {
String maxInventory = header + "最大库存";
Integer maxIndex = headerMap.get(maxInventory);
if (maxIndex == null || maxIndex == -1) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{maxInventory});
}
Cell maxCell = dataRaw.getCell(maxIndex);
double maxValue = maxCell.getNumericCellValue();
String minInventory = header + "最小库存";
Integer minIndex = headerMap.get(minInventory);
if (minIndex == null || minIndex == -1) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{minInventory});
}
Cell cell = dataRaw.getCell(minIndex);
double minValue = cell.getNumericCellValue();
ReelConsumptionInventory inventory = new ReelConsumptionInventory();
inventory.setMax((int) maxValue);
inventory.setMin((int) minValue);
Map<String, ReelConsumptionInventory> inventoryMap = reelConsumption.getInventoryMap();
inventoryMap.put(header, inventory);
reelConsumption.setInventoryMap(inventoryMap);
}
}
resultList.add(reelConsumption);
}
log.info(JSON.toJSONString(resultList));
Map<String,ReelConsumption> cacheMap = dataCache.getCache(Constants.Cache_reelConsumption);
if (cacheMap == null){
cacheMap = new HashMap<>();
}
for (ReelConsumption consumption : resultList) {
cacheMap.put(consumption.getPartNumber(),consumption);
}
dataCache.updateCache(Constants.Cache_reelConsumption, cacheMap);
return ResultBean.newOkResult("");
}
@ApiOperation("获取列表信息")
@RequestMapping(value = "/list")
@AnonymousAccess
public ResultBean list() {
Map<String,ReelConsumption> cacheMap = dataCache.getCache(Constants.Cache_reelConsumption);
if (cacheMap == null){
cacheMap = new HashMap<>();
}
return ResultBean.newOkResult(cacheMap.values());
}
}
package com.neotel.smfcore.custom.lizhen.innerBox.rest;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.ReelConsumption;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@Api(tags = "开线数量维护")
@Slf4j
@RestController
@RequestMapping("/wireQtyMaint")
public class WireQtyMaintController {
@Autowired
private DataCache dataCache;
@ApiOperation("获取线体信息")
@RequestMapping(value = "/detail")
@AnonymousAccess
public ResultBean detail() {
Map<String, Integer> cacheMap = dataCache.getCache(Constants.CACHE_wireQtyMaint);
if (cacheMap == null) {
cacheMap = new HashMap<>();
}
Map<String, ReelConsumption> reelConsumptionMap = dataCache.getCache(Constants.Cache_reelConsumption);
if (reelConsumptionMap == null) {
reelConsumptionMap = new HashMap<>();
}
if (reelConsumptionMap.size() > 0) {
for (ReelConsumption reelConsumption : reelConsumptionMap.values()) {
for (String key : reelConsumption.getInventoryMap().keySet()) {
Integer integer = cacheMap.get(key);
if (integer == null) {
integer = 0;
cacheMap.put(key, integer);
}
}
}
}
dataCache.updateCache(Constants.CACHE_wireQtyMaint, cacheMap);
return ResultBean.newOkResult(cacheMap);
}
@ApiOperation("修改线体信息")
@RequestMapping(value = "/update")
@AnonymousAccess
public ResultBean update(@RequestBody Map<String, Integer> paramMap) {
Map<String, Integer> cacheMap = dataCache.getCache(Constants.CACHE_wireQtyMaint);
if (cacheMap == null) {
cacheMap = new HashMap<>();
}
for (String key : paramMap.keySet()) {
cacheMap.put(key,paramMap.get(key));
}
dataCache.updateCache(Constants.CACHE_wireQtyMaint, cacheMap);
return ResultBean.newOkResult("");
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!