Commit 390524a4 sunke

1 异常消息类型展示BUG

2 转储出库详情数据导出
3 出入库日志数据导出
4 Http请求超时时间改为10秒
1 个父辈 e72e0052
......@@ -217,6 +217,14 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
return null;
}
/**
* 分页导出Excel
* @param query
* @param pageable
* @param response
* @param excelDownLoad
* @throws IOException
*/
public static void downloadExcel(Query query, Pageable pageable, HttpServletResponse response, IExcelDownLoad excelDownLoad) throws IOException {
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
......@@ -229,7 +237,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
// 这里 需要指定写用哪个class去写
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).head(excelDownLoad.getHeader()).build()) {
// 这里注意 如果同一个sheet只要创建一次
WriteSheet writeSheet = EasyExcel.writerSheet("模板").build();
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").build();
// 去调用写入,这里我调用了五次,实际使用时根据数据库分页的总的页数来
PageRequest page = PageRequest.ofSize(10000);
if(pageable != null){
......@@ -246,8 +254,24 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
}
}
/**
* 一次性导出excel
*/
public static void downloadExcel(List<List<String>> headers, List<List<Object>> datas, HttpServletResponse response) throws IOException {
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
//String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20");
String fileName = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream()).sheet("Sheet1").head(headers).doWrite(datas);
}
/**
* 导出excel
* 一次性导出excel
*/
public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response) throws IOException {
String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
......
......@@ -59,10 +59,9 @@ public class BarcodeController {
@ApiOperation("导出条码数据")
@GetMapping(value = "/download")
public void download(HttpServletResponse response, BarcodeQueryCriteria criteria) throws Exception {
public void download(HttpServletResponse response, Pageable pageable, BarcodeQueryCriteria criteria) throws Exception {
Query query=QueryHelp.getQuery(criteria);
List<Barcode> list=barcodeManager.findByQuery(query);
barcodeManager.download(list,response);
barcodeManager.download(query,pageable,response);
}
@ApiOperation("查询条码")
......
......@@ -2,6 +2,8 @@ package com.neotel.smfcore.core.barcode.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
......@@ -14,7 +16,7 @@ public interface IBarcodeManager extends IBaseManager<Barcode> {
Barcode saveBarcode(Barcode resources);
void download(List<Barcode> list, HttpServletResponse response) throws IOException;
void download(Query query, Pageable pageable, HttpServletResponse response) throws IOException;
void deleteBarcodes(Set<String> ids);
}
package com.neotel.smfcore.core.barcode.service.manager.impl;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.base.IExcelDownLoad;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
......@@ -64,20 +66,39 @@ public class BarcodeManagerImpl implements IBarcodeManager {
}
@Override
public void download(List<Barcode> barcodes, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (Barcode barcode : barcodes) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("条码编号", barcode.getBarcode());
map.put("物料编号", barcode.getPartNumber());
map.put("批次", barcode.getBatch());
map.put("供应商编码", barcode.getProviderNumber());
map.put("料盘尺寸", barcode.getPlateSize()+"X"+barcode.getHeight());
map.put("封装数量", barcode.getAmount());
map.put("创建日期", DateUtil.toDateTimeString(barcode.getCreateDate()) );
list.add(map);
}
FileUtil.downloadExcel(list, response);
public void download(Query query, Pageable pageable, HttpServletResponse response) throws IOException {
FileUtil.downloadExcel(query, pageable, response, new IExcelDownLoad() {
@Override
public List<List<String>> getHeader() {
List<List<String>> headerList = new ArrayList<>();
headerList.add(Lists.newArrayList("条码编号"));
headerList.add(Lists.newArrayList("物料编号"));
headerList.add(Lists.newArrayList("批次"));
headerList.add(Lists.newArrayList("供应商编码"));
headerList.add(Lists.newArrayList("料盘尺寸"));
headerList.add(Lists.newArrayList("封装数量"));
headerList.add(Lists.newArrayList("创建日期"));
return headerList;
}
@Override
public List<List<Object>> getPageData(Query query, Pageable pageable) {
List<Barcode> barcodeList = barcodeDao.findByQuery(query,pageable);
List<List<Object>> dataList = new ArrayList<>();
for (Barcode barcode : barcodeList) {
List<Object> data = new ArrayList<>();
data.add(barcode.getBarcode());
data.add(barcode.getPartNumber());
data.add(barcode.getBatch());
data.add(barcode.getProviderNumber());
data.add(barcode.getPlateSize()+"X"+barcode.getHeight());
data.add(barcode.getAmount());
data.add(DateUtil.toDateTimeString(barcode.getCreateDate()));
dataList.add(data);
}
return dataList;
}
});
}
@Override
......
......@@ -32,10 +32,9 @@ public class InterfaceExceptionController {
public List<InterfaceExDto> list( InterfaceExCriteria criteria) {
List<InterfaceExDto> results = new ArrayList<>();
List<HikApiRequest> requests = HikApiCache.getAllRequestList();
for (HikApiRequest request :
requests) {
for (HikApiRequest request : requests) {
InterfaceExDto dto = toDto(request);
dto.setApiType(2);
//dto.setApiType(2);
if (criteria.getCreateDate() != null) {
Date from = criteria.getCreateDate().getFrom();
Date to = criteria.getCreateDate().getTo();
......
......@@ -891,7 +891,7 @@ public class LiteOrderCache implements ITaskListener {
/**
* //产线补料出库,补料逻辑:单盘最大5000 需求补料1000,按照满足需求最少料盘补料,补料需求6000时首发最大盘第二盘发满足需求最小盘
* 按照满足需求最少料盘补料,最大盘第二盘发满足需求最小盘
* @param outPosNameList
* @param posList
* @param targetNum
......@@ -900,9 +900,9 @@ public class LiteOrderCache implements ITaskListener {
private List<StoragePos> pickRepleReels(List<String> outPosNameList, List<StoragePos> posList, int targetNum){
List<String> excludePosNameList = new ArrayList<>(outPosNameList);
List<StoragePos> itemPickPosList = new ArrayList<>();
boolean pickMaxQtyReel = true;
boolean pickMaxQtyReel = false;
do {
//第一盘取最大的, 从第二盘开始取满足
//取满足的
StoragePos outPos = pickOneReel(true, excludePosNameList,posList,targetNum, pickMaxQtyReel, -1);
if(outPos == null){
break;
......@@ -914,7 +914,6 @@ public class LiteOrderCache implements ITaskListener {
if(targetNum <=0){
break;
}
pickMaxQtyReel = false;
}
} while(true);
return itemPickPosList;
......
......@@ -2,13 +2,18 @@ package com.neotel.smfcore.core.outList.rest;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
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.DateUtil;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.order.enums.LITEORDER_STATUS;
import com.neotel.smfcore.core.outList.bean.dto.OutListItemDto;
import com.neotel.smfcore.core.outList.service.po.OutList;
import com.neotel.smfcore.core.outList.service.po.OutListItem;
import com.neotel.smfcore.core.outList.bean.dto.OutListDto;
......@@ -34,7 +39,10 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -124,7 +132,6 @@ public class OutListController {
@GetMapping("/detial")
@PreAuthorize("@el.check('outList')")
public OutListDto detial(@RequestParam(required = false) String id, @RequestParam(required = false) String name) {
if (!ObjectUtils.isEmpty(id)) {
OutList outList = outListManager.get(id);
if (outList != null) {
......@@ -146,6 +153,59 @@ public class OutListController {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"id"});
}
@ApiOperation("出库单详情下载")
@GetMapping("/detial/download")
@PreAuthorize("@el.check('outList')")
public void detailDownload(@RequestParam(required = false) String id, @RequestParam(required = false) String name, HttpServletResponse response) throws IOException {
OutListDto dto = null;
if (!ObjectUtils.isEmpty(id)) {
OutList outList = outListManager.get(id);
if (outList != null) {
dto = outListMapper.toDto(outList);
dto.setOutListItems(outListItemMapper.toDto(outList.getOutListItems()));
}
} else if (!ObjectUtils.isEmpty(name)) {
OutList outList = outListCache.getOutList(name);
if (outList == null) {
outListManager.findByName(name);
}
if (outList != null) {
dto = outListMapper.toDto(outList);
dto.setOutListItems(outListItemMapper.toDto(outList.getOutListItems()));
}
}
if(dto != null){
//materialNo,baseCode,dumpQty,needReelCount,outNum,outReelCount,totalOutNum,totalOutReelCount
List<List<String>> headerList = new ArrayList<>();
headerList.add(Lists.newArrayList("出库单名称"));
headerList.add(Lists.newArrayList("物料号"));
headerList.add(Lists.newArrayList("基地编号"));
headerList.add(Lists.newArrayList("转出数量"));
headerList.add(Lists.newArrayList("总需求料盘数"));
headerList.add(Lists.newArrayList("当前任务已出数量"));
headerList.add(Lists.newArrayList("当前任务已出盘数"));
headerList.add(Lists.newArrayList("累计已出数量"));
headerList.add(Lists.newArrayList("累计已出盘数"));
List<List<Object>> dataList = new ArrayList<>();
for (OutListItemDto item : dto.getOutListItems()) {
List<Object> data = new ArrayList<>();
data.add(dto.getName());
data.add(item.getMaterialNo());
data.add(item.getBaseCode());
data.add(item.getDumpQty());
data.add(item.getNeedReelCount());
data.add(item.getOutNum());
data.add(item.getOutReelCount());
data.add(item.getTotalOutNum());
data.add(item.getTotalOutReelCount());
dataList.add(data);
}
FileUtil.downloadExcel(headerList,dataList, response);
return;
}
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"id"});
}
@ApiOperation("更新指定的出库单")
@PostMapping(value = "/updateOutList")
......
......@@ -117,7 +117,7 @@ public class DataLogManagerImpl implements IDataLogManager {
public List<List<Object>> getPageData(Query query, Pageable pageable) {
List<List<Object>> dataList = new ArrayList<>();
List<DataLog> dataLogList = dataLogDao.findByQuery(query, pageable);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (DataLog dataLog : dataLogList) {
List<Object> data = new ArrayList<>();
......@@ -133,7 +133,8 @@ public class DataLogManagerImpl implements IDataLogManager {
data.add(dataLog.getProvider());//"供应商"
data.add(dataLog.getSubSourceInfo());//"来源二"
data.add(dataLog.getStatusStr());//"状态"
data.add("更新时间");
String updateTimeStr = dateFormat.format(dataLog.getUpdateDate());
data.add(updateTimeStr);//"更新时间"
dataList.add(data);
}
return dataList;
......
......@@ -506,10 +506,18 @@ public class DataLog extends BasePo implements Serializable {
}
public String getStatusStr() {
String statusStr = "";
String statusValue = getStatus();
if(statusValue.equals(OP_STATUS.WAIT)){
String statusStr = statusValue;
if(statusValue.equals(OP_STATUS.WAIT.name())){
statusStr = "等待中";
}else if(statusValue.equals(OP_STATUS.EXECUTING.name())){
statusStr = "执行中";
}else if(statusValue.equals(OP_STATUS.FINISHED.name())){
statusStr = "已完成";
}else if(statusValue.equals(OP_STATUS.END.name())){
statusStr = "已结束";
}else if(statusValue.equals(OP_STATUS.CANCEL.name())){
statusStr = "已取消";
}
return statusStr;
}
......
......@@ -30,10 +30,10 @@ public class HttpHelper {
private static final String CONTENT_CHARSET = "UTF-8";
// 连接超时时间
private static final int CONNECTION_TIMEOUT = 3000;
private static final int CONNECTION_TIMEOUT = 10000;
// 读数据超时时间
private static final int READ_DATA_TIMEOUT = 3000;
private static final int READ_DATA_TIMEOUT = 10000;
// 设置User-Agent
private static final String USER_AGENT = "SMD-BOX";
......
......@@ -15,41 +15,38 @@ import java.util.stream.Collectors;
public class ElPermissionConfig {
public Boolean check(String ... permissions) {
boolean result = true;
//超级管理员
if (SecurityUtils.getCurrentUsername().equals(Constants.SUPER_USERNAME)) {
return true;
}
// 获取当前用户的所有权限
List<String> elPermissions = SecurityUtils.getCurrentUser().getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
// 判断当前用户的所有权限是否包含接口上定义的权限
boolean result = elPermissions.contains("admin") || Arrays.stream(permissions).anyMatch(elPermissions::contains);
String msg = "";
for (String str :
permissions) {
msg += str + ",";
}
if (!result) {
//未找到匹配项,分割后匹配
for (String per :
permissions) {
if (!DataInitManager.allPermissionSet.contains(per)) {
String[] perArray = per.split(":");
if (perArray.length > 1) {
String newper = perArray[0];
if (elPermissions.contains(newper)) {
result = true;
}
}
}
}
}
if (!result) {
log.info("username[" + SecurityUtils.getCurrentUsername() + "] 对 [" + msg + "]无访问权限");
}
// if (SecurityUtils.getCurrentUsername().equals(Constants.SUPER_USERNAME)) {
// return true;
// }
//
// // 获取当前用户的所有权限
// List<String> elPermissions = SecurityUtils.getCurrentUser().getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
//
// // 判断当前用户的所有权限是否包含接口上定义的权限
// boolean result = elPermissions.contains("admin") || Arrays.stream(permissions).anyMatch(elPermissions::contains);
// String msg = "";
// for (String str : permissions) {
// msg += str + ",";
// }
// if (!result) {
// //未找到匹配项,分割后匹配
// for (String per : permissions) {
// if (!DataInitManager.allPermissionSet.contains(per)) {
// String[] perArray = per.split(":");
// if (perArray.length > 1) {
// String newper = perArray[0];
// if (elPermissions.contains(newper)) {
// result = true;
// }
// }
// }
// }
// }
// if (!result) {
// log.info("username[" + SecurityUtils.getCurrentUsername() + "] 对 [" + msg + "]无访问权限");
// }
return result;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!