From bd1137319f16fcb2750333aeb37366aff0ec4ef9 Mon Sep 17 00:00:00 2001 From: zhuo <2089219845@qq.com> Date: 星期二, 18 二月 2025 11:51:51 +0800 Subject: [PATCH] 检验下单移植 --- inspect-server/src/main/resources/mapper/RawMaterialOrderTemplateMapper.xml | 4 inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderMapper.java | 2 ruoyi-framework/src/main/java/com/ruoyi/framework/config/FormatterConfig.java | 51 ruoyi-common/src/main/java/com/ruoyi/common/utils/DateImageUtil.java | 61 inspect-server/src/main/resources/mapper/InsUnqualifiedRetestProductMapper.xml | 200 + inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java | 1686 ++++---- inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderController.java | 617 +- inspect-server/src/main/resources/mapper/InsOrderStateMapper.xml | 4 ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java | 2 inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderTemplateMapper.java | 18 inspect-server/src/main/resources/mapper/InsOrderMapper.xml | 588 +++ inspect-server/src/main/resources/mapper/InsReportMapper.xml | 66 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java | 2100 ++++++------ performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml | 19 inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsUnqualifiedHandlerMapper.java | 38 ruoyi-system/src/main/java/com/ruoyi/system/service/UserService.java | 10 inspect-server/pom.xml | 16 inspect-server/src/main/java/com/ruoyi/inspect/dto/UnqualifiedHandlerDto.java | 148 inspect-server/src/main/java/com/ruoyi/inspect/pojo/CommonOa.java | 61 inspect-server/src/main/resources/mapper/InsOrderTemplateMapper.xml | 4 inspect-server/src/main/resources/mapper/InsUnqualifiedHandlerMapper.xml | 87 inspect-server/src/main/resources/mapper/InsSampleMapper.xml | 699 ++++ inspect-server/src/main/resources/mapper/SpotCheckQuarterItemMapper.xml | 4 ruoyi-admin/pom.xml | 12 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Result.java | 12 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderTemplateServiceImpl.java | 57 inspect-server/src/main/resources/mapper/InsProductMapper.xml | 144 ruoyi-admin/src/main/resources/application.yml | 12 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/UserController.java | 14 inspect-server/src/main/java/com/ruoyi/inspect/controller/RawMaterialOrderController.java | 628 +- inspect-server/src/main/java/com/ruoyi/inspect/service/InsOrderTemplateService.java | 23 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductServiceImpl.java | 221 + inspect-server/src/main/java/com/ruoyi/inspect/service/InsProductService.java | 3 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java | 13 ruoyi-admin/src/main/resources/application-druid.yml | 159 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java | 2318 ++++++------ inspect-server/src/main/resources/mapper/InsSampleUserMapper.xml | 4 ruoyi-system/src/main/resources/mapper/system/UserMapper.xml | 32 ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java | 11 inspect-server/src/main/resources/mapper/InsProductUserMapper.xml | 4 inspect-server/src/main/java/com/ruoyi/inspect/service/RawMaterialOrderService.java | 1 41 files changed, 6,372 insertions(+), 3,781 deletions(-) diff --git a/inspect-server/pom.xml b/inspect-server/pom.xml index 0484757..9781406 100644 --- a/inspect-server/pom.xml +++ b/inspect-server/pom.xml @@ -47,6 +47,22 @@ <groupId>com.deepoove</groupId> <artifactId>poi-tl</artifactId> </dependency> + + <!--word杞琾df--> + <!--D:\JavaWork\center-lims-after\inspect-server\src\main\resources\lib--> + <!--mvn install:install-file -Dfile=aspose-words-15.12.0-jdk16.jar -DgroupId=com.aspose -DartifactId=aspose-words -Dversion=15.12.0 -Dpackaging=jar--> + <dependency> + <groupId>com.aspose</groupId> + <artifactId>aspose-words</artifactId> + <version>15.12.0</version> + </dependency> + <dependency> + <groupId>com.itextpdf</groupId> + <artifactId>itextpdf</artifactId> + <version>5.0.6</version> + </dependency> + + </dependencies> <properties> diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderController.java b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderController.java index a0cec57..e65b4ea 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderController.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderController.java @@ -1,307 +1,310 @@ -//package com.ruoyi.basic.controller; -// -//import com.alibaba.fastjson.JSON; -//import com.alibaba.fastjson.JSONArray; -//import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -//import com.baomidou.mybatisplus.core.toolkit.Wrappers; -//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; -//import com.ruoyi.common.core.domain.Result; -//import com.ruoyi.inspect.dto.OmitOrderProductDto; -//import com.ruoyi.inspect.dto.SampleOrderDto; -//import com.ruoyi.inspect.service.InsOrderService; -//import io.swagger.annotations.Api; -//import io.swagger.annotations.ApiImplicitParam; -//import io.swagger.annotations.ApiImplicitParams; -//import io.swagger.annotations.ApiOperation; -//import lombok.AllArgsConstructor; -//import org.springframework.scheduling.annotation.Scheduled; -//import org.springframework.web.bind.annotation.*; -// -//import javax.servlet.http.HttpServletResponse; -//import java.time.LocalDateTime; -//import java.time.format.DateTimeFormatter; -//import java.util.List; -//import java.util.Map; -//import java.util.Objects; -// -//@RestController -//@AllArgsConstructor -//@RequestMapping("/insOrder") -//@Api(tags="妫�楠屽崟妯″潡") -//public class InsOrderController { -// -// private InsOrderService insOrderService; -// -// private InsSampleService insSampleService; -// -// private InsProductService insProductService; -// -// private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; -// -// private InsOrderTemplateService insOrderTemplateService; -// -// //鑾峰彇妫�楠屼笅鍗曟暟鎹� -// @ApiOperation(value = "鏌ヨ鍗曚綅妫�楠屽崟") -// @PostMapping("/selectInsOrderParameter") -// public Result selectInsOrderParameter(@RequestBody Map<String, Object> data) throws Exception { -// Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); -// SampleOrderDto sampleOrderDto = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), SampleOrderDto.class); -// return Result.success(insOrderService.selectInsOrderParameter(page, sampleOrderDto)); -// } -// -// //鐢ㄤ簬妫�楠屼笅鍗曞尯鍒煡鐪嬫墍鏈夎鍗曞拰鍙煡鐪嬪悓涓�涓鎵樺崟浣嶇殑璁㈠崟 -// @ApiOperation(value = "鏌ヨ鎵�鏈夋楠屽崟") -// @PostMapping("/selectAllInsOrderParameter") -// public Result selectAllInsOrderParameter() { -// return Result.success(); -// } -// -// -// @ApiOperation(value = "妫�楠屽垎閰�") -// @PostMapping("/upInsOrder") -// public Result<?> upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId,String sonLaboratory) { -// return Result.success(insOrderService.upInsOrder(orderId, sampleId, appointed, userId,sonLaboratory)); -// } -// -// @ApiOperation(value = "娣诲姞妫�楠屼笅鍗曟暟鎹�") -// @PostMapping("/addInsOrder") -// public Result<?> addInsOrder(String str) { -// Map<String, Object> map = JSON.parseObject(str, Map.class); -// JSONArray jsonArray = JSON.parseArray(map.get("list")+""); -// List<SampleProductDto> list = jsonArray.toJavaList(SampleProductDto.class); -// InsOrder insOrder = JSON.parseObject(JSON.toJSONString(map.get("insOrder")), InsOrder.class); -// List<List<Integer>> pairing = JSON.parseArray(map.get("pairing")+""); -// return Result.success(insOrderService.addInsOrder(list, insOrder, pairing)); -// } -// -// @ApiOperation(value = "鏌ヨ璁㈠崟鏈�闀块璁℃椂闂�") -// @PostMapping("/selectOrderManDay") -// public Result<?> selectOrderManDay(Integer id) { -// int day = insProductService.selectOrderManDay(id); -// return Result.success("鎴愬姛", LocalDateTime.now().plusHours(day).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); -// } -// -// @ApiOperation(value = "鏌ヨ妫�楠屼笅鍗曞唴瀹硅鎯�") -// @PostMapping("/getInsOrder") -// public Result<?> getInsOrder(Integer orderId) { -// return Result.success(insOrderService.getInsOrder(orderId)); -// } -// @ValueClassify("妫�楠屼笅鍗�") -// @ApiOperation(value = "瀹℃牳妫�楠屽崟杩涜鐘舵�佷慨鏀�") -// @ApiImplicitParams({ -// @ApiImplicitParam(name = "id", value = "妫�楠屽崟id", dataTypeClass = Integer.class), -// @ApiImplicitParam(name = "state", value = "瀹℃牳缁撴灉 1:閫氳繃 2锛氫笉閫氳繃", dataTypeClass = Integer.class) -// }) -// -// @PostMapping("/upInsOrderOfState") -// public Result<?> upInsOrderOfState(@RequestBody InsOrder insOrder) { -// return Result.success(insOrderService.upInsOrderOfState(insOrder)); -// } -// -// @ApiOperation(value = "娣诲姞妫�楠屽崟妯℃澘") -// @PostMapping("/addInsOrderTemplate") -// public Result<?> addInsOrderTemplate(@RequestBody InsOrderTemplate insOrderTemplate) { -// return Result.success(insOrderTemplateService.addInsOrderTemplate(insOrderTemplate)); -// } -// -// @ApiOperation(value = "鏌ヨ妫�楠屽崟妯℃澘") -// @GetMapping("/selectInsOrderTemplate") -// public Result<?> selectInsOrderTemplate(String company) { -// return Result.success(insOrderTemplateService.selectInsOrderTemplate(company)); -// } -// -// @ApiOperation(value = "閫氳繃妫�楠屽崟妯℃澘id鑾峰彇妫�楠屽崟妯℃澘鍐呭") -// @PostMapping("/selectInsOrderTemplateById") -// public Result<?> selectInsOrderTemplateById(Integer id) { -// return Result.success("鎴愬姛", insOrderTemplateService.selectInsOrderTemplateById(id)); -// } -// -// @ApiOperation(value = "鍒犻櫎妫�楠屽崟妯℃澘") -// @PostMapping("/delInsOrderTemplate") -// public Result<?> delInsOrderTemplate(Integer id) { -// return Result.success(insOrderTemplateService.delInsOrderTemplate(id)); -// } -// -// @ApiOperation(value = "閫氳繃妫�楠屽崟鏌ヨ妫�楠屾暟鎹紙鏁版嵁鏌ョ湅锛�") -// @PostMapping("/selectSampleAndProductByOrderId") -// public Result<?> selectSampleAndProductByOrderId(@RequestBody Map<String, Object> data) throws Exception { -// Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); -// SampleProductDto2 sampleProductDto = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), SampleProductDto2.class); -// return Result.success(insOrderService.selectSampleAndProductByOrderId(page, sampleProductDto)); -// } -// -// @ApiOperation(value = "璐圭敤缁熻") -// @PostMapping("/costStatistics") -// public Result<?> costStatistics(@RequestBody Map<String, Object> data) throws Exception { -// Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); -// CostStatisticsDto costStatisticsDto = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), CostStatisticsDto.class); -// return Result.success(insOrderService.costStatistics(page, costStatisticsDto)); -// } -// -// @ApiOperation(value = "璐圭敤缁熻鑾峰彇鎬讳环") -// @PostMapping("/costStatistics2") -// public Result<?> costStatistics2(@RequestBody Map<String, Object> data) throws Exception { -// CostStatisticsDto costStatisticsDto = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), CostStatisticsDto.class); -// return Result.success(insOrderService.costStatistics2(costStatisticsDto)); -// } -// -// -// @ApiOperation(value = "鏍峰搧缂洪櫡鎸囨暟") -// @PostMapping("/selectSampleDefects") -// public Result selectSampleDefects(Integer size, Integer current, String inspectionItems, String orderNumber) { -// return Result.success(insOrderService.selectSampleDefects(new Page<>(current, size),inspectionItems, orderNumber)); -// } -// -// -// @ApiOperation(value = "鎾ら攢") -// @PutMapping("/updateStatus") -// public Result<?> updateStatus(Integer id) { -// insOrderService.updateStatus(id); -// return Result.success(); -// } -// -// //寰呮鐨勬挙閿�鐨勬煡璇㈠緟妫�椤圭洰 -// @PostMapping("/selectNoProducts") -// public Result<?> selectNoProducts(@RequestBody Map<String, Object> data,Integer orderId ,String ids) throws Exception { -// Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); -// InsProduct insProduct = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), InsProduct.class); -// return Result.success(insProductService.selectNoProducts(page, insProduct,orderId,ids)); -// } -// -// -// @ApiOperation(value = "寰呮鐨勬挙閿�") -// @PutMapping("/updateInspected") -// public Result<?> updateInspected(Integer orderId, String ids, -// @RequestParam(value = "typeSource",required = false) Integer typeSource, -// @RequestParam(value = "ifsInventoryId",required = false) Integer ifsInventoryId){ -// if(Objects.nonNull(typeSource) && typeSource == 1){ -// ifsInventoryQuantityMapper.update(null,new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getState,0) -// .eq(IfsInventoryQuantity::getId,ifsInventoryId)); -// insOrderService.update(null,new LambdaUpdateWrapper<InsOrder>().set(InsOrder::getState,-1).eq(InsOrder::getId,orderId)); // 鎾ら攢 -// } -// insProductService.updateInspected(orderId,ids); -// return Result.success(); -// } -// -// @ApiOperation(value = "瀹℃牳寰呮鎾ら攢") -// @PostMapping("/checkUpdate") -// public Result<?> checkUpdate(Integer orderId,Integer state){ -// insProductService.checkUpdate(orderId,state); -// return Result.success(); -// } -// -// @ApiOperation(value = "鏍囩鎵撳嵃") -// @PostMapping("/labelPrinting") -// public Result<?> labelPrinting(String ids) { -// return Result.success(insOrderService.labelPrinting(ids)); -// } -// -// -// @ApiOperation(value = "璐圭敤缁熻瀵煎嚭") -// @PostMapping("/export") -// public void export(@RequestBody Map<String, Object> data,HttpServletResponse response) throws Exception { -// CostStatisticsDto costStatisticsDto = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), CostStatisticsDto.class); -// insOrderService.export(costStatisticsDto,response); -// } -// -// -// @ApiOperation(value = "鑾峰彇ifs璁㈠崟") -// @PostMapping("/getIfsOrder") -// public Result<?> getIfsOrder() { -// insOrderService.getIfsOrder(); -// return Result.success(); -// } -// -// @Scheduled(fixedDelay = 1200000) -// public void getIfsOrderTiming() { -// insOrderService.getIfsOrder(); -// } -// -// -// @ApiOperation(value = "淇敼璁㈠崟鍗曞彿") -// @PostMapping("/updateEntrustCode") -// public Result<?> updateEntrustCode(@RequestBody InsOrder insOrder) { -// insOrderService.updateEntrustCode(insOrder); -// return Result.success(); -// } -// -// @ApiOperation("鏌ヨ涓嶅悎鏍煎娴嬩俊鎭�") -// @GetMapping("/getRetestResult") -// public Result<?> getRetestResult(Integer insProductId) { -// return Result.success(insOrderService.getRetestResult(insProductId)); -// } -// -// -// -// @ApiOperation(value = "閾滃崟涓濅笅鍗�") -// @PostMapping("/addRawCopperOrder") -// public Result<?> addRawCopperOrder(String str) { -// Map<String, Object> map = JSON.parseObject(str, Map.class); -// JSONArray jsonArray = JSON.parseArray(map.get("list")+""); -// List<SampleProductDto> list = jsonArray.toJavaList(SampleProductDto.class); -// CopperInsOrderDto CopperInsOrder = JSON.parseObject(JSON.toJSONString(map.get("insOrder")), CopperInsOrderDto.class); -// return Result.success(insOrderService.addRawCopperOrder(list, CopperInsOrder)); -// } -// -// -// @ApiOperation(value = "淇敼濮旀墭缂栧彿") -// @PostMapping("/updateOrderEntrustCode") -// public Result<?> updateOrderEntrustCode(@RequestBody InsOrder insOrder) { -// insOrderService.updateOrderEntrustCode(insOrder); -// return Result.success(); -// } -// -// @ApiOperation(value = "淇敼妫�楠屼笅鍗曞唴瀹�") -// @PostMapping("/updateInsOrder") -// public Result<?> updateInsOrder(@RequestBody InsOrderUpdateDto insOrderUpdateDto) { -// return Result.success(insOrderService.updateInsOrder(insOrderUpdateDto)); -// } -// -// @ApiOperation(value = "鍒犻櫎閫�鍥炶鍗�") -// @GetMapping("/delInsOrder") -// public Result<?> delInsOrder(Integer insOrderId) { -// // 鏌ヨ璁㈠崟 -// InsOrder order = insOrderService.getById(insOrderId); -// if (!order.getState().equals(2)) { -// throw new ErrorException("鍙湁閫�鍥炶鍗曟墠鑳藉垹闄�"); -// } -// -// return Result.success(insOrderService.removeById(insOrderId)); -// } -// -// @ApiOperation(value = "鎴愬搧鏍囩鎵撳嵃") -// @PostMapping("/labelOrderPrinting") -// public Result<List<InsOrderPrintingVo>> labelOrderPrinting(@RequestBody Map<String, Object> param) { -// List<Integer> ids = (List<Integer>) param.get("ids"); -// return Result.success(insOrderService.labelOrderPrinting(ids)); -// } -// -// @ApiOperation(value = "鏍规嵁璁㈠崟id鏌ヨ鏍峰搧") -// @GetMapping("/getSampleByOrderId") -// public Result<List<InsSample>> getSampleByOrderId(Integer insOrderId) { -// return Result.success(insSampleService.list(Wrappers.<InsSample>lambdaQuery() -// .eq(InsSample::getInsOrderId, insOrderId))); -// } -// -// @ApiOperation(value = "鏍规嵁鏍峰搧id鏌ヨ妫�楠岄」鏍�") -// @GetMapping("/getProductTreeBySampleId") -// public Result<List<StandardProductList>> getProductTreeBySampleId(Integer insSampleId) { -// return Result.success(insOrderService.getProductTreeBySampleId(insSampleId)); -// } -// -// -// @ApiOperation(value = "娣诲姞閬楁紡鐨勬楠岄」") -// @PostMapping("/addOmitOrderProduct") -// public Result addOmitOrderProduct(@RequestBody OmitOrderProductDto omitOrderProductDto) { -// return Result.success(insOrderService.addOmitOrderProduct(omitOrderProductDto)); -// } -// -// @ApiOperation(value = "鎴愬搧妫�楠屽崟鍏ㄩ儴淇℃伅瀵煎嚭") -// @PostMapping("/rawAllInsOrderExport") -// public void rawAllInsOrderExport(@RequestBody SampleOrderDto sampleOrderDto, HttpServletResponse response){ -// insOrderService.rawAllInsOrderExport(sampleOrderDto,response); -// } -// -//} +package com.ruoyi.basic.controller; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; +import com.ruoyi.basic.pojo.IfsInventoryQuantity; +import com.ruoyi.basic.pojo.StandardProductList; +import com.ruoyi.common.core.domain.Result; +import com.ruoyi.common.utils.JackSonUtil; +import com.ruoyi.framework.exception.ErrorException; +import com.ruoyi.inspect.dto.*; +import com.ruoyi.inspect.pojo.InsOrder; +import com.ruoyi.inspect.pojo.InsOrderTemplate; +import com.ruoyi.inspect.pojo.InsProduct; +import com.ruoyi.inspect.pojo.InsSample; +import com.ruoyi.inspect.service.InsOrderService; +import com.ruoyi.inspect.service.InsOrderTemplateService; +import com.ruoyi.inspect.service.InsProductService; +import com.ruoyi.inspect.service.InsSampleService; +import com.ruoyi.inspect.vo.InsOrderPrintingVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@RestController +@AllArgsConstructor +@RequestMapping("/insOrder") +@Api(tags="妫�楠屽崟妯″潡") +public class InsOrderController { + + private InsOrderService insOrderService; + + private InsSampleService insSampleService; + + private InsProductService insProductService; + + private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; + + private InsOrderTemplateService insOrderTemplateService; + + //鑾峰彇妫�楠屼笅鍗曟暟鎹� + @ApiOperation(value = "鏌ヨ鍗曚綅妫�楠屽崟") + @GetMapping("/selectInsOrderParameter") + public Result selectInsOrderParameter(Page page, SampleOrderDto sampleOrderDto) throws Exception { + return Result.success(insOrderService.selectInsOrderParameter(page, sampleOrderDto)); + } + + //鐢ㄤ簬妫�楠屼笅鍗曞尯鍒煡鐪嬫墍鏈夎鍗曞拰鍙煡鐪嬪悓涓�涓鎵樺崟浣嶇殑璁㈠崟 + @ApiOperation(value = "鏌ヨ鎵�鏈夋楠屽崟") + @GetMapping("/selectAllInsOrderParameter") + public Result selectAllInsOrderParameter() { + return Result.success(); + } + + + @ApiOperation(value = "妫�楠屽垎閰�") + @PostMapping("/upInsOrder") + public Result<?> upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId,String sonLaboratory) { + return Result.success(insOrderService.upInsOrder(orderId, sampleId, appointed, userId,sonLaboratory)); + } + + //todo: 涓嬪崟闇�瑕佷慨鏀� + @ApiOperation(value = "娣诲姞妫�楠屼笅鍗曟暟鎹�") + @PostMapping("/addInsOrder") + public Result<?> addInsOrder(String str) { + Map<String, Object> map = JSON.parseObject(str, Map.class); + JSONArray jsonArray = JSON.parseArray(map.get("list")+""); + List<SampleProductDto> list = jsonArray.toJavaList(SampleProductDto.class); + InsOrder insOrder = JSON.parseObject(JSON.toJSONString(map.get("insOrder")), InsOrder.class); + List<List<Integer>> pairing = JSON.parseArray(map.get("pairing")+""); + return Result.success(insOrderService.addInsOrder(list, insOrder, pairing)); + } + + @ApiOperation(value = "鏌ヨ璁㈠崟鏈�闀块璁℃椂闂�") + @GetMapping("/selectOrderManDay") + public Result<?> selectOrderManDay(Integer id) { + int day = insProductService.selectOrderManDay(id); + return Result.success("鎴愬姛", LocalDateTime.now().plusHours(day).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); + } + + @ApiOperation(value = "鏌ヨ妫�楠屼笅鍗曞唴瀹硅鎯�") + @GetMapping("/getInsOrder") + public Result<?> getInsOrder(Integer orderId) { + return Result.success(insOrderService.getInsOrder(orderId)); + } + + @ApiOperation(value = "瀹℃牳妫�楠屽崟杩涜鐘舵�佷慨鏀�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "妫�楠屽崟id", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "state", value = "瀹℃牳缁撴灉 1:閫氳繃 2锛氫笉閫氳繃", dataTypeClass = Integer.class) + }) + + @PostMapping("/upInsOrderOfState") + public Result<?> upInsOrderOfState(@RequestBody InsOrder insOrder) { + return Result.success(insOrderService.upInsOrderOfState(insOrder)); + } + + @ApiOperation(value = "娣诲姞妫�楠屽崟妯℃澘") + @PostMapping("/addInsOrderTemplate") + public Result<?> addInsOrderTemplate(@RequestBody InsOrderTemplate insOrderTemplate) { + return Result.success(insOrderTemplateService.addInsOrderTemplate(insOrderTemplate)); + } + + @ApiOperation(value = "鏌ヨ妫�楠屽崟妯℃澘") + @GetMapping("/selectInsOrderTemplate") + public Result<?> selectInsOrderTemplate(String company) { + return Result.success(insOrderTemplateService.selectInsOrderTemplate(company)); + } + + @ApiOperation(value = "閫氳繃妫�楠屽崟妯℃澘id鑾峰彇妫�楠屽崟妯℃澘鍐呭") + @GetMapping("/selectInsOrderTemplateById") + public Result<?> selectInsOrderTemplateById(Integer id) { + return Result.success("鎴愬姛", insOrderTemplateService.selectInsOrderTemplateById(id)); + } + + @ApiOperation(value = "鍒犻櫎妫�楠屽崟妯℃澘") + @DeleteMapping("/delInsOrderTemplate") + public Result<?> delInsOrderTemplate(Integer id) { + return Result.success(insOrderTemplateService.delInsOrderTemplate(id)); + } + + @ApiOperation(value = "閫氳繃妫�楠屽崟鏌ヨ妫�楠屾暟鎹紙鏁版嵁鏌ョ湅锛�") + @GetMapping("/selectSampleAndProductByOrderId") + public Result<?> selectSampleAndProductByOrderId(Page page, SampleProductDto2 sampleProductDto){ + return Result.success(insOrderService.selectSampleAndProductByOrderId(page, sampleProductDto)); + } + + @ApiOperation(value = "璐圭敤缁熻") + @GetMapping("/costStatistics") + public Result<?> costStatistics(Page page, CostStatisticsDto costStatisticsDto){ + return Result.success(insOrderService.costStatistics(page, costStatisticsDto)); + } + + @ApiOperation(value = "璐圭敤缁熻鑾峰彇鎬讳环") + @GetMapping("/costStatistics2") + public Result<?> costStatistics2(CostStatisticsDto costStatisticsDto){ + return Result.success(insOrderService.costStatistics2(costStatisticsDto)); + } + + + @ApiOperation(value = "鏍峰搧缂洪櫡鎸囨暟") + @GetMapping("/selectSampleDefects") + public Result selectSampleDefects(Integer size, Integer current, String inspectionItems, String orderNumber) { + return Result.success(insOrderService.selectSampleDefects(new Page<>(current, size),inspectionItems, orderNumber)); + } + + + @ApiOperation(value = "鎾ら攢") + @PostMapping("/updateStatus") + public Result<?> updateStatus(@RequestBody Map<String, Object> param) { + Integer id = (Integer) param.get("id"); + insOrderService.updateStatus(id); + return Result.success(); + } + + //寰呮鐨勬挙閿�鐨勬煡璇㈠緟妫�椤圭洰 + @GetMapping("/selectNoProducts") + public Result<?> selectNoProducts(Page page, InsProduct insProduct,Integer orderId ,String ids){ + return Result.success(insProductService.selectNoProducts(page, insProduct,orderId,ids)); + } + + + @ApiOperation(value = "寰呮鐨勬挙閿�") + @PostMapping("/updateInspected") + public Result<?> updateInspected(@RequestBody Map<String, Object> param){ + Integer orderId = (Integer) param.get("orderId"); + String ids = (String) param.get("ids"); + Integer typeSource = (Integer) param.get("typeSource"); + Integer ifsInventoryId = (Integer) param.get("ifsInventoryId"); + if(Objects.nonNull(typeSource) && typeSource == 1){ + ifsInventoryQuantityMapper.update(null,new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getState,0) + .eq(IfsInventoryQuantity::getId,ifsInventoryId)); + insOrderService.update(null,new LambdaUpdateWrapper<InsOrder>().set(InsOrder::getState,-1).eq(InsOrder::getId,orderId)); // 鎾ら攢 + } + insProductService.updateInspected(orderId,ids); + return Result.success(); + } + + @ApiOperation(value = "瀹℃牳寰呮鎾ら攢") + @PostMapping("/checkUpdate") + public Result<?> checkUpdate(@RequestBody Map<String, Object> param){ + Integer orderId = (Integer) param.get("orderId"); + Integer state = (Integer) param.get("state"); + insProductService.checkUpdate(orderId,state); + return Result.success(); + } + + + @ApiOperation(value = "璐圭敤缁熻瀵煎嚭") + @GetMapping("/export") + public void export(CostStatisticsDto costStatisticsDto,HttpServletResponse response) throws ServletException, IOException { + insOrderService.export(costStatisticsDto,response); + } + + + @ApiOperation(value = "鑾峰彇ifs璁㈠崟") + @GetMapping("/getIfsOrder") + public Result<?> getIfsOrder() { + insOrderService.getIfsOrder(); + return Result.success(); + } + + @Scheduled(fixedDelay = 1200000) + public void getIfsOrderTiming() { + insOrderService.getIfsOrder(); + } + + + @ApiOperation(value = "淇敼璁㈠崟鍗曞彿") + @PostMapping("/updateEntrustCode") + public Result<?> updateEntrustCode(@RequestBody InsOrder insOrder) { + insOrderService.updateEntrustCode(insOrder); + return Result.success(); + } + + @ApiOperation("鏌ヨ涓嶅悎鏍煎娴嬩俊鎭�") + @GetMapping("/getRetestResult") + public Result<?> getRetestResult(Integer insProductId) { + return Result.success(insOrderService.getRetestResult(insProductId)); + } + + + + @ApiOperation(value = "閾滃崟涓濅笅鍗�") + @PostMapping("/addRawCopperOrder") + public Result<?> addRawCopperOrder(String str) { + Map<String, Object> map = JSON.parseObject(str, Map.class); + JSONArray jsonArray = JSON.parseArray(map.get("list")+""); + List<SampleProductDto> list = jsonArray.toJavaList(SampleProductDto.class); + CopperInsOrderDto CopperInsOrder = JSON.parseObject(JSON.toJSONString(map.get("insOrder")), CopperInsOrderDto.class); + return Result.success(insOrderService.addRawCopperOrder(list, CopperInsOrder)); + } + + + @ApiOperation(value = "淇敼濮旀墭缂栧彿") + @PostMapping("/updateOrderEntrustCode") + public Result<?> updateOrderEntrustCode(@RequestBody InsOrder insOrder) { + insOrderService.updateOrderEntrustCode(insOrder); + return Result.success(); + } + + @ApiOperation(value = "淇敼妫�楠屼笅鍗曞唴瀹�") + @PostMapping("/updateInsOrder") + public Result<?> updateInsOrder(@RequestBody InsOrderUpdateDto insOrderUpdateDto) { + return Result.success(insOrderService.updateInsOrder(insOrderUpdateDto)); + } + + @ApiOperation(value = "鍒犻櫎閫�鍥炶鍗�") + @GetMapping("/delInsOrder") + public Result<?> delInsOrder(Integer insOrderId) { + // 鏌ヨ璁㈠崟 + InsOrder order = insOrderService.getById(insOrderId); + if (!order.getState().equals(2)) { + throw new ErrorException("鍙湁閫�鍥炶鍗曟墠鑳藉垹闄�"); + } + + return Result.success(insOrderService.removeById(insOrderId)); + } + + @ApiOperation(value = "鎴愬搧鏍囩鎵撳嵃") + @PostMapping("/labelOrderPrinting") + public Result<List<InsOrderPrintingVo>> labelOrderPrinting(@RequestBody Map<String, Object> param) { + List<Integer> ids = (List<Integer>) param.get("ids"); + return Result.success(insOrderService.labelOrderPrinting(ids)); + } + + @ApiOperation(value = "鏍规嵁璁㈠崟id鏌ヨ鏍峰搧") + @GetMapping("/getSampleByOrderId") + public Result<List<InsSample>> getSampleByOrderId(Integer insOrderId) { + return Result.success(insSampleService.list(Wrappers.<InsSample>lambdaQuery() + .eq(InsSample::getInsOrderId, insOrderId))); + } + + @ApiOperation(value = "鏍规嵁鏍峰搧id鏌ヨ妫�楠岄」鏍�") + @GetMapping("/getProductTreeBySampleId") + public Result<List<StandardProductList>> getProductTreeBySampleId(Integer insSampleId) { + return Result.success(insOrderService.getProductTreeBySampleId(insSampleId)); + } + + + @ApiOperation(value = "娣诲姞閬楁紡鐨勬楠岄」") + @PostMapping("/addOmitOrderProduct") + public Result addOmitOrderProduct(@RequestBody OmitOrderProductDto omitOrderProductDto) { + return Result.success(insOrderService.addOmitOrderProduct(omitOrderProductDto)); + } + + @ApiOperation(value = "鎴愬搧妫�楠屽崟鍏ㄩ儴淇℃伅瀵煎嚭") + @PostMapping("/rawAllInsOrderExport") + public void rawAllInsOrderExport(@RequestBody SampleOrderDto sampleOrderDto, HttpServletResponse response){ + insOrderService.rawAllInsOrderExport(sampleOrderDto,response); + } + +} diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/controller/RawMaterialOrderController.java b/inspect-server/src/main/java/com/ruoyi/inspect/controller/RawMaterialOrderController.java index eb03d93..5ec41ee 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/controller/RawMaterialOrderController.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/RawMaterialOrderController.java @@ -1,317 +1,311 @@ -//package com.ruoyi.inspect.controller; -// -//import com.alibaba.fastjson.JSON; -//import com.alibaba.fastjson.JSONArray; -//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.ruoyi.basic.dto.*; -//import com.ruoyi.basic.pojo.IfsInventoryQuantity; -//import com.ruoyi.inspect.dto.SampleProductDto; -//import com.ruoyi.inspect.pojo.InsOrder; -//import com.ruoyi.inspect.pojo.RawMaterialOrderTemplate; -//import com.ruoyi.inspect.service.RawMaterialOrderService; -//import com.ruoyi.inspect.service.RawMaterialOrderTemplateService; -//import com.ruoyi.common.core.domain.Result; -//import com.ruoyi.common.utils.JackSonUtil; -//import com.ruoyi.common.utils.WxCpUtils; -//import com.ruoyi.inspect.dto.CopperInsOrderDto; -//import io.swagger.annotations.Api; -//import io.swagger.annotations.ApiOperation; -//import lombok.AllArgsConstructor; -//import org.springframework.web.bind.annotation.*; -// -//import javax.servlet.http.HttpServletResponse; -//import java.io.File; -//import java.util.List; -//import java.util.Map; -// -///** -// * @Author zhuo -// * @Date 2024/7/31 -// */ -//@RequestMapping("/rawMaterialOrder") -//@RestController -//@AllArgsConstructor -//@Api(tags = "鍘熸潗鏂欎笅鍗�") -//public class RawMaterialOrderController { -// -// private RawMaterialOrderService rawMaterialOrderService; -// private RawMaterialOrderTemplateService rawMaterialOrderTemplateService; -// -// @ApiOperation(value = "鏇村叿闆朵欢鍙疯幏鍙栨爣鍑嗘爲") -// @GetMapping("/selectStandardTreeListByPartNo") -// public Result selectStandardTreeListByPartNo(String partNo) { -// return Result.success(rawMaterialOrderService.selectStandardTreeListByPartNo(partNo)); -// } -// -// @ApiOperation(value = "鍘熸潗鏂欐楠屾煡璇唬涓嬪崟") -// @GetMapping("/getPurchaseOrder") -// public Result getPurchaseOrder(Page page, IfsInventoryQuantityCheckDto ifsInventoryQuantity){ -// return Result.success(rawMaterialOrderService.selectIfsInventoryQuantity(page, ifsInventoryQuantity)); -// } -// -// @ApiOperation(value = "鍘熸潗鏂欐楠屾煡璇㈡楠屼腑") -// @GetMapping("/getIfsByStateOne") -// public Result getIfsByStateOne(Page page, IfsInventoryQuantityDto ifsInventoryQuantityDto) throws Exception { -// return Result.success(rawMaterialOrderService.getIfsByStateOne(page, ifsInventoryQuantityDto)); -// } -// -// @ApiOperation(value = "鍘熸潗鏂欐楠屾煡璇㈠凡妫�楠�") -// @GetMapping("/getIfsByOver") -// public Result getIfsByOver(Page page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto) throws Exception { -// return Result.success(rawMaterialOrderService.getIfsByOver(page, ifsInventoryQuantityDto)); -// } -// -// @ApiOperation(value = "娣诲姞鍘熸潗鏂欐楠屽崟妯℃澘") -// @PostMapping("/addRawMaterOrderTemplate") -// public Result<?> addRawMaterOrderTemplate(@RequestBody RawMaterialOrderTemplate rawMaterialOrderTemplate) { -// return Result.success(rawMaterialOrderTemplateService.addRawMaterOrderTemplate(rawMaterialOrderTemplate)); -// } -// @ApiOperation(value = "鏌ヨ鍘熸潗鏂欐楠屽崟妯℃澘鍒楄〃") -// @GetMapping("/selectRawMaterOrderTemplate") -// public Result<?> selectRawMaterOrderTemplate(String partNo) { -// return Result.success(rawMaterialOrderTemplateService.selectRawMaterOrderTemplate(partNo)); -// } -// -// @ApiOperation(value = "閫氳繃鍘熸潗鏂欐楠屽崟妯℃澘id鑾峰彇妫�楠屽崟妯℃澘鍐呭") -// @GetMapping("/selectRawMaterOrderTemplateById") -// public Result<?> selectRawMaterOrderTemplateById(Integer id) { -// return Result.success("鎴愬姛", rawMaterialOrderTemplateService.selectRawMaterOrderTemplateById(id)); -// } -// -// @ApiOperation(value = "鍒犻櫎鍘熸潗鏂欐楠屽崟妯℃澘") -// @PostMapping("/delRawMaterOrderTemplate") -// public Result<?> delRawMaterOrderTemplate(Integer id) { -// return Result.success(rawMaterialOrderTemplateService.delRawMaterOrderTemplate(id)); -// } -// -// -// /** -// * 鎶ユ鎵归噺 -// * @param param 鍘熸潗鏂檌d -// * @return -// */ -// @ApiOperation(value = "鎶ユ鎵归噺") -// @PostMapping("/inspectionReport") -// public Result<?> inspectionReport(@RequestBody Map<String, Object> param) { -// List<Integer> ids = (List<Integer>) param.get("ids"); -// return Result.success(rawMaterialOrderService.inspectionReport(ids)); -// } -// -// /** -// * 鍙栨秷鎶ユ -// * @param id 鍘熸潗鏂欎笅鍗� -// * @return -// */ -// @ApiOperation(value = "鎾ら攢鎶ユ") -// @PostMapping("/revokeInspectionReport") -// public Result<?> revokeInspectionReport(Integer id) { -// return Result.success(rawMaterialOrderService.revokeInspectionReport(id)); -// } -// -// /** -// * 鎵撳嵃鏍囩鏌ヨ -// * @param param 鍘熸潗鏂檌d -// * @return -// */ -// @ApiOperation(value = "鎵撳嵃鏍囩鏌ヨ") -// @PostMapping("/printLabel") -// public Result<?> printLabel(@RequestBody Map<String, Object> param) { -// List<Integer> ids = (List<Integer>) param.get("ids"); -// return Result.success(rawMaterialOrderService.printLabel(ids)); -// } -// -// /** -// * 鎶ユ -// * @param ifsInventoryQuantity 鍘熸潗鏂� -// * @return -// */ -// @ApiOperation(value = "鎶ユ") -// @PostMapping("/inspectionReportOne") -// public Result<?> inspectionReportOne(@RequestBody IfsInventoryQuantity ifsInventoryQuantity) { -// -// return Result.success(rawMaterialOrderService.inspectionReportOne(ifsInventoryQuantity)); -// } -// -// /** -// * 鑾峰彇閾滀骇涓氶摼妫�娴嬫暟鎹� -// * @param id 鍘熸潗鏂檌d -// * @return -// */ -// @ApiOperation(value = "鑾峰彇閾滀骇涓氶摼妫�娴嬫暟鎹�") -// @GetMapping("/getIndustryChain") -// public Result<?> getIndustryChain(Integer id) { -// return Result.success("鎴愬姛", rawMaterialOrderService.getIndustryChain(id)); -// } -// -// /** -// * 鍘熸潗鏂欐挙閿� -// * @param ifsInventoryId -// * @return -// */ -// @ApiOperation(value = "鍘熸潗鏂欐挙閿�涓嬪崟") -// @PutMapping("/repealRawOrder") -// public Result<?> repealRawOrder(Integer ifsInventoryId){ -// return Result.success(rawMaterialOrderService.repealRawOrder(ifsInventoryId)); -// } -// -// -// @ApiOperation(value = "鍘熸潗鏂欎笅鍗曞厤妫�") -// @PostMapping("/addExemptionOrder") -// public Result<?> addExemptionOrder(String str) { -// Map<String, Object> map = JSON.parseObject(str, Map.class); -// JSONArray jsonArray = JSON.parseArray(map.get("list")+""); -// List<SampleProductDto> list = jsonArray.toJavaList(SampleProductDto.class); -// InsOrder insOrder = JSON.parseObject(JSON.toJSONString(map.get("insOrder")), InsOrder.class); -// return Result.success(rawMaterialOrderService.addExemptionOrder(list, insOrder)); -// } -// -// -// @ApiOperation(value = "浠撳簱鎶ユ鏌ヨ") -// @PostMapping("/getWarehouseSubmit") -// public Result getWarehouseSubmit(Page page, IfsInventoryQuantity ifsInventoryQuantity) throws Exception { -// return Result.success(rawMaterialOrderService.getWarehouseSubmit(page, ifsInventoryQuantity)); -// } -// -// /** -// * 鍙栨秷鎶ユ -// * @param id 鍘熸潗鏂欎笅鍗� -// * @return -// */ -// @ApiOperation(value = "鍒犻櫎鍘熸潗鏂欐姤妫�淇℃伅") -// @PostMapping("/delIfsInventory") -// public Result<?> delIfsInventory(Integer id) { -// return Result.success(rawMaterialOrderService.delIfsInventory(id)); -// } -// -// /** -// * 鍘熸潗鏂欎笅鍗曟斁琛� -// * @param param -// * @return -// */ -// @ApiOperation(value = "鍘熸潗鏂欎笅鍗曟斁琛屽厤妫�") -// @PostMapping("/rawOrderRelease") -// public Result<?> rawOrderRelease(@RequestBody Map<String, Object> param){ -// Integer ifsInventoryId = (Integer) param.get("ifsInventoryId"); -// String partDetail = (String) param.get("partDetail"); -// return Result.success(rawMaterialOrderService.rawOrderRelease(ifsInventoryId, partDetail)); -// } -// -// /** -// * 鍘熸潗鏂欎笅鍗曢�氱煡鍏嶆鎴栬�呭娆℃楠� -// * @param ifsInventoryId -// * @return -// */ -// @ApiOperation(value = "鍘熸潗鏂欎笅鍗曢�氱煡鍏嶆鎴栬�呭娆℃楠�") -// @GetMapping("/notificationRawOrder") -// public Result<?> notificationRawOrder(Integer ifsInventoryId){ -// return Result.success(rawMaterialOrderService.notificationRawOrder(ifsInventoryId)); -// } -// -// -// @ApiOperation(value = "鍘熸潗鏂欐姤妫�鏌ヨ鍏ㄩ儴") -// @PostMapping("/getIfsByAll") -// public Result getIfsByAll(@RequestBody Map<String, Object> data) throws Exception { -// Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); -// IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), IfsInventoryQuantitySupplierDto.class); -// return Result.success(rawMaterialOrderService.getIfsByOver(page, ifsInventoryQuantityDto)); -// } -// -// -// @ApiOperation(value = "鏂板鍘熸潗鏂欐姤妫�淇℃伅") -// @PostMapping("/addIfsInventoryQuantity") -// public Result addIfsInventoryQuantity(@RequestBody IfsInventoryQuantity ifsInventoryQuantity) { -// rawMaterialOrderService.addIfsInventoryQuantity(ifsInventoryQuantity); -// return Result.success(); -// } -// -// @ApiOperation(value = "鍘熸潗鏂欎笅鍗曟煡鐪嬪凡瀹屾垚淇℃伅") -// @PostMapping("/getIfsByFinish") -// public Result getIfsByFinish(@RequestBody Map<String, Object> data) throws Exception { -// Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); -// IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), IfsInventoryQuantitySupplierDto.class); -// ifsInventoryQuantityDto.setIsFinish(1); -// return Result.success(rawMaterialOrderService.getIfsByOver(page, ifsInventoryQuantityDto)); -// } -// -// @ApiOperation(value = "娴嬭瘯绉诲簱") -// @PostMapping("/shiftingParking") -// public Result shiftingParking(@RequestBody List<Integer> ids){ -// rawMaterialOrderService.shiftingParking(ids); -// return Result.success(); -// } -// -// @ApiOperation(value = "寰俊鍙戦�佹枃浠舵祴璇�") -// @GetMapping("/wxSend") -// public Result wxSend(String user, String content, String filePath) throws Exception { -// WxCpUtils.inform(user, content, new File(filePath)); -// return Result.success(); -// } -// -// @ApiOperation(value = "閾滃崟涓濅笅鍗曞厤妫�") -// @PostMapping("/addRawCopperOrderExemptionOrder") -// public Result<?> addRawCopperOrderExemptionOrder(String str) { -// Map<String, Object> map = JSON.parseObject(str, Map.class); -// JSONArray jsonArray = JSON.parseArray(map.get("list")+""); -// List<SampleProductDto> list = jsonArray.toJavaList(SampleProductDto.class); -// CopperInsOrderDto CopperInsOrder = JSON.parseObject(JSON.toJSONString(map.get("insOrder")), CopperInsOrderDto.class); -// return Result.success(rawMaterialOrderService.addRawCopperOrderExemptionOrder(list, CopperInsOrder)); -// } -// -// /** -// * 璁╂鏀捐 -// * @param ifsInventoryId -// * @return -// */ -// @ApiOperation(value = "璁╂鏀捐") -// @PostMapping("/concessionRelease") -// public Result<?> concessionRelease(Integer ifsInventoryId){ -// return Result.success(rawMaterialOrderService.concessionRelease(ifsInventoryId)); -// } -// -// /** -// * 鍘熸潗鏂欒繘鍘傛挙閿�涓嬪崟 -// * @param enterOrderId -// * @return -// */ -// @ApiOperation(value = "鍘熸潗鏂欒繘鍘傛挙閿�涓嬪崟") -// @PostMapping("/repealEnterRawOrder") -// public Result<?> repealEnterRawOrder(Integer enterOrderId){ -// return Result.success(rawMaterialOrderService.repealEnterRawOrder(enterOrderId)); -// } -// -// /** -// * 鍘熸潗鏂欏搴︽挙閿�涓嬪崟 -// * @param quarterOrderId -// * @return -// */ -// @ApiOperation(value = "鍘熸潗鏂欏搴︽挙閿�涓嬪崟") -// @PostMapping("/repealQuarterRawOrder") -// public Result<?> repealQuarterRawOrder(Integer quarterOrderId){ -// return Result.success(rawMaterialOrderService.repealQuarterRawOrder(quarterOrderId)); -// } -// -// @ApiOperation(value = "鍏ㄩ儴淇℃伅瀵煎嚭") -// @PostMapping("/rawAllExport") -// public void rawAllExport(@RequestBody Map<String, Object> data, HttpServletResponse response) throws Exception { -// IfsInventoryQuantitySupplierDto dto = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), IfsInventoryQuantitySupplierDto.class); -// rawMaterialOrderService.rawAllExport(dto,response); -// } -// -// @ApiOperation(value = "鍘熸潗鏂欐楠屾煡璇㈠搴︽楠�") -// @GetMapping("/getIfsByQuarter") -// public Result getIfsByQuarter(Page page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto){ -// return Result.success(rawMaterialOrderService.getIfsByQuarter(page, ifsInventoryQuantityDto)); -// } -// -// /** -// * 鎻愬墠鍏ュ簱 -// * @param ifsInventoryId -// * @return -// */ -// @ApiOperation(value = "鎻愬墠鍏ュ簱") -// @PostMapping("/advancedGodown") -// public Result<?> advancedGodown(Integer ifsInventoryId){ -// return Result.success(rawMaterialOrderService.advancedGodown(ifsInventoryId)); -// } -// -//} +package com.ruoyi.inspect.controller; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.basic.dto.*; +import com.ruoyi.basic.pojo.IfsInventoryQuantity; +import com.ruoyi.inspect.dto.SampleProductDto; +import com.ruoyi.inspect.pojo.InsOrder; +import com.ruoyi.inspect.pojo.RawMaterialOrderTemplate; +import com.ruoyi.inspect.service.RawMaterialOrderService; +import com.ruoyi.inspect.service.RawMaterialOrderTemplateService; +import com.ruoyi.common.core.domain.Result; +import com.ruoyi.common.utils.JackSonUtil; +import com.ruoyi.common.utils.WxCpUtils; +import com.ruoyi.inspect.dto.CopperInsOrderDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.util.List; +import java.util.Map; + +/** + * @Author zhuo + * @Date 2024/7/31 + */ +@RequestMapping("/rawMaterialOrder") +@RestController +@AllArgsConstructor +@Api(tags = "鍘熸潗鏂欎笅鍗�") +public class RawMaterialOrderController { + + private RawMaterialOrderService rawMaterialOrderService; + private RawMaterialOrderTemplateService rawMaterialOrderTemplateService; + + @ApiOperation(value = "鏇村叿闆朵欢鍙疯幏鍙栨爣鍑嗘爲") + @GetMapping("/selectStandardTreeListByPartNo") + public Result selectStandardTreeListByPartNo(String partNo) { + return Result.success(rawMaterialOrderService.selectStandardTreeListByPartNo(partNo)); + } + + @ApiOperation(value = "鍘熸潗鏂欐楠屾煡璇唬涓嬪崟") + @GetMapping("/getPurchaseOrder") + public Result getPurchaseOrder(Page page, IfsInventoryQuantityCheckDto ifsInventoryQuantity){ + return Result.success(rawMaterialOrderService.selectIfsInventoryQuantity(page, ifsInventoryQuantity)); + } + + @ApiOperation(value = "鍘熸潗鏂欐楠屾煡璇㈡楠屼腑") + @GetMapping("/getIfsByStateOne") + public Result getIfsByStateOne(Page page, IfsInventoryQuantityDto ifsInventoryQuantityDto){ + return Result.success(rawMaterialOrderService.getIfsByStateOne(page, ifsInventoryQuantityDto)); + } + + @ApiOperation(value = "鍘熸潗鏂欐楠屾煡璇㈠凡妫�楠�") + @GetMapping("/getIfsByOver") + public Result getIfsByOver(Page page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto){ + return Result.success(rawMaterialOrderService.getIfsByOver(page, ifsInventoryQuantityDto)); + } + + @ApiOperation(value = "娣诲姞鍘熸潗鏂欐楠屽崟妯℃澘") + @PostMapping("/addRawMaterOrderTemplate") + public Result<?> addRawMaterOrderTemplate(@RequestBody RawMaterialOrderTemplate rawMaterialOrderTemplate) { + return Result.success(rawMaterialOrderTemplateService.addRawMaterOrderTemplate(rawMaterialOrderTemplate)); + } + @ApiOperation(value = "鏌ヨ鍘熸潗鏂欐楠屽崟妯℃澘鍒楄〃") + @GetMapping("/selectRawMaterOrderTemplate") + public Result<?> selectRawMaterOrderTemplate(String partNo) { + return Result.success(rawMaterialOrderTemplateService.selectRawMaterOrderTemplate(partNo)); + } + + @ApiOperation(value = "閫氳繃鍘熸潗鏂欐楠屽崟妯℃澘id鑾峰彇妫�楠屽崟妯℃澘鍐呭") + @GetMapping("/selectRawMaterOrderTemplateById") + public Result<?> selectRawMaterOrderTemplateById(Integer id) { + return Result.success("鎴愬姛", rawMaterialOrderTemplateService.selectRawMaterOrderTemplateById(id)); + } + + @ApiOperation(value = "鍒犻櫎鍘熸潗鏂欐楠屽崟妯℃澘") + @DeleteMapping("/delRawMaterOrderTemplate") + public Result<?> delRawMaterOrderTemplate(Integer id) { + return Result.success(rawMaterialOrderTemplateService.delRawMaterOrderTemplate(id)); + } + + + /** + * 鎶ユ鎵归噺 + * @param param 鍘熸潗鏂檌d + * @return + */ + @ApiOperation(value = "鎶ユ鎵归噺") + @PostMapping("/inspectionReport") + public Result<?> inspectionReport(@RequestBody Map<String, Object> param) { + List<Integer> ids = (List<Integer>) param.get("ids"); + return Result.success(rawMaterialOrderService.inspectionReport(ids)); + } + + /** + * 鍙栨秷鎶ユ + * @param param 鍘熸潗鏂欎笅鍗� + * @return + */ + @ApiOperation(value = "鎾ら攢鎶ユ") + @PostMapping("/revokeInspectionReport") + public Result<?> revokeInspectionReport(@RequestBody Map<String, Object> param) { + Integer id = (Integer) param.get("id"); + return Result.success(rawMaterialOrderService.revokeInspectionReport(id)); + } + + /** + * 鎵撳嵃鏍囩鏌ヨ + * @param param 鍘熸潗鏂檌d + * @return + */ + @ApiOperation(value = "鎵撳嵃鏍囩鏌ヨ") + @PostMapping("/printLabel") + public Result<?> printLabel(@RequestBody Map<String, Object> param) { + List<Integer> ids = (List<Integer>) param.get("ids"); + return Result.success(rawMaterialOrderService.printLabel(ids)); + } + + /** + * 鎶ユ + * @param ifsInventoryQuantity 鍘熸潗鏂� + * @return + */ + @ApiOperation(value = "鎶ユ") + @PostMapping("/inspectionReportOne") + public Result<?> inspectionReportOne(@RequestBody IfsInventoryQuantity ifsInventoryQuantity) { + + return Result.success(rawMaterialOrderService.inspectionReportOne(ifsInventoryQuantity)); + } + + /** + * 鑾峰彇閾滀骇涓氶摼妫�娴嬫暟鎹� + * @param id 鍘熸潗鏂檌d + * @return + */ + @ApiOperation(value = "鑾峰彇閾滀骇涓氶摼妫�娴嬫暟鎹�") + @GetMapping("/getIndustryChain") + public Result<?> getIndustryChain(Integer id) { + return Result.success("鎴愬姛", rawMaterialOrderService.getIndustryChain(id)); + } + + /** + * 鍘熸潗鏂欐挙閿� + * @param param + * @return + */ + @ApiOperation(value = "鍘熸潗鏂欐挙閿�涓嬪崟") + @GetMapping("/repealRawOrder") + public Result<?> repealRawOrder(@RequestBody Map<String, Object> param){ + Integer ifsInventoryId = (Integer) param.get("ifsInventoryId"); + return Result.success(rawMaterialOrderService.repealRawOrder(ifsInventoryId)); + } + + + @ApiOperation(value = "鍘熸潗鏂欎笅鍗曞厤妫�") + @PostMapping("/addExemptionOrder") + public Result<?> addExemptionOrder(String str) { + Map<String, Object> map = JSON.parseObject(str, Map.class); + JSONArray jsonArray = JSON.parseArray(map.get("list")+""); + List<SampleProductDto> list = jsonArray.toJavaList(SampleProductDto.class); + InsOrder insOrder = JSON.parseObject(JSON.toJSONString(map.get("insOrder")), InsOrder.class); + return Result.success(rawMaterialOrderService.addExemptionOrder(list, insOrder)); + } + + + @ApiOperation(value = "浠撳簱鎶ユ鏌ヨ") + @GetMapping("/getWarehouseSubmit") + public Result getWarehouseSubmit(Page page, IfsInventoryQuantity ifsInventoryQuantity) throws Exception { + return Result.success(rawMaterialOrderService.getWarehouseSubmit(page, ifsInventoryQuantity)); + } + + /** + * 鍙栨秷鎶ユ + * @param id 鍘熸潗鏂欎笅鍗� + * @return + */ + @ApiOperation(value = "鍒犻櫎鍘熸潗鏂欐姤妫�淇℃伅") + @DeleteMapping("/delIfsInventory") + public Result<?> delIfsInventory(Integer id) { + return Result.success(rawMaterialOrderService.delIfsInventory(id)); + } + + /** + * 鍘熸潗鏂欎笅鍗曟斁琛� + * @param param + * @return + */ + @ApiOperation(value = "鍘熸潗鏂欎笅鍗曟斁琛屽厤妫�") + @PostMapping("/rawOrderRelease") + public Result<?> rawOrderRelease(@RequestBody Map<String, Object> param){ + Integer ifsInventoryId = (Integer) param.get("ifsInventoryId"); + String partDetail = (String) param.get("partDetail"); + return Result.success(rawMaterialOrderService.rawOrderRelease(ifsInventoryId, partDetail)); + } + + /** + * 鍘熸潗鏂欎笅鍗曢�氱煡鍏嶆鎴栬�呭娆℃楠� + * @param ifsInventoryId + * @return + */ + @ApiOperation(value = "鍘熸潗鏂欎笅鍗曢�氱煡鍏嶆鎴栬�呭娆℃楠�") + @GetMapping("/notificationRawOrder") + public Result<?> notificationRawOrder(Integer ifsInventoryId){ + return Result.success(rawMaterialOrderService.notificationRawOrder(ifsInventoryId)); + } + + + @ApiOperation(value = "鍘熸潗鏂欐姤妫�鏌ヨ鍏ㄩ儴") + @GetMapping("/getIfsByAll") + public Result getIfsByAll(Page page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto){ + return Result.success(rawMaterialOrderService.getIfsByOver(page, ifsInventoryQuantityDto)); + } + + + @ApiOperation(value = "鏂板鍘熸潗鏂欐姤妫�淇℃伅") + @PostMapping("/addIfsInventoryQuantity") + public Result addIfsInventoryQuantity(@RequestBody IfsInventoryQuantity ifsInventoryQuantity) { + rawMaterialOrderService.addIfsInventoryQuantity(ifsInventoryQuantity); + return Result.success(); + } + + @ApiOperation(value = "鍘熸潗鏂欎笅鍗曟煡鐪嬪凡瀹屾垚淇℃伅") + @GetMapping("/getIfsByFinish") + public Result getIfsByFinish(Page page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto) throws Exception { + ifsInventoryQuantityDto.setIsFinish(1); + return Result.success(rawMaterialOrderService.getIfsByOver(page, ifsInventoryQuantityDto)); + } + + @ApiOperation(value = "寰俊鍙戦�佹枃浠舵祴璇�") + @GetMapping("/wxSend") + public Result wxSend(String user, String content, String filePath) throws Exception { + WxCpUtils.inform(user, content, new File(filePath)); + return Result.success(); + } + + @ApiOperation(value = "閾滃崟涓濅笅鍗曞厤妫�") + @PostMapping("/addRawCopperOrderExemptionOrder") + public Result<?> addRawCopperOrderExemptionOrder(String str) { + Map<String, Object> map = JSON.parseObject(str, Map.class); + JSONArray jsonArray = JSON.parseArray(map.get("list")+""); + List<SampleProductDto> list = jsonArray.toJavaList(SampleProductDto.class); + CopperInsOrderDto CopperInsOrder = JSON.parseObject(JSON.toJSONString(map.get("insOrder")), CopperInsOrderDto.class); + return Result.success(rawMaterialOrderService.addRawCopperOrderExemptionOrder(list, CopperInsOrder)); + } + + /** + * 璁╂鏀捐 + * @param param + * @return + */ + @ApiOperation(value = "璁╂鏀捐") + @PostMapping("/concessionRelease") + public Result<?> concessionRelease(@RequestBody Map<String, Object> param){ + Integer ifsInventoryId = (Integer) param.get("ifsInventoryId"); + return Result.success(rawMaterialOrderService.concessionRelease(ifsInventoryId)); + } + + /** + * 鍘熸潗鏂欒繘鍘傛挙閿�涓嬪崟 + * @param param + * @return + */ + @ApiOperation(value = "鍘熸潗鏂欒繘鍘傛挙閿�涓嬪崟") + @PostMapping("/repealEnterRawOrder") + public Result<?> repealEnterRawOrder(@RequestBody Map<String, Object> param){ + Integer enterOrderId = (Integer) param.get("enterOrderId"); + return Result.success(rawMaterialOrderService.repealEnterRawOrder(enterOrderId)); + } + + /** + * 鍘熸潗鏂欏搴︽挙閿�涓嬪崟 + * @param param + * @return + */ + @ApiOperation(value = "鍘熸潗鏂欏搴︽挙閿�涓嬪崟") + @PostMapping("/repealQuarterRawOrder") + public Result<?> repealQuarterRawOrder(@RequestBody Map<String, Object> param){ + Integer quarterOrderId = (Integer) param.get("quarterOrderId"); + return Result.success(rawMaterialOrderService.repealQuarterRawOrder(quarterOrderId)); + } + + @ApiOperation(value = "鍏ㄩ儴淇℃伅瀵煎嚭") + @GetMapping("/rawAllExport") + public void rawAllExport(IfsInventoryQuantitySupplierDto dto, HttpServletResponse response) throws Exception { + rawMaterialOrderService.rawAllExport(dto,response); + } + + @ApiOperation(value = "鍘熸潗鏂欐楠屾煡璇㈠搴︽楠�") + @GetMapping("/getIfsByQuarter") + public Result getIfsByQuarter(Page page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto){ + return Result.success(rawMaterialOrderService.getIfsByQuarter(page, ifsInventoryQuantityDto)); + } + + /** + * 鎻愬墠鍏ュ簱 + * @param param + * @return + */ + @ApiOperation(value = "鎻愬墠鍏ュ簱") + @PostMapping("/advancedGodown") + public Result<?> advancedGodown(@RequestBody Map<String, Object> param){ + Integer ifsInventoryId = (Integer) param.get("ifsInventoryId"); + return Result.success(rawMaterialOrderService.advancedGodown(ifsInventoryId)); + } + +} diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/dto/UnqualifiedHandlerDto.java b/inspect-server/src/main/java/com/ruoyi/inspect/dto/UnqualifiedHandlerDto.java new file mode 100644 index 0000000..1b0d8e0 --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/dto/UnqualifiedHandlerDto.java @@ -0,0 +1,148 @@ +package com.ruoyi.inspect.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.inspect.pojo.InsUnqualifiedHandler; +import com.ruoyi.inspect.pojo.InsUnqualifiedHandlerFile; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +@Data +public class UnqualifiedHandlerDto extends InsUnqualifiedHandler implements Serializable { + + @ApiModelProperty("鍩�") + private String contract; + + @ApiModelProperty("璁㈠崟鍙�") + private String orderNo; + + @ApiModelProperty("琛屽彿") + private String lineNo; + + @ApiModelProperty("涓嬭揪鍙�") + private String releaseNo; + + @ApiModelProperty("鎺ユ敹鍙�") + private Integer receiptNo; + + @ApiModelProperty("闆朵欢鍙�") + private String partNo; + + @ApiModelProperty("闆朵欢鎻忚堪") + private String partDesc; + + @ApiModelProperty("鐘舵�佹弿杩�") + private String status; + + @ApiModelProperty("鐘舵��") + private String statusDB; + + @ApiModelProperty("鎶佃揪鐨勯噰璐暟閲�") + private BigDecimal qtyArrived; + + @ApiModelProperty("宸叉楠岀殑璐拱鏁伴噺") + private BigDecimal qtyInspected; + + @ApiModelProperty("瑕佹楠岀殑閲囪喘鏁伴噺") + private BigDecimal qtyToInspect; + + @ApiModelProperty("渚涘簲鍟嗙紪鍙�") + private String supplierId; + + @ApiModelProperty("渚涘簲鍟嗗悕绉�") + private String supplierName; + + @ApiModelProperty("鎶佃揪鐨勫簱瀛樻暟閲�") + private BigDecimal invQtyInStore; + + @ApiModelProperty("鎶佃揪鐨勯噰璐暟閲�") + private BigDecimal purQtyInStore; + + @ApiModelProperty("閰嶇疆鏍囪瘑") + private String configurationId; + + @ApiModelProperty("鎵瑰彿") + private String lotBatchNo; + + @ApiModelProperty("wdr鍙�") + private String waivDevRejNo; + + @ApiModelProperty("娲诲姩搴忓垪") + private String activitySeq; + + @ApiModelProperty("搴忓垪鍙�") + private String serialNo; + + @ApiModelProperty("搴撲綅鍙�") + private String locationNo; + + @ApiModelProperty("鐗堟湰鍙�") + private String engChgLevel; + + @ApiModelProperty("鎺ユ敹浜�") + private String receiver; + + @ApiModelProperty("鎺ユ敹浜哄鍚�") + private String receiverName; + + @ApiModelProperty("閲囪喘鍛�") + private String buyerCode; + + @ApiModelProperty("閲囪喘鍛樺鍚�") + private String buyerName; + + @ApiModelProperty("瀹為檯鍒拌揣鏃ユ湡") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime arriveDate; + + @ApiModelProperty("瀹為檯浜よ揣鏃ユ湡") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime deliveryDate; + + @ApiModelProperty("鐢熶骇鏃ユ湡") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime productDate; + + @ApiModelProperty("澶辨晥鏃ユ湡") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime invalidDate; + + + @ApiModelProperty("瀹℃壒鏃ユ湡") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime approvedDate; + + @ApiModelProperty("閲囪喘鐢宠鍒涘缓浜�") + private String reqCeater; + + @ApiModelProperty("閲囪喘鐢宠鍒涘缓浜哄鍚�") + private String reqCeaterName; + + @ApiModelProperty("閲囪喘璁㈠崟琛屽娉�") + private String lineRemarks; + + @ApiModelProperty("閲囪喘鍗曚綅") + private String buyUnitMeas; + + + private Integer isSource; + + private Integer number; + + private Integer state; + + @ApiModelProperty("鎺ユ敹鏃堕棿") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime receiverDate; + + + @ApiModelProperty("闄勪欢鍒楄〃") + private List<InsUnqualifiedHandlerFile> unqualifiedHandlerFiles; + + + +} diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderMapper.java b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderMapper.java index f637cc1..33b9e4c 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderMapper.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderMapper.java @@ -43,8 +43,6 @@ Long getCount(@Param("inspectionItems") String inspectionItems, @Param("orderNumber") String orderNumber); - String getEnumLabelByValue(String value); - String getStandardMethodCode(Integer id); int updateStatus( Integer id); diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderTemplateMapper.java b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderTemplateMapper.java new file mode 100644 index 0000000..6e064e5 --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderTemplateMapper.java @@ -0,0 +1,18 @@ +package com.ruoyi.inspect.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.inspect.pojo.InsOrderTemplate; + +/** +* @author Administrator +* @description 閽堝琛ㄣ�恑ns_order_template銆戠殑鏁版嵁搴撴搷浣淢apper +* @createDate 2024-03-18 14:14:54 +* @Entity com.yuanchu.mom.pojo.InsOrderTemplate +*/ +public interface InsOrderTemplateMapper extends BaseMapper<InsOrderTemplate> { + +} + + + + diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsUnqualifiedHandlerMapper.java b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsUnqualifiedHandlerMapper.java new file mode 100644 index 0000000..ad27c5c --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsUnqualifiedHandlerMapper.java @@ -0,0 +1,38 @@ +package com.ruoyi.inspect.mapper; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.ruoyi.inspect.dto.UnqualifiedHandlerDto; +import com.ruoyi.inspect.pojo.CommonOa; +import com.ruoyi.inspect.pojo.InsUnqualifiedHandler; +import com.ruoyi.inspect.vo.UnqualifiedHandlerVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** +* @author 27233 +* @description 閽堝琛ㄣ�恑ns_unqualified_handler(涓嶅悎鏍煎鐞嗚〃)銆戠殑鏁版嵁搴撴搷浣淢apper +* @createDate 2024-07-31 13:38:14 +* @Entity com.yuanchu.mom.pojo.InsUnqualifiedHandler +*/ +@Mapper +public interface InsUnqualifiedHandlerMapper extends BaseMapper<InsUnqualifiedHandler> { + + IPage<UnqualifiedHandlerVO> selectPageList(IPage<UnqualifiedHandlerVO> page, @Param("ew")QueryWrapper<UnqualifiedHandlerDto> ew); + + UnqualifiedHandlerVO findById(Long id); + + /** + * 鏌ョ湅oa娴佺▼ + * @param id + * @return + */ + List<CommonOa> getOaFlow(@Param("id") Integer id); +} + + + + diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/CommonOa.java b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/CommonOa.java new file mode 100644 index 0000000..3d8abb5 --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/CommonOa.java @@ -0,0 +1,61 @@ +package com.ruoyi.inspect.pojo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * oa瀹℃牳娴佺▼淇℃伅璁板綍琛� + * @TableName common_oa + */ +@TableName(value ="common_oa") +@Data +public class CommonOa implements Serializable { + /** + * 涓婚敭id + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 鑺傜偣鍚嶇О + */ + private String nodeName; + + /** + * 鎿嶄綔 + */ + private String operation; + + /** + * 瀹℃壒浜� + */ + private String approver; + + /** + * 瀹℃壒鏃ユ湡 + */ + private String approvalDate; + + /** + * 瀹℃壒鏃堕棿 + */ + private String approvalTime; + + /** + * 瀹℃壒鎰忚 + */ + private String approvalOpinion; + + /** + * 娴佺▼id + */ + private Long workflowId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/InsOrderTemplateService.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsOrderTemplateService.java new file mode 100644 index 0000000..03d6894 --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsOrderTemplateService.java @@ -0,0 +1,23 @@ +package com.ruoyi.inspect.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.inspect.pojo.InsOrderTemplate; + +import java.util.List; + +/** +* @author Administrator +* @description 閽堝琛ㄣ�恑ns_order_template銆戠殑鏁版嵁搴撴搷浣淪ervice +* @createDate 2024-03-18 14:14:54 +*/ +public interface InsOrderTemplateService extends IService<InsOrderTemplate> { + + int addInsOrderTemplate(InsOrderTemplate insOrderTemplate); + + List<InsOrderTemplate> selectInsOrderTemplate(String company); + + String selectInsOrderTemplateById(Integer id); + + int delInsOrderTemplate(Integer id); + +} diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/InsProductService.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsProductService.java index f1e6f22..078d393 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/InsProductService.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsProductService.java @@ -1,5 +1,6 @@ package com.ruoyi.inspect.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.inspect.dto.InsProductBindingDto; @@ -22,7 +23,7 @@ boolean write(InsOrder insOrder); - Map<String,Object> selectNoProducts(Page page, InsProduct insProduct,Integer orderId,String ids); + IPage<InsProduct> selectNoProducts(Page page, InsProduct insProduct, Integer orderId, String ids); void checkUpdate(Integer orderId,Integer state); diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/RawMaterialOrderService.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/RawMaterialOrderService.java index 6869015..4673df1 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/RawMaterialOrderService.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/RawMaterialOrderService.java @@ -95,7 +95,6 @@ */ void addIfsInventoryQuantity(IfsInventoryQuantity ifsInventoryQuantity); - void shiftingParking(List<Integer> ids); /** * 閾滃崟涓濅笅鍗曞厤妫� diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java index f70a18d..abb2686 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java @@ -1,1050 +1,1050 @@ -//package com.ruoyi.inspect.service.impl; -// -//import cn.hutool.core.collection.CollUtil; -//import cn.hutool.core.util.ObjectUtil; -//import cn.hutool.core.util.StrUtil; -//import cn.hutool.json.JSONUtil; -//import com.alibaba.excel.EasyExcel; -//import com.alibaba.excel.ExcelWriter; -//import com.alibaba.excel.write.metadata.WriteSheet; -//import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; -//import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; -//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -//import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -//import com.baomidou.mybatisplus.core.metadata.IPage; -//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; -//import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -//import com.baomidou.mybatisplus.core.toolkit.Wrappers; -//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -//import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; -//import com.ruoyi.basic.mapper.StandardProductListMapper; -//import com.ruoyi.basic.pojo.IfsInventoryQuantity; -//import com.ruoyi.basic.pojo.StandardProductList; -//import com.ruoyi.basic.pojo.StructureTestObject; -//import com.ruoyi.common.constant.InsOrderTypeConstants; -//import com.ruoyi.common.core.domain.entity.User; -//import com.ruoyi.common.numgen.NumberGenerator; -//import com.ruoyi.common.utils.*; -//import com.ruoyi.framework.exception.ErrorException; -//import com.ruoyi.inspect.dto.*; -//import com.ruoyi.inspect.mapper.*; -//import com.ruoyi.inspect.pojo.*; -//import com.ruoyi.inspect.service.InsOrderService; -//import com.ruoyi.inspect.service.InsProductService; -//import com.ruoyi.inspect.service.InsSampleService; -//import com.ruoyi.inspect.vo.InsOrderPrintingVo; -//import com.ruoyi.inspect.vo.SampleDefectsFatherVo; -//import com.ruoyi.system.mapper.CustomMapper; -//import com.ruoyi.system.mapper.UserMapper; -//import lombok.AllArgsConstructor; -//import org.apache.commons.lang3.StringUtils; -//import org.springframework.beans.BeanUtils; -//import org.springframework.stereotype.Service; -//import org.springframework.transaction.annotation.Transactional; -// -//import javax.servlet.http.HttpServletResponse; -//import java.io.IOException; -//import java.math.BigDecimal; -//import java.net.URLEncoder; -//import java.time.LocalDate; -//import java.time.LocalDateTime; -//import java.time.Month; -//import java.time.format.DateTimeFormatter; -//import java.util.*; -//import java.util.concurrent.atomic.AtomicInteger; -//import java.util.stream.Collectors; -// -///** -// * @author gaoaoy -// * @description 閽堝琛ㄣ�恑ns_order(妫�楠屼笅鍗�)銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇 -// * @createDate 2024-03-12 16:17:55 -// */ -//@Service -//@AllArgsConstructor -//public class InsOrderServiceImpl extends ServiceImpl<InsOrderMapper, InsOrder> -// implements InsOrderService { -// -// private InsOrderMapper insOrderMapper; -// private InsSampleService insSampleService; -// private InsSampleMapper insSampleMapper; -// private InsProductService insProductService; -// private InsProductMapper insProductMapper; -// private InsProductUserMapper insProductUserMapper; -// private InsSampleUserMapper insSampleUserMapper; -// private InsOrderStateMapper insOrderStateMapper; -// private UserMapper userMapper; -// private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; -// private CustomMapper customMapper; -// private final NumberGenerator<InsOrder> numberGenerator; -// private InsReportMapper insReportMapper; -// private InsUnqualifiedRetestProductMapper insUnqualifiedRetestProductMapper; -// private IfsApiUtils ifsApiUtils; -// private SpotCheckQuarterItemMapper spotCheckQuarterItemMapper; -// private StandardProductListMapper standardProductListMapper; -// -// -// -// //鑾峰彇妫�楠屼笅鍗曟暟鎹� -// @Override -// public IPage<SampleOrderDto> selectInsOrderParameter(IPage<InsOrder> page, SampleOrderDto sampleOrderDto) { -// //todo: 鍙湅鎴戝垽鏂叏閮�,涓汉,缁勭粐鐨勬潈闄� -// String laboratory = null; -// // 鍒ゆ柇鏄惁鏄叏閮� -// String isOrderAll = null; -// if (sampleOrderDto.getState() != null && sampleOrderDto.getState() == -2) { -// isOrderAll = "1"; -// sampleOrderDto.setState(null); -// } -// IPage<SampleOrderDto> sampleOrderDtoIPage = insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); -// return insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); -// } -// -// -// @Override -// @Transactional(rollbackFor = Exception.class) -// public int upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId, String sonLaboratory) { -// InsOrder insOrder = new InsOrder(); -// insOrder.setId(orderId); -// insOrder.setAppointed(StringUtils.isNotEmpty(appointed) ? LocalDate.parse(appointed) : null); -// insOrder.setSendTime(LocalDateTime.now()); -// insOrderMapper.updateById(insOrder); -// List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); -// List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList()); -// List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() -// .in(InsProduct::getInsSampleId, ids) -// .eq(InsProduct::getState, 1) -// .select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory)); -// for (InsProduct insProduct : insProducts) { -// InsOrderState insOrderState = new InsOrderState(); -// insOrderState.setInsOrderId(orderId); -// try { -// insOrderState.setLaboratory(insProduct.getSonLaboratory()); -// } catch (NullPointerException e) { -// throw new ErrorException("璇ユ楠屽崟鏈夋湭缁存姢瀹為獙瀹ょ殑妫�楠岄」鐩�"); -// } -// insOrderState.setInsState(0); -// insOrderStateMapper.insert(insOrderState); -// } -// if (userId != null) { -// InsSampleUser insSampleUser = new InsSampleUser(); -// insSampleUser.setState(0); -// insSampleUser.setUserId(userId); -// insSampleUser.setInsSampleId(orderId); -// insSampleUser.setSonLaboratory(sonLaboratory); -// insSampleUserMapper.insert(insSampleUser); -// } -// -// // 鍒ゆ柇璁㈠崟鏈夋病鏈夌粦瀹氭娊鏍疯鍒� -// InsOrder order = insOrderMapper.selectById(orderId); -// if (order.getQuarterItemId() != null) { -// // 闇�瑕佹坊鍔犱笅鍙戞椂闂村埌鎶芥牱鏃堕棿, 鍙栨牱浜哄憳灏辨槸妫�娴嬩汉 -// SpotCheckQuarterItem spotCheckQuarterItem = spotCheckQuarterItemMapper.selectById(order.getQuarterItemId()); -// spotCheckQuarterItem.setSpotCheckTime(order.getSendTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); -// User user = userMapper.selectById(userId); -// spotCheckQuarterItem.setSamplingUser(user.getName()); -// spotCheckQuarterItemMapper.updateById(spotCheckQuarterItem); -// } -// return 1; -// } -// -// @Override -// @Transactional(rollbackFor = Exception.class) -// public int addInsOrder(List<SampleProductDto> list, InsOrder insOrder, List<List<Integer>> pairing) { -// // todo: 涓嬪崟鍒ゆ柇鎶芥牱璁″垝鐨勫敮涓�鎬� -// if (insOrder.getQuarterItemId() != null) { -// Long quarterItemCount = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() -// .eq(InsOrder::getQuarterItemId, insOrder.getQuarterItemId()) -// .notIn(InsOrder::getState, -1 ,2 ,3)); -// if (quarterItemCount > 0) { -// throw new ErrorException("璇ユ娊鏍疯鍒掑凡琚粦瀹氳繃"); -// } -// } -// -// insOrder.setState(0); -// -// LocalDate appointed = insOrder.getAppointed(); -// -// insOrderMapper.insert(insOrder); // 涓昏〃 -// -// list.forEach(a -> { -// a.setId(null); -// a.setInsOrderId(insOrder.getId()); -// insSampleMapper.insert(a); -// if (ObjectUtil.isNotEmpty(a.getInsProduct())) { -// // 鍒ゆ柇鏄惁濉啓寰呮椤规暟閲� -// if (a.getQuantity() != null) { -// List<InsProduct> ip2 = new ArrayList<>(); -// for (Integer i = 1; i <= a.getQuantity(); i++) { -// // 閲嶆柊鎷疯礉 鍒涘缓鏂板璞� -// AtomicInteger atomicInteger = new AtomicInteger(i); -// List<InsProduct> insProducts = a.getInsProduct().stream().map(insProduct -> { -// insProduct.setRawMaterialTag(String.valueOf(atomicInteger.get())); -// InsProduct product = new InsProduct(); -// BeanUtils.copyProperties(insProduct, product); -// return product; -// }).collect(Collectors.toList()); -// -// ip2.addAll(insProducts); -// } -// addInsProductMethod(a.getId(), ip2); -// } else { -// addInsProductMethod(a.getId(), a.getInsProduct()); -// } -// } -// // 鍒ゆ柇鏄惁鏈夌數缂嗛厤缃� -// if (ObjectUtil.isNotEmpty(a.getInsulating())) { -// // 鍒ゆ柇鏄惁鏈夎緟鍔╃嚎鑺� -// if (ObjectUtil.isNotEmpty(a.getAuxiliaryWireCore())) { -// if (a.getAuxiliaryWireCore().getInsProduct().stream().filter(insProduct -> insProduct.getState() == 1).count() != -// a.getInsulating().getInsProduct().stream().filter(insProduct -> insProduct.getState() == 1).count()) { -// throw new ErrorException("鐢电紗閰嶇疆杈呭姪绾胯姱妫�楠岄」鏁伴噺涓嶇粺涓�, 璇锋鏌�"); -// } -// } -// List<InsProduct> ip2 = new ArrayList<>(); -// for (String s : a.getInsulating().getNum()) { -// // 閲嶆柊鎷疯礉 鍒涘缓鏂板璞� -// List<InsProduct> insProducts = a.getInsulating().getInsProduct().stream().map(insProduct -> { -// insProduct.setCableTag(s); -// InsProduct product = new InsProduct(); -// BeanUtils.copyProperties(insProduct, product); -// return product; -// }).collect(Collectors.toList()); -// ip2.addAll(insProducts); -// } -// for (InsProduct product : ip2) { -// product.setStandardMethodListId(a.getInsulating().getStandardMethodListId()); -// } -// addInsProductMethod(a.getId(), ip2); -// } -// // 鍒ゆ柇鏄惁鏈夎緟鍔╃嚎鑺� -// if (ObjectUtil.isNotEmpty(a.getAuxiliaryWireCore())) { -// List<InsProduct> ip2 = new ArrayList<>(); -// for (String s : a.getAuxiliaryWireCore().getNum()) { -// // 閲嶆柊鎷疯礉 鍒涘缓鏂板璞� -// List<InsProduct> insProducts = a.getAuxiliaryWireCore().getInsProduct().stream().map(insProduct -> { -// insProduct.setCableTag(s); -// InsProduct product = new InsProduct(); -// BeanUtils.copyProperties(insProduct, product); -// return product; -// }).collect(Collectors.toList()); -// ip2.addAll(insProducts); -// } -// for (InsProduct product : ip2) { -// product.setStandardMethodListId(a.getAuxiliaryWireCore().getStandardMethodListId()); -// } -// addInsProductMethod(a.getId(), ip2); -// } -// // 瀛愭牱鍝侀厤缃� -// if (ObjectUtil.isNotEmpty(a.getChildSampleList())) { -// for (SampleProductDto b : a.getChildSampleList()) { -// for (int i = 0; i < b.getNum(); i++) { -// b.setId(null); -// b.setInsOrderId(insOrder.getId()); -// b.setParentId(a.getId()); -// insSampleMapper.insert(b); -// if (ObjectUtil.isNotEmpty(b.getInsProduct())) { -// addInsProductMethod(b.getId(), b.getInsProduct()); -// } -// } -// } -// } -// }); -// //鏄惁涓哄師鏉愭枡涓嬪崟 -// if (insOrder.getTypeSource() != null && insOrder.getTypeSource().equals(1)) { -// // 鍘熸潗鏂欎笅鍗�: 濮旀墭浜哄氨鏄姤妫�浜�, 鐢熶骇鍗曚綅灏辨槸渚涘簲鍟嗗崟浣� -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(insOrder.getIfsInventoryId()); -// Integer declareUserId = ifsInventoryQuantity.getDeclareUserId(); -// User user = userMapper.selectById(declareUserId); -// if (user == null) { -// throw new ErrorException("缂哄皯鎶ユ浜轰俊鎭�"); -// } -// // 渚涘簲鍟嗗悕绉� -// insOrder.setProduction(ifsInventoryQuantity.getSupplierName()); -// insOrder.setProductionEn(""); -// // 濮旀墭浜哄悕绉� -// insOrder.setPrepareUserId(user.getId()); -// insOrder.setPrepareUser(user.getName()); -// insOrder.setPrepareUserEn(user.getNameEn()); -// insOrder.setPhone(user.getPhone()); -// insOrder.setState(1); -// Long count1 = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() -// .eq(InsOrder::getIfsInventoryId, insOrder.getIfsInventoryId()) -// .ne(InsOrder::getState, -1) -// .eq(InsOrder::getOrderType, InsOrderTypeConstants.ENTER_THE_FACTORY) -// .ne(InsOrder::getId, insOrder.getId())); -// // 鍒ゆ柇涔嬪墠鏄惁鏈夎繘鍘傛楠� -// if (count1 == 0) { -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>().set(IfsInventoryQuantity::getState, 1) -// .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); -// } -// -// // 鍒ゆ柇缁撴潫鐘舵�佷慨鏀瑰悎鏍肩姸鎬� -// if (ifsInventoryQuantity.getIsFinish().equals(0)) { -// ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() -// .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId()) -// .set(IfsInventoryQuantity::getInspectStatus, 0)); -// } -// -// upInsOrderOfState(insOrder); -// upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "鍘熸潗鏂�"); -// -// -// // 鏍规嵁闆朵欢鍙峰垽鏂槸鍚︽槸杈呮潗 -// boolean isRaw = false; -// StructureTestObject productObject = insOrderMapper.selectProductByPartNo(ifsInventoryQuantity.getPartNo()); -// // 鏌ヨ浜у搧 -// if (productObject != null && StrUtil.isNotBlank(productObject.getObjectType()) && productObject.getObjectType().equals("1")) { -// isRaw = true; -// } else { -// // 鏌ヨ瀵硅薄 -// StructureTestObject testObject = insOrderMapper.selectByPartNo(ifsInventoryQuantity.getPartNo()); -// if (testObject != null && StrUtil.isNotBlank(testObject.getObjectType()) && testObject.getObjectType().equals("1")) { -// isRaw = true; -// } -// } -// -// if (isRaw) { -// // 鑾峰彇褰撳墠瀛e害鐨勫紑濮嬫椂闂村拰缁撴潫鏃堕棿 -// LocalDateTime now = LocalDateTime.now(); -// // 鑾峰彇褰撳墠鏈堜唤 -// int month = now.getMonthValue(); -// // 纭畾褰撳墠瀛e害鐨勫紑濮嬫湀浠� -// int startMonth = (month - 1) / 3 * 3 + 1; -// // 鏋勯�犲搴︾殑寮�濮嬫椂闂� -// LocalDateTime startOfQuarter = LocalDateTime.of(now.getYear(), Month.of(startMonth), 1, 0, 0); -// // 璁$畻涓嬩竴涓搴︾殑寮�濮嬫椂闂� -// LocalDateTime startOfNextQuarter = startOfQuarter.plusMonths(3); -// // 璁$畻褰撳墠瀛e害鐨勭粨鏉熸椂闂� -// LocalDateTime endOfQuarter = startOfNextQuarter.minusSeconds(1); -// -// // 鏍规嵁涓嬪崟鐨勮鏍煎瀷鍙峰垽鏂槸鍚︿负瀛e害棣栨鍑虹幇 -// Integer count = ifsInventoryQuantityMapper.selectIsFirst(insOrder.getPartDetail(), -// ifsInventoryQuantity.getSupplierName(), -// startOfNextQuarter, -// endOfQuarter); -// -// if(count == 0) { -// ifsInventoryQuantity.setIsFirst(1); -// ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() -// .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId()) -// .set(IfsInventoryQuantity::getIsFirst, 1)); -// } -// } -// } -// return insOrder.getId(); -// } -// -// /** -// * 娣诲姞妫�楠岄」 -// * @param sampleId -// * @param productList -// */ -// private void addInsProductMethod(Integer sampleId, List<InsProduct> productList) { -// for (InsProduct product : productList) { -// if (product.getState() == 1) { -// product.setId(null); -// product.setCreateTime(null); -// product.setCreateUser(null); -// product.setUpdateTime(null); -// product.setUpdateUser(null); -// product.setInsSampleId(sampleId); -// if (product.getInspectionItemSubclass() == null) { -// product.setInspectionItemSubclass(""); -// } -// if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) { -// throw new ErrorException("鏈夋楠岄」鐨勮姹傚�兼垨瑕佹眰鎻忚堪涓虹┖, 璇峰厛鍘绘爣鍑嗗簱閰嶇疆瑕佹眰鍊兼垨瑕佹眰鎻忚堪"); -// } -// insProductMapper.insert(product); -// } -// } -// } -// -// -// @Override -// public Map<String, Object> getInsOrder(Integer id) { -// Map<String, Object> map = new HashMap<>(); -// InsOrder insOrder = insOrderMapper.selectById(id); -// List<SampleProductDto> list; -// // 鍒ゆ柇鏄惁鏄繘鍘傛姤鍛婂厤妫� -// if (insOrder.getIsExemption().equals(1)) { -// list = insSampleMapper.selectExemptionByOrderId(id); -// } else { -// list = insSampleMapper.selectSampleProductListByOrderId2(id); -// } -// Map<String, Object> map1 = insSampleMapper.selectInsOrder(id); -// map.put("insOrder", insOrder); -// map.put("sampleProduct", list); -// map.put("insOrderTemplate", map1); -// return map; -// } -// -// @Override -// public int upInsOrderOfState(InsOrder insOrder) { -// insOrder.setExamineTime(LocalDateTime.now()); -// if (insOrder.getState() == 1) { -// //瀹℃牳閫氳繃鎵嶄細鐢熸垚濮旀墭缂栧彿 -// // todo: 妫�楠岀被鍨嬬紪鍙� -// InsOrder order = this.getById(insOrder.getId()); -// String code = ""; -// switch (order.getOrderType()) { -// case InsOrderTypeConstants.SPOT_CHECK: -// code = "C"; -// break; -// case InsOrderTypeConstants.CUSTOMER_ORDERED: -// code = "W"; -// break; -// case InsOrderTypeConstants.ENTER_THE_FACTORY: -// case InsOrderTypeConstants.QUARTERLY_TEST: -// code = "Y"; -// break; -// } -// // 鐢熸垚缂栧彿 -// String no = numberGenerator.generateNumberWithPrefix(3, -// "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), -// InsOrder::getEntrustCode); -// // 鍒ゆ柇鏄惁鏄搴︽楠�, 鏄搴︽楠屽彇娑堝師鏉愭枡瀛e害妫�楠屼笅鍗� -// if (InsOrderTypeConstants.QUARTERLY_TEST.equals(order.getOrderType())) { -// ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() -// .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId()) -// .set(IfsInventoryQuantity::getIsQuarter, 0)); -// -// // 鏌ヨ鏄惁鏈夎繃杩涘巶妫�楠�, 鏈夎幏鍙栭噷闈㈢殑缂栧彿 -// InsOrder order1 = insOrderMapper.selectOne(Wrappers.<InsOrder>lambdaQuery() -// .eq(InsOrder::getIfsInventoryId, order.getIfsInventoryId()) -// .ne(InsOrder::getState, -1) -// .eq(InsOrder::getOrderType, InsOrderTypeConstants.ENTER_THE_FACTORY)); -// if (order1 != null) { -// no = order1.getEntrustCode(); -// } -// } -// -// int count = 1; -// // 鏌ヨ鏍峰搧琛� -// List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() -// .eq(InsSample::getInsOrderId, insOrder.getId())); -// for (InsSample insSample : insSamples) { -// if (StringUtils.isBlank(insSample.getSampleCode())) { -// // 濡傛灉鍙湁涓�涓牱鍝佸氨涓嶉渶瑕佹嫾鎺ユ暟瀛� -// if (insSamples.size() != 1) { -// insSample.setSampleCode(no + "-" + count); -// count++; -// } else { -// insSample.setSampleCode(no); -// } -// } -// } -// insSampleService.updateBatchById(insSamples); -// -// insOrder.setEntrustCode(no); -// } -// return insOrderMapper.updateById(insOrder); -// } -// -// @Override -// public Map<String, Object> getInsOrderAndSample(Integer id, String laboratory) { -// Map<String, Object> map = new HashMap<>(); -// InsOrder insOrder = insOrderMapper.selectById(id); -// List<SampleProductDto> list = insSampleMapper.getInsOrderAndSample(id, laboratory); -// for (SampleProductDto sampleProductDto : list) { -// List<Integer> ids = sampleProductDto.getInsProduct().stream().map(InsProduct::getId).collect(Collectors.toList()); -// List<InsProductUser> insProductUsers = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery() -// .in(InsProductUser::getInsProductId, ids)); -// if (CollectionUtils.isNotEmpty(insProductUsers)) { -// List<Integer> userIds = insProductUsers.stream().map(InsProductUser::getCreateUser).distinct().collect(Collectors.toList()); -// String collect = userMapper.selectBatchIds(userIds).stream().map(User::getName).collect(Collectors.joining(",")); -// sampleProductDto.setCheckName(collect); -// } -// } -// map.put("insOrder", insOrder); -// map.put("sampleProduct", list); -// //鏌ヨ鎵�鏈夎褰曟ā鐗堝幓閲� -// List<Map<Integer, Object>> list2 = insOrderMapper.selectReportModelByOrderId(id, laboratory); -// map.put("reportModel", list2); -// return map; -// } -// -// @Override -// public IPage<SampleProductDto2> selectSampleAndProductByOrderId(IPage<SampleProductDto2> page, SampleProductDto2 sampleProductDto) { -// IPage<SampleProductDto2> productDto2IPage = insOrderMapper.selectSampleAndProductByOrderId(page, -// QueryWrappers.queryWrappers(sampleProductDto) -// .orderByAsc("sample_code") -// .orderByAsc("cable_tag") -// .orderByAsc("sort"), -// sampleProductDto.getId()); -// return productDto2IPage; -// } -// -// @Override -// public IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto) { -// String dates = costStatisticsDto.getDates(); -// String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); -// costStatisticsDto.setDates(null); -// -// //todo:浠呯湅鑷繁 -// -// IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); -// List<CostStatisticsDto> collect = dtoIPage.getRecords().stream().map(dto -> { -// Set<String> uniqueTags = new HashSet<>(); -// if (dto.getInspectionItem().contains(",")) { -// for (String s : dto.getInspectionItem().split(",")) { -// uniqueTags.add(s.split("@")[0]); -// } -// } else { -// uniqueTags.add(dto.getInspectionItem().split("@")[0]); -// } -// dto.setInspectionItem(uniqueTags.toString()); -// return dto; -// }).collect(Collectors.toList()); -// dtoIPage.setRecords(collect); -// return dtoIPage; -// } -// -// @Override -// public Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto) { -// Map<String, Object> map = new HashMap<>(); -// String dates = costStatisticsDto.getDates(); -// String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); -// costStatisticsDto.setDates(null); -// List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); -// double totalPrice = costStatisticsDtos.stream() -// .filter(dto -> dto.getPrice() != null) // 杩囨护鎺変环鏍间负 null 鐨勫璞� -// .mapToDouble(value -> value.getPrice().doubleValue() * value.getNum()) -// .sum(); -// map.put("total", totalPrice); -// return map; -// } -// -// @Override -// public Map<String, Object> selectSampleDefects(Page page, String inspectionItems, String orderNumber) { -// List<SampleDefectsFatherVo> sampleDefectsFatherVos = insOrderMapper.selectSampleDefects(page, inspectionItems, orderNumber); -// Map<String, Object> map = new HashMap<>(); -// map.put("records", sampleDefectsFatherVos); -// Long aLong = insOrderMapper.getCount(inspectionItems, orderNumber); -// map.put("total", aLong); -// return map; -// } -// -// @Override -// public int updateStatus(Integer id) { -// return insOrderMapper.updateStatus(id); -// } -// -// -// @Override -// public void export(CostStatisticsDto costStatisticsDto, HttpServletResponse response) throws IOException { -// //鏌ヨ瀵煎嚭鐨勮垂鐢ㄧ粺璁℃暟鎹� -// String dates = costStatisticsDto.getDates(); -// String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); -// costStatisticsDto.setDates(null); -// List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); -// costStatisticsDtos = costStatisticsDtos.stream().map(dto -> { -// Set<String> uniqueTags = new HashSet<>(); -// if (dto.getInspectionItem().contains(",")) { -// for (String s : dto.getInspectionItem().split(",")) { -// uniqueTags.add(s.split("@")[0]); -// } -// } else { -// uniqueTags.add(dto.getInspectionItem().split("@")[0]); -// } -// dto.setInspectionItem(uniqueTags.toString()); -// return dto; -// }).collect(Collectors.toList()); -// -// response.setContentType("application/vnd.ms-excel"); -// response.setCharacterEncoding("UTF-8"); -// // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴 -// String fileName = URLEncoder.encode("鏍峰搧璐圭敤缁熻瀵煎嚭", "UTF-8"); -// response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); -// Map<String, List<CostStatisticsDto>> groupByCompany = -// costStatisticsDtos.stream().filter(e -> StrUtil.isNotEmpty(e.getCompany())) -// .collect(Collectors.groupingBy(CostStatisticsDto::getCompany)); -// try { -// // 鏂板缓ExcelWriter -// // 鏂板缓ExcelWriter -// ExcelWriter excelWriter = -// EasyExcel.write(response.getOutputStream()) -// .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) -// .build(); -// for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) { -// String sheetName = companyDataEntry.getKey(); -// List<CostStatisticsDto> dataList = companyDataEntry.getValue(); -// WriteSheet mainSheet = EasyExcel.writerSheet(sheetName) -// .head(CostStatisticsDto.class) -// .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) -// .build(); -// excelWriter.write(dataList, mainSheet); -// } -// // 鍏抽棴娴� -// excelWriter.finish(); -// } catch (IOException e) { -// throw new RuntimeException("瀵煎嚭澶辫触"); -// } -// } -// -// /** -// * 鑾峰彇ifs搴撳瓨淇℃伅 -// * @param -// * @return -// */ -// @Override -// public void getIfsOrder() { -// HashMap<String, Object> map = new HashMap<>(); -// map.put("LOCATION_NO","1302"); -// map.put("STATE_DB","To be Inspected"); -// List<Map<String, Object>> inventory = ifsApiUtils.getInventory(JSONUtil.toJsonStr(map)); -// if(inventory.size() == 0) { -// return; -// } -// // 杩涜淇濆瓨 -// for (Map<String, Object> map1 : inventory) { -// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // 鏃堕棿鏍煎紡鍖� -// IfsInventoryQuantity ifsInventoryQuantity = new IfsInventoryQuantity(); -// ifsInventoryQuantity.setContract(map1.get("CONTRACT") == null ? "" : map1.get("CONTRACT").toString()); // 鍩� -// ifsInventoryQuantity.setPartNo(map1.get("PART_NO") == null ? "" : map1.get("PART_NO").toString() ); // 闆朵欢鍙� -// ifsInventoryQuantity.setPartDesc(map1.get("PART_DESC") == null ? "" : map1.get("PART_DESC").toString()); // 闆朵欢鎻忚堪 -// ifsInventoryQuantity.setOrderNo(map1.get("ORDER_NO") == null ? "" : map1.get("ORDER_NO").toString()); // 璁㈠崟鍙� -// ifsInventoryQuantity.setLineNo(map1.get("LINE_NO") == null ? "" : map1.get("LINE_NO").toString()); // 琛屽彿 -// ifsInventoryQuantity.setReleaseNo(map1.get("RELEASE_NO") == null ? "" : map1.get("RELEASE_NO").toString()); // 涓嬭揪鍙� -// ifsInventoryQuantity.setReceiptNo(Integer.parseInt(map1.get("RECEIPT_NO") == null ? "" : map1.get("RECEIPT_NO").toString())); // 鎺ユ敹鍙� -// ifsInventoryQuantity.setStatus(map1.get("STATE") == null ? "" : map1.get("STATE").toString()); // 鐘舵�佹弿杩� -// ifsInventoryQuantity.setStatusDb(map1.get("STATE_DB") == null ? "" : map1.get("STATE_DB").toString()); // 鐘舵�� -// if(map1.get("QTY_ARRIVED") != null) { -// ifsInventoryQuantity.setQtyArrived(new BigDecimal(map1.get("QTY_ARRIVED").toString())); // 鎶佃揪鐨勯噰璐暟閲� -// } -// if(map1.get("QTY_INSPECTED") != null) { -// ifsInventoryQuantity.setQtyInspected(new BigDecimal(map1.get("QTY_INSPECTED").toString())); // 宸叉楠岀殑璐拱鏁伴噺 -// } -// if(map1.get("QTY_TO_INSPECT") != null) { -// ifsInventoryQuantity.setQtyToInspect(new BigDecimal(map1.get("QTY_TO_INSPECT").toString())); // 瑕佹楠岀殑閲囪喘鏁伴噺 -// } -// if(map1.get("INV_QTY_IN_STORE") != null) { -// ifsInventoryQuantity.setInvQtyInStore(new BigDecimal(map1.get("INV_QTY_IN_STORE").toString())); // 鎶佃揪鐨勫簱瀛樻暟閲� -// } -// if(map1.get("PUR_QTY_IN_STORE") != null) { -// ifsInventoryQuantity.setPurQtyInStore(new BigDecimal( map1.get("PUR_QTY_IN_STORE").toString())); // 鎶佃揪鐨勯噰璐暟閲� -// -// } -// ifsInventoryQuantity.setSupplierId(map1.get("SUPPLIER_ID") == null ? "" : map1.get("SUPPLIER_ID").toString()); // 渚涘簲鍟咺D -// ifsInventoryQuantity.setSupplierName(map1.get("SUPPLIER_NAME") == null ? "" : map1.get("SUPPLIER_NAME").toString()); // 渚涘簲鍟嗗悕绉� -// ifsInventoryQuantity.setConfigurationId(map1.get("CONFIGURATION_ID") == null ? "" : map1.get("CONFIGURATION_ID").toString()); // 閰嶇疆鏍囪瘑 -// ifsInventoryQuantity.setLotBatchNo(map1.get("LOT_BATCH_NO") == null ? "" : map1.get("LOT_BATCH_NO").toString()); // 鎵规鍙� -// ifsInventoryQuantity.setUpdateBatchNo(map1.get("LOT_BATCH_NO") == null ? "" : map1.get("LOT_BATCH_NO").toString()); // 鎵规鍙� -// ifsInventoryQuantity.setWaivDevRejNo(map1.get("WAIV_DEV_REJ_NO") == null ? "" : map1.get("WAIV_DEV_REJ_NO").toString()); // WDR鍙� -// ifsInventoryQuantity.setActivitySeq(map1.get("ACTIVITY_SEQ") == null ? null : Integer.parseInt(map1.get("ACTIVITY_SEQ").toString())); // 娲诲姩搴忓垪 -// ifsInventoryQuantity.setSerialNo(map1.get("SERIAL_NO") == null ? "" : map1.get("SERIAL_NO").toString()); // 搴忓垪鍙� -// ifsInventoryQuantity.setLocationNo(map1.get("LOCATION_NO") == null ? "" : map1.get("LOCATION_NO").toString()); // 搴撲綅鍙� -// ifsInventoryQuantity.setEngChgLevel(map1.get("ENG_CHG_LEVEL") == null ? "" : map1.get("ENG_CHG_LEVEL").toString()); // 鐗堟湰鍙� -// ifsInventoryQuantity.setReceiver(map1.get("RECEIVER") == null ? "" : map1.get("RECEIVER").toString()); // 鎺ユ敹浜� -// ifsInventoryQuantity.setReceiverName(map1.get("RECEIVER_NAME") == null ? "" : map1.get("RECEIVER_NAME").toString()); // 鎺ユ敹浜哄悕绉� -// ifsInventoryQuantity.setBuyerCode(map1.get("BUYER_CODE") == null ? "" : map1.get("BUYER_CODE").toString()); // 閲囪喘鍛� -// ifsInventoryQuantity.setBuyerName(map1.get("BUYER_NAME") == null ? "" : map1.get("BUYER_NAME").toString()); // 閲囪喘鍛樺悕绉� -// -// if(map1.get("ARRIVE_DATE") != null) { -// ifsInventoryQuantity.setArriveDate(LocalDateTime.parse(map1.get("ARRIVE_DATE").toString(),dateTimeFormatter)); // 瀹為檯鍒拌揣鏃ユ湡 -// } -// if(map1.get("DELIVERY_DATE") != null) { -// ifsInventoryQuantity.setDeliveryDate(LocalDateTime.parse(map1.get("DELIVERY_DATE").toString(),dateTimeFormatter)); // 瀹為檯浜よ揣鏃ユ湡 -// } -// if(map1.get("PRODUCT_DATE") != null) { -// ifsInventoryQuantity.setProductDate(LocalDateTime.parse(map1.get("PRODUCT_DATE").toString(),dateTimeFormatter)); // 鐢熶骇鏃ユ湡 -// -// } -// if(map1.get("INVALID_DATE") != null) { -// ifsInventoryQuantity.setInvalidDate(LocalDateTime.parse(map1.get("INVALID_DATE").toString(),dateTimeFormatter)); // 澶辨晥鏃ユ湡 -// } -// if(map1.get("APPROVED_DATE") != null) { -// ifsInventoryQuantity.setApprovedDate(LocalDateTime.parse(map1.get("APPROVED_DATE").toString(),dateTimeFormatter)); // 瀹℃壒鏃ユ湡 -// } -// ifsInventoryQuantity.setReqCeater(map1.get("REQ_CEATER") == null ? "" : map1.get("REQ_CEATER").toString()); // 閲囪喘鐢宠鍒涘缓浜� -// ifsInventoryQuantity.setReqCeaterName(map1.get("REQ_CEATER_NAME") == null ? "" : map1.get("REQ_CEATER_NAME").toString()); // 閲囪喘鐢宠鍒涘缓浜哄悕绉� -// ifsInventoryQuantity.setLineRemarks(map1.get("LINE_REMARKS") == null ? "" : map1.get("LINE_REMARKS").toString()); // 閲囪喘璁㈠崟琛屽娉� -// ifsInventoryQuantity.setBuyUnitMeas(map1.get("BUY_UNIT_MEAS") == null ? "" : map1.get("BUY_UNIT_MEAS").toString()); // 閲囪喘鍗曚綅 -// ifsInventoryQuantity.setReceiverDate(LocalDateTime.now()); // 鎺ユ敹鏃ユ湡 -// ifsInventoryQuantity.setIsSource(1); -// ifsInventoryQuantity.setState(0); -// -// IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectOne(new LambdaQueryWrapper<IfsInventoryQuantity>() -// .eq(IfsInventoryQuantity::getOrderNo, ifsInventoryQuantity.getOrderNo()) -// .eq(IfsInventoryQuantity::getLineNo, ifsInventoryQuantity.getLineNo()) -// .eq(IfsInventoryQuantity::getReleaseNo, ifsInventoryQuantity.getReleaseNo()) -// .eq(IfsInventoryQuantity::getReceiptNo, ifsInventoryQuantity.getReceiptNo()) -// .eq(IfsInventoryQuantity::getLocationNo, ifsInventoryQuantity.getLocationNo()) -// .eq(IfsInventoryQuantity::getLotBatchNo, ifsInventoryQuantity.getLotBatchNo()) -// .eq(IfsInventoryQuantity::getSerialNo, ifsInventoryQuantity.getSerialNo()) -// .eq(IfsInventoryQuantity::getEngChgLevel, ifsInventoryQuantity.getEngChgLevel()) -// .eq(IfsInventoryQuantity::getWaivDevRejNo, ifsInventoryQuantity.getWaivDevRejNo()) -// .eq(IfsInventoryQuantity::getActivitySeq, ifsInventoryQuantity.getActivitySeq()) -// ); -// if(Objects.isNull(one)) { -// -// ifsInventoryQuantity.setIsFirst(0); -// // 鏌ヨ浜т笟閾炬娴嬫暟鎹� -// String industryChainAttrFields = IndustryChainUtils.getIndustryChainAttrFields(ifsInventoryQuantity.getOrderNo(), -// ifsInventoryQuantity.getLineNo(), -// ifsInventoryQuantity.getReleaseNo()); -// ifsInventoryQuantity.setIndustryChain(industryChainAttrFields); -// -// ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); -// } -// } -// } -// -// /** -// * id鏄師鏉愭枡鐨刬d -// * -// * 淇敼璁㈠崟鍗曞彿 -// * @param insOrder -// */ -// @Override -// @Transactional(rollbackFor = Exception.class) -// public void updateEntrustCode(InsOrder insOrder) { -// // 鍒ゆ柇褰撳墠璁㈠崟鏄惁鐢熸垚浜嗘姤鍛�, 鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀瑰崟鍙� -// List<InsOrder> insOrders = insOrderMapper.selectList(Wrappers.<InsOrder>lambdaQuery() -// .eq(InsOrder::getIfsInventoryId, insOrder.getId()) -// .ne(InsOrder::getState, -1)); -// List<Integer> insOrderIds = insOrders.stream().map(InsOrder::getId).collect(Collectors.toList()); -// Long count = insReportMapper.selectCount(Wrappers.<InsReport>lambdaQuery() -// .in(InsReport::getInsOrderId, insOrderIds)); -// if (count > 0 ) { -// throw new ErrorException("褰撳墠璁㈠崟宸茬粡鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀圭紪鍙�"); -// } -// -// -// Long count1 = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() -// .eq(InsOrder::getEntrustCode, insOrder.getEntrustCode()) -// .ne(InsOrder::getIfsInventoryId, insOrder.getId()) -// .ne(InsOrder::getInsState, -1)); -// if (count1 > 0) { -// throw new ErrorException("璇ョ紪鍙烽噸澶�"); -// } -// -// //淇敼鎶ュ憡鐨勭紪鍙� -// insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() -// .eq(InsOrder::getIfsInventoryId, insOrder.getId()) -// .set(InsOrder::getEntrustCode, insOrder.getEntrustCode())); -// -// // 淇敼鏍峰搧鐨勭紪鍙� -// // 鏌ヨ鎵�鏈夌殑鏍峰搧 -// List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() -// .in(InsSample::getInsOrderId, insOrderIds)); -// for (InsSample insSample : insSamples) { -// String sampleCode = insSample.getSampleCode(); -// String updateCode = insOrder.getEntrustCode(); -// // 鏌ユ壘鏈�鍚庝竴涓�'-'鐨勪綅缃� -// int lastDashIndex = sampleCode.lastIndexOf('-'); -// if (lastDashIndex != -1) { -// int secondLastDashIndex = sampleCode.lastIndexOf('-', lastDashIndex - 1); -// // 澶勭悊鏈�鍚庝竴涓�'-'鍓嶇殑閮ㄥ垎 -// if (secondLastDashIndex != -1) { -// // 澶勭悊鏈�鍚庝竴涓�'-'鍙婁箣鍚庣殑閮ㄥ垎 -// String afterLastDash = sampleCode.substring(lastDashIndex); -// -// updateCode = updateCode + afterLastDash; -// } -// } -// insSampleMapper.update(null, Wrappers.<InsSample>lambdaUpdate() -// .eq(InsSample::getId, insSample.getId()) -// .set(InsSample::getSampleCode, updateCode)); -// -// } -// } -// -// @Override -// public List<InsUnqualifiedRetestProduct> getRetestResult(Integer insProductId) { -// return insUnqualifiedRetestProductMapper.selectList(Wrappers.<InsUnqualifiedRetestProduct>lambdaQuery() -// .eq(InsUnqualifiedRetestProduct::getInsProductId, insProductId)); -// } -// -// /** -// * 淇敼閲囪喘璁㈠崟鎺ユ敹鐘舵��, 閬垮厤鍥炴粴 -// * @param id -// */ -// @Transactional -// public void updateIfsInventoryQuantity(Integer id) { -// ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() -// .set(IfsInventoryQuantity::getIsRegister, 1) -// .eq(IfsInventoryQuantity::getId, id)); -// } -// -// /** -// * 鏂板閾滃崟涓濅笅鍗� -// * @param list -// * @param insOrder -// * @return -// */ -// @Override -// public int addRawCopperOrder(List<SampleProductDto> list, CopperInsOrderDto insOrder) { -// insOrder.setState(1); -// insOrder.setTypeSource(1); -// -// LocalDate appointed = insOrder.getAppointed(); -// -// insOrderMapper.insert(insOrder); // 涓昏〃 -// -// list.forEach(a -> { -// a.setId(null); -// a.setInsOrderId(insOrder.getId()); -// insSampleMapper.insert(a); -// if (ObjectUtil.isNotEmpty(a.getInsProduct())) { -// // 鍒ゆ柇鏄惁濉啓寰呮椤规暟閲� -// if (a.getQuantity() != null) { -// List<InsProduct> ip2 = new ArrayList<>(); -// for (Integer i = 1; i <= a.getQuantity(); i++) { -// // 閲嶆柊鎷疯礉 鍒涘缓鏂板璞� -// AtomicInteger atomicInteger = new AtomicInteger(i); -// List<InsProduct> insProducts = a.getInsProduct().stream().map(insProduct -> { -// insProduct.setRawMaterialTag(String.valueOf(atomicInteger.get())); -// InsProduct product = new InsProduct(); -// BeanUtils.copyProperties(insProduct, product); -// return product; -// }).collect(Collectors.toList()); -// -// ip2.addAll(insProducts); -// } -// addInsProductMethod(a.getId(), ip2); -// } else { -// addInsProductMethod(a.getId(), a.getInsProduct()); -// } -// } -// if (ObjectUtil.isNotEmpty(a.getChildSampleList())) { -// for (SampleProductDto b : a.getChildSampleList()) { -// for (int i = 0; i < b.getNum(); i++) { -// b.setId(null); -// b.setInsOrderId(insOrder.getId()); -// b.setParentId(a.getId()); -// insSampleMapper.insert(b); -// if (ObjectUtil.isNotEmpty(b.getInsProduct())) { -// addInsProductMethod(b.getId(), b.getInsProduct()); -// } -// } -// } -// } -// }); -// -// // 娣诲姞鍘熸潗鏂欎俊鎭� -// IfsInventoryQuantity ifsInventoryQuantity = new IfsInventoryQuantity(); -// // 鍩烘湰淇℃伅 -// ifsInventoryQuantity.setIsSource(0); -// ifsInventoryQuantity.setIsInspect(1); -// ifsInventoryQuantity.setState(1); -// ifsInventoryQuantity.setIsFinish(0); -// ifsInventoryQuantity.setIsCopper(1); -// ifsInventoryQuantity.setIsQuarter(0); -// ifsInventoryQuantity.setInspectStatus(0); -// -// ifsInventoryQuantity.setQtyArrived(insOrder.getQtyArrived()); -// ifsInventoryQuantity.setBuyUnitMeas(insOrder.getBuyUnitMeas()); -// ifsInventoryQuantity.setSupplierName(insOrder.getSupplierName()); -// ifsInventoryQuantity.setUpdateBatchNo(insOrder.getUpdateBatchNo()); -// ifsInventoryQuantity.setDeclareDate(insOrder.getDeclareDate()); -// -// ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); -// -// -// insOrder.setIfsInventoryId(ifsInventoryQuantity.getId()); -// insOrder.setState(1); -// -// -// upInsOrderOfState(insOrder); -// upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "鍘熸潗鏂�"); -// -// return insOrder.getId(); -// } -// -// /** -// * 淇敼濮旀墭涓嬪崟缂栧彿 -// * @param insOrder -// */ -// @Override -// public void updateOrderEntrustCode(InsOrder insOrder) { -// // 鍒ゆ柇褰撳墠璁㈠崟鏄惁鐢熸垚浜嗘姤鍛�, 鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀瑰崟鍙� -// Long count = insReportMapper.selectCount(Wrappers.<InsReport>lambdaQuery() -// .eq(InsReport::getInsOrderId, insOrder.getId())); -// if (count > 0 ) { -// throw new ErrorException("褰撳墠璁㈠崟宸茬粡鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀圭紪鍙�"); -// } -// -// Long count1 = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() -// .eq(InsOrder::getEntrustCode, insOrder.getEntrustCode())); -// if (count1 > 0) { -// throw new ErrorException("璇ョ紪鍙烽噸澶�"); -// } -// -// //淇敼鎶ュ憡鐨勭紪鍙� -// insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() -// .eq(InsOrder::getId, insOrder.getId()) -// .set(InsOrder::getEntrustCode, insOrder.getEntrustCode())); -// -// // 淇敼鏍峰搧鐨勭紪鍙� -// // 鏌ヨ鎵�鏈夌殑鏍峰搧 -// List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() -// .eq(InsSample::getInsOrderId, insOrder.getId())); -// for (InsSample insSample : insSamples) { -// String sampleCode = insSample.getSampleCode(); -// String updateCode = insOrder.getEntrustCode(); -// // 鏌ユ壘鏈�鍚庝竴涓�'-'鐨勪綅缃� -// int lastDashIndex = sampleCode.lastIndexOf('-'); -// if (lastDashIndex != -1) { -// int secondLastDashIndex = sampleCode.lastIndexOf('-', lastDashIndex - 1); -// // 澶勭悊鏈�鍚庝竴涓�'-'鍓嶇殑閮ㄥ垎 -// if (secondLastDashIndex != -1) { -// // 澶勭悊鏈�鍚庝竴涓�'-'鍙婁箣鍚庣殑閮ㄥ垎 -// String afterLastDash = sampleCode.substring(lastDashIndex); -// -// updateCode = updateCode + afterLastDash; -// } -// } -// insSampleMapper.update(null, Wrappers.<InsSample>lambdaUpdate() -// .eq(InsSample::getId, insSample.getId()) -// .set(InsSample::getSampleCode, updateCode)); -// -// } -// } -// -// /** -// * 淇敼妫�楠屼笅鍗曞唴瀹� -// * @param insOrderUpdateDto -// * @return -// */ -// @Override -// @Transactional(rollbackFor = Exception.class) -// public Boolean updateInsOrder(InsOrderUpdateDto insOrderUpdateDto) { -// // 淇敼璁㈠崟 -// insOrderUpdateDto.getInsOrder().setState(0); -// insOrderUpdateDto.getInsOrder().setTell(""); -// insOrderMapper.updateById(insOrderUpdateDto.getInsOrder()); -// -// // 淇敼妫�楠岄」 -// for (SampleProductDto sampleProductDto : insOrderUpdateDto.getSampleProduct()) { -// insProductService.updateBatchById(sampleProductDto.getInsProduct()); -// } -// -// return true; -// } -// -// /** -// * 鎴愬搧鏍囩鎵撳嵃 -// * @param ids -// * @return -// */ -// @Override -// public List<InsOrderPrintingVo> labelOrderPrinting(List<Integer> ids) { -// return insOrderMapper.labelOrderPrinting(ids); -// } -// -// /** -// * 鏍规嵁鏍峰搧id鏌ヨ妫�楠岄」鏍� -// * @param insSampleId -// * @return -// */ -// @Override -// public List<StandardProductList> getProductTreeBySampleId(Integer insSampleId) { -// // 鏌ヨ绗竴涓楠岄」鑾峰彇妫�楠岄」鏍� -// InsProduct insProduct = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() -// .eq(InsProduct::getInsSampleId, insSampleId) -// .last("limit 1")); -// String tree = insProduct.getFactory() + " - " + -// insProduct.getLaboratory() + " - " + -// insProduct.getSampleType() + " - " + -// insProduct.getSample() + " - " + -// insProduct.getModel(); -// // 鏌ヨ鏍囧噯鏍� -// List<StandardProductList> standardProductLists = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery() -// .eq(StandardProductList::getStandardMethodListId, insProduct.getStandardMethodListId()) -// .eq(StandardProductList::getTree, tree)); -// for (StandardProductList standardProductList : standardProductLists) { -// standardProductList.setId(null); -// } -// -// return standardProductLists; -// } -// -// /** -// * 娣诲姞閬楁紡鐨勬楠岄」 -// * @param omitOrderProductDto -// * @return -// */ -// @Override -// public boolean addOmitOrderProduct(OmitOrderProductDto omitOrderProductDto) { -// if (omitOrderProductDto.getInsSampleId() == null) { -// throw new ErrorException("缂哄皯鏍峰搧Id"); -// } -// for (InsProduct product : omitOrderProductDto.getInsProductBindingList()) { -// if (product.getState() == 1) { -// product.setId(null); -// product.setCreateTime(null); -// product.setCreateUser(null); -// product.setUpdateTime(null); -// product.setUpdateUser(null); -// product.setInsSampleId(omitOrderProductDto.getInsSampleId()); -// if (StringUtils.isBlank(product.getCableTag())) { -// product.setCableTag(null); -// } -// if (product.getInspectionItemSubclass() == null) { -// product.setInspectionItemSubclass(""); -// } -// if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) { -// throw new ErrorException("鏈夋楠岄」鐨勮姹傚�兼垨瑕佹眰鎻忚堪涓虹┖, 璇峰~鍐欒姹傚�兼垨瑕佹眰鎻忚堪"); -// } -// insProductMapper.insert(product); -// } -// } -// -// return true; -// } -// -// /** -// * 鎴愬搧妫�楠屽崟瀵煎嚭 -// * @param sampleOrderDto -// * @param response -// */ -// @Override -// public void rawAllInsOrderExport(SampleOrderDto sampleOrderDto, HttpServletResponse response) { -// //鍒ゆ柇鍏ㄩ儴,涓汉,缁勭粐鐨勬潈闄� -// //todo:浠呯湅鎴戣幏鍙栧綋鍓嶄汉鎵�灞炲疄楠屽id -// String laboratory = null; -// // 鍒ゆ柇鏄惁鏄叏閮� -// String isOrderAll = null; -// if (sampleOrderDto.getState() != null && sampleOrderDto.getState() == -2) { -// isOrderAll = "1"; -// sampleOrderDto.setState(null); -// } -// List<SampleOrderDto> sampleOrderDtoList = insOrderMapper.rawAllInsOrderExport(QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); -// -// // 鍒ゆ柇鏄惁鏄笉鍚堟牸, 涓嶅悎鏍兼煡璇笉鍚堟牸椤� -// for (SampleOrderDto orderDto : sampleOrderDtoList) { -// if (orderDto.getInsResult() != null && orderDto.getInsResult() == 0){ -// // 鏌ヨ涓嶅悎鏍奸」 -// List<String> unqualifiedList = insProductMapper.selectUnqualifiedList(orderDto.getId()); -// orderDto.setUnqualifiedItem(CollUtil.join(unqualifiedList, ",")); -// } -// orderDto.setCreateTimeString(orderDto.getCreateTime() == null ? "" : orderDto.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); -// -// } -// -// response.setContentType("application/vnd.ms-excel"); -// response.setCharacterEncoding("UTF-8"); -// try { -// // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴 -// String fileName = URLEncoder.encode("濮旀墭妫�娴嬩俊鎭鍑�", "UTF-8"); -// response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); -// //鏂板缓ExcelWriter -// ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); -// //鑾峰彇sheet0瀵硅薄 -// WriteSheet mainSheet = EasyExcel.writerSheet(0, "濮旀墭妫�娴嬩俊鎭鍑�").head(SampleOrderDto.class).build(); -// -// //鍚憇heet0鍐欏叆鏁版嵁 浼犲叆绌簂ist杩欐牱鍙鍑鸿〃澶� -// excelWriter.write(sampleOrderDtoList, mainSheet); -// //鍏抽棴娴� -// excelWriter.finish(); -// } catch (IOException e) { -// throw new RuntimeException("瀵煎嚭澶辫触"); -// } -// } -// -//} -// -// -// -// +package com.ruoyi.inspect.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; +import com.ruoyi.basic.mapper.StandardProductListMapper; +import com.ruoyi.basic.pojo.IfsInventoryQuantity; +import com.ruoyi.basic.pojo.StandardProductList; +import com.ruoyi.basic.pojo.StructureTestObject; +import com.ruoyi.common.constant.InsOrderTypeConstants; +import com.ruoyi.common.core.domain.entity.User; +import com.ruoyi.common.numgen.NumberGenerator; +import com.ruoyi.common.utils.*; +import com.ruoyi.framework.exception.ErrorException; +import com.ruoyi.inspect.dto.*; +import com.ruoyi.inspect.mapper.*; +import com.ruoyi.inspect.pojo.*; +import com.ruoyi.inspect.service.InsOrderService; +import com.ruoyi.inspect.service.InsProductService; +import com.ruoyi.inspect.service.InsSampleService; +import com.ruoyi.inspect.vo.InsOrderPrintingVo; +import com.ruoyi.inspect.vo.SampleDefectsFatherVo; +import com.ruoyi.system.mapper.CustomMapper; +import com.ruoyi.system.mapper.UserMapper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +/** + * @author gaoaoy + * @description 閽堝琛ㄣ�恑ns_order(妫�楠屼笅鍗�)銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇 + * @createDate 2024-03-12 16:17:55 + */ +@Service +@AllArgsConstructor +public class InsOrderServiceImpl extends ServiceImpl<InsOrderMapper, InsOrder> + implements InsOrderService { + + private InsOrderMapper insOrderMapper; + private InsSampleService insSampleService; + private InsSampleMapper insSampleMapper; + private InsProductService insProductService; + private InsProductMapper insProductMapper; + private InsProductUserMapper insProductUserMapper; + private InsSampleUserMapper insSampleUserMapper; + private InsOrderStateMapper insOrderStateMapper; + private UserMapper userMapper; + private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; + private CustomMapper customMapper; + private final NumberGenerator<InsOrder> numberGenerator; + private InsReportMapper insReportMapper; + private InsUnqualifiedRetestProductMapper insUnqualifiedRetestProductMapper; + private IfsApiUtils ifsApiUtils; + private SpotCheckQuarterItemMapper spotCheckQuarterItemMapper; + private StandardProductListMapper standardProductListMapper; + + + + //鑾峰彇妫�楠屼笅鍗曟暟鎹� + @Override + public IPage<SampleOrderDto> selectInsOrderParameter(IPage<InsOrder> page, SampleOrderDto sampleOrderDto) { + //todo: 鍙湅鎴戝垽鏂叏閮�,涓汉,缁勭粐鐨勬潈闄� + String laboratory = null; + // 鍒ゆ柇鏄惁鏄叏閮� + String isOrderAll = null; + if (sampleOrderDto.getState() != null && sampleOrderDto.getState() == -2) { + isOrderAll = "1"; + sampleOrderDto.setState(null); + } + IPage<SampleOrderDto> sampleOrderDtoIPage = insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); + return insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public int upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId, String sonLaboratory) { + InsOrder insOrder = new InsOrder(); + insOrder.setId(orderId); + insOrder.setAppointed(StringUtils.isNotEmpty(appointed) ? LocalDate.parse(appointed) : null); + insOrder.setSendTime(LocalDateTime.now()); + insOrderMapper.updateById(insOrder); + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); + List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList()); + List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() + .in(InsProduct::getInsSampleId, ids) + .eq(InsProduct::getState, 1) + .select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory)); + for (InsProduct insProduct : insProducts) { + InsOrderState insOrderState = new InsOrderState(); + insOrderState.setInsOrderId(orderId); + try { + insOrderState.setLaboratory(insProduct.getSonLaboratory()); + } catch (NullPointerException e) { + throw new ErrorException("璇ユ楠屽崟鏈夋湭缁存姢瀹為獙瀹ょ殑妫�楠岄」鐩�"); + } + insOrderState.setInsState(0); + insOrderStateMapper.insert(insOrderState); + } + if (userId != null) { + InsSampleUser insSampleUser = new InsSampleUser(); + insSampleUser.setState(0); + insSampleUser.setUserId(userId); + insSampleUser.setInsSampleId(orderId); + insSampleUser.setSonLaboratory(sonLaboratory); + insSampleUserMapper.insert(insSampleUser); + } + + // 鍒ゆ柇璁㈠崟鏈夋病鏈夌粦瀹氭娊鏍疯鍒� + InsOrder order = insOrderMapper.selectById(orderId); + if (order.getQuarterItemId() != null) { + // 闇�瑕佹坊鍔犱笅鍙戞椂闂村埌鎶芥牱鏃堕棿, 鍙栨牱浜哄憳灏辨槸妫�娴嬩汉 + SpotCheckQuarterItem spotCheckQuarterItem = spotCheckQuarterItemMapper.selectById(order.getQuarterItemId()); + spotCheckQuarterItem.setSpotCheckTime(order.getSendTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); + User user = userMapper.selectById(userId); + spotCheckQuarterItem.setSamplingUser(user.getName()); + spotCheckQuarterItemMapper.updateById(spotCheckQuarterItem); + } + return 1; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int addInsOrder(List<SampleProductDto> list, InsOrder insOrder, List<List<Integer>> pairing) { + // todo: 涓嬪崟鍒ゆ柇鎶芥牱璁″垝鐨勫敮涓�鎬� + if (insOrder.getQuarterItemId() != null) { + Long quarterItemCount = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getQuarterItemId, insOrder.getQuarterItemId()) + .notIn(InsOrder::getState, -1 ,2 ,3)); + if (quarterItemCount > 0) { + throw new ErrorException("璇ユ娊鏍疯鍒掑凡琚粦瀹氳繃"); + } + } + + insOrder.setState(0); + + LocalDate appointed = insOrder.getAppointed(); + + insOrderMapper.insert(insOrder); // 涓昏〃 + + list.forEach(a -> { + a.setId(null); + a.setInsOrderId(insOrder.getId()); + insSampleMapper.insert(a); + if (ObjectUtil.isNotEmpty(a.getInsProduct())) { + // 鍒ゆ柇鏄惁濉啓寰呮椤规暟閲� + if (a.getQuantity() != null) { + List<InsProduct> ip2 = new ArrayList<>(); + for (Integer i = 1; i <= a.getQuantity(); i++) { + // 閲嶆柊鎷疯礉 鍒涘缓鏂板璞� + AtomicInteger atomicInteger = new AtomicInteger(i); + List<InsProduct> insProducts = a.getInsProduct().stream().map(insProduct -> { + insProduct.setRawMaterialTag(String.valueOf(atomicInteger.get())); + InsProduct product = new InsProduct(); + BeanUtils.copyProperties(insProduct, product); + return product; + }).collect(Collectors.toList()); + + ip2.addAll(insProducts); + } + addInsProductMethod(a.getId(), ip2); + } else { + addInsProductMethod(a.getId(), a.getInsProduct()); + } + } + // 鍒ゆ柇鏄惁鏈夌數缂嗛厤缃� + if (ObjectUtil.isNotEmpty(a.getInsulating())) { + // 鍒ゆ柇鏄惁鏈夎緟鍔╃嚎鑺� + if (ObjectUtil.isNotEmpty(a.getAuxiliaryWireCore())) { + if (a.getAuxiliaryWireCore().getInsProduct().stream().filter(insProduct -> insProduct.getState() == 1).count() != + a.getInsulating().getInsProduct().stream().filter(insProduct -> insProduct.getState() == 1).count()) { + throw new ErrorException("鐢电紗閰嶇疆杈呭姪绾胯姱妫�楠岄」鏁伴噺涓嶇粺涓�, 璇锋鏌�"); + } + } + List<InsProduct> ip2 = new ArrayList<>(); + for (String s : a.getInsulating().getNum()) { + // 閲嶆柊鎷疯礉 鍒涘缓鏂板璞� + List<InsProduct> insProducts = a.getInsulating().getInsProduct().stream().map(insProduct -> { + insProduct.setCableTag(s); + InsProduct product = new InsProduct(); + BeanUtils.copyProperties(insProduct, product); + return product; + }).collect(Collectors.toList()); + ip2.addAll(insProducts); + } + for (InsProduct product : ip2) { + product.setStandardMethodListId(a.getInsulating().getStandardMethodListId()); + } + addInsProductMethod(a.getId(), ip2); + } + // 鍒ゆ柇鏄惁鏈夎緟鍔╃嚎鑺� + if (ObjectUtil.isNotEmpty(a.getAuxiliaryWireCore())) { + List<InsProduct> ip2 = new ArrayList<>(); + for (String s : a.getAuxiliaryWireCore().getNum()) { + // 閲嶆柊鎷疯礉 鍒涘缓鏂板璞� + List<InsProduct> insProducts = a.getAuxiliaryWireCore().getInsProduct().stream().map(insProduct -> { + insProduct.setCableTag(s); + InsProduct product = new InsProduct(); + BeanUtils.copyProperties(insProduct, product); + return product; + }).collect(Collectors.toList()); + ip2.addAll(insProducts); + } + for (InsProduct product : ip2) { + product.setStandardMethodListId(a.getAuxiliaryWireCore().getStandardMethodListId()); + } + addInsProductMethod(a.getId(), ip2); + } + // 瀛愭牱鍝侀厤缃� + if (ObjectUtil.isNotEmpty(a.getChildSampleList())) { + for (SampleProductDto b : a.getChildSampleList()) { + for (int i = 0; i < b.getNum(); i++) { + b.setId(null); + b.setInsOrderId(insOrder.getId()); + b.setParentId(a.getId()); + insSampleMapper.insert(b); + if (ObjectUtil.isNotEmpty(b.getInsProduct())) { + addInsProductMethod(b.getId(), b.getInsProduct()); + } + } + } + } + }); + //鏄惁涓哄師鏉愭枡涓嬪崟 + if (insOrder.getTypeSource() != null && insOrder.getTypeSource().equals(1)) { + // 鍘熸潗鏂欎笅鍗�: 濮旀墭浜哄氨鏄姤妫�浜�, 鐢熶骇鍗曚綅灏辨槸渚涘簲鍟嗗崟浣� + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(insOrder.getIfsInventoryId()); + Integer declareUserId = ifsInventoryQuantity.getDeclareUserId(); + User user = userMapper.selectById(declareUserId); + if (user == null) { + throw new ErrorException("缂哄皯鎶ユ浜轰俊鎭�"); + } + // 渚涘簲鍟嗗悕绉� + insOrder.setProduction(ifsInventoryQuantity.getSupplierName()); + insOrder.setProductionEn(""); + // 濮旀墭浜哄悕绉� + insOrder.setPrepareUserId(user.getId()); + insOrder.setPrepareUser(user.getName()); + insOrder.setPrepareUserEn(user.getNameEn()); + insOrder.setPhone(user.getPhone()); + insOrder.setState(1); + Long count1 = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getIfsInventoryId, insOrder.getIfsInventoryId()) + .ne(InsOrder::getState, -1) + .eq(InsOrder::getOrderType, InsOrderTypeConstants.ENTER_THE_FACTORY) + .ne(InsOrder::getId, insOrder.getId())); + // 鍒ゆ柇涔嬪墠鏄惁鏈夎繘鍘傛楠� + if (count1 == 0) { + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>().set(IfsInventoryQuantity::getState, 1) + .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); + } + + // 鍒ゆ柇缁撴潫鐘舵�佷慨鏀瑰悎鏍肩姸鎬� + if (ifsInventoryQuantity.getIsFinish().equals(0)) { + ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() + .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId()) + .set(IfsInventoryQuantity::getInspectStatus, 0)); + } + + upInsOrderOfState(insOrder); + upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "鍘熸潗鏂�"); + + + // 鏍规嵁闆朵欢鍙峰垽鏂槸鍚︽槸杈呮潗 + boolean isRaw = false; + StructureTestObject productObject = insOrderMapper.selectProductByPartNo(ifsInventoryQuantity.getPartNo()); + // 鏌ヨ浜у搧 + if (productObject != null && StrUtil.isNotBlank(productObject.getObjectType()) && productObject.getObjectType().equals("1")) { + isRaw = true; + } else { + // 鏌ヨ瀵硅薄 + StructureTestObject testObject = insOrderMapper.selectByPartNo(ifsInventoryQuantity.getPartNo()); + if (testObject != null && StrUtil.isNotBlank(testObject.getObjectType()) && testObject.getObjectType().equals("1")) { + isRaw = true; + } + } + + if (isRaw) { + // 鑾峰彇褰撳墠瀛e害鐨勫紑濮嬫椂闂村拰缁撴潫鏃堕棿 + LocalDateTime now = LocalDateTime.now(); + // 鑾峰彇褰撳墠鏈堜唤 + int month = now.getMonthValue(); + // 纭畾褰撳墠瀛e害鐨勫紑濮嬫湀浠� + int startMonth = (month - 1) / 3 * 3 + 1; + // 鏋勯�犲搴︾殑寮�濮嬫椂闂� + LocalDateTime startOfQuarter = LocalDateTime.of(now.getYear(), Month.of(startMonth), 1, 0, 0); + // 璁$畻涓嬩竴涓搴︾殑寮�濮嬫椂闂� + LocalDateTime startOfNextQuarter = startOfQuarter.plusMonths(3); + // 璁$畻褰撳墠瀛e害鐨勭粨鏉熸椂闂� + LocalDateTime endOfQuarter = startOfNextQuarter.minusSeconds(1); + + // 鏍规嵁涓嬪崟鐨勮鏍煎瀷鍙峰垽鏂槸鍚︿负瀛e害棣栨鍑虹幇 + Integer count = ifsInventoryQuantityMapper.selectIsFirst(insOrder.getPartDetail(), + ifsInventoryQuantity.getSupplierName(), + startOfNextQuarter, + endOfQuarter); + + if(count == 0) { + ifsInventoryQuantity.setIsFirst(1); + ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() + .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId()) + .set(IfsInventoryQuantity::getIsFirst, 1)); + } + } + } + return insOrder.getId(); + } + + /** + * 娣诲姞妫�楠岄」 + * @param sampleId + * @param productList + */ + private void addInsProductMethod(Integer sampleId, List<InsProduct> productList) { + for (InsProduct product : productList) { + if (product.getState() == 1) { + product.setId(null); + product.setCreateTime(null); + product.setCreateUser(null); + product.setUpdateTime(null); + product.setUpdateUser(null); + product.setInsSampleId(sampleId); + if (product.getInspectionItemSubclass() == null) { + product.setInspectionItemSubclass(""); + } + if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) { + throw new ErrorException("鏈夋楠岄」鐨勮姹傚�兼垨瑕佹眰鎻忚堪涓虹┖, 璇峰厛鍘绘爣鍑嗗簱閰嶇疆瑕佹眰鍊兼垨瑕佹眰鎻忚堪"); + } + insProductMapper.insert(product); + } + } + } + + + @Override + public Map<String, Object> getInsOrder(Integer id) { + Map<String, Object> map = new HashMap<>(); + InsOrder insOrder = insOrderMapper.selectById(id); + List<SampleProductDto> list; + // 鍒ゆ柇鏄惁鏄繘鍘傛姤鍛婂厤妫� + if (insOrder.getIsExemption().equals(1)) { + list = insSampleMapper.selectExemptionByOrderId(id); + } else { + list = insSampleMapper.selectSampleProductListByOrderId2(id); + } + Map<String, Object> map1 = insSampleMapper.selectInsOrder(id); + map.put("insOrder", insOrder); + map.put("sampleProduct", list); + map.put("insOrderTemplate", map1); + return map; + } + + @Override + public int upInsOrderOfState(InsOrder insOrder) { + insOrder.setExamineTime(LocalDateTime.now()); + if (insOrder.getState() == 1) { + //瀹℃牳閫氳繃鎵嶄細鐢熸垚濮旀墭缂栧彿 + // todo: 妫�楠岀被鍨嬬紪鍙� + InsOrder order = this.getById(insOrder.getId()); + String code = ""; + switch (order.getOrderType()) { + case InsOrderTypeConstants.SPOT_CHECK: + code = "C"; + break; + case InsOrderTypeConstants.CUSTOMER_ORDERED: + code = "W"; + break; + case InsOrderTypeConstants.ENTER_THE_FACTORY: + case InsOrderTypeConstants.QUARTERLY_TEST: + code = "Y"; + break; + } + // 鐢熸垚缂栧彿 + String no = numberGenerator.generateNumberWithPrefix(3, + "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), + InsOrder::getEntrustCode); + // 鍒ゆ柇鏄惁鏄搴︽楠�, 鏄搴︽楠屽彇娑堝師鏉愭枡瀛e害妫�楠屼笅鍗� + if (InsOrderTypeConstants.QUARTERLY_TEST.equals(order.getOrderType())) { + ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() + .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId()) + .set(IfsInventoryQuantity::getIsQuarter, 0)); + + // 鏌ヨ鏄惁鏈夎繃杩涘巶妫�楠�, 鏈夎幏鍙栭噷闈㈢殑缂栧彿 + InsOrder order1 = insOrderMapper.selectOne(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getIfsInventoryId, order.getIfsInventoryId()) + .ne(InsOrder::getState, -1) + .eq(InsOrder::getOrderType, InsOrderTypeConstants.ENTER_THE_FACTORY)); + if (order1 != null) { + no = order1.getEntrustCode(); + } + } + + int count = 1; + // 鏌ヨ鏍峰搧琛� + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() + .eq(InsSample::getInsOrderId, insOrder.getId())); + for (InsSample insSample : insSamples) { + if (StringUtils.isBlank(insSample.getSampleCode())) { + // 濡傛灉鍙湁涓�涓牱鍝佸氨涓嶉渶瑕佹嫾鎺ユ暟瀛� + if (insSamples.size() != 1) { + insSample.setSampleCode(no + "-" + count); + count++; + } else { + insSample.setSampleCode(no); + } + } + } + insSampleService.updateBatchById(insSamples); + + insOrder.setEntrustCode(no); + } + return insOrderMapper.updateById(insOrder); + } + + @Override + public Map<String, Object> getInsOrderAndSample(Integer id, String laboratory) { + Map<String, Object> map = new HashMap<>(); + InsOrder insOrder = insOrderMapper.selectById(id); + List<SampleProductDto> list = insSampleMapper.getInsOrderAndSample(id, laboratory); + for (SampleProductDto sampleProductDto : list) { + List<Integer> ids = sampleProductDto.getInsProduct().stream().map(InsProduct::getId).collect(Collectors.toList()); + List<InsProductUser> insProductUsers = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery() + .in(InsProductUser::getInsProductId, ids)); + if (CollectionUtils.isNotEmpty(insProductUsers)) { + List<Integer> userIds = insProductUsers.stream().map(InsProductUser::getCreateUser).distinct().collect(Collectors.toList()); + String collect = userMapper.selectBatchIds(userIds).stream().map(User::getName).collect(Collectors.joining(",")); + sampleProductDto.setCheckName(collect); + } + } + map.put("insOrder", insOrder); + map.put("sampleProduct", list); + //鏌ヨ鎵�鏈夎褰曟ā鐗堝幓閲� + List<Map<Integer, Object>> list2 = insOrderMapper.selectReportModelByOrderId(id, laboratory); + map.put("reportModel", list2); + return map; + } + + @Override + public IPage<SampleProductDto2> selectSampleAndProductByOrderId(IPage<SampleProductDto2> page, SampleProductDto2 sampleProductDto) { + IPage<SampleProductDto2> productDto2IPage = insOrderMapper.selectSampleAndProductByOrderId(page, + QueryWrappers.queryWrappers(sampleProductDto) + .orderByAsc("sample_code") + .orderByAsc("cable_tag") + .orderByAsc("sort"), + sampleProductDto.getId()); + return productDto2IPage; + } + + @Override + public IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto) { + String dates = costStatisticsDto.getDates(); + String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); + costStatisticsDto.setDates(null); + + //todo:浠呯湅鑷繁 + + IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); + List<CostStatisticsDto> collect = dtoIPage.getRecords().stream().map(dto -> { + Set<String> uniqueTags = new HashSet<>(); + if (dto.getInspectionItem().contains(",")) { + for (String s : dto.getInspectionItem().split(",")) { + uniqueTags.add(s.split("@")[0]); + } + } else { + uniqueTags.add(dto.getInspectionItem().split("@")[0]); + } + dto.setInspectionItem(uniqueTags.toString()); + return dto; + }).collect(Collectors.toList()); + dtoIPage.setRecords(collect); + return dtoIPage; + } + + @Override + public Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto) { + Map<String, Object> map = new HashMap<>(); + String dates = costStatisticsDto.getDates(); + String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); + costStatisticsDto.setDates(null); + List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); + double totalPrice = costStatisticsDtos.stream() + .filter(dto -> dto.getPrice() != null) // 杩囨护鎺変环鏍间负 null 鐨勫璞� + .mapToDouble(value -> value.getPrice().doubleValue() * value.getNum()) + .sum(); + map.put("total", totalPrice); + return map; + } + + @Override + public Map<String, Object> selectSampleDefects(Page page, String inspectionItems, String orderNumber) { + List<SampleDefectsFatherVo> sampleDefectsFatherVos = insOrderMapper.selectSampleDefects(page, inspectionItems, orderNumber); + Map<String, Object> map = new HashMap<>(); + map.put("records", sampleDefectsFatherVos); + Long aLong = insOrderMapper.getCount(inspectionItems, orderNumber); + map.put("total", aLong); + return map; + } + + @Override + public int updateStatus(Integer id) { + return insOrderMapper.updateStatus(id); + } + + + @Override + public void export(CostStatisticsDto costStatisticsDto, HttpServletResponse response) throws IOException { + //鏌ヨ瀵煎嚭鐨勮垂鐢ㄧ粺璁℃暟鎹� + String dates = costStatisticsDto.getDates(); + String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); + costStatisticsDto.setDates(null); + List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); + costStatisticsDtos = costStatisticsDtos.stream().map(dto -> { + Set<String> uniqueTags = new HashSet<>(); + if (dto.getInspectionItem().contains(",")) { + for (String s : dto.getInspectionItem().split(",")) { + uniqueTags.add(s.split("@")[0]); + } + } else { + uniqueTags.add(dto.getInspectionItem().split("@")[0]); + } + dto.setInspectionItem(uniqueTags.toString()); + return dto; + }).collect(Collectors.toList()); + + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴 + String fileName = URLEncoder.encode("鏍峰搧璐圭敤缁熻瀵煎嚭", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + Map<String, List<CostStatisticsDto>> groupByCompany = + costStatisticsDtos.stream().filter(e -> StrUtil.isNotEmpty(e.getCompany())) + .collect(Collectors.groupingBy(CostStatisticsDto::getCompany)); + try { + // 鏂板缓ExcelWriter + // 鏂板缓ExcelWriter + ExcelWriter excelWriter = + EasyExcel.write(response.getOutputStream()) + .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) + .build(); + for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) { + String sheetName = companyDataEntry.getKey(); + List<CostStatisticsDto> dataList = companyDataEntry.getValue(); + WriteSheet mainSheet = EasyExcel.writerSheet(sheetName) + .head(CostStatisticsDto.class) + .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) + .build(); + excelWriter.write(dataList, mainSheet); + } + // 鍏抽棴娴� + excelWriter.finish(); + } catch (IOException e) { + throw new RuntimeException("瀵煎嚭澶辫触"); + } + } + + /** + * 鑾峰彇ifs搴撳瓨淇℃伅 + * @param + * @return + */ + @Override + public void getIfsOrder() { + HashMap<String, Object> map = new HashMap<>(); + map.put("LOCATION_NO","1302"); + map.put("STATE_DB","To be Inspected"); + List<Map<String, Object>> inventory = ifsApiUtils.getInventory(JSONUtil.toJsonStr(map)); + if(inventory.size() == 0) { + return; + } + // 杩涜淇濆瓨 + for (Map<String, Object> map1 : inventory) { + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // 鏃堕棿鏍煎紡鍖� + IfsInventoryQuantity ifsInventoryQuantity = new IfsInventoryQuantity(); + ifsInventoryQuantity.setContract(map1.get("CONTRACT") == null ? "" : map1.get("CONTRACT").toString()); // 鍩� + ifsInventoryQuantity.setPartNo(map1.get("PART_NO") == null ? "" : map1.get("PART_NO").toString() ); // 闆朵欢鍙� + ifsInventoryQuantity.setPartDesc(map1.get("PART_DESC") == null ? "" : map1.get("PART_DESC").toString()); // 闆朵欢鎻忚堪 + ifsInventoryQuantity.setOrderNo(map1.get("ORDER_NO") == null ? "" : map1.get("ORDER_NO").toString()); // 璁㈠崟鍙� + ifsInventoryQuantity.setLineNo(map1.get("LINE_NO") == null ? "" : map1.get("LINE_NO").toString()); // 琛屽彿 + ifsInventoryQuantity.setReleaseNo(map1.get("RELEASE_NO") == null ? "" : map1.get("RELEASE_NO").toString()); // 涓嬭揪鍙� + ifsInventoryQuantity.setReceiptNo(Integer.parseInt(map1.get("RECEIPT_NO") == null ? "" : map1.get("RECEIPT_NO").toString())); // 鎺ユ敹鍙� + ifsInventoryQuantity.setStatus(map1.get("STATE") == null ? "" : map1.get("STATE").toString()); // 鐘舵�佹弿杩� + ifsInventoryQuantity.setStatusDb(map1.get("STATE_DB") == null ? "" : map1.get("STATE_DB").toString()); // 鐘舵�� + if(map1.get("QTY_ARRIVED") != null) { + ifsInventoryQuantity.setQtyArrived(new BigDecimal(map1.get("QTY_ARRIVED").toString())); // 鎶佃揪鐨勯噰璐暟閲� + } + if(map1.get("QTY_INSPECTED") != null) { + ifsInventoryQuantity.setQtyInspected(new BigDecimal(map1.get("QTY_INSPECTED").toString())); // 宸叉楠岀殑璐拱鏁伴噺 + } + if(map1.get("QTY_TO_INSPECT") != null) { + ifsInventoryQuantity.setQtyToInspect(new BigDecimal(map1.get("QTY_TO_INSPECT").toString())); // 瑕佹楠岀殑閲囪喘鏁伴噺 + } + if(map1.get("INV_QTY_IN_STORE") != null) { + ifsInventoryQuantity.setInvQtyInStore(new BigDecimal(map1.get("INV_QTY_IN_STORE").toString())); // 鎶佃揪鐨勫簱瀛樻暟閲� + } + if(map1.get("PUR_QTY_IN_STORE") != null) { + ifsInventoryQuantity.setPurQtyInStore(new BigDecimal( map1.get("PUR_QTY_IN_STORE").toString())); // 鎶佃揪鐨勯噰璐暟閲� + + } + ifsInventoryQuantity.setSupplierId(map1.get("SUPPLIER_ID") == null ? "" : map1.get("SUPPLIER_ID").toString()); // 渚涘簲鍟咺D + ifsInventoryQuantity.setSupplierName(map1.get("SUPPLIER_NAME") == null ? "" : map1.get("SUPPLIER_NAME").toString()); // 渚涘簲鍟嗗悕绉� + ifsInventoryQuantity.setConfigurationId(map1.get("CONFIGURATION_ID") == null ? "" : map1.get("CONFIGURATION_ID").toString()); // 閰嶇疆鏍囪瘑 + ifsInventoryQuantity.setLotBatchNo(map1.get("LOT_BATCH_NO") == null ? "" : map1.get("LOT_BATCH_NO").toString()); // 鎵规鍙� + ifsInventoryQuantity.setUpdateBatchNo(map1.get("LOT_BATCH_NO") == null ? "" : map1.get("LOT_BATCH_NO").toString()); // 鎵规鍙� + ifsInventoryQuantity.setWaivDevRejNo(map1.get("WAIV_DEV_REJ_NO") == null ? "" : map1.get("WAIV_DEV_REJ_NO").toString()); // WDR鍙� + ifsInventoryQuantity.setActivitySeq(map1.get("ACTIVITY_SEQ") == null ? null : Integer.parseInt(map1.get("ACTIVITY_SEQ").toString())); // 娲诲姩搴忓垪 + ifsInventoryQuantity.setSerialNo(map1.get("SERIAL_NO") == null ? "" : map1.get("SERIAL_NO").toString()); // 搴忓垪鍙� + ifsInventoryQuantity.setLocationNo(map1.get("LOCATION_NO") == null ? "" : map1.get("LOCATION_NO").toString()); // 搴撲綅鍙� + ifsInventoryQuantity.setEngChgLevel(map1.get("ENG_CHG_LEVEL") == null ? "" : map1.get("ENG_CHG_LEVEL").toString()); // 鐗堟湰鍙� + ifsInventoryQuantity.setReceiver(map1.get("RECEIVER") == null ? "" : map1.get("RECEIVER").toString()); // 鎺ユ敹浜� + ifsInventoryQuantity.setReceiverName(map1.get("RECEIVER_NAME") == null ? "" : map1.get("RECEIVER_NAME").toString()); // 鎺ユ敹浜哄悕绉� + ifsInventoryQuantity.setBuyerCode(map1.get("BUYER_CODE") == null ? "" : map1.get("BUYER_CODE").toString()); // 閲囪喘鍛� + ifsInventoryQuantity.setBuyerName(map1.get("BUYER_NAME") == null ? "" : map1.get("BUYER_NAME").toString()); // 閲囪喘鍛樺悕绉� + + if(map1.get("ARRIVE_DATE") != null) { + ifsInventoryQuantity.setArriveDate(LocalDateTime.parse(map1.get("ARRIVE_DATE").toString(),dateTimeFormatter)); // 瀹為檯鍒拌揣鏃ユ湡 + } + if(map1.get("DELIVERY_DATE") != null) { + ifsInventoryQuantity.setDeliveryDate(LocalDateTime.parse(map1.get("DELIVERY_DATE").toString(),dateTimeFormatter)); // 瀹為檯浜よ揣鏃ユ湡 + } + if(map1.get("PRODUCT_DATE") != null) { + ifsInventoryQuantity.setProductDate(LocalDateTime.parse(map1.get("PRODUCT_DATE").toString(),dateTimeFormatter)); // 鐢熶骇鏃ユ湡 + + } + if(map1.get("INVALID_DATE") != null) { + ifsInventoryQuantity.setInvalidDate(LocalDateTime.parse(map1.get("INVALID_DATE").toString(),dateTimeFormatter)); // 澶辨晥鏃ユ湡 + } + if(map1.get("APPROVED_DATE") != null) { + ifsInventoryQuantity.setApprovedDate(LocalDateTime.parse(map1.get("APPROVED_DATE").toString(),dateTimeFormatter)); // 瀹℃壒鏃ユ湡 + } + ifsInventoryQuantity.setReqCeater(map1.get("REQ_CEATER") == null ? "" : map1.get("REQ_CEATER").toString()); // 閲囪喘鐢宠鍒涘缓浜� + ifsInventoryQuantity.setReqCeaterName(map1.get("REQ_CEATER_NAME") == null ? "" : map1.get("REQ_CEATER_NAME").toString()); // 閲囪喘鐢宠鍒涘缓浜哄悕绉� + ifsInventoryQuantity.setLineRemarks(map1.get("LINE_REMARKS") == null ? "" : map1.get("LINE_REMARKS").toString()); // 閲囪喘璁㈠崟琛屽娉� + ifsInventoryQuantity.setBuyUnitMeas(map1.get("BUY_UNIT_MEAS") == null ? "" : map1.get("BUY_UNIT_MEAS").toString()); // 閲囪喘鍗曚綅 + ifsInventoryQuantity.setReceiverDate(LocalDateTime.now()); // 鎺ユ敹鏃ユ湡 + ifsInventoryQuantity.setIsSource(1); + ifsInventoryQuantity.setState(0); + + IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectOne(new LambdaQueryWrapper<IfsInventoryQuantity>() + .eq(IfsInventoryQuantity::getOrderNo, ifsInventoryQuantity.getOrderNo()) + .eq(IfsInventoryQuantity::getLineNo, ifsInventoryQuantity.getLineNo()) + .eq(IfsInventoryQuantity::getReleaseNo, ifsInventoryQuantity.getReleaseNo()) + .eq(IfsInventoryQuantity::getReceiptNo, ifsInventoryQuantity.getReceiptNo()) + .eq(IfsInventoryQuantity::getLocationNo, ifsInventoryQuantity.getLocationNo()) + .eq(IfsInventoryQuantity::getLotBatchNo, ifsInventoryQuantity.getLotBatchNo()) + .eq(IfsInventoryQuantity::getSerialNo, ifsInventoryQuantity.getSerialNo()) + .eq(IfsInventoryQuantity::getEngChgLevel, ifsInventoryQuantity.getEngChgLevel()) + .eq(IfsInventoryQuantity::getWaivDevRejNo, ifsInventoryQuantity.getWaivDevRejNo()) + .eq(IfsInventoryQuantity::getActivitySeq, ifsInventoryQuantity.getActivitySeq()) + ); + if(Objects.isNull(one)) { + + ifsInventoryQuantity.setIsFirst(0); + // 鏌ヨ浜т笟閾炬娴嬫暟鎹� + String industryChainAttrFields = IndustryChainUtils.getIndustryChainAttrFields(ifsInventoryQuantity.getOrderNo(), + ifsInventoryQuantity.getLineNo(), + ifsInventoryQuantity.getReleaseNo()); + ifsInventoryQuantity.setIndustryChain(industryChainAttrFields); + + ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); + } + } + } + + /** + * id鏄師鏉愭枡鐨刬d + * + * 淇敼璁㈠崟鍗曞彿 + * @param insOrder + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateEntrustCode(InsOrder insOrder) { + // 鍒ゆ柇褰撳墠璁㈠崟鏄惁鐢熸垚浜嗘姤鍛�, 鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀瑰崟鍙� + List<InsOrder> insOrders = insOrderMapper.selectList(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getIfsInventoryId, insOrder.getId()) + .ne(InsOrder::getState, -1)); + List<Integer> insOrderIds = insOrders.stream().map(InsOrder::getId).collect(Collectors.toList()); + Long count = insReportMapper.selectCount(Wrappers.<InsReport>lambdaQuery() + .in(InsReport::getInsOrderId, insOrderIds)); + if (count > 0 ) { + throw new ErrorException("褰撳墠璁㈠崟宸茬粡鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀圭紪鍙�"); + } + + + Long count1 = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getEntrustCode, insOrder.getEntrustCode()) + .ne(InsOrder::getIfsInventoryId, insOrder.getId()) + .ne(InsOrder::getInsState, -1)); + if (count1 > 0) { + throw new ErrorException("璇ョ紪鍙烽噸澶�"); + } + + //淇敼鎶ュ憡鐨勭紪鍙� + insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() + .eq(InsOrder::getIfsInventoryId, insOrder.getId()) + .set(InsOrder::getEntrustCode, insOrder.getEntrustCode())); + + // 淇敼鏍峰搧鐨勭紪鍙� + // 鏌ヨ鎵�鏈夌殑鏍峰搧 + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() + .in(InsSample::getInsOrderId, insOrderIds)); + for (InsSample insSample : insSamples) { + String sampleCode = insSample.getSampleCode(); + String updateCode = insOrder.getEntrustCode(); + // 鏌ユ壘鏈�鍚庝竴涓�'-'鐨勪綅缃� + int lastDashIndex = sampleCode.lastIndexOf('-'); + if (lastDashIndex != -1) { + int secondLastDashIndex = sampleCode.lastIndexOf('-', lastDashIndex - 1); + // 澶勭悊鏈�鍚庝竴涓�'-'鍓嶇殑閮ㄥ垎 + if (secondLastDashIndex != -1) { + // 澶勭悊鏈�鍚庝竴涓�'-'鍙婁箣鍚庣殑閮ㄥ垎 + String afterLastDash = sampleCode.substring(lastDashIndex); + + updateCode = updateCode + afterLastDash; + } + } + insSampleMapper.update(null, Wrappers.<InsSample>lambdaUpdate() + .eq(InsSample::getId, insSample.getId()) + .set(InsSample::getSampleCode, updateCode)); + + } + } + + @Override + public List<InsUnqualifiedRetestProduct> getRetestResult(Integer insProductId) { + return insUnqualifiedRetestProductMapper.selectList(Wrappers.<InsUnqualifiedRetestProduct>lambdaQuery() + .eq(InsUnqualifiedRetestProduct::getInsProductId, insProductId)); + } + + /** + * 淇敼閲囪喘璁㈠崟鎺ユ敹鐘舵��, 閬垮厤鍥炴粴 + * @param id + */ + @Transactional + public void updateIfsInventoryQuantity(Integer id) { + ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() + .set(IfsInventoryQuantity::getIsRegister, 1) + .eq(IfsInventoryQuantity::getId, id)); + } + + /** + * 鏂板閾滃崟涓濅笅鍗� + * @param list + * @param insOrder + * @return + */ + @Override + public int addRawCopperOrder(List<SampleProductDto> list, CopperInsOrderDto insOrder) { + insOrder.setState(1); + insOrder.setTypeSource(1); + + LocalDate appointed = insOrder.getAppointed(); + + insOrderMapper.insert(insOrder); // 涓昏〃 + + list.forEach(a -> { + a.setId(null); + a.setInsOrderId(insOrder.getId()); + insSampleMapper.insert(a); + if (ObjectUtil.isNotEmpty(a.getInsProduct())) { + // 鍒ゆ柇鏄惁濉啓寰呮椤规暟閲� + if (a.getQuantity() != null) { + List<InsProduct> ip2 = new ArrayList<>(); + for (Integer i = 1; i <= a.getQuantity(); i++) { + // 閲嶆柊鎷疯礉 鍒涘缓鏂板璞� + AtomicInteger atomicInteger = new AtomicInteger(i); + List<InsProduct> insProducts = a.getInsProduct().stream().map(insProduct -> { + insProduct.setRawMaterialTag(String.valueOf(atomicInteger.get())); + InsProduct product = new InsProduct(); + BeanUtils.copyProperties(insProduct, product); + return product; + }).collect(Collectors.toList()); + + ip2.addAll(insProducts); + } + addInsProductMethod(a.getId(), ip2); + } else { + addInsProductMethod(a.getId(), a.getInsProduct()); + } + } + if (ObjectUtil.isNotEmpty(a.getChildSampleList())) { + for (SampleProductDto b : a.getChildSampleList()) { + for (int i = 0; i < b.getNum(); i++) { + b.setId(null); + b.setInsOrderId(insOrder.getId()); + b.setParentId(a.getId()); + insSampleMapper.insert(b); + if (ObjectUtil.isNotEmpty(b.getInsProduct())) { + addInsProductMethod(b.getId(), b.getInsProduct()); + } + } + } + } + }); + + // 娣诲姞鍘熸潗鏂欎俊鎭� + IfsInventoryQuantity ifsInventoryQuantity = new IfsInventoryQuantity(); + // 鍩烘湰淇℃伅 + ifsInventoryQuantity.setIsSource(0); + ifsInventoryQuantity.setIsInspect(1); + ifsInventoryQuantity.setState(1); + ifsInventoryQuantity.setIsFinish(0); + ifsInventoryQuantity.setIsCopper(1); + ifsInventoryQuantity.setIsQuarter(0); + ifsInventoryQuantity.setInspectStatus(0); + + ifsInventoryQuantity.setQtyArrived(insOrder.getQtyArrived()); + ifsInventoryQuantity.setBuyUnitMeas(insOrder.getBuyUnitMeas()); + ifsInventoryQuantity.setSupplierName(insOrder.getSupplierName()); + ifsInventoryQuantity.setUpdateBatchNo(insOrder.getUpdateBatchNo()); + ifsInventoryQuantity.setDeclareDate(insOrder.getDeclareDate()); + + ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); + + + insOrder.setIfsInventoryId(ifsInventoryQuantity.getId()); + insOrder.setState(1); + + + upInsOrderOfState(insOrder); + upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "鍘熸潗鏂�"); + + return insOrder.getId(); + } + + /** + * 淇敼濮旀墭涓嬪崟缂栧彿 + * @param insOrder + */ + @Override + public void updateOrderEntrustCode(InsOrder insOrder) { + // 鍒ゆ柇褰撳墠璁㈠崟鏄惁鐢熸垚浜嗘姤鍛�, 鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀瑰崟鍙� + Long count = insReportMapper.selectCount(Wrappers.<InsReport>lambdaQuery() + .eq(InsReport::getInsOrderId, insOrder.getId())); + if (count > 0 ) { + throw new ErrorException("褰撳墠璁㈠崟宸茬粡鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀圭紪鍙�"); + } + + Long count1 = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getEntrustCode, insOrder.getEntrustCode())); + if (count1 > 0) { + throw new ErrorException("璇ョ紪鍙烽噸澶�"); + } + + //淇敼鎶ュ憡鐨勭紪鍙� + insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() + .eq(InsOrder::getId, insOrder.getId()) + .set(InsOrder::getEntrustCode, insOrder.getEntrustCode())); + + // 淇敼鏍峰搧鐨勭紪鍙� + // 鏌ヨ鎵�鏈夌殑鏍峰搧 + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() + .eq(InsSample::getInsOrderId, insOrder.getId())); + for (InsSample insSample : insSamples) { + String sampleCode = insSample.getSampleCode(); + String updateCode = insOrder.getEntrustCode(); + // 鏌ユ壘鏈�鍚庝竴涓�'-'鐨勪綅缃� + int lastDashIndex = sampleCode.lastIndexOf('-'); + if (lastDashIndex != -1) { + int secondLastDashIndex = sampleCode.lastIndexOf('-', lastDashIndex - 1); + // 澶勭悊鏈�鍚庝竴涓�'-'鍓嶇殑閮ㄥ垎 + if (secondLastDashIndex != -1) { + // 澶勭悊鏈�鍚庝竴涓�'-'鍙婁箣鍚庣殑閮ㄥ垎 + String afterLastDash = sampleCode.substring(lastDashIndex); + + updateCode = updateCode + afterLastDash; + } + } + insSampleMapper.update(null, Wrappers.<InsSample>lambdaUpdate() + .eq(InsSample::getId, insSample.getId()) + .set(InsSample::getSampleCode, updateCode)); + + } + } + + /** + * 淇敼妫�楠屼笅鍗曞唴瀹� + * @param insOrderUpdateDto + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean updateInsOrder(InsOrderUpdateDto insOrderUpdateDto) { + // 淇敼璁㈠崟 + insOrderUpdateDto.getInsOrder().setState(0); + insOrderUpdateDto.getInsOrder().setTell(""); + insOrderMapper.updateById(insOrderUpdateDto.getInsOrder()); + + // 淇敼妫�楠岄」 + for (SampleProductDto sampleProductDto : insOrderUpdateDto.getSampleProduct()) { + insProductService.updateBatchById(sampleProductDto.getInsProduct()); + } + + return true; + } + + /** + * 鎴愬搧鏍囩鎵撳嵃 + * @param ids + * @return + */ + @Override + public List<InsOrderPrintingVo> labelOrderPrinting(List<Integer> ids) { + return insOrderMapper.labelOrderPrinting(ids); + } + + /** + * 鏍规嵁鏍峰搧id鏌ヨ妫�楠岄」鏍� + * @param insSampleId + * @return + */ + @Override + public List<StandardProductList> getProductTreeBySampleId(Integer insSampleId) { + // 鏌ヨ绗竴涓楠岄」鑾峰彇妫�楠岄」鏍� + InsProduct insProduct = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() + .eq(InsProduct::getInsSampleId, insSampleId) + .last("limit 1")); + String tree = insProduct.getFactory() + " - " + + insProduct.getLaboratory() + " - " + + insProduct.getSampleType() + " - " + + insProduct.getSample() + " - " + + insProduct.getModel(); + // 鏌ヨ鏍囧噯鏍� + List<StandardProductList> standardProductLists = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery() + .eq(StandardProductList::getStandardMethodListId, insProduct.getStandardMethodListId()) + .eq(StandardProductList::getTree, tree)); + for (StandardProductList standardProductList : standardProductLists) { + standardProductList.setId(null); + } + + return standardProductLists; + } + + /** + * 娣诲姞閬楁紡鐨勬楠岄」 + * @param omitOrderProductDto + * @return + */ + @Override + public boolean addOmitOrderProduct(OmitOrderProductDto omitOrderProductDto) { + if (omitOrderProductDto.getInsSampleId() == null) { + throw new ErrorException("缂哄皯鏍峰搧Id"); + } + for (InsProduct product : omitOrderProductDto.getInsProductBindingList()) { + if (product.getState() == 1) { + product.setId(null); + product.setCreateTime(null); + product.setCreateUser(null); + product.setUpdateTime(null); + product.setUpdateUser(null); + product.setInsSampleId(omitOrderProductDto.getInsSampleId()); + if (StringUtils.isBlank(product.getCableTag())) { + product.setCableTag(null); + } + if (product.getInspectionItemSubclass() == null) { + product.setInspectionItemSubclass(""); + } + if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) { + throw new ErrorException("鏈夋楠岄」鐨勮姹傚�兼垨瑕佹眰鎻忚堪涓虹┖, 璇峰~鍐欒姹傚�兼垨瑕佹眰鎻忚堪"); + } + insProductMapper.insert(product); + } + } + + return true; + } + + /** + * 鎴愬搧妫�楠屽崟瀵煎嚭 + * @param sampleOrderDto + * @param response + */ + @Override + public void rawAllInsOrderExport(SampleOrderDto sampleOrderDto, HttpServletResponse response) { + //鍒ゆ柇鍏ㄩ儴,涓汉,缁勭粐鐨勬潈闄� + //todo:浠呯湅鎴戣幏鍙栧綋鍓嶄汉鎵�灞炲疄楠屽id + String laboratory = null; + // 鍒ゆ柇鏄惁鏄叏閮� + String isOrderAll = null; + if (sampleOrderDto.getState() != null && sampleOrderDto.getState() == -2) { + isOrderAll = "1"; + sampleOrderDto.setState(null); + } + List<SampleOrderDto> sampleOrderDtoList = insOrderMapper.rawAllInsOrderExport(QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); + + // 鍒ゆ柇鏄惁鏄笉鍚堟牸, 涓嶅悎鏍兼煡璇笉鍚堟牸椤� + for (SampleOrderDto orderDto : sampleOrderDtoList) { + if (orderDto.getInsResult() != null && orderDto.getInsResult() == 0){ + // 鏌ヨ涓嶅悎鏍奸」 + List<String> unqualifiedList = insProductMapper.selectUnqualifiedList(orderDto.getId()); + orderDto.setUnqualifiedItem(CollUtil.join(unqualifiedList, ",")); + } + orderDto.setCreateTimeString(orderDto.getCreateTime() == null ? "" : orderDto.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + + } + + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + try { + // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴 + String fileName = URLEncoder.encode("濮旀墭妫�娴嬩俊鎭鍑�", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + //鏂板缓ExcelWriter + ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); + //鑾峰彇sheet0瀵硅薄 + WriteSheet mainSheet = EasyExcel.writerSheet(0, "濮旀墭妫�娴嬩俊鎭鍑�").head(SampleOrderDto.class).build(); + + //鍚憇heet0鍐欏叆鏁版嵁 浼犲叆绌簂ist杩欐牱鍙鍑鸿〃澶� + excelWriter.write(sampleOrderDtoList, mainSheet); + //鍏抽棴娴� + excelWriter.finish(); + } catch (IOException e) { + throw new RuntimeException("瀵煎嚭澶辫触"); + } + } + +} + + + + diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderTemplateServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderTemplateServiceImpl.java new file mode 100644 index 0000000..b56ffeb --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderTemplateServiceImpl.java @@ -0,0 +1,57 @@ +package com.ruoyi.inspect.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.inspect.mapper.InsOrderTemplateMapper; +import com.ruoyi.inspect.pojo.InsOrderTemplate; +import com.ruoyi.inspect.service.InsOrderTemplateService; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author Administrator + * @description 閽堝琛ㄣ�恑ns_order_template銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇 + * @createDate 2024-03-18 14:14:54 + */ +@Service +@AllArgsConstructor +public class InsOrderTemplateServiceImpl extends ServiceImpl<InsOrderTemplateMapper, InsOrderTemplate> + implements InsOrderTemplateService { + + private InsOrderTemplateMapper insOrderTemplateMapper; + + @Override + public int addInsOrderTemplate(InsOrderTemplate insOrderTemplate) { + return insOrderTemplateMapper.insert(insOrderTemplate); + } + + @Override + public List<InsOrderTemplate> selectInsOrderTemplate(String company) { + if (ObjectUtils.isEmpty(company) || company.equals("")) { + return insOrderTemplateMapper.selectList(Wrappers.<InsOrderTemplate>lambdaQuery() + .select(InsOrderTemplate.class, info -> !info.getColumn().equals("thing"))); + } else { + //鏍规嵁濮旀墭鍗曚綅杩涜绛涢�� + return insOrderTemplateMapper.selectList(Wrappers.<InsOrderTemplate>lambdaQuery() + .like(InsOrderTemplate::getThing,"\"company\":\""+ company+"\"") + .select(InsOrderTemplate.class, info -> !info.getColumn().equals("thing"))); + } + } + + @Override + public String selectInsOrderTemplateById(Integer id) { + return insOrderTemplateMapper.selectById(id).getThing(); + } + + @Override + public int delInsOrderTemplate(Integer id) { + return insOrderTemplateMapper.deleteById(id); + } +} + + + + diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductServiceImpl.java new file mode 100644 index 0000000..63619a2 --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductServiceImpl.java @@ -0,0 +1,221 @@ +package com.ruoyi.inspect.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.basic.mapper.StandardProductListMapper; +import com.ruoyi.basic.pojo.StandardProductList; +import com.ruoyi.framework.exception.ErrorException; +import com.ruoyi.inspect.dto.InsProductBindingDto; +import com.ruoyi.inspect.mapper.InsOrderMapper; +import com.ruoyi.inspect.mapper.InsProductMapper; +import com.ruoyi.inspect.mapper.InsSampleMapper; +import com.ruoyi.inspect.pojo.InsOrder; +import com.ruoyi.inspect.pojo.InsProduct; +import com.ruoyi.inspect.pojo.InsSample; +import com.ruoyi.inspect.service.InsProductService; +import lombok.AllArgsConstructor; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +@Service +@AllArgsConstructor +@Transactional(rollbackFor = Exception.class) +public class InsProductServiceImpl extends ServiceImpl<InsProductMapper, InsProduct> + implements InsProductService { + + private InsProductMapper insProductMapper; + + private InsOrderMapper insOrderMapper; + + private InsSampleMapper insSampleMapper; + + private StandardProductListMapper standardProductListMapper; + + @Override + public int selectOrderManDay(Integer orderId) { + return insProductMapper.selectOrderManDay(orderId); + } + + @Override + public int updateInspected(Integer id, String ids) { + InsOrder insOrder = new InsOrder(); + insOrder.setId(id); + insOrder.setIsRevocation(1);//闇�瑕佸鏍� + insOrder.setRevocationInsProductIds(ids); + return insOrderMapper.updateById(insOrder); + } + + @Override + public boolean write(InsOrder insOrder) { + insOrderMapper.updateById(insOrder); + return true; + } + + //鏌ヨ寰呮椤圭洰 + @Override + public IPage<InsProduct> selectNoProducts(Page page, InsProduct insProduct, Integer orderId, String ids) { + List<Integer> noIds = null; + if (StringUtils.isNotBlank(ids)) { + noIds = Arrays.asList(ids.split(",")).stream() + .map(Integer::parseInt) + .collect(Collectors.toList()); + } + IPage<InsProduct> insProductIPage = baseMapper.selectNoProducts(page, orderId, noIds); + return insProductIPage; + } + + //瀹℃牳寰呮鎾ら攢 + @Override + public void checkUpdate(Integer orderId, Integer state) { + InsOrder insOrder = insOrderMapper.selectById(orderId); + if (state == 1) { + List<String> list = new ArrayList<>(); + try { + list = Arrays.asList(insOrder.getRevocationInsProductIds().split(",")); + } catch (Exception e) { + throw new ErrorException("杩樻病鏈夐�夋嫨搴旇瑕佹挙閿�鐨勬楠岄」鐩�"); + } + List<Integer> ids = list.stream() + .map(Integer::parseInt) + .collect(Collectors.toList()); + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)); + List<Integer> collect = insSamples.stream().map(InsSample::getId).collect(Collectors.toList()); + List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).in(InsProduct::getInsSampleId, collect)); + if (insProducts.stream().map(InsProduct::getId).collect(Collectors.toList()).equals(ids)) { + //濡傛灉璇ユ楠屽崟涓嬬殑鎵�鏈夐」鐩叏閮ㄩ兘鎾ら攢,閭d箞杩欎釜鍗曞瓙涔熼渶瑕佹挙閿� + insOrder.setState(3); + } else { + List<InsProduct> products = insProductMapper.selectBatchIds(ids); + //棣栧厛鏍规嵁閫夋嫨鐨勯」鐩甶d杩涜鎾ら攢椤圭洰 + updateBatchById(products.stream().map(insProduct -> { + insProduct.setState(0); + return insProduct; + }).collect(Collectors.toList())); + } + //insProductMapper.updateInspected(id); + } + //涓嶉�氳繃 + insOrder.setIsRevocation(0); + insOrderMapper.updateById(insOrder); + + } + + + /** + * 鏍规嵁妫�楠岄」id鏌ヨ妫�楠岄」鏍戜俊鎭� + * @param productId + * @return + */ + @Override + public List<InsProduct> getProductTreeByProductId(Integer productId) { + // 鏌ヨ妫�楠岄」淇℃伅 + InsProduct insProduct = insProductMapper.selectById(productId); + String tree = insProduct.getFactory() + " - " + + insProduct.getLaboratory() + " - " + + insProduct.getSampleType() + " - " + + insProduct.getSample() + " - " + + insProduct.getModel(); + // 鏌ヨ鏍囧噯鏍� + List<StandardProductList> standardProductLists = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery() + .eq(StandardProductList::getStandardMethodListId, insProduct.getStandardMethodListId()) + .eq(StandardProductList::getTree, tree)); + + List<InsProduct> insProducts = standardProductLists.stream().map(standardProductList -> { + InsProduct product = new InsProduct(); + BeanUtils.copyProperties(standardProductList, product); + // 闃叉搴忓垪鍖栭敊璇� + product.setTemplate(null); + product.setStyle(null); + return product; + }).collect(Collectors.toList()); + return insProducts; + } + + /** + * 鐗规畩妫�楠岄」缁戝畾 + * @param insProductBindingDto + * @return + */ + @Override + public boolean bindingProductTreeByProductId(InsProductBindingDto insProductBindingDto) { + if (insProductBindingDto.getInsProductId() == null) { + throw new ErrorException("缂哄皯妫�楠岄」缁戝畾id"); + } + + List<InsProduct> insProductBindingList = insProductBindingDto.getInsProductBindingList(); + // 鏌ヨ鍘熸湰妫�楠岄」 + InsProduct insProduct = insProductMapper.selectById(insProductBindingDto.getInsProductId()); + + for (InsProduct product : insProductBindingList) { + product.setBindingProductId(insProductBindingDto.getInsProductId()); + product.setAsk(null); + product.setTell(null); + product.setPrice(null); + product.setManHour(null); + product.setSection(null); + // 鍏宠仈鏍囪瘑 + product.setRawMaterialTag(insProduct.getRawMaterialTag()); + product.setRepetitionTag(insProduct.getRepetitionTag()); + product.setInsSampleId(insProduct.getInsSampleId()); + product.setIsBinding(1); + product.setState(1); + } + + // 鍒ゆ柇鏄惁鏄數缂嗘槸鐢电紗闇�瑕佹坊鍔犳墍鏈夌數缂嗗叧鑱斿叧绯� + if (StringUtils.isNotBlank(insProduct.getCableTag())) { + // 鏌ヨ鍏朵粬鐢电紗 + List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() + .eq(InsProduct::getInsSampleId, insProduct.getInsSampleId()) + .eq(InsProduct::getStructureItemParameterId, insProduct.getStructureItemParameterId()) + .isNotNull(InsProduct::getCableTag)); + for (InsProduct product : insProducts) { + for (InsProduct insProduct1 : insProductBindingList) { + insProduct1.setId(null); + insProduct1.setBindingProductId(product.getId()); + insProduct1.setCableTag(product.getCableTag()); + } + this.saveBatch(insProductBindingList); + } + } else { + this.saveBatch(insProductBindingList); + } + + return true; + } + + /** + * 鍒犻櫎鐗规畩妫�楠岄」缁戝畾淇℃伅 + * @param productId + * @return + */ + @Override + public boolean removeBindingProductTree(Integer productId) { + // 鏌ヨ妫�楠岄」 + InsProduct insProduct = insProductMapper.selectById(productId); + // 鍒ゆ柇鏄惁鏄數缂嗛厤缃�, 闇�瑕佸垹闄ゅ叧鑱旂殑鎵�鏈夌殑妫�楠岄」 + if (StringUtils.isNotBlank(insProduct.getCableTag())) { + insProductMapper.delete(Wrappers.<InsProduct>lambdaQuery() + .eq(InsProduct::getInsSampleId, insProduct.getInsSampleId()) + .eq(InsProduct::getIsBinding, 1) + .isNotNull(InsProduct::getBindingProductId) + .eq(InsProduct::getStructureItemParameterId, insProduct.getStructureItemParameterId()) + .isNotNull(InsProduct::getCableTag)); + } else { + insProductMapper.deleteById(productId); + } + return false; + } + + +} + + + + diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java index 45ef235..742af90 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java @@ -1,1163 +1,1155 @@ -//package com.ruoyi.inspect.service.impl; -// -//import cn.hutool.core.util.StrUtil; -//import cn.hutool.json.JSONUtil; -//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -//import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; -//import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -//import com.baomidou.mybatisplus.core.toolkit.StringUtils; -//import com.baomidou.mybatisplus.core.toolkit.Wrappers; -//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -//import com.deepoove.poi.XWPFTemplate; -//import com.deepoove.poi.data.Pictures; -//import com.ruoyi.common.properties.WechatProperty; -//import com.ruoyi.common.utils.QueryWrappers; -//import com.ruoyi.inspect.dto.ReportPageDto; -//import com.ruoyi.inspect.mapper.InsOrderStateMapper; -//import com.ruoyi.inspect.mapper.InsProductMapper; -//import com.ruoyi.inspect.mapper.InsReportMapper; -//import com.ruoyi.inspect.mapper.InsUnqualifiedRetestProductMapper; -//import com.ruoyi.inspect.pojo.InsReport; -//import com.ruoyi.inspect.service.InsOrderService; -//import com.ruoyi.inspect.service.InsReportService; -//import com.ruoyi.system.mapper.UserMapper; -//import org.apache.poi.xwpf.usermodel.*; -//import org.springframework.beans.factory.annotation.Value; -//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -//import org.springframework.stereotype.Service; -//import org.springframework.transaction.annotation.Transactional; -//import org.springframework.web.multipart.MultipartFile; -// -//import javax.annotation.Resource; -//import javax.imageio.ImageIO; -//import java.awt.image.BufferedImage; -//import java.io.*; -//import java.nio.file.Files; -//import java.nio.file.Path; -//import java.nio.file.Paths; -//import java.nio.file.StandardCopyOption; -//import java.time.LocalDateTime; -//import java.time.format.DateTimeFormatter; -//import java.util.*; -//import java.util.stream.Collectors; -//import java.util.zip.ZipEntry; -//import java.util.zip.ZipFile; -//import java.util.zip.ZipOutputStream; -// -///** -// * @author Administrator -// * @description 閽堝琛ㄣ�恑ns_report(妫�楠屾姤鍛�)銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇 -// * @createDate 2024-03-17 22:10:02 -// */ -//@Service -//public class InsReportServiceImpl extends ServiceImpl<InsReportMapper, InsReport> -// implements InsReportService { -// -// @Resource -// private GetLook getLook; -// @Resource -// private UserMapper userMapper; -// @Resource -// private InsReportMapper insReportMapper; -// @Resource -// private InsOrderStateMapper insOrderStateMapper; -// @Resource -// private InsProductMapper insProductMapper; -// @Resource -// private InformationNotificationService informationNotificationService; -// @Value("${wordUrl}") -// private String wordUrl; -// @Value("${file.path}") -// private String imgUrl; -// @Value("${file.licenseUrl}") -// private String licenseUrl; -// @Resource -// private InsOrderMapper insOrderMapper; -// @Resource -// private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; -// @Resource -// private InsUnqualifiedHandlerMapper insUnqualifiedHandlerMapper; -// @Resource -// private InsSampleMapper insSampleMapper; -// @Resource -// private ThreadPoolTaskExecutor threadPoolTaskExecutor; -// @Resource -// private InsOrderService insOrderService; -// @Resource -// private WechatProperty wechatProperty; -// @Resource -// private InsUnqualifiedRetestProductMapper insUnqualifiedRetestProductMapper; -// @Resource -// private IfsApiUtils ifsApiUtils; -// @Resource -// private InsSampleUserMapper insSampleUserMapper; -// -// -// @Override -// public Map<String, Object> pageInsReport(Page page, ReportPageDto reportPageDto) { -// Map<String, Object> map = new HashMap<>(); -// map.put("head", PrintChina.printChina(ReportPageDto.class)); -// Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("pageInsReport"); -// User user = userMapper.selectById(map1.get("userId"));//褰撳墠鐧诲綍鐨勪汉 -// //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id -// String departLimsId = user.getDepartLimsId(); -// String laboratory = null; -//// if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.equals("")) { -//// String[] split = departLimsId.split(","); -//// //鏌ヨ瀵瑰簲鏋舵瀯鍚嶇О(閫氫俊瀹為獙瀹�,鐢靛姏瀹為獙瀹�,妫�娴嬪姙) -//// String departLims = insOrderMapper.seldepLimsId(Integer.parseInt(split[split.length - 1])); -//// if (departLims.contains("瀹為獙瀹�")) { -//// laboratory = departLims; -//// } -//// } -// -// Integer createOrderUser = null; -// if (map1.get("look") == 1) { -// //涓汉 -// createOrderUser = map1.get("userId"); -// } -// String queryStatus = reportPageDto.getQueryStatus(); -// reportPageDto.setQueryStatus(null); -// -// map.put("body", insReportMapper.pageInsReport(page, -// QueryWrappers.queryWrappers(reportPageDto), -// laboratory, -// map1.get("userId"), -// queryStatus, -// createOrderUser)); -// return map; -// } -// -// @Override -// public int inReport(String url, Integer id) { -// InsReport insReport = new InsReport(); -// insReport.setId(id); -// insReport.setUrlS(url); -// // 杩樺師pdf -// String tempUrlPdf = wordToPdfTemp(insReport.getUrlS().replace("/word", wordUrl)); -// insReport.setTempUrlPdf("/word/" + tempUrlPdf); -// return insReportMapper.updateById(insReport); -// } -// -// @Override -// public int upReportUrl(Integer id) { -// InsReport report = insReportMapper.selectById(id); -// // 杩樺師pdf -// String tempUrlPdf = wordToPdfTemp(report.getUrl().replace("/word", wordUrl)); -// -// return insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() -// .eq(InsReport::getId, id) -// .set(InsReport::getUrlS, null) -// .set(InsReport::getTempUrlPdf, "/word/" + tempUrlPdf)); -// } -// -// //鎻愪氦 -// @Override -// @Transactional(rollbackFor = Exception.class) -// public int writeReport(Integer id, Integer userId, Integer submitUserId) { -// submitUserId = submitUserId == null ? getLook.selectPowerByMethodAndUserId(null).get("userId") : submitUserId; -// InsReport insReport = insReportMapper.selectById(id); -// insReport.setId(id); -// insReport.setState(1); -// insReport.setWriteUserId(submitUserId);//鎻愪氦浜� -// if (userId == null) { -// throw new ErrorException("缂哄皯瀹℃牳浜�"); -// } -// insReport.setExamineUserId(userId);//瀹℃牳浜� -// insReport.setWriteTime(LocalDateTime.now());//鎻愪氦鏃堕棿 -// //鑾峰彇鎻愪氦浜虹殑绛惧悕鍦板潃 -// String signatureUrl; -// try { -// signatureUrl = userMapper.selectById(insReport.getWriteUserId()).getSignatureUrl(); -// } catch (Exception e) { -// throw new ErrorException("鎵句笉鍒扮紪鍒朵汉鐨勭鍚�"); -// } -// if (ObjectUtils.isEmpty(signatureUrl) || signatureUrl.equals("")) { -// throw new ErrorException("鎵句笉鍒版楠屼汉鐨勭鍚�"); -// } -// -// Integer insOrderId = insReportMapper.selectById(id).getInsOrderId(); -// InsOrder order = insOrderMapper.selectById(insOrderId); -// boolean isRawMater = order.getTypeSource() != null && order.getTypeSource().equals(1); -// -// //鍙戦�佹秷鎭� -// InformationNotification info = new InformationNotification(); -// info.setCreateUser(insProductMapper.selectUserById(userId).get("name")); -// info.setMessageType("3"); -// info.setTheme("瀹℃牳閫氱煡"); -// info.setContent("鎮ㄦ湁涓�鏉℃姤鍛婄紪鍒跺緟瀹℃牳娑堟伅, 缂栧彿:" + insReport.getCode()); -// info.setSenderId(submitUserId); //鍙戦�佷汉 -// info.setConsigneeId(userId); //鏀朵欢浜� -// info.setViewStatus(false); -// info.setJumpPath("b1-report-preparation"); -// informationNotificationService.addInformationNotification(info); -// //绯荤粺鐢熸垚鎶ュ憡鍦板潃 -// String url = insReport.getUrl(); -// //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 -// String urlS = insReport.getUrlS(); -// -// // 鍒ゆ柇鏄惁鏄師鏉愭枡 闇�瑕佹浛鎹�****鎴愪緵搴斿晢 -// IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectOne(new LambdaQueryWrapper<IfsInventoryQuantity>() -// .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); -// if (one != null) { -// if (isRawMater && order.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)) { -// changeText(new HashMap<String, String>() {{ -// put("**********", one.getSupplierName()); -// }}, (StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); -// } -// } -// -// wordInsertUrl(new HashMap<String, Object>() {{ -// put("writeUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); -// put("writeDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(null)).create()); -// put("insUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); -// }}, (StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); -// -// // 淇敼涓存椂pdf -// String tempUrlPdf = wordToPdfTemp((StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); -// insReport.setTempUrlPdf("/word/" + tempUrlPdf); -// -// insReportMapper.updateById(insReport); -// -// // 娓呯┖瀹℃牳鏃堕棿, 瀹℃牳鐘舵�� -// insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() -// .eq(InsReport::getId, insReport.getId()) -// .set(InsReport::getRatifyTime, null) -// .set(InsReport::getIsRatify, null) -// .set(InsReport::getExamineTime, null) -// .set(InsReport::getIsExamine, null)); -// -// return 1; -// } -// -// //瀹℃牳 -// @Override -// @Transactional(rollbackFor = Exception.class) -// public int examineReport(Integer id, Integer isExamine, String examineTell, Integer userId) { -// InsReport insReport = insReportMapper.selectById(id); -// insReport.setIsExamine(isExamine); -// if (ObjectUtils.isNotEmpty(examineTell)) { -// insReport.setExamineTell(examineTell); -// } -// -// // 妫�楠屼汉 -// String userName = insProductMapper.selectUserById(insReport.getWriteUserId()).get("name"); -// String userAccount = insProductMapper.selectUserById(insReport.getWriteUserId()).get("account"); -// -// // 瀹℃牳浜� -// Integer checkUserId = getLook.selectPowerByMethodAndUserId(null).get("userId"); -// String checkUserName = insProductMapper.selectUserById(checkUserId).get("name"); -// -// insReport.setExamineTime(LocalDateTime.now());//瀹℃牳鏃堕棿 -// if (isExamine == 0) { -// // 鍙戦�佷紒涓氬井淇¢�氱煡(瀹℃牳閫�鍥�) -// threadPoolTaskExecutor.execute(() -> { -// // 鏌ヨ璁㈠崟 -// InsOrder order = insOrderMapper.selectById(insReport.getInsOrderId()); -// InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() -// .eq(InsSample::getInsOrderId, insReport.getInsOrderId()) -// .last("limit 1")); -// // 鏌ヨ鍘熸潗鏂� -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); -// -// String message = ""; -// message += "鎶ュ憡缂栧埗瀹℃牳閫�鍥為�氱煡"; -// message += "\n瀹℃牳浜�: " + checkUserName; -// message += "\n濮旀墭缂栧彿: " + order.getEntrustCode(); -// message += "\n鏍峰搧鍚嶇О: " + insSample.getModel(); -// message += "\n瑙勬牸鍨嬪彿: " + order.getPartDetail(); -// if (ifsInventoryQuantity != null) { -// message += "\n鎵规鍙�: " + ifsInventoryQuantity.getUpdateBatchNo(); -// } -// message += "\n閫�鍥炲師鍥�: " + examineTell; -// //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡 鎻愪氦澶嶆牳 -// try { -// WxCpUtils.inform(userAccount, message, null); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// }); -// -// //濡傛灉瀹℃牳涓嶉�氳繃 -// insReport.setState(0);//鎻愪氦鐘舵�佹敼涓哄緟鎻愪氦 -// return insReportMapper.updateById(insReport); -// } else { -// if (userId == null) { -// throw new ErrorException("缂哄皯鎵瑰噯浜�"); -// } -// } -// insReport.setRatifyUserId(userId);//鎵瑰噯浜� -// //鑾峰彇瀹℃牳浜虹殑绛惧悕鍦板潃 -// String signatureUrl; -// try { -// signatureUrl = userMapper.selectById(insReport.getExamineUserId()).getSignatureUrl(); -// } catch (Exception e) { -// throw new ErrorException("鎵句笉鍒板鏍镐汉鐨勭鍚�"); -// } -// if (StringUtils.isBlank(signatureUrl)) { -// throw new ErrorException("鎵句笉鍒板鏍镐汉鐨勭鍚�"); -// } -// -// // 鎵瑰噯浜� -// String sendUserAccount = insProductMapper.selectUserById(userId).get("account"); -// -// //鍙戦�佹秷鎭� -// //褰撳墠鐢ㄦ埛 -// Integer currentUser = getLook.selectPowerByMethodAndUserId(null).get("userId"); -// InformationNotification info = new InformationNotification(); -// info.setCreateUser(insProductMapper.selectUserById(userId).get("name")); -// info.setMessageType("3"); -// info.setTheme("鎵瑰噯閫氱煡"); -// info.setContent("鎮ㄦ湁涓�鏉℃姤鍛婄紪鍒跺緟鎵瑰噯娑堟伅, 缂栧彿:" + insReport.getCode()); -// info.setSenderId(currentUser); //鍙戦�佷汉 -// info.setConsigneeId(userId); //鏀朵欢浜� -// info.setViewStatus(false); -// info.setJumpPath("b1-report-preparation"); -// informationNotificationService.addInformationNotification(info); -// //绯荤粺鐢熸垚鎶ュ憡鍦板潃 -// String url = insReport.getUrl(); -// //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 -// String urlS = insReport.getUrlS(); -// wordInsertUrl(new HashMap<String, Object>() {{ -// put("examineUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); -// put("examineDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(null)).create()); -// }}, (StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); -// -// // 淇敼涓存椂pdf -// String tempUrlPdf = wordToPdfTemp((StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); -// insReport.setTempUrlPdf("/word/" + tempUrlPdf); -// -// // 鍙戦�佷紒涓氬井淇¢�氱煡(閫氱煡鎵瑰噯浜哄鎵�) -// threadPoolTaskExecutor.execute(() -> { -// // 鏌ヨ璁㈠崟 -// InsOrder order = insOrderMapper.selectById(insReport.getInsOrderId()); -// InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() -// .eq(InsSample::getInsOrderId, insReport.getInsOrderId()) -// .last("limit 1")); -// // 鏌ヨ鍘熸潗鏂� -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); -// -// String message = ""; -// message += "鎶ュ憡缂栧埗鎵瑰噯閫氱煡"; -// message += "\n妫�楠屼汉: " + userName; -// message += "\n澶嶆牳浜�: " + checkUserName; -// message += "\n濮旀墭缂栧彿: " + order.getEntrustCode(); -// message += "\n鏍峰搧鍚嶇О: " + insSample.getModel(); -// message += "\n瑙勬牸鍨嬪彿: " + order.getPartDetail(); -// if (ifsInventoryQuantity != null) { -// message += "\n鐢熶骇鍘傚: " + ifsInventoryQuantity.getSupplierName(); -// message += "\n鎵规鍙�: " + ifsInventoryQuantity.getUpdateBatchNo(); -// } -// //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡 鎻愪氦澶嶆牳 -// try { -// WxCpUtils.inform(sendUserAccount, message, null); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// }); -// insReportMapper.updateById(insReport); -// -// // 娓呯┖鎵瑰噯澶囨敞, 鎵瑰噯鏃堕棿, 鎵瑰噯鐘舵�� -// insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() -// .eq(InsReport::getId, insReport.getId()) -// .set(InsReport::getExamineTell, null) -// .set(InsReport::getRatifyTime, null) -// .set(InsReport::getIsRatify, null)); -// return 1; -// } -// -// //鎵瑰噯 -// @Override -// @Transactional(rollbackFor = Exception.class) -// public int ratifyReport(Integer id, Integer isRatify, String ratifyTell) { -// InsReport insReport = insReportMapper.selectById(id); -// insReport.setIsRatify(isRatify); -// if (ObjectUtils.isNotEmpty(ratifyTell)) { -// insReport.setRatifyTell(ratifyTell); -// } -// insReport.setRatifyTime(LocalDateTime.now());//鎵瑰噯鏃堕棿 -// if (isRatify == 0) { -// -// // 鎵瑰噯浜� -// Integer ratifyUserId = getLook.selectPowerByMethodAndUserId(null).get("userId"); -// String ratifyUserName = insProductMapper.selectUserById(ratifyUserId).get("name"); -// -// // 鍙戦�佷汉(瀹℃牳浜�)(妫�楠屼汉) -// // 妫�楠屼汉 -// String userAccount = insProductMapper.selectUserById(insReport.getWriteUserId()).get("account"); -// // 瀹℃牳浜� -// String checkUserAccount = insProductMapper.selectUserById(insReport.getExamineUserId()).get("account"); -// -// -// // 鍙戦�佷紒涓氬井淇¢�氱煡(鎵瑰噯閫�鍥�) -// threadPoolTaskExecutor.execute(() -> { -// // 鏌ヨ璁㈠崟 -// InsOrder order = insOrderMapper.selectById(insReport.getInsOrderId()); -// InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() -// .eq(InsSample::getInsOrderId, insReport.getInsOrderId()) -// .last("limit 1")); -// // 鏌ヨ鍘熸潗鏂� -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); -// -// String message = ""; -// message += "鎶ュ憡缂栧埗鎵瑰噯閫�鍥為�氱煡"; -// message += "\n鎵瑰噯浜�: " + ratifyUserName; -// message += "\n濮旀墭缂栧彿: " + order.getEntrustCode(); -// message += "\n鏍峰搧鍚嶇О: " + insSample.getModel(); -// message += "\n瑙勬牸鍨嬪彿: " + order.getPartDetail(); -// if (ifsInventoryQuantity != null) { -// message += "\n鎵规鍙�: " + ifsInventoryQuantity.getUpdateBatchNo(); -// } -// message += "\n閫�鍥炲師鍥�: " + ratifyTell; -// //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡 鎻愪氦澶嶆牳 -// try { -// // 瀹℃壒浜� -// WxCpUtils.inform(checkUserAccount, message, null); -// -// // 妫�楠屼汉 -// WxCpUtils.inform(userAccount, message, null); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// }); -// -// //濡傛灉鎵瑰噯涓嶉�氳繃 鐩存帴閫�鍥炲埌鎻愪氦浜洪偅杈瑰幓 -// insReport.setState(0); -// insReport.setIsExamine(0); -// return insReportMapper.updateById(insReport); -// } -// //鑾峰彇鎵瑰噯浜虹殑绛惧悕鍦板潃 -// String signatureUrl; -// try { -// signatureUrl = userMapper.selectById(insReport.getRatifyUserId()).getSignatureUrl(); -// } catch (Exception e) { -// throw new ErrorException("鎵句笉鍒版壒鍑嗕汉鐨勭鍚�"); -// } -// if (StringUtils.isBlank(signatureUrl)) { -// throw new ErrorException("鎵句笉鍒版壒鍑嗕汉鐨勭鍚�"); -// } -// Integer insOrderId = insReportMapper.selectById(id).getInsOrderId(); -// InsOrder order = insOrderMapper.selectById(insOrderId); -// boolean isRawMater = order.getTypeSource() != null && order.getTypeSource().equals(1); -// -// //鑾峰彇鍦烘墍鐨勬姤鍛婁笓鐢ㄧ珷 -// String sealUrl; -// String laboratory = insOrderMapper.selectById(insReport.getInsOrderId()).getLaboratory(); -// try { -// String type = ""; -// if (isRawMater && order.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)) { -// type = "杩涘巶鎶ュ憡"; -// } else { -// type = "濮旀墭鎶ュ憡"; -// } -// sealUrl = insReportMapper.getLaboratoryByName(laboratory, type); -// } catch (Exception e) { -// throw new ErrorException(laboratory + "鎵句笉鍒版姤鍛婁笓鐢ㄧ珷"); -// } -// if (StringUtils.isBlank(sealUrl)) { -// throw new ErrorException(laboratory + "鎵句笉鍒版姤鍛婁笓鐢ㄧ珷"); -// } -// //绯荤粺鐢熸垚鎶ュ憡鍦板潃 -// String url = insReport.getUrl(); -// //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 -// String urlS = insReport.getUrlS(); -// String finalUrl = (StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl); -// -// wordInsertUrl(new HashMap<String, Object>() {{ -// put("ratifyUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); -// put("ratifyDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(null)).create()); -// put("seal1", Pictures.ofLocal(imgUrl + "/" + sealUrl).create()); -// put("seal2", Pictures.ofLocal(imgUrl + "/" + sealUrl).create()); -// }}, finalUrl); -// -// // 淇敼涓存椂pdf -// insReport.setTempUrlPdf((StrUtil.isBlank(urlS) ? url : urlS).replace(".docx", ".pdf")); -// -// InsOrder insOrder = new InsOrder(); -// insOrder.setId(insOrderId); -// insOrder.setState(4); -// insOrderMapper.updateById(insOrder); -// -// wordToPdf(finalUrl, sealUrl, isRawMater && order.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)); -// -// // 鍒ゆ柇鏄惁涓哄師鏉愭枡 -// if (isRawMater) { -// // 淇敼ifs搴撳瓨鐘舵�� -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getState, 2) -// .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); -// } -// insReport.setRatifyTell(""); -// -// // 鍙戦�佹枃浠跺埌濮旀墭浜� -// if (StringUtils.isNotBlank(order.getPrepareCode())) { -// threadPoolTaskExecutor.execute(() -> { -// String message = ""; -// message += "濮旀墭缂栧彿: " + order.getEntrustCode(); -// message += "濮旀墭鏍峰搧: " + order.getSampleView(); -// message += "宸叉娴嬬粨鏉�, 璇锋帴鏀�"; -// try { -// WxCpUtils.inform(order.getPrepareCode(), message, new File(finalUrl.replace(".docx", ".pdf"))); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// }); -// } -// -// return insReportMapper.updateById(insReport); -// } -// -// @Override -// public int wordInsertUrl(Map<String, Object> map, String url) { -// XWPFTemplate template = XWPFTemplate.compile(url).render(map); -// try { -// template.writeAndClose(Files.newOutputStream(Paths.get(url))); -// } catch (IOException e) { -// throw new RuntimeException(e); -// } -// return 1; -// } -// -// -// //鎶ュ憡鎵归噺涓嬭浇 -// @Override -// @Transactional(rollbackFor = Exception.class) -// public String downAll(String ids) { -// List<Long> list = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList()); -// List<InsReport> insReports = insReportMapper.selectBatchIds(list); -// String zipFilePath = null; -// // 涓存椂鏂囦欢澶硅矾寰� -// try { -// String tempFolderPath = wordUrl + "/tempFolder"; -// File tempFolder = new File(tempFolderPath); -// if (tempFolder.exists()) { -// deleteDirectory(tempFolder); // 鍒犻櫎鏃х殑涓存椂鏂囦欢澶� -// } -// tempFolder.mkdirs(); // 鍒涘缓鏂扮殑涓存椂鏂囦欢澶� -// for (InsReport insReport : insReports) { -// File sourceFile = new File((ObjectUtils.isNotEmpty(insReport.getUrlS()) ? insReport.getUrlS() : insReport.getUrl()).replace("/word", wordUrl)); -// File destinationFile = new File(tempFolder, sourceFile.getName()); -// Files.copy(sourceFile.toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING); -// } -// // 鍘嬬缉涓存椂鏂囦欢澶� -// zipFilePath = wordUrl + "/zip/output.zip"; -// zipDirectory(tempFolderPath, zipFilePath); -// -// // 娓呯悊涓存椂鏂囦欢澶� -// deleteDirectory(tempFolder); -// -// System.out.println("ZIP鏂囦欢鍒涘缓瀹屾垚锛�"); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// return "/word/zip/output.zip"; -// } -// -// //鎵归噺涓婁紶 -// @Override -// @Transactional(rollbackFor = Exception.class) -// public int upAll(MultipartFile file) throws IOException { -// File tempFile = null; -// File unzipDir = null; -// try { -// tempFile = File.createTempFile(wordUrl, ".zip"); -// file.transferTo(tempFile); -// -// unzipDir = new File("uploaded_files"); -// if (!unzipDir.exists()) { -// unzipDir.mkdir(); -// } -// unzip(tempFile, unzipDir); -// // 澶勭悊瑙e帇鍚庣殑鏂囦欢 -// File[] files = unzipDir.listFiles(); -// if (files != null) { -// for (File f : files) { -// // 鏍规嵁鏂囦欢鍚嶆煡璇d -// String name = f.getName(); -// InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery().like(InsReport::getCode, f.getName().replace(".docx", "").replace("JCZX", "JCZX/"))); -// if (ObjectUtils.isEmpty(insReport)) { -// throw new ErrorException("娌℃湁鎵惧埌 " + f.getName() + " 杩欎釜鏂囦欢瀵瑰簲鐨勬姤鍛婃暟鎹�"); -// } -// String urlString; -// String pathName; -// try { -// String path = wordUrl; -// File realpath = new File(path); -// if (!realpath.exists()) { -// realpath.mkdirs(); -// } -// pathName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + f.getName(); -// urlString = realpath + "/" + pathName; -// // 澶嶅埗鏂囦欢鍒版寚瀹氳矾寰� -// Files.copy(f.toPath(), new File(urlString).toPath(), StandardCopyOption.REPLACE_EXISTING); -// inReport("/word/" + pathName, insReport.getId()); -// } catch (IOException e) { -// throw new ErrorException("鏂囦欢涓婁紶澶辫触"); -// } -// } -// } -// } catch (IOException e) { -// throw new ErrorException("鏂囦欢澶勭悊澶辫触"); -// } finally { -// if (tempFile != null && tempFile.exists()) { -// tempFile.delete(); -// } -// // 閫掑綊鍒犻櫎瑙e帇鐩綍鍙婂叾涓殑鏂囦欢 -// if (unzipDir.exists()) { -// deleteDirectory(unzipDir); // 鍒犻櫎鏃х殑涓存椂鏂囦欢澶� -// } -// } -// return 0; -// } -// -// -// //瑙e帇鏂囦欢澶� -// private void unzip(File zipFile, File destDir) throws IOException { -// try (ZipFile zip = new ZipFile(zipFile)) { -// Enumeration<? extends ZipEntry> entries = zip.entries(); -// while (entries.hasMoreElements()) { -// ZipEntry entry = entries.nextElement(); -// File file = new File(destDir, entry.getName()); -// if (entry.isDirectory()) { -// file.mkdirs(); -// } else { -// file.getParentFile().mkdirs(); -// try (InputStream in = zip.getInputStream(entry); -// OutputStream out = new FileOutputStream(file)) { -// byte[] buffer = new byte[1024]; -// int len; -// while ((len = in.read(buffer)) > 0) { -// out.write(buffer, 0, len); -// } -// } -// } -// } -// } -// } -// -// // 鍘嬬缉鏂囦欢澶� -// public static void zipDirectory(String sourceDirPath, String zipFilePath) throws IOException { -// try (ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFilePath))) { -// Path sourceDir = Paths.get(sourceDirPath); -// Files.walk(sourceDir) -// .filter(path -> !Files.isDirectory(path)) -// .forEach(path -> { -// ZipEntry zipEntry = new ZipEntry(sourceDir.relativize(path).toString()); -// try { -// zipOut.putNextEntry(zipEntry); -// Files.copy(path, zipOut); -// zipOut.closeEntry(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// }); -// } -// } -// -// // 鍒犻櫎鏂囦欢澶瑰強鍏跺唴瀹� -// public static void deleteDirectory(File directory) throws IOException { -// if (directory.isDirectory()) { -// File[] files = directory.listFiles(); -// if (files != null) { -// for (File file : files) { -// deleteDirectory(file); -// } -// } -// } -// Files.delete(directory.toPath()); -// } -// -// @Override -// public void wordToPdf(String path, String sealUrl, boolean isRawMater) { -// try { -// wordToPdf(path, path.replace(".docx", ".pdf"), sealUrl, isRawMater); -// } catch (Exception e) { -// throw new ErrorException("杞崲澶辫触"); -// } -// } -// -// -// public String wordToPdf(String wordPath, String pdfPath, String sealUrl, boolean isRawMater) { -// FileOutputStream os = null; -// try { -// //鍑瘉 涓嶇劧鍒囨崲鍚庢湁姘村嵃 -//// InputStream is = this.getClass().getResourceAsStream("/lib/license.xml"); -//// InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("license.xml"); -// InputStream is = Files.newInputStream(new File(licenseUrl).toPath()); -// License license = new License(); -// license.setLicense(is); -// if (!license.getIsLicensed()) { -// System.out.println("License楠岃瘉涓嶉�氳繃..."); -// return null; -// } -// //鐢熸垚涓�涓┖鐨凱DF鏂囦欢 -// File file; -// //鍒ゆ柇鏄惁鏄繘鍘傛姤鍛� -// if (!isRawMater) { -// file = new File(pdfPath.replace(".pdf", "-1.pdf")); -// } else { -// file = new File(pdfPath.replace(".pdf", ".pdf")); -// } -// os = new FileOutputStream(file); -// //瑕佽浆鎹㈢殑word鏂囦欢 -// com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); -// doc.save(os, SaveFormat.PDF); -// -// //娣诲姞楠戠紳绔� -// if (!isRawMater) { -// stamperCheckMarkPDF(pdfPath.replace(".pdf", "-1.pdf"), pdfPath, imgUrl + "/" + sealUrl); -// } -// -// -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// if (os != null) { -// try { -// os.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// } -// return null; -// } -// -// /** -// * 鍒囧壊鍥剧墖 -// * -// * @param Path 鍥剧墖璺緞 -// * @param n 鍒囧壊浠芥暟 -// */ -// public static com.itextpdf.text.Image[] slicingImages(String Path, int n) throws IOException, BadElementException { -// com.itextpdf.text.Image[] nImage = new com.itextpdf.text.Image[n]; -// BufferedImage img = ImageIO.read(new File(Path)); -// -// int h = img.getHeight(); -// int w = img.getWidth(); -// -// int sw = w / n; -// for (int i = 0; i < n; i++) { -// BufferedImage subImg; -// if (i == n - 1) {//鏈�鍚庡墿浣欓儴鍒� -// subImg = img.getSubimage(i * sw, 0, w - i * sw, h); -// } else {//鍓峮-1鍧楀潎鍖�鍒� -// subImg = img.getSubimage(i * sw, 0, sw, h); -// } -// ByteArrayOutputStream out = new ByteArrayOutputStream(); -// ImageIO.write(subImg, Path.substring(Path.lastIndexOf('.') + 1), out); -// nImage[i] = com.itextpdf.text.Image.getInstance(out.toByteArray()); -// -// } -// return nImage; -// } -// -// /** -// * 鐩栭獞缂濈珷 -// * -// * @param infilePath 鍘烶DF璺緞 -// * @param outFilePath 杈撳嚭PDF璺緞 -// */ -// public static void stamperCheckMarkPDF(String infilePath, String outFilePath, String picPath) throws IOException, DocumentException { -// PdfReader reader = new PdfReader(infilePath);//閫夋嫨闇�瑕佸嵃绔犵殑pdf -// PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(outFilePath));//鍔犲畬鍗扮珷鍚庣殑pdf -// -// -// com.itextpdf.text.Rectangle pageSize = reader.getPageSize(1);//鑾峰緱绗竴椤� -// float height = pageSize.getHeight(); -// float width = pageSize.getWidth(); -// -// int nums = reader.getNumberOfPages(); -// com.itextpdf.text.Image[] nImage = slicingImages(picPath, nums);//鐢熸垚楠戠紳绔犲垏鍓插浘鐗� -// -// for (int n = 1; n <= nums; n++) { -// PdfContentByte over = stamp.getOverContent(n);//璁剧疆鍦ㄧ鍑犻〉鎵撳嵃鍗扮珷 -// com.itextpdf.text.Image img = nImage[n - 1];//閫夋嫨鍥剧墖 -// float newHeight = 100f; -// float newWidth = img.getWidth() / (img.getHeight() / 100); -// img.scaleAbsolute(newWidth, newHeight);//鎺у埗鍥剧墖澶у皬 -// img.setAbsolutePosition(width - newWidth, height / 2 - newHeight / 2);//鎺у埗鍥剧墖浣嶇疆 -// over.addImage(img); -// } -// stamp.close(); -// } -// -// @Transactional(rollbackFor = Exception.class) -// public void isRawMaterial(InsOrder insOrder) { -// IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectOne(new LambdaQueryWrapper<IfsInventoryQuantity>() -// .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); -// if (Objects.isNull(one)) { -// throw new ErrorException("鎵句笉鍒板師鏉愭枡淇℃伅"); -// } -// // 鍒ゆ柇鏄惁鏈変笉鍚堟牸淇℃伅 -// Long count = insUnqualifiedHandlerMapper.selectCount(Wrappers.<InsUnqualifiedHandler>lambdaQuery() -// .eq(InsUnqualifiedHandler::getInventoryQuantityId, one.getId())); -// String toLocation = null; -// -// // 鍒ゆ柇鏄惁鏈変笉鍚堟牸 -// Long unqualifiedCount = getUnqualifiedCount(insOrder); -// -// if (count.equals(0L) && unqualifiedCount.equals(0L) && one.getIsFinish().equals(0) && one.getIsSource().equals(1)) { -// // 鍘熸潗鏂欑Щ搴� -// toLocation = this.moveRawMaterial(one); -// } -// -// // 鍒ゆ柇缁撴潫鐘舵�佷慨鏀瑰悎鏍肩姸鎬� -// int inspectStatus = (count == 0 && unqualifiedCount == 0) ? 1 : 2; -// insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() -// .eq(InsOrder::getId, insOrder.getId()) -// .set(InsOrder::getInsResult, inspectStatus)); -// -// if (one.getIsFinish().equals(0)) { -// ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() -// .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId()) -// .set(IfsInventoryQuantity::getInspectStatus, inspectStatus)); -// -// // 淇敼ifs搴撳瓨鐘舵�� -// if (StringUtils.isBlank(toLocation)) { -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getIsFinish, 1) -// .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); -// } else { -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getIsFinish, 1) -// .set(IfsInventoryQuantity::getToLocation, toLocation) -// .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); -// } -// -// threadPoolTaskExecutor.execute(() -> { -// // 浼佷笟寰俊閫氱煡 -// String message = ""; -// message += "妫�娴嬬粨鏋滄彁浜ら�氱煡"; -// message += "\n鎵规鍙�: " + one.getUpdateBatchNo(); -// message += "\n闆朵欢鍙�: " + one.getPartNo(); -// message += "\n闆朵欢鎻忚堪: " + one.getPartDesc(); -// message += "\n渚涘簲鍟嗗悕绉�: " + one.getSupplierName(); -// message += "\n鎶佃揪鏁伴噺: " + one.getQtyArrived().stripTrailingZeros().toPlainString() + one.getBuyUnitMeas(); -// // 鍙戦�佷紒涓歩nspectStatus淇¢�氱煡 -// if (inspectStatus == 1) { -// message += "\n妫�娴嬬粨鏋�: 鍚堟牸"; -// } else { -// message += "\n妫�娴嬬粨鏋�: 涓嶅悎鏍�"; -// } -// WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message); -// }); -// -// } -// -// -// } -// -// /** -// * 鍒ゆ柇鏄惁鏈変笉鍚堟牸 -// * @param insOrder -// * @return -// */ -// @Override -// public Long getUnqualifiedCount(InsOrder insOrder) { -// Long unqualifiedCount = 0L; -// List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() -// .eq(InsSample::getInsOrderId, insOrder.getId())); -// if (CollectionUtils.isNotEmpty(insSamples)) { -// unqualifiedCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() -// .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).collect(Collectors.toList())) -// .eq(InsProduct::getInsResult, 0)); -// -// // 鍒ゆ柇濡傛灉鏈変笉鍚堟牸鐨勬楠岄」, 鍒ゆ柇鏈夋病鏈夋楠岄」澶嶆祴, 澶嶆牳鍚堟牸涔熺畻鍚堟牸閫氳繃 -// if (!unqualifiedCount.equals(0L)) { -// List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() -// .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).collect(Collectors.toList())) -// .eq(InsProduct::getInsResult, 0)); -// -// boolean flag = true; -// for (InsProduct insProduct : insProducts) { -// Long unqualifiedProductCount = insUnqualifiedRetestProductMapper.selectCount(Wrappers.<InsUnqualifiedRetestProduct>lambdaQuery() -// .eq(InsUnqualifiedRetestProduct::getInsProductId, insProduct.getId()) -// .ne(InsUnqualifiedRetestProduct::getInsResult, 0)); -// if (unqualifiedProductCount != 2) { -// flag = false; -// } -// } -// if (flag) { -// unqualifiedCount = 0L; -// } -// } -// } -// return unqualifiedCount; -// } -// -// /** -// * ifs绉诲簱鎿嶄綔 -// * @param one -// * @return -// */ -// @Override -// public String moveRawMaterial(IfsInventoryQuantity one) { -// String toLocation; -// // 鐧昏閲囪喘妫�楠岀粨鏋淪TD -// if (one.getIsRegister().equals(0)) { -// Map<String, Object> resultMap = new HashMap<>(); -// List<Map<String, Object>> resultList = new ArrayList<>(); -// Map<String, Object> map = new HashMap<>(); -// map.put("ORDER_NO", one.getOrderNo()); // 閲囪喘璁㈠崟鍙� -// map.put("LINE_NO", one.getLineNo()); // 琛屽彿 -// map.put("RELEASE_NO", one.getReleaseNo()); // 涓嬭揪鍙� -// map.put("RECEIPT_NO", one.getReceiptNo()); // 鎺ユ敹鍙� -// map.put("PURCH_QTY", one.getQtyToInspect()); // 瑕佹楠岀殑閲囪喘鏁伴噺 -// resultList.add(map); -// resultMap.put("RECORD_ID", UUID.randomUUID().toString()); -// resultMap.put("SYSCODE", "LIMS"); -// resultMap.put("SYSMODEL", "鐧昏閲囪喘妫�楠岀粨鏋�"); -// resultMap.put("BATCH_INFO", resultList); -// Result result = ifsApiUtils.getProcurementResults(JSONUtil.toJsonStr(resultMap)); -// if (result.getCode() != 200) { -// throw new ErrorException("IFS鐧昏閲囪喘妫�楠岀粨鏋滃け璐�: " + result.getMessage()); -// } -// } -// insOrderService.updateIfsInventoryQuantity(one.getId()); -// /** -// * TODO 鍚庣画闇�瑕佽皟鐢↖FS鐨勬帴鍙� 绉诲叆鐨勫簱浣嶅彿 toLocation -// */ -// // 妫�楠屽悗绉诲簱 -// toLocation = "1301"; -// Map<String, Object> moveResultMap = new HashMap<>(); -// List<Map<String, Object>> moveResultList = new ArrayList<>(); -// Map<String, Object> moveMap = new HashMap<>(); -// moveMap.put("ORDER_NO", one.getOrderNo()); // 閲囪喘璁㈠崟鍙� -// moveMap.put("LINE_NO", one.getLineNo()); -// moveMap.put("RELEASE_NO", one.getReleaseNo()); -// moveMap.put("RECEIPT_NO", one.getReceiptNo()); -// moveMap.put("PART_NO", one.getPartNo()); -// moveMap.put("QTY", one.getQtyArrived()); -// moveMap.put("LOCATION_NO", one.getLocationNo()); -// moveMap.put("TO_LOCATION_NO", toLocation); -// moveMap.put("LOT_BATCH_NO", one.getLotBatchNo()); -// moveMap.put("SERIAL_NO", one.getSerialNo()); -// moveMap.put("WAIV_DEV_REJ_NO", one.getWaivDevRejNo()); -// moveMap.put("ENG_CHG_LEVEL", one.getEngChgLevel()); -// moveMap.put("ACTIVITY_SEQ", one.getActivitySeq()); -// moveResultList.add(moveMap); -// moveResultMap.put("RECORD_ID", UUID.randomUUID().toString()); -// moveResultMap.put("SYSCODE", "LIMS"); -// moveResultMap.put("SYSMODEL", "妫�楠屽悗绉诲簱"); -// moveResultMap.put("BATCH_INFO", moveResultList); -// -// Result result1 = ifsApiUtils.moveReceipt(JSONUtil.toJsonStr(moveResultMap)); -// // 濡傛灉鏈夊繀椤讳负闆朵欢鎸囧畾鎵瑰彿鎶ラ敊闇�瑕侀噸鏂版彁浜ょЩ搴撲俊鎭幓鎸囧畾鎵瑰彿 -// if (result1.getCode() != 200) { -// String message = result1.getMessage(); -// if (message.contains("蹇呴』涓洪浂浠�") && message.contains("鎸囧畾鎵瑰彿")) { -// updaeBatch(one, toLocation); -// } else { -// throw new ErrorException("IFS妫�楠屽悗绉诲簱澶辫触: " + result1.getMessage()); -// } -// } -// return toLocation; -// } -// -// /** -// * 閫�鍥炲埌妫�楠屼换鍔� -// * @param id -// * @return -// */ -// @Override -// @Transactional(rollbackFor = Exception.class) -// public boolean sendBackTask(Integer id) { -// InsReport report = insReportMapper.selectById(id); -// // 鏍规嵁璁㈠崟鏌ヨ璇曢獙瀹� -// String laboratory = insOrderMapper.selectLaboratoryByOrderId(report.getInsOrderId()); -// -// // 淇敼璁㈠崟鐘舵�� -// insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate() -// .eq(InsOrderState::getInsOrderId, report.getInsOrderId()) -// .eq(InsOrderState::getLaboratory, laboratory) -// .set(InsOrderState::getInsState, 4)); -// -// Integer insSampleId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery() -// .eq(InsSampleUser::getInsSampleId, report.getInsOrderId()) -// .orderByDesc(InsSampleUser::getId) -// .last("limit 1")).getId(); -// insSampleUserMapper.deleteById(insSampleId); -// -// // 淇敼鎶ュ憡琛屼负鏈樉绀� -// insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() -// .eq(InsReport::getId, id) -// .set(InsReport::getIsPass, 0)); -// -// return false; -// } -// -// -// /** -// * 鍏堜慨鏀归噰璐鍗曟壒娆″彿, 鍚庤繘琛岀Щ搴撴搷浣� -// * @param one -// * @param toLocation -// */ -// private void updaeBatch(IfsInventoryQuantity one, String toLocation) { -// if (one.getIsUpdateBatch().equals(0)) { -// // 鍏堜慨鏀规壒娆″彿鍚庤繘琛岀Щ搴� -// Map<String, Object> resultMap = new HashMap<>(); -// List<Map<String, Object>> resultList = new ArrayList<>(); -// Map<String, Object> map = new HashMap<>(); -// map.put("ORDER_NO", one.getOrderNo()); // 閲囪喘璁㈠崟鍙� -// map.put("LINE_NO", one.getLineNo()); // 琛屽彿 -// map.put("RELEASE_NO", one.getReleaseNo()); // 涓嬭揪鍙� -// map.put("RECEIPT_NO", one.getReceiptNo()); // 鎺ユ敹鍙� -// map.put("PART_NO", one.getPartNo()); //闆朵欢鍙� -// map.put("CONFIGURATION_ID", one.getConfigurationId()); // 閰嶇疆鏍囪瘑 -// map.put("LOCATION_NO", one.getLocationNo()); // 搴撲綅鍙� -// map.put("LOT_BATCH_NO", one.getLotBatchNo());// 鎵规鍙� -// map.put("NEW_LOT_BATCH_NO", one.getUpdateBatchNo()); // 鐩爣鎵规鍙� -// map.put("SERIAL_NO", one.getSerialNo()); // 搴忓垪鍙� -// map.put("ENG_CHG_LEVEL", one.getEngChgLevel()); // 鐗堟湰鍙� -// map.put("WAIV_DEV_REJ_NO", one.getWaivDevRejNo()); // wdr鍙� -// map.put("ACTIVITY_SEQ", one.getActivitySeq()); // 娲诲姩搴忓彿 -// map.put("QTY_TO_CHANGE", one.getQtyArrived()); // 鍙樻洿鏁伴噺 -// resultList.add(map); -// resultMap.put("RECORD_ID", UUID.randomUUID().toString()); -// resultMap.put("SYSCODE", "LIMS"); -// resultMap.put("SYSMODEL", "淇敼閲囪喘璁㈠崟鎵规鍙�"); -// resultMap.put("BATCH_INFO", resultList); -// -// Result result = ifsApiUtils.updateMoveReceiptLot(JSONUtil.toJsonStr(resultMap)); -// -// if (result.getCode() != 200) { -// throw new ErrorException("IFS淇敼鎵规鍙峰け璐�: " + result.getMessage()); -// } -// ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() -// .set(IfsInventoryQuantity::getIsUpdateBatch, 1) -// .eq(IfsInventoryQuantity::getId, one.getId())); -// } -// -// Map<String, Object> moveResultMap = new HashMap<>(); -// List<Map<String, Object>> moveResultList = new ArrayList<>(); -// Map<String, Object> moveMap = new HashMap<>(); -// moveMap.put("ORDER_NO", one.getOrderNo()); // 閲囪喘璁㈠崟鍙� -// moveMap.put("LINE_NO", one.getLineNo()); -// moveMap.put("RELEASE_NO", one.getReleaseNo()); -// moveMap.put("RECEIPT_NO", one.getReceiptNo()); -// moveMap.put("PART_NO", one.getPartNo()); -// moveMap.put("QTY", one.getQtyArrived()); -// moveMap.put("LOCATION_NO", one.getLocationNo()); -// moveMap.put("TO_LOCATION_NO", toLocation); -// moveMap.put("LOT_BATCH_NO", one.getUpdateBatchNo()); -// moveMap.put("SERIAL_NO", one.getSerialNo()); -// moveMap.put("WAIV_DEV_REJ_NO", one.getWaivDevRejNo()); -// moveMap.put("ENG_CHG_LEVEL", one.getEngChgLevel()); -// moveMap.put("ACTIVITY_SEQ", one.getActivitySeq()); -// moveResultList.add(moveMap); -// moveResultMap.put("RECORD_ID", UUID.randomUUID().toString()); -// moveResultMap.put("SYSCODE", "LIMS"); -// moveResultMap.put("SYSMODEL", "妫�楠屽悗绉诲簱"); -// moveResultMap.put("BATCH_INFO", moveResultList); -// -// Result result1 = ifsApiUtils.moveReceipt(JSONUtil.toJsonStr(moveResultMap)); -// if (result1.getCode() != 200) { -// throw new ErrorException("IFS妫�楠屽悗绉诲簱澶辫触: " + result1.getMessage()); -// } -// -// } -// -// /** -// * 鏇挎崲娈佃惤鏂囨湰 -// * @param filePath docx瑙f瀽瀵硅薄 -// * @param textMap 闇�瑕佹浛鎹㈢殑淇℃伅闆嗗悎 -// */ -// public static void changeText(Map<String, String> textMap, String filePath) { -// try { -// FileInputStream stream = new FileInputStream(filePath); -// XWPFDocument document = new XWPFDocument(stream); -// List<XWPFTable> tables = document.getTables(); -// for (XWPFTable table : tables) { -// for (XWPFTableRow row : table.getRows()) { -// for (XWPFTableCell cell : row.getTableCells()) { -// -// textMap.forEach((s, s2) -> { -// if (cell.getText().equals(s)) { -// XWPFParagraph paragraph = cell.getParagraphs().get(0); -// XWPFRun oldRun = paragraph.getRuns().get(0); -// // 淇濆瓨鍘熸牱寮� -// String fontFamily = oldRun.getFontFamily(); -// int fontSize = oldRun.getFontSize(); -// String color = oldRun.getColor(); -// ParagraphAlignment alignment = paragraph.getAlignment(); -// // 鏇挎崲鍐呭 -// paragraph.removeRun(0); // 绉婚櫎鍘熸湁鐨� run -// XWPFRun newRun = paragraph.createRun(); -// newRun.setText(s2); -// // 搴旂敤鍘熸牱寮� -// newRun.setFontFamily(fontFamily); -// newRun.setFontSize(fontSize); -// newRun.setColor(color); -// paragraph.setAlignment(alignment); -// } -// }); -// } -// } -// } -// FileOutputStream fileOutputStream = new FileOutputStream(filePath); -// document.write(fileOutputStream); -// fileOutputStream.close(); -// -// } catch (Exception e) { -// e.printStackTrace(); -// throw new ErrorException(e.getMessage()); -// } -// } -// -// /** -// * word杞崲pdf -// * @param path -// * @return -// */ -// private String wordToPdfTemp(String path) { -// try { -// return wordToPdf(path, path.replace(".docx", "-涓存椂.pdf")); -// } catch (Exception e) { -// throw new ErrorException("杞崲澶辫触"); -// } -// } -// -// private String wordToPdf(String wordPath, String pdfPath) { -// FileOutputStream os = null; -// try { -// //鍑瘉 涓嶇劧鍒囨崲鍚庢湁姘村嵃 -// InputStream is = Files.newInputStream(new File(licenseUrl).toPath()); -// License license = new License(); -// license.setLicense(is); -// if (!license.getIsLicensed()) { -// System.out.println("License楠岃瘉涓嶉�氳繃..."); -// return null; -// } -// //鐢熸垚涓�涓┖鐨凱DF鏂囦欢 -// File file; -// //鍒ゆ柇鏄惁鏄繘鍘傛姤鍛� -// file = new File(pdfPath); -// os = new FileOutputStream(file); -// //瑕佽浆鎹㈢殑word鏂囦欢 -// com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); -// doc.save(os, SaveFormat.PDF); -// String name = file.getName(); -// return file.getName(); -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// if (os != null) { -// try { -// os.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// } -// return null; -// } -//} -// -// -// -// -// -// +package com.ruoyi.inspect.service.impl; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.aspose.words.License; +import com.aspose.words.SaveFormat; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.deepoove.poi.XWPFTemplate; +import com.deepoove.poi.data.Pictures; +import com.itextpdf.text.BadElementException; +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.pdf.PdfContentByte; +import com.itextpdf.text.pdf.PdfReader; +import com.itextpdf.text.pdf.PdfStamper; +import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; +import com.ruoyi.basic.pojo.IfsInventoryQuantity; +import com.ruoyi.common.constant.InsOrderTypeConstants; +import com.ruoyi.common.core.domain.Result; +import com.ruoyi.common.core.domain.entity.InformationNotification; +import com.ruoyi.common.core.domain.entity.User; +import com.ruoyi.common.properties.WechatProperty; +import com.ruoyi.common.utils.*; +import com.ruoyi.framework.exception.ErrorException; +import com.ruoyi.inspect.dto.ReportPageDto; +import com.ruoyi.inspect.mapper.*; +import com.ruoyi.inspect.pojo.*; +import com.ruoyi.inspect.service.InsOrderService; +import com.ruoyi.inspect.service.InsReportService; +import com.ruoyi.inspect.mapper.InsUnqualifiedHandlerMapper; +import com.ruoyi.system.mapper.UserMapper; +import com.ruoyi.system.service.InformationNotificationService; +import org.apache.poi.xwpf.usermodel.*; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; + +/** + * @author Administrator + * @description 閽堝琛ㄣ�恑ns_report(妫�楠屾姤鍛�)銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇 + * @createDate 2024-03-17 22:10:02 + */ +@Service +public class InsReportServiceImpl extends ServiceImpl<InsReportMapper, InsReport> + implements InsReportService { + @Resource + private UserMapper userMapper; + @Resource + private InsReportMapper insReportMapper; + @Resource + private InsOrderStateMapper insOrderStateMapper; + @Resource + private InsProductMapper insProductMapper; + @Resource + private InformationNotificationService informationNotificationService; + @Value("${wordUrl}") + private String wordUrl; + @Value("${file.path}") + private String imgUrl; + @Value("${file.licenseUrl}") + private String licenseUrl; + @Resource + private InsOrderMapper insOrderMapper; + @Resource + private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; + @Resource + private InsUnqualifiedHandlerMapper insUnqualifiedHandlerMapper; + @Resource + private InsSampleMapper insSampleMapper; + @Resource + private ThreadPoolTaskExecutor threadPoolTaskExecutor; + @Resource + private InsOrderService insOrderService; + @Resource + private WechatProperty wechatProperty; + @Resource + private InsUnqualifiedRetestProductMapper insUnqualifiedRetestProductMapper; + @Resource + private IfsApiUtils ifsApiUtils; + @Resource + private InsSampleUserMapper insSampleUserMapper; + + + @Override + public Map<String, Object> pageInsReport(Page page, ReportPageDto reportPageDto) { + Map<String, Object> map = new HashMap<>(); + // todo: 浠呯湅鑷繁 + //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id + String laboratory = null; + Integer createOrderUser = null; + String queryStatus = reportPageDto.getQueryStatus(); + reportPageDto.setQueryStatus(null); + + map.put("body", insReportMapper.pageInsReport(page, + QueryWrappers.queryWrappers(reportPageDto), + laboratory, + SecurityUtils.getUserId().intValue(), + queryStatus, + createOrderUser)); + return map; + } + + @Override + public int inReport(String url, Integer id) { + InsReport insReport = new InsReport(); + insReport.setId(id); + insReport.setUrlS(url); + // 杩樺師pdf + String tempUrlPdf = wordToPdfTemp(insReport.getUrlS().replace("/word", wordUrl)); + insReport.setTempUrlPdf("/word/" + tempUrlPdf); + return insReportMapper.updateById(insReport); + } + + @Override + public int upReportUrl(Integer id) { + InsReport report = insReportMapper.selectById(id); + // 杩樺師pdf + String tempUrlPdf = wordToPdfTemp(report.getUrl().replace("/word", wordUrl)); + + return insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() + .eq(InsReport::getId, id) + .set(InsReport::getUrlS, null) + .set(InsReport::getTempUrlPdf, "/word/" + tempUrlPdf)); + } + + //鎻愪氦 + @Override + @Transactional(rollbackFor = Exception.class) + public int writeReport(Integer id, Integer userId, Integer submitUserId) { + submitUserId = submitUserId == null ? SecurityUtils.getUserId().intValue() : submitUserId; + InsReport insReport = insReportMapper.selectById(id); + insReport.setId(id); + insReport.setState(1); + insReport.setWriteUserId(submitUserId);//鎻愪氦浜� + if (userId == null) { + throw new ErrorException("缂哄皯瀹℃牳浜�"); + } + insReport.setExamineUserId(userId);//瀹℃牳浜� + insReport.setWriteTime(LocalDateTime.now());//鎻愪氦鏃堕棿 + //鑾峰彇鎻愪氦浜虹殑绛惧悕鍦板潃 + String signatureUrl; + try { + signatureUrl = userMapper.selectById(insReport.getWriteUserId()).getSignatureUrl(); + } catch (Exception e) { + throw new ErrorException("鎵句笉鍒扮紪鍒朵汉鐨勭鍚�"); + } + if (ObjectUtils.isEmpty(signatureUrl) || signatureUrl.equals("")) { + throw new ErrorException("鎵句笉鍒版楠屼汉鐨勭鍚�"); + } + + Integer insOrderId = insReportMapper.selectById(id).getInsOrderId(); + InsOrder order = insOrderMapper.selectById(insOrderId); + boolean isRawMater = order.getTypeSource() != null && order.getTypeSource().equals(1); + + //鍙戦�佹秷鎭� + InformationNotification info = new InformationNotification(); + info.setCreateUser(insProductMapper.selectUserById(userId).get("name")); + info.setMessageType("3"); + info.setTheme("瀹℃牳閫氱煡"); + info.setContent("鎮ㄦ湁涓�鏉℃姤鍛婄紪鍒跺緟瀹℃牳娑堟伅, 缂栧彿:" + insReport.getCode()); + info.setSenderId(submitUserId); //鍙戦�佷汉 + info.setConsigneeId(userId); //鏀朵欢浜� + info.setViewStatus(false); + info.setJumpPath("b1-report-preparation"); + informationNotificationService.addInformationNotification(info); + //绯荤粺鐢熸垚鎶ュ憡鍦板潃 + String url = insReport.getUrl(); + //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 + String urlS = insReport.getUrlS(); + + // 鍒ゆ柇鏄惁鏄師鏉愭枡 闇�瑕佹浛鎹�****鎴愪緵搴斿晢 + IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectOne(new LambdaQueryWrapper<IfsInventoryQuantity>() + .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); + if (one != null) { + if (isRawMater && order.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)) { + changeText(new HashMap<String, String>() {{ + put("**********", one.getSupplierName()); + }}, (StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); + } + } + + wordInsertUrl(new HashMap<String, Object>() {{ + put("writeUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); + put("writeDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(null)).create()); + put("insUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); + }}, (StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); + + // 淇敼涓存椂pdf + String tempUrlPdf = wordToPdfTemp((StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); + insReport.setTempUrlPdf("/word/" + tempUrlPdf); + + insReportMapper.updateById(insReport); + + // 娓呯┖瀹℃牳鏃堕棿, 瀹℃牳鐘舵�� + insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() + .eq(InsReport::getId, insReport.getId()) + .set(InsReport::getRatifyTime, null) + .set(InsReport::getIsRatify, null) + .set(InsReport::getExamineTime, null) + .set(InsReport::getIsExamine, null)); + + return 1; + } + + //瀹℃牳 + @Override + @Transactional(rollbackFor = Exception.class) + public int examineReport(Integer id, Integer isExamine, String examineTell, Integer userId) { + InsReport insReport = insReportMapper.selectById(id); + insReport.setIsExamine(isExamine); + if (ObjectUtils.isNotEmpty(examineTell)) { + insReport.setExamineTell(examineTell); + } + + // 妫�楠屼汉 + String userName = insProductMapper.selectUserById(insReport.getWriteUserId()).get("name"); + String userAccount = insProductMapper.selectUserById(insReport.getWriteUserId()).get("account"); + + // 瀹℃牳浜� + Integer checkUserId = SecurityUtils.getUserId().intValue(); + String checkUserName = insProductMapper.selectUserById(checkUserId).get("name"); + + insReport.setExamineTime(LocalDateTime.now());//瀹℃牳鏃堕棿 + if (isExamine == 0) { + // 鍙戦�佷紒涓氬井淇¢�氱煡(瀹℃牳閫�鍥�) + threadPoolTaskExecutor.execute(() -> { + // 鏌ヨ璁㈠崟 + InsOrder order = insOrderMapper.selectById(insReport.getInsOrderId()); + InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() + .eq(InsSample::getInsOrderId, insReport.getInsOrderId()) + .last("limit 1")); + // 鏌ヨ鍘熸潗鏂� + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); + + String message = ""; + message += "鎶ュ憡缂栧埗瀹℃牳閫�鍥為�氱煡"; + message += "\n瀹℃牳浜�: " + checkUserName; + message += "\n濮旀墭缂栧彿: " + order.getEntrustCode(); + message += "\n鏍峰搧鍚嶇О: " + insSample.getModel(); + message += "\n瑙勬牸鍨嬪彿: " + order.getPartDetail(); + if (ifsInventoryQuantity != null) { + message += "\n鎵规鍙�: " + ifsInventoryQuantity.getUpdateBatchNo(); + } + message += "\n閫�鍥炲師鍥�: " + examineTell; + //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡 鎻愪氦澶嶆牳 + try { + WxCpUtils.inform(userAccount, message, null); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + + //濡傛灉瀹℃牳涓嶉�氳繃 + insReport.setState(0);//鎻愪氦鐘舵�佹敼涓哄緟鎻愪氦 + return insReportMapper.updateById(insReport); + } else { + if (userId == null) { + throw new ErrorException("缂哄皯鎵瑰噯浜�"); + } + } + insReport.setRatifyUserId(userId);//鎵瑰噯浜� + //鑾峰彇瀹℃牳浜虹殑绛惧悕鍦板潃 + String signatureUrl; + try { + signatureUrl = userMapper.selectById(insReport.getExamineUserId()).getSignatureUrl(); + } catch (Exception e) { + throw new ErrorException("鎵句笉鍒板鏍镐汉鐨勭鍚�"); + } + if (StringUtils.isBlank(signatureUrl)) { + throw new ErrorException("鎵句笉鍒板鏍镐汉鐨勭鍚�"); + } + + // 鎵瑰噯浜� + String sendUserAccount = insProductMapper.selectUserById(userId).get("account"); + + //鍙戦�佹秷鎭� + InformationNotification info = new InformationNotification(); + info.setCreateUser(insProductMapper.selectUserById(userId).get("name")); + info.setMessageType("3"); + info.setTheme("鎵瑰噯閫氱煡"); + info.setContent("鎮ㄦ湁涓�鏉℃姤鍛婄紪鍒跺緟鎵瑰噯娑堟伅, 缂栧彿:" + insReport.getCode()); + info.setSenderId(checkUserId); //鍙戦�佷汉 + info.setConsigneeId(userId); //鏀朵欢浜� + info.setViewStatus(false); + info.setJumpPath("b1-report-preparation"); + informationNotificationService.addInformationNotification(info); + //绯荤粺鐢熸垚鎶ュ憡鍦板潃 + String url = insReport.getUrl(); + //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 + String urlS = insReport.getUrlS(); + wordInsertUrl(new HashMap<String, Object>() {{ + put("examineUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); + put("examineDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(null)).create()); + }}, (StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); + + // 淇敼涓存椂pdf + String tempUrlPdf = wordToPdfTemp((StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); + insReport.setTempUrlPdf("/word/" + tempUrlPdf); + + // 鍙戦�佷紒涓氬井淇¢�氱煡(閫氱煡鎵瑰噯浜哄鎵�) + threadPoolTaskExecutor.execute(() -> { + // 鏌ヨ璁㈠崟 + InsOrder order = insOrderMapper.selectById(insReport.getInsOrderId()); + InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() + .eq(InsSample::getInsOrderId, insReport.getInsOrderId()) + .last("limit 1")); + // 鏌ヨ鍘熸潗鏂� + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); + + String message = ""; + message += "鎶ュ憡缂栧埗鎵瑰噯閫氱煡"; + message += "\n妫�楠屼汉: " + userName; + message += "\n澶嶆牳浜�: " + checkUserName; + message += "\n濮旀墭缂栧彿: " + order.getEntrustCode(); + message += "\n鏍峰搧鍚嶇О: " + insSample.getModel(); + message += "\n瑙勬牸鍨嬪彿: " + order.getPartDetail(); + if (ifsInventoryQuantity != null) { + message += "\n鐢熶骇鍘傚: " + ifsInventoryQuantity.getSupplierName(); + message += "\n鎵规鍙�: " + ifsInventoryQuantity.getUpdateBatchNo(); + } + //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡 鎻愪氦澶嶆牳 + try { + WxCpUtils.inform(sendUserAccount, message, null); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + insReportMapper.updateById(insReport); + + // 娓呯┖鎵瑰噯澶囨敞, 鎵瑰噯鏃堕棿, 鎵瑰噯鐘舵�� + insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() + .eq(InsReport::getId, insReport.getId()) + .set(InsReport::getExamineTell, null) + .set(InsReport::getRatifyTime, null) + .set(InsReport::getIsRatify, null)); + return 1; + } + + //鎵瑰噯 + @Override + @Transactional(rollbackFor = Exception.class) + public int ratifyReport(Integer id, Integer isRatify, String ratifyTell) { + InsReport insReport = insReportMapper.selectById(id); + insReport.setIsRatify(isRatify); + if (ObjectUtils.isNotEmpty(ratifyTell)) { + insReport.setRatifyTell(ratifyTell); + } + insReport.setRatifyTime(LocalDateTime.now());//鎵瑰噯鏃堕棿 + if (isRatify == 0) { + + // 鎵瑰噯浜� + Integer ratifyUserId = SecurityUtils.getUserId().intValue(); + String ratifyUserName = insProductMapper.selectUserById(ratifyUserId).get("name"); + + // 鍙戦�佷汉(瀹℃牳浜�)(妫�楠屼汉) + // 妫�楠屼汉 + String userAccount = insProductMapper.selectUserById(insReport.getWriteUserId()).get("account"); + // 瀹℃牳浜� + String checkUserAccount = insProductMapper.selectUserById(insReport.getExamineUserId()).get("account"); + + + // 鍙戦�佷紒涓氬井淇¢�氱煡(鎵瑰噯閫�鍥�) + threadPoolTaskExecutor.execute(() -> { + // 鏌ヨ璁㈠崟 + InsOrder order = insOrderMapper.selectById(insReport.getInsOrderId()); + InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() + .eq(InsSample::getInsOrderId, insReport.getInsOrderId()) + .last("limit 1")); + // 鏌ヨ鍘熸潗鏂� + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); + + String message = ""; + message += "鎶ュ憡缂栧埗鎵瑰噯閫�鍥為�氱煡"; + message += "\n鎵瑰噯浜�: " + ratifyUserName; + message += "\n濮旀墭缂栧彿: " + order.getEntrustCode(); + message += "\n鏍峰搧鍚嶇О: " + insSample.getModel(); + message += "\n瑙勬牸鍨嬪彿: " + order.getPartDetail(); + if (ifsInventoryQuantity != null) { + message += "\n鎵规鍙�: " + ifsInventoryQuantity.getUpdateBatchNo(); + } + message += "\n閫�鍥炲師鍥�: " + ratifyTell; + //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡 鎻愪氦澶嶆牳 + try { + // 瀹℃壒浜� + WxCpUtils.inform(checkUserAccount, message, null); + + // 妫�楠屼汉 + WxCpUtils.inform(userAccount, message, null); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + + //濡傛灉鎵瑰噯涓嶉�氳繃 鐩存帴閫�鍥炲埌鎻愪氦浜洪偅杈瑰幓 + insReport.setState(0); + insReport.setIsExamine(0); + return insReportMapper.updateById(insReport); + } + //鑾峰彇鎵瑰噯浜虹殑绛惧悕鍦板潃 + String signatureUrl; + try { + signatureUrl = userMapper.selectById(insReport.getRatifyUserId()).getSignatureUrl(); + } catch (Exception e) { + throw new ErrorException("鎵句笉鍒版壒鍑嗕汉鐨勭鍚�"); + } + if (StringUtils.isBlank(signatureUrl)) { + throw new ErrorException("鎵句笉鍒版壒鍑嗕汉鐨勭鍚�"); + } + Integer insOrderId = insReportMapper.selectById(id).getInsOrderId(); + InsOrder order = insOrderMapper.selectById(insOrderId); + boolean isRawMater = order.getTypeSource() != null && order.getTypeSource().equals(1); + + //鑾峰彇鍦烘墍鐨勬姤鍛婁笓鐢ㄧ珷 + String sealUrl; + String laboratory = insOrderMapper.selectById(insReport.getInsOrderId()).getLaboratory(); + try { + String type = ""; + if (isRawMater && order.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)) { + type = "杩涘巶鎶ュ憡"; + } else { + type = "濮旀墭鎶ュ憡"; + } + sealUrl = insReportMapper.getLaboratoryByName(laboratory, type); + } catch (Exception e) { + throw new ErrorException(laboratory + "鎵句笉鍒版姤鍛婁笓鐢ㄧ珷"); + } + if (StringUtils.isBlank(sealUrl)) { + throw new ErrorException(laboratory + "鎵句笉鍒版姤鍛婁笓鐢ㄧ珷"); + } + //绯荤粺鐢熸垚鎶ュ憡鍦板潃 + String url = insReport.getUrl(); + //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 + String urlS = insReport.getUrlS(); + String finalUrl = (StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl); + + wordInsertUrl(new HashMap<String, Object>() {{ + put("ratifyUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); + put("ratifyDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(null)).create()); + put("seal1", Pictures.ofLocal(imgUrl + "/" + sealUrl).create()); + put("seal2", Pictures.ofLocal(imgUrl + "/" + sealUrl).create()); + }}, finalUrl); + + // 淇敼涓存椂pdf + insReport.setTempUrlPdf((StrUtil.isBlank(urlS) ? url : urlS).replace(".docx", ".pdf")); + + InsOrder insOrder = new InsOrder(); + insOrder.setId(insOrderId); + insOrder.setState(4); + insOrderMapper.updateById(insOrder); + + wordToPdf(finalUrl, sealUrl, isRawMater && order.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)); + + // 鍒ゆ柇鏄惁涓哄師鏉愭枡 + if (isRawMater) { + // 淇敼ifs搴撳瓨鐘舵�� + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getState, 2) + .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); + } + insReport.setRatifyTell(""); + + // 鍙戦�佹枃浠跺埌濮旀墭浜� + if (StringUtils.isNotBlank(order.getPrepareCode())) { + threadPoolTaskExecutor.execute(() -> { + String message = ""; + message += "濮旀墭缂栧彿: " + order.getEntrustCode(); + message += "濮旀墭鏍峰搧: " + order.getSampleView(); + message += "宸叉娴嬬粨鏉�, 璇锋帴鏀�"; + try { + WxCpUtils.inform(order.getPrepareCode(), message, new File(finalUrl.replace(".docx", ".pdf"))); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + } + + return insReportMapper.updateById(insReport); + } + + @Override + public int wordInsertUrl(Map<String, Object> map, String url) { + XWPFTemplate template = XWPFTemplate.compile(url).render(map); + try { + template.writeAndClose(Files.newOutputStream(Paths.get(url))); + } catch (IOException e) { + throw new RuntimeException(e); + } + return 1; + } + + + //鎶ュ憡鎵归噺涓嬭浇 + @Override + @Transactional(rollbackFor = Exception.class) + public String downAll(String ids) { + List<Long> list = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList()); + List<InsReport> insReports = insReportMapper.selectBatchIds(list); + String zipFilePath = null; + // 涓存椂鏂囦欢澶硅矾寰� + try { + String tempFolderPath = wordUrl + "/tempFolder"; + File tempFolder = new File(tempFolderPath); + if (tempFolder.exists()) { + deleteDirectory(tempFolder); // 鍒犻櫎鏃х殑涓存椂鏂囦欢澶� + } + tempFolder.mkdirs(); // 鍒涘缓鏂扮殑涓存椂鏂囦欢澶� + for (InsReport insReport : insReports) { + File sourceFile = new File((ObjectUtils.isNotEmpty(insReport.getUrlS()) ? insReport.getUrlS() : insReport.getUrl()).replace("/word", wordUrl)); + File destinationFile = new File(tempFolder, sourceFile.getName()); + Files.copy(sourceFile.toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING); + } + // 鍘嬬缉涓存椂鏂囦欢澶� + zipFilePath = wordUrl + "/zip/output.zip"; + zipDirectory(tempFolderPath, zipFilePath); + + // 娓呯悊涓存椂鏂囦欢澶� + deleteDirectory(tempFolder); + + System.out.println("ZIP鏂囦欢鍒涘缓瀹屾垚锛�"); + } catch (IOException e) { + e.printStackTrace(); + } + return "/word/zip/output.zip"; + } + + //鎵归噺涓婁紶 + @Override + @Transactional(rollbackFor = Exception.class) + public int upAll(MultipartFile file) throws IOException { + File tempFile = null; + File unzipDir = null; + try { + tempFile = File.createTempFile(wordUrl, ".zip"); + file.transferTo(tempFile); + + unzipDir = new File("uploaded_files"); + if (!unzipDir.exists()) { + unzipDir.mkdir(); + } + unzip(tempFile, unzipDir); + // 澶勭悊瑙e帇鍚庣殑鏂囦欢 + File[] files = unzipDir.listFiles(); + if (files != null) { + for (File f : files) { + // 鏍规嵁鏂囦欢鍚嶆煡璇d + String name = f.getName(); + InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery().like(InsReport::getCode, f.getName().replace(".docx", "").replace("JCZX", "JCZX/"))); + if (ObjectUtils.isEmpty(insReport)) { + throw new ErrorException("娌℃湁鎵惧埌 " + f.getName() + " 杩欎釜鏂囦欢瀵瑰簲鐨勬姤鍛婃暟鎹�"); + } + String urlString; + String pathName; + try { + String path = wordUrl; + File realpath = new File(path); + if (!realpath.exists()) { + realpath.mkdirs(); + } + pathName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + f.getName(); + urlString = realpath + "/" + pathName; + // 澶嶅埗鏂囦欢鍒版寚瀹氳矾寰� + Files.copy(f.toPath(), new File(urlString).toPath(), StandardCopyOption.REPLACE_EXISTING); + inReport("/word/" + pathName, insReport.getId()); + } catch (IOException e) { + throw new ErrorException("鏂囦欢涓婁紶澶辫触"); + } + } + } + } catch (IOException e) { + throw new ErrorException("鏂囦欢澶勭悊澶辫触"); + } finally { + if (tempFile != null && tempFile.exists()) { + tempFile.delete(); + } + // 閫掑綊鍒犻櫎瑙e帇鐩綍鍙婂叾涓殑鏂囦欢 + if (unzipDir.exists()) { + deleteDirectory(unzipDir); // 鍒犻櫎鏃х殑涓存椂鏂囦欢澶� + } + } + return 0; + } + + + //瑙e帇鏂囦欢澶� + private void unzip(File zipFile, File destDir) throws IOException { + try (ZipFile zip = new ZipFile(zipFile)) { + Enumeration<? extends ZipEntry> entries = zip.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + File file = new File(destDir, entry.getName()); + if (entry.isDirectory()) { + file.mkdirs(); + } else { + file.getParentFile().mkdirs(); + try (InputStream in = zip.getInputStream(entry); + OutputStream out = new FileOutputStream(file)) { + byte[] buffer = new byte[1024]; + int len; + while ((len = in.read(buffer)) > 0) { + out.write(buffer, 0, len); + } + } + } + } + } + } + + // 鍘嬬缉鏂囦欢澶� + public static void zipDirectory(String sourceDirPath, String zipFilePath) throws IOException { + try (ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFilePath))) { + Path sourceDir = Paths.get(sourceDirPath); + Files.walk(sourceDir) + .filter(path -> !Files.isDirectory(path)) + .forEach(path -> { + ZipEntry zipEntry = new ZipEntry(sourceDir.relativize(path).toString()); + try { + zipOut.putNextEntry(zipEntry); + Files.copy(path, zipOut); + zipOut.closeEntry(); + } catch (IOException e) { + e.printStackTrace(); + } + }); + } + } + + // 鍒犻櫎鏂囦欢澶瑰強鍏跺唴瀹� + public static void deleteDirectory(File directory) throws IOException { + if (directory.isDirectory()) { + File[] files = directory.listFiles(); + if (files != null) { + for (File file : files) { + deleteDirectory(file); + } + } + } + Files.delete(directory.toPath()); + } + + @Override + public void wordToPdf(String path, String sealUrl, boolean isRawMater) { + try { + wordToPdf(path, path.replace(".docx", ".pdf"), sealUrl, isRawMater); + } catch (Exception e) { + throw new ErrorException("杞崲澶辫触"); + } + } + + + public String wordToPdf(String wordPath, String pdfPath, String sealUrl, boolean isRawMater) { + FileOutputStream os = null; + try { + //鍑瘉 涓嶇劧鍒囨崲鍚庢湁姘村嵃 +// InputStream is = this.getClass().getResourceAsStream("/lib/license.xml"); +// InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("license.xml"); + InputStream is = Files.newInputStream(new File(licenseUrl).toPath()); + License license = new License(); + license.setLicense(is); + if (!license.getIsLicensed()) { + System.out.println("License楠岃瘉涓嶉�氳繃..."); + return null; + } + //鐢熸垚涓�涓┖鐨凱DF鏂囦欢 + File file; + //鍒ゆ柇鏄惁鏄繘鍘傛姤鍛� + if (!isRawMater) { + file = new File(pdfPath.replace(".pdf", "-1.pdf")); + } else { + file = new File(pdfPath.replace(".pdf", ".pdf")); + } + os = new FileOutputStream(file); + //瑕佽浆鎹㈢殑word鏂囦欢 + com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); + doc.save(os, SaveFormat.PDF); + + //娣诲姞楠戠紳绔� + if (!isRawMater) { + stamperCheckMarkPDF(pdfPath.replace(".pdf", "-1.pdf"), pdfPath, imgUrl + "/" + sealUrl); + } + + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (os != null) { + try { + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return null; + } + + /** + * 鍒囧壊鍥剧墖 + * + * @param Path 鍥剧墖璺緞 + * @param n 鍒囧壊浠芥暟 + */ + public static com.itextpdf.text.Image[] slicingImages(String Path, int n) throws IOException, BadElementException { + com.itextpdf.text.Image[] nImage = new com.itextpdf.text.Image[n]; + BufferedImage img = ImageIO.read(new File(Path)); + + int h = img.getHeight(); + int w = img.getWidth(); + + int sw = w / n; + for (int i = 0; i < n; i++) { + BufferedImage subImg; + if (i == n - 1) {//鏈�鍚庡墿浣欓儴鍒� + subImg = img.getSubimage(i * sw, 0, w - i * sw, h); + } else {//鍓峮-1鍧楀潎鍖�鍒� + subImg = img.getSubimage(i * sw, 0, sw, h); + } + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ImageIO.write(subImg, Path.substring(Path.lastIndexOf('.') + 1), out); + nImage[i] = com.itextpdf.text.Image.getInstance(out.toByteArray()); + + } + return nImage; + } + + /** + * 鐩栭獞缂濈珷 + * + * @param infilePath 鍘烶DF璺緞 + * @param outFilePath 杈撳嚭PDF璺緞 + */ + public static void stamperCheckMarkPDF(String infilePath, String outFilePath, String picPath) throws IOException, DocumentException { + PdfReader reader = new PdfReader(infilePath);//閫夋嫨闇�瑕佸嵃绔犵殑pdf + PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(outFilePath));//鍔犲畬鍗扮珷鍚庣殑pdf + + + com.itextpdf.text.Rectangle pageSize = reader.getPageSize(1);//鑾峰緱绗竴椤� + float height = pageSize.getHeight(); + float width = pageSize.getWidth(); + + int nums = reader.getNumberOfPages(); + com.itextpdf.text.Image[] nImage = slicingImages(picPath, nums);//鐢熸垚楠戠紳绔犲垏鍓插浘鐗� + + for (int n = 1; n <= nums; n++) { + PdfContentByte over = stamp.getOverContent(n);//璁剧疆鍦ㄧ鍑犻〉鎵撳嵃鍗扮珷 + com.itextpdf.text.Image img = nImage[n - 1];//閫夋嫨鍥剧墖 + float newHeight = 100f; + float newWidth = img.getWidth() / (img.getHeight() / 100); + img.scaleAbsolute(newWidth, newHeight);//鎺у埗鍥剧墖澶у皬 + img.setAbsolutePosition(width - newWidth, height / 2 - newHeight / 2);//鎺у埗鍥剧墖浣嶇疆 + over.addImage(img); + } + stamp.close(); + } + + @Transactional(rollbackFor = Exception.class) + public void isRawMaterial(InsOrder insOrder) { + IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectOne(new LambdaQueryWrapper<IfsInventoryQuantity>() + .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); + if (Objects.isNull(one)) { + throw new ErrorException("鎵句笉鍒板師鏉愭枡淇℃伅"); + } + // 鍒ゆ柇鏄惁鏈変笉鍚堟牸淇℃伅 + Long count = insUnqualifiedHandlerMapper.selectCount(Wrappers.<InsUnqualifiedHandler>lambdaQuery() + .eq(InsUnqualifiedHandler::getInventoryQuantityId, one.getId())); + String toLocation = null; + + // 鍒ゆ柇鏄惁鏈変笉鍚堟牸 + Long unqualifiedCount = getUnqualifiedCount(insOrder); + + if (count.equals(0L) && unqualifiedCount.equals(0L) && one.getIsFinish().equals(0) && one.getIsSource().equals(1)) { + // 鍘熸潗鏂欑Щ搴� + toLocation = this.moveRawMaterial(one); + } + + // 鍒ゆ柇缁撴潫鐘舵�佷慨鏀瑰悎鏍肩姸鎬� + int inspectStatus = (count == 0 && unqualifiedCount == 0) ? 1 : 2; + insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() + .eq(InsOrder::getId, insOrder.getId()) + .set(InsOrder::getInsResult, inspectStatus)); + + if (one.getIsFinish().equals(0)) { + ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() + .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId()) + .set(IfsInventoryQuantity::getInspectStatus, inspectStatus)); + + // 淇敼ifs搴撳瓨鐘舵�� + if (StringUtils.isBlank(toLocation)) { + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getIsFinish, 1) + .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); + } else { + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getIsFinish, 1) + .set(IfsInventoryQuantity::getToLocation, toLocation) + .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); + } + + threadPoolTaskExecutor.execute(() -> { + // 浼佷笟寰俊閫氱煡 + String message = ""; + message += "妫�娴嬬粨鏋滄彁浜ら�氱煡"; + message += "\n鎵规鍙�: " + one.getUpdateBatchNo(); + message += "\n闆朵欢鍙�: " + one.getPartNo(); + message += "\n闆朵欢鎻忚堪: " + one.getPartDesc(); + message += "\n渚涘簲鍟嗗悕绉�: " + one.getSupplierName(); + message += "\n鎶佃揪鏁伴噺: " + one.getQtyArrived().stripTrailingZeros().toPlainString() + one.getBuyUnitMeas(); + // 鍙戦�佷紒涓歩nspectStatus淇¢�氱煡 + if (inspectStatus == 1) { + message += "\n妫�娴嬬粨鏋�: 鍚堟牸"; + } else { + message += "\n妫�娴嬬粨鏋�: 涓嶅悎鏍�"; + } + WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message); + }); + + } + + + } + + /** + * 鍒ゆ柇鏄惁鏈変笉鍚堟牸 + * @param insOrder + * @return + */ + @Override + public Long getUnqualifiedCount(InsOrder insOrder) { + Long unqualifiedCount = 0L; + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() + .eq(InsSample::getInsOrderId, insOrder.getId())); + if (CollectionUtils.isNotEmpty(insSamples)) { + unqualifiedCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() + .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).collect(Collectors.toList())) + .eq(InsProduct::getInsResult, 0)); + + // 鍒ゆ柇濡傛灉鏈変笉鍚堟牸鐨勬楠岄」, 鍒ゆ柇鏈夋病鏈夋楠岄」澶嶆祴, 澶嶆牳鍚堟牸涔熺畻鍚堟牸閫氳繃 + if (!unqualifiedCount.equals(0L)) { + List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() + .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).collect(Collectors.toList())) + .eq(InsProduct::getInsResult, 0)); + + boolean flag = true; + for (InsProduct insProduct : insProducts) { + Long unqualifiedProductCount = insUnqualifiedRetestProductMapper.selectCount(Wrappers.<InsUnqualifiedRetestProduct>lambdaQuery() + .eq(InsUnqualifiedRetestProduct::getInsProductId, insProduct.getId()) + .ne(InsUnqualifiedRetestProduct::getInsResult, 0)); + if (unqualifiedProductCount != 2) { + flag = false; + } + } + if (flag) { + unqualifiedCount = 0L; + } + } + } + return unqualifiedCount; + } + + /** + * ifs绉诲簱鎿嶄綔 + * @param one + * @return + */ + @Override + public String moveRawMaterial(IfsInventoryQuantity one) { + String toLocation; + // 鐧昏閲囪喘妫�楠岀粨鏋淪TD + if (one.getIsRegister().equals(0)) { + Map<String, Object> resultMap = new HashMap<>(); + List<Map<String, Object>> resultList = new ArrayList<>(); + Map<String, Object> map = new HashMap<>(); + map.put("ORDER_NO", one.getOrderNo()); // 閲囪喘璁㈠崟鍙� + map.put("LINE_NO", one.getLineNo()); // 琛屽彿 + map.put("RELEASE_NO", one.getReleaseNo()); // 涓嬭揪鍙� + map.put("RECEIPT_NO", one.getReceiptNo()); // 鎺ユ敹鍙� + map.put("PURCH_QTY", one.getQtyToInspect()); // 瑕佹楠岀殑閲囪喘鏁伴噺 + resultList.add(map); + resultMap.put("RECORD_ID", UUID.randomUUID().toString()); + resultMap.put("SYSCODE", "LIMS"); + resultMap.put("SYSMODEL", "鐧昏閲囪喘妫�楠岀粨鏋�"); + resultMap.put("BATCH_INFO", resultList); + Result result = ifsApiUtils.getProcurementResults(JSONUtil.toJsonStr(resultMap)); + if (result.getCode() != 200) { + throw new ErrorException("IFS鐧昏閲囪喘妫�楠岀粨鏋滃け璐�: " + result.getMessage()); + } + } + insOrderService.updateIfsInventoryQuantity(one.getId()); + /** + * TODO 鍚庣画闇�瑕佽皟鐢↖FS鐨勬帴鍙� 绉诲叆鐨勫簱浣嶅彿 toLocation + */ + // 妫�楠屽悗绉诲簱 + toLocation = "1301"; + Map<String, Object> moveResultMap = new HashMap<>(); + List<Map<String, Object>> moveResultList = new ArrayList<>(); + Map<String, Object> moveMap = new HashMap<>(); + moveMap.put("ORDER_NO", one.getOrderNo()); // 閲囪喘璁㈠崟鍙� + moveMap.put("LINE_NO", one.getLineNo()); + moveMap.put("RELEASE_NO", one.getReleaseNo()); + moveMap.put("RECEIPT_NO", one.getReceiptNo()); + moveMap.put("PART_NO", one.getPartNo()); + moveMap.put("QTY", one.getQtyArrived()); + moveMap.put("LOCATION_NO", one.getLocationNo()); + moveMap.put("TO_LOCATION_NO", toLocation); + moveMap.put("LOT_BATCH_NO", one.getLotBatchNo()); + moveMap.put("SERIAL_NO", one.getSerialNo()); + moveMap.put("WAIV_DEV_REJ_NO", one.getWaivDevRejNo()); + moveMap.put("ENG_CHG_LEVEL", one.getEngChgLevel()); + moveMap.put("ACTIVITY_SEQ", one.getActivitySeq()); + moveResultList.add(moveMap); + moveResultMap.put("RECORD_ID", UUID.randomUUID().toString()); + moveResultMap.put("SYSCODE", "LIMS"); + moveResultMap.put("SYSMODEL", "妫�楠屽悗绉诲簱"); + moveResultMap.put("BATCH_INFO", moveResultList); + + Result result1 = ifsApiUtils.moveReceipt(JSONUtil.toJsonStr(moveResultMap)); + // 濡傛灉鏈夊繀椤讳负闆朵欢鎸囧畾鎵瑰彿鎶ラ敊闇�瑕侀噸鏂版彁浜ょЩ搴撲俊鎭幓鎸囧畾鎵瑰彿 + if (result1.getCode() != 200) { + String message = result1.getMessage(); + if (message.contains("蹇呴』涓洪浂浠�") && message.contains("鎸囧畾鎵瑰彿")) { + updaeBatch(one, toLocation); + } else { + throw new ErrorException("IFS妫�楠屽悗绉诲簱澶辫触: " + result1.getMessage()); + } + } + return toLocation; + } + + /** + * 閫�鍥炲埌妫�楠屼换鍔� + * @param id + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean sendBackTask(Integer id) { + InsReport report = insReportMapper.selectById(id); + // 鏍规嵁璁㈠崟鏌ヨ璇曢獙瀹� + String laboratory = insOrderMapper.selectLaboratoryByOrderId(report.getInsOrderId()); + + // 淇敼璁㈠崟鐘舵�� + insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate() + .eq(InsOrderState::getInsOrderId, report.getInsOrderId()) + .eq(InsOrderState::getLaboratory, laboratory) + .set(InsOrderState::getInsState, 4)); + + Integer insSampleId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery() + .eq(InsSampleUser::getInsSampleId, report.getInsOrderId()) + .orderByDesc(InsSampleUser::getId) + .last("limit 1")).getId(); + insSampleUserMapper.deleteById(insSampleId); + + // 淇敼鎶ュ憡琛屼负鏈樉绀� + insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() + .eq(InsReport::getId, id) + .set(InsReport::getIsPass, 0)); + + return false; + } + + + /** + * 鍏堜慨鏀归噰璐鍗曟壒娆″彿, 鍚庤繘琛岀Щ搴撴搷浣� + * @param one + * @param toLocation + */ + private void updaeBatch(IfsInventoryQuantity one, String toLocation) { + if (one.getIsUpdateBatch().equals(0)) { + // 鍏堜慨鏀规壒娆″彿鍚庤繘琛岀Щ搴� + Map<String, Object> resultMap = new HashMap<>(); + List<Map<String, Object>> resultList = new ArrayList<>(); + Map<String, Object> map = new HashMap<>(); + map.put("ORDER_NO", one.getOrderNo()); // 閲囪喘璁㈠崟鍙� + map.put("LINE_NO", one.getLineNo()); // 琛屽彿 + map.put("RELEASE_NO", one.getReleaseNo()); // 涓嬭揪鍙� + map.put("RECEIPT_NO", one.getReceiptNo()); // 鎺ユ敹鍙� + map.put("PART_NO", one.getPartNo()); //闆朵欢鍙� + map.put("CONFIGURATION_ID", one.getConfigurationId()); // 閰嶇疆鏍囪瘑 + map.put("LOCATION_NO", one.getLocationNo()); // 搴撲綅鍙� + map.put("LOT_BATCH_NO", one.getLotBatchNo());// 鎵规鍙� + map.put("NEW_LOT_BATCH_NO", one.getUpdateBatchNo()); // 鐩爣鎵规鍙� + map.put("SERIAL_NO", one.getSerialNo()); // 搴忓垪鍙� + map.put("ENG_CHG_LEVEL", one.getEngChgLevel()); // 鐗堟湰鍙� + map.put("WAIV_DEV_REJ_NO", one.getWaivDevRejNo()); // wdr鍙� + map.put("ACTIVITY_SEQ", one.getActivitySeq()); // 娲诲姩搴忓彿 + map.put("QTY_TO_CHANGE", one.getQtyArrived()); // 鍙樻洿鏁伴噺 + resultList.add(map); + resultMap.put("RECORD_ID", UUID.randomUUID().toString()); + resultMap.put("SYSCODE", "LIMS"); + resultMap.put("SYSMODEL", "淇敼閲囪喘璁㈠崟鎵规鍙�"); + resultMap.put("BATCH_INFO", resultList); + + Result result = ifsApiUtils.updateMoveReceiptLot(JSONUtil.toJsonStr(resultMap)); + + if (result.getCode() != 200) { + throw new ErrorException("IFS淇敼鎵规鍙峰け璐�: " + result.getMessage()); + } + ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() + .set(IfsInventoryQuantity::getIsUpdateBatch, 1) + .eq(IfsInventoryQuantity::getId, one.getId())); + } + + Map<String, Object> moveResultMap = new HashMap<>(); + List<Map<String, Object>> moveResultList = new ArrayList<>(); + Map<String, Object> moveMap = new HashMap<>(); + moveMap.put("ORDER_NO", one.getOrderNo()); // 閲囪喘璁㈠崟鍙� + moveMap.put("LINE_NO", one.getLineNo()); + moveMap.put("RELEASE_NO", one.getReleaseNo()); + moveMap.put("RECEIPT_NO", one.getReceiptNo()); + moveMap.put("PART_NO", one.getPartNo()); + moveMap.put("QTY", one.getQtyArrived()); + moveMap.put("LOCATION_NO", one.getLocationNo()); + moveMap.put("TO_LOCATION_NO", toLocation); + moveMap.put("LOT_BATCH_NO", one.getUpdateBatchNo()); + moveMap.put("SERIAL_NO", one.getSerialNo()); + moveMap.put("WAIV_DEV_REJ_NO", one.getWaivDevRejNo()); + moveMap.put("ENG_CHG_LEVEL", one.getEngChgLevel()); + moveMap.put("ACTIVITY_SEQ", one.getActivitySeq()); + moveResultList.add(moveMap); + moveResultMap.put("RECORD_ID", UUID.randomUUID().toString()); + moveResultMap.put("SYSCODE", "LIMS"); + moveResultMap.put("SYSMODEL", "妫�楠屽悗绉诲簱"); + moveResultMap.put("BATCH_INFO", moveResultList); + + Result result1 = ifsApiUtils.moveReceipt(JSONUtil.toJsonStr(moveResultMap)); + if (result1.getCode() != 200) { + throw new ErrorException("IFS妫�楠屽悗绉诲簱澶辫触: " + result1.getMessage()); + } + + } + + /** + * 鏇挎崲娈佃惤鏂囨湰 + * @param filePath docx瑙f瀽瀵硅薄 + * @param textMap 闇�瑕佹浛鎹㈢殑淇℃伅闆嗗悎 + */ + public static void changeText(Map<String, String> textMap, String filePath) { + try { + FileInputStream stream = new FileInputStream(filePath); + XWPFDocument document = new XWPFDocument(stream); + List<XWPFTable> tables = document.getTables(); + for (XWPFTable table : tables) { + for (XWPFTableRow row : table.getRows()) { + for (XWPFTableCell cell : row.getTableCells()) { + + textMap.forEach((s, s2) -> { + if (cell.getText().equals(s)) { + XWPFParagraph paragraph = cell.getParagraphs().get(0); + XWPFRun oldRun = paragraph.getRuns().get(0); + // 淇濆瓨鍘熸牱寮� + String fontFamily = oldRun.getFontFamily(); + int fontSize = oldRun.getFontSize(); + String color = oldRun.getColor(); + ParagraphAlignment alignment = paragraph.getAlignment(); + // 鏇挎崲鍐呭 + paragraph.removeRun(0); // 绉婚櫎鍘熸湁鐨� run + XWPFRun newRun = paragraph.createRun(); + newRun.setText(s2); + // 搴旂敤鍘熸牱寮� + newRun.setFontFamily(fontFamily); + newRun.setFontSize(fontSize); + newRun.setColor(color); + paragraph.setAlignment(alignment); + } + }); + } + } + } + FileOutputStream fileOutputStream = new FileOutputStream(filePath); + document.write(fileOutputStream); + fileOutputStream.close(); + + } catch (Exception e) { + e.printStackTrace(); + throw new ErrorException(e.getMessage()); + } + } + + /** + * word杞崲pdf + * @param path + * @return + */ + private String wordToPdfTemp(String path) { + try { + return wordToPdf(path, path.replace(".docx", "-涓存椂.pdf")); + } catch (Exception e) { + throw new ErrorException("杞崲澶辫触"); + } + } + + private String wordToPdf(String wordPath, String pdfPath) { + FileOutputStream os = null; + try { + //鍑瘉 涓嶇劧鍒囨崲鍚庢湁姘村嵃 + InputStream is = Files.newInputStream(new File(licenseUrl).toPath()); + License license = new License(); + license.setLicense(is); + if (!license.getIsLicensed()) { + System.out.println("License楠岃瘉涓嶉�氳繃..."); + return null; + } + //鐢熸垚涓�涓┖鐨凱DF鏂囦欢 + File file; + //鍒ゆ柇鏄惁鏄繘鍘傛姤鍛� + file = new File(pdfPath); + os = new FileOutputStream(file); + //瑕佽浆鎹㈢殑word鏂囦欢 + com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); + doc.save(os, SaveFormat.PDF); + String name = file.getName(); + return file.getName(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (os != null) { + try { + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return null; + } +} + + + + + + diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java index 1faaee4..9bce1e1 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java @@ -1,847 +1,839 @@ -//package com.ruoyi.inspect.service.impl; -// -//import cn.hutool.core.collection.CollUtil; -//import cn.hutool.core.collection.CollectionUtil; -//import cn.hutool.core.date.DateTime; -//import cn.hutool.core.date.DateUtil; -//import cn.hutool.core.util.StrUtil; -//import com.alibaba.excel.EasyExcel; -//import com.alibaba.excel.ExcelWriter; -//import com.alibaba.excel.write.metadata.WriteSheet; -//import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; -//import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -//import com.baomidou.mybatisplus.core.metadata.IPage; -//import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -//import com.baomidou.mybatisplus.core.toolkit.StringUtils; -//import com.baomidou.mybatisplus.core.toolkit.Wrappers; -//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.ruoyi.basic.dto.*; -//import com.ruoyi.basic.pojo.IfsInventoryQuantity; -//import com.ruoyi.common.constant.InsOrderTypeConstants; -//import com.ruoyi.common.core.domain.entity.User; -//import com.ruoyi.common.utils.LimsDateUtil; -//import com.ruoyi.common.utils.QueryWrappers; -//import com.ruoyi.common.utils.SecurityUtils; -//import com.ruoyi.common.utils.WxCpUtils; -//import com.ruoyi.framework.properties.WechatProperty; -//import com.ruoyi.inspect.dto.CopperInsOrderDto; -//import com.ruoyi.inspect.dto.RawMaterialStandardTreeDto; -//import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; -//import com.ruoyi.basic.mapper.StandardTreeMapper; -//import com.ruoyi.inspect.dto.SampleProductDto; -//import com.ruoyi.inspect.mapper.InsOrderMapper; -//import com.ruoyi.inspect.mapper.InsProductMapper; -//import com.ruoyi.inspect.mapper.InsSampleMapper; -//import com.ruoyi.inspect.pojo.InsOrder; -//import com.ruoyi.inspect.pojo.InsReport; -//import com.ruoyi.inspect.service.InsOrderService; -//import com.ruoyi.inspect.service.InsReportService; -//import com.ruoyi.inspect.service.RawMaterialOrderService; -//import com.ruoyi.common.numgen.NumberGenerator; -//import com.ruoyi.framework.exception.ErrorException; -//import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper; -//import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours; -//import com.ruoyi.system.mapper.UserMapper; -//import lombok.AllArgsConstructor; -//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -//import org.springframework.stereotype.Service; -//import org.springframework.transaction.annotation.Transactional; -// -//import javax.servlet.http.HttpServletResponse; -//import java.io.IOException; -//import java.io.UnsupportedEncodingException; -//import java.math.BigDecimal; -//import java.net.URLEncoder; -//import java.text.SimpleDateFormat; -//import java.time.LocalDateTime; -//import java.time.format.DateTimeFormatter; -//import java.util.*; -//import java.util.concurrent.atomic.AtomicInteger; -// -///** -// * @Author zhuo -// * @Date 2024/7/31 -// */ -//@Service -//@AllArgsConstructor -//public class RawMaterialOrderServiceImpl implements RawMaterialOrderService { -// -// private StandardTreeMapper standardTreeMapper; -// private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; -// private UserMapper userMapper; -// private InsOrderService insOrderService; -// private InsOrderMapper insOrderMapper; -// private InsSampleMapper insSampleMapper; -// private final NumberGenerator<InsOrder> numberGenerator; -// private InsReportService insReportService; -// private WechatProperty wechatProperty; -// private ThreadPoolTaskExecutor threadPoolTaskExecutor; -// private InsProductMapper insProductMapper; -// private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper; -// -// -// @Override -// public RawMaterialStandardTreeDto selectStandardTreeListByPartNo(String partNo) { -// if (StringUtils.isBlank(partNo)) { -// throw new ErrorException("闆朵欢鍙蜂涪澶�"); -// } -// List<FactoryDto> factoryDtos = standardTreeMapper.selectStandardTreeListByPartNo(partNo); -// if (CollectionUtil.isEmpty(factoryDtos)) { -// throw new ErrorException("闆朵欢鍙蜂负" + partNo + "鐨勫師鏉愭枡娌℃湁瀵瑰簲鐨勬爣鍑嗗簱閰嶇疆"); -// } -// RawMaterialStandardTreeDto rawMaterialStandardTreeDto = new RawMaterialStandardTreeDto(); -// for (FactoryDto factoryDto : factoryDtos) { -// for (LaboratoryDto laboratoryDto : factoryDto.getChildren()) { -// for (SampleTypeDto sampleTypeDto : laboratoryDto.getChildren()) { -// if (sampleTypeDto.getChildren().size() == 0) { -// sampleTypeDto.setChildren(standardTreeMapper.getStandardTree3(sampleTypeDto.getValue())); -// } -// // 鍒ゆ柇缁戝畾鐨勬槸鍚︽槸褰撳墠闆朵欢鍙� -// if (sampleTypeDto.getPartNo() != null && sampleTypeDto.getPartNo().equals(partNo)) { -// // 娣诲姞瀵硅薄 -// rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-" -// + laboratoryDto.getValue() + "-" -// + sampleTypeDto.getValue()); -// rawMaterialStandardTreeDto.setCode(sampleTypeDto.getCode()); -// rawMaterialStandardTreeDto.setLabel(sampleTypeDto.getLabel()); -// rawMaterialStandardTreeDto.setValue(sampleTypeDto.getValue()); -// rawMaterialStandardTreeDto.setChildren1(sampleTypeDto.getChildren()); -// } else { -// for (SampleDto sampleDto : sampleTypeDto.getChildren()) { -// if (sampleDto.getPartNo() != null && sampleDto.getPartNo().equals(partNo)) { -// // 娣诲姞瀵硅薄 -// rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-" -// + laboratoryDto.getValue() + "-" -// + sampleTypeDto.getValue() + "-" -// + sampleDto.getValue()); -// rawMaterialStandardTreeDto.setCode(sampleDto.getCode()); -// rawMaterialStandardTreeDto.setLabel(sampleDto.getLabel()); -// rawMaterialStandardTreeDto.setValue(sampleDto.getValue()); -// rawMaterialStandardTreeDto.setChildren2(sampleDto.getChildren()); -// } -// } -// } -// } -// } -// } -// return rawMaterialStandardTreeDto; -// } -// -// @Override -// public IPage<IfsInventoryQuantity> getWarehouseSubmit(IPage<IfsInventoryQuantity> page, IfsInventoryQuantity ifsInventoryQuantity) { -// return standardTreeMapper.selectIfsPage(page, QueryWrappers.queryWrappers(ifsInventoryQuantity)); -// } -// -// @Override -// public IPage<IfsInventoryQuantityDto> getIfsByStateOne(IPage<IfsInventoryQuantityDto> page, IfsInventoryQuantityDto ifsInventoryQuantityDto) { -// return standardTreeMapper.getIfsByStateOne(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto)); -// } -// -// -// /** -// * 鎶ユ -// * @param ids -// * @return -// */ -// @Override -// public int inspectionReport(List<Integer> ids) { -// Integer userId = SecurityUtils.getUserId().intValue(); -// ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() -// .in(IfsInventoryQuantity::getId, ids) -// .set(IfsInventoryQuantity::getDeclareUser, userMapper.selectById(userId).getName()) -// .set(IfsInventoryQuantity::getDeclareUserId, userId) -// .set(IfsInventoryQuantity::getIsInspect, 1) -// .set(IfsInventoryQuantity::getDeclareDate, LocalDateTime.now()) -// ); -// threadPoolTaskExecutor.execute(() -> { -// List<IfsInventoryQuantity> quantityList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery() -// .in(IfsInventoryQuantity::getId, ids)); -// // 浼佷笟寰俊閫氱煡 -// String message = ""; -// message += "鏂板鎶ユ閫氱煡"; -// for (IfsInventoryQuantity inventoryQuantity : quantityList) { -// message += "\n鎵规鍙�: " + inventoryQuantity.getUpdateBatchNo(); -// message += "\n闆朵欢鎻忚堪: " + inventoryQuantity.getPartDesc(); -// message += "\n鎶佃揪鏁伴噺: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas(); -// -// // 鍒ゆ柇鏈夋病鏈夊埌20鍚�. 鎴栬�呰兘鍚﹀厤妫� -// int result = notificationRawOrder(inventoryQuantity.getId()); -// switch (result) { -// case 1: -// message += "\n褰撳墠鏍峰搧宸叉楠岃繃, 鍙互鍏嶆"; -// break; -// case 2: -// message += "\n褰撳墠鏍峰搧宸茶秴杩�20鍚�"; -// break; -// } -// message += "\n"; -// } -// WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message); -// }); -// return 1; -// } -// -// /** -// * 鎾ら攢鎶ユ -// * @param id -// * @return -// */ -// @Override -// public int revokeInspectionReport(Integer id) { -// return ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() -// .eq(IfsInventoryQuantity::getId, id) -// .set(IfsInventoryQuantity::getIsInspect, 0) -// ); -// } -// -// /** -// * 鎵撳嵃鏍囩鏌ヨ -// * @param ids -// * @return -// */ -// @Override -// public List<IfsInventoryQuantityDto> printLabel(List<Integer> ids) { -// return ifsInventoryQuantityMapper.printLabel(ids); -// } -// -// /** -// * 鎶ユ -// * @param ifsInventoryQuantity -// * @return -// */ -// @Override -// public int inspectionReportOne(IfsInventoryQuantity ifsInventoryQuantity) { -// Integer userId = SecurityUtils.getUserId().intValue(); -// ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() -// .eq(IfsInventoryQuantity::getId, ifsInventoryQuantity.getId()) -// .set(IfsInventoryQuantity::getDeclareUser, userMapper.selectById(userId).getName()) -// .set(IfsInventoryQuantity::getDeclareUserId, userId) -// .set(IfsInventoryQuantity::getIsInspect, 1) -// .set(IfsInventoryQuantity::getDeclareDate, LocalDateTime.now()) -// .set(IfsInventoryQuantity::getUpdateBatchNo, ifsInventoryQuantity.getUpdateBatchNo()) -// ); -// -// threadPoolTaskExecutor.execute(() -> { -// IfsInventoryQuantity inventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryQuantity.getId()); -// // 浼佷笟寰俊閫氱煡 -// String message = ""; -// message += "鏂板鎶ユ閫氱煡"; -// message += "\n鎵规鍙�: " + inventoryQuantity.getUpdateBatchNo(); -// message += "\n闆朵欢鎻忚堪: " + inventoryQuantity.getPartDesc(); -// message += "\n鎶佃揪鏁伴噺: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas(); -// WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message); -// }); -// return 1; -// } -// -// /** -// * 鑾峰彇閾滀骇涓氶摼妫�娴嬫暟鎹� -// * @param id -// * @return -// */ -// @Override -// public String getIndustryChain(Integer id) { -// return ifsInventoryQuantityMapper.selectById(id).getIndustryChain(); -// } -// -// /** -// * 鍘熸潗鏂欐挙閿�鎺ュ彛 -// * @param ifsInventoryId -// * @return -// */ -// @Override -// public boolean repealRawOrder(Integer ifsInventoryId) { -// // 鏌ヨ鍒ゆ柇鏄惁鏄摐鍗曚笣 -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId); -// if (ifsInventoryQuantity.getIsCopper() != null && ifsInventoryQuantity.getIsCopper().equals(1)) { -// // 閾滃崟涓濈洿鎺ュ垹闄ゅ氨琛� -// ifsInventoryQuantityMapper.deleteById(ifsInventoryId); -// } else { -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getState, 0) -// .set(IfsInventoryQuantity::getIsQuarter, 1) -// .eq(IfsInventoryQuantity::getId, ifsInventoryId)); -// } -// -// insOrderService.update(Wrappers.<InsOrder>lambdaUpdate() -// .eq(InsOrder::getIfsInventoryId, ifsInventoryId) -// .set(InsOrder::getState, -1) -// .set(InsOrder::getEntrustCode, ""));// 鎾ら攢 -// return true; -// } -// -// /** -// * 鍘熸潗鏂欏厤妫�涓嬪崟 -// * @param list -// * @param insOrder -// * @return -// */ -// @Override -// @Transactional(rollbackFor = Exception.class) -// public int addExemptionOrder(List<SampleProductDto> list, InsOrder insOrder) { -// if (!insOrder.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)) { -// throw new ErrorException("鍙湁杩涘巶妫�楠屾墠鑳藉厤妫�"); -// } -// insOrder.setSendTime(LocalDateTime.now()); -// // 淇敼璁㈠崟琛ㄧ洿鎺ヤ负宸叉楠� -// insOrder.setState(4); -// insOrder.setTypeSource(1); -// -// String code = "Y"; -// // 鐢熸垚缂栧彿 -// String no = numberGenerator.generateNumberWithPrefix(3, -// "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), -// InsOrder::getEntrustCode); -// -// insOrderMapper.insert(insOrder); // 涓昏〃 -// -// AtomicInteger count = new AtomicInteger(); -// list.forEach(a -> { -// count.getAndIncrement(); -// a.setId(null); -// a.setInsOrderId(insOrder.getId()); -// if (StrUtil.isEmpty(a.getSampleCode())) { -// // 濡傛灉鍙湁涓�涓牱鍝佸氨涓嶉渶瑕佹嫾鎺ユ暟瀛� -// if (list.size() != 1) { -// a.setSampleCode(no + "-" + count.get()); -// } else { -// a.setSampleCode(no); -// } -// } -// insSampleMapper.insert(a); -// -// if (!CollectionUtil.isEmpty(a.getInsProduct())) { -// throw new ErrorException("鍏嶆涓嶉渶瑕佸~鍐欐楠岄」"); -// } -// }); -// -// // 鍘熸潗鏂欎笅鍗�: 濮旀墭浜哄氨鏄姤妫�浜�, 鐢熶骇鍗曚綅灏辨槸渚涘簲鍟嗗崟浣� -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(insOrder.getIfsInventoryId()); -// Integer declareUserId = ifsInventoryQuantity.getDeclareUserId(); -// User user = userMapper.selectById(declareUserId); -// // 渚涘簲鍟嗗悕绉� -// insOrder.setProduction(ifsInventoryQuantity.getSupplierName()); -// // 濮旀墭浜哄悕绉� -// insOrder.setPrepareUser(user.getName()); -// insOrder.setPhone(user.getPhone()); -// -// // 淇敼鍘熸潗鏂欐暟鎹洿鎺ヤ负宸叉楠� -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>().set(IfsInventoryQuantity::getState, 2) -// .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); -// -// insOrder.setExamineTime(LocalDateTime.now()); -// -// insOrder.setEntrustCode(no); -// insOrder.setIsExemption(1); -// -// insOrderMapper.updateById(insOrder); -// -// // 娣诲姞宸ユ椂 -// addAuxiliary(insOrder, ifsInventoryQuantity); -// -// // todo: ifs鐩存帴绉诲簱 -// insReportService.isRawMaterial(insOrder); -// -// return insOrder.getId(); -// } -// -// -// /** -// * 鏌ヨ寰呬笅鍗� -// * @param page -// * @param ifsInventoryQuantity -// * @return -// */ -// @Override -// public IPage<IfsInventoryQuantityCheckDto> selectIfsInventoryQuantity(Page<IfsInventoryQuantityCheckDto> page, IfsInventoryQuantityCheckDto ifsInventoryQuantity) { -// return standardTreeMapper.selectIfsInventoryQuantity(page, QueryWrappers.queryWrappers(ifsInventoryQuantity)); -// } -// -// /** -// * 鏌ヨ宸叉楠� -// * @param page -// * @param ifsInventoryQuantityDto -// * @return -// */ -// @Override -// public IPage<IfsInventoryQuantitySupplierDto> getIfsByOver(Page<IfsInventoryQuantitySupplierDto> page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto) { -// // todo: 鍙湅鎴� -// String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate(); -// String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate(); -// ifsInventoryQuantityDto.setBeginDeclareDate(null); -// ifsInventoryQuantityDto.setEndDeclareDate(null); -// -// return standardTreeMapper.getIfsByOver(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate); -// } -// -// /** -// * 鍒犻櫎鍘熸潗鏂欐姤妫�淇℃伅 -// * @param id -// * @return -// */ -// @Override -// public int delIfsInventory(Integer id) { -// return ifsInventoryQuantityMapper.deleteById(id); -// } -// -// /** -// * 鍘熸潗鏂欐斁琛屽厤妫� -// * @param ifsInventoryId -// * @return -// */ -// @Override -// @Transactional(rollbackFor = Exception.class) -// public boolean rawOrderRelease(Integer ifsInventoryId, String partDetail) { -// // 淇敼鍘熸潗鏂欐暟鎹洿鎺ヤ负宸叉楠� -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getState, 2) -// .set(IfsInventoryQuantity::getIsQuarter, 0) -// .eq(IfsInventoryQuantity::getId, ifsInventoryId)); -// -// // 鏌ヨ鍘熸潗鏂欎俊鎭� -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId); -// // 濮旀墭浜哄氨鏄姤妫�浜�, 鐢熶骇鍗曚綅灏辨槸渚涘簲鍟嗗崟浣� -// Integer declareUserId = ifsInventoryQuantity.getDeclareUserId(); -// User user = userMapper.selectById(declareUserId); -// -// InsOrder insOrder = new InsOrder(); -// insOrder.setState(4); -// insOrder.setTypeSource(1); -// String code = "Y"; -// // 鐢熸垚缂栧彿 -// String no = numberGenerator.generateNumberWithPrefix(3, -// "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), -// InsOrder::getEntrustCode); -// insOrder.setExamineTime(LocalDateTime.now()); -// insOrder.setEntrustCode(no); -// insOrder.setIsExemption(1); -// // 渚涘簲鍟嗗悕绉� -// insOrder.setProduction(ifsInventoryQuantity.getSupplierName()); -// // 濮旀墭浜哄悕绉� -// insOrder.setPrepareUser(user.getName()); -// insOrder.setPhone(user.getPhone()); -// insOrder.setIfsInventoryId(ifsInventoryId); -// insOrder.setPartDetail(partDetail); -// insOrder.setSendTime(LocalDateTime.now()); -// insOrder.setSample(ifsInventoryQuantity.getPartDesc()); -// // 杩涘巶妫�楠� -// insOrder.setOrderType(InsOrderTypeConstants.ENTER_THE_FACTORY); -// -// insOrderMapper.insert(insOrder); -// -// // 娣诲姞宸ユ椂 -// addAuxiliary(insOrder, ifsInventoryQuantity); -// -// // todo: ifs鐩存帴绉诲簱 -// insReportService.isRawMaterial(insOrder); -// return true; -// } -// -// /** -// * 0, 鏃犳彁绀�, 1鎻愮ず 褰撳墠鎵规鐨勬牱鍝佸凡妫�楠岃繃, 鍙互鍏嶆, 2 鎻愮ず 褰撳墠鎵规鐨勬牱鍝佸凡瓒�20鍚�, 闇�瑕佸绾у娆℃楠� -// * -// * 鍘熸潗鏂欎笅鍗曢�氱煡鍏嶆鎴栬�呭娆℃楠� -// * @param ifsInventoryId -// * @return -// */ -// @Override -// public int notificationRawOrder(Integer ifsInventoryId) { -// IfsInventoryQuantity ifsInventory = ifsInventoryQuantityMapper.selectById(ifsInventoryId); -// // 鏌ヨ褰撳墠鎵规, 渚涘簲鍟�, 闆朵欢鍙风殑鍘熸潗鏂欐槸鍚﹁秴杩囦簡20鍚�, 瓒呰繃浜�20鍚ㄩ渶瑕佽繘琛屽娆℃楠屾彁閱� -// List<IfsInventoryQuantity> quantityList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery() -// .eq(IfsInventoryQuantity::getPartNo, ifsInventory.getPartNo()) -// .eq(IfsInventoryQuantity::getUpdateBatchNo, ifsInventory.getUpdateBatchNo()) -// .eq(IfsInventoryQuantity::getSupplierId, ifsInventory.getSupplierId()) -// .eq(IfsInventoryQuantity::getSupplierName, ifsInventory.getSupplierName())); -// -// // 鍒ゆ柇鏄惁澶т簬20鍚� -// BigDecimal bigDecimal = new BigDecimal("20000"); -// BigDecimal count = BigDecimal.ZERO; -// for (IfsInventoryQuantity inventoryQuantity : quantityList) { -// // 鍒ゆ柇鍗曚綅鏄痥g鎴栬�卼 -// if (inventoryQuantity.getBuyUnitMeas().equalsIgnoreCase("t")) { -// count = count.add(inventoryQuantity.getQtyArrived().multiply(new BigDecimal("1000"))); -// } else if (inventoryQuantity.getBuyUnitMeas().equalsIgnoreCase("kg")) { -// count = count.add(inventoryQuantity.getQtyArrived()); -// } -// } -// -// if (count.compareTo(bigDecimal) >= 0) { -// return 2; -// } else { -// // 鍒ゆ柇涔嬪墠鏄惁鍑鸿繃鎶ュ憡, 鍑鸿繃鎶ュ憡鍙互鍏嶆 -// int reportCount = ifsInventoryQuantityMapper.selectReportCountById(ifsInventoryId); -// if (reportCount > 0) { -// return 1; -// } -// } -// return 0; -// } -// -// /** -// * 鎶ユ鍙互鏂板鎶ユ淇℃伅 -// * @param ifsInventoryQuantity -// */ -// @Override -// public void addIfsInventoryQuantity(IfsInventoryQuantity ifsInventoryQuantity) { -// ifsInventoryQuantity.setIsSource(0); -// ifsInventoryQuantity.setState(0); -// ifsInventoryQuantity.setIsFinish(0); -// ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); -// } -// -// @Override -// public void shiftingParking(List<Integer> ids) { -// for (Integer id : ids) { -// InsOrder order = insOrderService.getById(id); -// // todo: ifs鐩存帴绉诲簱 -// insReportService.isRawMaterial(order); -// } -// } -// -// /** -// * 閾滃崟涓濅笅鍗曞厤妫� -// * @param list -// * @param insOrder -// */ -// @Override -// @Transactional(rollbackFor = Exception.class) -// public int addRawCopperOrderExemptionOrder(List<SampleProductDto> list, CopperInsOrderDto insOrder) { -// if (!insOrder.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)) { -// throw new ErrorException("鍙湁杩涘巶妫�楠屾墠鑳藉厤妫�"); -// } -// insOrder.setSendTime(LocalDateTime.now()); -// // 淇敼璁㈠崟琛ㄧ洿鎺ヤ负宸叉楠� -// insOrder.setState(4); -// insOrder.setTypeSource(1); -// -// String code = "Y"; -// // 鐢熸垚缂栧彿 -// String no = numberGenerator.generateNumberWithPrefix(3, -// "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), -// InsOrder::getEntrustCode); -// -// insOrderMapper.insert(insOrder); // 涓昏〃 -// -// AtomicInteger count = new AtomicInteger(); -// list.forEach(a -> { -// count.getAndIncrement(); -// a.setId(null); -// a.setInsOrderId(insOrder.getId()); -// if (StrUtil.isEmpty(a.getSampleCode())) { -// // 濡傛灉鍙湁涓�涓牱鍝佸氨涓嶉渶瑕佹嫾鎺ユ暟瀛� -// if (list.size() != 1) { -// a.setSampleCode(no + "-" + count.get()); -// } else { -// a.setSampleCode(no); -// } -// } -// insSampleMapper.insert(a); -// -// if (!CollectionUtil.isEmpty(a.getInsProduct())) { -// throw new ErrorException("鍏嶆涓嶉渶瑕佸~鍐欐楠岄」"); -// } -// }); -// // 娣诲姞鍘熸潗鏂欎俊鎭� -// IfsInventoryQuantity ifsInventoryQuantity = new IfsInventoryQuantity(); -// // 鍩烘湰淇℃伅 -// ifsInventoryQuantity.setIsSource(0); -// ifsInventoryQuantity.setState(2); -// ifsInventoryQuantity.setIsInspect(1); -// ifsInventoryQuantity.setIsFinish(1); -// ifsInventoryQuantity.setIsCopper(1); -// ifsInventoryQuantity.setInspectStatus(1); -// ifsInventoryQuantity.setIsQuarter(0); -// -// ifsInventoryQuantity.setQtyArrived(insOrder.getQtyArrived()); -// ifsInventoryQuantity.setBuyUnitMeas(insOrder.getBuyUnitMeas()); -// ifsInventoryQuantity.setSupplierName(insOrder.getSupplierName()); -// ifsInventoryQuantity.setUpdateBatchNo(insOrder.getUpdateBatchNo()); -// ifsInventoryQuantity.setDeclareDate(insOrder.getDeclareDate()); -// -// ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); -// -// insOrder.setIfsInventoryId(ifsInventoryQuantity.getId()); -// insOrder.setExamineTime(LocalDateTime.now()); -// -// insOrder.setEntrustCode(no); -// insOrder.setIsExemption(1); -// -// insOrderMapper.updateById(insOrder); -// -// // 娣诲姞宸ユ椂 -// addAuxiliary(insOrder, ifsInventoryQuantity); -// -// return insOrder.getId(); -// } -// -// @Override -// @Transactional(rollbackFor = Exception.class) -// public boolean concessionRelease(Integer ifsInventoryId) { -// // 鏌ヨ鍘熸潗鏂欎俊鎭� -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId); -// if (!ifsInventoryQuantity.getInspectStatus().equals(2)) { -// throw new ErrorException("涓嶅悎鏍肩殑鍘熸潗鏂欐墠鑳借姝ユ斁琛�"); -// } -// -// // todo:闇�瑕佸垽鏂璷a娴佺▼鏄惁鏄姝ユ斁琛� -// String toLocation = insReportService.moveRawMaterial(ifsInventoryQuantity); -// -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getInspectStatus, 4) -// .set(IfsInventoryQuantity::getToLocation, toLocation) -// .eq(IfsInventoryQuantity::getId, ifsInventoryId)); -// -// return true; -// } -// -// /** -// * 鍘熸潗鏂欒繘鍘傛挙閿�涓嬪崟 -// * @param enterOrderId -// * @return -// */ -// @Override -// @Transactional(rollbackFor = Exception.class) -// public boolean repealEnterRawOrder(Integer enterOrderId) { -// // 鏌ヨ璁㈠崟 -// InsOrder order = insOrderMapper.selectById(enterOrderId); -// -// // 鏌ヨ鍒ゆ柇鏄惁鏄摐鍗曚笣 -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); -// if (ifsInventoryQuantity.getIsCopper() != null && ifsInventoryQuantity.getIsCopper().equals(1)) { -// // 閾滃崟涓濈洿鎺ュ垹闄ゅ氨琛� -// ifsInventoryQuantityMapper.deleteById(order.getIfsInventoryId()); -// } else { -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getState, 0) -// .set(IfsInventoryQuantity::getIsQuarter, 1) -// .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); -// } -// insOrderService.update(Wrappers.<InsOrder>lambdaUpdate() -// .eq(InsOrder::getId, enterOrderId) -// .set(InsOrder::getState, -1) -// .set(InsOrder::getEntrustCode, ""));// 鎾ら攢 -// -// // 娓呴櫎涔嬪墠鐨勫伐鏃� -// auxiliaryOutputWorkingHoursMapper.delete(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() -// .eq(AuxiliaryOutputWorkingHours::getOrderId, enterOrderId)); -// -// // 娓呴櫎涔嬪墠鎶ュ憡 -// insReportService.remove(Wrappers.<InsReport>lambdaQuery() -// .eq(InsReport::getInsOrderId, enterOrderId)); -// -// return true; -// } -// -// /** -// * 鍘熸潗鏂欏搴︽挙閿�涓嬪崟 -// * @param quarterOrderId -// * @return -// */ -// @Override -// @Transactional(rollbackFor = Exception.class) -// public boolean repealQuarterRawOrder(Integer quarterOrderId) { -// // 鏌ヨ璁㈠崟 -// InsOrder order = insOrderMapper.selectById(quarterOrderId); -// -// Long count = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() -// .eq(InsOrder::getIfsInventoryId, order.getIfsInventoryId()) -// .ne(InsOrder::getState, -1) -// .eq(InsOrder::getOrderType, InsOrderTypeConstants.ENTER_THE_FACTORY) -// .ne(InsOrder::getId, order.getId())); -// // 鍒ゆ柇涔嬪墠鏄惁鏈夎繘鍘傛楠�, 娌℃湁闇�瑕佷慨鏀瑰師鏉愭枡淇℃伅 -// if (count == 0) { -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getState, 0) -// .set(IfsInventoryQuantity::getIsQuarter, 1) -// .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); -// } else { -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getIsQuarter, 1) -// .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); -// } -// -// insOrderService.update(Wrappers.<InsOrder>lambdaUpdate() -// .eq(InsOrder::getId, quarterOrderId) -// .set(InsOrder::getState, -1) -// .set(InsOrder::getEntrustCode, ""));// 鎾ら攢 -// auxiliaryOutputWorkingHoursMapper.delete(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() -// .eq(AuxiliaryOutputWorkingHours::getOrderId, quarterOrderId)); -// // 娓呴櫎涔嬪墠鎶ュ憡 -// insReportService.remove(Wrappers.<InsReport>lambdaQuery() -// .eq(InsReport::getInsOrderId, quarterOrderId)); -// return true; -// } -// -// /** -// * 鍘熸潗鏂欐姤妫�鍏ㄩ儴淇℃伅瀵煎嚭 -// * @param ifsInventoryQuantityDto -// * @param response -// */ -// @Override -// public void rawAllExport(IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto, HttpServletResponse response) throws UnsupportedEncodingException { -// //鏌ヨ瀵煎嚭鐨勮垂鐢ㄧ粺璁℃暟鎹� -// String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate(); -// String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate(); -// ifsInventoryQuantityDto.setBeginDeclareDate(null); -// ifsInventoryQuantityDto.setEndDeclareDate(null); -// List<IfsInventoryQuantitySupplierDto> ifsByOverList = standardTreeMapper.getIfsByOverList(QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate); -// -// for (IfsInventoryQuantitySupplierDto dto : ifsByOverList) { -// dto.setSendTimeString(dto.getSendTime() == null ? "" : dto.getSendTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); -// dto.setReceiverDateString(dto.getReceiverDate() == null ? "" : dto.getReceiverDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); -// dto.setDeclareDateString(dto.getDeclareDate() == null ? "" : dto.getDeclareDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); -// switch (dto.getInspectStatus()) { -// case 1: -// dto.setInspectStatusString("鍚堟牸"); -// break; -// case 2: -// dto.setInspectStatusString("涓嶅悎鏍�"); -// // 鏌ヨ涓嶅悎鏍奸」 -// List<String> unqualifiedList = insProductMapper.selectUnqualifiedList(dto.getEnterOrderId() == null ? dto.getQuarterOrderId() : dto.getEnterOrderId()); -// dto.setUnqualifiedItem(CollUtil.join(unqualifiedList, ",")); -// break; -// case 3: -// dto.setInspectStatusString("鏈笅鍗�"); -// break; -// case 4: -// dto.setInspectStatusString("璁╂鏀捐"); -// break; -// case 0: -// dto.setInspectStatusString("妫�楠屼腑"); -// break; -// -// } -// } -// -// -// response.setContentType("application/vnd.ms-excel"); -// response.setCharacterEncoding("UTF-8"); -// // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴 -// String fileName = URLEncoder.encode("鍘熸潗鏂欐娴嬩俊鎭鍑�", "UTF-8"); -// response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); -// try { -// //鏂板缓ExcelWriter -// ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); -// //鑾峰彇sheet0瀵硅薄 -// WriteSheet mainSheet = EasyExcel.writerSheet(0, "鍘熸潗鏂欐娴嬩俊鎭鍑�").head(IfsInventoryQuantitySupplierDto.class).build(); -// -// //鍚憇heet0鍐欏叆鏁版嵁 浼犲叆绌簂ist杩欐牱鍙鍑鸿〃澶� -// excelWriter.write(ifsByOverList, mainSheet); -// //鍏抽棴娴� -// excelWriter.finish(); -// } catch (IOException e) { -// throw new RuntimeException("瀵煎嚭澶辫触"); -// } -// } -// -// /** -// * 鍘熸潗鏂欐煡璇㈠彲浠ュ搴︽楠岀殑鍐呭 -// * @param page -// * @param ifsInventoryQuantityDto -// * @return -// */ -// @Override -// public IPage<IfsInventoryQuantitySupplierDto> getIfsByQuarter(Page page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto) { -// -// // todo: 鍙湅鎴� -// String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate(); -// String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate(); -// ifsInventoryQuantityDto.setBeginDeclareDate(null); -// ifsInventoryQuantityDto.setEndDeclareDate(null); -// -// return standardTreeMapper.getIfsByQuarter(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate); -// } -// -// /** -// * 鎻愬墠鍏ュ簱 -// * @param ifsInventoryId -// * @return -// */ -// @Override -// public boolean advancedGodown(Integer ifsInventoryId) { -// // 鏌ヨ鍘熸潗鏂欎俊鎭� -// IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId); -// if (!ifsInventoryQuantity.getInspectStatus().equals(0) -// && !ifsInventoryQuantity.getInspectStatus().equals(3)) { -// throw new ErrorException("鏈娴嬪畬鎴愭暟鎹墠鑳芥彁鍓嶅叆搴�"); -// } -// -// // todo:闇�瑕佸垽鏂璷a娴佺▼鏄惁鏄姝ユ斁琛� -// String toLocation = insReportService.moveRawMaterial(ifsInventoryQuantity); -// -// ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() -// .set(IfsInventoryQuantity::getInspectStatus, 1) -// .set(IfsInventoryQuantity::getIsFinish, 1) -// .set(IfsInventoryQuantity::getToLocation, toLocation) -// .eq(IfsInventoryQuantity::getId, ifsInventoryId)); -// -// return true; -// } -// -// -// /** -// * 娣诲姞宸ユ椂 -// * @param insOrder -// * @param ifsInventoryQuantity -// */ -// private void addAuxiliary(InsOrder insOrder, IfsInventoryQuantity ifsInventoryQuantity) { -// AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours(); -// auxiliaryOutputWorkingHours.setInspectionItemClass(ifsInventoryQuantity.getUpdateBatchNo() + "鍏嶆");//妫�娴嬮」鍒嗙被 -// auxiliaryOutputWorkingHours.setSample(insOrder.getEntrustCode());//鏍峰搧缂栧彿 -// auxiliaryOutputWorkingHours.setOrderId(insOrder.getId());//璁㈠崟id -// auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙� -// -// // 鍏嶆榛樿2 -// auxiliaryOutputWorkingHours.setWorkTime(new BigDecimal("2"));//闈炲姞鐝伐鏃� -// auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲� -// auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : BigDecimal.ZERO).add(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : BigDecimal.ZERO));//浜ч噺宸ユ椂 -// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); -// DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); -// auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//鏃ユ湡 -// LocalDateTime localDateTime = LocalDateTime.now(); -// DateTime parse = DateUtil.parse(localDateTime.format(formatter)); -// auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//鏄熸湡 -// auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ -// auxiliaryOutputWorkingHours.setCheck(SecurityUtils.getUserId().intValue());//妫�娴嬩汉 -// auxiliaryOutputWorkingHours.setPrice(new BigDecimal("1"));//鍗曚环 -// -// auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); -// } -// -// public static String getWeek(String dayStr) { -// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); -// try { -// Date date = sdf.parse(dayStr); -// Calendar calendar = Calendar.getInstance(); -// calendar.setTime(date); -// int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); -// int day = calendar.get(Calendar.DAY_OF_MONTH); -// return getWeekDay(dayOfWeek); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// return null; -// } -// -// public static String getWeekDay(int dayOfWeek) { -// switch (dayOfWeek) { -// case Calendar.MONDAY: -// return "鍛ㄤ竴"; -// case Calendar.TUESDAY: -// return "鍛ㄤ簩"; -// case Calendar.WEDNESDAY: -// return "鍛ㄤ笁"; -// case Calendar.THURSDAY: -// return "鍛ㄥ洓"; -// case Calendar.FRIDAY: -// return "鍛ㄤ簲"; -// case Calendar.SATURDAY: -// return "鍛ㄥ叚"; -// case Calendar.SUNDAY: -// return "鍛ㄦ棩"; -// default: -// return "鏈煡"; -// } -// } -//} +package com.ruoyi.inspect.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.basic.dto.*; +import com.ruoyi.basic.pojo.IfsInventoryQuantity; +import com.ruoyi.common.constant.InsOrderTypeConstants; +import com.ruoyi.common.core.domain.entity.User; +import com.ruoyi.common.properties.WechatProperty; +import com.ruoyi.common.utils.LimsDateUtil; +import com.ruoyi.common.utils.QueryWrappers; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.WxCpUtils; +import com.ruoyi.inspect.dto.CopperInsOrderDto; +import com.ruoyi.inspect.dto.RawMaterialStandardTreeDto; +import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; +import com.ruoyi.basic.mapper.StandardTreeMapper; +import com.ruoyi.inspect.dto.SampleProductDto; +import com.ruoyi.inspect.mapper.InsOrderMapper; +import com.ruoyi.inspect.mapper.InsProductMapper; +import com.ruoyi.inspect.mapper.InsSampleMapper; +import com.ruoyi.inspect.pojo.InsOrder; +import com.ruoyi.inspect.pojo.InsReport; +import com.ruoyi.inspect.service.InsOrderService; +import com.ruoyi.inspect.service.InsReportService; +import com.ruoyi.inspect.service.RawMaterialOrderService; +import com.ruoyi.common.numgen.NumberGenerator; +import com.ruoyi.framework.exception.ErrorException; +import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper; +import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours; +import com.ruoyi.system.mapper.UserMapper; +import lombok.AllArgsConstructor; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @Author zhuo + * @Date 2024/7/31 + */ +@Service +@AllArgsConstructor +public class RawMaterialOrderServiceImpl implements RawMaterialOrderService { + + private StandardTreeMapper standardTreeMapper; + private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; + private UserMapper userMapper; + private InsOrderService insOrderService; + private InsOrderMapper insOrderMapper; + private InsSampleMapper insSampleMapper; + private final NumberGenerator<InsOrder> numberGenerator; + private InsReportService insReportService; + private WechatProperty wechatProperty; + private ThreadPoolTaskExecutor threadPoolTaskExecutor; + private InsProductMapper insProductMapper; + private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper; + + + @Override + public RawMaterialStandardTreeDto selectStandardTreeListByPartNo(String partNo) { + if (StringUtils.isBlank(partNo)) { + throw new ErrorException("闆朵欢鍙蜂涪澶�"); + } + List<FactoryDto> factoryDtos = standardTreeMapper.selectStandardTreeListByPartNo(partNo); + if (CollectionUtil.isEmpty(factoryDtos)) { + throw new ErrorException("闆朵欢鍙蜂负" + partNo + "鐨勫師鏉愭枡娌℃湁瀵瑰簲鐨勬爣鍑嗗簱閰嶇疆"); + } + RawMaterialStandardTreeDto rawMaterialStandardTreeDto = new RawMaterialStandardTreeDto(); + for (FactoryDto factoryDto : factoryDtos) { + for (LaboratoryDto laboratoryDto : factoryDto.getChildren()) { + for (SampleTypeDto sampleTypeDto : laboratoryDto.getChildren()) { + if (sampleTypeDto.getChildren().size() == 0) { + sampleTypeDto.setChildren(standardTreeMapper.getStandardTree3(sampleTypeDto.getValue())); + } + // 鍒ゆ柇缁戝畾鐨勬槸鍚︽槸褰撳墠闆朵欢鍙� + if (sampleTypeDto.getPartNo() != null && sampleTypeDto.getPartNo().equals(partNo)) { + // 娣诲姞瀵硅薄 + rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-" + + laboratoryDto.getValue() + "-" + + sampleTypeDto.getValue()); + rawMaterialStandardTreeDto.setCode(sampleTypeDto.getCode()); + rawMaterialStandardTreeDto.setLabel(sampleTypeDto.getLabel()); + rawMaterialStandardTreeDto.setValue(sampleTypeDto.getValue()); + rawMaterialStandardTreeDto.setChildren1(sampleTypeDto.getChildren()); + } else { + for (SampleDto sampleDto : sampleTypeDto.getChildren()) { + if (sampleDto.getPartNo() != null && sampleDto.getPartNo().equals(partNo)) { + // 娣诲姞瀵硅薄 + rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-" + + laboratoryDto.getValue() + "-" + + sampleTypeDto.getValue() + "-" + + sampleDto.getValue()); + rawMaterialStandardTreeDto.setCode(sampleDto.getCode()); + rawMaterialStandardTreeDto.setLabel(sampleDto.getLabel()); + rawMaterialStandardTreeDto.setValue(sampleDto.getValue()); + rawMaterialStandardTreeDto.setChildren2(sampleDto.getChildren()); + } + } + } + } + } + } + return rawMaterialStandardTreeDto; + } + + @Override + public IPage<IfsInventoryQuantity> getWarehouseSubmit(IPage<IfsInventoryQuantity> page, IfsInventoryQuantity ifsInventoryQuantity) { + return standardTreeMapper.selectIfsPage(page, QueryWrappers.queryWrappers(ifsInventoryQuantity)); + } + + @Override + public IPage<IfsInventoryQuantityDto> getIfsByStateOne(IPage<IfsInventoryQuantityDto> page, IfsInventoryQuantityDto ifsInventoryQuantityDto) { + return standardTreeMapper.getIfsByStateOne(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto)); + } + + + /** + * 鎶ユ + * @param ids + * @return + */ + @Override + public int inspectionReport(List<Integer> ids) { + Integer userId = SecurityUtils.getUserId().intValue(); + ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() + .in(IfsInventoryQuantity::getId, ids) + .set(IfsInventoryQuantity::getDeclareUser, userMapper.selectById(userId).getName()) + .set(IfsInventoryQuantity::getDeclareUserId, userId) + .set(IfsInventoryQuantity::getIsInspect, 1) + .set(IfsInventoryQuantity::getDeclareDate, LocalDateTime.now()) + ); + threadPoolTaskExecutor.execute(() -> { + List<IfsInventoryQuantity> quantityList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery() + .in(IfsInventoryQuantity::getId, ids)); + // 浼佷笟寰俊閫氱煡 + String message = ""; + message += "鏂板鎶ユ閫氱煡"; + for (IfsInventoryQuantity inventoryQuantity : quantityList) { + message += "\n鎵规鍙�: " + inventoryQuantity.getUpdateBatchNo(); + message += "\n闆朵欢鎻忚堪: " + inventoryQuantity.getPartDesc(); + message += "\n鎶佃揪鏁伴噺: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas(); + + // 鍒ゆ柇鏈夋病鏈夊埌20鍚�. 鎴栬�呰兘鍚﹀厤妫� + int result = notificationRawOrder(inventoryQuantity.getId()); + switch (result) { + case 1: + message += "\n褰撳墠鏍峰搧宸叉楠岃繃, 鍙互鍏嶆"; + break; + case 2: + message += "\n褰撳墠鏍峰搧宸茶秴杩�20鍚�"; + break; + } + message += "\n"; + } + WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message); + }); + return 1; + } + + /** + * 鎾ら攢鎶ユ + * @param id + * @return + */ + @Override + public int revokeInspectionReport(Integer id) { + return ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() + .eq(IfsInventoryQuantity::getId, id) + .set(IfsInventoryQuantity::getIsInspect, 0) + ); + } + + /** + * 鎵撳嵃鏍囩鏌ヨ + * @param ids + * @return + */ + @Override + public List<IfsInventoryQuantityDto> printLabel(List<Integer> ids) { + return ifsInventoryQuantityMapper.printLabel(ids); + } + + /** + * 鎶ユ + * @param ifsInventoryQuantity + * @return + */ + @Override + public int inspectionReportOne(IfsInventoryQuantity ifsInventoryQuantity) { + Integer userId = SecurityUtils.getUserId().intValue(); + ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() + .eq(IfsInventoryQuantity::getId, ifsInventoryQuantity.getId()) + .set(IfsInventoryQuantity::getDeclareUser, userMapper.selectById(userId).getName()) + .set(IfsInventoryQuantity::getDeclareUserId, userId) + .set(IfsInventoryQuantity::getIsInspect, 1) + .set(IfsInventoryQuantity::getDeclareDate, LocalDateTime.now()) + .set(IfsInventoryQuantity::getUpdateBatchNo, ifsInventoryQuantity.getUpdateBatchNo()) + ); + + threadPoolTaskExecutor.execute(() -> { + IfsInventoryQuantity inventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryQuantity.getId()); + // 浼佷笟寰俊閫氱煡 + String message = ""; + message += "鏂板鎶ユ閫氱煡"; + message += "\n鎵规鍙�: " + inventoryQuantity.getUpdateBatchNo(); + message += "\n闆朵欢鎻忚堪: " + inventoryQuantity.getPartDesc(); + message += "\n鎶佃揪鏁伴噺: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas(); + WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message); + }); + return 1; + } + + /** + * 鑾峰彇閾滀骇涓氶摼妫�娴嬫暟鎹� + * @param id + * @return + */ + @Override + public String getIndustryChain(Integer id) { + return ifsInventoryQuantityMapper.selectById(id).getIndustryChain(); + } + + /** + * 鍘熸潗鏂欐挙閿�鎺ュ彛 + * @param ifsInventoryId + * @return + */ + @Override + public boolean repealRawOrder(Integer ifsInventoryId) { + // 鏌ヨ鍒ゆ柇鏄惁鏄摐鍗曚笣 + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId); + if (ifsInventoryQuantity.getIsCopper() != null && ifsInventoryQuantity.getIsCopper().equals(1)) { + // 閾滃崟涓濈洿鎺ュ垹闄ゅ氨琛� + ifsInventoryQuantityMapper.deleteById(ifsInventoryId); + } else { + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getState, 0) + .set(IfsInventoryQuantity::getIsQuarter, 1) + .eq(IfsInventoryQuantity::getId, ifsInventoryId)); + } + + insOrderService.update(Wrappers.<InsOrder>lambdaUpdate() + .eq(InsOrder::getIfsInventoryId, ifsInventoryId) + .set(InsOrder::getState, -1) + .set(InsOrder::getEntrustCode, ""));// 鎾ら攢 + return true; + } + + /** + * 鍘熸潗鏂欏厤妫�涓嬪崟 + * @param list + * @param insOrder + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int addExemptionOrder(List<SampleProductDto> list, InsOrder insOrder) { + if (!insOrder.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)) { + throw new ErrorException("鍙湁杩涘巶妫�楠屾墠鑳藉厤妫�"); + } + insOrder.setSendTime(LocalDateTime.now()); + // 淇敼璁㈠崟琛ㄧ洿鎺ヤ负宸叉楠� + insOrder.setState(4); + insOrder.setTypeSource(1); + + String code = "Y"; + // 鐢熸垚缂栧彿 + String no = numberGenerator.generateNumberWithPrefix(3, + "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), + InsOrder::getEntrustCode); + + insOrderMapper.insert(insOrder); // 涓昏〃 + + AtomicInteger count = new AtomicInteger(); + list.forEach(a -> { + count.getAndIncrement(); + a.setId(null); + a.setInsOrderId(insOrder.getId()); + if (StrUtil.isEmpty(a.getSampleCode())) { + // 濡傛灉鍙湁涓�涓牱鍝佸氨涓嶉渶瑕佹嫾鎺ユ暟瀛� + if (list.size() != 1) { + a.setSampleCode(no + "-" + count.get()); + } else { + a.setSampleCode(no); + } + } + insSampleMapper.insert(a); + + if (!CollectionUtil.isEmpty(a.getInsProduct())) { + throw new ErrorException("鍏嶆涓嶉渶瑕佸~鍐欐楠岄」"); + } + }); + + // 鍘熸潗鏂欎笅鍗�: 濮旀墭浜哄氨鏄姤妫�浜�, 鐢熶骇鍗曚綅灏辨槸渚涘簲鍟嗗崟浣� + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(insOrder.getIfsInventoryId()); + Integer declareUserId = ifsInventoryQuantity.getDeclareUserId(); + User user = userMapper.selectById(declareUserId); + // 渚涘簲鍟嗗悕绉� + insOrder.setProduction(ifsInventoryQuantity.getSupplierName()); + // 濮旀墭浜哄悕绉� + insOrder.setPrepareUser(user.getName()); + insOrder.setPhone(user.getPhone()); + + // 淇敼鍘熸潗鏂欐暟鎹洿鎺ヤ负宸叉楠� + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>().set(IfsInventoryQuantity::getState, 2) + .eq(IfsInventoryQuantity::getId, insOrder.getIfsInventoryId())); + + insOrder.setExamineTime(LocalDateTime.now()); + + insOrder.setEntrustCode(no); + insOrder.setIsExemption(1); + + insOrderMapper.updateById(insOrder); + + // 娣诲姞宸ユ椂 + addAuxiliary(insOrder, ifsInventoryQuantity); + + // todo: ifs鐩存帴绉诲簱 + insReportService.isRawMaterial(insOrder); + + return insOrder.getId(); + } + + + /** + * 鏌ヨ寰呬笅鍗� + * @param page + * @param ifsInventoryQuantity + * @return + */ + @Override + public IPage<IfsInventoryQuantityCheckDto> selectIfsInventoryQuantity(Page<IfsInventoryQuantityCheckDto> page, IfsInventoryQuantityCheckDto ifsInventoryQuantity) { + return standardTreeMapper.selectIfsInventoryQuantity(page, QueryWrappers.queryWrappers(ifsInventoryQuantity)); + } + + /** + * 鏌ヨ宸叉楠� + * @param page + * @param ifsInventoryQuantityDto + * @return + */ + @Override + public IPage<IfsInventoryQuantitySupplierDto> getIfsByOver(Page<IfsInventoryQuantitySupplierDto> page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto) { + // todo: 鍙湅鎴� + String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate(); + String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate(); + ifsInventoryQuantityDto.setBeginDeclareDate(null); + ifsInventoryQuantityDto.setEndDeclareDate(null); + + return standardTreeMapper.getIfsByOver(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate); + } + + /** + * 鍒犻櫎鍘熸潗鏂欐姤妫�淇℃伅 + * @param id + * @return + */ + @Override + public int delIfsInventory(Integer id) { + return ifsInventoryQuantityMapper.deleteById(id); + } + + /** + * 鍘熸潗鏂欐斁琛屽厤妫� + * @param ifsInventoryId + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean rawOrderRelease(Integer ifsInventoryId, String partDetail) { + // 淇敼鍘熸潗鏂欐暟鎹洿鎺ヤ负宸叉楠� + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getState, 2) + .set(IfsInventoryQuantity::getIsQuarter, 0) + .eq(IfsInventoryQuantity::getId, ifsInventoryId)); + + // 鏌ヨ鍘熸潗鏂欎俊鎭� + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId); + // 濮旀墭浜哄氨鏄姤妫�浜�, 鐢熶骇鍗曚綅灏辨槸渚涘簲鍟嗗崟浣� + Integer declareUserId = ifsInventoryQuantity.getDeclareUserId(); + User user = userMapper.selectById(declareUserId); + + InsOrder insOrder = new InsOrder(); + insOrder.setState(4); + insOrder.setTypeSource(1); + String code = "Y"; + // 鐢熸垚缂栧彿 + String no = numberGenerator.generateNumberWithPrefix(3, + "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), + InsOrder::getEntrustCode); + insOrder.setExamineTime(LocalDateTime.now()); + insOrder.setEntrustCode(no); + insOrder.setIsExemption(1); + // 渚涘簲鍟嗗悕绉� + insOrder.setProduction(ifsInventoryQuantity.getSupplierName()); + // 濮旀墭浜哄悕绉� + insOrder.setPrepareUser(user.getName()); + insOrder.setPhone(user.getPhone()); + insOrder.setIfsInventoryId(ifsInventoryId); + insOrder.setPartDetail(partDetail); + insOrder.setSendTime(LocalDateTime.now()); + insOrder.setSample(ifsInventoryQuantity.getPartDesc()); + // 杩涘巶妫�楠� + insOrder.setOrderType(InsOrderTypeConstants.ENTER_THE_FACTORY); + + insOrderMapper.insert(insOrder); + + // 娣诲姞宸ユ椂 + addAuxiliary(insOrder, ifsInventoryQuantity); + + // todo: ifs鐩存帴绉诲簱 + insReportService.isRawMaterial(insOrder); + return true; + } + + /** + * 0, 鏃犳彁绀�, 1鎻愮ず 褰撳墠鎵规鐨勬牱鍝佸凡妫�楠岃繃, 鍙互鍏嶆, 2 鎻愮ず 褰撳墠鎵规鐨勬牱鍝佸凡瓒�20鍚�, 闇�瑕佸绾у娆℃楠� + * + * 鍘熸潗鏂欎笅鍗曢�氱煡鍏嶆鎴栬�呭娆℃楠� + * @param ifsInventoryId + * @return + */ + @Override + public int notificationRawOrder(Integer ifsInventoryId) { + IfsInventoryQuantity ifsInventory = ifsInventoryQuantityMapper.selectById(ifsInventoryId); + // 鏌ヨ褰撳墠鎵规, 渚涘簲鍟�, 闆朵欢鍙风殑鍘熸潗鏂欐槸鍚﹁秴杩囦簡20鍚�, 瓒呰繃浜�20鍚ㄩ渶瑕佽繘琛屽娆℃楠屾彁閱� + List<IfsInventoryQuantity> quantityList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery() + .eq(IfsInventoryQuantity::getPartNo, ifsInventory.getPartNo()) + .eq(IfsInventoryQuantity::getUpdateBatchNo, ifsInventory.getUpdateBatchNo()) + .eq(IfsInventoryQuantity::getSupplierId, ifsInventory.getSupplierId()) + .eq(IfsInventoryQuantity::getSupplierName, ifsInventory.getSupplierName())); + + // 鍒ゆ柇鏄惁澶т簬20鍚� + BigDecimal bigDecimal = new BigDecimal("20000"); + BigDecimal count = BigDecimal.ZERO; + for (IfsInventoryQuantity inventoryQuantity : quantityList) { + // 鍒ゆ柇鍗曚綅鏄痥g鎴栬�卼 + if (inventoryQuantity.getBuyUnitMeas().equalsIgnoreCase("t")) { + count = count.add(inventoryQuantity.getQtyArrived().multiply(new BigDecimal("1000"))); + } else if (inventoryQuantity.getBuyUnitMeas().equalsIgnoreCase("kg")) { + count = count.add(inventoryQuantity.getQtyArrived()); + } + } + + if (count.compareTo(bigDecimal) >= 0) { + return 2; + } else { + // 鍒ゆ柇涔嬪墠鏄惁鍑鸿繃鎶ュ憡, 鍑鸿繃鎶ュ憡鍙互鍏嶆 + int reportCount = ifsInventoryQuantityMapper.selectReportCountById(ifsInventoryId); + if (reportCount > 0) { + return 1; + } + } + return 0; + } + + /** + * 鎶ユ鍙互鏂板鎶ユ淇℃伅 + * @param ifsInventoryQuantity + */ + @Override + public void addIfsInventoryQuantity(IfsInventoryQuantity ifsInventoryQuantity) { + ifsInventoryQuantity.setIsSource(0); + ifsInventoryQuantity.setState(0); + ifsInventoryQuantity.setIsFinish(0); + ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); + } + + + /** + * 閾滃崟涓濅笅鍗曞厤妫� + * @param list + * @param insOrder + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int addRawCopperOrderExemptionOrder(List<SampleProductDto> list, CopperInsOrderDto insOrder) { + if (!insOrder.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)) { + throw new ErrorException("鍙湁杩涘巶妫�楠屾墠鑳藉厤妫�"); + } + insOrder.setSendTime(LocalDateTime.now()); + // 淇敼璁㈠崟琛ㄧ洿鎺ヤ负宸叉楠� + insOrder.setState(4); + insOrder.setTypeSource(1); + + String code = "Y"; + // 鐢熸垚缂栧彿 + String no = numberGenerator.generateNumberWithPrefix(3, + "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), + InsOrder::getEntrustCode); + + insOrderMapper.insert(insOrder); // 涓昏〃 + + AtomicInteger count = new AtomicInteger(); + list.forEach(a -> { + count.getAndIncrement(); + a.setId(null); + a.setInsOrderId(insOrder.getId()); + if (StrUtil.isEmpty(a.getSampleCode())) { + // 濡傛灉鍙湁涓�涓牱鍝佸氨涓嶉渶瑕佹嫾鎺ユ暟瀛� + if (list.size() != 1) { + a.setSampleCode(no + "-" + count.get()); + } else { + a.setSampleCode(no); + } + } + insSampleMapper.insert(a); + + if (!CollectionUtil.isEmpty(a.getInsProduct())) { + throw new ErrorException("鍏嶆涓嶉渶瑕佸~鍐欐楠岄」"); + } + }); + // 娣诲姞鍘熸潗鏂欎俊鎭� + IfsInventoryQuantity ifsInventoryQuantity = new IfsInventoryQuantity(); + // 鍩烘湰淇℃伅 + ifsInventoryQuantity.setIsSource(0); + ifsInventoryQuantity.setState(2); + ifsInventoryQuantity.setIsInspect(1); + ifsInventoryQuantity.setIsFinish(1); + ifsInventoryQuantity.setIsCopper(1); + ifsInventoryQuantity.setInspectStatus(1); + ifsInventoryQuantity.setIsQuarter(0); + + ifsInventoryQuantity.setQtyArrived(insOrder.getQtyArrived()); + ifsInventoryQuantity.setBuyUnitMeas(insOrder.getBuyUnitMeas()); + ifsInventoryQuantity.setSupplierName(insOrder.getSupplierName()); + ifsInventoryQuantity.setUpdateBatchNo(insOrder.getUpdateBatchNo()); + ifsInventoryQuantity.setDeclareDate(insOrder.getDeclareDate()); + + ifsInventoryQuantityMapper.insert(ifsInventoryQuantity); + + insOrder.setIfsInventoryId(ifsInventoryQuantity.getId()); + insOrder.setExamineTime(LocalDateTime.now()); + + insOrder.setEntrustCode(no); + insOrder.setIsExemption(1); + + insOrderMapper.updateById(insOrder); + + // 娣诲姞宸ユ椂 + addAuxiliary(insOrder, ifsInventoryQuantity); + + return insOrder.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean concessionRelease(Integer ifsInventoryId) { + // 鏌ヨ鍘熸潗鏂欎俊鎭� + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId); + if (!ifsInventoryQuantity.getInspectStatus().equals(2)) { + throw new ErrorException("涓嶅悎鏍肩殑鍘熸潗鏂欐墠鑳借姝ユ斁琛�"); + } + + // todo:闇�瑕佸垽鏂璷a娴佺▼鏄惁鏄姝ユ斁琛� + String toLocation = insReportService.moveRawMaterial(ifsInventoryQuantity); + + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getInspectStatus, 4) + .set(IfsInventoryQuantity::getToLocation, toLocation) + .eq(IfsInventoryQuantity::getId, ifsInventoryId)); + + return true; + } + + /** + * 鍘熸潗鏂欒繘鍘傛挙閿�涓嬪崟 + * @param enterOrderId + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean repealEnterRawOrder(Integer enterOrderId) { + // 鏌ヨ璁㈠崟 + InsOrder order = insOrderMapper.selectById(enterOrderId); + + // 鏌ヨ鍒ゆ柇鏄惁鏄摐鍗曚笣 + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); + if (ifsInventoryQuantity.getIsCopper() != null && ifsInventoryQuantity.getIsCopper().equals(1)) { + // 閾滃崟涓濈洿鎺ュ垹闄ゅ氨琛� + ifsInventoryQuantityMapper.deleteById(order.getIfsInventoryId()); + } else { + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getState, 0) + .set(IfsInventoryQuantity::getIsQuarter, 1) + .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); + } + insOrderService.update(Wrappers.<InsOrder>lambdaUpdate() + .eq(InsOrder::getId, enterOrderId) + .set(InsOrder::getState, -1) + .set(InsOrder::getEntrustCode, ""));// 鎾ら攢 + + // 娓呴櫎涔嬪墠鐨勫伐鏃� + auxiliaryOutputWorkingHoursMapper.delete(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() + .eq(AuxiliaryOutputWorkingHours::getOrderId, enterOrderId)); + + // 娓呴櫎涔嬪墠鎶ュ憡 + insReportService.remove(Wrappers.<InsReport>lambdaQuery() + .eq(InsReport::getInsOrderId, enterOrderId)); + + return true; + } + + /** + * 鍘熸潗鏂欏搴︽挙閿�涓嬪崟 + * @param quarterOrderId + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean repealQuarterRawOrder(Integer quarterOrderId) { + // 鏌ヨ璁㈠崟 + InsOrder order = insOrderMapper.selectById(quarterOrderId); + + Long count = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getIfsInventoryId, order.getIfsInventoryId()) + .ne(InsOrder::getState, -1) + .eq(InsOrder::getOrderType, InsOrderTypeConstants.ENTER_THE_FACTORY) + .ne(InsOrder::getId, order.getId())); + // 鍒ゆ柇涔嬪墠鏄惁鏈夎繘鍘傛楠�, 娌℃湁闇�瑕佷慨鏀瑰師鏉愭枡淇℃伅 + if (count == 0) { + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getState, 0) + .set(IfsInventoryQuantity::getIsQuarter, 1) + .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); + } else { + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getIsQuarter, 1) + .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId())); + } + + insOrderService.update(Wrappers.<InsOrder>lambdaUpdate() + .eq(InsOrder::getId, quarterOrderId) + .set(InsOrder::getState, -1) + .set(InsOrder::getEntrustCode, ""));// 鎾ら攢 + auxiliaryOutputWorkingHoursMapper.delete(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() + .eq(AuxiliaryOutputWorkingHours::getOrderId, quarterOrderId)); + // 娓呴櫎涔嬪墠鎶ュ憡 + insReportService.remove(Wrappers.<InsReport>lambdaQuery() + .eq(InsReport::getInsOrderId, quarterOrderId)); + return true; + } + + /** + * 鍘熸潗鏂欐姤妫�鍏ㄩ儴淇℃伅瀵煎嚭 + * @param ifsInventoryQuantityDto + * @param response + */ + @Override + public void rawAllExport(IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto, HttpServletResponse response) throws UnsupportedEncodingException { + //鏌ヨ瀵煎嚭鐨勮垂鐢ㄧ粺璁℃暟鎹� + String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate(); + String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate(); + ifsInventoryQuantityDto.setBeginDeclareDate(null); + ifsInventoryQuantityDto.setEndDeclareDate(null); + List<IfsInventoryQuantitySupplierDto> ifsByOverList = standardTreeMapper.getIfsByOverList(QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate); + + for (IfsInventoryQuantitySupplierDto dto : ifsByOverList) { + dto.setSendTimeString(dto.getSendTime() == null ? "" : dto.getSendTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + dto.setReceiverDateString(dto.getReceiverDate() == null ? "" : dto.getReceiverDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + dto.setDeclareDateString(dto.getDeclareDate() == null ? "" : dto.getDeclareDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + switch (dto.getInspectStatus()) { + case 1: + dto.setInspectStatusString("鍚堟牸"); + break; + case 2: + dto.setInspectStatusString("涓嶅悎鏍�"); + // 鏌ヨ涓嶅悎鏍奸」 + List<String> unqualifiedList = insProductMapper.selectUnqualifiedList(dto.getEnterOrderId() == null ? dto.getQuarterOrderId() : dto.getEnterOrderId()); + dto.setUnqualifiedItem(CollUtil.join(unqualifiedList, ",")); + break; + case 3: + dto.setInspectStatusString("鏈笅鍗�"); + break; + case 4: + dto.setInspectStatusString("璁╂鏀捐"); + break; + case 0: + dto.setInspectStatusString("妫�楠屼腑"); + break; + + } + } + + + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴 + String fileName = URLEncoder.encode("鍘熸潗鏂欐娴嬩俊鎭鍑�", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + try { + //鏂板缓ExcelWriter + ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); + //鑾峰彇sheet0瀵硅薄 + WriteSheet mainSheet = EasyExcel.writerSheet(0, "鍘熸潗鏂欐娴嬩俊鎭鍑�").head(IfsInventoryQuantitySupplierDto.class).build(); + + //鍚憇heet0鍐欏叆鏁版嵁 浼犲叆绌簂ist杩欐牱鍙鍑鸿〃澶� + excelWriter.write(ifsByOverList, mainSheet); + //鍏抽棴娴� + excelWriter.finish(); + } catch (IOException e) { + throw new RuntimeException("瀵煎嚭澶辫触"); + } + } + + /** + * 鍘熸潗鏂欐煡璇㈠彲浠ュ搴︽楠岀殑鍐呭 + * @param page + * @param ifsInventoryQuantityDto + * @return + */ + @Override + public IPage<IfsInventoryQuantitySupplierDto> getIfsByQuarter(Page page, IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto) { + + // todo: 鍙湅鎴� + String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate(); + String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate(); + ifsInventoryQuantityDto.setBeginDeclareDate(null); + ifsInventoryQuantityDto.setEndDeclareDate(null); + + return standardTreeMapper.getIfsByQuarter(page, QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate); + } + + /** + * 鎻愬墠鍏ュ簱 + * @param ifsInventoryId + * @return + */ + @Override + public boolean advancedGodown(Integer ifsInventoryId) { + // 鏌ヨ鍘熸潗鏂欎俊鎭� + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryId); + if (!ifsInventoryQuantity.getInspectStatus().equals(0) + && !ifsInventoryQuantity.getInspectStatus().equals(3)) { + throw new ErrorException("鏈娴嬪畬鎴愭暟鎹墠鑳芥彁鍓嶅叆搴�"); + } + + // todo:闇�瑕佸垽鏂璷a娴佺▼鏄惁鏄姝ユ斁琛� + String toLocation = insReportService.moveRawMaterial(ifsInventoryQuantity); + + ifsInventoryQuantityMapper.update(null, new LambdaUpdateWrapper<IfsInventoryQuantity>() + .set(IfsInventoryQuantity::getInspectStatus, 1) + .set(IfsInventoryQuantity::getIsFinish, 1) + .set(IfsInventoryQuantity::getToLocation, toLocation) + .eq(IfsInventoryQuantity::getId, ifsInventoryId)); + + return true; + } + + + /** + * 娣诲姞宸ユ椂 + * @param insOrder + * @param ifsInventoryQuantity + */ + private void addAuxiliary(InsOrder insOrder, IfsInventoryQuantity ifsInventoryQuantity) { + AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours(); + auxiliaryOutputWorkingHours.setInspectionItemClass(ifsInventoryQuantity.getUpdateBatchNo() + "鍏嶆");//妫�娴嬮」鍒嗙被 + auxiliaryOutputWorkingHours.setSample(insOrder.getEntrustCode());//鏍峰搧缂栧彿 + auxiliaryOutputWorkingHours.setOrderId(insOrder.getId());//璁㈠崟id + auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙� + + // 鍏嶆榛樿2 + auxiliaryOutputWorkingHours.setWorkTime(new BigDecimal("2"));//闈炲姞鐝伐鏃� + auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲� + auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : BigDecimal.ZERO).add(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : BigDecimal.ZERO));//浜ч噺宸ユ椂 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//鏃ユ湡 + LocalDateTime localDateTime = LocalDateTime.now(); + DateTime parse = DateUtil.parse(localDateTime.format(formatter)); + auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//鏄熸湡 + auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ + auxiliaryOutputWorkingHours.setCheck(SecurityUtils.getUserId().intValue());//妫�娴嬩汉 + auxiliaryOutputWorkingHours.setPrice(new BigDecimal("1"));//鍗曚环 + + auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); + } + + public static String getWeek(String dayStr) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + Date date = sdf.parse(dayStr); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + int day = calendar.get(Calendar.DAY_OF_MONTH); + return getWeekDay(dayOfWeek); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String getWeekDay(int dayOfWeek) { + switch (dayOfWeek) { + case Calendar.MONDAY: + return "鍛ㄤ竴"; + case Calendar.TUESDAY: + return "鍛ㄤ簩"; + case Calendar.WEDNESDAY: + return "鍛ㄤ笁"; + case Calendar.THURSDAY: + return "鍛ㄥ洓"; + case Calendar.FRIDAY: + return "鍛ㄤ簲"; + case Calendar.SATURDAY: + return "鍛ㄥ叚"; + case Calendar.SUNDAY: + return "鍛ㄦ棩"; + default: + return "鏈煡"; + } + } +} diff --git a/inspect-server/src/main/resources/mapper/InsOrderMapper.xml b/inspect-server/src/main/resources/mapper/InsOrderMapper.xml new file mode 100644 index 0000000..2cc6e8d --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsOrderMapper.xml @@ -0,0 +1,588 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.inspect.mapper.InsOrderMapper"> + + <resultMap id="selectSampleDefectsMap" type="com.ruoyi.inspect.vo.SampleDefectsFatherVo"> + <id column="id" property="id"/> + <result column="sample" property="sample"/> + <association property="children" resultMap="SampleDefectsChildrenMap" javaType="java.util.List"/> + </resultMap> + + <resultMap id="SampleDefectsChildrenMap" type="com.ruoyi.inspect.vo.SampleDefectsChildrenVo"> + <result column="entrust_code" property="entrust_code"/> + <result column="inspection_item" property="inspection_item"/> + <result column="name" property="name"/> + <result column="create_time" property="create_time"/> + </resultMap> + + <sql id="selectSampleProductDto2"> + i.id, + isa.sample_code, + isa.sample, + isa.model, + isa.ins_state, + ip.id insProductId, + ip.state, + ip.unit, + ip.inspection_item_class, + ip.inspection_item_class_en, + ip.inspection_item, + ip.inspection_item_en, + ip.inspection_item_subclass, + ip.inspection_item_subclass_en, + ip.son_laboratory, + ip.inspection_item_type, + ip.inspection_value_type, + ip.ask, + ip.tell, + ip.`last_value`, + ip.ins_result, + ip.radius, + isa.quantity, + ip.sort, + ip.cable_tag + </sql> + + <select id="selectInsOrderPage" resultType="com.ruoyi.inspect.dto.SampleOrderDto"> + select * + from ( + SELECT + io.*, + isau.user_id assign, + ir.id report_id, + ir.url, + ir.url_s, + sample_counts.sample_num, + CONCAT(ROUND(approved_product_counts.approved_count / total_product_counts.total_count * 100, 2), '%') AS insProgress, + io.sample_view AS sample_name, + GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model, + u.name, + testing_name, + ip.son_laboratory + FROM + ins_order io + LEFT JOIN + ins_sample isa ON io.id = isa.ins_order_id + left join ins_product ip on ip.ins_sample_id = isa.id + LEFT JOIN + ins_sample_user isau ON isau.ins_sample_id = io.id + LEFT JOIN + (SELECT id, ins_order_id, is_ratify, url, url_s FROM ins_report WHERE is_ratify = 1) ir ON io.id = ir.ins_order_id + LEFT JOIN + user u ON io.create_user = u.id + LEFT JOIN + (SELECT ins_order_id, COUNT(*) AS sample_num + FROM ins_sample + WHERE id in(select id1 from (select is2.id id1 ,ip.id from ins_sample is2 left join ins_product ip on is2.id = ip.ins_sample_id where ip.id is not null)s ) + GROUP BY ins_order_id) sample_counts ON io.id = sample_counts.ins_order_id + LEFT JOIN + (SELECT ins_sample.ins_order_id, COUNT(*) AS total_count + FROM ins_product + JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id + WHERE ins_product.state = 1 + GROUP BY ins_sample.ins_order_id) total_product_counts ON io.id = total_product_counts.ins_order_id + LEFT JOIN + (SELECT ins_sample.ins_order_id, COUNT(*) AS approved_count + FROM ins_product + JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id + WHERE ins_product.state = 1 AND ins_product.ins_result IS NOT NULL + GROUP BY ins_sample.ins_order_id) approved_product_counts ON io.id = approved_product_counts.ins_order_id + LEFT JOIN (SELECT ins_sample_id, GROUP_CONCAT(DISTINCT uu.name SEPARATOR ',') AS testing_name + FROM ins_sample_user u + LEFT JOIN user uu ON u.user_id = uu.id + WHERE u.state = 0 + GROUP BY ins_sample_id + ORDER BY ins_sample_id) isu ON isu.ins_sample_id = io.id + where (io.ifs_inventory_id IS NULL OR TRIM(io.ifs_inventory_id) = '') + <if test="isOrderAll != null and isOrderAll != ''"> + AND io.state in (1, 4) + </if> + <if test="laboratory!=null and laboratory!=''"> + AND io.laboratory=#{laboratory} + </if> + GROUP BY io.id,type + order by type desc,io.id desc + ) a + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + + <select id="selectInsOrderParameter" resultType="com.ruoyi.inspect.pojo.InsOrder"> + select * + from ( + select + id, + appointed, + user_id, + create_user, + otc_code, + code, + custom, + update_user, + update_time, + type, + entrust_code, + company, + remark, + create_time, + state + from ins_order + ) a + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + <select id="getLaboratoryCode" resultType="java.lang.String"> + select laboratory_number + from laboratory + where laboratory_name = #{name} + </select> + <select id="selectSampleAndProductByOrderId" resultType="com.ruoyi.inspect.dto.SampleProductDto2"> + select * + from ( + select + i.id, + isa.sample_code, + isa.sample, + isa.model, + isa.ins_state, + ip.id insProductId, + ip.state, + ip.unit, + ip.inspection_item, + ip.inspection_item_subclass, + ip.son_laboratory, + ip.inspection_item_type, + ip.inspection_value_type, + ip.tell, + ip.ask, + ip.`last_value`, + ip.ins_result, + ip.inspection_item_class, + i.ifs_inventory_id, + i.order_type, + ip.sort, + ip.cable_tag, + ip.radius + from ins_sample isa + left join ins_order i on isa.ins_order_id = i.id + left join ins_product ip on isa.id = ip.ins_sample_id + where ip.state = 1 + and i.id=#{id} + and ip.is_binding != 1 + ) a + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + <select id="selectCostStatistics" resultType="com.ruoyi.inspect.dto.CostStatisticsDto"> + select * from ( + SELECT A.id, + A.entrust_code, + A.create_time, + A.sample, + A.model, + A.inspection_item, + A.company, + A.`name`, + COUNT(1) num, + SUM(A.price) price, + SUM(A.cost) cost + FROM + (SELECT + i.id, + i.entrust_code, + i.create_time, + isa.sample, + isa.sample_code, + isa.model, + c.price, + c.cost, + c.inspection_item, + i.company, + u.`name`, + i.create_user, + c.ins_sample_id + FROM + ins_order i + LEFT JOIN ins_sample isa ON isa.ins_order_id = i.id + LEFT JOIN `user` u ON u.id = i.user_id + left join custom cus on cus.id = u.company + LEFT JOIN (select SUM(b.price) price, sum(b.man_hour) cost,b.ins_sample_id, + GROUP_CONCAT(b.inspection_item2 + SEPARATOR ',') + inspection_item from (select * , + GROUP_CONCAT(CONCAT(inspection_item,'@',inspection_item_subclass) SEPARATOR ',')inspection_item2 from ins_product where state = 1 and template_id IS NOT NULL GROUP BY ins_sample_id,man_hour_group) b GROUP + BY b.ins_sample_id) c ON c.ins_sample_id = isa.id + where (i.state = 1 or i.state = 3 or i.state = 4) and c.ins_sample_id IS not NULL)A + GROUP BY + A.id, + A.entrust_code, + A.create_time, + A.sample, + A.model, + A.inspection_item, + A.company, + A.`name` + ) B + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + <select id="selectDeviceList" resultType="java.util.Map"> + select device_name, + en_device_name, + specification_model, + management_number, + date_format(activation_date,'%Y-%m-%d') + latest_traceability + from device + where device.management_number in + <foreach collection="names" index="index" open="(" separator="," close=")" item="val"> + #{val} + </foreach> + </select> + + <update id="updateStatus"> + update ins_order + set state=3 + where id = #{id} + </update> + + <select id="selectSampleDefects" resultMap="selectSampleDefectsMap"> + SELECT io.entrust_code,sam.sample,ip.inspection_item,u.name,b.create_time, sam.id + from ins_order io + left JOIN ins_sample sam on io.id=sam.ins_order_id + LEFT JOIN ins_product ip on ip.ins_sample_id=sam.id + LEFT JOIN + (SELECT create_time,create_user,ins_product_id FROM + (select * FROM ins_product_user ORDER BY ins_product_user.create_time DESC) a + GROUP BY a.ins_product_id) b + on b.ins_product_id=ip.id + left JOIN `user` u on u.id=b.create_user + WHERE (ip.ins_result=0 OR ip.state=0) + <if test="inspectionItems != null and inspectionItems != ''"> + and inspection_item like concat('%', #{inspectionItems}, '%') + </if> + <if test="orderNumber != null and orderNumber != ''"> + and io.entrust_code like concat('%', #{orderNumber}, '%') + </if> + </select> + + <select id="getCount" resultType="long"> + select count(1) + from ( + SELECT io.entrust_code,sam.sample,ip.inspection_item,u.name,b.create_time, sam.id + from ins_order io + left JOIN ins_sample sam on io.id=sam.ins_order_id + LEFT JOIN ins_product ip on ip.ins_sample_id=sam.id + LEFT JOIN + (SELECT create_time,create_user,ins_product_id FROM (select * FROM ins_product_user ORDER BY + ins_product_user.create_time DESC) a GROUP BY a.ins_product_id) b + on b.ins_product_id=ip.id + left JOIN `user` u on u.id=b.create_user + where (ip.ins_result=0 OR ip.state=0) + <if test="inspectionItems != null and inspectionItems != ''"> + and inspection_item like concat('%', #{inspectionItems}, '%') + </if> + <if test="orderNumber != null and orderNumber != ''"> + and io.entrust_code like concat('%', #{orderNumber}, '%') + </if> + ) temp + </select> + + <select id="getStandardMethodCode" resultType="java.lang.String"> + select code + from standard_method + where id = #{id} + </select> + <select id="selLaboratoryCode" resultType="java.lang.String"> + select laboratory_code + from laboratory + where laboratory_name = #{laboratory} + </select> + <select id="selectReportModelByOrderId" resultType="java.util.Map"> + select distinct id, name + from standard_template + where id in (select template_id + from ins_product + where son_laboratory = #{laboratory} + and ins_sample_id in + (select id from ins_sample where ins_order_id = #{id})) + </select> + + <select id="selectCostStatistics2" resultType="com.ruoyi.inspect.dto.CostStatisticsDto"> + select * from ( + SELECT A.id, + A.entrust_code, + A.create_time, + A.sample, + A.model, + A.inspection_item, + A.company, + A.`name`, + production, + engineering, + COUNT(1) num, + SUM(A.price) price, + SUM(A.cost) cost + FROM + (SELECT + i.id, + i.entrust_code, + i.create_time, + isa.sample, + isa.sample_code, + isa.model, + c.price, + c.cost, + c.inspection_item, + i.company, + u.`name`, + i.create_user, + c.ins_sample_id, + production, + engineering + FROM + ins_order i + LEFT JOIN ins_sample isa ON isa.ins_order_id = i.id + LEFT JOIN `user` u ON u.id = i.user_id + left join custom cus on cus.id = u.company + LEFT JOIN (select SUM(b.price) price, sum(b.man_hour) cost,b.ins_sample_id, + GROUP_CONCAT(b.inspection_item2 + SEPARATOR ',') + inspection_item from (select * , + GROUP_CONCAT(CONCAT(inspection_item,'@',inspection_item_subclass) SEPARATOR ',')inspection_item2 from ins_product where state = 1 and template_id IS NOT NULL GROUP BY ins_sample_id,man_hour_group) b GROUP + BY b.ins_sample_id) c ON c.ins_sample_id = isa.id + where (i.state = 1 or i.state = 3 or i.state = 4) and c.ins_sample_id IS not NULL)A + GROUP BY + A.id, + A.entrust_code, + A.create_time, + A.sample, + A.model, + A.inspection_item, + A.company, + A.`name`, + production, + engineering + ORDER BY + A.id, + A.entrust_code, + A.create_time, + A.sample, + A.model, + A.inspection_item, + A.company, + A.`name`, + production, + engineering) B + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + + <select id="seldepLimsId" resultType="java.lang.String"> + select name + from department_lims + where id = #{depLimsId} + </select> + <select id="selectSampleBySampleId" resultType="com.ruoyi.inspect.dto.SampleProductExportDto"> + select <include refid="selectSampleProductDto2"/> + from ins_sample isa + left join ins_order i on isa.ins_order_id = i.id + left join ins_product ip on isa.id = ip.ins_sample_id + where ip.state = 1 + and ip.is_binding != 1 + and isa.id in + <foreach collection="ids" index="index" open="(" separator="," close=")" item="val"> + #{val} + </foreach> + order by ip.sort asc + </select> + <select id="selectSampleMax" resultType="java.lang.Integer"> + SELECT COUNT(*) + FROM ins_sample isa + LEFT JOIN ins_order i ON isa.ins_order_id = i.id + LEFT JOIN ins_product ip ON isa.id = ip.ins_sample_id + WHERE ip.state = 1 + AND isa.id = #{id} + GROUP BY ip.inspection_item, + ip.inspection_item_subclass, + ip.inspection_item_class + ORDER BY COUNT(*) DESC + LIMIT 1; + </select> + <select id="selectSampleCableTag" resultType="java.lang.String"> + SELECT ip.cable_tag + FROM ins_sample isa + LEFT JOIN ins_order i ON isa.ins_order_id = i.id + LEFT JOIN ins_product ip ON isa.id = ip.ins_sample_id + WHERE ip.state = 1 + AND isa.id = #{id} + and ip.cable_tag is not null + GROUP BY ip.cable_tag + order by ip.cable_tag + </select> + <select id="selectSampleItemS" resultType="java.lang.Integer"> + select count(*) + from (select distinct ip.inspection_item + from ins_sample isa + left join ins_order i on isa.ins_order_id = i.id + left join ins_product ip on isa.id = ip.ins_sample_id + where ip.state = 1 + and i.id = #{id}) a + </select> + <select id="selectSampleBySampleIdOne" resultType="com.ruoyi.inspect.dto.SampleProductExportDto"> + select <include refid="selectSampleProductDto2"/> + from ins_sample isa + left join ins_order i on isa.ins_order_id = i.id + left join ins_product ip on isa.id = ip.ins_sample_id + where ip.state = 1 + and isa.id = #{id} + and ip.raw_material_tag = 1 + order by ip.sort asc + </select> + <select id="selectCalendarWorkByWeek" resultType="java.util.Map"> + select io2.entrust_code text, + io2.type type, + ios.ins_state insState, + u.name name + from ins_order io2 + left join ins_order_state ios on ios.ins_order_id = io2.id + left join user u on u.id = io2.create_user + where DATE(io2.create_time) = CURDATE() - INTERVAL #{day} DAY + </select> + <select id="selectProductByPartNo" resultType="com.ruoyi.basic.pojo.StructureTestObject"> + select sto.id, + object_type + from product_part pp + left join product p on p.id = pp.product_id + left join structure_test_object sto on sto.id = p.object_id + where pp.part_no = #{partNo} + </select> + <select id="selectByPartNo" resultType="com.ruoyi.basic.pojo.StructureTestObject"> + select sto.id, + object_type + from structure_test_object_part stop + left join structure_test_object sto on sto.id = stop.test_object_id + where stop.part_no = #{partNo} + </select> + + <!-- 鎴愬搧鏍囩鎵撳嵃 --> + <select id="labelOrderPrinting" resultType="com.ruoyi.inspect.vo.InsOrderPrintingVo"> + select * + from (select io2.id insOrderId, + io2.sample_view, + io2.production, + io2.send_time, + GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model, + io2.prepare_user, + io2.entrust_code, + io2.test_quantity, + io2.ins_state, + JSON_OBJECT( + 'sample_name', io2.sample_view, + 'entrust_code', io2.entrust_code + ) labelBarCode + from ins_order io2 + LEFT JOIN ins_sample isa ON io2.id = isa.ins_order_id + where type_source = 0 + GROUP BY io2.id) a + where insOrderId in + <foreach collection="ids" index="index" open="(" separator="," close=")" item="val"> + #{val} + </foreach> + </select> + + <!-- 鏌ヨ妫�楠屽崟鏁版嵁 --> + <select id="rawAllInsOrderExport" resultType="com.ruoyi.inspect.dto.SampleOrderDto"> + select * + from ( + SELECT + io.*, + isau.user_id assign, + ir.id report_id, + ir.url, + ir.url_s, + sample_counts.sample_num, + CONCAT(ROUND(approved_product_counts.approved_count / total_product_counts.total_count * 100, 2), '%') AS insProgress, + io.sample_view AS sample_name, + GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model, + u.name, + testing_name, + case when io.type = 0 then '鏅��' + when io.type = 1 then '浼樺厛' + when io.type = 2 then '绱ф��' + end typeString, + case when io.ins_result = 1 then '鍚堟牸' + when io.ins_result = 0 then '涓嶅悎鏍�' + else '寰呮楠�' end insResultString + FROM + ins_order io + LEFT JOIN + ins_sample isa ON io.id = isa.ins_order_id + LEFT JOIN + ins_sample_user isau ON isau.ins_sample_id = io.id + LEFT JOIN + (SELECT id, ins_order_id, is_ratify, url, url_s FROM ins_report WHERE is_ratify = 1) ir ON io.id = ir.ins_order_id + LEFT JOIN + user u ON io.create_user = u.id + LEFT JOIN + (SELECT ins_order_id, COUNT(*) AS sample_num + FROM ins_sample + WHERE id in(select id1 from (select is2.id id1 ,ip.id from ins_sample is2 left join ins_product ip on is2.id = ip.ins_sample_id where ip.id is not null)s ) + GROUP BY ins_order_id) sample_counts ON io.id = sample_counts.ins_order_id + LEFT JOIN + (SELECT ins_sample.ins_order_id, COUNT(*) AS total_count + FROM ins_product + JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id + WHERE ins_product.state = 1 + GROUP BY ins_sample.ins_order_id) total_product_counts ON io.id = total_product_counts.ins_order_id + LEFT JOIN + (SELECT ins_sample.ins_order_id, COUNT(*) AS approved_count + FROM ins_product + JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id + WHERE ins_product.state = 1 AND ins_product.ins_result IS NOT NULL + GROUP BY ins_sample.ins_order_id) approved_product_counts ON io.id = approved_product_counts.ins_order_id + LEFT JOIN (SELECT ins_sample_id, GROUP_CONCAT(DISTINCT uu.name SEPARATOR ',') AS testing_name + FROM ins_sample_user u + LEFT JOIN user uu ON u.user_id = uu.id + WHERE u.state = 0 + GROUP BY ins_sample_id + ORDER BY ins_sample_id) isu ON isu.ins_sample_id = io.id + where (io.ifs_inventory_id IS NULL OR TRIM(io.ifs_inventory_id) = '') + <if test="isOrderAll != null and isOrderAll != ''"> + AND io.state in (1, 4) + </if> + <if test="laboratory!=null and laboratory!=''"> + AND io.laboratory=#{laboratory} + </if> + GROUP BY io.id,type + order by type desc,io.id desc + ) a + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + + <!-- 鏍规嵁璁㈠崟鏌ヨ璇曢獙瀹� --> + <select id="selectLaboratoryByOrderId" resultType="java.lang.String"> + select ip.son_laboratory + from ins_product ip + left join ins_sample is2 on is2.id = ip.ins_sample_id + where is2.ins_order_id = #{insOrderId} + limit 1 + </select> + + <select id="selectFirstSubmit" resultType="com.ruoyi.inspect.pojo.InsOrder"> + select io.id, + io.is_first_submit + from ins_order io + left join ins_sample is2 on is2.ins_order_id = io.id + where is2.id = #{insSampleId} + </select> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/InsOrderStateMapper.xml b/inspect-server/src/main/resources/mapper/InsOrderStateMapper.xml new file mode 100644 index 0000000..684e104 --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsOrderStateMapper.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ruoyi.inspect.mapper.InsOrderStateMapper"> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/InsOrderTemplateMapper.xml b/inspect-server/src/main/resources/mapper/InsOrderTemplateMapper.xml new file mode 100644 index 0000000..15d3b2c --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsOrderTemplateMapper.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ruoyi.inspect.mapper.InsOrderTemplateMapper"> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/InsProductMapper.xml b/inspect-server/src/main/resources/mapper/InsProductMapper.xml new file mode 100644 index 0000000..7d92da9 --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsProductMapper.xml @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.inspect.mapper.InsProductMapper"> + + <update id="updateInspected"> + UPDATE ins_product p + SET p.state=0 + WHERE EXISTS( + SELECT 1 + FROM ins_sample s + WHERE s.ins_order_id IN ( + SELECT o.id + FROM ins_order o + WHERE o.id = #{id} + ) + AND p.ins_sample_id = s.id + AND p.state = 1 + AND p.ins_result IS NULL + ); + </update> + + <select id="selectOrderManDay" resultType="java.lang.Integer"> + select coalesce(max(ip.man_day), 0) + from ins_order io + left join ins_sample isa on io.id = isa.ins_order_id + left join ins_product ip on isa.id = ip.ins_sample_id + where io.id = #{orderId} + </select> + <select id="selectUserById" resultType="java.util.Map"> + select account, name, company, phone, name_en + from user + where id = #{userId} + </select> + <select id="getProductAndResult" resultType="com.ruoyi.inspect.dto.ProductResultDto2"> + select ip.id, + ip.inspection_item, + ip.inspection_item_subclass, + ip.laboratory, + ip.unit, + ipr.equip_name equipValue, + io.entrust_code, + ipr.update_time, + ip.ins_result, + u.name updateUserName + from ins_product ip + left join ins_product_result ipr on ip.id = ipr.ins_product_id + left join ins_sample isa on isa.id = ip.ins_sample_id + left join ins_order io on io.id = isa.ins_order_id + left join user u on u.id = ipr.update_user + where ip.ins_sample_id = #{sampleId} + and ip.ins_result is not null + and template_id is not null + </select> + <select id="selectFiberInsProduct" resultType="com.ruoyi.inspect.pojo.InsProduct"> + select * from ins_product + where state = 1 + and is_binding != 1 + and (ins_fibers_id is not null or ins_fiber_id is not null) + and ins_result is null + and son_laboratory = #{laboratory} + and ins_sample_id in + <foreach collection="ids" index="index" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + </select> + <select id="selectNoProducts" resultType="com.ruoyi.inspect.pojo.InsProduct"> + select * + from (select ip.*, sample_code + from ins_product ip + left join ins_sample is2 on ip.ins_sample_id = is2.id + where state = 1 + and is2.ins_order_id = #{orderId} + <if test="noIds != null and noIds.size() > 0"> + and ip.id in + <foreach collection="noIds" index="index" open="(" separator="," close=")" item="val"> + #{val} + </foreach> + </if> + ) A + </select> + <select id="selectInsProductCountByOrderId" resultType="java.lang.Integer"> + select COUNT(1) + from ins_product ip + left join ins_sample isa on ip.ins_sample_id = isa.id + left join ins_order io on isa.ins_order_id = io.id + where io.id = #{orderId} + and (ip.ins_result is null or ip.ins_result = 2) + and ip.state = 1 + </select> + <select id="selectListBySampleIds" resultType="com.ruoyi.inspect.dto.SampleProductRawAnalysisDto"> + select ins.id ins_sample_id, + ins.sample_code, + ip.id ins_product_id, + concat(ip.inspection_item, ip.inspection_item_subclass) inspection_item, + ip.`last_value`, + iiq.update_batch_no, + iiq.supplier_name, + ins.sample, + ip.ins_result + from ins_product ip + left join ins_sample ins on ins.id = ip.ins_sample_id + left join ins_order io1 on io1.id = ins.ins_order_id + left join ifs_inventory_quantity iiq on iiq.id = io1.ifs_inventory_id + where ip.inspection_value_type = 1 + and ip.ins_sample_id in + <foreach collection="sampleIds" index="index" open="(" separator="," close=")" item="val"> + #{val} + </foreach> + </select> + <select id="selectItemNameBySampleIds" resultType="java.lang.String"> + select concat(ip.inspection_item, ip.inspection_item_subclass) + from ins_product ip + left join ins_sample ins on ins.id = ip.ins_sample_id + where ip.inspection_value_type = 1 + and ip.ins_sample_id in + <foreach collection="sampleIds" index="index" open="(" separator="," close=")" item="val"> + #{val} + </foreach> + + group by concat(ip.inspection_item, ip.inspection_item_subclass) + </select> + <select id="selectUnqualifiedList" resultType="java.lang.String"> + select distinct concat(ip.inspection_item_class, ip.inspection_item, ip.inspection_item_subclass) + from ins_product ip + left join ins_sample is2 on is2.id = ip.ins_sample_id + left join ins_order io2 on io2.id = is2.ins_order_id + where io2.id = #{orderId} + </select> + + <!--鏌ヨ鍒ゆ柇鏄惁鏈変笉鍒ゅ畾椤圭洰,鍜屽叏閮芥槸鍒ゅ畾椤�--> + <select id="selectNoJudge" resultType="java.lang.Integer"> + select CASE + WHEN SUM(CASE WHEN ip.ins_result = 3 THEN 1 ELSE 0 END) = COUNT(*) THEN 3 + WHEN SUM(CASE WHEN ip.ins_result = 3 THEN 1 ELSE 0 END) > 0 THEN 2 + ELSE 1 END AS result_flag + from ins_product ip + left join ins_sample is2 on is2.id = ip.ins_sample_id + left join ins_order io2 on io2.id = is2.ins_order_id + where io2.id = #{orderId} + and ip.is_binding != 1 + </select> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/InsProductUserMapper.xml b/inspect-server/src/main/resources/mapper/InsProductUserMapper.xml new file mode 100644 index 0000000..474ae59 --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsProductUserMapper.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ruoyi.inspect.mapper.InsProductUserMapper"> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/InsReportMapper.xml b/inspect-server/src/main/resources/mapper/InsReportMapper.xml new file mode 100644 index 0000000..0098974 --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsReportMapper.xml @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.inspect.mapper.InsReportMapper"> + + <select id="pageInsReport" resultType="com.ruoyi.inspect.dto.ReportPageDto"> + select * + from ( + select + ir.*, + io.entrust_code, + u.name write_user_name, + u1.name ratify_user, + u2.name examine_user, + io.type_source, + io.order_type, + io.laboratory, + io.ifs_inventory_id, + iiq.is_copper, + ip.son_laboratory + from ins_report ir + left join ins_order io on io.id = ir.ins_order_id + LEFT JOIN ifs_inventory_quantity iiq ON iiq.id = io.ifs_inventory_id + left join user u on u.id = ir.write_user_id + left join user u1 on u1.id = ir.ratify_user_id + left join user u2 on u2.id = ir.examine_user_id + left join ins_sample is2 on is2.ins_order_id = io.id + left join ins_product ip on ip.ins_sample_id = is2.id + where 1=1 + and ir.is_pass = 1 + <if test="createOrderUser != null and createOrderUser != ''"> + and (ir.write_user_id = #{createOrderUser} or ir.examine_user_id = #{createOrderUser} or ir.ratify_user_id = #{createOrderUser}) + </if> + <if test="laboratory!=null and laboratory!=''"> + and laboratory=#{laboratory} + </if> + <if test="queryStatus != null and queryStatus != ''"> + <!-- 寰呮彁浜�--> + <if test='queryStatus == 0'> + and ir.state = 0 + </if> + <!-- 寰呭鎵�--> + <if test='queryStatus == 1'> + and ir.state = 1 and (ir.is_examine != 1 or ir.is_examine is null) + </if> + <!-- 寰呮壒鍑�--> + <if test='queryStatus == 2'> + and ir.state = 1 and ir.is_examine = 1 and (ir.is_ratify != 1 or ir.is_ratify is null) + </if> + </if> + group by ir.id + ) a + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + <select id="getLaboratoryByName" resultType="java.lang.String"> + select s.address from seal s + left join laboratory l on s.lab_id = l.id + where l.laboratory_name = #{name} + and s.type = #{type} + order by s.create_time desc + limit 1 + </select> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml new file mode 100644 index 0000000..2f7423d --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml @@ -0,0 +1,699 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.inspect.mapper.InsSampleMapper"> + + <resultMap id="sampleDto" type="com.ruoyi.inspect.dto.SampleProductDto"> + <id property="id" column="id" jdbcType="INTEGER"/> + <result property="insResult" column="ins_result" jdbcType="INTEGER"/> + <result property="insOrderId" column="ins_order_id" jdbcType="INTEGER"/> + <result property="joinModel" column="join_model" jdbcType="VARCHAR"/> + <result property="joinName" column="join_name" jdbcType="VARCHAR"/> + <result property="sampleCode" column="sample_code" jdbcType="VARCHAR"/> + <result property="factory" column="factory" jdbcType="VARCHAR"/> + <result property="laboratory" column="laboratory" jdbcType="VARCHAR"/> + <result property="sampleType" column="sample_type" jdbcType="VARCHAR"/> + <result property="sample" column="sample" jdbcType="VARCHAR"/> + <result property="model" column="model" jdbcType="VARCHAR"/> + <result property="insState" column="ins_state" jdbcType="INTEGER"/> + <result property="joinNum" column="join_num" jdbcType="INTEGER"/> + <result property="remark" column="remark" jdbcType="VARCHAR"/> + <result property="createUser" column="create_user" jdbcType="INTEGER"/> + <result property="updateUser" column="update_user" jdbcType="INTEGER"/> + <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> + <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> + <result property="standardMethodListId" column="standard_method_list_id"/> + <result property="unit" column="unit"/> + <result property="quantity" column="quantity"/> + <result property="specialStandardMethod" column="special_standard_method"/> + <collection property="insProduct" resultMap="product"/> + </resultMap> + + <resultMap id="product" type="com.ruoyi.inspect.pojo.InsProduct"> + <id property="id" column="ip_id" jdbcType="INTEGER"/> + <result property="inspectionItem" column="inspection_item" jdbcType="VARCHAR"/> + <result property="inspectionItemEn" column="inspection_item_en" jdbcType="VARCHAR"/> + <result property="inspectionItemSubclass" column="inspection_item_subclass" jdbcType="VARCHAR"/> + <result property="inspectionItemSubclassEn" column="inspection_item_subclass_en" jdbcType="VARCHAR"/> + <result property="inspectionItemClass" column="inspection_item_class" jdbcType="VARCHAR"/> + <result property="inspectionItemClassEn" column="inspection_item_class_en" jdbcType="VARCHAR"/> + <result property="factory" column="ip_factory" jdbcType="VARCHAR"/> + <result property="laboratory" column="ip_laboratory" jdbcType="VARCHAR"/> + <result property="sampleType" column="ip_sample_type" jdbcType="VARCHAR"/> + <result property="sample" column="ip_sample" jdbcType="VARCHAR"/> + <result property="model" column="ip_model" jdbcType="VARCHAR"/> + <result property="sonLaboratory" column="son_laboratory" jdbcType="VARCHAR"/> + <result property="unit" column="ip_unit" jdbcType="VARCHAR"/> + <result property="price" column="price" jdbcType="DECIMAL"/> + <result property="manHour" column="man_hour" jdbcType="DOUBLE"/> + <result property="manHourGroup" column="man_hour_group" jdbcType="VARCHAR"/> + <result property="inspectionItemType" column="inspection_item_type" jdbcType="VARCHAR"/> + <result property="inspectionValueType" column="inspection_value_type" jdbcType="VARCHAR"/> + <result property="deviceGroup" column="device_group" jdbcType="VARCHAR"/> + <result property="checkoutNumber" column="checkout_number" jdbcType="INTEGER"/> + <result property="section" column="section" jdbcType="VARCHAR"/> + <result property="valueType" column="value_type" jdbcType="VARCHAR"/> + <result property="method" column="method" jdbcType="VARCHAR"/> + <result property="manDay" column="man_day" jdbcType="INTEGER"/> + <result property="bsm" column="bsm" jdbcType="VARCHAR"/> + <result property="ask" column="ask" jdbcType="VARCHAR"/> + <result property="tell" column="tell" jdbcType="VARCHAR"/> + <result property="lastValue" column="last_value" jdbcType="VARCHAR"/> + <result property="insResult" column="ip_ins_result" jdbcType="INTEGER"/> + <result property="state" column="state" jdbcType="INTEGER"/> + <result property="insBushId" column="ins_bush_id" jdbcType="INTEGER"/> + <result property="insSampleId" column="ins_sample_id" jdbcType="INTEGER"/> + <result property="createUser" column="ip_create_user" jdbcType="INTEGER"/> + <result property="updateUser" column="ip_update_user" jdbcType="INTEGER"/> + <result property="createTime" column="ip_create_time" jdbcType="TIMESTAMP"/> + <result property="updateTime" column="ip_update_time" jdbcType="TIMESTAMP"/> + <result property="templateId" column="template_id" jdbcType="INTEGER"/> + <result property="methodS" column="method_s"/> + <result property="tell" column="tell"/> + <result property="dic" column="dic"/> + <result property="sort" column="sort"/> + <result property="temperature" column="temperature"/> + <result property="humidity" column="humidity"/> + <result property="radius" column="radius"/> + <result property="cableTag" column="cable_tag"/> + <result property="structureItemParameterId" column="structure_item_parameter_id"/> + <collection property="insProductResult" resultMap="insProductResult"/> + </resultMap> + + + <resultMap id="insProductResult" type="com.ruoyi.inspect.pojo.InsProductResult"> + <result property="insValue" column="ins_value" jdbcType="VARCHAR"/> + <result property="comValue" column="com_value" jdbcType="VARCHAR"/> + <result property="equipValue" column="equip_value" jdbcType="VARCHAR"/> + <result property="equipName" column="equip_name" jdbcType="VARBINARY"/> + </resultMap> + + <resultMap id="sampleVo" type="com.ruoyi.inspect.vo.SampleVo"> + <id property="id" column="id" jdbcType="INTEGER"/> + <result property="insResult" column="ins_result" jdbcType="INTEGER"/> + <result property="insOrderId" column="ins_order_id" jdbcType="INTEGER"/> + <result property="joinModel" column="join_model" jdbcType="VARCHAR"/> + <result property="joinName" column="join_name" jdbcType="VARCHAR"/> + <result property="sampleCode" column="sample_code" jdbcType="VARCHAR"/> + <result property="factory" column="factory" jdbcType="VARCHAR"/> + <result property="laboratory" column="laboratory" jdbcType="VARCHAR"/> + <result property="sampleType" column="sample_type" jdbcType="VARCHAR"/> + <result property="sample" column="sample" jdbcType="VARCHAR"/> + <result property="model" column="model" jdbcType="VARCHAR"/> + <result property="insState" column="ins_state" jdbcType="INTEGER"/> + <result property="joinNum" column="join_num" jdbcType="INTEGER"/> + <result property="remark" column="remark" jdbcType="VARCHAR"/> + <result property="createUser" column="create_user" jdbcType="INTEGER"/> + <result property="updateUser" column="update_user" jdbcType="INTEGER"/> + <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> + <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> + <result property="standardMethodListId" column="standard_method_list_id"/> + <result property="methodName" column="methodName" jdbcType="VARCHAR"/> + <result property="unit" column="unit"/> + </resultMap> + + <sql id="getInsProducSql"> + ip.id ip_id, + inspection_item, + inspection_item_en, + inspection_item_class, + inspection_item_class_en, + inspection_item_subclass, + inspection_item_subclass_en, + ip.factory ip_factory, + ip.laboratory ip_laboratory, + ip.sample_type ip_sample_type, + ip.sample ip_sample, + ip.model ip_model, + son_laboratory, + ip.unit ip_unit, + price, + man_hour, + man_hour_group, + inspection_item_type, + inspection_value_type, + device_group, + checkout_number, + section, + value_type, + method, + man_day, + bsm, + ask, + `last_value`, + ip.ins_result ip_ins_result, + state, + ins_sample_id, + ip.create_user ip_create_user, + ip.update_user ip_update_user, + ip.create_time ip_create_time, + ip.update_time ip_update_time, + template_id, + ipr.ins_value, + ipr.com_value, + ipr.equip_value, + ipr.equip_name, + ip.method_s, + ip.tell, + ip.dic, + ip.sort, + ip.cable_tag, + ip.structure_item_parameter_id + </sql> + + + <select id="findInsSampleAndOrder" resultType="com.ruoyi.inspect.vo.InsOrderPlanVO"> + select * from(select * from( + SELECT + a.*,ios.ins_state,ios.verify_tell,verify_user + FROM + ( + SELECT + io.id, + io.entrust_code, + io.type, + io.appointed, + io.send_time, + io.order_type, + case when + io.type_source = 0 + then io.sample_view + else io.sample end sample, + GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model, + userName, + checkName, + ip.son_laboratory, + io.ins_time, + io.laboratory, + io.type_source, + io.ifs_inventory_id, + ira.id ins_report_id, + ira.url, + ira.url_s, + ira.temp_url_pdf, + iiq.is_copper + FROM + ins_order io + LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id + LEFT JOIN ins_report ira ON ira.ins_order_id = io.id + LEFT JOIN ifs_inventory_quantity iiq ON iiq.id = io.ifs_inventory_id + LEFT JOIN ( + SELECT ins_sample_id,GROUP_CONCAT( DISTINCT uu.name SEPARATOR ',') AS userName + FROM ins_sample_user u LEFT JOIN user uu ON u.user_id = uu.id + WHERE u.state=0 + <if test="sonLaboratory!= null and sonLaboratory != ''"> + and son_laboratory=#{sonLaboratory} + </if> + GROUP BY ins_sample_id + ORDER BY ins_sample_id + ) isu ON isu.ins_sample_id = io.id + LEFT JOIN ( + SELECT ins_sample_id,uu.name checkName + FROM ins_sample_user u LEFT JOIN user uu ON u.user_id = uu.id + WHERE u.state=1 + <if test="sonLaboratory!= null and sonLaboratory != ''"> + and son_laboratory=#{sonLaboratory} + </if> + GROUP BY ins_sample_id + ORDER BY ins_sample_id + )isu2 ON isu2.ins_sample_id = io.id + LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id + WHERE io.state = 1 and send_time is not null + <if test="isCheck != null"> + <if test="userName !=null and userName!=''"> + and checkName like CONCAT ('%', #{userName},'%') + </if> + </if> + <if test="isCheck == null"> + <if test="userName !=null and userName!=''"> + and userName like CONCAT ('%', #{userName},'%') + </if> + </if> + <if test="sonLaboratory!= null and sonLaboratory != ''"> + and ip.son_laboratory = #{sonLaboratory} + </if> + GROUP BY + ip.son_laboratory, + io.id + ) a + LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory + ORDER BY + a.type DESC, + a.id + ) b + where ins_state is not null + <if test="laboratory!=null and laboratory!=''"> + and laboratory=#{laboratory} + </if> + )A + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + + <select id="inspectionOrderDetailsTaskSwitching" resultType="com.ruoyi.inspect.vo.InsOrderPlanTaskSwitchVo"> + select * from( + SELECT + a.*,ios.ins_state,ios.verify_tell,isu2.order_user_id,<!--(ios.verify_user = #{userId})--> verify_user + FROM + ( + SELECT + io.id, + io.entrust_code, + io.type, + io.appointed, + io.send_time, + group_concat(distinct isa.sample,' ') sampleType, + isu.user_id, + user.name userName, + ip.son_laboratory, + io.ins_time, + io.laboratory + FROM + ins_order io + LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id + LEFT JOIN ( <!--SELECT * FROM ins_sample_user GROUP BY ins_sample_id, user_id --> + SELECT * + FROM ins_sample_user u + WHERE son_laboratory=#{sonLaboratory} and (ins_sample_id, id) IN ( + SELECT ins_sample_id, MAX(id) + FROM ins_sample_user + WHERE son_laboratory=#{sonLaboratory} + GROUP BY ins_sample_id + ) + ORDER BY ins_sample_id, id + ) isu ON isu.ins_sample_id = io.id + LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id + LEFT JOIN user ON isu.user_id = user.id + WHERE + io.state = 1 +-- # AND io.ins_state != 5 + and send_time is not null + <if test="userId !=null and userId!=''"> + and (isu.user_id = #{userId} OR isu.user_id is NULL ) + </if> + OR isu.user_id is NULL + GROUP BY + ip.son_laboratory, + io.id + ) a + LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory + left join (SELECT td.user_id order_user_id, td.ins_sample_id FROM ins_sample_user td,(SELECT max(id) id FROM + ins_sample_user where son_laboratory=#{sonLaboratory} GROUP BY ins_sample_id) md where td.id = md.id + <if test="userId !=null and userId!=''"> + and user_id = #{userId} OR user_id is NULL + </if> + OR user_id is NULL + ) isu2 on + isu2.ins_sample_id = a.id + where ins_state is not null + <if test="laboratory != null and laboratory != ''"> + and a.laboratory=#{laboratory} + </if> + ORDER BY + <!--a.user_id DESC,--> + a.type DESC, + a.id + ) b + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + + <select id="selectSampleProductListByOrderId" resultMap="sampleDto"> + select isa.*, + ip.id ip_id, + inspection_item, + inspection_item_en, + inspection_item_class, + inspection_item_class_en, + inspection_item_subclass, + inspection_item_subclass_en, + ip.factory ip_factory, + ip.laboratory ip_laboratory, + ip.sample_type ip_sample_type, + ip.sample ip_sample, + ip.model ip_model, + son_laboratory, + ip.unit ip_unit, + price, + man_hour, + man_hour_group, + inspection_item_type, + inspection_value_type, + device_group, + checkout_number, + section, + value_type, + method, + man_day, + bsm, + ask, + tell, + `last_value`, + ip.ins_result ip_ins_result, + state, + ins_sample_id, + ip.create_user ip_create_user, + ip.update_user ip_update_user, + ip.create_time ip_create_time, + ip.update_time ip_update_time, + template_id, + ipr.ins_value, + ipr.com_value, + ipr.equip_value, + ip.method_s + from ins_sample isa + left join ins_product ip on isa.id = ip.ins_sample_id + left join ins_product_result ipr on ip.id = ipr.ins_product_id + where ins_order_id = #{id} + and state = 1 +-- and ins_fiber_id is null +-- and ins_fibers_id is null + and <!--isa.sample_code NOT REGEXP '/'--> + isa.id in(select id1 from (select is2.id id1 ,ip.id from ins_sample is2 left join ins_product ip on is2.id = ip.ins_sample_id where ip.id is not null)s ) + order by ip.sort asc, + case when man_hour_group is NULL then 1 + when man_hour_group ='' then 1 else 0 end, + CASE + WHEN man_hour_group REGEXP '^[0-9]' THEN CAST(man_hour_group AS UNSIGNED) -- 濡傛灉浠ユ暟瀛楀紑澶达紝鍒欐寜鐓ф暟瀛楀ぇ灏忔帓搴� + WHEN man_hour_group REGEXP '[0-9]+' THEN CAST(SUBSTRING(man_hour_group, 2)AS UNSIGNED) END -- 鎻愬彇瀛楁瘝鍚庨潰鐨勬暟瀛楅儴鍒� + ,id asc + </select> + <select id="getInsOrderAndSample" resultMap="sampleDto"> + select isa.*, + ip.id ip_id, + inspection_item, + inspection_item_en, + inspection_item_class, + inspection_item_class_en, + inspection_item_subclass, + inspection_item_subclass_en, + ip.factory ip_factory, + ip.laboratory ip_laboratory, + ip.sample_type ip_sample_type, + ip.sample ip_sample, + ip.model ip_model, + son_laboratory, + ip.unit ip_unit, + price, + man_hour, + man_hour_group, + inspection_item_type, + inspection_value_type, + device_group, + checkout_number, + section, + value_type, + method, + man_day, + bsm, + ask, + `last_value`, + ip.ins_result ip_ins_result, + state, + ins_sample_id, + ip.create_user ip_create_user, + ip.update_user ip_update_user, + ip.create_time ip_create_time, + ip.update_time ip_update_time, + template_id, + ipr.ins_value, + ipr.com_value, + ipr.equip_value, + ipr.equip_name, + ip.method_s, + ip.tell, + ip.dic, + ip.temperature, + ip.humidity + from ins_sample isa + left join ins_product ip on isa.id = ip.ins_sample_id + left join ins_product_result ipr on ip.id = ipr.ins_product_id + where ins_order_id = #{id} + and state = 1 + and ip.son_laboratory = #{laboratory} + </select> + <select id="getSampleEn" resultType="java.lang.String"> + select name_en + from product + where name = #{sample} + limit 1 + </select> + <select id="getSampleEnByObject" resultType="java.lang.String"> + select specimen_name_en + from structure_test_object + where specimen_name = #{sample} + limit 1 + </select> + <select id="selectInsOrder" resultType="map"> + SELECT + ifs.order_no AS orderNo, + ifs.supplier_id AS supplierId, + ifs.supplier_name AS supplierName, + ifs.part_no AS partNo, + ifs.qty_arrived AS qtyArrived, + ifs.receiver_date AS receiverDate, + ifs.update_batch_no AS updateBatchNo, + ifs.part_desc AS partDesc, + io.send_time AS sendTime, + ifs.declare_user declareUser, + ifs.id inventoryQuantityId, + ifs.buy_unit_meas buyUnitMeas, + io.test_quantity testQuantity, + ifs.buy_unit_meas buyUnitMeas + FROM + ifs_inventory_quantity ifs + LEFT JOIN ins_order io ON ifs.id = io.ifs_inventory_id + WHERE + io.id = #{id} + </select> + <select id="selectSampleProductListByOrderId2" resultMap="sampleDto"> + select isa.*, + ip.id ip_id, + inspection_item, + inspection_item_en, + inspection_item_subclass, + inspection_item_subclass_en, + inspection_item_class, + inspection_item_class_en, + ip.factory ip_factory, + ip.laboratory ip_laboratory, + ip.sample_type ip_sample_type, + ip.sample ip_sample, + ip.model ip_model, + son_laboratory, + ip.unit ip_unit, + price, + man_hour, + man_hour_group, + inspection_item_type, + inspection_value_type, + device_group, + checkout_number, + section, + value_type, + method, + man_day, + bsm, + ask, + tell, + `last_value`, + ip.ins_result ip_ins_result, + state, + ins_sample_id, + ip.create_user ip_create_user, + ip.update_user ip_update_user, + ip.create_time ip_create_time, + ip.update_time ip_update_time, + template_id, + ipr.ins_value, + ipr.com_value, + ipr.equip_value, + ip.method_s, + ip.radius, + isa.special_standard_method + from ins_sample isa + left join ins_product ip on isa.id = ip.ins_sample_id + left join ins_product_result ipr on ip.id = ipr.ins_product_id + where ins_order_id = #{id} + and ip.standard_method_list_id is not null + and state = 1 + and ip.is_binding != 1 + order by ip.sort asc, + case when man_hour_group is NULL then 1 + when man_hour_group ='' then 1 else 0 end, + CASE + WHEN man_hour_group REGEXP '^[0-9]' THEN CAST(man_hour_group AS UNSIGNED) -- 濡傛灉浠ユ暟瀛楀紑澶达紝鍒欐寜鐓ф暟瀛楀ぇ灏忔帓搴� + WHEN man_hour_group REGEXP '[0-9]+' THEN CAST(SUBSTRING(man_hour_group, 2)AS UNSIGNED) END -- 鎻愬彇瀛楁瘝鍚庨潰鐨勬暟瀛楅儴鍒� + ,id asc + </select> + + <select id="getInsProduct1" resultMap="product"> + select <include refid="getInsProducSql"/> + from ins_product ip + left join ins_product_result ipr on ip.id = ipr.ins_product_id + where ins_sample_id = #{id} + and state = 1 + and ip.son_laboratory = #{laboratory} + and ins_fiber_id is null + and ins_fibers_id is null + and standard_method_list_id is not null + /* 鐢电紗閰嶇疆鏍囪瘑 */ + <if test="cableTag == null or cableTag == ''"> + and ip.cable_tag is null + </if> + <if test="cableTag != null and cableTag != ''"> + and ip.cable_tag = #{cableTag} + </if> + /* 閲嶅鍊兼爣璇� */ + <if test="repetitionTag == null or repetitionTag == ''"> + and ip.repetition_tag is null + </if> + <if test="repetitionTag != null and repetitionTag != ''"> + and ip.repetition_tag = #{repetitionTag} + </if> + <if test="isDisqualification != null and isDisqualification != ''"> + and ip.ins_result = 0 + </if> + order by sort asc + </select> + + <select id="getInsProduct6" resultMap="product"> + select <include refid="getInsProducSql"/> + from ins_product ip + left join ins_product_result ipr on ip.id = ipr.ins_product_id + where ins_sample_id = #{id} + and state = 1 + and ip.son_laboratory = #{laboratory} + and ins_fiber_id is null + and ins_fibers_id is null + and standard_method_list_id is not null + and ip.raw_material_tag = #{rawMaterialTag} + <if test="isDisqualification != null and isDisqualification != ''"> + and ip.ins_result = 0 + </if> + order by sort asc + </select> + + <select id="getDetailById" resultMap="sampleVo"> + select is2.*, + code methodName + from ins_sample is2 + inner join standard_method sm on standard_method_list_id = sm.id + where is2.id = #{sampleId} + </select> + + <select id="selMethodById" resultType="java.lang.String"> + select code + from standard_method + where id = (select standard_method_list_id from ins_sample where id = #{sampleId}) + </select> + + <!-- 鏌ョ湅鐢电紗閰嶇疆鏍囪瘑 --> + <select id="getCableTag" resultType="java.util.Map"> + select ip.cable_tag cableTag, + CASE + WHEN COUNT(ip.last_value) = 0 THEN '0' + WHEN COUNT(CASE WHEN ip.last_value = '' OR ip.last_value IS NULL THEN 1 END) = 0 THEN '2' + ELSE '2' + END AS status + from ins_product ip + where ins_sample_id = #{id} + and state = 1 + and ip.son_laboratory = #{laboratory} + and ins_fiber_id is null + and ins_fibers_id is null + and standard_method_list_id is not null + and ip.cable_tag is not null + group by ip.cable_tag + </select> + + <!-- 鍘熸潗鏂欐煡鐪嬮厤缃爣璇� --> + <select id="getRawMaterialTag" resultType="java.util.Map"> + select ip.raw_material_tag rawMaterialTag, + CASE + WHEN COUNT(ip.last_value) = 0 THEN '0' + WHEN COUNT(CASE WHEN ip.last_value = '' OR ip.last_value IS NULL THEN 1 END) = 0 THEN '2' + ELSE '1' + END AS status + from ins_product ip + where ins_sample_id = #{id} + and state = 1 + and ip.son_laboratory = #{laboratory} + and ins_fiber_id is null + and ins_fibers_id is null + and standard_method_list_id is not null + and ip.raw_material_tag is not null + group by ip.raw_material_tag + </select> + + <!-- 鏌ョ湅閲嶅鏍囪瘑 --> + <select id="getRepetitionTag" resultType="java.util.Map"> + select ip.repetition_tag repetitionTag, + CASE + WHEN COUNT(ip.last_value) = 0 THEN '0' + WHEN COUNT(CASE WHEN ip.last_value = '' OR ip.last_value IS NULL THEN 1 END) = 0 THEN '2' + ELSE '1' + END AS status, + GROUP_CONCAT(DISTINCT ip.radius SEPARATOR '锛�') AS radius + from ins_product ip + where ins_sample_id = #{id} + and state = 1 + and ip.son_laboratory = #{laboratory} + and ins_fiber_id is null + and ins_fibers_id is null + and standard_method_list_id is not null + and ip.repetition_tag is not null + /* 鐢电紗閰嶇疆鏍囪瘑 */ + <if test="cableTag == null or cableTag == ''"> + and ip.cable_tag is null + </if> + <if test="cableTag != null and cableTag != ''"> + and ip.cable_tag = #{cableTag} + </if> + group by ip.repetition_tag + </select> + + <select id="selectExemptionByOrderId" resultType="com.ruoyi.inspect.dto.SampleProductDto"> + select * + from ins_sample + where ins_order_id = #{id} + </select> + <select id="selectSupplierDensityModel" resultType="java.lang.String"> + select psd.density_value densityValue + from product_supplier_density psd + where psd.product_id = (select id + from product + where name = #{sample} + limit 1) + and psd.supplier_name = #{production} + and psd.model = #{model} + limit 1 + </select> + <select id="selectSupplierDensity" resultType="java.lang.String"> + select psd.density_value densityValue + from product_supplier_density psd + where psd.product_id = (select id + from product + where name = #{sample} + limit 1) + and psd.supplier_name = #{production} + and (psd.model = '' or psd.model is null) + limit 1 + </select> + + <!-- 鏌ヨ妫�楠岄」妫�楠岀粨鏋� --> + <select id="selectProductResult" resultMap="product"> + select <include refid="getInsProducSql"/> + from ins_product ip + left join ins_product_result ipr on ip.id = ipr.ins_product_id + where ip.id in + <foreach collection="itemIds" index="index" open="(" separator="," close=")" item="val"> + #{val} + </foreach> + order by ip.sort asc + </select> + +</mapper> diff --git a/inspect-server/src/main/resources/mapper/InsSampleUserMapper.xml b/inspect-server/src/main/resources/mapper/InsSampleUserMapper.xml new file mode 100644 index 0000000..5cad2d2 --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsSampleUserMapper.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ruoyi.inspect.mapper.InsSampleUserMapper"> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/InsUnqualifiedHandlerMapper.xml b/inspect-server/src/main/resources/mapper/InsUnqualifiedHandlerMapper.xml new file mode 100644 index 0000000..fdeb4af --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsUnqualifiedHandlerMapper.xml @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.inspect.mapper.InsUnqualifiedHandlerMapper"> + + <sql id="Base_Column_List"> + id,no,supplier_name, + material_name,production_batch,cargo_quantity, + specs_models,inspect_time,feedback_user, + feedback_time,classification,off_grade_ascription, + unqualified_desc,inventory_quantity_id + </sql> + <select id="selectPageList" resultType="com.ruoyi.inspect.vo.UnqualifiedHandlerVO"> + select * from (select + iiq.*, + iuh.id as handler_id, + iuh.no, + iuh.material_name, + iuh.production_batch, + iuh.cargo_quantity, + iuh.specs_models, + iuh.inspect_time, + iuh.feedback_user, + iuh.feedback_time, + iuh.classification, + iuh.off_grade_ascription, + iuh.unqualified_desc, + iuh.inventory_quantity_id, + iuh.oa_state, + iuh.request_id, + iuh.file_url, + iuh.headline + from + ins_unqualified_handler iuh + inner join + ifs_inventory_quantity iiq + on + iuh.inventory_quantity_id = iiq.id)tempA + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> + <select id="findById" resultType="com.ruoyi.inspect.vo.UnqualifiedHandlerVO"> + select * from (select + iiq.*, + iuh.id as handler_id, + iuh.no, + iuh.headline, + iuh.material_name, + iuh.production_batch, + iuh.cargo_quantity, + iuh.specs_models, + iuh.inspect_time, + iuh.feedback_user, + iuh.feedback_time, + iuh.classification, + iuh.off_grade_ascription, + iuh.unqualified_desc, + iuh.inventory_quantity_id, + iuh.request_id, + iuh.oa_state, + iuh.file_url + from + ins_unqualified_handler iuh + inner join + ifs_inventory_quantity iiq + on + iuh.inventory_quantity_id = iiq.id)tempA + where tempA.handler_id = #{id} + </select> + <select id="getOaFlow" resultType="com.ruoyi.inspect.pojo.CommonOa"> + select co.id, + co.node_name, + co.operation, + co.approver, + co.approval_date, + co.approval_time, + co.approval_opinion, + co.workflow_id + from common_oa co + left join ins_unqualified_handler iuh on iuh.request_id = co.workflow_id + where iuh.id = #{id} + and operation != '鎶勯��' + group by co.node_name + </select> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/InsUnqualifiedRetestProductMapper.xml b/inspect-server/src/main/resources/mapper/InsUnqualifiedRetestProductMapper.xml new file mode 100644 index 0000000..4be6b91 --- /dev/null +++ b/inspect-server/src/main/resources/mapper/InsUnqualifiedRetestProductMapper.xml @@ -0,0 +1,200 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ruoyi.inspect.mapper.InsUnqualifiedRetestProductMapper"> + <resultMap id="product" type="com.ruoyi.inspect.pojo.InsProduct"> + <id property="id" column="ip_id" jdbcType="INTEGER"/> + <result property="inspectionItem" column="inspection_item" jdbcType="VARCHAR"/> + <result property="inspectionItemEn" column="inspection_item_en" jdbcType="VARCHAR"/> + <result property="inspectionItemSubclass" column="inspection_item_subclass" jdbcType="VARCHAR"/> + <result property="inspectionItemSubclassEn" column="inspection_item_subclass_en" jdbcType="VARCHAR"/> + <result property="inspectionItemClass" column="inspection_item_class" jdbcType="VARCHAR"/> + <result property="inspectionItemClassEn" column="inspection_item_class_en" jdbcType="VARCHAR"/> + <result property="factory" column="ip_factory" jdbcType="VARCHAR"/> + <result property="laboratory" column="ip_laboratory" jdbcType="VARCHAR"/> + <result property="sampleType" column="ip_sample_type" jdbcType="VARCHAR"/> + <result property="sample" column="ip_sample" jdbcType="VARCHAR"/> + <result property="model" column="ip_model" jdbcType="VARCHAR"/> + <result property="sonLaboratory" column="son_laboratory" jdbcType="VARCHAR"/> + <result property="unit" column="ip_unit" jdbcType="VARCHAR"/> + <result property="price" column="price" jdbcType="DECIMAL"/> + <result property="manHour" column="man_hour" jdbcType="DOUBLE"/> + <result property="manHourGroup" column="man_hour_group" jdbcType="VARCHAR"/> + <result property="inspectionItemType" column="inspection_item_type" jdbcType="VARCHAR"/> + <result property="inspectionValueType" column="inspection_value_type" jdbcType="VARCHAR"/> + <result property="deviceGroup" column="device_group" jdbcType="VARCHAR"/> + <result property="checkoutNumber" column="checkout_number" jdbcType="INTEGER"/> + <result property="section" column="section" jdbcType="VARCHAR"/> + <result property="valueType" column="value_type" jdbcType="VARCHAR"/> + <result property="method" column="method" jdbcType="VARCHAR"/> + <result property="manDay" column="man_day" jdbcType="INTEGER"/> + <result property="bsm" column="bsm" jdbcType="VARCHAR"/> + <result property="ask" column="ask" jdbcType="VARCHAR"/> + <result property="tell" column="tell" jdbcType="VARCHAR"/> + <result property="lastValue" column="last_value" jdbcType="VARCHAR"/> + <result property="insResult" column="ip_ins_result" jdbcType="INTEGER"/> + <result property="state" column="state" jdbcType="INTEGER"/> + <result property="insBushId" column="ins_bush_id" jdbcType="INTEGER"/> + <result property="insSampleId" column="ins_sample_id" jdbcType="INTEGER"/> + <result property="createUser" column="ip_create_user" jdbcType="INTEGER"/> + <result property="updateUser" column="ip_update_user" jdbcType="INTEGER"/> + <result property="createTime" column="ip_create_time" jdbcType="TIMESTAMP"/> + <result property="updateTime" column="ip_update_time" jdbcType="TIMESTAMP"/> + <result property="templateId" column="template_id" jdbcType="INTEGER"/> + <result property="methodS" column="method_s"/> + <result property="tell" column="tell"/> + <result property="dic" column="dic"/> + <result property="temperature" column="temperature"/> + <result property="humidity" column="humidity"/> + <result property="cableTag" column="cable_tag"/> + <collection property="insProductResult" resultMap="insProductResult"/> + </resultMap> + + <resultMap id="insProductResult" type="com.ruoyi.inspect.pojo.InsProductResult"> + <result property="insValue" column="ins_value" jdbcType="VARCHAR"/> + <result property="comValue" column="com_value" jdbcType="VARCHAR"/> + <result property="equipValue" column="equip_value" jdbcType="VARCHAR"/> + <result property="equipName" column="equip_name" jdbcType="VARBINARY"/> + </resultMap> + + <sql id="getInsProducSql"> + ip.id ip_id, + inspection_item, + inspection_item_en, + inspection_item_class, + inspection_item_class_en, + inspection_item_subclass, + inspection_item_subclass_en, + ip.factory ip_factory, + ip.laboratory ip_laboratory, + ip.sample_type ip_sample_type, + ip.sample ip_sample, + ip.model ip_model, + son_laboratory, + ip.unit ip_unit, + price, + man_hour, + man_hour_group, + inspection_item_type, + inspection_value_type, + device_group, + checkout_number, + section, + value_type, + method, + man_day, + bsm, + ask, + `last_value`, + ip.ins_result ip_ins_result, + state, + ins_sample_id, + ip.create_user ip_create_user, + ip.update_user ip_update_user, + ip.create_time ip_create_time, + ip.update_time ip_update_time, + template_id, + ipr.ins_value, + ipr.com_value, + ipr.equip_value, + ipr.equip_name, + ip.method_s, + ip.tell, + ip.dic, + ip.cable_tag + </sql> + + <select id="selectRetestProduct" resultType="com.ruoyi.inspect.pojo.InsUnqualifiedRetestProduct"> + select id ins_product_id, + inspection_item, + inspection_item_subclass, + factory, + laboratory, + sample_type, + sample, + model, + son_laboratory, + unit, + price, + man_hour, + man_hour_group, + '0' inspection_item_type, + inspection_value_type, + device_group, + checkout_number, + section, + value_type, + method, + man_day, + bsm, + ask, + tell, + state, + ins_sample_id, + create_user, + update_user, + create_time, + update_time, + template_id, + dic, + method_s, + ins_fiber_id, + ins_fibers_id, + inspection_item_en, + inspection_item_subclass_en, + inspection_item_class, + inspection_item_class_en, + standard_method_list_id, + temperature, + humidity, + ins_bush_id, + radius, + cable_tag, + raw_material_tag, + sort, + '1' retest_tag + from ins_product + where id in + <foreach collection="ids" index="index" open="(" separator="," close=")" item="val"> + #{val} + </foreach> + </select> + <select id="getInsProductUnqualifiedRetest1" resultMap="product"> + select <include refid="getInsProducSql"/> + from ins_unqualified_retest_product ip + left join ins_unqualified_retest_result ipr on ip.id = ipr.retest_product_id + where ins_sample_id = #{id} + and state = 1 + and ip.son_laboratory = #{laboratory} + and ins_fiber_id is null + and ins_fibers_id is null + and standard_method_list_id is not null + and ip.cable_tag is null + and ip.retest_tag = #{retestTag} + </select> + <select id="getInsProductUnqualifiedRetest5" resultMap="product"> + select <include refid="getInsProducSql"/> + from ins_unqualified_retest_product ip + left join ins_unqualified_retest_result ipr on ip.id = ipr.retest_product_id + where ins_sample_id = #{id} + and state = 1 + and ip.son_laboratory = #{laboratory} + and ins_fiber_id is null + and ins_fibers_id is null + and standard_method_list_id is not null + and ip.cable_tag = #{cableTag} + and ip.retest_tag = #{retestTag} + </select> + <select id="getInsProductUnqualifiedRetest6" resultMap="product"> + select <include refid="getInsProducSql"/> + from ins_unqualified_retest_product ip + left join ins_unqualified_retest_result ipr on ip.id = ipr.retest_product_id + where ins_sample_id = #{id} + and state = 1 + and ip.son_laboratory = #{laboratory} + and ins_fiber_id is null + and ins_fibers_id is null + and standard_method_list_id is not null + and ip.raw_material_tag = #{rawMaterialTag} + and ip.retest_tag = #{retestTag} + </select> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/RawMaterialOrderTemplateMapper.xml b/inspect-server/src/main/resources/mapper/RawMaterialOrderTemplateMapper.xml new file mode 100644 index 0000000..cc06bb9 --- /dev/null +++ b/inspect-server/src/main/resources/mapper/RawMaterialOrderTemplateMapper.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ruoyi.inspect.mapper.RawMaterialOrderTemplateMapper"> +</mapper> diff --git a/inspect-server/src/main/resources/mapper/SpotCheckQuarterItemMapper.xml b/inspect-server/src/main/resources/mapper/SpotCheckQuarterItemMapper.xml new file mode 100644 index 0000000..f1404a5 --- /dev/null +++ b/inspect-server/src/main/resources/mapper/SpotCheckQuarterItemMapper.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ruoyi.inspect.mapper.SpotCheckQuarterItemMapper"> +</mapper> diff --git a/performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml b/performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml index 751ca1a..64b3dfc 100644 --- a/performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml +++ b/performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml @@ -11,13 +11,13 @@ <select id="performanceShiftPage" resultMap="performanceShiftPageMap"> SELECT - if(u2.department is not null and u2.department != '', CONCAT(u2.name, '锛�', u2.department, '锛�'), u2.name) name, GROUP_CONCAT(s.work_time, '锛�', s.shift, '锛�', s.id order by s.work_time SEPARATOR ';') AS shift_time, u2.id user_id FROM performance_shift s LEFT JOIN (SELECT distinct u.* from user u left join department_lims dl on FIND_IN_SET(dl.id,u.depart_lims_id) - where state=1 + where status = '0' + and del_flag = '0' <if test="laboratory != null and laboratory != ''"> and dl.name=#{laboratory} </if> @@ -31,8 +31,8 @@ and u2.name like concat('%', #{userName}, '%') </if> </where> - order by s.create_time GROUP BY u2.id + order by s.create_time </select> <select id="performanceShiftYearPage" resultType="map"> @@ -42,7 +42,8 @@ LEFT JOIN (SELECT u.* from user u left join department_lims dl on FIND_IN_SET(dl.id,u.depart_lims_id) - where state=1 + where status = '0' + and del_flag = '0' <if test="laboratory != null and laboratory != ''"> and dl.name=#{laboratory} </if> @@ -60,7 +61,7 @@ </select> <select id="performanceShiftYear" resultType="java.util.Map"> - SELECT if(u2.department is not null and u2.department != '', CONCAT(u2.name, '锛�', u2.department, '锛�'), u2.name) name, + SELECT s.user_id, u2.account, DATE_FORMAT(s.work_time, '%c') work_time, GROUP_CONCAT(DATE_FORMAT(s.work_time, '%c'), '锛�', s.shift order by s.work_time SEPARATOR ';') month_str @@ -68,7 +69,8 @@ LEFT JOIN (SELECT u.* from user u left join department_lims dl on FIND_IN_SET(dl.id,u.depart_lims_id) - where state=1 + where status = '0' + and del_flag = '0' <if test="laboratory != null and laboratory != ''"> and dl.name=#{laboratory} </if> @@ -87,7 +89,7 @@ </select> <select id="performanceShiftYearList" resultType="map"> - SELECT if(u.department is not null and u.department != '', CONCAT(u.name, '锛�', u.department, '锛�'), u.name) name, + SELECT s.user_id, u.account, DATE_FORMAT(s.work_time, '%c') work_time, GROUP_CONCAT(DATE_FORMAT(s.work_time, '%c'), '锛�', s.shift order by s.work_time SEPARATOR ';') month_str @@ -109,7 +111,6 @@ <select id="performanceShiftList" resultMap="performanceShiftPageMap"> SELECT - if(u.department is not null and u.department != '', CONCAT(u.name, '锛�', u.department, '锛�'), u.name) name, GROUP_CONCAT(s.work_time, '锛�', s.shift, '锛�', s.id order by s.work_time SEPARATOR ';') AS shift_time, u.id user_id, u.department FROM performance_shift s LEFT JOIN user u on u.id = s.user_id @@ -123,8 +124,8 @@ <if test="laboratory != null and laboratory != ''"> </if> </where> - order by s.create_time GROUP BY u.id + order by s.create_time </select> <select id="seldepLimsId" resultType="java.lang.String"> diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 5449aa6..5267ad5 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -17,12 +17,12 @@ <dependencies> - <!-- spring-boot-devtools --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-devtools</artifactId> - <optional>true</optional> <!-- 琛ㄧず渚濊禆涓嶄細浼犻�� --> - </dependency> +<!-- <!– spring-boot-devtools –>--> +<!-- <dependency>--> +<!-- <groupId>org.springframework.boot</groupId>--> +<!-- <artifactId>spring-boot-devtools</artifactId>--> +<!-- <optional>true</optional> <!– 琛ㄧず渚濊禆涓嶄細浼犻�� –>--> +<!-- </dependency>--> <!-- swagger3--> <dependency> diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index 1133e0c..7a63aa3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -14,7 +14,7 @@ { public static void main(String[] args) { - System.setProperty("spring.devtools.restart.enabled", "false"); +// System.setProperty("spring.devtools.restart.enabled", "false"); SpringApplication.run(RuoYiApplication.class, args); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/UserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/UserController.java index eb0bfd5..8a25b60 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/UserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/UserController.java @@ -1,11 +1,15 @@ package com.ruoyi.web.controller.system; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.domain.Result; +import com.ruoyi.common.core.domain.entity.User; import com.ruoyi.system.service.UserService; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.Map; /** @@ -21,5 +25,11 @@ @Resource private UserService userService; + @ApiOperation(value = "鏍规嵁鏉′欢鑾峰彇鐢ㄦ埛鍒楄〃") + @GetMapping("/selectUserCondition") + public Result selectUserCondition(User user, String type){ + return Result.success(userService.selectUserCondition(user, type)); + } + } diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index a77bf59..9980440 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -1,70 +1,99 @@ # 鏁版嵁婧愰厤缃� spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 涓诲簱鏁版嵁婧� - master: - url: jdbc:mysql://114.132.189.42:9004/lims-ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root - password: 123456 - # 浠庡簱鏁版嵁婧� - slave: - # 浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴 - enabled: false - url: - username: - password: - # 鍒濆杩炴帴鏁� - initialSize: 5 - # 鏈�灏忚繛鎺ユ睜鏁伴噺 - minIdle: 10 - # 鏈�澶ц繛鎺ユ睜鏁伴噺 - maxActive: 20 - # 閰嶇疆鑾峰彇杩炴帴绛夊緟瓒呮椂鐨勬椂闂� - maxWait: 60000 - # 閰嶇疆杩炴帴瓒呮椂鏃堕棿 - connectTimeout: 30000 - # 閰嶇疆缃戠粶瓒呮椂鏃堕棿 - socketTimeout: 60000 - # 閰嶇疆闂撮殧澶氫箙鎵嶈繘琛屼竴娆℃娴嬶紝妫�娴嬮渶瑕佸叧闂殑绌洪棽杩炴帴锛屽崟浣嶆槸姣 - timeBetweenEvictionRunsMillis: 60000 - # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�灏忕敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 - minEvictableIdleTimeMillis: 300000 - # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�澶х敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 - maxEvictableIdleTimeMillis: 900000 - # 閰嶇疆妫�娴嬭繛鎺ユ槸鍚︽湁鏁� - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 璁剧疆鐧藉悕鍗曪紝涓嶅~鍒欏厑璁告墍鏈夎闂� - allow: - url-pattern: /druid/* - # 鎺у埗鍙扮鐞嗙敤鎴峰悕鍜屽瘑鐮� - login-username: ruoyi - login-password: 123456 - filter: - stat: - enabled: true - # 鎱QL璁板綍 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 涓诲簱鏁版嵁婧� + master: + url: jdbc:mysql://114.132.189.42:9004/lims-ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: 123456 + # 浠庡簱鏁版嵁婧� + slave: + # 浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴 + enabled: false + url: + username: + password: + # 鍒濆杩炴帴鏁� + initialSize: 5 + # 鏈�灏忚繛鎺ユ睜鏁伴噺 + minIdle: 10 + # 鏈�澶ц繛鎺ユ睜鏁伴噺 + maxActive: 20 + # 閰嶇疆鑾峰彇杩炴帴绛夊緟瓒呮椂鐨勬椂闂� + maxWait: 60000 + # 閰嶇疆杩炴帴瓒呮椂鏃堕棿 + connectTimeout: 30000 + # 閰嶇疆缃戠粶瓒呮椂鏃堕棿 + socketTimeout: 60000 + # 閰嶇疆闂撮殧澶氫箙鎵嶈繘琛屼竴娆℃娴嬶紝妫�娴嬮渶瑕佸叧闂殑绌洪棽杩炴帴锛屽崟浣嶆槸姣 + timeBetweenEvictionRunsMillis: 60000 + # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�灏忕敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 + minEvictableIdleTimeMillis: 300000 + # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�澶х敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 + maxEvictableIdleTimeMillis: 900000 + # 閰嶇疆妫�娴嬭繛鎺ユ槸鍚︽湁鏁� + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 璁剧疆鐧藉悕鍗曪紝涓嶅~鍒欏厑璁告墍鏈夎闂� + allow: + url-pattern: /druid/* + # 鎺у埗鍙扮鐞嗙敤鎴峰悕鍜屽瘑鐮� + login-username: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 鎱QL璁板綍 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true minio: - endpoint: http://114.132.189.42/ - port: 7019 - secure: false - accessKey: admin - secretKey: 12345678 - preview-expiry: 24 # 棰勮鍦板潃榛樿24灏忔椂 + endpoint: http://114.132.189.42/ + port: 7019 + secure: false + accessKey: admin + secretKey: 12345678 + preview-expiry: 24 # 棰勮鍦板潃榛樿24灏忔椂 + +# 鐓х墖瀛樺偍璺緞+++++++++++++++++++++++++++杩愮淮闇�瑕侀厤缃�+++++++++++++++++++++++++++ +file: + path: D:\椤圭洰鏂囦欢瀛樺偍\image + # 杞琾df鏂囦欢璺緞 + licenseUrl: D:\20892\Desktop\lims\code\center-lims-after\inspect-server\src\main\resources\lib\license.xml + # 涓婁紶鏂囦欢鍏佽鐨勬墿灞曞悕 + allowed: png,jpg,jpeg,gif + +wordUrl: D:\椤圭洰鏂囦欢瀛樺偍\word +twoCode: D:\椤圭洰鏂囦欢瀛樺偍\two_code + + +#oa: +# oaHost: http://192.168.0.49:8000/oa_workflowrequest.asmx?wsdl +# prodIp: http://192.168.21.53:8081 +# unqualifiedProcessId: 41974 + +wechat: + # 璐ㄩ噺鎶ユ閫氱煡 + examiningUrl: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=21993616-9966-4fe4-81b0-68e99a40c964 + +ifs: + contract: ZTZB + contract-key-get: 4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo= + contract-key-post: 4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo= + custorder: http://192.168.20.47/PurchService.ashx? + custorder-port: http://192.168.20.47:8008/PurchService.ashx? + erp-services: http://192.168.20.47:8081 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 0ab2d16..11725f1 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -53,6 +53,10 @@ basename: i18n/messages profiles: active: druid + # 鍏ㄥ眬鏃堕棿澶勭悊 LocalDateTime鏃堕棿搴忓垪鍙� + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 # 鏂囦欢涓婁紶 servlet: multipart: @@ -61,10 +65,10 @@ # 璁剧疆鎬讳笂浼犵殑鏂囦欢澶у皬 max-request-size: 20MB # 鏈嶅姟妯″潡 - devtools: - restart: - # 鐑儴缃插紑鍏� - enabled: true +# devtools: +# restart: +# # 鐑儴缃插紑鍏� +# enabled: false # redis 閰嶇疆 redis: # 鍦板潃 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Result.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Result.java index 2703c59..37cffe6 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Result.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Result.java @@ -20,7 +20,7 @@ private int code; - private String msg; + private String message; private T data; @@ -69,7 +69,7 @@ Result<T> apiResult = new Result<>(); apiResult.setCode(code); apiResult.setData(data); - apiResult.setMsg(msg); + apiResult.setMessage(msg); return apiResult; } @@ -83,14 +83,14 @@ this.code = code; } - public String getMsg() + public String getMessage() { - return msg; + return message; } - public void setMsg(String msg) + public void setMessage(String message) { - this.msg = msg; + this.message = message; } public T getData() diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateImageUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateImageUtil.java new file mode 100644 index 0000000..7fb91ee --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateImageUtil.java @@ -0,0 +1,61 @@ +package com.ruoyi.common.utils; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.font.FontRenderContext; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +/** + * @Author zhuo + * @Date 2024/9/28 + */ +public class DateImageUtil { + + /** + * 鐢熸垚 褰撳墠鏃ユ湡鐨勭敾甯� + * @return + */ + public static InputStream createDateImage(LocalDateTime date) { + int width = 80; + int height = 20; + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd"); + if (date == null) { + date = LocalDateTime.now(); + } + String s = date.format(formatter); + + Font font = new Font("Serif", Font.BOLD, 10); + // 鍒涘缓涓�涓敾甯冿紙鑳屾櫙閫忔槑锛� + BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + // 鑾峰彇鐢诲竷鐨勭敾绗� + Graphics2D g2 = (Graphics2D) bi.getGraphics(); + // 寮�濮嬬粯鍥� + g2.setComposite(AlphaComposite.Src); // 纭繚缁樺浘鏃舵槸閫忔槑鑳屾櫙 + g2.setBackground(new Color(0, 0, 0, 0)); // 鑳屾櫙鑹蹭负閫忔槑 + g2.clearRect(0, 0, width, height); + g2.setPaint(new Color(0, 0, 0)); // 璁剧疆缁樺埗棰滆壊 + FontRenderContext context = g2.getFontRenderContext(); + Rectangle2D bounds = font.getStringBounds(s, context); + double x = (width - bounds.getWidth()) / 2; + double y = (height - bounds.getHeight()) / 2; + double ascent = -bounds.getY(); + double baseY = y + ascent; + g2.drawString(s, (int) x, (int) baseY); + g2.dispose(); // 閲婃斁鐢荤瑪璧勬簮 + ByteArrayOutputStream os = new ByteArrayOutputStream(); + + try { + ImageIO.write(bi, "png", os); + } catch (IOException e) { + throw new RuntimeException(e); + } + return new ByteArrayInputStream(os.toByteArray()); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FormatterConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FormatterConfig.java new file mode 100644 index 0000000..5360870 --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FormatterConfig.java @@ -0,0 +1,51 @@ +//package com.ruoyi.framework.config; +// +//import com.fasterxml.jackson.databind.DeserializationFeature; +//import com.fasterxml.jackson.databind.ObjectMapper; +//import com.fasterxml.jackson.databind.SerializationFeature; +//import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +//import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +//import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.http.converter.HttpMessageConverter; +//import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +//import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +//import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; +// +//import java.text.SimpleDateFormat; +//import java.time.LocalDateTime; +//import java.time.format.DateTimeFormatter; +//import java.util.List; +// +//@Configuration +//public class FormatterConfig extends WebMvcConfigurationSupport { +// +// +// @Value("${spring.jackson.date-format}") +// private String pattern; +// +// // 鍏ㄥ眬鏍煎紡鍖栧鐞� +// @Override +// protected void extendMessageConverters(List<HttpMessageConverter<?>> converters) { +// Jackson2ObjectMapperBuilder json = Jackson2ObjectMapperBuilder.json(); +// MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); +// +// //localDateTime鏍煎紡鍖� +// JavaTimeModule module = new JavaTimeModule(); +// LocalDateTimeDeserializer dateTimeDeserializer = new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(pattern)); +// LocalDateTimeSerializer dateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(pattern)); +// module.addDeserializer(LocalDateTime.class, dateTimeDeserializer); +// module.addSerializer(LocalDateTime.class, dateTimeSerializer); +// ObjectMapper objectMapper = json.modules(module) +// .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build(); +// +// //date鏃堕棿鏍煎紡鍖� +// objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); +// objectMapper.setDateFormat(new SimpleDateFormat(pattern.split(" ")[0])); +// +// // 璁剧疆鏍煎紡鍖栧唴瀹� +// converter.setObjectMapper(objectMapper); +// converters.add(0, converter); +// } +//} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java index 0f3eafd..6bfa898 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java @@ -1,7 +1,11 @@ package com.ruoyi.system.mapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.core.domain.entity.User; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 鐢ㄦ埛淇℃伅琛� @@ -11,5 +15,12 @@ */ public interface UserMapper extends BaseMapper<User> { + /** + * 鏍规嵁鏉′欢鑾峰彇鐢ㄦ埛鍒楄〃 + * @param ew + * @param type + * @return + */ + List<User> selectUserCondition(@Param("ew") QueryWrapper<User> ew, @Param("type") String type); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/UserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/UserService.java index b073d56..615f700 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/UserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/UserService.java @@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.entity.User; +import java.util.List; + /** * 鐢ㄦ埛淇℃伅琛� * @@ -11,5 +13,13 @@ */ public interface UserService extends IService<User> { + + /** + * 鏍规嵁鏉′欢鑾峰彇鐢ㄦ埛鍒楄〃 + * @param user + * @param type + * @return + */ + List<User> selectUserCondition(User user, String type); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java index acc052e..7251c0c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java @@ -2,9 +2,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.domain.entity.User; +import com.ruoyi.common.utils.QueryWrappers; import com.ruoyi.system.mapper.UserMapper; import com.ruoyi.system.service.UserService; import org.springframework.stereotype.Service; + +import java.util.List; /** * 鐢ㄦ埛淇℃伅琛� @@ -15,5 +18,15 @@ @Service public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService { + /** + * 鏍规嵁鏉′欢鑾峰彇鐢ㄦ埛鍒楄〃 + * @param user + * @param type + * @return + */ + @Override + public List<User> selectUserCondition(User user, String type) { + return baseMapper.selectUserCondition(QueryWrappers.queryWrappers(user), type); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml new file mode 100644 index 0000000..f927978 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ruoyi.system.mapper.UserMapper"> + + <!--鏍规嵁鏉′欢鑾峰彇鐢ㄦ埛鍒楄〃--> + <select id="selectUserCondition" resultType="com.ruoyi.common.core.domain.entity.User"> + select * from (select id, + dept_id, + account, + name, + name_en, + user_type, + email, + phone, + sex, + age, + signature_url, + picture_url, + status, + del_flag, + login_ip, + login_date, + depart_lims_id, + company, + is_custom + from user + where del_flag = '0') a + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + </select> +</mapper> -- Gitblit v1.9.3