mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
生产单管理-模板
This commit is contained in:
+55
-1
@@ -3,6 +3,8 @@ package com.cf.imes.module.executor.controller.admin.order;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderSaveReqVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -13,8 +15,9 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
@@ -30,6 +33,16 @@ import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.service.order.OrderService;
|
||||
|
||||
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 生产单表 order_{N}")
|
||||
@RestController
|
||||
@RequestMapping("/executor/order")
|
||||
@@ -39,6 +52,8 @@ public class OrderController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OrderController.class);
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建生产单表 order_{N}")
|
||||
@PreAuthorize("@ss.hasPermission('executor:order:create')")
|
||||
@@ -93,4 +108,43 @@ public class OrderController {
|
||||
BeanUtils.toBean(list, OrderRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获得导入生产单模板")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
try {
|
||||
// path是指想要下载的文件的路径
|
||||
File file = new File(ResourceUtils.getURL("classpath:").getPath()+ "\\files\\生产单上传样式.xlsx");
|
||||
log.info(file.getPath());
|
||||
// 获取文件名
|
||||
String filename = file.getName();
|
||||
// 获取文件后缀名
|
||||
String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
|
||||
log.info("文件后缀名:" + ext);
|
||||
|
||||
// 将文件写入输入流
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
InputStream fis = new BufferedInputStream(fileInputStream);
|
||||
byte[] buffer = new byte[fis.available()];
|
||||
fis.read(buffer);
|
||||
fis.close();
|
||||
|
||||
// 清空response
|
||||
response.reset();
|
||||
// 设置response的Header
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
||||
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
||||
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
|
||||
// 告知浏览器文件的大小
|
||||
response.addHeader("Content-Length", "" + file.length());
|
||||
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
|
||||
response.setContentType("application/octet-stream");
|
||||
outputStream.write(buffer);
|
||||
outputStream.flush();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -1,9 +1,16 @@
|
||||
package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderSaveReqVO;
|
||||
import com.cf.imes.module.system.enums.common.SexEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
@@ -11,6 +18,11 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
|
||||
@@ -29,6 +41,11 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
@Override
|
||||
public Long createOrder(OrderSaveReqVO createReqVO) {
|
||||
/**
|
||||
* 1、解析文件
|
||||
*
|
||||
*/
|
||||
|
||||
// 插入
|
||||
OrderDO order = BeanUtils.toBean(createReqVO, OrderDO.class);
|
||||
orderMapper.insert(order);
|
||||
|
||||
Reference in New Issue
Block a user