From 3fb990a4bd353f0c3ffac0ddd785913e4b4a8b66 Mon Sep 17 00:00:00 2001 From: Agoni <791536664@qq.com> Date: Wed, 23 Aug 2023 20:14:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=20=E4=BB=A5=E5=8F=8A=20=E7=89=A9=E6=96=99=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=B7=B2=E5=AF=B9=E6=8E=A5=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/bs/enums/ErrorCodeConstants.java | 3 ++ .../admin/materiel/MaterielController.java | 7 +++ .../admin/materiel/vo/MaterielBaseVO.java | 7 ++- .../admin/materiel/vo/MaterielExcelVO.java | 3 ++ .../materiel/vo/MaterielExportReqVO.java | 3 ++ .../admin/materiel/vo/MaterielPageReqVO.java | 6 +++ .../SupplierCompanyController.java | 10 ++-- .../dal/dataobject/materiel/MaterielDO.java | 11 +++++ .../service/materiel/MaterielServiceImpl.java | 47 ++++++++++++++++++- .../SupplierCompanyServiceImpl.java | 6 ++- .../module/bs/utils/BaiduOcrHandler.java | 17 +++++-- 11 files changed, 108 insertions(+), 12 deletions(-) diff --git a/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java index b207a6dc..f08b5070 100644 --- a/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java +++ b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java @@ -20,4 +20,7 @@ public interface ErrorCodeConstants { ErrorCode QUOTATION_SHEET_DETAIL_NOT_EXISTS = new ErrorCode(202500, "报价单物料明细不存在"); ErrorCode MATERIEL_NOT_EXISTS = new ErrorCode(202600, "物料不存在"); ErrorCode QUOTATION_SHEET_BIDDING_NOT_EXISTS = new ErrorCode(202700, "报价单物料中标不存在"); + ErrorCode SUPPLIER_COMPANY_NOT_EXISTS_Ai = new ErrorCode(202800, "识别营业执照接口返回信息状态失败"); + ErrorCode SUPPLIER_COMPANY_NOT_EXISTS_Ai_Error = new ErrorCode(202900, "识别营业执照识别失败"); + ErrorCode QUOTATION_SHEET_NOT_EXISTS_PHONE = new ErrorCode(203000, "手机号码不能重复"); } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/MaterielController.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/MaterielController.java index 757d1d70..d7079a25 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/MaterielController.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/MaterielController.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.bs.controller.admin.materiel; +import com.alibaba.fastjson.JSON; +import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -67,6 +69,11 @@ public class MaterielController { @PreAuthorize("@ss.hasPermission('bs:materiel:query')") public CommonResult getMateriel(@RequestParam("id") Long id) { MaterielDO materiel = materielService.getMateriel(id); + if (materiel.getExtend()!=null && !materiel.getExtend().equals("")){ + materiel.setExtendList(JSON.parseArray(materiel.getExtend(),Object.class)); + }else { + materiel.setExtendList(new ArrayList<>()); + } return success(MaterielConvert.INSTANCE.convert(materiel)); } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielBaseVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielBaseVO.java index ee045bf2..2feac132 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielBaseVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielBaseVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -33,7 +34,7 @@ public class MaterielBaseVO { private Integer materielType; @Schema(description = "单台用量") - @NotNull(message = "单台用量不能为空") +// @NotNull(message = "单台用量不能为空") private Integer dosage; @Schema(description = "描述", example = "你说的对") @@ -46,6 +47,8 @@ public class MaterielBaseVO { private String quality; @Schema(description = "扩展") - private String extend; + private List extendList; + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) + private List files; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielExcelVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielExcelVO.java index 6ebbcbba..1b0a46b9 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielExcelVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielExcelVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -52,4 +53,6 @@ public class MaterielExcelVO { @ExcelProperty("扩展") private String extend; + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) + private List files; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielExportReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielExportReqVO.java index 936b5001..d2669096 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielExportReqVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielExportReqVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import lombok.*; import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; @@ -47,4 +48,6 @@ public class MaterielExportReqVO { @Schema(description = "扩展") private String extend; + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) + private List files; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielPageReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielPageReqVO.java index 41b04ac9..1b731b33 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielPageReqVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/materiel/vo/MaterielPageReqVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import lombok.*; import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; @@ -49,4 +50,9 @@ public class MaterielPageReqVO extends PageParam { @Schema(description = "扩展") private String extend; + @Schema(description = "扩展数组") + private List extendList; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) + private List files; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/suppliercompany/SupplierCompanyController.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/suppliercompany/SupplierCompanyController.java index a435a519..8d4202d3 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/suppliercompany/SupplierCompanyController.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/suppliercompany/SupplierCompanyController.java @@ -17,12 +17,16 @@ import java.io.IOException; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.SUPPLIER_COMPANY_NOT_EXISTS_Ai; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.SUPPLIER_COMPANY_NOT_EXISTS_Ai_Error; import static cn.iocoder.yudao.module.bs.utils.BaiduOcrHandler.handleBusinessLicense; import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*; @@ -43,11 +47,11 @@ public class SupplierCompanyController { @PostMapping("/buildBusinessLicense") @Operation(summary = "百度云营业执照识别") @PreAuthorize("@ss.hasPermission('bs:supplier-company:create')") - public CommonResult buildBusinessLicense(MultipartFile file) { + public CommonResult buildBusinessLicense(MultipartFile file,String url) { try { - return success(handleBusinessLicense(file)); + return success(handleBusinessLicense(file,url)); } catch (Exception e) { - throw new RuntimeException(e); + throw exception(SUPPLIER_COMPANY_NOT_EXISTS_Ai_Error); } } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/materiel/MaterielDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/materiel/MaterielDO.java index c237de37..8b7618a9 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/materiel/MaterielDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/materiel/MaterielDO.java @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.materiel; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import lombok.*; import java.util.*; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import java.time.LocalDateTime; import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.*; @@ -69,4 +71,13 @@ public class MaterielDO extends TenantBaseDO { */ private String extend; + @TableField(exist = false) + private List extendList; + + /** + * 附件 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private List files; + } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/materiel/MaterielServiceImpl.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/materiel/MaterielServiceImpl.java index 85d3a5ee..9f2be072 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/materiel/MaterielServiceImpl.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/materiel/MaterielServiceImpl.java @@ -2,7 +2,10 @@ package cn.iocoder.yudao.module.bs.service.materiel; import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO; import cn.iocoder.yudao.module.bs.dal.mysql.quotationsheet.QuotationSheetMapper; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.github.yulichang.base.MPJBaseServiceImpl; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -34,6 +37,10 @@ public class MaterielServiceImpl extends MPJBaseServiceImpl getMaterielList(Collection ids) { - return materielMapper.selectBatchIds(ids); + List materielDOS = materielMapper.selectBatchIds(ids); + if (null!=materielDOS){ + materielDOS.forEach(p->{ + if (p.getExtend()!=null && !p.getExtend().equals("")){ + p.setExtendList(JSON.parseArray(p.getExtend(),Object.class)); + }else { + p.setExtendList(new ArrayList<>()); + } + }); + } + return materielDOS; } @Override public PageResult getMaterielPage(MaterielPageReqVO pageReqVO) { - return materielMapper.selectPage(pageReqVO); + PageResult materielDOPageResult = materielMapper.selectPage(pageReqVO); + if (null!=materielDOPageResult.getList()){ + materielDOPageResult.getList().forEach(p->{ + if (p.getExtend()!=null && !p.getExtend().equals("")){ + p.setExtendList(JSON.parseArray(p.getExtend(),Object.class)); + }else { + p.setExtendList(new ArrayList<>()); + } + }); + } + return materielDOPageResult; + } + + /** + * String 转 List + */ + public static List> getStrToListMap(String json){ + List list = JSON.parseArray(json); + + List< Map> listw = new ArrayList>(); + for (Object object : list){ + Map ageMap = new HashMap(); + Map ret = (Map) object;//取出list里面的值转为map + listw.add(ret); + } + return listw; + } @Override diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/suppliercompany/SupplierCompanyServiceImpl.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/suppliercompany/SupplierCompanyServiceImpl.java index 347198f8..c95ed435 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/suppliercompany/SupplierCompanyServiceImpl.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/suppliercompany/SupplierCompanyServiceImpl.java @@ -47,12 +47,16 @@ public class SupplierCompanyServiceImpl extends MPJBaseServiceImpl().eq("phone", createReqVO.getPhone())); + if (supplierCompanyDOList >0L){ + throw exception(QUOTATION_SHEET_NOT_EXISTS_PHONE); + } // userCreateReqDTO.setTenantId(supplierCompany.getCompanyNumber()); Long userId = adminUserApi.addUser(userCreateReqDTO); supplierCompany.setCorrelationUserId(userId); diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/BaiduOcrHandler.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/BaiduOcrHandler.java index 117358a4..c44bee92 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/BaiduOcrHandler.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/BaiduOcrHandler.java @@ -14,6 +14,10 @@ import java.io.File; import java.net.URLEncoder; import java.util.Map; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.SUPPLIER_COMPANY_NOT_EXISTS; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.SUPPLIER_COMPANY_NOT_EXISTS_Ai; + /** * @author MrFang * @date 2023年08月15日 11:36 @@ -92,18 +96,23 @@ public class BaiduOcrHandler { * @param businessLicenseImage 营业执照照片(支持:{@linkplain File}及{@linkplain MultipartFile}) * @return IdCard */ - public static BusinessLicense handleBusinessLicense(Object businessLicenseImage) throws Exception { + public static BusinessLicense handleBusinessLicense(Object businessLicenseImage,String url) throws Exception { String accessToken = getAccessToken(); if (StringUtils.isEmpty(accessToken)) { throw new RuntimeException("获取token失败"); } - String base64ImgParam = getImageBase64Param(businessLicenseImage); - String param = "detect_direction=true&" + "image=" + base64ImgParam; + String param =null; + if (url!=null&&!url.trim().equals("")){ + param = "detect_direction=true&" + "url=" + url; + }else { + String base64ImgParam = getImageBase64Param(businessLicenseImage); + param = "detect_direction=true&" + "image=" + base64ImgParam; + } String jsonStr = HttpUtil.post(BaiduOcrConstant.BUSINESS_LICENSE_URL, accessToken, param); JSONObject jsonObject = JSON.parseObject(jsonStr); // log.info("营业执照OCR识别结果=>{}", jsonObject); if (!jsonObject.containsKey("words_result")) { - throw new RuntimeException("识别营业执照接口返回信息状态失败"); + throw exception(SUPPLIER_COMPANY_NOT_EXISTS_Ai); } BusinessLicense license = new BusinessLicense(); JSONObject wordsResult = jsonObject.getJSONObject("words_result");