From fcedf22c8d6091564d36ef9a755a7d21ff3fe6df Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Wed, 5 Jun 2024 13:05:55 +0800 Subject: [PATCH] =?UTF-8?q?OA=E5=AF=B9=E6=8E=A5,=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E4=B8=AD=E9=97=B4=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/quot/QuotController.java | 33 ++- .../src/main/resources/application-druid.yml | 9 + .../ruoyi/common/enums/DataSourceType.java | 8 +- .../ruoyi/framework/config/DruidConfig.java | 10 + .../java/com/ruoyi/quot/domain/SysOaQuot.java | 194 ++++++++++++++++++ .../ruoyi/quot/domain/SysOaQuotMaterial.java | 192 +++++++++++++++++ .../com/ruoyi/quot/mapper/QuotMapper.java | 19 ++ .../com/ruoyi/quot/service/IQuotService.java | 13 ++ .../quot/service/impl/QuotServiceImpl.java | 54 +++++ .../main/resources/mapper/quot/QuotMapper.xml | 54 +++++ ruoyi-ui/src/views/quot/quot/index.vue | 14 +- 11 files changed, 593 insertions(+), 7 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/quot/domain/SysOaQuot.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/quot/domain/SysOaQuotMaterial.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/quot/QuotController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/quot/QuotController.java index 111d37b..21b00f5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/quot/QuotController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/quot/QuotController.java @@ -14,8 +14,7 @@ import com.ruoyi.common.utils.file.MinioUtil; import com.ruoyi.common.utils.uuid.UUID; import com.ruoyi.priceVerification.domain.QuotHj; import com.ruoyi.priceVerification.service.IQuotHjService; -import com.ruoyi.quot.domain.QuotFile; -import com.ruoyi.quot.domain.QuotMaterial; +import com.ruoyi.quot.domain.*; import com.ruoyi.quot.service.IQuotFileService; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysNoticeService; @@ -31,7 +30,6 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.quot.domain.Quot; import com.ruoyi.quot.service.IQuotService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; @@ -464,8 +462,35 @@ public class QuotController extends BaseController @PostMapping("/commitOAQuot") public AjaxResult commitOAQuot(@RequestBody Quot quot) { - // TODO 对接OA + // 报价单提交OA,插入中间表 sys_oa_quot sys_oa_quot_material + SysOaQuot sysOaQuot = new SysOaQuot(); + SysOaQuot oauser = quotService.selectOAUserByUserName(getUsername());// 查询OA用户 + if(oauser==null){ + return error("该账户:"+getUsername()+"在OA中不存在"); + } + + sysOaQuot.setUserId(oauser.getUserId()); + sysOaQuot.setDepartmentId(oauser.getUserId()); + sysOaQuot.setDepartmentId(oauser.getDepartmentId()); + sysOaQuot.setSubmissionTime(DateUtils.getTime()); + sysOaQuot.setQuotId(UUID.fastUUID().toString()); + sysOaQuot.setQuotCode(quot.getQuotCode()); + sysOaQuot.setQuotSalesmanName(quot.getQuotSalesmanName()); + sysOaQuot.setQuotCustomerName(quot.getQuotCustomerName()); + sysOaQuot.setQuotAddress(quot.getQuotAddress()); + sysOaQuot.setQuotPhone(quot.getQuotPhone()); + sysOaQuot.setQuotInquiryDate(quot.getQuotInquiryDate()); + sysOaQuot.setQuotProject(quot.getQuotProject()); + sysOaQuot.setQuotQuotationRequire(quot.getQuotQuotationRequire()); + sysOaQuot.setQuotLvPrice(quot.getQuotLvPrice()); + sysOaQuot.setQuotTongPrice(quot.getQuotTongPrice()); + sysOaQuot.setQuotMatpriceDiff(quot.getQuotMatpriceDiff()); + + sysOaQuot.setMaterials(quot.getQuotMaterialList()); + + quotService.insertSysOAQuot(sysOaQuot); + quot.setQuotOAApprovalStatus("1");// 更新OA提交状态为 审批中 quotService.updateQuot(quot); return success(); diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 6e4964b..af03b69 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -61,6 +61,15 @@ spring: url: jdbc:sqlserver://192.168.9.2:1433;DatabaseName=jn_web username: sa password: it12345 + # OA数据库数据源 + oa: + # 从数据源开关/默认关闭 + enabled: true + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + # 正式数据库 + url: jdbc:sqlserver://192.168.9.182:1433;DatabaseName=ecology + username: sa + password: Itcenter110- # 初始连接数 initialSize: 10 # 最小连接池数量 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java index 3ed2044..5bd48d1 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java @@ -43,6 +43,12 @@ public enum DataSourceType * @author JIAL * @updateTime 2024/5/24 15:50 */ - ORDER + ORDER, + + /** + * OA数据库 + */ + OA + } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java index a8b9b66..34861fc 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java @@ -94,6 +94,15 @@ public class DruidConfig return druidProperties.dataSource(dataSource); } + @Bean + @ConfigurationProperties("spring.datasource.druid.oa") + @ConditionalOnProperty(prefix = "spring.datasource.druid.oa", name = "enabled", havingValue = "true") + public DataSource oaDataSource(DruidProperties druidProperties) + { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + @Bean(name = "dynamicDataSource") @Primary public DynamicDataSource dataSource(DataSource masterDataSource) @@ -106,6 +115,7 @@ public class DruidConfig setDataSource(targetDataSources, DataSourceType.JNERP.name(), "jnerpDataSource"); setDataSource(targetDataSources, DataSourceType.STORAGE.name(), "storageDataSource"); setDataSource(targetDataSources, DataSourceType.ORDER.name(), "orderDataSource"); + setDataSource(targetDataSources, DataSourceType.OA.name(), "oaDataSource"); return new DynamicDataSource(masterDataSource, targetDataSources); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/quot/domain/SysOaQuot.java b/ruoyi-system/src/main/java/com/ruoyi/quot/domain/SysOaQuot.java new file mode 100644 index 0000000..665b4fe --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/quot/domain/SysOaQuot.java @@ -0,0 +1,194 @@ +package com.ruoyi.quot.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.Date; +import java.util.List; + +/** + * 报价对象 SysOaQuot + * + * @author ruoyi + * @date 2024-04-01 + */ +public class SysOaQuot extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** oa用户id */ + private Integer userId; + + /** oa部门ID */ + private Integer departmentId; + + /** 提交oa时间 */ + private String submissionTime; + + /** 报价单id */ + private String quotId; + + /** 报价单号 */ + private String quotCode; + + /** 业务员 */ + private String quotSalesmanName; + + /** 客户名称 */ + private String quotCustomerName; + + /** 地址 */ + private String quotAddress; + + /** 联系电话 */ + private String quotPhone; + + /** 询价日期 */ + private Date quotInquiryDate; + + /** 项目名称 */ + private String quotProject; + + /** 报价要求 */ + private String quotQuotationRequire; + + /** 铝价 */ + private String quotLvPrice; + + /** 铜价 */ + private String quotTongPrice; + + /** 整单料价价差率 */ + private String quotMatpriceDiff; + + /** 明细 */ + List materials; + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getDepartmentId() { + return departmentId; + } + + public void setDepartmentId(Integer departmentId) { + this.departmentId = departmentId; + } + + public String getSubmissionTime() { + return submissionTime; + } + + public void setSubmissionTime(String submissionTime) { + this.submissionTime = submissionTime; + } + + public String getQuotId() { + return quotId; + } + + public void setQuotId(String quotId) { + this.quotId = quotId; + } + + public String getQuotCode() { + return quotCode; + } + + public void setQuotCode(String quotCode) { + this.quotCode = quotCode; + } + + public String getQuotSalesmanName() { + return quotSalesmanName; + } + + public void setQuotSalesmanName(String quotSalesmanName) { + this.quotSalesmanName = quotSalesmanName; + } + + public String getQuotCustomerName() { + return quotCustomerName; + } + + public void setQuotCustomerName(String quotCustomerName) { + this.quotCustomerName = quotCustomerName; + } + + public String getQuotAddress() { + return quotAddress; + } + + public void setQuotAddress(String quotAddress) { + this.quotAddress = quotAddress; + } + + public String getQuotPhone() { + return quotPhone; + } + + public void setQuotPhone(String quotPhone) { + this.quotPhone = quotPhone; + } + + public Date getQuotInquiryDate() { + return quotInquiryDate; + } + + public void setQuotInquiryDate(Date quotInquiryDate) { + this.quotInquiryDate = quotInquiryDate; + } + + public String getQuotProject() { + return quotProject; + } + + public void setQuotProject(String quotProject) { + this.quotProject = quotProject; + } + + public String getQuotQuotationRequire() { + return quotQuotationRequire; + } + + public void setQuotQuotationRequire(String quotQuotationRequire) { + this.quotQuotationRequire = quotQuotationRequire; + } + + public String getQuotLvPrice() { + return quotLvPrice; + } + + public void setQuotLvPrice(String quotLvPrice) { + this.quotLvPrice = quotLvPrice; + } + + public String getQuotTongPrice() { + return quotTongPrice; + } + + public void setQuotTongPrice(String quotTongPrice) { + this.quotTongPrice = quotTongPrice; + } + + public String getQuotMatpriceDiff() { + return quotMatpriceDiff; + } + + public void setQuotMatpriceDiff(String quotMatpriceDiff) { + this.quotMatpriceDiff = quotMatpriceDiff; + } + + public List getMaterials() { + return materials; + } + + public void setMaterials(List materials) { + this.materials = materials; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/quot/domain/SysOaQuotMaterial.java b/ruoyi-system/src/main/java/com/ruoyi/quot/domain/SysOaQuotMaterial.java new file mode 100644 index 0000000..912af31 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/quot/domain/SysOaQuotMaterial.java @@ -0,0 +1,192 @@ +package com.ruoyi.quot.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.math.BigDecimal; + +/** + * 报价单-产品对象 SysOaQuotMaterial + * + * @author ruoyi + * @date 2024-04-01 + */ +public class SysOaQuotMaterial extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 产品ID */ + private String matId; + + /** 型号 */ + private String matXingh; + + /** 规格 */ + private String matGuig; + + /** 电压 */ + private String matDiany; + + /** 标准 */ + private String matStandard; + + /** 单位 */ + private String matDanw; + + /** 数量 */ + private BigDecimal matSl; + + /** 备注 */ + private String matRemark; + + /** 料价 */ + private BigDecimal matMatprice; + + /** 红本价 */ + private BigDecimal matPrice; + + /** 报价 */ + private BigDecimal matQuotPrice; + + /** 报价金额 */ + private BigDecimal matQuotAllPrice; + + /** 料价价差率 */ + private BigDecimal matMatpriceDiff; + + /** 序号 */ + private Integer xh;//序号 + /** 行号 */ + private Integer index;//行号 + + /** 报价单ID */ + private String quotId; + + public String getMatId() { + return matId; + } + + public void setMatId(String matId) { + this.matId = matId; + } + + public String getMatXingh() { + return matXingh; + } + + public void setMatXingh(String matXingh) { + this.matXingh = matXingh; + } + + public String getMatGuig() { + return matGuig; + } + + public void setMatGuig(String matGuig) { + this.matGuig = matGuig; + } + + public String getMatDiany() { + return matDiany; + } + + public void setMatDiany(String matDiany) { + this.matDiany = matDiany; + } + + public String getMatStandard() { + return matStandard; + } + + public void setMatStandard(String matStandard) { + this.matStandard = matStandard; + } + + public String getMatDanw() { + return matDanw; + } + + public void setMatDanw(String matDanw) { + this.matDanw = matDanw; + } + + public BigDecimal getMatSl() { + return matSl; + } + + public void setMatSl(BigDecimal matSl) { + this.matSl = matSl; + } + + public String getMatRemark() { + return matRemark; + } + + public void setMatRemark(String matRemark) { + this.matRemark = matRemark; + } + + public BigDecimal getMatMatprice() { + return matMatprice; + } + + public void setMatMatprice(BigDecimal matMatprice) { + this.matMatprice = matMatprice; + } + + public BigDecimal getMatPrice() { + return matPrice; + } + + public void setMatPrice(BigDecimal matPrice) { + this.matPrice = matPrice; + } + + public BigDecimal getMatQuotPrice() { + return matQuotPrice; + } + + public void setMatQuotPrice(BigDecimal matQuotPrice) { + this.matQuotPrice = matQuotPrice; + } + + public BigDecimal getMatQuotAllPrice() { + return matQuotAllPrice; + } + + public void setMatQuotAllPrice(BigDecimal matQuotAllPrice) { + this.matQuotAllPrice = matQuotAllPrice; + } + + public BigDecimal getMatMatpriceDiff() { + return matMatpriceDiff; + } + + public void setMatMatpriceDiff(BigDecimal matMatpriceDiff) { + this.matMatpriceDiff = matMatpriceDiff; + } + + public Integer getXh() { + return xh; + } + + public void setXh(Integer xh) { + this.xh = xh; + } + + public Integer getIndex() { + return index; + } + + public void setIndex(Integer index) { + this.index = index; + } + + public String getQuotId() { + return quotId; + } + + public void setQuotId(String quotId) { + this.quotId = quotId; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/quot/mapper/QuotMapper.java b/ruoyi-system/src/main/java/com/ruoyi/quot/mapper/QuotMapper.java index b71ae09..f678c2e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/quot/mapper/QuotMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/quot/mapper/QuotMapper.java @@ -3,6 +3,7 @@ package com.ruoyi.quot.mapper; import java.util.List; import com.ruoyi.quot.domain.Quot; import com.ruoyi.quot.domain.QuotMaterial; +import com.ruoyi.quot.domain.SysOaQuot; import org.apache.ibatis.annotations.Param; /** @@ -122,4 +123,22 @@ public interface QuotMapper */ String checkExistQuot(@Param("quotSalesmanCode") String username, @Param("quotCustomerBm") String quotCustomerBm, @Param("quotProject") String quotProject); + /** + * 报价单提交OA,插入中间表 sys_oa_quot sys_oa_quot_material + * @param sysOaQuot + */ + void insertSysOAQuot(SysOaQuot sysOaQuot); + + /** + * 查询OA用户 + * @param loginid + * @return + */ + SysOaQuot selectOAUserByUserName(String loginid); + + /** + * 报价单提交OA,插入中间表 sys_oa_quot sys_oa_quot_material + * @param subList + */ + void batchSysOaQuotMaterial(List subList); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/quot/service/IQuotService.java b/ruoyi-system/src/main/java/com/ruoyi/quot/service/IQuotService.java index 2907572..2a3c64a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/quot/service/IQuotService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/quot/service/IQuotService.java @@ -4,6 +4,7 @@ import java.util.List; import com.ruoyi.customer.domain.Customer; import com.ruoyi.quot.domain.Quot; +import com.ruoyi.quot.domain.SysOaQuot; /** * 报价Service接口 @@ -105,4 +106,16 @@ public interface IQuotService */ Boolean checkExistQuot(String username, String quotCustomerBm, String quotProject); + + /** + * 报价单提交OA,插入中间表 sys_oa_quot sys_oa_quot_material + * @param sysOaQuot + */ + void insertSysOAQuot(SysOaQuot sysOaQuot); + + /** + * 查询OA用户 + * @return + */ + SysOaQuot selectOAUserByUserName(String loginid); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/quot/service/impl/QuotServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/quot/service/impl/QuotServiceImpl.java index b04d608..378871b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/quot/service/impl/QuotServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/quot/service/impl/QuotServiceImpl.java @@ -3,9 +3,12 @@ package com.ruoyi.quot.service.impl; import java.util.List; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.uuid.UUID; import com.ruoyi.customer.domain.Customer; +import com.ruoyi.quot.domain.SysOaQuot; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -176,6 +179,26 @@ public class QuotServiceImpl implements IQuotService return !"0".equals(count); } + /** + * 报价单提交OA,插入中间表 sys_oa_quot sys_oa_quot_material + * @param sysOaQuot + */ + @Override + public void insertSysOAQuot(SysOaQuot sysOaQuot) { + quotMapper.insertSysOAQuot(sysOaQuot); + insertSysOAQuotMaterial(sysOaQuot); + } + + /** + * 查询OA用户 + * @return + */ + @Override + @DataSource(DataSourceType.OA) + public SysOaQuot selectOAUserByUserName(String loginid) { + return quotMapper.selectOAUserByUserName(loginid); + } + /** * 新增报价单-产品信息 * @@ -206,4 +229,35 @@ public class QuotServiceImpl implements IQuotService } } } + + /** + * 新增报价单-OA产品信息 + * + * @param sysOaQuot 报价对象 + */ + public void insertSysOAQuotMaterial(SysOaQuot sysOaQuot) + { + List quotMaterialList = sysOaQuot.getMaterials(); + String quotId = sysOaQuot.getQuotId(); + if (StringUtils.isNotNull(quotMaterialList)) + { + List list = new ArrayList(); + for (QuotMaterial quotMaterial : quotMaterialList) + { + quotMaterial.setMatId(UUID.fastUUID().toString()); + //TODO 标准 + quotMaterial.setQuotId(quotId); + list.add(quotMaterial); + } + if (list.size() > 0) + { + int batchSize = 100; // 每批次插入的数据量 + for (int i = 0; i < list.size(); i += batchSize) { + int toIndex = Math.min(i + batchSize, list.size()); + List subList = list.subList(i, toIndex); + quotMapper.batchSysOaQuotMaterial(subList); + } + } + } + } } diff --git a/ruoyi-system/src/main/resources/mapper/quot/QuotMapper.xml b/ruoyi-system/src/main/resources/mapper/quot/QuotMapper.xml index 11c1048..77cfdb3 100644 --- a/ruoyi-system/src/main/resources/mapper/quot/QuotMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/quot/QuotMapper.xml @@ -85,6 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -174,6 +176,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" b.mat_quot_allPrice as sub_mat_quot_allPrice, b.mat_matprice_diff as sub_mat_matprice_diff, + b.xh as sub_xh, + b.number as sub_number, + b.quot_id as sub_quot_id from quot a left join quot_material b on b.quot_id = a.quot_id @@ -289,6 +294,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + insert into sys_oa_quot + + user_id, + department_id, + submission_time, + quot_id, + quot_code, + quot_salesman_name, + quot_customer_name, + quot_address, + quot_phone, + quot_inquiry_date, + quot_project, + quot_quotation_require, + quot_lv_price, + quot_tong_price, + quot_matprice_diff, + + + #{userId}, + #{departmentId}, + #{submissionTime}, + #{quotId}, + #{quotCode}, + #{quotSalesmanName}, + #{quotCustomerName}, + #{quotAddress}, + #{quotPhone}, + #{quotInquiryDate}, + #{quotProject}, + #{quotQuotationRequire}, + #{quotLvPrice}, + #{quotTongPrice}, + #{quotMatpriceDiff}, + + + update quot @@ -368,6 +415,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + insert into sys_oa_quot_material( mat_id, mat_xingh, mat_guig, mat_diany,mat_standard, mat_danw, mat_sl,mat_remark, quot_id,xh,number,mat_matprice,mat_price,mat_quot_price,mat_quot_allPrice,mat_matprice_diff) values + + ( #{item.matId}, #{item.matXingh}, #{item.matGuig}, #{item.matDiany}, #{item.matStandard}, #{item.matDanw}, cast(#{item.matSl,jdbcType=DECIMAL} as decimal(18,3)),#{item.matRemark}, #{item.quotId}, #{item.xh}, #{item.index}, cast(#{item.matMatprice,jdbcType=DECIMAL} as decimal(18,3)), cast(#{item.matPrice,jdbcType=DECIMAL} as decimal(18,3)), cast(#{item.matQuotPrice,jdbcType=DECIMAL} as decimal(18,3)),cast(#{item.matQuotAllPrice,jdbcType=DECIMAL} as decimal(18,3)), cast(#{item.matMatpriceDiff,jdbcType=DECIMAL} as decimal(18,3))) + + +