供应商信息 以及 物料管理已对接完成

new
Agoni 1 year ago
parent 9946d271c3
commit 3fb990a4bd

@ -20,4 +20,7 @@ public interface ErrorCodeConstants {
ErrorCode QUOTATION_SHEET_DETAIL_NOT_EXISTS = new ErrorCode(202500, "报价单物料明细不存在"); ErrorCode QUOTATION_SHEET_DETAIL_NOT_EXISTS = new ErrorCode(202500, "报价单物料明细不存在");
ErrorCode MATERIEL_NOT_EXISTS = new ErrorCode(202600, "物料不存在"); ErrorCode MATERIEL_NOT_EXISTS = new ErrorCode(202600, "物料不存在");
ErrorCode QUOTATION_SHEET_BIDDING_NOT_EXISTS = new ErrorCode(202700, "报价单物料中标不存在"); 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, "手机号码不能重复");
} }

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.bs.controller.admin.materiel; 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 org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -67,6 +69,11 @@ public class MaterielController {
@PreAuthorize("@ss.hasPermission('bs:materiel:query')") @PreAuthorize("@ss.hasPermission('bs:materiel:query')")
public CommonResult<MaterielRespVO> getMateriel(@RequestParam("id") Long id) { public CommonResult<MaterielRespVO> getMateriel(@RequestParam("id") Long id) {
MaterielDO materiel = materielService.getMateriel(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)); return success(MaterielConvert.INSTANCE.convert(materiel));
} }

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo; 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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
@ -33,7 +34,7 @@ public class MaterielBaseVO {
private Integer materielType; private Integer materielType;
@Schema(description = "单台用量") @Schema(description = "单台用量")
@NotNull(message = "单台用量不能为空") // @NotNull(message = "单台用量不能为空")
private Integer dosage; private Integer dosage;
@Schema(description = "描述", example = "你说的对") @Schema(description = "描述", example = "你说的对")
@ -46,6 +47,8 @@ public class MaterielBaseVO {
private String quality; private String quality;
@Schema(description = "扩展") @Schema(description = "扩展")
private String extend; private List<Object> extendList;
@Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED)
private List<ImageVo> files;
} }

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo; 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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
@ -52,4 +53,6 @@ public class MaterielExcelVO {
@ExcelProperty("扩展") @ExcelProperty("扩展")
private String extend; private String extend;
@Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED)
private List<ImageVo> files;
} }

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo; package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo;
import cn.iocoder.yudao.framework.common.pojo.ImageVo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@ -47,4 +48,6 @@ public class MaterielExportReqVO {
@Schema(description = "扩展") @Schema(description = "扩展")
private String extend; private String extend;
@Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED)
private List<ImageVo> files;
} }

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo; package cn.iocoder.yudao.module.bs.controller.admin.materiel.vo;
import cn.iocoder.yudao.framework.common.pojo.ImageVo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@ -49,4 +50,9 @@ public class MaterielPageReqVO extends PageParam {
@Schema(description = "扩展") @Schema(description = "扩展")
private String extend; private String extend;
@Schema(description = "扩展数组")
private List<Object> extendList;
@Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED)
private List<ImageVo> files;
} }

@ -17,12 +17,16 @@ import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; 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 static cn.iocoder.yudao.module.bs.utils.BaiduOcrHandler.handleBusinessLicense;
import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*; import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*;
@ -43,11 +47,11 @@ public class SupplierCompanyController {
@PostMapping("/buildBusinessLicense") @PostMapping("/buildBusinessLicense")
@Operation(summary = "百度云营业执照识别") @Operation(summary = "百度云营业执照识别")
@PreAuthorize("@ss.hasPermission('bs:supplier-company:create')") @PreAuthorize("@ss.hasPermission('bs:supplier-company:create')")
public CommonResult<BusinessLicense> buildBusinessLicense(MultipartFile file) { public CommonResult<BusinessLicense> buildBusinessLicense(MultipartFile file,String url) {
try { try {
return success(handleBusinessLicense(file)); return success(handleBusinessLicense(file,url));
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw exception(SUPPLIER_COMPANY_NOT_EXISTS_Ai_Error);
} }
} }

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.materiel;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import lombok.*; import lombok.*;
import java.util.*; 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 java.time.LocalDateTime; import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
@ -69,4 +71,13 @@ public class MaterielDO extends TenantBaseDO {
*/ */
private String extend; private String extend;
@TableField(exist = false)
private List<Object> extendList;
/**
*
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<ImageVo> files;
} }

@ -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.dataobject.quotationsheet.QuotationSheetDO;
import cn.iocoder.yudao.module.bs.dal.mysql.quotationsheet.QuotationSheetMapper; 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 com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -34,6 +37,10 @@ public class MaterielServiceImpl extends MPJBaseServiceImpl<MaterielMapper, Mate
public Long createMateriel(MaterielCreateReqVO createReqVO) { public Long createMateriel(MaterielCreateReqVO createReqVO) {
// 插入 // 插入
MaterielDO materiel = MaterielConvert.INSTANCE.convert(createReqVO); MaterielDO materiel = MaterielConvert.INSTANCE.convert(createReqVO);
if (createReqVO.getExtendList()!=null){
materiel.setExtend(JSON.toJSONString(createReqVO.getExtendList()));
}
materielMapper.insert(materiel); materielMapper.insert(materiel);
// 返回 // 返回
return materiel.getId(); return materiel.getId();
@ -69,12 +76,48 @@ public class MaterielServiceImpl extends MPJBaseServiceImpl<MaterielMapper, Mate
@Override @Override
public List<MaterielDO> getMaterielList(Collection<Long> ids) { public List<MaterielDO> getMaterielList(Collection<Long> ids) {
return materielMapper.selectBatchIds(ids); List<MaterielDO> 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 @Override
public PageResult<MaterielDO> getMaterielPage(MaterielPageReqVO pageReqVO) { public PageResult<MaterielDO> getMaterielPage(MaterielPageReqVO pageReqVO) {
return materielMapper.selectPage(pageReqVO); PageResult<MaterielDO> 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<Map<String,Object>
*/
public static List<Map<Object, Object>> getStrToListMap(String json){
List<Object> list = JSON.parseArray(json);
List< Map<Object,Object>> listw = new ArrayList<Map<Object,Object>>();
for (Object object : list){
Map<Object,Object> ageMap = new HashMap<Object,Object>();
Map <Object,Object> ret = (Map<Object, Object>) object;//取出list里面的值转为map
listw.add(ret);
}
return listw;
} }
@Override @Override

@ -47,12 +47,16 @@ public class SupplierCompanyServiceImpl extends MPJBaseServiceImpl<SupplierCompa
String companyNumber = numberCreate(); String companyNumber = numberCreate();
supplierCompany.setCompanyNumber(companyNumber); supplierCompany.setCompanyNumber(companyNumber);
supplierCompany.setDeleted(false); supplierCompany.setDeleted(false);
supplierCompanyMapper.insert(supplierCompany); // supplierCompanyMapper.insert(supplierCompany);
UserCreateReqDTO userCreateReqDTO=new UserCreateReqDTO(); UserCreateReqDTO userCreateReqDTO=new UserCreateReqDTO();
userCreateReqDTO.setPassword("123456Aa@"); userCreateReqDTO.setPassword("123456Aa@");
userCreateReqDTO.setUsername(supplierCompany.getPhone()); userCreateReqDTO.setUsername(supplierCompany.getPhone());
userCreateReqDTO.setNickname(supplierCompany.getBankName()); userCreateReqDTO.setNickname(supplierCompany.getBankName());
userCreateReqDTO.setMobile(supplierCompany.getPhone()); userCreateReqDTO.setMobile(supplierCompany.getPhone());
Long supplierCompanyDOList = supplierCompanyMapper.selectCount(new QueryWrapper<SupplierCompanyDO>().eq("phone", createReqVO.getPhone()));
if (supplierCompanyDOList >0L){
throw exception(QUOTATION_SHEET_NOT_EXISTS_PHONE);
}
// userCreateReqDTO.setTenantId(supplierCompany.getCompanyNumber()); // userCreateReqDTO.setTenantId(supplierCompany.getCompanyNumber());
Long userId = adminUserApi.addUser(userCreateReqDTO); Long userId = adminUserApi.addUser(userCreateReqDTO);
supplierCompany.setCorrelationUserId(userId); supplierCompany.setCorrelationUserId(userId);

@ -14,6 +14,10 @@ import java.io.File;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Map; 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 * @author MrFang
* @date 20230815 11:36 * @date 20230815 11:36
@ -92,18 +96,23 @@ public class BaiduOcrHandler {
* @param businessLicenseImage {@linkplain File}{@linkplain MultipartFile} * @param businessLicenseImage {@linkplain File}{@linkplain MultipartFile}
* @return IdCard * @return IdCard
*/ */
public static BusinessLicense handleBusinessLicense(Object businessLicenseImage) throws Exception { public static BusinessLicense handleBusinessLicense(Object businessLicenseImage,String url) throws Exception {
String accessToken = getAccessToken(); String accessToken = getAccessToken();
if (StringUtils.isEmpty(accessToken)) { if (StringUtils.isEmpty(accessToken)) {
throw new RuntimeException("获取token失败"); throw new RuntimeException("获取token失败");
} }
String base64ImgParam = getImageBase64Param(businessLicenseImage); String param =null;
String param = "detect_direction=true&" + "image=" + base64ImgParam; 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); String jsonStr = HttpUtil.post(BaiduOcrConstant.BUSINESS_LICENSE_URL, accessToken, param);
JSONObject jsonObject = JSON.parseObject(jsonStr); JSONObject jsonObject = JSON.parseObject(jsonStr);
// log.info("营业执照OCR识别结果=>{}", jsonObject); // log.info("营业执照OCR识别结果=>{}", jsonObject);
if (!jsonObject.containsKey("words_result")) { if (!jsonObject.containsKey("words_result")) {
throw new RuntimeException("识别营业执照接口返回信息状态失败"); throw exception(SUPPLIER_COMPANY_NOT_EXISTS_Ai);
} }
BusinessLicense license = new BusinessLicense(); BusinessLicense license = new BusinessLicense();
JSONObject wordsResult = jsonObject.getJSONObject("words_result"); JSONObject wordsResult = jsonObject.getJSONObject("words_result");

Loading…
Cancel
Save