ÎļþÃû´Ó basic-server/src/main/java/com/ruoyi/inspect/controller/CapacityScopeController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.inspect.controller; |
| | | package com.ruoyi.basic.controller; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.poi.excel.ExcelUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.util.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.dto.PageTestObjectDto; |
| | | import com.ruoyi.basic.dto.ProductDTO1; |
| | | import com.ruoyi.basic.excel.StructureTestObjectData; |
| | | import com.ruoyi.basic.excel.StructureTestObjectListener; |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.StandardTemplate; |
| | | import com.ruoyi.basic.pojo.StructureItemParameter; |
| | | import com.ruoyi.basic.pojo.StructureTestObject; |
| | | import com.ruoyi.basic.service.CapacityScopeService; |
| | | import com.ruoyi.basic.service.ProductService; |
| | | import com.ruoyi.basic.service.StandardTemplateService; |
| | | import com.ruoyi.basic.service.StructureItemParameterService; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import com.ruoyi.inspect.dto.PageTestObjectDto; |
| | | import com.ruoyi.inspect.dto.ProductDTO1; |
| | | import com.ruoyi.inspect.excel.StructureTestObjectData; |
| | | import com.ruoyi.inspect.excel.StructureTestObjectListener; |
| | | import com.ruoyi.inspect.pojo.Product; |
| | | import com.ruoyi.inspect.pojo.StandardTemplate; |
| | | import com.ruoyi.inspect.pojo.StructureItemParameter; |
| | | import com.ruoyi.inspect.pojo.StructureTestObject; |
| | | import com.ruoyi.inspect.service.CapacityScopeService; |
| | | import com.ruoyi.inspect.service.ProductService; |
| | | import com.ruoyi.inspect.service.StandardTemplateService; |
| | | import com.ruoyi.inspect.service.StructureItemParameterService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | private StandardTemplateService standardTemplateService; |
| | | |
| | | @ApiOperation(value = "è·åé¡¹ç®æ£éªåæ°å表") |
| | | @PostMapping("/selectItemParameterList") |
| | | public Result selectItemParameterList(Page page,StructureItemParameter itemParameter) throws Exception { |
| | | @GetMapping("/selectItemParameterList") |
| | | public Result selectItemParameterList(Page page, StructureItemParameter itemParameter) throws Exception { |
| | | return Result.success(capacityScopeService.selectItemParameterList(page, itemParameter)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "å é¤é¡¹ç®æ£éªåæ°") |
| | | @PostMapping("/delItemParameter") |
| | | @DeleteMapping("/delItemParameter") |
| | | public Result<?> delItemParameter(Integer id) { |
| | | return Result.success(capacityScopeService.delItemParameter(id)); |
| | | } |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åæ£éªå¯¹è±¡") |
| | | @PostMapping("/selectTestObjectList") |
| | | public Result selectTestObjectList(Page page,PageTestObjectDto pageTestObjectDto) throws Exception { |
| | | @GetMapping("/selectTestObjectList") |
| | | public Result selectTestObjectList(Page page, PageTestObjectDto pageTestObjectDto) throws Exception { |
| | | return Result.success(capacityScopeService.selectTestObjectList(page, pageTestObjectDto)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "å 餿£éªå¯¹è±¡") |
| | | @PostMapping("/delTestObject") |
| | | @DeleteMapping("/delTestObject") |
| | | public Result<?> delTestObject(Integer id) { |
| | | return Result.success(capacityScopeService.delTestObject(id)); |
| | | } |
| | |
| | | return Result.success(capacityScopeService.selectTestObjectByName()); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åæ£éªé¡¹åå项") |
| | | @GetMapping("/selectTestInspectionItem") |
| | | public Result selectTestObjectInspectionItem(String specimenName) { |
| | | return Result.success(structureItemParameterService.selectTestObjectInspectionItem(specimenName)); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åæ£éªé¡¹åå项") |
| | | @GetMapping("/selectTestInspectionItemSub") |
| | | public Result selectTestInspectionItemSub(String inspectionItemSubclass) { |
| | | return Result.success(structureItemParameterService.selectTestInspectionItemSub(inspectionItemSubclass)); |
| | | } |
| | | |
| | | @ApiOperation(value = "设å¤éé¢éæ©æ£éªé¡¹ç®(æ å½¢ç»æ)") |
| | | @PostMapping("/getInsProduction") |
| | | @GetMapping("/getInsProduction") |
| | | public Result getInsProduction() { |
| | | return Result.success(capacityScopeService.getInsProduction()); |
| | | } |
| | | |
| | | @ApiOperation(value = "ç»´æ¤æ£éªå¯¹è±¡ç产å") |
| | | @PostMapping("/selectProductListByObjectId") |
| | | public Result selectProductListByObjectId(Page page,ProductDTO1 productDTO) throws Exception { |
| | | @GetMapping("/selectProductListByObjectId") |
| | | public Result selectProductListByObjectId(Page page, ProductDTO1 productDTO) throws Exception { |
| | | return Result.success(productService.selectProductListByObjectId(page, productDTO)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "å é¤äº§å") |
| | | @PostMapping("/delProduct") |
| | | @DeleteMapping("/delProduct") |
| | | public Result delProduct(Integer id) { |
| | | return Result.success(productService.delProduct(id)); |
| | | } |
| | |
| | | return Result.success(capacityScopeService.getItemTree()); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "è£
å¤å¯¼å
¥æ£éªé¡¹ç®") |
| | | @PostMapping("/importEquipData") |
| | | @Transactional |
| | | public Result importEquipData(@RequestParam("file") MultipartFile file) throws Exception { |
| | | @ApiOperation(value = "导å
¥æ£éªé¡¹ç®") |
| | | @PostMapping("/importData") |
| | | public Result importData(@RequestParam("file") MultipartFile file) throws Exception { |
| | | InputStream inputStream = file.getInputStream(); |
| | | List<StructureItemParameter> lists = new ArrayList<>(); |
| | | AtomicReference<String> sample = new AtomicReference<>(); |
| | |
| | | } |
| | | if (l >= 1) { |
| | | StructureItemParameter str = new StructureItemParameter(); |
| | | // æµè¯å¯¹è±¡ |
| | | if (list1.get(1) == null) { |
| | | str.setSample(null); |
| | | } else { |
| | | String brand = (String) list1.get(1); |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append("["); |
| | | // 产å |
| | | if (ObjectUtil.isNotEmpty(list1.get(2))) { |
| | | String production = (String) list1.get(2); |
| | | if (!production.contains("ï¼")) { |
| | | if (!production.contains("ã")) { |
| | | builder.append(String.format("[\"%s\",\"%s\"]", brand, production)); |
| | | } else { |
| | | Arrays.stream(production.split("ï¼")).forEach(item -> { |
| | | Arrays.stream(production.split("ã")).forEach(item -> { |
| | | builder.append(String.format("[\"%s\",\"%s\"],", brand, item)); |
| | | }); |
| | | builder.deleteCharAt(builder.length() - 1); |
| | |
| | | builder.append("]"); |
| | | str.setSample(builder.toString()); |
| | | } |
| | | // æ£éªé¡¹ |
| | | str.setInspectionItem(list1.get(4).toString().trim()); |
| | | // æ£éªé¡¹è±æ |
| | | str.setInspectionItem(list1.get(4).toString()); |
| | | if (list1.get(5) != null) { |
| | | str.setInspectionItemEn(list1.get(5).toString()); |
| | | } |
| | | // æ£éªå项 |
| | | if (list1.get(6) == null) { |
| | | str.setInspectionItemSubclass(null); |
| | | } else { |
| | | str.setInspectionItemSubclass(list1.get(6).toString().trim()); |
| | | str.setInspectionItemSubclass(list1.get(6).toString()); |
| | | } |
| | | // æ£éªåé¡¹è±æ |
| | | if (list1.get(7) == null) { |
| | | str.setInspectionItemSubclassEn(null); |
| | | } else { |
| | | str.setInspectionItemSubclassEn(String.valueOf(list1.get(7).toString())); |
| | | } |
| | | // æ£éªé¡¹åç±» |
| | | if (list1.get(22) != null && list1.get(22) != "") { |
| | | str.setInspectionItemClass(list1.get(22).toString().trim()); |
| | | StructureItemParameter db_str; |
| | | if (StringUtils.isEmpty(str.getInspectionItemSubclass())) { |
| | | // æ¯è¾ä¸¤ä¸ªæ¡ä»¶ |
| | | try { |
| | | db_str = structureItemParameterService.getOne(Wrappers.lambdaQuery(StructureItemParameter.class) |
| | | .eq(StructureItemParameter::getInspectionItem, str.getInspectionItem()) |
| | | .eq(StructureItemParameter::getSample, str.getSample()) |
| | | .last("limit 1") |
| | | ); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("é夿¥è¯¢ï¼" + str.getInspectionItem()); |
| | | } |
| | | } else { |
| | | str.setInspectionItemClass(null); |
| | | try { |
| | | db_str = structureItemParameterService.getOne(Wrappers.lambdaQuery(StructureItemParameter.class) |
| | | .eq(StructureItemParameter::getInspectionItem, str.getInspectionItem()) |
| | | .eq(StructureItemParameter::getSample, str.getSample()) |
| | | .eq(StructureItemParameter::getInspectionItemSubclass, str.getInspectionItemSubclass()) |
| | | .last("limit 1") |
| | | ); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("é夿¥è¯¢ï¼" + str.getInspectionItem() + " " + str.getInspectionItemSubclass()); |
| | | } |
| | | } |
| | | // æ£éªé¡¹åç±»è±æ |
| | | if (list1.get(23) != null && list1.get(23) != "") { |
| | | str.setInspectionItemClassEn(list1.get(23) + ""); |
| | | } else { |
| | | str.setInspectionItemClassEn(null); |
| | | } |
| | | |
| | | LambdaQueryWrapper<StructureItemParameter> wrapper = Wrappers.lambdaQuery(StructureItemParameter.class) |
| | | .eq(StructureItemParameter::getInspectionItem, str.getInspectionItem()) |
| | | .eq(StructureItemParameter::getSample, str.getSample()) |
| | | |
| | | .last("limit 1"); |
| | | // 夿æ¯å¦ææ£éªé¡¹ç±»å |
| | | if (ObjectUtils.isNotEmpty(str.getInspectionItemClass())) { |
| | | wrapper.eq(StructureItemParameter::getInspectionItemClass, str.getInspectionItemClass()); |
| | | } |
| | | |
| | | // 夿æ¯å¦ææ£éªå项 |
| | | if (ObjectUtils.isNotEmpty(str.getInspectionItemSubclass())) { |
| | | wrapper.eq(StructureItemParameter::getInspectionItemSubclass, str.getInspectionItemSubclass()); |
| | | } |
| | | StructureItemParameter db_str = structureItemParameterService.getOne(wrapper); |
| | | if (ObjectUtils.isNotEmpty(db_str)) { |
| | | str.setId(db_str.getId()); |
| | | } |
| | | // æ¹æ³åç§° |
| | | if (list1.get(8) == null) { |
| | | str.setMethod(null); |
| | | } else { |
| | | StringBuffer buffer = new StringBuffer(); |
| | | String input = list1.get(8).toString(); |
| | | buffer.append("["); |
| | | String[] values = input.split("ï¼"); |
| | | String[] values = input.split("ã"); |
| | | for (String value : values) { |
| | | buffer.append("\"").append(value.trim()).append("\","); |
| | | } |
| | |
| | | buffer.append("]"); |
| | | str.setMethod(buffer.toString()); |
| | | } |
| | | // è¯éªå®¤ |
| | | |
| | | if (list1.get(9) == null) { |
| | | str.setSonLaboratory(null); |
| | | } else { |
| | | str.setSonLaboratory(list1.get(9).toString()); |
| | | } |
| | | // 计éåä½ |
| | | if (list1.get(10) == null) { |
| | | str.setUnit(null); |
| | | } else { |
| | | str.setUnit(list1.get(10).toString()); |
| | | } |
| | | // è¦æ±å¼ |
| | | |
| | | if (list1.get(11) == null) { |
| | | str.setAskTell(null); |
| | | } else { |
| | | str.setAskTell(list1.get(11).toString()); |
| | | } |
| | | // è¦æ±æè¿° |
| | | |
| | | if (list1.get(12) == null) { |
| | | str.setAsk(null); |
| | | } else { |
| | | str.setAsk(list1.get(12).toString()); |
| | | } |
| | | // åä»· |
| | | |
| | | if (list1.get(13) == null) { |
| | | str.setPrice(null); |
| | | } else { |
| | | str.setPrice(list1.get(13) + ""); |
| | | } |
| | | // å·¥æ¶ç³»æ° |
| | | |
| | | if (list1.get(14) == null) { |
| | | str.setManHour(null); |
| | | } else { |
| | | str.setManHour(Double.valueOf(list1.get(14).toString())); |
| | | } |
| | | // å·¥æ¶åç» |
| | | |
| | | if (list1.get(15) == null) { |
| | | str.setManHourGroup(null); |
| | | } else { |
| | | str.setManHourGroup(list1.get(15).toString()); |
| | | } |
| | | // é¢è®¡å®ææ¶é´ |
| | | |
| | | if (list1.get(16) == null) { |
| | | str.setManDay(null); |
| | | } else { |
| | | str.setManDay(Integer.valueOf(list1.get(16).toString())); |
| | | } |
| | | // æ°æ®ç±»å |
| | | String jy; |
| | | if (list1.get(17).toString().equals("éééç±»å")) { |
| | | jy = "0"; |
| | |
| | | jy = "1"; |
| | | } |
| | | str.setInspectionItemType(jy); |
| | | // æ£éªé¡¹ç±»å |
| | | String validateValueType = list1.get(18).toString(); |
| | | if (ObjectUtils.isNotEmpty(validateValueType)) { |
| | | if (StringUtils.isNotBlank(validateValueType)) { |
| | | List<SysDictData> enums = dictTypeService.selectDictDataByName("æ£éªå¼ç±»å") |
| | | .stream().filter(sysDictData -> sysDictData.getDictLabel().equals(validateValueType)).collect(Collectors.toList()); |
| | | str.setInspectionValueType(enums.get(0).getDictValue()); |
| | | } |
| | | int bsm; |
| | | //ç¹æ®æ è¯ |
| | | if (list1.get(19).toString().equals("å¦")) { |
| | | bsm = 0; |
| | | } else { |
| | | bsm = 1; |
| | | } |
| | | str.setBsm(bsm + ""); |
| | | // æ°ååå
¸ |
| | | if (list1.get(20) != null) { |
| | | str.setDic(list1.get(20) + ""); |
| | | } else { |
| | | str.setDic(null); |
| | | } |
| | | // åå§è®°å½æ¨¡æ¿ |
| | | StandardTemplate standTempIdByName = standardTemplateService.getStandTempIdByName(String.valueOf(list1.get(21))); |
| | | if (standTempIdByName != null) { |
| | | str.setTemplateId(standTempIdByName.getId()); |
| | |
| | | str.setTemplateId(null); |
| | | } |
| | | try { |
| | | if (list1.get(22) != null && list1.get(22) != "") { |
| | | str.setInspectionItemClass(list1.get(22) + ""); |
| | | } else { |
| | | str.setInspectionItemClass(null); |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | try { |
| | | if (list1.get(23) != null && list1.get(23) != "") { |
| | | str.setInspectionItemClassEn(list1.get(23) + ""); |
| | | } else { |
| | | str.setInspectionItemClassEn(null); |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | try { |
| | | if (list1.get(24) != null) { |
| | | str.setLaboratory(list1.get(24) + ""); |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | // æ¡ä»¶ |
| | | if (list1.get(25) == null) { |
| | | str.setRadiusList(null); |
| | | } else { |
| | | StringBuffer buffer = new StringBuffer(); |
| | | String input = list1.get(25).toString(); |
| | | buffer.append("["); |
| | | String[] values = input.split("ï¼"); |
| | | for (String value : values) { |
| | | buffer.append("\"").append(value.trim()).append("\","); |
| | | } |
| | | buffer.deleteCharAt(buffer.length() - 1); |
| | | buffer.append("]"); |
| | | str.setRadiusList(buffer.toString()); |
| | | } |
| | | // æ¶è´¹æ å |
| | | if (list1.get(26) == null) { |
| | | str.setRates(null); |
| | | } else { |
| | | str.setRates(list1.get(26) + ""); |
| | | } |
| | | |
| | | lists.add(str); |
| | | } |
| | | }); |
| | | // structureItemParameterService.removeNoSample(sample.get()); |
| | | structureItemParameterService.removeNoSample(sample.get()); |
| | | // å¦ææ°æ®åºéé¢çæ°æ®åå¨é£ä¹å°±æ§è¡æ´æ°æ·è´æä½ |
| | | try { |
| | | structureItemParameterService.saveOrUpdateBatch(lists); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("æå¡ç«¯æ¥é"); |
| | | throw new RuntimeException("æå¡ç«¯æ¥éå¦!!!"); |
| | | } |
| | | return Result.success(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "导å
¥æ£éªå¯¹è±¡") |
| | | @PostMapping("/importExcel") |
| | | public Result importExcel(@RequestParam("file") MultipartFile file) { |