Browse Source

添加下载功能

lwx_dev
erdanergou 3 years ago
parent
commit
8b08cc857a
  1. 57
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

57
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

@ -547,7 +547,7 @@ public class DepositoryRecordController {
Map<String, Object> insert = new HashMap<>(); Map<String, Object> insert = new HashMap<>();
insert.put("applicantId", userToken.getId()); insert.put("applicantId", userToken.getId());
insert.put("mid", map.get("mid" + temp)); insert.put("mid", map.get("mid" + temp));
insert.put("quantity",(int)(ObjectFormatUtil.toDouble(map.get("quantity" + temp)) * 100)); insert.put("quantity", (int) (ObjectFormatUtil.toDouble(map.get("quantity" + temp)) * 100));
insert.put("applyRemark", map.get("applyRemark" + temp)); insert.put("applyRemark", map.get("applyRemark" + temp));
insert.put("code", map.get("code")); insert.put("code", map.get("code"));
insert.put("placeId", map.get("placeId")); insert.put("placeId", map.get("placeId"));
@ -734,7 +734,7 @@ public class DepositoryRecordController {
// 获取申请的物料信息 // 获取申请的物料信息
Inventory materialById = materialService.findInventoryById(applicationOutMinById.getMid()); Inventory materialById = materialService.findInventoryById(applicationOutMinById.getMid());
if ("-1".equals(applicationOutMinById.getUnit())) { if ("-1".equals(applicationOutMinById.getUnit())) {
simpleApplicationOutMinRecordP.setShowQuantity(materialById.getUnit() + ":" + (applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut())); simpleApplicationOutMinRecordP.setShowQuantity(materialById.getUnit() + ":" + (applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut()));
} else { } else {
simpleApplicationOutMinRecordP.setShowQuantity(applicationOutMinById.getUnit() + ":" + (applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut())); simpleApplicationOutMinRecordP.setShowQuantity(applicationOutMinById.getUnit() + ":" + (applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut()));
} }
@ -761,7 +761,7 @@ public class DepositoryRecordController {
simpleApplicationOutMinRecordP.setCheckerName(checker.getName()); simpleApplicationOutMinRecordP.setCheckerName(checker.getName());
simpleApplicationOutMinRecordP.setPcode(placeByDid.getCode()); simpleApplicationOutMinRecordP.setPcode(placeByDid.getCode());
// 当已经完成出库时设置数量为出库数 // 当已经完成出库时设置数量为出库数
simpleApplicationOutMinRecordP.setQuantity(applicationOutMinById.getQuantity() ); simpleApplicationOutMinRecordP.setQuantity(applicationOutMinById.getQuantity());
} }
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialService.findMaterialAndProducedDateByMid(materialById.getId()); List<MaterialAndProducedDate> materialAndProducedDateByMid = materialService.findMaterialAndProducedDateByMid(materialById.getId());
if (materialAndProducedDateByMid.size() > 0) { if (materialAndProducedDateByMid.size() > 0) {
@ -835,14 +835,14 @@ public class DepositoryRecordController {
depositoryName.append(depository.getDname()).append(","); depositoryName.append(depository.getDname()).append(",");
sumQuantity += applicationOutRecordMin.getQuantity(); sumQuantity += applicationOutRecordMin.getQuantity();
String unit = applicationOutRecordMin.getUnit(); String unit = applicationOutRecordMin.getUnit();
if("-1".equals(unit)){ if ("-1".equals(unit)) {
sumPrice += (inventory.getPrice() * applicationOutRecordMin.getQuantity()); sumPrice += (inventory.getPrice() * applicationOutRecordMin.getQuantity());
}else{ } else {
// 获取当前对应的拆单记录 // 获取当前对应的拆单记录
Map<String,Object> paramForSplitInfo = new HashMap<>(); Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("mid",inventory.getMid()); paramForSplitInfo.put("mid", inventory.getMid());
paramForSplitInfo.put("newUnit",unit); paramForSplitInfo.put("newUnit", unit);
SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo); SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取当前拆单记录与基础单位进制 // 获取当前拆单记录与基础单位进制
int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
@ -1428,7 +1428,7 @@ public class DepositoryRecordController {
Double integer = ObjectFormatUtil.toDouble(quantitys.get(i)); Double integer = ObjectFormatUtil.toDouble(quantitys.get(i));
// 获取当前仓库编号 // 获取当前仓库编号
Integer depositoryId = depositoryIds.get(i); Integer depositoryId = depositoryIds.get(i);
String quantity = String.valueOf((int)(integer * 100)); String quantity = String.valueOf((int) (integer * 100));
// 获取库位 // 获取库位
String placeCode = placeCodes.get(i); String placeCode = placeCodes.get(i);
@ -1478,7 +1478,7 @@ public class DepositoryRecordController {
outRecord.put("placeId", place); outRecord.put("placeId", place);
outRecord.put("unit", unit); outRecord.put("unit", unit);
outRecord.put("applyRemark", applyRemark); outRecord.put("applyRemark", applyRemark);
outRecord.put("adminorgId",userToken.getMaindeparment()); outRecord.put("adminorgId", userToken.getMaindeparment());
success += depositoryRecordService.insertApplicationOutMin(outRecord); success += depositoryRecordService.insertApplicationOutMin(outRecord);
} else { } else {
// 获取失败的物料信息 // 获取失败的物料信息
@ -1562,13 +1562,13 @@ public class DepositoryRecordController {
// 用于下载待打印出库订单 // 用于下载待打印出库订单
@GetMapping("/downloadOutRecord") @GetMapping("/downloadOutRecord")
public void downloadOutRecord(@RequestParam Map<String,Object> map, HttpServletRequest request, HttpServletResponse response){ public void downloadOutRecord(@RequestParam Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) {
String token = request.getHeader("user-token"); String token = request.getHeader("user-token");
if (token == null) { if (token == null) {
token = (String) request.getSession().getAttribute("userToken"); token = (String) request.getSession().getAttribute("userToken");
} }
UserByPort userToken = AuthenticationTokenPool.getUserToken(token); UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
if(map.containsKey("id")){ if (map.containsKey("id")) {
Integer id = ObjectFormatUtil.toInteger(map.get("id")); Integer id = ObjectFormatUtil.toInteger(map.get("id"));
List<String> strings = excelService.writeExcelForPrint(id, 4, userToken); List<String> strings = excelService.writeExcelForPrint(id, 4, userToken);
List<File> files = new ArrayList<>(); List<File> files = new ArrayList<>();
@ -1576,36 +1576,9 @@ public class DepositoryRecordController {
File file = new File(string); File file = new File(string);
files.add(file); files.add(file);
} }
ZipMultiFileUtil.zipDownload(response,"出库订单.zip",files); ZipMultiFileUtil.zipDownload(response, "出库订单.zip", files);
ZipMultiFileUtil.deleteFile(files); ZipMultiFileUtil.deleteFile(files);
/*try { } else {
String path = "static/upload/materialTypeImport.xlsx";
String fileName = "materialTypeImport.xlsx";
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.setContentType("content-type:octet-stream");
*//* .getClassLoader() 方法是在静态文件路径添加一个/ *//*
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(path);
OutputStream outputStream = response.getOutputStream();
try {
byte[] buffer = new byte[1024];
int len;
assert inputStream != null;
while ((len = inputStream.read(buffer)) != -1) { *//* 将流中内容写出去 .*//*
outputStream.write(buffer, 0, len);
}
}catch (IOException e){
e.printStackTrace();
}finally {
assert inputStream != null;
inputStream.close();
outputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}*/
}else{
throw new MyException("缺少必要参数"); throw new MyException("缺少必要参数");
} }
} }

Loading…
Cancel
Save