|
@@ -1,19 +1,17 @@
|
|
|
package com.github.zuihou.business.controller.operationManagementCenter;
|
|
|
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.github.zuihou.base.R;
|
|
|
+import com.github.zuihou.base.controller.SuperController;
|
|
|
import com.github.zuihou.base.request.PageParams;
|
|
|
-import com.github.zuihou.business.operationManagementCenter.entity.Plan;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.dto.PlanPageDTO;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dto.PlanSaveDTO;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dto.PlanUpdateDTO;
|
|
|
-import com.github.zuihou.business.operationManagementCenter.dto.PlanPageDTO;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.Plan;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.PlanService;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import com.github.zuihou.base.controller.SuperController;
|
|
|
-import com.github.zuihou.base.R;
|
|
|
import com.github.zuihou.common.util.StringUtil;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
|
|
@@ -23,14 +21,26 @@ import com.github.zuihou.security.model.SysUser;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import com.github.zuihou.security.annotation.PreAuth;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.*;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.channels.Channels;
|
|
|
+import java.nio.channels.ReadableByteChannel;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -76,6 +86,12 @@ public class PlanController extends SuperController<PlanService, Long, Plan, Pla
|
|
|
return success(baseService.list());
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "查询已经完成订单计划", notes = "查询已经完成订单计划")
|
|
|
+ @PostMapping("/getFinishPlanList")
|
|
|
+ public R<List<Map<String,String>>> getFinishPlanList(@RequestBody Map<String,Object> params) {
|
|
|
+ return success(baseService.getFinishPlanList(params));
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "新增计划", notes = "新增计划")
|
|
|
@PostMapping("/save")
|
|
|
public R<Plan> save(@RequestBody Map<String,Object> model) {
|
|
@@ -162,4 +178,56 @@ public class PlanController extends SuperController<PlanService, Long, Plan, Pla
|
|
|
return success(baseService.updateNumber(model));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "下载工艺流程卡", notes = "下载工艺流程卡")
|
|
|
+ @PostMapping("/downloadCraftCards")
|
|
|
+ public void downloadCraftCards(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, @RequestBody Map<String,Object> params) throws IOException {
|
|
|
+ String planId = params.get("id").toString();
|
|
|
+ // TODO 根据后续实际情况取真实数据展示
|
|
|
+ Map<String, String> partInfo = baseService.getFinishPlanPartInfo(params);
|
|
|
+ List<Map<String, String>> procedures = baseService.getFinishPlanPartProcedures(params);
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.putAll(partInfo);
|
|
|
+ map.put("dataList", procedures);
|
|
|
+ File temp = File.createTempFile("craftCradsResult", ".xlsx");
|
|
|
+ // TODO 根据后续真实模板地址修改,存放在nginx目录下
|
|
|
+ URL url = new URL("http://127.0.0.1:8760/file/0000/template/craftCradsTemplate.xlsx");
|
|
|
+ ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream());
|
|
|
+ FileOutputStream fileOutputStream = new FileOutputStream(temp);
|
|
|
+ fileOutputStream.getChannel().transferFrom(readableByteChannel,0,Long.MAX_VALUE);
|
|
|
+ fileOutputStream.close();
|
|
|
+ readableByteChannel.close();
|
|
|
+
|
|
|
+ TemplateExportParams templateExportParams = new TemplateExportParams(temp.getAbsolutePath(),true);
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(templateExportParams, map);
|
|
|
+ FileOutputStream fos = new FileOutputStream(temp.getAbsolutePath());
|
|
|
+
|
|
|
+
|
|
|
+ BufferedInputStream bis = null;
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ // 模板填充数据
|
|
|
+ workbook.write(fos);
|
|
|
+ fos.flush();
|
|
|
+ fos.close();
|
|
|
+
|
|
|
+ outputStream = httpServletResponse.getOutputStream();
|
|
|
+ httpServletResponse.setHeader("content-type", "text/csv");
|
|
|
+ httpServletResponse.setContentType("application/octet-stream");
|
|
|
+ httpServletResponse.setHeader("Content-Disposition", "attachment; filename=" + planId + ".xlsx");
|
|
|
+ workbook.write(outputStream);
|
|
|
+ } catch ( IOException e ) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (bis != null) {
|
|
|
+ bis.close();
|
|
|
+ }
|
|
|
+ if (outputStream != null) {
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+ }
|
|
|
+ // 删除零时文件
|
|
|
+ temp.delete();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|