| | |
| | | import cn.hutool.core.lang.Snowflake; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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; |
| | |
| | | .build(); |
| | | inspectionMaterialMapper.insert(inspectionMaterial); |
| | | /*新增检验项目表*/ |
| | | //获取物料id |
| | | Material material = materialMapper.selectOne(Wrappers.<Material>query() |
| | | .eq("name", inspectionVo.getName()) |
| | | .eq("code", inspectionVo.getMcode())); |
| | | //获取规格名称和型号名称 |
| | | String specification = inspectionVo.getSpecifications(); |
| | | String[] split = specification.split("-"); |
| | | String stName = split[0]; |
| | | String spName = split[1]; |
| | | //获取规格id |
| | | Standard standard = standardService.getOne(Wrappers.<Standard>query() |
| | | .eq("name", stName) |
| | | .eq("material_id", material.getId())); |
| | | //获取型号id |
| | | Specifications specifications = specificationsService.getOne(Wrappers.<Specifications>query() |
| | | .eq("name", spName) |
| | | .eq("standard_id", standard.getId())); |
| | | //根据型号id查询项目信息 |
| | | List<Product> productList = productMapper.selectList(Wrappers.<Product>query().eq("specifications_id", specifications.getId())); |
| | | ArrayList<InspectionProduct> list = new ArrayList<>(); |
| | | for (Product product : productList) { |
| | | InspectionProduct rawInsProduct = InspectionProduct.builder() |
| | | .name(product.getName()) |
| | | .unit(product.getUnit()) |
| | | .required(product.getRequired()) |
| | | .internal(product.getInternal()) |
| | | .inspectionMaterialId(material.getId()) |
| | | .build(); |
| | | list.add(rawInsProduct); |
| | | //根据样品名称编号以及型号规格获取型号id |
| | | Integer specificationId = getSpecificationId(inspectionVo.getName(), inspectionVo.getMcode(), inspectionVo.getSpecifications()); |
| | | //如果试验项目字段不为空 |
| | | if (ObjectUtils.isNotEmpty(inspectionVo.getExperiment())) { |
| | | //获取试验项目信息(结构,导线外径) |
| | | List<String> experiments = Arrays.stream(inspectionVo.getExperiment().split(",")).collect(Collectors.toList()); |
| | | //根据型号id和项目信息查询项目信息 |
| | | List<Product> products = new ArrayList<>(); |
| | | for (String experiment : experiments) { |
| | | List<Product> productList1 = productMapper.selectList(Wrappers.<Product>query() |
| | | .eq("specifications_id", specificationId) |
| | | .eq("father", experiment)); |
| | | if (ObjectUtils.isEmpty(productList1)) { |
| | | Product product = productMapper.selectOne(Wrappers.<Product>query() |
| | | .eq("specifications_id", specificationId) |
| | | .isNull("father") |
| | | .eq("name", experiment)); |
| | | products.add(product); |
| | | } else products.addAll(productList1); |
| | | } |
| | | |
| | | //将查询的项目信息构建成检验项目 |
| | | ArrayList<InspectionProduct> list = new ArrayList<>(); |
| | | for (Product product : products) { |
| | | InspectionProduct rawInsProduct = InspectionProduct.builder() |
| | | .name(product.getName()) |
| | | .unit(product.getUnit()) |
| | | .required(product.getRequired()) |
| | | .internal(product.getInternal()) |
| | | .inspectionMaterialId(inspectionMaterial.getId()) |
| | | .build(); |
| | | list.add(rawInsProduct); |
| | | } |
| | | |
| | | //检验项目批量添加 |
| | | inspectionProductService.saveBatch(list); |
| | | return inspection.getId(); |
| | | } |
| | | //检验项目批量添加 |
| | | inspectionProductService.saveBatch(list); |
| | | return inspection.getId(); |
| | | //todo:未完 |
| | | return null; |
| | | } |
| | | |
| | | //根据检验单id查询原材料检验单详情 |
| | |
| | | } |
| | | |
| | | |
| | | //新增检验单-->选择检验项目版本 |
| | | @Override |
| | | public List<Map<String, Object>> chooseVer(String name, String mcode, String specifications) { |
| | | Integer specificationId = getSpecificationId(name, mcode, specifications); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /*根据样品名称,样品编号,型号规格获取型号id*/ |
| | | private Integer getSpecificationId(String name, String mcode, String specification) { |
| | | //获取物料id |
| | | Material material = materialMapper.selectOne(Wrappers.<Material>query() |
| | | .eq("name", name) |
| | | .eq("code", mcode)); |
| | | //获取规格名称和型号名称 |
| | | String[] split = specification.split("-"); |
| | | String stName = split[0]; |
| | | String spName = split[1]; |
| | | //获取规格id |
| | | Standard standard = standardService.getOne(Wrappers.<Standard>query() |
| | | .eq("name", stName) |
| | | .eq("material_id", material.getId())); |
| | | //获取型号id |
| | | Specifications specifications = specificationsService.getOne(Wrappers.<Specifications>query() |
| | | .eq("name", spName) |
| | | .eq("standard_id", standard.getId())); |
| | | return specifications.getId(); |
| | | } |
| | | |
| | | } |
| | | |