From c40d7f65624a6f158ec734d2007d7bf8d3b744f4 Mon Sep 17 00:00:00 2001 From: whycxzp <perryhsu@163.com> Date: 星期三, 07 九月 2022 11:32:54 +0800 Subject: [PATCH] 软件excel解析 --- src/main/java/com/whyc/controller/ProductController.java | 88 ++++++++++++++++++++++++++++++++++++------- 1 files changed, 73 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/whyc/controller/ProductController.java b/src/main/java/com/whyc/controller/ProductController.java index 4611c3c..94e53aa 100644 --- a/src/main/java/com/whyc/controller/ProductController.java +++ b/src/main/java/com/whyc/controller/ProductController.java @@ -1,16 +1,19 @@ package com.whyc.controller; import com.whyc.dto.Response; -import com.whyc.pojo.ProductHistory; -import com.whyc.service.ProductHistoryService; -import com.whyc.service.ProductService; +import com.whyc.pojo.Product; +import com.whyc.service.*; +import com.whyc.util.ActionUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -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.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; @Api(tags = "浜у搧绠$悊") @RestController @@ -22,10 +25,19 @@ @Autowired private ProductHistoryService historyService; - @ApiOperation(tags = "鐗╂枡绠$悊",value = "鏍规嵁鐗╂枡缂栫爜鏌ヨ鎵�鏈夊寘鍚鐗╂枡鐨勪骇鍝佷俊鎭�",notes = "8.17淇敼鍚庝娇鐢�") - @GetMapping("getProductByMaterial") - public Response getProductByMaterial(@RequestParam String subCode){ - return service.getProductByMaterial(subCode); + @Autowired + private ProductBomService bomService; + + @Autowired + private ProductBomHistoryService bomHistoryService; + + @Autowired + private MaterialService meterService; + + @ApiOperation(value = "寤虹珛鍏宠仈鏃舵煡璇㈡墍鏈夌殑鐗╂枡锛堜笉鍒嗛〉锛�",notes = "8.17淇敼鍚庝娇鐢�") + @GetMapping("getAllMaterialNoLimit") + public Response getAllMaterialNoLimit(){ + return meterService.getAllMaterialNoLimit(); } @ApiOperation(value = "鏌ヨ鍑烘墍鏈夌殑浜у搧淇℃伅(鍒嗛〉鍔犳ā绯婃煡璇�<浜у搧鐨勭紪鐮侊紝鍨嬪彿锛屽悕瀛楋紝瀹氬埗琛ㄧ紪鍙�>)",notes = "8.17淇敼鍚庝娇鐢�") @@ -34,10 +46,56 @@ , @RequestParam(required = false) String customCode, @RequestParam int pageCurr, @RequestParam int pageSize){ return service.getAllProduct(parentCode,parentName,parentModel,customCode,pageCurr,pageSize); } - @ApiOperation(value = "浜у搧璇︽儏鏌ョ湅鐗堟湰淇℃伅",notes = "8.17淇敼鍚庝娇鐢�") - @GetMapping("getProductVersion") - public Response getProductVersion( @RequestParam String parentModel, String customCode){ - return historyService.getProductVersion(parentModel,customCode); + + @ApiOperation(value = "鏌ヨ鍑烘墍鏈夌殑浜у搧鏃犲弬涓嶅垎椤碉紙浜у搧涓婁紶鐨勬槸鐢級",notes = "9.2淇敼鍚庝娇鐢�") + @GetMapping("getUpBomUseProduct") + public Response getUpBomUseProduct(){ + return service.getUpBomUseProduct(); } + @ApiOperation(value = "浜у搧璇︽儏鏌ョ湅鐗堟湰淇℃伅",notes = "8.17淇敼鍚庝娇鐢�") + @GetMapping("getProductVersion") + public Response getProductVersion( @RequestParam String parentCode, String customCode){ + return historyService.getProductVersion(parentCode,customCode); + } + @ApiOperation(value = "鏍规嵁浜у搧id鍜岀増鏈煡璇㈠瓙浠跺強鍏跺叧鑱旂殑鐗╂枡淇℃伅",notes = "8.17淇敼鍚庝娇鐢�") + @GetMapping("getBomAndMaterial") + public Response getBomAndMaterial( @RequestParam int productId, @RequestParam int version){ + return bomService.getBomAndMaterial(productId,version); + } + @ApiOperation(value = "浜у搧涓嬭浇(浜у搧id鍜岀増鏈�<褰撳墠鏈�鏂扮増鏈�>)",notes = "8.17淇敼鍚庝娇鐢�") + @GetMapping("downloadProduct") + public void downloadProduct(HttpServletRequest req, HttpServletResponse resp, @RequestParam int productId, @RequestParam int version){ + bomService.downloadProduct(req,resp,productId,version); + } + + @ApiOperation(value = "鍘嗗彶浜у搧淇℃伅鏌ョ湅锛堟牴鎹巻鍙蹭骇鍝佷骇鍝乮d鍜岀増鏈煡璇㈠瓙浠跺強鍏跺叧鑱旂殑鐗╂枡淇℃伅锛�",notes = "8.17淇敼鍚庝娇鐢�") + @GetMapping("getBomHistoryAndMaterial") + public Response getBomHistoryAndMaterial( @RequestParam int productId, @RequestParam int version){ + return bomHistoryService.getBomHistoryAndMaterial(productId,version); + } + @ApiOperation(value = "鍘嗗彶浜у搧涓嬭浇(浜у搧id鍜岀増鏈�<涓嬭浇鐨勭増鏈�>)",notes = "8.17淇敼鍚庝娇鐢�") + @GetMapping("downloadProductHistory") + public void downloadProductHistory(HttpServletRequest req, HttpServletResponse resp, @RequestParam int productId, @RequestParam int version){ + bomHistoryService.downloadProductHistory(req,resp,productId,version); + } + + @ApiOperation(value = "鍘嗗彶鐗堟湰鍙敤鎬ц瀹�",notes = "8.31淇敼鍚庝娇鐢�") + @GetMapping("setpHistoryEnable") + public Response setpHistoryEnable( @RequestParam String parentCode, @RequestParam String customCode, @RequestParam int version,@RequestParam int enabled) { + return historyService.setpHistoryEnable(parentCode, customCode, version, enabled); + } + @PostMapping("zipParse") + @ApiOperation(value = "zip瑙f瀽",notes = "杩斿洖缁撴灉涓�,杩藉姞data3涓哄姣旂粨鏋�,涓簁ey-value闆嗗悎,key涓篸iffList,addList,deleteList") + public Response zipParse(@RequestParam("file") MultipartFile file,@RequestParam(required = false) String baseStr) throws IOException, InvalidFormatException { + //瑕佸仛瀵规瘮鐨勪骇鍝�,浼犲叆浜嗙墿鏂�(parent_code)鍜屽畾鍒惰〃鍗曞彿(custom_code) + Product baseProduct = (baseStr==null?null:ActionUtil.getGson().fromJson(baseStr, Product.class)); + return service.zipParse(file,baseProduct); + } + + @PostMapping + @ApiOperation(value = "鏂板",notes = "瑙f瀽鏃惰繑鍥炵殑缁濆璺緞,闇�瑕佸洖浼犲埌瀛楁fileUrl") + public Response add(@RequestBody Product product) throws IOException { + return service.add(product); + } } -- Gitblit v1.9.1