去除无用代码,新增主数据功能

This commit is contained in:
wangmingwei
2026-05-06 09:32:05 +08:00
parent 540f3973d9
commit 825c45a45a
194 changed files with 12560 additions and 7946 deletions

View File

@@ -103,16 +103,16 @@
<version>${project.version}</version>
</dependency>
<!-- 客户关系-->
<dependency>
<groupId>com.yunzhupaas</groupId>
<artifactId>yunzhupaas-crm-controller</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.yunzhupaas</groupId>
<artifactId>yunzhupaas-pcm-controller</artifactId>
<version>${project.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.yunzhupaas</groupId>-->
<!-- <artifactId>yunzhupaas-crm-controller</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.yunzhupaas</groupId>-->
<!-- <artifactId>yunzhupaas-pcm-controller</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.yunzhupaas</groupId>

View File

@@ -2,7 +2,7 @@
server:
tomcat:
uri-encoding: UTF-8 #tomcat编码
port: 30000 #tomcat端口
port: 40000 #tomcat端口
spring:
messages:
@@ -21,11 +21,12 @@ spring:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure #排除自动配置手动配置druid
datasource:
db-type: MySQL #数据库类型(可选值 MySQL、SQLServer、Oracle、DM8、KingbaseES、PostgreSQL请严格按可选值填写)
# host: aliyun.szlecheng.cn
host: mysql.szlecheng.cn
port: 13306
username: yunzhupass
password: '@yunzhupass'
db-name: dev_yunzhupaas
username: jnpfsoft
password: ZtRmzjij4CiaXpSE
db-name: jnpfsoft_dev
db-schema: #金仓达梦选填
prepare-url: #自定义url
@@ -71,12 +72,12 @@ spring:
statementPrepareAfterLogEnabled: false
statementPrepareCallAfterLogEnabled: false
statementParameterSetLogEnabled: false
# datasource:
# master:
# url: jdbc:mysql://${spring.datasource.host}:${spring.datasource.port}/${spring.datasource.dbname}?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC
# username: ${spring.datasource.username}
# password: ${spring.datasource.password}
# driver-class-name: com.mysql.cj.jdbc.Driver
# datasource:
# master:
# url: jdbc:mysql://${spring.datasource.host}:${spring.datasource.port}/${spring.datasource.dbname}?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC
# username: ${spring.datasource.username}
# password: ${spring.datasource.password}
# driver-class-name: com.mysql.cj.jdbc.Driver
# ===================== Redis配置 =====================
# redis单机模式
@@ -85,7 +86,7 @@ spring:
database: 10
host: 127.0.0.1
port: 6379
# password: redis_JtjYRD # 密码为空时,请将本行注释
# password: redis_JtjYRD # 密码为空时,请将本行注释
timeout: 3000 #超时时间(单位:秒)
lettuce: #Lettuce为Redis的Java驱动包
pool:
@@ -94,24 +95,24 @@ spring:
min-idle: 0 # 连接池中的最小空闲连接
max-idle: 8 # 连接池中的最大空闲连接
# redis集群模式
# redis:
# cluster:
# nodes:
# - 192.168.0.225:6380
# - 192.168.0.225:6381
# - 192.168.0.225:6382
# - 192.168.0.225:6383
# - 192.168.0.225:6384
# - 192.168.0.225:6385
# password: 123456 # 密码为空时,请将本行注释
# timeout: 3000 # 超时时间(单位:秒)
# lettuce: #Lettuce为Redis的Java驱动包
# pool:
# max-active: 8 # 连接池最大连接数
# max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
# min-idle: 0 # 连接池中的最小空闲连接
# max-idle: 8 # 连接池中的最大空闲连接
# redis集群模式
# redis:
# cluster:
# nodes:
# - 192.168.0.225:6380
# - 192.168.0.225:6381
# - 192.168.0.225:6382
# - 192.168.0.225:6383
# - 192.168.0.225:6384
# - 192.168.0.225:6385
# password: 123456 # 密码为空时,请将本行注释
# timeout: 3000 # 超时时间(单位:秒)
# lettuce: #Lettuce为Redis的Java驱动包
# pool:
# max-active: 8 # 连接池最大连接数
# max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
# min-idle: 0 # 连接池中的最小空闲连接
# max-idle: 8 # 连接池中的最大空闲连接
# ===================== Redis配置-End =====================
# ===================== 单点登录(用户信息同步)配置-Start =====================
cloud:
@@ -123,22 +124,22 @@ spring:
group: maxkey_identity
# 若使用RocketMQ-End
# 若使用RabbitMQ-Start
# binders:
# defaultRabbit: # 表示定义的名称用于binding整合
# type: rabbit # 消息组件类型
# environment: # 设置rabbitmq的相关环境配置
# spring:
# rabbitmq:
# host: 192.168.10.6
# port: 5672
# username: rabbitmq
# password: rabbitmq
# binders:
# defaultRabbit: # 表示定义的名称用于binding整合
# type: rabbit # 消息组件类型
# environment: # 设置rabbitmq的相关环境配置
# spring:
# rabbitmq:
# host: 192.168.10.6
# port: 5672
# username: rabbitmq
# password: rabbitmq
# 若使用RabbitMQ-End
# 若使用Kafka-Start
# kafka:
# # KafkaBinderConfigurationProperties
# binder:
# brokers: 192.168.10.6:9092
# kafka:
# # KafkaBinderConfigurationProperties
# binder:
# brokers: 192.168.10.6:9092
# 若使用Kafka-End
bindings:
ssoEventReceiver-in-0:
@@ -160,16 +161,16 @@ spring:
mode: qwen-max
# GPT转发平台
# api-host: https://api.chatanywhere.tech/
# api-key:
# chat:
# mode: gpt-3.5-turbo
# api-host: https://api.chatanywhere.tech/
# api-key:
# chat:
# mode: gpt-3.5-turbo
# DeepSeek
# api-host: https://api.deepseek.com/v1/
# api-key:
# chat:
# mode: deepseek-chat
# api-host: https://api.deepseek.com/v1/
# api-key:
# chat:
# mode: deepseek-chat
# ===================== AI配置-End =====================
# SpringDoc接口文档 访问地址http://127.0.0.1:30000/doc.html
@@ -204,7 +205,7 @@ config:
enable-storage: true #启用存储
enable-access: true #启用访问(线上请使用 Nginx 配置,效率更高)
domain: "" # 访问域名例如“http://127.0.0.1:8030/”,注意后面要和 path-patterns 保持一致,“/”结尾,本地存储建议使用相对路径,方便后期更换域名
# base-path: /data/work-data/upload/jnpfsoft/yunzhupaas-resources/ # 基础路径
# base-path: /data/work-data/upload/jnpfsoft/yunzhupaas-resources/ # 基础路径
base-path: E:/XiangMu/yunzhu/zero-resources/ # 基础路径
path-patterns: /** # 访问路径
storage-path: # 存储路径
@@ -366,3 +367,4 @@ oauth:
serverLoginUrl: ${oauth.sso.cas.baseUrl}/sign/authz/cas/login
serverValidateUrl: ${oauth.sso.cas.baseUrl}/sign/authz/cas
# ===================== 单点登录(SSO)配置-End =====================
userUrl: http://192.168.3.31:8000/api-web/sys/user/save

View File

@@ -2,7 +2,7 @@
server:
tomcat:
uri-encoding: UTF-8 #tomcat编码
port: 30000 #tomcat端口
port: 40001 #tomcat端口
spring:
messages:
@@ -20,12 +20,13 @@ spring:
# ===================== 数据源配置 =====================
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure #排除自动配置手动配置druid
datasource:
db-type: MySQL #数据库类型(可选值 MySQL、SQLServer、Oracle、DM、KingbaseES、PostgreSQL请严格按可选值填写)
host: 127.0.0.1
port: 3306
username: root
password: 123456
db-name: yunzhupaas_init
db-type: MySQL #数据库类型(可选值 MySQL、SQLServer、Oracle、DM8、KingbaseES、PostgreSQL请严格按可选值填写)
# host: aliyun.szlecheng.cn
host: mysql.szlecheng.cn
port: 13306
username: yunzhupass
password: '@yunzhupass'
db-name: pord_yunzhupass
db-schema: #金仓达梦选填
prepare-url: #自定义url
@@ -78,13 +79,14 @@ spring:
# password: ${spring.datasource.password}
# driver-class-name: com.mysql.cj.jdbc.Driver
# ===================== Redis配置-Start =====================
# ===================== Redis配置 =====================
# redis单机模式
data:
redis:
database: 1 #缓存库编号
database: 10
host: 127.0.0.1
port: 6379
password: 123456 # 密码为空时,请将本行注释
# password: redis_JtjYRD # 密码为空时,请将本行注释
timeout: 3000 #超时时间(单位:秒)
lettuce: #Lettuce为Redis的Java驱动包
pool:
@@ -145,6 +147,32 @@ spring:
destination: MXK_IDENTITY_MAIN_TOPIC
group: maxkey_identity
# ===================== 单点登录(用户信息同步)配置-End =====================
# ===================== AI配置-Start =====================
ai:
openai:
enabled: true
# 超时时间, 秒, 根据AI平台性能调整超时时间
timeout: 300
# 阿里百联平台
api-host: https://dashscope.aliyuncs.com/compatible-mode/
api-key: sk-def0e6d9d0f8497cb5bcfff8c0c19935
chat:
mode: qwen-max
# GPT转发平台
# api-host: https://api.chatanywhere.tech/
# api-key:
# chat:
# mode: gpt-3.5-turbo
# DeepSeek
# api-host: https://api.deepseek.com/v1/
# api-key:
# chat:
# mode: deepseek-chat
# ===================== AI配置-End =====================
# SpringDoc接口文档 访问地址http://127.0.0.1:30000/doc.html
springdoc:
default-flat-param-object: true
@@ -177,7 +205,8 @@ config:
enable-storage: true #启用存储
enable-access: true #启用访问(线上请使用 Nginx 配置,效率更高)
domain: "" # 访问域名例如“http://127.0.0.1:8030/”,注意后面要和 path-patterns 保持一致,“/”结尾,本地存储建议使用相对路径,方便后期更换域名
base-path: D:/project/yunzhupaas-resources/ # 基础路径
# base-path: /data/work-data/upload/jnpfsoft/yunzhupaas-resources/ # 基础路径
base-path: E:/XiangMu/yunzhu/zero-resources/ # 基础路径
path-patterns: /** # 访问路径
storage-path: # 存储路径
aliyun-oss: # 阿里云 OSS ,不使用的情况下可以不写
@@ -311,26 +340,31 @@ oauth:
defaultSSO: cas
#后端登录接口地址
loginPath: http://127.0.0.1:30000/api/oauth/Login
#轮询登录模式是否输出结果
ticketOutMessage: false
login:
#login:
#JWT生成秘钥 不填写为默认值
#jwtSecretKey: WviMjFNC72VKwGqm5LPoheQo5XN9iN4d
sso:
#单点登录系统地址
baseUrl: http://127.0.0.1:8527
#登录成功后跳转到前端的页面
sucessFrontUrl: http://127.0.0.1:3000/sso
sucessFrontUrl: http://127.0.0.1:3100/sso
#错误信息是否输出到页面
ticketOutMessage: false
#logoutFrontUrl: http://sso.maxkey.top:8527/maxkey
#单点注销后端接口地址, 配置启用后YUNZHUPAAS退出会请求单点系统退出, 触发单点注销退出全部应用
#ssoLogoutApiUrl: ${oauth.sso.baseUrl}/sign/logout
auth2:
enabled: true
clientId: 747887288041603072
clientSecret: MYgMMjIwNzIwMjIxNTU4MTAxNzQlKQ
baseUrl: http://127.0.0.1:8527
baseUrl: ${oauth.sso.baseUrl}
authorizeUrl: ${oauth.sso.auth2.baseUrl}/sign/authz/oauth/v20/authorize
accessTokenUrl: ${oauth.sso.auth2.baseUrl}/sign/authz/oauth/v20/token
userInfoUrl: ${oauth.sso.auth2.baseUrl}/sign/api/oauth/v20/me
cas:
enabled: true
baseUrl: ${oauth.sso.auth2.baseUrl}
baseUrl: ${oauth.sso.baseUrl}
serverLoginUrl: ${oauth.sso.cas.baseUrl}/sign/authz/cas/login
serverValidateUrl: ${oauth.sso.cas.baseUrl}/sign/authz/cas
# ===================== 单点登录(SSO)配置-End =====================
userUrl: http://192.168.3.31:8000/api-web/sys/user/save

View File

@@ -2,7 +2,7 @@
server:
tomcat:
uri-encoding: UTF-8 #tomcat编码
port: 30000 #tomcat端口
port: 40001 #tomcat端口
spring:
messages:
@@ -24,9 +24,9 @@ spring:
# host: aliyun.szlecheng.cn
host: mysql.szlecheng.cn
port: 13306
username: yunzhupass
password: '@yunzhupass'
db-name: pord_yunzhupass
username: oa_yunzhupaas
password: OAYUNZHUPAAS
db-name: oa_yunzhupass
db-schema: #金仓达梦选填
prepare-url: #自定义url

View File

@@ -3,7 +3,7 @@ spring:
name: yunzhupaas-boot
profiles:
# 指定环境配置 dev(开发环境-默认)、test(测试环境)、preview(预生产)、prod(生产环境)
active: dev
active: test
servlet:
multipart: #文件传输配置
max-file-size: 100MB #单个数据大小限制

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.CrmOpportunityMapper">
<update id="updateByCustomerByCustomerId">
update crm_customer set last_followup_date=#{lastFollowupDate} where company_id=#{customerId}
</update>
<select id="selectCustomerBycustomerId" resultType="java.lang.String">
select company_name from mdm_company where company_id=#{customerId}
</select>
</mapper>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.BcmProjectTypeMapper">
</mapper>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.MdmCompanyMapper">
<mapper namespace="com.yunzhupaas.mdm.mapper.CompanyBankMapper">

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.mdm.mapper.CompanyInvoiceMapper">
</mapper>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.CrmLeadMapper">
<mapper namespace="com.yunzhupaas.mdm.mapper.CompanyMapper">

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.MdmProjectMapper">
<mapper namespace="com.yunzhupaas.mdm.mapper.CorporationMapper">

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.CrmCustomerMapper">
<mapper namespace="com.yunzhupaas.mdm.mapper.CustomersMapper">

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.mdm.mapper.MaterialMapper">
</mapper>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.MdmCompanyBankMapper">
</mapper>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.MdmCompanyContactMapper">
</mapper>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.MdmContractTypeMapper">
</mapper>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.mdm.mapper.PanyInvoiceMapper">
</mapper>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.mdm.mapper.ProductsMapper">
</mapper>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.mdm.mapper.SupplierMapper">
</mapper>

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.PcmContractMapper">
<insert id="addPcmDocument">
insert into pcm_document (document_id,file_size,file_name,file_ext_name,local_path)
values (#{fileId},#{fileSize},#{name},#{fileExtension},#{url})
</insert>
<insert id="addPcmBusinessDocument">
insert into pcm_business_document (table_name,business_object_id,document_id)
values (#{tableName},#{businessObjectId},#{documentId})
</insert>
<delete id="deleteByBusinessObjectId">
delete from pcm_business_document where business_object_id=#{businessObjectId} and table_name =#{tableName}
</delete>
<select id="selectByIdAndTableName" resultType="com.yunzhupaas.base.model.pcmcontract.PcmDocument">
select document.document_id fileId,document.file_size fileSize,document.
file_name 'name',document.file_ext_name fileExtension,document.local_path url
from pcm_business_document business
left join pcm_document document on business.document_id=document.document_id
where business.table_name=#{tableName} and business.business_object_id=#{id}
</select>
<select id="selectByFEnCode" resultType="java.lang.String">
select f_full_name from base_dictionary_data where f_en_code=#{resourcesName} and f_dictionary_type_id='808608974935952773'
</select>
</mapper>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.Pcm_contract_itemMapper">
</mapper>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yunzhupaas.base.mapper.Pcm_payment_planMapper">
</mapper>

View File

@@ -1,20 +0,0 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.CrmOpportunityEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* crm_opportunity
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-27
*/
public interface CrmOpportunityMapper extends SuperMapper<CrmOpportunityEntity> {
String selectCustomerBycustomerId(String customerId);
int updateByCustomerByCustomerId(CrmOpportunityEntity entity);
}

View File

@@ -1,31 +0,0 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.base.model.crmlead.*;
import java.util.*;
/**
* crm_lead
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-27
*/
public interface CrmLeadService extends SuperService<CrmLeadEntity> {
List<CrmLeadEntity> getList(CrmLeadPagination crmLeadPagination);
List<CrmLeadEntity> getTypeList(CrmLeadPagination crmLeadPagination,String dataType);
CrmLeadEntity getInfo(String leadid);
void delete(CrmLeadEntity entity);
void create(CrmLeadEntity entity);
boolean update(String leadid, CrmLeadEntity entity);
String checkForm(CrmLeadForm form,int i);
void saveOrUpdate(CrmLeadForm crmLeadForm,String id, boolean isSave) throws Exception;
}

View File

@@ -1,33 +0,0 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.base.model.crmopportunity.*;
import java.util.*;
/**
* crm_opportunity
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-27
*/
public interface CrmOpportunityService extends SuperService<CrmOpportunityEntity> {
List<CrmOpportunityEntity> getList(CrmOpportunityPagination crmOpportunityPagination);
List<CrmOpportunityEntity> getTypeList(CrmOpportunityPagination crmOpportunityPagination,String dataType);
CrmOpportunityEntity getInfo(String opportunityid);
void delete(CrmOpportunityEntity entity);
void create(CrmOpportunityEntity entity);
boolean update(String opportunityid, CrmOpportunityEntity entity);
String checkForm(CrmOpportunityForm form,int i);
void saveOrUpdate(CrmOpportunityForm crmOpportunityForm,String id, boolean isSave) throws Exception;
String selectCustomerBycustomerId(String customerId);
}

View File

@@ -1,33 +0,0 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.CrmCustomerMapper;
import com.yunzhupaas.base.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
/**
*
* mdm_company
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-27
*/
@Service
public class CrmCustomerServiceImpl extends SuperServiceImpl<CrmCustomerMapper, CrmCustomerEntity> implements CrmCustomerService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
}

View File

@@ -1,334 +0,0 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.CrmLeadMapper;
import com.yunzhupaas.base.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.model.crmlead.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* crm_lead
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-27
*/
@Service
public class CrmLeadServiceImpl extends SuperServiceImpl<CrmLeadMapper, CrmLeadEntity> implements CrmLeadService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<CrmLeadEntity> getList(CrmLeadPagination crmLeadPagination){
return getTypeList(crmLeadPagination,crmLeadPagination.getDataType());
}
/** 列表查询 */
@Override
public List<CrmLeadEntity> getTypeList(CrmLeadPagination crmLeadPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("crm_lead",CrmLeadEntity.class);
MPJLambdaWrapper<CrmLeadEntity> wrapper = JoinWrappers
.lambda("crm_lead",CrmLeadEntity.class)
.selectAll(CrmLeadEntity.class);
MPJLambdaWrapper<CrmLeadEntity> wrapper2 = JoinWrappers
.lambda("crm_lead",CrmLeadEntity.class)
.distinct().select(CrmLeadEntity::getLeadId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(CrmLeadConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? CrmLeadConstant.getAppColumnData() : CrmLeadConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(crmLeadPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = true;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(crmLeadPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(crmLeadPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(crmLeadPagination, wrapper, isPc);
otherConditions(crmLeadPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) crmLeadPagination.getCurrentPage(), (int) crmLeadPagination.getPageSize(), true);
List<CrmLeadEntity> userIPage = this.selectJoinList(CrmLeadEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getLeadId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(CrmLeadEntity::getLeadId,collect);
}
List<CrmLeadEntity> result = this.selectJoinList(CrmLeadEntity.class, wrapper);
return crmLeadPagination.setData(result,objects.getTotal());
}else{
List<CrmLeadEntity> list = this.selectJoinList(CrmLeadEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(crmLeadPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getLeadId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(CrmLeadPagination crmLeadPagination, MPJLambdaWrapper<CrmLeadEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
//假删除标志
wrapper.isNull(CrmLeadEntity::getDeleteMark);
wrapper.isNull(CrmLeadEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(crmLeadPagination.getYunzhupaasKeyword())){
if(isPc){
wrapper.and(t -> {
t.like(CrmLeadEntity::getMobile,crmLeadPagination.getYunzhupaasKeyword()).or();
});
}
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(crmLeadPagination.getMobile())){
String value = crmLeadPagination.getMobile() instanceof List ?
JsonUtil.getObjectToString(crmLeadPagination.getMobile()) :
String.valueOf(crmLeadPagination.getMobile());
wrapper.like(CrmLeadEntity::getMobile,value);
}
if(ObjectUtil.isNotEmpty(crmLeadPagination.getCustomerSource())){
List<String> idList = new ArrayList<>();
try {
String[][] customerSource = JsonUtil.getJsonToBean(crmLeadPagination.getCustomerSource(),String[][].class);
for(int i=0;i<customerSource.length;i++){
if(customerSource[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(customerSource[i])));
}
}
}catch (Exception e1){
try {
List<String> customerSource = JsonUtil.getJsonToList(crmLeadPagination.getCustomerSource(),String.class);
if(customerSource.size()>0){
idList.addAll(customerSource);
}
}catch (Exception e2){
idList.add(String.valueOf(crmLeadPagination.getCustomerSource()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(CrmLeadEntity::getCustomerSource, tt).or();
});
});
}
}
//排序
if(StringUtil.isEmpty(crmLeadPagination.getSidx())){
wrapper.orderByDesc(CrmLeadEntity::getLeadId);
}else{
try {
String[] split = crmLeadPagination.getSidx().split(",");
for(String sidx:split){
CrmLeadEntity crmLeadEntity = new CrmLeadEntity();
String oderTableField = crmLeadEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = crmLeadEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public CrmLeadEntity getInfo(String leadid){
MPJLambdaWrapper<CrmLeadEntity> wrapper = JoinWrappers
.lambda("crm_lead",CrmLeadEntity.class)
.selectAll(CrmLeadEntity.class);
wrapper.and(
t->t.eq(CrmLeadEntity::getLeadId, leadid )
.or().eq(CrmLeadEntity::getFlowTaskId, leadid)
);
return this.selectJoinOne(CrmLeadEntity.class,wrapper);
}
@Override
public void create(CrmLeadEntity entity){
this.save(entity);
}
@Override
public boolean update(String leadid, CrmLeadEntity entity){
return this.updateById(entity);
}
@Override
public void delete(CrmLeadEntity entity){
if(entity!=null){
this.removeById(entity.getLeadId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(CrmLeadForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getLeadId()) && !form.getLeadId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getLeadId();
}
//主表字段验证
fieldTipName = "线索名称";
if(StringUtil.isEmpty(form.getLeadName())){
return fieldTipName + canNotNull;
}
fieldTipName = "手机号";
if(StringUtil.isEmpty(form.getMobile())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getMobile())){
form.setMobile(form.getMobile().trim());
QueryWrapper<CrmLeadEntity> mobileWrapper=new QueryWrapper<>();
mobileWrapper.lambda().eq(CrmLeadEntity::getMobile,form.getMobile());
mobileWrapper.lambda().isNull(CrmLeadEntity::getFlowId);
//假删除标志
mobileWrapper.lambda().isNull(CrmLeadEntity::getDeleteMark);
if (isUp){
mobileWrapper.lambda().ne(CrmLeadEntity::getLeadId, id);
}
if((int) this.count(mobileWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
if(StringUtil.isNotEmpty(form.getMobile())){
if(!Pattern.compile("^1[3456789]\\d{9}$").matcher(String.valueOf(form.getMobile())).matches()){
return I18nUtil.getMessageStr("sys.validate.mobilePhone", "请输入正确的手机号码");
}
}
fieldTipName = "邮箱";
if(StringUtil.isNotEmpty(form.getEmail())){
if(!Pattern.compile("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$").matcher(String.valueOf(form.getEmail())).matches()){
return I18nUtil.getMessageStr("sys.validate.email", "请输入正确的邮箱");
}
}
fieldTipName = "状态";
fieldTipName = "销售人员";
fieldTipName = "来源";
fieldTipName = "备注";
return countRecover;
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param crmLeadForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(CrmLeadForm crmLeadForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
crmLeadForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(CrmLeadConstant.getFormData(),crmLeadForm,CrmLeadConstant.TABLERENAMES),CrmLeadForm.class);
CrmLeadEntity entity = JsonUtil.getJsonToBean(crmLeadForm, CrmLeadEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setLeadId(mainUuid);
entity.setVersion(0);
} else {
}
boolean b = this.saveOrUpdate(entity);
if(!b){
throw new DataException("当前表单原数据已被调整,请重新进入该页面编辑并提交数据");
}
CrmLeadEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
}
}

View File

@@ -1,338 +0,0 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.CrmOpportunityMapper;
import com.yunzhupaas.base.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.model.crmopportunity.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* crm_opportunity
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-27
*/
@Service
public class CrmOpportunityServiceImpl extends SuperServiceImpl<CrmOpportunityMapper, CrmOpportunityEntity> implements CrmOpportunityService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<CrmOpportunityEntity> getList(CrmOpportunityPagination crmOpportunityPagination){
return getTypeList(crmOpportunityPagination,crmOpportunityPagination.getDataType());
}
/** 列表查询 */
@Override
public List<CrmOpportunityEntity> getTypeList(CrmOpportunityPagination crmOpportunityPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("crm_opportunity",CrmOpportunityEntity.class);
tableClassMap.put("crm_customer",CrmCustomerEntity.class);
MPJLambdaWrapper<CrmOpportunityEntity> wrapper = JoinWrappers
.lambda("crm_opportunity",CrmOpportunityEntity.class)
.selectAssociation(CrmCustomerEntity.class,CrmOpportunityEntity::getCrmCustomer)
.leftJoin(CrmCustomerEntity.class,"crm_customer",CrmCustomerEntity::getCustomerId,CrmOpportunityEntity::getCustomerId)
.selectAll(CrmOpportunityEntity.class);
MPJLambdaWrapper<CrmOpportunityEntity> wrapper2 = JoinWrappers
.lambda("crm_opportunity",CrmOpportunityEntity.class)
.leftJoin(CrmCustomerEntity.class,"crm_customer",CrmCustomerEntity::getCustomerId,CrmOpportunityEntity::getCustomerId)
.distinct().select(CrmOpportunityEntity::getOpportunityId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(CrmOpportunityConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? CrmOpportunityConstant.getAppColumnData() : CrmOpportunityConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(crmOpportunityPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = false;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(crmOpportunityPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(crmOpportunityPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(crmOpportunityPagination, wrapper, isPc);
otherConditions(crmOpportunityPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) crmOpportunityPagination.getCurrentPage(), (int) crmOpportunityPagination.getPageSize(), true);
List<CrmOpportunityEntity> userIPage = this.selectJoinList(CrmOpportunityEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getOpportunityId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(CrmOpportunityEntity::getOpportunityId,collect);
}
List<CrmOpportunityEntity> result = this.selectJoinList(CrmOpportunityEntity.class, wrapper);
return crmOpportunityPagination.setData(result,objects.getTotal());
}else{
List<CrmOpportunityEntity> list = this.selectJoinList(CrmOpportunityEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(crmOpportunityPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getOpportunityId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(CrmOpportunityPagination crmOpportunityPagination, MPJLambdaWrapper<CrmOpportunityEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
//假删除标志
wrapper.isNull(CrmOpportunityEntity::getDeleteMark);
wrapper.isNull(CrmOpportunityEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(crmOpportunityPagination.getYunzhupaasKeyword())){
if(isPc){
wrapper.and(t -> {
t.like(CrmOpportunityEntity::getOpportunityName,crmOpportunityPagination.getYunzhupaasKeyword()).or();
});
}
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(crmOpportunityPagination.getOpportunityName())){
String value = crmOpportunityPagination.getOpportunityName() instanceof List ?
JsonUtil.getObjectToString(crmOpportunityPagination.getOpportunityName()) :
String.valueOf(crmOpportunityPagination.getOpportunityName());
wrapper.like(CrmOpportunityEntity::getOpportunityName,value);
}
if(ObjectUtil.isNotEmpty(crmOpportunityPagination.getOpportunityStage())){
List<String> idList = new ArrayList<>();
try {
String[][] opportunityStage = JsonUtil.getJsonToBean(crmOpportunityPagination.getOpportunityStage(),String[][].class);
for(int i=0;i<opportunityStage.length;i++){
if(opportunityStage[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(opportunityStage[i])));
}
}
}catch (Exception e1){
try {
List<String> opportunityStage = JsonUtil.getJsonToList(crmOpportunityPagination.getOpportunityStage(),String.class);
if(opportunityStage.size()>0){
idList.addAll(opportunityStage);
}
}catch (Exception e2){
idList.add(String.valueOf(crmOpportunityPagination.getOpportunityStage()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(CrmOpportunityEntity::getOpportunityStage, tt).or();
});
});
}
if(ObjectUtil.isNotEmpty(crmOpportunityPagination.getCloseDate())){
List CloseDateList = JsonUtil.getJsonToList(crmOpportunityPagination.getCloseDate(),String.class);
for(int i=0;i<CloseDateList.size();i++){
String id = String.valueOf(CloseDateList.get(i));
boolean idAll = StringUtil.isNotEmpty(id) && !id.equals("null");
if(idAll){
Object b= new Date(Long.valueOf(id));
if(i==0){
wrapper.ge(CrmOpportunityEntity::getCloseDate,b);
}else{
wrapper.le(CrmOpportunityEntity::getCloseDate,b);
}
}
}
}
}
//排序
if(StringUtil.isEmpty(crmOpportunityPagination.getSidx())){
wrapper.orderByDesc(CrmOpportunityEntity::getOpportunityId);
}else{
try {
String[] split = crmOpportunityPagination.getSidx().split(",");
for(String sidx:split){
CrmOpportunityEntity crmOpportunityEntity = new CrmOpportunityEntity();
String oderTableField = crmOpportunityEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = crmOpportunityEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public CrmOpportunityEntity getInfo(String opportunityid){
MPJLambdaWrapper<CrmOpportunityEntity> wrapper = JoinWrappers
.lambda("crm_opportunity",CrmOpportunityEntity.class)
.selectAssociation(CrmCustomerEntity.class,CrmOpportunityEntity::getCrmCustomer)
.leftJoin(CrmCustomerEntity.class,"crm_customer",CrmCustomerEntity::getCustomerId,CrmOpportunityEntity::getCustomerId)
.selectAll(CrmOpportunityEntity.class);
wrapper.and(
t->t.eq(CrmOpportunityEntity::getOpportunityId, opportunityid )
.or().eq(CrmOpportunityEntity::getFlowTaskId, opportunityid)
);
return this.selectJoinOne(CrmOpportunityEntity.class,wrapper);
}
@Override
public void create(CrmOpportunityEntity entity){
this.save(entity);
}
@Override
public boolean update(String opportunityid, CrmOpportunityEntity entity){
return this.updateById(entity);
}
@Override
public void delete(CrmOpportunityEntity entity){
if(entity!=null){
this.removeById(entity.getOpportunityId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(CrmOpportunityForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getOpportunityId()) && !form.getOpportunityId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getOpportunityId();
}
//主表字段验证
fieldTipName = "商机编码";
fieldTipName = "商机名称";
fieldTipName = "客户";
fieldTipName = "商机负责人";
fieldTipName = "商机阶段";
fieldTipName = "预计金额";
fieldTipName = "预计成交日期";
fieldTipName = "商机简介";
fieldTipName = "赢单概率";
fieldTipName = "最后跟进日期";
fieldTipName = "竞争对手信息";
fieldTipName = "决策分析";
fieldTipName = "备注";
return countRecover;
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param crmOpportunityForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(CrmOpportunityForm crmOpportunityForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
crmOpportunityForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(CrmOpportunityConstant.getFormData(),crmOpportunityForm,CrmOpportunityConstant.TABLERENAMES),CrmOpportunityForm.class);
CrmOpportunityEntity entity = JsonUtil.getJsonToBean(crmOpportunityForm, CrmOpportunityEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setOpportunityId(mainUuid);
entity.setVersion(0);
} else {
}
boolean b = this.saveOrUpdate(entity);
int i = this.baseMapper.updateByCustomerByCustomerId(entity);
if(!b){
throw new DataException("当前表单原数据已被调整,请重新进入该页面编辑并提交数据");
}
CrmOpportunityEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
}
@Override
public String selectCustomerBycustomerId(String customerId) {
return this.baseMapper.selectCustomerBycustomerId(customerId);
}
}

View File

@@ -1,238 +0,0 @@
package com.yunzhupaas.base.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.base.service.*;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.base.model.crmopportunity.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunzhupaas.flowable.entity.TaskEntity;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import com.yunzhupaas.flowable.entity.TaskEntity;
import com.yunzhupaas.exception.WorkFlowException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* crm_opportunity
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Slf4j
@RestController
@Tag(name = "crm_opportunity" , description = "bcm")
@RequestMapping("/api/bcm/CrmOpportunity")
public class CrmOpportunityController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private CrmOpportunityService crmOpportunityService;
/**
* 列表
*
* @param crmOpportunityPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody CrmOpportunityPagination crmOpportunityPagination)throws Exception{
List<CrmOpportunityEntity> list= crmOpportunityService.getList(crmOpportunityPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (CrmOpportunityEntity entity : list) {
Map<String, Object> crmOpportunityMap=JsonUtil.entityToMap(entity);
crmOpportunityMap.put("id", crmOpportunityMap.get("opportunity_id"));
//副表数据
//子表数据
realList.add(crmOpportunityMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, CrmOpportunityConstant.getFormData(), CrmOpportunityConstant.getColumnData(), crmOpportunityPagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(crmOpportunityPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param crmOpportunityForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid CrmOpportunityForm crmOpportunityForm) {
String b = crmOpportunityService.checkForm(crmOpportunityForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
crmOpportunityService.saveOrUpdate(crmOpportunityForm, null ,true);
}catch(Exception e){
log.error("【商机信息创建接口异常】参数:{}", crmOpportunityForm, e);
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
CrmOpportunityEntity entity= crmOpportunityService.getInfo(id);
if(entity!=null){
//假删除
entity.setDeleteMark(1);
entity.setDeleteUserId(userProvider.get().getUserId());
entity.setDeleteTime(new Date());
crmOpportunityService.setIgnoreLogicDelete().updateById(entity);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param crmOpportunityForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid CrmOpportunityForm crmOpportunityForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
CrmOpportunityEntity entity= crmOpportunityService.getInfo(id);
if(entity!=null){
crmOpportunityForm.setOpportunityId(String.valueOf(entity.getOpportunityId()));
if (!isImport) {
String b = crmOpportunityService.checkForm(crmOpportunityForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
crmOpportunityService.saveOrUpdate(crmOpportunityForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
log.error("【商机信息编辑接口异常】参数:{}", crmOpportunityForm, e);
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
CrmOpportunityEntity entity= crmOpportunityService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> crmOpportunityMap=JsonUtil.entityToMap(entity);
crmOpportunityMap.put("id", crmOpportunityMap.get("opportunity_id"));
//副表数据
//子表数据
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
crmOpportunityMap = generaterSwapUtil.swapDataDetail(crmOpportunityMap,CrmOpportunityConstant.getFormData(),"807147983731689285",isPc?false:false);
//子表数据
return ActionResult.success(crmOpportunityMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
CrmOpportunityEntity entity= crmOpportunityService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> crmOpportunityMap=JsonUtil.entityToMap(entity);
crmOpportunityMap.put("id", crmOpportunityMap.get("opportunity_id"));
String customerName =crmOpportunityService.selectCustomerBycustomerId(entity.getCustomerId());
crmOpportunityMap.put("customerName", customerName);
//副表数据
//子表数据
crmOpportunityMap = generaterSwapUtil.swapDataForm(crmOpportunityMap,CrmOpportunityConstant.getFormData(),CrmOpportunityConstant.TABLEFIELDKEY,CrmOpportunityConstant.TABLERENAMES);
return ActionResult.success(crmOpportunityMap);
}
}

View File

@@ -1,81 +0,0 @@
package com.yunzhupaas.base.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
/**
* 客户信息
*
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Data
@TableName("crm_customer")
public class CrmCustomerEntity {
@TableId(value ="customer_id" )
@JSONField(name = "customer_id")
private String customerId;
@TableField("company_id")
@JSONField(name = "company_id")
private String companyId;
@TableField(value = "org_id" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "org_id")
private String orgId;
@TableField(value = "owner_id" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "owner_id")
private String ownerId;
@TableField(value = "customer_level" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "customer_level")
private String customerLevel;
@TableField(value = "customer_lifecycle" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "customer_lifecycle")
private String customerLifecycle;
@TableField(value = "is_public" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "is_public")
private String isPublic;
@TableField(value = "last_followup_date" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "last_followup_date")
private Date lastFollowupDate;
@TableField("remark")
@JSONField(name = "remark")
private String remark;
@TableField("create_by")
@JSONField(name = "create_by")
private String createBy;
@TableField("create_time")
@JSONField(name = "create_time")
private Date createTime;
@TableField("update_by")
@JSONField(name = "update_by")
private String updateBy;
@TableField("update_time")
@JSONField(name = "update_time")
private Date updateTime;
@TableField("f_flow_id")
@JSONField(name = "f_flow_id")
private String flowId;
@TableField("f_flow_task_id")
@JSONField(name = "f_flow_task_id")
private String flowTaskId;
@TableField("f_delete_mark")
@JSONField(name = "f_delete_mark")
private Integer deleteMark;
@TableField("f_delete_time")
@JSONField(name = "f_delete_time")
private Date deleteTime;
@TableField("f_delete_user_id")
@JSONField(name = "f_delete_user_id")
private String deleteUserId;
@TableField("f_version")
@Version
@JSONField(name = "f_version")
private Integer version;
@TableField(value = "f_tenant_id",fill = FieldFill.INSERT_UPDATE)
@JSONField(name = "f_tenant_id")
private String tenantId;
}

View File

@@ -1,81 +0,0 @@
package com.yunzhupaas.base.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
/**
*
*
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Data
@TableName("crm_lead")
public class CrmLeadEntity {
@TableId(value ="lead_id" )
@JSONField(name = "lead_id")
private String leadId;
@TableField(value = "lead_name" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "lead_name")
private String leadName;
@TableField(value = "mobile" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "mobile")
private String mobile;
@TableField(value = "email" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "email")
private String email;
@TableField(value = "lead_status" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "lead_status")
private String leadStatus;
@TableField(value = "sales_id" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "sales_id")
private String salesId;
@TableField(value = "customer_source" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "customer_source")
private String customerSource;
@TableField("customer_id")
@JSONField(name = "customer_id")
private String customerId;
@TableField(value = "remark" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "remark")
private String remark;
@TableField("create_by")
@JSONField(name = "create_by")
private String createBy;
@TableField("create_time")
@JSONField(name = "create_time")
private Date createTime;
@TableField("update_by")
@JSONField(name = "update_by")
private String updateBy;
@TableField("update_time")
@JSONField(name = "update_time")
private Date updateTime;
@TableField("f_flow_id")
@JSONField(name = "f_flow_id")
private String flowId;
@TableField("f_flow_task_id")
@JSONField(name = "f_flow_task_id")
private String flowTaskId;
@TableField("f_delete_mark")
@JSONField(name = "f_delete_mark")
private Integer deleteMark;
@TableField("f_delete_time")
@JSONField(name = "f_delete_time")
private Date deleteTime;
@TableField("f_delete_user_id")
@JSONField(name = "f_delete_user_id")
private String deleteUserId;
@TableField("f_version")
@Version
@JSONField(name = "f_version")
private Integer version;
@TableField(value = "f_tenant_id",fill = FieldFill.INSERT_UPDATE)
@JSONField(name = "f_tenant_id")
private String tenantId;
}

View File

@@ -1,100 +0,0 @@
package com.yunzhupaas.base.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
import java.math.BigDecimal;
/**
* 商机信息
*
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Data
@TableName("crm_opportunity")
public class CrmOpportunityEntity {
@TableId(value ="opportunity_id" )
@JSONField(name = "opportunity_id")
private String opportunityId;
@TableField(value = "customer_id" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "customer_id")
private String customerId;
@TableField(value = "opportunity_code" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "opportunity_code")
private String opportunityCode;
@TableField(value = "opportunity_name" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "opportunity_name")
private String opportunityName;
@TableField(value = "owner_id" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "owner_id")
private String ownerId;
@TableField(value = "opportunity_stage" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "opportunity_stage")
private String opportunityStage;
@TableField(value = "desciption" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "desciption")
private String desciption;
@TableField(value = "amount" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "amount")
private BigDecimal amount;
@TableField(value = "close_date" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "close_date")
private Date closeDate;
@TableField(value = "probability" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "probability")
private Byte probability;
@TableField(value = "last_followup_date" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "last_followup_date")
private Date lastFollowupDate;
@TableField(value = "competitor" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "competitor")
private String competitor;
@TableField(value = "analysis" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "analysis")
private String analysis;
@TableField(value = "remark" , updateStrategy = FieldStrategy.IGNORED)
@JSONField(name = "remark")
private String remark;
@TableField("create_by")
@JSONField(name = "create_by")
private String createBy;
@TableField("create_time")
@JSONField(name = "create_time")
private Date createTime;
@TableField("update_by")
@JSONField(name = "update_by")
private String updateBy;
@TableField("update_time")
@JSONField(name = "update_time")
private Date updateTime;
@TableField("f_flow_id")
@JSONField(name = "f_flow_id")
private String flowId;
@TableField("f_flow_task_id")
@JSONField(name = "f_flow_task_id")
private String flowTaskId;
@TableField("f_delete_mark")
@JSONField(name = "f_delete_mark")
private Integer deleteMark;
@TableField("f_delete_time")
@JSONField(name = "f_delete_time")
private Date deleteTime;
@TableField("f_delete_user_id")
@JSONField(name = "f_delete_user_id")
private String deleteUserId;
@TableField("f_version")
@Version
@JSONField(name = "f_version")
private Integer version;
@TableField(value = "f_tenant_id",fill = FieldFill.INSERT_UPDATE)
@JSONField(name = "f_tenant_id")
private String tenantId;
@JSONField(name = "crmCustomer")
@TableField(exist = false)
private CrmCustomerEntity crmCustomer;
}

View File

@@ -1,25 +0,0 @@
package com.yunzhupaas.base.model.crmCustomer;
import lombok.Data;
import java.sql.Time;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.alibaba.fastjson.annotation.JSONField;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import java.math.BigDecimal;
import java.util.List;
/**
*
* mdm_company
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Data
public class CrmCustomerExcelVO{
}

View File

@@ -1,58 +0,0 @@
package com.yunzhupaas.base.model.crmCustomer;
import lombok.Data;
import java.util.List;
import java.util.Date;
import java.math.BigDecimal;
import com.alibaba.fastjson.annotation.JSONField;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
/**
*
* mdm_company
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-27
*/
@Data
@Schema(description = "CrmCustomer子表参数")
public class CrmCustomerModel {
/** 子表CrmCustomer 主键customer_id **/
@Schema(description = "主键")
@JsonProperty("customer_id")
private String customer_id;
/** 客户负责人 **/
@Schema(description = "客户负责人")
@JsonProperty("owner_id")
@JSONField(name = "owner_id")
private Object ownerId;
/** 归属组织 **/
@Schema(description = "归属组织")
@JsonProperty("org_id")
@JSONField(name = "org_id")
private Object orgId;
/** 客户等级 **/
@Schema(description = "客户等级")
@JsonProperty("customer_level")
@JSONField(name = "customer_level")
private Object customerLevel;
/** 生命周期阶段 **/
@Schema(description = "生命周期阶段")
@JsonProperty("customer_lifecycle")
@JSONField(name = "customer_lifecycle")
private Object customerLifecycle;
/** 是否公海客户 **/
@Schema(description = "是否公海客户")
@JsonProperty("is_public")
@JSONField(name = "is_public")
private Object isPublic;
/** 最后一次跟进日期 **/
@Schema(description = "最后一次跟进日期")
@JsonProperty("last_followup_date")
@JSONField(name = "last_followup_date")
private Long lastFollowupDate;
}

View File

@@ -1,60 +0,0 @@
package com.yunzhupaas.base.model.crmlead;
import lombok.Data;
import java.sql.Time;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.alibaba.fastjson.annotation.JSONField;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import java.math.BigDecimal;
import java.util.List;
/**
*
* crm_lead
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Data
public class CrmLeadExcelVO{
/** 线索名称 **/
@JSONField(name = "lead_name")
@Excel(name = "线索名称(lead_name)",orderNum = "1", isImportField = "true" )
private String lead_name;
/** 手机号 **/
@JSONField(name = "mobile")
@Excel(name = "手机号(mobile)",orderNum = "1", isImportField = "true" )
private String mobile;
/** 状态 **/
@JSONField(name = "lead_status")
@Excel(name = "状态(lead_status)",orderNum = "1", isImportField = "true" )
private String lead_status;
/** 销售人员 **/
@JSONField(name = "sales_id")
@Excel(name = "销售人员(sales_id)",orderNum = "1", isImportField = "true" )
private String sales_id;
/** 备注 **/
@JSONField(name = "remark")
@Excel(name = "备注(remark)",orderNum = "1", isImportField = "true" )
private String remark;
/** 邮箱 **/
@JSONField(name = "email")
@Excel(name = "邮箱(email)",orderNum = "1", isImportField = "true" )
private String email;
/** 来源 **/
@JSONField(name = "customer_source")
@Excel(name = "来源(customer_source)",orderNum = "1", isImportField = "true" )
private String customer_source;
}

View File

@@ -1,67 +0,0 @@
package com.yunzhupaas.base.model.crmlead;
import lombok.Data;
import java.util.*;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* crm_lead
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Data
@Schema(description = "表单参数")
public class CrmLeadForm {
/** 主键 */
@Schema(description = "主键")
@JSONField(name = "lead_id")
private String leadId;
/** 乐观锁 **/
@Schema(description = "乐观锁")
@JsonProperty("f_version")
@JSONField(name = "f_version")
private Integer version;
/** 线索名称 **/
@Schema(description = "线索名称")
@JsonProperty("lead_name")
@JSONField(name = "lead_name")
private String leadName;
/** 手机号 **/
@Schema(description = "手机号")
@JsonProperty("mobile")
@JSONField(name = "mobile")
private String mobile;
/** 邮箱 **/
@Schema(description = "邮箱")
@JsonProperty("email")
@JSONField(name = "email")
private String email;
/** 状态 **/
@Schema(description = "状态")
@JsonProperty("lead_status")
@JSONField(name = "lead_status")
private Object leadStatus;
/** 销售人员 **/
@Schema(description = "销售人员")
@JsonProperty("sales_id")
@JSONField(name = "sales_id")
private Object salesId;
/** 来源 **/
@Schema(description = "来源")
@JsonProperty("customer_source")
@JSONField(name = "customer_source")
private Object customerSource;
/** 备注 **/
@Schema(description = "备注")
@JsonProperty("remark")
@JSONField(name = "remark")
private String remark;
}

View File

@@ -1,22 +0,0 @@
package com.yunzhupaas.base.model.crmopportunity;
import lombok.Data;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.fastjson.annotation.JSONField;
/**
*
* crm_opportunity
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Data
public class CrmOpportunityExcelErrorVO extends CrmOpportunityExcelVO{
@Excel(name = "异常原因",orderNum = "-999")
@JSONField(name = "errorsInfo")
private String errorsInfo;
}

View File

@@ -1,25 +0,0 @@
package com.yunzhupaas.base.model.crmopportunity;
import lombok.Data;
import java.sql.Time;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.alibaba.fastjson.annotation.JSONField;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import java.math.BigDecimal;
import java.util.List;
/**
*
* crm_opportunity
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Data
public class CrmOpportunityExcelVO{
}

View File

@@ -1,97 +0,0 @@
package com.yunzhupaas.base.model.crmopportunity;
import lombok.Data;
import java.util.*;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* crm_opportunity
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-27
*/
@Data
@Schema(description = "表单参数")
public class CrmOpportunityForm {
/** 主键 */
@Schema(description = "主键")
@JSONField(name = "opportunity_id")
private String opportunityId;
/** 乐观锁 **/
@Schema(description = "乐观锁")
@JsonProperty("f_version")
@JSONField(name = "f_version")
private Integer version;
/** 商机编码 **/
@Schema(description = "商机编码")
@JsonProperty("opportunity_code")
@JSONField(name = "opportunity_code")
private String opportunityCode;
/** 商机名称 **/
@Schema(description = "商机名称")
@JsonProperty("opportunity_name")
@JSONField(name = "opportunity_name")
private String opportunityName;
/** 客户 **/
@Schema(description = "客户")
@JsonProperty("customer_id")
@JSONField(name = "customer_id")
private String customerId;
/** 商机负责人 **/
@Schema(description = "商机负责人")
@JsonProperty("owner_id")
@JSONField(name = "owner_id")
private Object ownerId;
/** 商机阶段 **/
@Schema(description = "商机阶段")
@JsonProperty("opportunity_stage")
@JSONField(name = "opportunity_stage")
private Object opportunityStage;
/** 预计金额 **/
@Schema(description = "预计金额")
@JsonProperty("amount")
@JSONField(name = "amount")
private BigDecimal amount;
/** 预计成交日期 **/
@Schema(description = "预计成交日期")
@JsonProperty("close_date")
@JSONField(name = "close_date")
private String closeDate;
/** 商机简介 **/
@Schema(description = "商机简介")
@JsonProperty("desciption")
@JSONField(name = "desciption")
private String desciption;
/** 赢单概率 **/
@Schema(description = "赢单概率")
@JsonProperty("probability")
@JSONField(name = "probability")
private BigDecimal probability;
/** 最后跟进日期 **/
@Schema(description = "最后跟进日期")
@JsonProperty("last_followup_date")
@JSONField(name = "last_followup_date")
private String lastFollowupDate;
/** 竞争对手信息 **/
@Schema(description = "竞争对手信息")
@JsonProperty("competitor")
@JSONField(name = "competitor")
private String competitor;
/** 决策分析 **/
@Schema(description = "决策分析")
@JsonProperty("analysis")
@JSONField(name = "analysis")
private String analysis;
/** 备注 **/
@Schema(description = "备注")
@JsonProperty("remark")
@JSONField(name = "remark")
private String remark;
}

View File

@@ -1,17 +0,0 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.MdmCompanyBankEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 企业信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-26
*/
public interface MdmCompanyBankMapper extends SuperMapper<MdmCompanyBankEntity> {
}

View File

@@ -1,17 +0,0 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.MdmCompanyContactEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 企业信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-26
*/
public interface MdmCompanyContactMapper extends SuperMapper<MdmCompanyContactEntity> {
}

View File

@@ -1,17 +0,0 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.MdmContractTypeEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* mdmContractType
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-30
*/
public interface MdmContractTypeMapper extends SuperMapper<MdmContractTypeEntity> {
}

View File

@@ -1,33 +0,0 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.base.model.bcmprojecttype.*;
import java.util.*;
/**
* 项目类型
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-26
*/
public interface BcmProjectTypeService extends SuperService<BcmProjectTypeEntity> {
List<BcmProjectTypeEntity> getList(BcmProjectTypePagination bcmProjectTypePagination);
List<BcmProjectTypeEntity> getTypeList(BcmProjectTypePagination bcmProjectTypePagination,String dataType);
BcmProjectTypeEntity getInfo(String projecttypeid);
void delete(BcmProjectTypeEntity entity);
void create(BcmProjectTypeEntity entity);
boolean update(String projecttypeid, BcmProjectTypeEntity entity);
String checkForm(BcmProjectTypeForm form,int i);
void saveOrUpdate(BcmProjectTypeForm bcmProjectTypeForm,String id, boolean isSave) throws Exception;
List<BcmProjectTypeEntity> getBcmprojecttypeList(BcmProjectTypePagination bcmProjectTypePagination);
}

View File

@@ -1,31 +0,0 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.base.model.mdmcompany.*;
import java.util.*;
/**
* 企业信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-26
*/
public interface MdmCompanyService extends SuperService<MdmCompanyEntity> {
List<MdmCompanyEntity> getList(MdmCompanyPagination mdmCompanyPagination);
List<MdmCompanyEntity> getTypeList(MdmCompanyPagination mdmCompanyPagination,String dataType);
MdmCompanyEntity getInfo(String companyid);
void delete(MdmCompanyEntity entity);
void create(MdmCompanyEntity entity);
boolean update(String companyid, MdmCompanyEntity entity);
String checkForm(MdmCompanyForm form,int i);
void saveOrUpdate(MdmCompanyForm mdmCompanyForm,String id, boolean isSave) throws Exception;
}

View File

@@ -1,31 +0,0 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.base.model.mdmcontracttype.*;
import java.util.*;
/**
* mdmContractType
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-30
*/
public interface MdmContractTypeService extends SuperService<MdmContractTypeEntity> {
List<MdmContractTypeEntity> getList(MdmContractTypePagination mdmContractTypePagination);
List<MdmContractTypeEntity> getTypeList(MdmContractTypePagination mdmContractTypePagination,String dataType);
MdmContractTypeEntity getInfo(String id);
void delete(MdmContractTypeEntity entity);
void create(MdmContractTypeEntity entity);
boolean update(String id, MdmContractTypeEntity entity);
String checkForm(MdmContractTypeForm form,int i);
void saveOrUpdate(MdmContractTypeForm mdmContractTypeForm,String id, boolean isSave) throws Exception;
}

View File

@@ -1,31 +0,0 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.base.model.mdmproject.*;
import java.util.*;
/**
* 项目结构
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-26
*/
public interface MdmProjectService extends SuperService<MdmProjectEntity> {
List<MdmProjectEntity> getList(MdmProjectPagination mdmProjectPagination);
List<MdmProjectEntity> getTypeList(MdmProjectPagination mdmProjectPagination,String dataType);
MdmProjectEntity getInfo(String projectid);
void delete(MdmProjectEntity entity);
void create(MdmProjectEntity entity);
boolean update(String projectid, MdmProjectEntity entity);
String checkForm(MdmProjectForm form,int i);
void saveOrUpdate(MdmProjectForm mdmProjectForm,String id, boolean isSave) throws Exception;
}

View File

@@ -1,331 +0,0 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.BcmProjectTypeMapper;
import com.yunzhupaas.base.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.model.bcmprojecttype.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* 项目类型
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-26
*/
@Service
public class BcmProjectTypeServiceImpl extends SuperServiceImpl<BcmProjectTypeMapper, BcmProjectTypeEntity> implements BcmProjectTypeService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<BcmProjectTypeEntity> getList(BcmProjectTypePagination bcmProjectTypePagination){
return getTypeList(bcmProjectTypePagination,bcmProjectTypePagination.getDataType());
}
/** 列表查询 */
@Override
public List<BcmProjectTypeEntity> getTypeList(BcmProjectTypePagination bcmProjectTypePagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("bcm_project_type",BcmProjectTypeEntity.class);
MPJLambdaWrapper<BcmProjectTypeEntity> wrapper = JoinWrappers
.lambda("bcm_project_type",BcmProjectTypeEntity.class)
.selectAll(BcmProjectTypeEntity.class);
MPJLambdaWrapper<BcmProjectTypeEntity> wrapper2 = JoinWrappers
.lambda("bcm_project_type",BcmProjectTypeEntity.class)
.distinct().select(BcmProjectTypeEntity::getProjectTypeId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(BcmProjectTypeConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? BcmProjectTypeConstant.getAppColumnData() : BcmProjectTypeConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(bcmProjectTypePagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = false;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(bcmProjectTypePagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(bcmProjectTypePagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(bcmProjectTypePagination, wrapper, isPc);
otherConditions(bcmProjectTypePagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) bcmProjectTypePagination.getCurrentPage(), (int) bcmProjectTypePagination.getPageSize(), true);
List<BcmProjectTypeEntity> userIPage = this.selectJoinList(BcmProjectTypeEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getProjectTypeId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(BcmProjectTypeEntity::getProjectTypeId,collect);
}
List<BcmProjectTypeEntity> result = this.selectJoinList(BcmProjectTypeEntity.class, wrapper);
return bcmProjectTypePagination.setData(result,objects.getTotal());
}else{
List<BcmProjectTypeEntity> list = this.selectJoinList(BcmProjectTypeEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(bcmProjectTypePagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getProjectTypeId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(BcmProjectTypePagination bcmProjectTypePagination, MPJLambdaWrapper<BcmProjectTypeEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
//假删除标志
wrapper.isNull(BcmProjectTypeEntity::getDeleteMark);
wrapper.isNull(BcmProjectTypeEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(bcmProjectTypePagination.getYunzhupaasKeyword())){
}
//普通查询
//排序
if(StringUtil.isEmpty(bcmProjectTypePagination.getSidx())){
wrapper.orderByDesc(BcmProjectTypeEntity::getProjectTypeId);
}else{
try {
String[] split = bcmProjectTypePagination.getSidx().split(",");
for(String sidx:split){
BcmProjectTypeEntity bcmProjectTypeEntity = new BcmProjectTypeEntity();
String oderTableField = bcmProjectTypeEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = bcmProjectTypeEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public BcmProjectTypeEntity getInfo(String projecttypeid){
MPJLambdaWrapper<BcmProjectTypeEntity> wrapper = JoinWrappers
.lambda("bcm_project_type",BcmProjectTypeEntity.class)
.selectAll(BcmProjectTypeEntity.class);
wrapper.and(
t->t.eq(BcmProjectTypeEntity::getProjectTypeId, projecttypeid )
.or().eq(BcmProjectTypeEntity::getFlowTaskId, projecttypeid)
);
return this.selectJoinOne(BcmProjectTypeEntity.class,wrapper);
}
@Override
public void create(BcmProjectTypeEntity entity){
this.save(entity);
}
@Override
public boolean update(String projecttypeid, BcmProjectTypeEntity entity){
return this.updateById(entity);
}
@Override
public void delete(BcmProjectTypeEntity entity){
if(entity!=null){
this.removeById(entity.getProjectTypeId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(BcmProjectTypeForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getProjectTypeId()) && !form.getProjectTypeId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getProjectTypeId();
}
//验证业务主键
String businessErr = checkBusinessKey(form, isUp ? id : null, null);
if (StringUtil.isNotEmpty(businessErr)) {
return businessErr;
}
//主表字段验证
fieldTipName = "项目类型编码";
if(StringUtil.isEmpty(form.getProjectTypeCode())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getProjectTypeCode())){
form.setProjectTypeCode(form.getProjectTypeCode().trim());
QueryWrapper<BcmProjectTypeEntity> project_type_codeWrapper=new QueryWrapper<>();
project_type_codeWrapper.lambda().eq(BcmProjectTypeEntity::getProjectTypeCode,form.getProjectTypeCode());
project_type_codeWrapper.lambda().isNull(BcmProjectTypeEntity::getFlowId);
//假删除标志
project_type_codeWrapper.lambda().isNull(BcmProjectTypeEntity::getDeleteMark);
if (isUp){
project_type_codeWrapper.lambda().ne(BcmProjectTypeEntity::getProjectTypeId, id);
}
if((int) this.count(project_type_codeWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "项目类型名称";
if(StringUtil.isEmpty(form.getProjectTypeName())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getProjectTypeName())){
form.setProjectTypeName(form.getProjectTypeName().trim());
QueryWrapper<BcmProjectTypeEntity> project_type_nameWrapper=new QueryWrapper<>();
project_type_nameWrapper.lambda().eq(BcmProjectTypeEntity::getProjectTypeName,form.getProjectTypeName());
project_type_nameWrapper.lambda().isNull(BcmProjectTypeEntity::getFlowId);
//假删除标志
project_type_nameWrapper.lambda().isNull(BcmProjectTypeEntity::getDeleteMark);
if (isUp){
project_type_nameWrapper.lambda().ne(BcmProjectTypeEntity::getProjectTypeId, id);
}
if((int) this.count(project_type_nameWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "备注";
return countRecover;
}
/**
* 验证业务主键
*/
private String checkBusinessKey(BcmProjectTypeForm form, Object id, List<String> flowIds){
QueryWrapper<BcmProjectTypeEntity> wrapper = new QueryWrapper<>();
//修改
if (id != null){
wrapper.lambda().ne(BcmProjectTypeEntity::getProjectTypeId, id);
}
//是否流程
if(flowIds == null){
wrapper.lambda().isNull(BcmProjectTypeEntity::getFlowId);
}else{
wrapper.lambda().in(BcmProjectTypeEntity::getFlowId, flowIds);
}
//假删除标志
wrapper.lambda().isNull(BcmProjectTypeEntity::getDeleteMark);
//项目类型编码字段判断
if(form.getProjectTypeCode() == null || form.getProjectTypeCode().toString().trim().isEmpty()){
wrapper.lambda().isNull(BcmProjectTypeEntity::getProjectTypeCode);
}else{
wrapper.lambda().eq(BcmProjectTypeEntity::getProjectTypeCode, form.getProjectTypeCode());
}
if((int) this.count(wrapper)>0){
return "数据已存在,请勿重复提交!";
}
return "";
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param bcmProjectTypeForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(BcmProjectTypeForm bcmProjectTypeForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
bcmProjectTypeForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(BcmProjectTypeConstant.getFormData(),bcmProjectTypeForm,BcmProjectTypeConstant.TABLERENAMES),BcmProjectTypeForm.class);
BcmProjectTypeEntity entity = JsonUtil.getJsonToBean(bcmProjectTypeForm, BcmProjectTypeEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setProjectTypeId(mainUuid);
entity.setVersion(0);
} else {
}
boolean b = this.saveOrUpdate(entity);
if(!b){
throw new DataException("当前表单原数据已被调整,请重新进入该页面编辑并提交数据");
}
BcmProjectTypeEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
}
@Override
public List<BcmProjectTypeEntity> getBcmprojecttypeList(BcmProjectTypePagination bcmProjectTypePagination) {
List<BcmProjectTypeEntity> entities = this.baseMapper.selectList(new QueryWrapper<BcmProjectTypeEntity>().lambda());
return entities;
}
}

View File

@@ -1,34 +0,0 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.MdmCompanyBankMapper;
import com.yunzhupaas.base.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.model.mdmcompany.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
/**
*
* 企业信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-26
*/
@Service
public class MdmCompanyBankServiceImpl extends SuperServiceImpl<MdmCompanyBankMapper, MdmCompanyBankEntity> implements MdmCompanyBankService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
}

View File

@@ -1,34 +0,0 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.MdmCompanyContactMapper;
import com.yunzhupaas.base.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.model.mdmcompany.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
/**
*
* 企业信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-26
*/
@Service
public class MdmCompanyContactServiceImpl extends SuperServiceImpl<MdmCompanyContactMapper, MdmCompanyContactEntity> implements MdmCompanyContactService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
}

View File

@@ -1,514 +0,0 @@
package com.yunzhupaas.base.service.impl;
import com.github.pagehelper.Page;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.MdmCompanyMapper;
import com.yunzhupaas.base.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.model.mdmcompany.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
import org.springframework.util.StringUtils;
/**
*
* mdm_company
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-27
*/
@Service
public class MdmCompanyServiceImpl extends SuperServiceImpl<MdmCompanyMapper, MdmCompanyEntity> implements MdmCompanyService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private CrmCustomerService crmCustomerService;
@Autowired
private MdmCompanyContactService mdmCompanyContactService;
@Autowired
private MdmCompanyBankService mdmCompanyBankService;
@Override
public List<MdmCompanyEntity> getList(MdmCompanyPagination mdmCompanyPagination){
return getTypeList(mdmCompanyPagination,mdmCompanyPagination.getDataType());
}
/** 列表查询 */
@Override
public List<MdmCompanyEntity> getTypeList(MdmCompanyPagination mdmCompanyPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_company",MdmCompanyEntity.class);
tableClassMap.put("mdm_company_bank",MdmCompanyBankEntity.class);
tableClassMap.put("mdm_company_contact",MdmCompanyContactEntity.class);
tableClassMap.put("crm_customer",CrmCustomerEntity.class);
MPJLambdaWrapper<MdmCompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",MdmCompanyEntity.class)
.selectCollection(MdmCompanyBankEntity.class,MdmCompanyEntity::getMdmCompanyBank)
.leftJoin(MdmCompanyBankEntity.class,"mdm_company_bank",MdmCompanyBankEntity::getCompanyId,MdmCompanyEntity::getCompanyId)
.selectCollection(MdmCompanyContactEntity.class,MdmCompanyEntity::getMdmCompanyContact)
.leftJoin(MdmCompanyContactEntity.class,"mdm_company_contact",MdmCompanyContactEntity::getCompanyId,MdmCompanyEntity::getCompanyId)
.selectAssociation(CrmCustomerEntity.class,MdmCompanyEntity::getCrmCustomer)
.leftJoin(CrmCustomerEntity.class,"crm_customer",CrmCustomerEntity::getCompanyId,MdmCompanyEntity::getCompanyId)
.selectAll(MdmCompanyEntity.class);
MPJLambdaWrapper<MdmCompanyEntity> wrapper2 = JoinWrappers
.lambda("mdm_company",MdmCompanyEntity.class)
.leftJoin(MdmCompanyBankEntity.class,"mdm_company_bank",MdmCompanyBankEntity::getCompanyId,MdmCompanyEntity::getCompanyId)
.leftJoin(MdmCompanyContactEntity.class,"mdm_company_contact",MdmCompanyContactEntity::getCompanyId,MdmCompanyEntity::getCompanyId)
.leftJoin(CrmCustomerEntity.class,"crm_customer",CrmCustomerEntity::getCompanyId,MdmCompanyEntity::getCompanyId)
.distinct().select(MdmCompanyEntity::getCompanyId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(MdmCompanyConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? MdmCompanyConstant.getAppColumnData() : MdmCompanyConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(mdmCompanyPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = false;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(mdmCompanyPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(mdmCompanyPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(mdmCompanyPagination, wrapper, isPc);
otherConditions(mdmCompanyPagination, wrapper2, isPc);
if("0".equals(dataType)){
Page<Object> objects = PageHelper.startPage((int) mdmCompanyPagination.getCurrentPage(), (int) mdmCompanyPagination.getPageSize(), true);
List<MdmCompanyEntity> userIPage = this.selectJoinList(MdmCompanyEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getCompanyId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(MdmCompanyEntity::getCompanyId,collect);
}
List<MdmCompanyEntity> result = this.selectJoinList(MdmCompanyEntity.class, wrapper);
return mdmCompanyPagination.setData(result,objects.getTotal());
}else{
List<MdmCompanyEntity> list = this.selectJoinList(MdmCompanyEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(mdmCompanyPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getCompanyId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(MdmCompanyPagination mdmCompanyPagination, MPJLambdaWrapper<MdmCompanyEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
//假删除标志
wrapper.isNull(MdmCompanyEntity::getDeleteMark);
wrapper.isNull(MdmCompanyEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(mdmCompanyPagination.getYunzhupaasKeyword())){
if(isPc){
wrapper.and(t -> {
t.like(MdmCompanyEntity::getCompanyName,mdmCompanyPagination.getYunzhupaasKeyword()).or();
});
}
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(mdmCompanyPagination.getCompanyName())){
String value = mdmCompanyPagination.getCompanyName() instanceof List ?
JsonUtil.getObjectToString(mdmCompanyPagination.getCompanyName()) :
String.valueOf(mdmCompanyPagination.getCompanyName());
wrapper.like(MdmCompanyEntity::getCompanyName,value);
}
if(ObjectUtil.isNotEmpty(mdmCompanyPagination.getEntityType())){
wrapper.eq(MdmCompanyEntity::getEntityType,mdmCompanyPagination.getEntityType());
}
}
//排序
if(StringUtil.isEmpty(mdmCompanyPagination.getSidx())){
wrapper.orderByDesc(MdmCompanyEntity::getCompanyId);
}else{
try {
String[] split = mdmCompanyPagination.getSidx().split(",");
for(String sidx:split){
MdmCompanyEntity mdmCompanyEntity = new MdmCompanyEntity();
String oderTableField = mdmCompanyEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = mdmCompanyEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public MdmCompanyEntity getInfo(String companyid){
MPJLambdaWrapper<MdmCompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",MdmCompanyEntity.class)
.selectCollection(MdmCompanyBankEntity.class,MdmCompanyEntity::getMdmCompanyBank)
.leftJoin(MdmCompanyBankEntity.class,"mdm_company_bank",MdmCompanyBankEntity::getCompanyId,MdmCompanyEntity::getCompanyId)
.selectCollection(MdmCompanyContactEntity.class,MdmCompanyEntity::getMdmCompanyContact)
.leftJoin(MdmCompanyContactEntity.class,"mdm_company_contact",MdmCompanyContactEntity::getCompanyId,MdmCompanyEntity::getCompanyId)
.selectAssociation(CrmCustomerEntity.class,MdmCompanyEntity::getCrmCustomer)
.leftJoin(CrmCustomerEntity.class,"crm_customer",CrmCustomerEntity::getCompanyId,MdmCompanyEntity::getCompanyId)
.selectAll(MdmCompanyEntity.class);
wrapper.and(
t->t.eq(MdmCompanyEntity::getCompanyId, companyid )
.or().eq(MdmCompanyEntity::getFlowTaskId, companyid)
);
return this.selectJoinOne(MdmCompanyEntity.class,wrapper);
}
@Override
public void create(MdmCompanyEntity entity){
this.save(entity);
}
@Override
public boolean update(String companyid, MdmCompanyEntity entity){
return this.updateById(entity);
}
@Override
public void delete(MdmCompanyEntity entity){
if(entity!=null){
this.removeById(entity.getCompanyId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(MdmCompanyForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getCompanyId()) && !form.getCompanyId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getCompanyId();
}
//主表字段验证
fieldTipName = "企业编码";
fieldTipName = "企业名称";
if(StringUtil.isEmpty(form.getCompanyName())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getCompanyName())){
form.setCompanyName(form.getCompanyName().trim());
QueryWrapper<MdmCompanyEntity> company_nameWrapper=new QueryWrapper<>();
company_nameWrapper.lambda().eq(MdmCompanyEntity::getCompanyName,form.getCompanyName());
company_nameWrapper.lambda().isNull(MdmCompanyEntity::getFlowId);
//假删除标志
company_nameWrapper.lambda().isNull(MdmCompanyEntity::getDeleteMark);
if (isUp){
company_nameWrapper.lambda().ne(MdmCompanyEntity::getCompanyId, id);
}
if((int) this.count(company_nameWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "简称/昵称";
fieldTipName = "类型";
fieldTipName = "社会信用代码";
if(StringUtil.isEmpty(form.getCreditCode())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getCreditCode())){
form.setCreditCode(form.getCreditCode().trim());
QueryWrapper<MdmCompanyEntity> credit_codeWrapper=new QueryWrapper<>();
credit_codeWrapper.lambda().eq(MdmCompanyEntity::getCreditCode,form.getCreditCode());
credit_codeWrapper.lambda().isNull(MdmCompanyEntity::getFlowId);
//假删除标志
credit_codeWrapper.lambda().isNull(MdmCompanyEntity::getDeleteMark);
if (isUp){
credit_codeWrapper.lambda().ne(MdmCompanyEntity::getCompanyId, id);
}
if((int) this.count(credit_codeWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "企业范围";
fieldTipName = "纳税人类别";
fieldTipName = "企业规模";
fieldTipName = "企业类型";
fieldTipName = "行业代码";
fieldTipName = "成立日期";
fieldTipName = "注册资本";
fieldTipName = "法定代表人";
fieldTipName = "联系电话";
if(StringUtil.isNotEmpty(form.getPhone())){
if(!Pattern.compile("^1[3456789]\\d{9}$|^0\\d{2,3}-?\\d{7,8}$").matcher(String.valueOf(form.getPhone())).matches()){
return I18nUtil.getMessageStr("sys.validate.mobilePhone", "请输入正确的手机号码");
}
}
fieldTipName = "邮箱";
if(StringUtil.isNotEmpty(form.getEmail())){
if(!Pattern.compile("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$").matcher(String.valueOf(form.getEmail())).matches()){
return I18nUtil.getMessageStr("sys.validate.email", "请输入正确的邮箱");
}
}
fieldTipName = "网站";
fieldTipName = "地址";
fieldTipName = "所属地区";
fieldTipName = "经营范围";
fieldTipName = "备注";
//子表字段验证
// if (form.getCrmCustomerList()!=null){
//
// fieldTipName = "设计子表"
// + "-" + "客户负责人";
//
//
// fieldTipName = "设计子表"
// + "-" + "归属组织";
//
//
// fieldTipName = "设计子表"
// + "-" + "客户等级";
//
//
// fieldTipName = "设计子表"
// + "-" + "生命周期阶段";
//
//
// fieldTipName = "设计子表"
// + "-" + "是否公海客户";
//
//
// fieldTipName = "设计子表"
// + "-" + "最后一次跟进日期";
//
// }
if (form.getMdmCompanyContactList()!=null){
fieldTipName = "联系人信息"
+ "-" + "联系人";
fieldTipName = "联系人信息"
+ "-" + "联系人职务";
fieldTipName = "联系人信息"
+ "-" + "电话";
fieldTipName = "联系人信息"
+ "-" + "邮箱";
fieldTipName = "联系人信息"
+ "-" + "备注";
}
if (form.getMdmCompanyBankList()!=null){
fieldTipName = "银行信息"
+ "-" + "银行账号";
fieldTipName = "银行信息"
+ "-" + "开户行";
fieldTipName = "银行信息"
+ "-" + "账户名";
fieldTipName = "银行信息"
+ "-" + "开户行城市";
fieldTipName = "银行信息"
+ "-" + "备注";
}
return countRecover;
}
private void setIfNotNull(Consumer<String> setter, Object value) {
if (value != null && StringUtils.hasText(String.valueOf(value))) {
setter.accept(String.valueOf(value));
}
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param mdmCompanyForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(MdmCompanyForm mdmCompanyForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
mdmCompanyForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(MdmCompanyConstant.getFormData(),mdmCompanyForm,MdmCompanyConstant.TABLERENAMES),MdmCompanyForm.class);
MdmCompanyEntity entity = JsonUtil.getJsonToBean(mdmCompanyForm, MdmCompanyEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setCompanyId(mainUuid);
entity.setVersion(0);
} else {
}
boolean b = this.saveOrUpdate(entity);
if(!b){
throw new DataException("当前表单原数据已被调整,请重新进入该页面编辑并提交数据");
}
MdmCompanyEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
//CrmCustomer子表数据新增修改
QueryWrapper<CrmCustomerEntity> CrmCustomerqueryWrapper = new QueryWrapper<>();
CrmCustomerqueryWrapper.lambda().eq(CrmCustomerEntity::getCompanyId, info.getCompanyId());
if(!isSave && !ObjectUtil.isNotEmpty(mdmCompanyForm.getOwnerId())){
crmCustomerService.remove(CrmCustomerqueryWrapper);
}
if (ObjectUtil.isNotEmpty(mdmCompanyForm.getOwnerId())){
CrmCustomerEntity customer = new CrmCustomerEntity();
// 必须赋值
customer.setCompanyId(info.getCompanyId());
// 下面全部 非null、非空字符串 才会设置
setIfNotNull(customer::setOwnerId, mdmCompanyForm.getOwnerId());
setIfNotNull(customer::setOrgId, mdmCompanyForm.getOrgId());
setIfNotNull(customer::setCustomerLevel, mdmCompanyForm.getCustomerLevel());
setIfNotNull(customer::setCustomerLifecycle, mdmCompanyForm.getCustomerLifecycle());
setIfNotNull(customer::setIsPublic, mdmCompanyForm.getIsPublic());
// //移除的数据
if(StringUtil.isNotEmpty(customer.getCustomerId())){
CrmCustomerqueryWrapper.lambda().eq(CrmCustomerEntity::getCustomerId,customer.getCustomerId());
}
crmCustomerService.remove(CrmCustomerqueryWrapper);
// for(CrmCustomerEntity entitys : tableField798457){
// entitys.setCompanyId(entity.getCompanyId());
// if(entitys.getCustomerId()==null){
// entitys.setCustomerId(RandomUtil.uuId());
// }
// crmCustomerService.saveOrUpdate(entitys);
// }
crmCustomerService.save(customer);
}
//MdmCompanyContact子表数据新增修改
QueryWrapper<MdmCompanyContactEntity> MdmCompanyContactqueryWrapper = new QueryWrapper<>();
MdmCompanyContactqueryWrapper.lambda().eq(MdmCompanyContactEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(mdmCompanyForm.getMdmCompanyContactList())){
mdmCompanyContactService.remove(MdmCompanyContactqueryWrapper);
}
if (CollectionUtils.isNotEmpty(mdmCompanyForm.getMdmCompanyContactList())){
List<MdmCompanyContactEntity> tableFieldc4fb23 = JsonUtil.getJsonToList(mdmCompanyForm.getMdmCompanyContactList(),MdmCompanyContactEntity.class);
//移除的数据
List<Object> childIds = tableFieldc4fb23.stream().filter(t->t.getContactId()!=null).map(MdmCompanyContactEntity::getContactId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
MdmCompanyContactqueryWrapper.lambda().notIn(MdmCompanyContactEntity::getContactId,childIds);
}
mdmCompanyContactService.remove(MdmCompanyContactqueryWrapper);
for(MdmCompanyContactEntity entitys : tableFieldc4fb23){
entitys.setCompanyId(entity.getCompanyId());
if(entitys.getContactId()==null){
entitys.setContactId(RandomUtil.uuId());
}
mdmCompanyContactService.saveOrUpdate(entitys);
}
}
//MdmCompanyBank子表数据新增修改
QueryWrapper<MdmCompanyBankEntity> MdmCompanyBankqueryWrapper = new QueryWrapper<>();
MdmCompanyBankqueryWrapper.lambda().eq(MdmCompanyBankEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(mdmCompanyForm.getMdmCompanyBankList())){
mdmCompanyBankService.remove(MdmCompanyBankqueryWrapper);
}
if (CollectionUtils.isNotEmpty(mdmCompanyForm.getMdmCompanyBankList())){
List<MdmCompanyBankEntity> tableFieldaafa82 = JsonUtil.getJsonToList(mdmCompanyForm.getMdmCompanyBankList(),MdmCompanyBankEntity.class);
//移除的数据
List<Object> childIds = tableFieldaafa82.stream().filter(t->t.getBankId()!=null).map(MdmCompanyBankEntity::getBankId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
MdmCompanyBankqueryWrapper.lambda().notIn(MdmCompanyBankEntity::getBankId,childIds);
}
mdmCompanyBankService.remove(MdmCompanyBankqueryWrapper);
for(MdmCompanyBankEntity entitys : tableFieldaafa82){
entitys.setCompanyId(entity.getCompanyId());
if(entitys.getBankId()==null){
entitys.setBankId(RandomUtil.uuId());
}
mdmCompanyBankService.saveOrUpdate(entitys);
}
}
}
}

View File

@@ -1,364 +0,0 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.MdmContractTypeMapper;
import com.yunzhupaas.base.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.model.mdmcontracttype.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* mdmContractType
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-30
*/
@Service
public class MdmContractTypeServiceImpl extends SuperServiceImpl<MdmContractTypeMapper, MdmContractTypeEntity> implements MdmContractTypeService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<MdmContractTypeEntity> getList(MdmContractTypePagination mdmContractTypePagination){
return getTypeList(mdmContractTypePagination,mdmContractTypePagination.getDataType());
}
/** 列表查询 */
@Override
public List<MdmContractTypeEntity> getTypeList(MdmContractTypePagination mdmContractTypePagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_contract_type",MdmContractTypeEntity.class);
MPJLambdaWrapper<MdmContractTypeEntity> wrapper = JoinWrappers
.lambda("mdm_contract_type",MdmContractTypeEntity.class)
.selectAll(MdmContractTypeEntity.class);
MPJLambdaWrapper<MdmContractTypeEntity> wrapper2 = JoinWrappers
.lambda("mdm_contract_type",MdmContractTypeEntity.class)
.distinct().select(MdmContractTypeEntity::getId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(MdmContractTypeConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? MdmContractTypeConstant.getAppColumnData() : MdmContractTypeConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(mdmContractTypePagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = false;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(mdmContractTypePagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(mdmContractTypePagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(mdmContractTypePagination, wrapper, isPc);
otherConditions(mdmContractTypePagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) mdmContractTypePagination.getCurrentPage(), (int) mdmContractTypePagination.getPageSize(), true);
List<MdmContractTypeEntity> userIPage = this.selectJoinList(MdmContractTypeEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(MdmContractTypeEntity::getId,collect);
}
List<MdmContractTypeEntity> result = this.selectJoinList(MdmContractTypeEntity.class, wrapper);
return mdmContractTypePagination.setData(result,objects.getTotal());
}else{
List<MdmContractTypeEntity> list = this.selectJoinList(MdmContractTypeEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(mdmContractTypePagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(MdmContractTypePagination mdmContractTypePagination, MPJLambdaWrapper<MdmContractTypeEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
//假删除标志
wrapper.isNull(MdmContractTypeEntity::getDeleteMark);
wrapper.isNull(MdmContractTypeEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(mdmContractTypePagination.getYunzhupaasKeyword())){
if(isPc){
wrapper.and(t -> {
t.like(MdmContractTypeEntity::getContractTypeName,mdmContractTypePagination.getYunzhupaasKeyword()).or();
});
}
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(mdmContractTypePagination.getContractTypeCode())){
String value = mdmContractTypePagination.getContractTypeCode() instanceof List ?
JsonUtil.getObjectToString(mdmContractTypePagination.getContractTypeCode()) :
String.valueOf(mdmContractTypePagination.getContractTypeCode());
wrapper.like(MdmContractTypeEntity::getContractTypeCode,value);
}
if(ObjectUtil.isNotEmpty(mdmContractTypePagination.getContractTypeName())){
String value = mdmContractTypePagination.getContractTypeName() instanceof List ?
JsonUtil.getObjectToString(mdmContractTypePagination.getContractTypeName()) :
String.valueOf(mdmContractTypePagination.getContractTypeName());
wrapper.like(MdmContractTypeEntity::getContractTypeName,value);
}
if(ObjectUtil.isNotEmpty(mdmContractTypePagination.getContractMode())){
List<String> idList = new ArrayList<>();
try {
String[][] contractMode = JsonUtil.getJsonToBean(mdmContractTypePagination.getContractMode(),String[][].class);
for(int i=0;i<contractMode.length;i++){
if(contractMode[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(contractMode[i])));
}
}
}catch (Exception e1){
try {
List<String> contractMode = JsonUtil.getJsonToList(mdmContractTypePagination.getContractMode(),String.class);
if(contractMode.size()>0){
idList.addAll(contractMode);
}
}catch (Exception e2){
idList.add(String.valueOf(mdmContractTypePagination.getContractMode()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(MdmContractTypeEntity::getContractMode, tt).or();
});
});
}
if(ObjectUtil.isNotEmpty(mdmContractTypePagination.getProjectType())){
String value = mdmContractTypePagination.getProjectType() instanceof List ?
JsonUtil.getObjectToString(mdmContractTypePagination.getProjectType()) :
String.valueOf(mdmContractTypePagination.getProjectType());
wrapper.like(MdmContractTypeEntity::getProjectType,value);
}
}
//排序
if(StringUtil.isEmpty(mdmContractTypePagination.getSidx())){
wrapper.orderByDesc(MdmContractTypeEntity::getId);
}else{
try {
String[] split = mdmContractTypePagination.getSidx().split(",");
for(String sidx:split){
MdmContractTypeEntity mdmContractTypeEntity = new MdmContractTypeEntity();
String oderTableField = mdmContractTypeEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = mdmContractTypeEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public MdmContractTypeEntity getInfo(String id){
MPJLambdaWrapper<MdmContractTypeEntity> wrapper = JoinWrappers
.lambda("mdm_contract_type",MdmContractTypeEntity.class)
.selectAll(MdmContractTypeEntity.class);
wrapper.and(
t->t.eq(MdmContractTypeEntity::getId, id )
.or().eq(MdmContractTypeEntity::getFlowTaskId, id)
);
return this.selectJoinOne(MdmContractTypeEntity.class,wrapper);
}
@Override
public void create(MdmContractTypeEntity entity){
this.save(entity);
}
@Override
public boolean update(String id, MdmContractTypeEntity entity){
return this.updateById(entity);
}
@Override
public void delete(MdmContractTypeEntity entity){
if(entity!=null){
this.removeById(entity.getId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(MdmContractTypeForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getId();
}
//主表字段验证
fieldTipName = "合同类型编码";
if(StringUtil.isEmpty(form.getContractTypeCode())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getContractTypeCode())){
form.setContractTypeCode(form.getContractTypeCode().trim());
QueryWrapper<MdmContractTypeEntity> contract_type_codeWrapper=new QueryWrapper<>();
contract_type_codeWrapper.lambda().eq(MdmContractTypeEntity::getContractTypeCode,form.getContractTypeCode());
contract_type_codeWrapper.lambda().isNull(MdmContractTypeEntity::getFlowId);
//假删除标志
contract_type_codeWrapper.lambda().isNull(MdmContractTypeEntity::getDeleteMark);
if (isUp){
contract_type_codeWrapper.lambda().ne(MdmContractTypeEntity::getId, id);
}
if((int) this.count(contract_type_codeWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "合同类型名称";
if(StringUtil.isEmpty(form.getContractTypeName())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getContractTypeName())){
form.setContractTypeName(form.getContractTypeName().trim());
QueryWrapper<MdmContractTypeEntity> contract_type_nameWrapper=new QueryWrapper<>();
contract_type_nameWrapper.lambda().eq(MdmContractTypeEntity::getContractTypeName,form.getContractTypeName());
contract_type_nameWrapper.lambda().isNull(MdmContractTypeEntity::getFlowId);
//假删除标志
contract_type_nameWrapper.lambda().isNull(MdmContractTypeEntity::getDeleteMark);
if (isUp){
contract_type_nameWrapper.lambda().ne(MdmContractTypeEntity::getId, id);
}
if((int) this.count(contract_type_nameWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "项目类型";
fieldTipName = "合同模式";
fieldTipName = "材料清单";
fieldTipName = "材料清单别名";
fieldTipName = "材料清单顺序";
fieldTipName = "租赁清单";
fieldTipName = "租赁清单别名";
fieldTipName = "租赁清单顺序";
fieldTipName = "劳务清单";
fieldTipName = "劳务清单别名";
fieldTipName = "劳务清单顺序";
fieldTipName = "工程量清单";
fieldTipName = "工程量清单别名";
fieldTipName = "工程量清单顺序";
fieldTipName = "在线合同模板";
fieldTipName = "工作流程";
fieldTipName = "流程模板ID关联流程模板表";
return countRecover;
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param mdmContractTypeForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(MdmContractTypeForm mdmContractTypeForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
mdmContractTypeForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(MdmContractTypeConstant.getFormData(),mdmContractTypeForm,MdmContractTypeConstant.TABLERENAMES),MdmContractTypeForm.class);
MdmContractTypeEntity entity = JsonUtil.getJsonToBean(mdmContractTypeForm, MdmContractTypeEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setId(mainUuid);
entity.setVersion(0);
} else {
}
boolean b = this.saveOrUpdate(entity);
if(!b){
throw new DataException("当前表单原数据已被调整,请重新进入该页面编辑并提交数据");
}
MdmContractTypeEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
}
}

View File

@@ -1,333 +0,0 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.MdmProjectMapper;
import com.yunzhupaas.base.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.model.mdmproject.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* 项目结构
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-03-26
*/
@Service
public class MdmProjectServiceImpl extends SuperServiceImpl<MdmProjectMapper, MdmProjectEntity> implements MdmProjectService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<MdmProjectEntity> getList(MdmProjectPagination mdmProjectPagination){
return getTypeList(mdmProjectPagination,mdmProjectPagination.getDataType());
}
/** 列表查询 */
@Override
public List<MdmProjectEntity> getTypeList(MdmProjectPagination mdmProjectPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_project",MdmProjectEntity.class);
MPJLambdaWrapper<MdmProjectEntity> wrapper = JoinWrappers
.lambda("mdm_project",MdmProjectEntity.class)
.selectAll(MdmProjectEntity.class);
MPJLambdaWrapper<MdmProjectEntity> wrapper2 = JoinWrappers
.lambda("mdm_project",MdmProjectEntity.class)
.distinct().select(MdmProjectEntity::getProjectId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(MdmProjectConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? MdmProjectConstant.getAppColumnData() : MdmProjectConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(mdmProjectPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = false;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(mdmProjectPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(mdmProjectPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(mdmProjectPagination, wrapper, isPc);
otherConditions(mdmProjectPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) mdmProjectPagination.getCurrentPage(), (int) mdmProjectPagination.getPageSize(), true);
List<MdmProjectEntity> userIPage = this.selectJoinList(MdmProjectEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getProjectId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(MdmProjectEntity::getProjectId,collect);
}
List<MdmProjectEntity> result = this.selectJoinList(MdmProjectEntity.class, wrapper);
return mdmProjectPagination.setData(result,objects.getTotal());
}else{
List<MdmProjectEntity> list = this.selectJoinList(MdmProjectEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(mdmProjectPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getProjectId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(MdmProjectPagination mdmProjectPagination, MPJLambdaWrapper<MdmProjectEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
wrapper.isNull(MdmProjectEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(mdmProjectPagination.getYunzhupaasKeyword())){
if(isPc){
wrapper.and(t -> {
t.like(MdmProjectEntity::getProjectName,mdmProjectPagination.getYunzhupaasKeyword()).or();
});
}
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(mdmProjectPagination.getProjectName())){
String value = mdmProjectPagination.getProjectName() instanceof List ?
JsonUtil.getObjectToString(mdmProjectPagination.getProjectName()) :
String.valueOf(mdmProjectPagination.getProjectName());
wrapper.like(MdmProjectEntity::getProjectName,value);
}
if(ObjectUtil.isNotEmpty(mdmProjectPagination.getOrgId())){
List<String> idList = new ArrayList<>();
try {
String[][] orgId = JsonUtil.getJsonToBean(mdmProjectPagination.getOrgId(),String[][].class);
for(int i=0;i<orgId.length;i++){
if(orgId[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(orgId[i])));
}
}
}catch (Exception e1){
try {
List<String> orgId = JsonUtil.getJsonToList(mdmProjectPagination.getOrgId(),String.class);
if(orgId.size()>0){
idList.add(JsonUtil.getObjectToString(orgId));
}
}catch (Exception e2){
idList.add(String.valueOf(mdmProjectPagination.getOrgId()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(MdmProjectEntity::getOrgId, tt).or();
});
});
}
if(ObjectUtil.isNotEmpty(mdmProjectPagination.getProjectStateId())){
wrapper.eq(MdmProjectEntity::getProjectStateId,mdmProjectPagination.getProjectStateId());
}
}
//排序
if(StringUtil.isEmpty(mdmProjectPagination.getSidx())){
wrapper.orderByDesc(MdmProjectEntity::getProjectId);
}else{
try {
String[] split = mdmProjectPagination.getSidx().split(",");
for(String sidx:split){
MdmProjectEntity mdmProjectEntity = new MdmProjectEntity();
String oderTableField = mdmProjectEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = mdmProjectEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public MdmProjectEntity getInfo(String projectid){
MPJLambdaWrapper<MdmProjectEntity> wrapper = JoinWrappers
.lambda("mdm_project",MdmProjectEntity.class)
.selectAll(MdmProjectEntity.class);
wrapper.and(
t->t.eq(MdmProjectEntity::getProjectId, projectid )
.or().eq(MdmProjectEntity::getFlowTaskId, projectid)
);
return this.selectJoinOne(MdmProjectEntity.class,wrapper);
}
@Override
public void create(MdmProjectEntity entity){
this.save(entity);
}
@Override
public boolean update(String projectid, MdmProjectEntity entity){
return this.updateById(entity);
}
@Override
public void delete(MdmProjectEntity entity){
if(entity!=null){
this.removeById(entity.getProjectId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(MdmProjectForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getProjectId()) && !form.getProjectId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getProjectId();
}
//主表字段验证
fieldTipName = "项目编码";
if(StringUtil.isEmpty(form.getProjectCode())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getProjectCode())){
form.setProjectCode(form.getProjectCode().trim());
QueryWrapper<MdmProjectEntity> project_codeWrapper=new QueryWrapper<>();
project_codeWrapper.lambda().eq(MdmProjectEntity::getProjectCode,form.getProjectCode());
project_codeWrapper.lambda().isNull(MdmProjectEntity::getFlowId);
if (isUp){
project_codeWrapper.lambda().ne(MdmProjectEntity::getProjectId, id);
}
if((int) this.count(project_codeWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "项目名称";
if(StringUtil.isEmpty(form.getProjectName())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getProjectName())){
form.setProjectName(form.getProjectName().trim());
QueryWrapper<MdmProjectEntity> project_nameWrapper=new QueryWrapper<>();
project_nameWrapper.lambda().eq(MdmProjectEntity::getProjectName,form.getProjectName());
project_nameWrapper.lambda().isNull(MdmProjectEntity::getFlowId);
if (isUp){
project_nameWrapper.lambda().ne(MdmProjectEntity::getProjectId, id);
}
if((int) this.count(project_nameWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "上级项目";
fieldTipName = "归属组织";
fieldTipName = "项目类型";
fieldTipName = "启动日期";
fieldTipName = "项目状态";
fieldTipName = "顺序号";
fieldTipName = "备注";
return countRecover;
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param mdmProjectForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(MdmProjectForm mdmProjectForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
mdmProjectForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(MdmProjectConstant.getFormData(),mdmProjectForm,MdmProjectConstant.TABLERENAMES),MdmProjectForm.class);
MdmProjectEntity entity = JsonUtil.getJsonToBean(mdmProjectForm, MdmProjectEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setProjectId(mainUuid);
} else {
}
boolean b = this.saveOrUpdate(entity);
MdmProjectEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
}
}

View File

@@ -1,17 +1,17 @@
package com.yunzhupaas.base.mapper;
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.base.entity.MdmCompanyEntity;
import com.yunzhupaas.mdm.entity.AssetEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 企业信息
* 资产信息
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-26
* 日期 2026-04-28
*/
public interface MdmCompanyMapper extends SuperMapper<MdmCompanyEntity> {
public interface AssetMapper extends SuperMapper<AssetEntity> {
}

View File

@@ -1,17 +1,17 @@
package com.yunzhupaas.base.mapper;
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.base.entity.CrmCustomerEntity;
import com.yunzhupaas.mdm.entity.CompanyBankEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* mdm_company
* 法人公司
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-27
* 日期 2026-04-24
*/
public interface CrmCustomerMapper extends SuperMapper<CrmCustomerEntity> {
public interface CompanyBankMapper extends SuperMapper<CompanyBankEntity> {
}

View File

@@ -1,17 +1,17 @@
package com.yunzhupaas.base.mapper;
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.base.entity.BcmProjectTypeEntity;
import com.yunzhupaas.mdm.entity.CompanyInvoiceEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 项目类型
* 法人公司
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-26
* 日期 2026-04-24
*/
public interface BcmProjectTypeMapper extends SuperMapper<BcmProjectTypeEntity> {
public interface CompanyInvoiceMapper extends SuperMapper<CompanyInvoiceEntity>, BaseMapper<CompanyInvoiceEntity> {
}

View File

@@ -1,17 +1,17 @@
package com.yunzhupaas.base.mapper;
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.base.entity.CrmLeadEntity;
import com.yunzhupaas.mdm.entity.CompanyEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* crm_lead
* 法人公司
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-27
* 日期 2026-04-24
*/
public interface CrmLeadMapper extends SuperMapper<CrmLeadEntity> {
public interface CompanyMapper extends SuperMapper<CompanyEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.mdm.entity.CorporationEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 法人公司
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
public interface CorporationMapper extends SuperMapper<CorporationEntity> {
}

View File

@@ -1,17 +1,17 @@
package com.yunzhupaas.base.mapper;
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.base.entity.MdmProjectEntity;
import com.yunzhupaas.mdm.entity.CustomerEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 项目结构
* 客户信息
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-26
* 日期 2026-04-24
*/
public interface MdmProjectMapper extends SuperMapper<MdmProjectEntity> {
public interface CustomersMapper extends SuperMapper<CustomerEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.mdm.entity.MaterialEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 物料信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-27
*/
public interface MaterialMapper extends SuperMapper<MaterialEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.mdm.entity.PanyInvoiceEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 供应商信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
public interface PanyInvoiceMapper extends SuperMapper<PanyInvoiceEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.mdm.entity.ProductEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 商品信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-27
*/
public interface ProductsMapper extends SuperMapper<ProductEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.mdm.mapper;
import com.yunzhupaas.mdm.entity.SupplierEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* 供应商信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
public interface SupplierMapper extends SuperMapper<SupplierEntity> {
}

View File

@@ -0,0 +1,31 @@
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.mdm.model.asset.*;
import java.util.*;
/**
* 资产信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-28
*/
public interface AssetService extends SuperService<AssetEntity> {
List<AssetEntity> getList(AssetPagination assetPagination);
List<AssetEntity> getTypeList(AssetPagination assetPagination,String dataType);
AssetEntity getInfo(String assetid);
void delete(AssetEntity entity);
void create(AssetEntity entity);
boolean update(String assetid, AssetEntity entity);
String checkForm(AssetForm form,int i);
void saveOrUpdate(AssetForm assetForm,String id, boolean isSave) throws Exception;
}

View File

@@ -1,14 +1,14 @@
package com.yunzhupaas.base.service;
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
/**
* mdm_company
* 法人公司
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-27
* 日期 2026-04-24
*/
public interface CrmCustomerService extends SuperService<CrmCustomerEntity> {
public interface CompanyBankService extends SuperService<CompanyBankEntity> {
}

View File

@@ -1,14 +1,14 @@
package com.yunzhupaas.base.service;
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
/**
* 企业信息
* 法人公司
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-26
* 日期 2026-04-24
*/
public interface MdmCompanyBankService extends SuperService<MdmCompanyBankEntity> {
public interface CompanyInvoiceService extends SuperService<CompanyInvoiceEntity> {
}

View File

@@ -0,0 +1,31 @@
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.mdm.model.company.*;
import java.util.*;
/**
* 企业信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
public interface CompanyService extends SuperService<CompanyEntity> {
List<CompanyEntity> getList(CompanyPagination companyPagination);
List<CompanyEntity> getTypeList(CompanyPagination companyPagination,String dataType);
CompanyEntity getInfo(String companyid);
void delete(CompanyEntity entity);
void create(CompanyEntity entity);
boolean update(String companyid, CompanyEntity entity);
String checkForm(CompanyForm form,int i);
void saveOrUpdate(CompanyForm companyForm,String id, boolean isSave) throws Exception;
}

View File

@@ -1,14 +1,14 @@
package com.yunzhupaas.base.service;
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
/**
* pcm_contract
* 法人公司
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-31
* 日期 2026-04-24
*/
public interface Pcm_payment_planService extends SuperService<Pcm_payment_planEntity> {
public interface CorporationService extends SuperService<CorporationEntity> {
}

View File

@@ -0,0 +1,31 @@
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.mdm.model.custinfo.*;
import java.util.*;
/**
* 客户信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
public interface CustinfoService extends SuperService<CompanyEntity> {
List<CompanyEntity> getList(CustinfoPagination companyPagination);
List<CompanyEntity> getTypeList(CustinfoPagination companyPagination,String dataType);
CompanyEntity getInfo(String companyid);
void delete(CompanyEntity entity);
void create(CompanyEntity entity);
boolean update(String companyid, CompanyEntity entity);
String checkForm(CustinfoForm form,int i);
void saveOrUpdate(CustinfoForm companyForm,String id, boolean isSave) throws Exception;
}

View File

@@ -1,14 +1,14 @@
package com.yunzhupaas.base.service;
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
/**
* 企业信息
* 客户信息
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-26
* 日期 2026-04-24
*/
public interface MdmCompanyContactService extends SuperService<MdmCompanyContactEntity> {
public interface CustomerService extends SuperService<CustomerEntity> {
}

View File

@@ -0,0 +1,31 @@
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.mdm.model.lpc.*;
import java.util.*;
/**
* 法人公司
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
public interface LpcService extends SuperService<CompanyEntity> {
List<CompanyEntity> getList(LpcPagination companyPagination);
List<CompanyEntity> getTypeList(LpcPagination companyPagination,String dataType);
CompanyEntity getInfo(String companyid);
void delete(CompanyEntity entity);
void create(CompanyEntity entity);
boolean update(String companyid, CompanyEntity entity);
String checkForm(LpcForm form,int i);
void saveOrUpdate(LpcForm companyForm,String id, boolean isSave) throws Exception;
}

View File

@@ -0,0 +1,31 @@
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.mdm.model.material.*;
import java.util.*;
/**
* 物料信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-27
*/
public interface MaterialService extends SuperService<MaterialEntity> {
List<MaterialEntity> getList(MaterialPagination materialPagination);
List<MaterialEntity> getTypeList(MaterialPagination materialPagination,String dataType);
MaterialEntity getInfo(String materialid);
void delete(MaterialEntity entity);
void create(MaterialEntity entity);
boolean update(String materialid, MaterialEntity entity);
String checkForm(MaterialForm form,int i);
void saveOrUpdate(MaterialForm materialForm,String id, boolean isSave) throws Exception;
}

View File

@@ -0,0 +1,14 @@
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
/**
* 供应商信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
public interface PanyInvoiceService extends SuperService<PanyInvoiceEntity> {
}

View File

@@ -0,0 +1,31 @@
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.mdm.model.product.*;
import java.util.*;
/**
* 商品信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-27
*/
public interface ProductsService extends SuperService<ProductEntity> {
List<ProductEntity> getList(ProductPagination productPagination);
List<ProductEntity> getTypeList(ProductPagination productPagination,String dataType);
ProductEntity getInfo(String productid);
void delete(ProductEntity entity);
void create(ProductEntity entity);
boolean update(String productid, ProductEntity entity);
String checkForm(ProductForm form,int i);
void saveOrUpdate(ProductForm productForm,String id, boolean isSave) throws Exception;
}

View File

@@ -0,0 +1,31 @@
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.mdm.model.suppinfo.*;
import java.util.*;
/**
* 供应商信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
public interface SuppinfoService extends SuperService<CompanyEntity> {
List<CompanyEntity> getList(SuppinfoPagination companyPagination);
List<CompanyEntity> getTypeList(SuppinfoPagination companyPagination,String dataType);
CompanyEntity getInfo(String companyid);
void delete(CompanyEntity entity);
void create(CompanyEntity entity);
boolean update(String companyid, CompanyEntity entity);
String checkForm(SuppinfoForm form,int i);
void saveOrUpdate(SuppinfoForm companyForm,String id, boolean isSave) throws Exception;
}

View File

@@ -0,0 +1,14 @@
package com.yunzhupaas.mdm.service;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.base.service.SuperService;
/**
* 供应商信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
public interface SupplierService extends SuperService<SupplierEntity> {
}

View File

@@ -0,0 +1,354 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.AssetMapper;
import com.yunzhupaas.mdm.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.mdm.model.asset.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* 资产信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-28
*/
@Service
public class AssetServiceImpl extends SuperServiceImpl<AssetMapper, AssetEntity> implements AssetService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<AssetEntity> getList(AssetPagination assetPagination){
return getTypeList(assetPagination,assetPagination.getDataType());
}
/** 列表查询 */
@Override
public List<AssetEntity> getTypeList(AssetPagination assetPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_asset",AssetEntity.class);
MPJLambdaWrapper<AssetEntity> wrapper = JoinWrappers
.lambda("mdm_asset",AssetEntity.class)
.selectAll(AssetEntity.class);
MPJLambdaWrapper<AssetEntity> wrapper2 = JoinWrappers
.lambda("mdm_asset",AssetEntity.class)
.distinct().select(AssetEntity::getAssetId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(AssetConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? AssetConstant.getAppColumnData() : AssetConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(assetPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = true;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(assetPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(assetPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(assetPagination, wrapper, isPc);
otherConditions(assetPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) assetPagination.getCurrentPage(), (int) assetPagination.getPageSize(), true);
List<AssetEntity> userIPage = this.selectJoinList(AssetEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getAssetId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(AssetEntity::getAssetId,collect);
}
List<AssetEntity> result = this.selectJoinList(AssetEntity.class, wrapper);
return assetPagination.setData(result,objects.getTotal());
}else{
List<AssetEntity> list = this.selectJoinList(AssetEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(assetPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getAssetId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(AssetPagination assetPagination, MPJLambdaWrapper<AssetEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
//假删除标志
wrapper.isNull(AssetEntity::getDeleteMark);
wrapper.isNull(AssetEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(assetPagination.getYunzhupaasKeyword())){
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(assetPagination.getAssetCode())){
String value = assetPagination.getAssetCode() instanceof List ?
JsonUtil.getObjectToString(assetPagination.getAssetCode()) :
String.valueOf(assetPagination.getAssetCode());
wrapper.like(AssetEntity::getAssetCode,value);
}
if(ObjectUtil.isNotEmpty(assetPagination.getAssetName())){
String value = assetPagination.getAssetName() instanceof List ?
JsonUtil.getObjectToString(assetPagination.getAssetName()) :
String.valueOf(assetPagination.getAssetName());
wrapper.like(AssetEntity::getAssetName,value);
}
if(ObjectUtil.isNotEmpty(assetPagination.getAssetStatus())){
List<String> idList = new ArrayList<>();
try {
String[][] assetStatus = JsonUtil.getJsonToBean(assetPagination.getAssetStatus(),String[][].class);
for(int i=0;i<assetStatus.length;i++){
if(assetStatus[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(assetStatus[i])));
}
}
}catch (Exception e1){
try {
List<String> assetStatus = JsonUtil.getJsonToList(assetPagination.getAssetStatus(),String.class);
if(assetStatus.size()>0){
idList.addAll(assetStatus);
}
}catch (Exception e2){
idList.add(String.valueOf(assetPagination.getAssetStatus()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(AssetEntity::getAssetStatus, tt).or();
});
});
}
if(ObjectUtil.isNotEmpty(assetPagination.getPurchaseDate())){
List PurchaseDateList = JsonUtil.getJsonToList(assetPagination.getPurchaseDate(),String.class);
for(int i=0;i<PurchaseDateList.size();i++){
String id = String.valueOf(PurchaseDateList.get(i));
boolean idAll = StringUtil.isNotEmpty(id) && !id.equals("null");
if(idAll){
Object b= new Date(Long.valueOf(id));
if(i==0){
wrapper.ge(AssetEntity::getPurchaseDate,b);
}else{
wrapper.le(AssetEntity::getPurchaseDate,b);
}
}
}
}
if(ObjectUtil.isNotEmpty(assetPagination.getCommissioningDate())){
List CommissioningDateList = JsonUtil.getJsonToList(assetPagination.getCommissioningDate(),String.class);
for(int i=0;i<CommissioningDateList.size();i++){
String id = String.valueOf(CommissioningDateList.get(i));
boolean idAll = StringUtil.isNotEmpty(id) && !id.equals("null");
if(idAll){
Object b= new Date(Long.valueOf(id));
if(i==0){
wrapper.ge(AssetEntity::getCommissioningDate,b);
}else{
wrapper.le(AssetEntity::getCommissioningDate,b);
}
}
}
}
if(ObjectUtil.isNotEmpty(assetPagination.getAssetType())){
wrapper.eq(AssetEntity::getAssetType,assetPagination.getAssetType());
}
}
//排序
if(StringUtil.isEmpty(assetPagination.getSidx())){
wrapper.orderByDesc(AssetEntity::getAssetId);
}else{
try {
String[] split = assetPagination.getSidx().split(",");
for(String sidx:split){
AssetEntity assetEntity = new AssetEntity();
String oderTableField = assetEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = assetEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public AssetEntity getInfo(String assetid){
MPJLambdaWrapper<AssetEntity> wrapper = JoinWrappers
.lambda("mdm_asset",AssetEntity.class)
.selectAll(AssetEntity.class);
wrapper.and(
t->t.eq(AssetEntity::getAssetId, assetid )
.or().eq(AssetEntity::getFlowTaskId, assetid)
);
return this.selectJoinOne(AssetEntity.class,wrapper);
}
@Override
public void create(AssetEntity entity){
this.save(entity);
}
@Override
public boolean update(String assetid, AssetEntity entity){
return this.updateById(entity);
}
@Override
public void delete(AssetEntity entity){
if(entity!=null){
this.removeById(entity.getAssetId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(AssetForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getAssetId()) && !form.getAssetId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getAssetId();
}
//主表字段验证
fieldTipName = "资产编码";
fieldTipName = "资产名称";
if(StringUtil.isEmpty(form.getAssetName())){
return fieldTipName + canNotNull;
}
fieldTipName = "资产类型";
fieldTipName = "资产分类";
fieldTipName = "资产状态";
fieldTipName = "资产位置";
fieldTipName = "使用组织";
fieldTipName = "保管用户";
fieldTipName = "资产权属";
fieldTipName = "单位";
fieldTipName = "数量";
fieldTipName = "购置日期";
fieldTipName = "启用日期";
fieldTipName = "预计使用年限";
fieldTipName = "供应商";
fieldTipName = "备注";
return countRecover;
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param assetForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(AssetForm assetForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
assetForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(AssetConstant.getFormData(),assetForm,AssetConstant.TABLERENAMES),AssetForm.class);
AssetEntity entity = JsonUtil.getJsonToBean(assetForm, AssetEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setAssetCode(generaterSwapUtil.getBillNumber("assetCode", false));
entity.setAssetId(mainUuid);
} else {
if(StringUtil.isEmpty(entity.getAssetCode()) ){
entity.setAssetCode(generaterSwapUtil.getBillNumber("assetCode", false));
}
}
boolean b = this.saveOrUpdate(entity);
AssetEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
}
}

View File

@@ -0,0 +1,24 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.CompanyBankMapper;
import com.yunzhupaas.mdm.service.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
/**
*
* 法人公司
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
@Service
public class CompanyBankServiceImpl extends SuperServiceImpl<CompanyBankMapper, CompanyBankEntity> implements CompanyBankService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
}

View File

@@ -0,0 +1,24 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.CompanyInvoiceMapper;
import com.yunzhupaas.mdm.service.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
/**
*
* 法人公司
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
@Service
public class CompanyInvoiceServiceImpl extends SuperServiceImpl<CompanyInvoiceMapper, CompanyInvoiceEntity> implements CompanyInvoiceService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
}

View File

@@ -0,0 +1,485 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.CompanyMapper;
import com.yunzhupaas.mdm.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.mdm.model.company.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* 企业信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
@Service
public class CompanyServiceImpl extends SuperServiceImpl<CompanyMapper, CompanyEntity> implements CompanyService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private CompanyBankService mdmCompanyBankService;
@Autowired
private CompanyInvoiceService companyInvoiceService;
@Override
public List<CompanyEntity> getList(CompanyPagination companyPagination){
return getTypeList(companyPagination,companyPagination.getDataType());
}
/** 列表查询 */
@Override
public List<CompanyEntity> getTypeList(CompanyPagination companyPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_company",CompanyEntity.class);
tableClassMap.put("mdm_company_bank",CompanyBankEntity.class);
tableClassMap.put("mdm_company_invoice",CompanyInvoiceEntity.class);
MPJLambdaWrapper<CompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.selectCollection(CompanyBankEntity.class,CompanyEntity::getCompanyBank)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(CompanyInvoiceEntity.class,CompanyEntity::getCompanyInvoice)
.leftJoin(CompanyInvoiceEntity.class,"mdm_company_invoice",CompanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAll(CompanyEntity.class);
MPJLambdaWrapper<CompanyEntity> wrapper2 = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.leftJoin(CompanyInvoiceEntity.class,"mdm_company_invoice",CompanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.distinct().select(CompanyEntity::getCompanyId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(CompanyConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? CompanyConstant.getAppColumnData() : CompanyConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(companyPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = true;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(companyPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(companyPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(companyPagination, wrapper, isPc);
otherConditions(companyPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) companyPagination.getCurrentPage(), (int) companyPagination.getPageSize(), true);
List<CompanyEntity> userIPage = this.selectJoinList(CompanyEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getCompanyId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(CompanyEntity::getCompanyId,collect);
}
List<CompanyEntity> result = this.selectJoinList(CompanyEntity.class, wrapper);
return companyPagination.setData(result,objects.getTotal());
}else{
List<CompanyEntity> list = this.selectJoinList(CompanyEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(companyPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getCompanyId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(CompanyPagination companyPagination, MPJLambdaWrapper<CompanyEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
wrapper.isNull(CompanyEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(companyPagination.getYunzhupaasKeyword())){
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(companyPagination.getCompanyName())){
String value = companyPagination.getCompanyName() instanceof List ?
JsonUtil.getObjectToString(companyPagination.getCompanyName()) :
String.valueOf(companyPagination.getCompanyName());
wrapper.like(CompanyEntity::getCompanyName,value);
}
if(ObjectUtil.isNotEmpty(companyPagination.getOrgId())){
List<String> idList = new ArrayList<>();
try {
String[][] orgId = JsonUtil.getJsonToBean(companyPagination.getOrgId(),String[][].class);
for(int i=0;i<orgId.length;i++){
if(orgId[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(orgId[i])));
}
}
}catch (Exception e1){
try {
List<String> orgId = JsonUtil.getJsonToList(companyPagination.getOrgId(),String.class);
if(orgId.size()>0){
idList.add(JsonUtil.getObjectToString(orgId));
}
}catch (Exception e2){
idList.add(String.valueOf(companyPagination.getOrgId()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(CompanyEntity::getOrgId, tt).or();
});
});
}
}
//排序
if(StringUtil.isEmpty(companyPagination.getSidx())){
wrapper.orderByDesc(CompanyEntity::getCompanyId);
}else{
try {
String[] split = companyPagination.getSidx().split(",");
for(String sidx:split){
CompanyEntity companyEntity = new CompanyEntity();
String oderTableField = companyEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = companyEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public CompanyEntity getInfo(String companyid){
MPJLambdaWrapper<CompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.selectCollection(CompanyBankEntity.class,CompanyEntity::getCompanyBank)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(CompanyInvoiceEntity.class,CompanyEntity::getCompanyInvoice)
.leftJoin(CompanyInvoiceEntity.class,"mdm_company_invoice",CompanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAll(CompanyEntity.class);
wrapper.and(
t->t.eq(CompanyEntity::getCompanyId, companyid )
.or().eq(CompanyEntity::getFlowTaskId, companyid)
);
return this.selectJoinOne(CompanyEntity.class,wrapper);
}
@Override
public void create(CompanyEntity entity){
this.save(entity);
}
@Override
public boolean update(String companyid, CompanyEntity entity){
return this.updateById(entity);
}
@Override
public void delete(CompanyEntity entity){
if(entity!=null){
this.removeById(entity.getCompanyId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(CompanyForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getCompanyId()) && !form.getCompanyId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getCompanyId();
}
//主表字段验证
fieldTipName = "企业编码";
fieldTipName = "企业名称";
if(StringUtil.isEmpty(form.getCompanyName())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getCompanyName())){
form.setCompanyName(form.getCompanyName().trim());
QueryWrapper<CompanyEntity> company_nameWrapper=new QueryWrapper<>();
company_nameWrapper.lambda().eq(CompanyEntity::getCompanyName,form.getCompanyName());
company_nameWrapper.lambda().isNull(CompanyEntity::getFlowId);
if (isUp){
company_nameWrapper.lambda().ne(CompanyEntity::getCompanyId, id);
}
if((int) this.count(company_nameWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "简称/昵称";
fieldTipName = "类型";
fieldTipName = "社会信用代码";
if(StringUtil.isEmpty(form.getCreditCode())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getCreditCode())){
form.setCreditCode(form.getCreditCode().trim());
QueryWrapper<CompanyEntity> credit_codeWrapper=new QueryWrapper<>();
credit_codeWrapper.lambda().eq(CompanyEntity::getCreditCode,form.getCreditCode());
credit_codeWrapper.lambda().isNull(CompanyEntity::getFlowId);
if (isUp){
credit_codeWrapper.lambda().ne(CompanyEntity::getCompanyId, id);
}
if((int) this.count(credit_codeWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "归属组织";
fieldTipName = "所属地区";
fieldTipName = "纳税人类别";
fieldTipName = "企业规模";
fieldTipName = "企业类型";
fieldTipName = "行业代码";
fieldTipName = "成立日期";
fieldTipName = "注册资本";
fieldTipName = "法定代表人";
fieldTipName = "联系电话";
if(StringUtil.isNotEmpty(form.getPhone())){
if(!Pattern.compile("^1[3456789]\\d{9}$|^0\\d{2,3}-?\\d{7,8}$").matcher(String.valueOf(form.getPhone())).matches()){
return I18nUtil.getMessageStr("sys.validate.telephone", "请输入正确的电话号码");
}
}
fieldTipName = "邮箱";
if(StringUtil.isNotEmpty(form.getEmail())){
if(!Pattern.compile("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$").matcher(String.valueOf(form.getEmail())).matches()){
return I18nUtil.getMessageStr("sys.validate.email", "请输入正确的邮箱");
}
}
fieldTipName = "网站";
fieldTipName = "地址";
fieldTipName = "经营范围";
fieldTipName = "备注";
//子表字段验证
if (form.getMdmCompanyBankList()!=null){
fieldTipName = "设计子表"
+ "-" + "开户行";
fieldTipName = "设计子表"
+ "-" + "账户名";
fieldTipName = "设计子表"
+ "-" + "银行账号";
fieldTipName = "设计子表"
+ "-" + "开户行城市";
fieldTipName = "设计子表"
+ "-" + "备注";
}
if (form.getCompanyInvoiceList()!=null){
fieldTipName = "设计子表"
+ "-" + "发票抬头编码";
fieldTipName = "设计子表"
+ "-" + "发票抬头名称";
fieldTipName = "设计子表"
+ "-" + "纳税人识别号";
fieldTipName = "设计子表"
+ "-" + "纳税人类别";
fieldTipName = "设计子表"
+ "-" + "地址";
fieldTipName = "设计子表"
+ "-" + "电话";
fieldTipName = "设计子表"
+ "-" + "开户银行";
fieldTipName = "设计子表"
+ "-" + "银行账户";
fieldTipName = "设计子表"
+ "-" + "是否默认";
fieldTipName = "设计子表"
+ "-" + "是否有效";
fieldTipName = "设计子表"
+ "-" + "备注";
}
return countRecover;
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param companyForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(CompanyForm companyForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
companyForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(CompanyConstant.getFormData(),companyForm,CompanyConstant.TABLERENAMES),CompanyForm.class);
CompanyEntity entity = JsonUtil.getJsonToBean(companyForm, CompanyEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setCompanyCode(generaterSwapUtil.getBillNumber("companyCode", false));
entity.setCompanyId(mainUuid);
} else {
if(StringUtil.isEmpty(entity.getCompanyCode()) ){
entity.setCompanyCode(generaterSwapUtil.getBillNumber("companyCode", false));
}
}
boolean b = this.saveOrUpdate(entity);
CompanyEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
//MdmCompanyBank子表数据新增修改
QueryWrapper<CompanyBankEntity> MdmCompanyBankqueryWrapper = new QueryWrapper<>();
MdmCompanyBankqueryWrapper.lambda().eq(CompanyBankEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(companyForm.getMdmCompanyBankList())){
mdmCompanyBankService.remove(MdmCompanyBankqueryWrapper);
}
if (CollectionUtils.isNotEmpty(companyForm.getMdmCompanyBankList())){
List<CompanyBankEntity> tableFieldad9d92 = JsonUtil.getJsonToList(companyForm.getMdmCompanyBankList(),CompanyBankEntity.class);
//移除的数据
List<Object> childIds = tableFieldad9d92.stream().filter(t->t.getBankId()!=null).map(CompanyBankEntity::getBankId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
MdmCompanyBankqueryWrapper.lambda().notIn(CompanyBankEntity::getBankId,childIds);
}
mdmCompanyBankService.remove(MdmCompanyBankqueryWrapper);
for(CompanyBankEntity entitys : tableFieldad9d92){
entitys.setCompanyId(entity.getCompanyId());
if(entitys.getBankId()==null){
entitys.setBankId(RandomUtil.uuId());
}
mdmCompanyBankService.saveOrUpdate(entitys);
}
}
//CompanyInvoice子表数据新增修改
QueryWrapper<CompanyInvoiceEntity> CompanyInvoicequeryWrapper = new QueryWrapper<>();
CompanyInvoicequeryWrapper.lambda().eq(CompanyInvoiceEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(companyForm.getCompanyInvoiceList())){
companyInvoiceService.remove(CompanyInvoicequeryWrapper);
}
if (CollectionUtils.isNotEmpty(companyForm.getCompanyInvoiceList())){
List<CompanyInvoiceEntity> tableField46dc53 = JsonUtil.getJsonToList(companyForm.getCompanyInvoiceList(),CompanyInvoiceEntity.class);
//移除的数据
List<Object> childIds = tableField46dc53.stream().filter(t->t.getInvoiceId()!=null).map(CompanyInvoiceEntity::getInvoiceId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
CompanyInvoicequeryWrapper.lambda().notIn(CompanyInvoiceEntity::getInvoiceId,childIds);
}
companyInvoiceService.remove(CompanyInvoicequeryWrapper);
for(CompanyInvoiceEntity entitys : tableField46dc53){
entitys.setCompanyId(entity.getCompanyId());
if(isSave || entitys.getInvoiceId()==null){
entitys.setTitleCode(generaterSwapUtil.getBillNumber("InvoiceTitleCode", false));
}else{
if(StringUtil.isEmpty(entitys.getTitleCode()) || entitys.getInvoiceId() == null ){
entitys.setTitleCode(generaterSwapUtil.getBillNumber("InvoiceTitleCode", false));
}
}
if(entitys.getInvoiceId()==null){
entitys.setInvoiceId(RandomUtil.uuId());
}
companyInvoiceService.saveOrUpdate(entitys);
}
}
}
}

View File

@@ -0,0 +1,24 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.CorporationMapper;
import com.yunzhupaas.mdm.service.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
/**
*
* 法人公司
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
@Service
public class CorporationServiceImpl extends SuperServiceImpl<CorporationMapper, CorporationEntity> implements CorporationService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
}

View File

@@ -0,0 +1,509 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.CompanyMapper;
import com.yunzhupaas.mdm.service.*;
import com.yunzhupaas.mdm.model.custinfo.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* 客户信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
@Service
public class CustinfoServiceImpl extends SuperServiceImpl<CompanyMapper, CompanyEntity> implements CustinfoService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private CustomerService customerService;
@Autowired
private CompanyInvoiceService companyInvoiceService;
@Autowired
private CompanyBankService companyBankService;
@Override
public List<CompanyEntity> getList(CustinfoPagination companyPagination){
return getTypeList(companyPagination,companyPagination.getDataType());
}
/** 列表查询 */
@Override
public List<CompanyEntity> getTypeList(CustinfoPagination companyPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_company",CompanyEntity.class);
tableClassMap.put("mdm_company_bank",CompanyBankEntity.class);
tableClassMap.put("mdm_company_invoice",CompanyInvoiceEntity.class);
tableClassMap.put("mdm_customer",CustomerEntity.class);
MPJLambdaWrapper<CompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.selectCollection(CompanyBankEntity.class,CompanyEntity::getCompanyBank)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(CompanyInvoiceEntity.class,CompanyEntity::getCompanyInvoice)
.leftJoin(CompanyInvoiceEntity.class,"mdm_company_invoice",CompanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAssociation(CustomerEntity.class,CompanyEntity::getCustomer)
.leftJoin(CustomerEntity.class,"mdm_customer",CustomerEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAll(CompanyEntity.class);
MPJLambdaWrapper<CompanyEntity> wrapper2 = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.leftJoin(CompanyInvoiceEntity.class,"mdm_company_invoice",CompanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.leftJoin(CustomerEntity.class,"mdm_customer",CustomerEntity::getCompanyId,CompanyEntity::getCompanyId)
.distinct().select(CompanyEntity::getCompanyId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(CustinfoConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? CustinfoConstant.getAppColumnData() : CustinfoConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(companyPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = true;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(companyPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(companyPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(companyPagination, wrapper, isPc);
otherConditions(companyPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) companyPagination.getCurrentPage(), (int) companyPagination.getPageSize(), true);
List<CompanyEntity> userIPage = this.selectJoinList(CompanyEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getCompanyId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(CompanyEntity::getCompanyId,collect);
}
List<CompanyEntity> result = this.selectJoinList(CompanyEntity.class, wrapper);
return companyPagination.setData(result,objects.getTotal());
}else{
List<CompanyEntity> list = this.selectJoinList(CompanyEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(companyPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getCompanyId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(CustinfoPagination companyPagination, MPJLambdaWrapper<CompanyEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
wrapper.isNull(CompanyEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(companyPagination.getYunzhupaasKeyword())){
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(companyPagination.getCompanyName())){
String value = companyPagination.getCompanyName() instanceof List ?
JsonUtil.getObjectToString(companyPagination.getCompanyName()) :
String.valueOf(companyPagination.getCompanyName());
wrapper.like(CompanyEntity::getCompanyName,value);
}
if(ObjectUtil.isNotEmpty(companyPagination.getOrgId())){
List<String> idList = new ArrayList<>();
try {
String[][] orgId = JsonUtil.getJsonToBean(companyPagination.getOrgId(),String[][].class);
for(int i=0;i<orgId.length;i++){
if(orgId[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(orgId[i])));
}
}
}catch (Exception e1){
try {
List<String> orgId = JsonUtil.getJsonToList(companyPagination.getOrgId(),String.class);
if(orgId.size()>0){
idList.add(JsonUtil.getObjectToString(orgId));
}
}catch (Exception e2){
idList.add(String.valueOf(companyPagination.getOrgId()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(CompanyEntity::getOrgId, tt).or();
});
});
}
}
//排序
if(StringUtil.isEmpty(companyPagination.getSidx())){
wrapper.orderByDesc(CompanyEntity::getCompanyId);
}else{
try {
String[] split = companyPagination.getSidx().split(",");
for(String sidx:split){
CompanyEntity companyEntity = new CompanyEntity();
String oderTableField = companyEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = companyEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public CompanyEntity getInfo(String companyid){
MPJLambdaWrapper<CompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.selectCollection(CompanyBankEntity.class,CompanyEntity::getCompanyBank)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(CompanyInvoiceEntity.class,CompanyEntity::getCompanyInvoice)
.leftJoin(CompanyInvoiceEntity.class,"mdm_company_invoice",CompanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAssociation(CustomerEntity.class,CompanyEntity::getCustomer)
.leftJoin(CustomerEntity.class,"mdm_customer",CustomerEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAll(CompanyEntity.class);
wrapper.and(
t->t.eq(CompanyEntity::getCompanyId, companyid )
.or().eq(CompanyEntity::getFlowTaskId, companyid)
);
return this.selectJoinOne(CompanyEntity.class,wrapper);
}
@Override
public void create(CompanyEntity entity){
this.save(entity);
}
@Override
public boolean update(String companyid, CompanyEntity entity){
return this.updateById(entity);
}
@Override
public void delete(CompanyEntity entity){
if(entity!=null){
this.removeById(entity.getCompanyId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(CustinfoForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getCompanyId()) && !form.getCompanyId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getCompanyId();
}
//主表字段验证
fieldTipName = "客户编码";
fieldTipName = "客户名称";
if(StringUtil.isEmpty(form.getCompanyName())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getCompanyName())){
form.setCompanyName(form.getCompanyName().trim());
QueryWrapper<CompanyEntity> company_nameWrapper=new QueryWrapper<>();
company_nameWrapper.lambda().eq(CompanyEntity::getCompanyName,form.getCompanyName());
company_nameWrapper.lambda().isNull(CompanyEntity::getFlowId);
if (isUp){
company_nameWrapper.lambda().ne(CompanyEntity::getCompanyId, id);
}
if((int) this.count(company_nameWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "简称/昵称";
fieldTipName = "类型";
fieldTipName = "社会信用代码";
if(StringUtil.isEmpty(form.getCreditCode())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getCreditCode())){
form.setCreditCode(form.getCreditCode().trim());
QueryWrapper<CompanyEntity> credit_codeWrapper=new QueryWrapper<>();
credit_codeWrapper.lambda().eq(CompanyEntity::getCreditCode,form.getCreditCode());
credit_codeWrapper.lambda().isNull(CompanyEntity::getFlowId);
if (isUp){
credit_codeWrapper.lambda().ne(CompanyEntity::getCompanyId, id);
}
if((int) this.count(credit_codeWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "归属组织";
fieldTipName = "所属地区";
fieldTipName = "纳税人类别";
fieldTipName = "企业规模";
fieldTipName = "企业类型";
fieldTipName = "行业代码";
fieldTipName = "成立日期";
fieldTipName = "注册资本";
fieldTipName = "法定代表人";
fieldTipName = "联系电话";
if(StringUtil.isNotEmpty(form.getPhone())){
if(!Pattern.compile("^1[3456789]\\d{9}$|^0\\d{2,3}-?\\d{7,8}$").matcher(String.valueOf(form.getPhone())).matches()){
return I18nUtil.getMessageStr("sys.validate.telephone", "请输入正确的电话号码");
}
}
fieldTipName = "邮箱";
if(StringUtil.isNotEmpty(form.getEmail())){
if(!Pattern.compile("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$").matcher(String.valueOf(form.getEmail())).matches()){
return I18nUtil.getMessageStr("sys.validate.email", "请输入正确的邮箱");
}
}
fieldTipName = "网站";
fieldTipName = "地址";
fieldTipName = "经营范围";
fieldTipName = "备注";
//副表字段验证
fieldTipName = "销售责任人";
if( form.getYunzhupaas_customer_yunzhupaas_personId() == null ){
return fieldTipName + canNotNull;
}
fieldTipName = "客户级别";
fieldTipName = "客户来源";
//子表字段验证
if (form.getCompanyInvoiceList()!=null){
fieldTipName = "设计子表"
+ "-" + "发票抬头编码";
fieldTipName = "设计子表"
+ "-" + "发票抬头名称";
fieldTipName = "设计子表"
+ "-" + "纳税人识别号";
fieldTipName = "设计子表"
+ "-" + "纳税人类别";
fieldTipName = "设计子表"
+ "-" + "地址";
fieldTipName = "设计子表"
+ "-" + "电话";
fieldTipName = "设计子表"
+ "-" + "开户银行";
fieldTipName = "设计子表"
+ "-" + "银行账户";
fieldTipName = "设计子表"
+ "-" + "是否默认";
fieldTipName = "设计子表"
+ "-" + "是否有效";
fieldTipName = "设计子表"
+ "-" + "备注";
}
if (form.getCompanyBankList()!=null){
fieldTipName = "设计子表"
+ "-" + "开户行";
fieldTipName = "设计子表"
+ "-" + "账户名";
fieldTipName = "设计子表"
+ "-" + "银行账号";
fieldTipName = "设计子表"
+ "-" + "开户行城市";
fieldTipName = "设计子表"
+ "-" + "备注";
}
return countRecover;
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param companyForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(CustinfoForm companyForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
companyForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(CustinfoConstant.getFormData(),companyForm,CustinfoConstant.TABLERENAMES),CustinfoForm.class);
CompanyEntity entity = JsonUtil.getJsonToBean(companyForm, CompanyEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setCompanyCode(generaterSwapUtil.getBillNumber("companyCode", false));
entity.setCompanyId(mainUuid);
} else {
if(StringUtil.isEmpty(entity.getCompanyCode()) ){
entity.setCompanyCode(generaterSwapUtil.getBillNumber("companyCode", false));
}
}
boolean b = this.saveOrUpdate(entity);
CompanyEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
//CompanyInvoice子表数据新增修改
QueryWrapper<CompanyInvoiceEntity> CompanyInvoicequeryWrapper = new QueryWrapper<>();
CompanyInvoicequeryWrapper.lambda().eq(CompanyInvoiceEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(companyForm.getCompanyInvoiceList())){
companyInvoiceService.remove(CompanyInvoicequeryWrapper);
}
if (CollectionUtils.isNotEmpty(companyForm.getCompanyInvoiceList())){
List<CompanyInvoiceEntity> tableField46dc53 = JsonUtil.getJsonToList(companyForm.getCompanyInvoiceList(),CompanyInvoiceEntity.class);
//移除的数据
List<Object> childIds = tableField46dc53.stream().filter(t->t.getInvoiceId()!=null).map(CompanyInvoiceEntity::getInvoiceId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
CompanyInvoicequeryWrapper.lambda().notIn(CompanyInvoiceEntity::getInvoiceId,childIds);
}
companyInvoiceService.remove(CompanyInvoicequeryWrapper);
for(CompanyInvoiceEntity entitys : tableField46dc53){
entitys.setCompanyId(entity.getCompanyId());
if(isSave || entitys.getInvoiceId()==null){
entitys.setTitleCode(generaterSwapUtil.getBillNumber("InvoiceTitleCode", false));
}else{
if(StringUtil.isEmpty(entitys.getTitleCode()) || entitys.getInvoiceId() == null ){
entitys.setTitleCode(generaterSwapUtil.getBillNumber("InvoiceTitleCode", false));
}
}
if(entitys.getInvoiceId()==null){
entitys.setInvoiceId(RandomUtil.uuId());
}
companyInvoiceService.saveOrUpdate(entitys);
}
}
//CompanyBank子表数据新增修改
QueryWrapper<CompanyBankEntity> CompanyBankqueryWrapper = new QueryWrapper<>();
CompanyBankqueryWrapper.lambda().eq(CompanyBankEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(companyForm.getCompanyBankList())){
companyBankService.remove(CompanyBankqueryWrapper);
}
if (CollectionUtils.isNotEmpty(companyForm.getCompanyBankList())){
List<CompanyBankEntity> tableFieldad9d92 = JsonUtil.getJsonToList(companyForm.getCompanyBankList(),CompanyBankEntity.class);
//移除的数据
List<Object> childIds = tableFieldad9d92.stream().filter(t->t.getBankId()!=null).map(CompanyBankEntity::getBankId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
CompanyBankqueryWrapper.lambda().notIn(CompanyBankEntity::getBankId,childIds);
}
companyBankService.remove(CompanyBankqueryWrapper);
for(CompanyBankEntity entitys : tableFieldad9d92){
entitys.setCompanyId(entity.getCompanyId());
if(entitys.getBankId()==null){
entitys.setBankId(RandomUtil.uuId());
}
companyBankService.saveOrUpdate(entitys);
}
}
//mdm_customer副表数据新增修改
Map<String, Object> CustomerMap = generaterSwapUtil.getMastTabelData(companyForm,"mdm_customer");
CustomerEntity customerentity = JsonUtil.getJsonToBean(CustomerMap,CustomerEntity.class);
//自动生成的字段
if(isSave){
customerentity.setCustomerId(RandomUtil.uuId());
customerentity.setCompanyId(entity.getCompanyId());
}else{
QueryWrapper<CustomerEntity> queryWrapperCustomer =new QueryWrapper<>();
queryWrapperCustomer.lambda().eq(CustomerEntity::getCompanyId,info.getCompanyId());
CustomerEntity customerOneEntity= customerService.getOne(queryWrapperCustomer);
customerentity.setCustomerId(customerOneEntity.getCustomerId());
customerentity.setCompanyId(entity.getCompanyId());
}
customerService.saveOrUpdate(customerentity);
}
}

View File

@@ -1,11 +1,11 @@
package com.yunzhupaas.base.service.impl;
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.base.mapper.Pcm_payment_planMapper;
import com.yunzhupaas.base.service.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.CustomersMapper;
import com.yunzhupaas.mdm.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.model.pcmcontract.*;
import com.yunzhupaas.mdm.model.custinfo.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,14 +21,14 @@ import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
/**
*
* pcm_contract
* 客户信息
* 版本 V5.2.7
* 版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者 深圳市乐程软件有限公司
* 日期 2026-03-31
* 日期 2026-04-24
*/
@Service
public class Pcm_payment_planServiceImpl extends SuperServiceImpl<Pcm_payment_planMapper, Pcm_payment_planEntity> implements Pcm_payment_planService{
public class CustomersServiceImpl extends SuperServiceImpl<CustomersMapper, CustomerEntity> implements CustomerService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
}

View File

@@ -0,0 +1,515 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.CompanyMapper;
import com.yunzhupaas.mdm.model.companyInvoice.CompanyInvoiceModel;
import com.yunzhupaas.mdm.service.*;
import com.yunzhupaas.mdm.model.lpc.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* 法人公司
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
@Service
public class LcpServiceImpl extends SuperServiceImpl<CompanyMapper, CompanyEntity> implements LpcService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private CorporationService corporationService;
@Autowired
private CompanyInvoiceService companyInvoiceService;
@Autowired
private CompanyBankService companyBankService;
@Override
public List<CompanyEntity> getList(LpcPagination companyPagination){
return getTypeList(companyPagination,companyPagination.getDataType());
}
/** 列表查询 */
@Override
public List<CompanyEntity> getTypeList(LpcPagination companyPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_company",CompanyEntity.class);
tableClassMap.put("mdm_corporation",CorporationEntity.class);
tableClassMap.put("mdm_company_bank",CompanyBankEntity.class);
tableClassMap.put("mdm_companyInvoice",CompanyInvoiceEntity.class);
MPJLambdaWrapper<CompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.selectAssociation(CorporationEntity.class,CompanyEntity::getCorporation)
.leftJoin(CorporationEntity.class,"mdm_corporation",CorporationEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(CompanyBankEntity.class,CompanyEntity::getCompanyBank)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(CompanyInvoiceEntity.class,CompanyEntity::getCompanyInvoice)
.leftJoin(CompanyInvoiceEntity.class,"mdm_companyInvoice",CompanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAll(CompanyEntity.class);
MPJLambdaWrapper<CompanyEntity> wrapper2 = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.leftJoin(CorporationEntity.class,"mdm_corporation",CorporationEntity::getCompanyId,CompanyEntity::getCompanyId)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.leftJoin(CompanyInvoiceEntity.class,"mdm_companyInvoice",CompanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.distinct().select(CompanyEntity::getCompanyId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(LpcConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? LpcConstant.getAppColumnData() : LpcConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(companyPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = true;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(companyPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(companyPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(companyPagination, wrapper, isPc);
otherConditions(companyPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) companyPagination.getCurrentPage(), (int) companyPagination.getPageSize(), true);
List<CompanyEntity> userIPage = this.selectJoinList(CompanyEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getCompanyId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(CompanyEntity::getCompanyId,collect);
}
List<CompanyEntity> result = this.selectJoinList(CompanyEntity.class, wrapper);
return companyPagination.setData(result,objects.getTotal());
}else{
List<CompanyEntity> list = this.selectJoinList(CompanyEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(companyPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getCompanyId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(LpcPagination companyPagination, MPJLambdaWrapper<CompanyEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
//假删除标志
wrapper.isNull(CompanyEntity::getDeleteMark);
wrapper.isNull(CompanyEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(companyPagination.getYunzhupaasKeyword())){
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(companyPagination.getOrgId())){
List<String> idList = new ArrayList<>();
try {
String[][] orgId = JsonUtil.getJsonToBean(companyPagination.getOrgId(),String[][].class);
for(int i=0;i<orgId.length;i++){
if(orgId[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(orgId[i])));
}
}
}catch (Exception e1){
try {
List<String> orgId = JsonUtil.getJsonToList(companyPagination.getOrgId(),String.class);
if(orgId.size()>0){
idList.add(JsonUtil.getObjectToString(orgId));
}
}catch (Exception e2){
idList.add(String.valueOf(companyPagination.getOrgId()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(CompanyEntity::getOrgId, tt).or();
});
});
}
if(ObjectUtil.isNotEmpty(companyPagination.getCompanyName())){
String value = companyPagination.getCompanyName() instanceof List ?
JsonUtil.getObjectToString(companyPagination.getCompanyName()) :
String.valueOf(companyPagination.getCompanyName());
wrapper.like(CompanyEntity::getCompanyName,value);
}
}
//排序
if(StringUtil.isEmpty(companyPagination.getSidx())){
wrapper.orderByDesc(CompanyEntity::getCompanyId);
}else{
try {
String[] split = companyPagination.getSidx().split(",");
for(String sidx:split){
CompanyEntity companyEntity = new CompanyEntity();
String oderTableField = companyEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = companyEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public CompanyEntity getInfo(String companyid){
MPJLambdaWrapper<CompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.selectAssociation(CorporationEntity.class,CompanyEntity::getCorporation)
.leftJoin(CorporationEntity.class,"mdm_corporation",CorporationEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(CompanyBankEntity.class,CompanyEntity::getCompanyBank)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(CompanyInvoiceEntity.class,CompanyEntity::getCompanyInvoice)
.leftJoin(CompanyInvoiceEntity.class,"mdm_companyInvoice",CompanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAll(CompanyEntity.class);
wrapper.and(
t->t.eq(CompanyEntity::getCompanyId, companyid )
.or().eq(CompanyEntity::getFlowTaskId, companyid)
);
return this.selectJoinOne(CompanyEntity.class,wrapper);
}
@Override
public void create(CompanyEntity entity){
this.save(entity);
}
@Override
public boolean update(String companyid, CompanyEntity entity){
return this.updateById(entity);
}
@Override
public void delete(CompanyEntity entity){
if(entity!=null){
this.removeById(entity.getCompanyId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(LpcForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getCompanyId()) && !form.getCompanyId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getCompanyId();
}
//主表字段验证
fieldTipName = "实体类型";
fieldTipName = "企业编码";
fieldTipName = "企业名称";
if(StringUtil.isEmpty(form.getCompanyName())){
return fieldTipName + canNotNull;
}
fieldTipName = "简称/昵称";
fieldTipName = "社会信用代码";
if(StringUtil.isEmpty(form.getCreditCode())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getCreditCode())){
form.setCreditCode(form.getCreditCode().trim());
QueryWrapper<CompanyEntity> credit_codeWrapper=new QueryWrapper<>();
credit_codeWrapper.lambda().eq(CompanyEntity::getCreditCode,form.getCreditCode());
credit_codeWrapper.lambda().isNull(CompanyEntity::getFlowId);
//假删除标志
credit_codeWrapper.lambda().isNull(CompanyEntity::getDeleteMark);
if (isUp){
credit_codeWrapper.lambda().ne(CompanyEntity::getCompanyId, id);
}
if((int) this.count(credit_codeWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "纳税人类别";
fieldTipName = "归属组织";
fieldTipName = "所属地区";
fieldTipName = "企业类型";
fieldTipName = "行业代码";
fieldTipName = "企业规模";
fieldTipName = "成立日期";
fieldTipName = "注册资本";
fieldTipName = "法定代表人";
fieldTipName = "联系电话";
fieldTipName = "邮箱";
fieldTipName = "网站";
fieldTipName = "地址";
fieldTipName = "经营范围";
fieldTipName = "备注";
//副表字段验证
fieldTipName = "负责人";
if( form.getYunzhupaas_corporation_yunzhupaas_majorPersonId() == null ){
return fieldTipName + canNotNull;
}
//子表字段验证
if (form.getCompanyInvoiceList()!=null){
fieldTipName = "设计子表"
+ "-" + "发票抬头编码";
fieldTipName = "设计子表"
+ "-" + "发票抬头名称";
for(CompanyInvoiceModel t : form.getCompanyInvoiceList()){
if( StringUtil.isNotEmpty(t.getTitleName()) ){
t.setTitleName(t.getTitleName().trim());
}
else{
return fieldTipName + canNotNull;
}
}
fieldTipName = "设计子表"
+ "-" + "纳税人识别号";
for(CompanyInvoiceModel t : form.getCompanyInvoiceList()){
if( StringUtil.isNotEmpty(t.getCreditCode()) ){
t.setCreditCode(t.getCreditCode().trim());
}
else{
return fieldTipName + canNotNull;
}
}
fieldTipName = "设计子表"
+ "-" + "纳税人类别";
for(CompanyInvoiceModel t : form.getCompanyInvoiceList()){
if( t.getTaxType() != null ){
t.setTaxType(t.getTaxType());
}
else{
return fieldTipName + canNotNull;
}
}
fieldTipName = "设计子表"
+ "-" + "地址";
fieldTipName = "设计子表"
+ "-" + "电话";
fieldTipName = "设计子表"
+ "-" + "开户银行";
fieldTipName = "设计子表"
+ "-" + "银行账户";
fieldTipName = "设计子表"
+ "-" + "是否默认抬头";
fieldTipName = "设计子表"
+ "-" + "是否有效";
fieldTipName = "设计子表"
+ "-" + "备注";
}
if (form.getCompanyBankList()!=null){
fieldTipName = "设计子表"
+ "-" + "开户行";
fieldTipName = "设计子表"
+ "-" + "账户名";
fieldTipName = "设计子表"
+ "-" + "银行账号";
fieldTipName = "设计子表"
+ "-" + "开户行城市";
fieldTipName = "设计子表"
+ "-" + "备注";
}
return countRecover;
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param companyForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(LpcForm companyForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
companyForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(LpcConstant.getFormData(),companyForm,LpcConstant.TABLERENAMES),LpcForm.class);
CompanyEntity entity = JsonUtil.getJsonToBean(companyForm, CompanyEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setCompanyCode(generaterSwapUtil.getBillNumber("companyCode", false));
entity.setCompanyId(mainUuid);
} else {
if(StringUtil.isEmpty(entity.getCompanyCode()) ){
entity.setCompanyCode(generaterSwapUtil.getBillNumber("companyCode", false));
}
}
boolean b = this.saveOrUpdate(entity);
CompanyEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
//CompanyInvoice子表数据新增修改
QueryWrapper<CompanyInvoiceEntity> CompanyInvoicequeryWrapper = new QueryWrapper<>();
CompanyInvoicequeryWrapper.lambda().eq(CompanyInvoiceEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(companyForm.getCompanyInvoiceList())){
companyInvoiceService.remove(CompanyInvoicequeryWrapper);
}
if (CollectionUtils.isNotEmpty(companyForm.getCompanyInvoiceList())){
List<CompanyInvoiceEntity> tableField5ced3a = JsonUtil.getJsonToList(companyForm.getCompanyInvoiceList(),CompanyInvoiceEntity.class);
//移除的数据
List<Object> childIds = tableField5ced3a.stream().filter(t->t.getInvoiceId()!=null).map(CompanyInvoiceEntity::getInvoiceId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
CompanyInvoicequeryWrapper.lambda().notIn(CompanyInvoiceEntity::getInvoiceId,childIds);
}
companyInvoiceService.remove(CompanyInvoicequeryWrapper);
for(CompanyInvoiceEntity entitys : tableField5ced3a){
entitys.setCompanyId(entity.getCompanyId());
if(isSave || entitys.getInvoiceId()==null){
entitys.setTitleCode(generaterSwapUtil.getBillNumber("InvoiceTitleCode", false));
}else{
if(StringUtil.isEmpty(entitys.getTitleCode()) || entitys.getInvoiceId() == null ){
entitys.setTitleCode(generaterSwapUtil.getBillNumber("InvoiceTitleCode", false));
}
}
if(entitys.getInvoiceId()==null){
entitys.setInvoiceId(RandomUtil.uuId());
}
companyInvoiceService.saveOrUpdate(entitys);
}
}
//CompanyBank子表数据新增修改
QueryWrapper<CompanyBankEntity> CompanyBankqueryWrapper = new QueryWrapper<>();
CompanyBankqueryWrapper.lambda().eq(CompanyBankEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(companyForm.getCompanyBankList())){
companyBankService.remove(CompanyBankqueryWrapper);
}
if (CollectionUtils.isNotEmpty(companyForm.getCompanyBankList())){
List<CompanyBankEntity> tableFieldbd0aa4 = JsonUtil.getJsonToList(companyForm.getCompanyBankList(),CompanyBankEntity.class);
//移除的数据
List<Object> childIds = tableFieldbd0aa4.stream().filter(t->t.getBankId()!=null).map(CompanyBankEntity::getBankId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
CompanyBankqueryWrapper.lambda().notIn(CompanyBankEntity::getBankId,childIds);
}
companyBankService.remove(CompanyBankqueryWrapper);
for(CompanyBankEntity entitys : tableFieldbd0aa4){
entitys.setCompanyId(entity.getCompanyId());
if(entitys.getBankId()==null){
entitys.setBankId(RandomUtil.uuId());
}
companyBankService.saveOrUpdate(entitys);
}
}
//mdm_corporation副表数据新增修改
Map<String, Object> CorporationMap = generaterSwapUtil.getMastTabelData(companyForm,"mdm_corporation");
CorporationEntity corporationentity = JsonUtil.getJsonToBean(CorporationMap,CorporationEntity.class);
//自动生成的字段
if(isSave){
corporationentity.setCorporationId(RandomUtil.uuId());
corporationentity.setCompanyId(entity.getCompanyId());
}else{
QueryWrapper<CorporationEntity> queryWrapperCorporation =new QueryWrapper<>();
queryWrapperCorporation.lambda().eq(CorporationEntity::getCompanyId,info.getCompanyId());
CorporationEntity corporationOneEntity= corporationService.getOne(queryWrapperCorporation);
corporationentity.setCorporationId(corporationOneEntity.getCorporationId());
corporationentity.setCompanyId(entity.getCompanyId());
}
corporationService.saveOrUpdate(corporationentity);
}
}

View File

@@ -0,0 +1,336 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.MaterialMapper;
import com.yunzhupaas.mdm.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.mdm.model.material.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* 物料信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-27
*/
@Service
public class MaterialServiceImpl extends SuperServiceImpl<MaterialMapper, MaterialEntity> implements MaterialService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<MaterialEntity> getList(MaterialPagination materialPagination){
return getTypeList(materialPagination,materialPagination.getDataType());
}
/** 列表查询 */
@Override
public List<MaterialEntity> getTypeList(MaterialPagination materialPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_material",MaterialEntity.class);
MPJLambdaWrapper<MaterialEntity> wrapper = JoinWrappers
.lambda("mdm_material",MaterialEntity.class)
.selectAll(MaterialEntity.class);
MPJLambdaWrapper<MaterialEntity> wrapper2 = JoinWrappers
.lambda("mdm_material",MaterialEntity.class)
.distinct().select(MaterialEntity::getMaterialId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(MaterialConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? MaterialConstant.getAppColumnData() : MaterialConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(materialPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = false;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(materialPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(materialPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(materialPagination, wrapper, isPc);
otherConditions(materialPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) materialPagination.getCurrentPage(), (int) materialPagination.getPageSize(), true);
List<MaterialEntity> userIPage = this.selectJoinList(MaterialEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getMaterialId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(MaterialEntity::getMaterialId,collect);
}
List<MaterialEntity> result = this.selectJoinList(MaterialEntity.class, wrapper);
return materialPagination.setData(result,objects.getTotal());
}else{
List<MaterialEntity> list = this.selectJoinList(MaterialEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(materialPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getMaterialId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(MaterialPagination materialPagination, MPJLambdaWrapper<MaterialEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
//假删除标志
wrapper.isNull(MaterialEntity::getDeleteMark);
wrapper.isNull(MaterialEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(materialPagination.getYunzhupaasKeyword())){
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(materialPagination.getMaterialName())){
String value = materialPagination.getMaterialName() instanceof List ?
JsonUtil.getObjectToString(materialPagination.getMaterialName()) :
String.valueOf(materialPagination.getMaterialName());
wrapper.like(MaterialEntity::getMaterialName,value);
}
if(ObjectUtil.isNotEmpty(materialPagination.getMaterialModel())){
String value = materialPagination.getMaterialModel() instanceof List ?
JsonUtil.getObjectToString(materialPagination.getMaterialModel()) :
String.valueOf(materialPagination.getMaterialModel());
wrapper.like(MaterialEntity::getMaterialModel,value);
}
if(ObjectUtil.isNotEmpty(materialPagination.getMaterialCategory())){
String value = materialPagination.getMaterialCategory() instanceof List ?
JsonUtil.getObjectToString(materialPagination.getMaterialCategory()) :
String.valueOf(materialPagination.getMaterialCategory());
wrapper.like(MaterialEntity::getMaterialCategory,value);
}
}
//排序
if(StringUtil.isEmpty(materialPagination.getSidx())){
wrapper.orderByDesc(MaterialEntity::getMaterialId);
}else{
try {
String[] split = materialPagination.getSidx().split(",");
for(String sidx:split){
MaterialEntity materialEntity = new MaterialEntity();
String oderTableField = materialEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = materialEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public MaterialEntity getInfo(String materialid){
MPJLambdaWrapper<MaterialEntity> wrapper = JoinWrappers
.lambda("mdm_material",MaterialEntity.class)
.selectAll(MaterialEntity.class);
wrapper.and(
t->t.eq(MaterialEntity::getMaterialId, materialid )
.or().eq(MaterialEntity::getFlowTaskId, materialid)
);
return this.selectJoinOne(MaterialEntity.class,wrapper);
}
@Override
public void create(MaterialEntity entity){
this.save(entity);
}
@Override
public boolean update(String materialid, MaterialEntity entity){
return this.updateById(entity);
}
@Override
public void delete(MaterialEntity entity){
if(entity!=null){
this.removeById(entity.getMaterialId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(MaterialForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getMaterialId()) && !form.getMaterialId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getMaterialId();
}
//验证业务主键
String businessErr = checkBusinessKey(form, isUp ? id : null, null);
if (StringUtil.isNotEmpty(businessErr)) {
return businessErr;
}
//主表字段验证
fieldTipName = "物料编码";
fieldTipName = "物料名称";
fieldTipName = "物料分类";
fieldTipName = "规格型号";
fieldTipName = "单位名称";
fieldTipName = "品牌";
fieldTipName = "税率";
fieldTipName = "税收分类";
fieldTipName = "材质/纹理";
fieldTipName = "质量标准";
fieldTipName = "技术标准";
fieldTipName = "验收标准";
fieldTipName = "交付要求";
fieldTipName = "储存条件";
return countRecover;
}
/**
* 验证业务主键
*/
private String checkBusinessKey(MaterialForm form, Object id, List<String> flowIds){
QueryWrapper<MaterialEntity> wrapper = new QueryWrapper<>();
//修改
if (id != null){
wrapper.lambda().ne(MaterialEntity::getMaterialId, id);
}
//是否流程
if(flowIds == null){
wrapper.lambda().isNull(MaterialEntity::getFlowId);
}else{
wrapper.lambda().in(MaterialEntity::getFlowId, flowIds);
}
//假删除标志
wrapper.lambda().isNull(MaterialEntity::getDeleteMark);
//物料名称字段判断
if(form.getMaterialName() == null || form.getMaterialName().toString().trim().isEmpty()){
wrapper.lambda().isNull(MaterialEntity::getMaterialName);
}else{
wrapper.lambda().eq(MaterialEntity::getMaterialName, form.getMaterialName());
}
//物料分类字段判断
if(form.getMaterialCategory() == null || form.getMaterialCategory().toString().trim().isEmpty()
||(form.getMaterialCategory() instanceof List && ((List) form.getMaterialCategory()).size() == 0)){
wrapper.lambda().isNull(MaterialEntity::getMaterialCategory);
}else{
Object obj = form.getMaterialCategory() instanceof List ?JsonUtil.getObjectToString(form.getMaterialCategory()):form.getMaterialCategory();
wrapper.lambda().eq(MaterialEntity::getMaterialCategory, obj);
}
if((int) this.count(wrapper)>0){
return "该物料分类下,该物料名称数据已存在,请勿重复提交!";
}
return "";
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param materialForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(MaterialForm materialForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
materialForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(MaterialConstant.getFormData(),materialForm,MaterialConstant.TABLERENAMES),MaterialForm.class);
MaterialEntity entity = JsonUtil.getJsonToBean(materialForm, MaterialEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setMaterialCode(generaterSwapUtil.getBillNumber("materialCode", false));
entity.setMaterialId(mainUuid);
entity.setVersion(0);
} else {
if(StringUtil.isEmpty(entity.getMaterialCode()) ){
entity.setMaterialCode(generaterSwapUtil.getBillNumber("materialCode", false));
}
}
boolean b = this.saveOrUpdate(entity);
if(!b){
throw new DataException("当前表单原数据已被调整,请重新进入该页面编辑并提交数据");
}
MaterialEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
}
}

View File

@@ -0,0 +1,24 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.PanyInvoiceMapper;
import com.yunzhupaas.mdm.service.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
/**
*
* 供应商信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
@Service
public class PanyInvoiceServiceImpl extends SuperServiceImpl<PanyInvoiceMapper, PanyInvoiceEntity> implements PanyInvoiceService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
}

View File

@@ -0,0 +1,366 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.ProductsMapper;
import com.yunzhupaas.mdm.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.mdm.model.product.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* 商品信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-27
*/
@Service
public class ProductsServiceImpl extends SuperServiceImpl<ProductsMapper, ProductEntity> implements ProductsService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<ProductEntity> getList(ProductPagination productPagination){
return getTypeList(productPagination,productPagination.getDataType());
}
/** 列表查询 */
@Override
public List<ProductEntity> getTypeList(ProductPagination productPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_product",ProductEntity.class);
MPJLambdaWrapper<ProductEntity> wrapper = JoinWrappers
.lambda("mdm_product",ProductEntity.class)
.selectAll(ProductEntity.class);
MPJLambdaWrapper<ProductEntity> wrapper2 = JoinWrappers
.lambda("mdm_product",ProductEntity.class)
.distinct().select(ProductEntity::getProductId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(ProductsConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? ProductsConstant.getAppColumnData() : ProductsConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(productPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = true;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(productPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(productPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(productPagination, wrapper, isPc);
otherConditions(productPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) productPagination.getCurrentPage(), (int) productPagination.getPageSize(), true);
List<ProductEntity> userIPage = this.selectJoinList(ProductEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getProductId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(ProductEntity::getProductId,collect);
}
List<ProductEntity> result = this.selectJoinList(ProductEntity.class, wrapper);
return productPagination.setData(result,objects.getTotal());
}else{
List<ProductEntity> list = this.selectJoinList(ProductEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(productPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getProductId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(ProductPagination productPagination, MPJLambdaWrapper<ProductEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
//假删除标志
wrapper.isNull(ProductEntity::getDeleteMark);
wrapper.isNull(ProductEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(productPagination.getYunzhupaasKeyword())){
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(productPagination.getProductName())){
String value = productPagination.getProductName() instanceof List ?
JsonUtil.getObjectToString(productPagination.getProductName()) :
String.valueOf(productPagination.getProductName());
wrapper.like(ProductEntity::getProductName,value);
}
if(ObjectUtil.isNotEmpty(productPagination.getProductCategory())){
List<String> idList = new ArrayList<>();
try {
String[][] productCategory = JsonUtil.getJsonToBean(productPagination.getProductCategory(),String[][].class);
for(int i=0;i<productCategory.length;i++){
if(productCategory[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(productCategory[i])));
}
}
}catch (Exception e1){
try {
List<String> productCategory = JsonUtil.getJsonToList(productPagination.getProductCategory(),String.class);
if(productCategory.size()>0){
idList.add(JsonUtil.getObjectToString(productCategory));
}
}catch (Exception e2){
idList.add(String.valueOf(productPagination.getProductCategory()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(ProductEntity::getProductCategory, tt).or();
});
});
}
if(ObjectUtil.isNotEmpty(productPagination.getProductType())){
wrapper.eq(ProductEntity::getProductType,productPagination.getProductType());
}
}
//排序
if(StringUtil.isEmpty(productPagination.getSidx())){
wrapper.orderByDesc(ProductEntity::getProductId);
}else{
try {
String[] split = productPagination.getSidx().split(",");
for(String sidx:split){
ProductEntity productEntity = new ProductEntity();
String oderTableField = productEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = productEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public ProductEntity getInfo(String productid){
MPJLambdaWrapper<ProductEntity> wrapper = JoinWrappers
.lambda("mdm_product",ProductEntity.class)
.selectAll(ProductEntity.class);
wrapper.and(
t->t.eq(ProductEntity::getProductId, productid )
.or().eq(ProductEntity::getFlowTaskId, productid)
);
return this.selectJoinOne(ProductEntity.class,wrapper);
}
@Override
public void create(ProductEntity entity){
this.save(entity);
}
@Override
public boolean update(String productid, ProductEntity entity){
return this.updateById(entity);
}
@Override
public void delete(ProductEntity entity){
if(entity!=null){
this.removeById(entity.getProductId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(ProductForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getProductId()) && !form.getProductId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getProductId();
}
//验证业务主键
String businessErr = checkBusinessKey(form, isUp ? id : null, null);
if (StringUtil.isNotEmpty(businessErr)) {
return businessErr;
}
//主表字段验证
fieldTipName = "商品编码";
fieldTipName = "商品名称";
if(StringUtil.isEmpty(form.getProductName())){
return fieldTipName + canNotNull;
}
fieldTipName = "商品类型";
fieldTipName = "商品分类";
fieldTipName = "商品简称";
fieldTipName = "品牌";
fieldTipName = "规格型号";
fieldTipName = "颜色";
fieldTipName = "尺寸/规格";
fieldTipName = "重量";
fieldTipName = "最小起订量";
fieldTipName = "标准销售单价";
fieldTipName = "毛重";
fieldTipName = "净重";
fieldTipName = "单位名称";
fieldTipName = "包装尺寸";
fieldTipName = "成本价";
fieldTipName = "保修期";
fieldTipName = "税率";
fieldTipName = "税收分类";
fieldTipName = "保修条款";
fieldTipName = "备注";
return countRecover;
}
/**
* 验证业务主键
*/
private String checkBusinessKey(ProductForm form, Object id, List<String> flowIds){
QueryWrapper<ProductEntity> wrapper = new QueryWrapper<>();
//修改
if (id != null){
wrapper.lambda().ne(ProductEntity::getProductId, id);
}
//是否流程
if(flowIds == null){
wrapper.lambda().isNull(ProductEntity::getFlowId);
}else{
wrapper.lambda().in(ProductEntity::getFlowId, flowIds);
}
//假删除标志
wrapper.lambda().isNull(ProductEntity::getDeleteMark);
//商品名称字段判断
if(form.getProductName() == null || form.getProductName().toString().trim().isEmpty()){
wrapper.lambda().isNull(ProductEntity::getProductName);
}else{
wrapper.lambda().eq(ProductEntity::getProductName, form.getProductName());
}
//商品分类字段判断
if(form.getProductCategory() == null || form.getProductCategory().toString().trim().isEmpty()
||(form.getProductCategory() instanceof List && ((List) form.getProductCategory()).size() == 0)){
wrapper.lambda().isNull(ProductEntity::getProductCategory);
}else{
Object obj = form.getProductCategory() instanceof List ?JsonUtil.getObjectToString(form.getProductCategory()):form.getProductCategory();
wrapper.lambda().eq(ProductEntity::getProductCategory, obj);
}
if((int) this.count(wrapper)>0){
return "商品分类下,商品名称数据已存在,请勿重复提交!";
}
return "";
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param productForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(ProductForm productForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
productForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(ProductsConstant.getFormData(),productForm,ProductsConstant.TABLERENAMES),ProductForm.class);
ProductEntity entity = JsonUtil.getJsonToBean(productForm, ProductEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setProductCode(generaterSwapUtil.getBillNumber("productCode", false));
entity.setProductId(mainUuid);
entity.setVersion(0);
} else {
if(StringUtil.isEmpty(entity.getProductCode()) ){
entity.setProductCode(generaterSwapUtil.getBillNumber("productCode", false));
}
}
boolean b = this.saveOrUpdate(entity);
if(!b){
throw new DataException("当前表单原数据已被调整,请重新进入该页面编辑并提交数据");
}
ProductEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
}
}

View File

@@ -0,0 +1,520 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.CompanyMapper;
import com.yunzhupaas.mdm.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.mdm.model.suppinfo.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
/**
*
* 供应商信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
@Service
public class SuppinfoServiceImpl extends SuperServiceImpl<CompanyMapper, CompanyEntity> implements SuppinfoService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private SupplierService supplierService;
@Autowired
private PanyInvoiceService panyInvoiceService;
@Autowired
private CompanyBankService companyBankService;
@Override
public List<CompanyEntity> getList(SuppinfoPagination companyPagination){
return getTypeList(companyPagination,companyPagination.getDataType());
}
/** 列表查询 */
@Override
public List<CompanyEntity> getTypeList(SuppinfoPagination companyPagination,String dataType){
String userId=userProvider.get().getUserId();
Map<String,Class> tableClassMap=new HashMap<>();
tableClassMap.put("mdm_company",CompanyEntity.class);
tableClassMap.put("mdm_company_bank",CompanyBankEntity.class);
tableClassMap.put("mdm_company_invoice",PanyInvoiceEntity.class);
tableClassMap.put("mdm_supplier",SupplierEntity.class);
MPJLambdaWrapper<CompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.selectCollection(CompanyBankEntity.class,CompanyEntity::getCompanyBank)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(PanyInvoiceEntity.class,CompanyEntity::getPanyInvoice)
.leftJoin(PanyInvoiceEntity.class,"mdm_company_invoice",PanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAssociation(SupplierEntity.class,CompanyEntity::getSupplier)
.leftJoin(SupplierEntity.class,"mdm_supplier",SupplierEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAll(CompanyEntity.class);
MPJLambdaWrapper<CompanyEntity> wrapper2 = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.leftJoin(PanyInvoiceEntity.class,"mdm_company_invoice",PanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.leftJoin(SupplierEntity.class,"mdm_supplier",SupplierEntity::getCompanyId,CompanyEntity::getCompanyId)
.distinct().select(CompanyEntity::getCompanyId);
QueryAllModel queryAllModel = new QueryAllModel();
queryAllModel.setWrapper(wrapper);
queryAllModel.setClassMap(tableClassMap);
queryAllModel.setDbLink(SuppinfoConstant.DBLINKID);
//数据过滤
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
String columnData = !isPc ? SuppinfoConstant.getAppColumnData() : SuppinfoConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
queryAllModel.setRuleJson(ruleJson);
//高级查询
boolean hasSuperQuery = true;
if (hasSuperQuery) {
queryAllModel.setSuperJson(companyPagination.getSuperQueryJson());
}
//数据权限
boolean pcPermission = true;
boolean appPermission = false;
if (isPc && pcPermission) {
queryAllModel.setModuleId(companyPagination.getMenuId());
}
if (!isPc && appPermission) {
queryAllModel.setModuleId(companyPagination.getMenuId());
}
//拼接复杂条件
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
if(wrapper == null) return new ArrayList<>();
queryAllModel.setWrapper(wrapper2);
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
//其他条件拼接
otherConditions(companyPagination, wrapper, isPc);
otherConditions(companyPagination, wrapper2, isPc);
if("0".equals(dataType)){
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) companyPagination.getCurrentPage(), (int) companyPagination.getPageSize(), true);
List<CompanyEntity> userIPage = this.selectJoinList(CompanyEntity.class, wrapper2);
List<Object> collect = userIPage.stream().map(t -> t.getCompanyId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(collect)){
wrapper.in(CompanyEntity::getCompanyId,collect);
}
List<CompanyEntity> result = this.selectJoinList(CompanyEntity.class, wrapper);
return companyPagination.setData(result,objects.getTotal());
}else{
List<CompanyEntity> list = this.selectJoinList(CompanyEntity.class, wrapper);
if("2".equals(dataType)){
List<Object> selectIds = Arrays.asList(companyPagination.getSelectIds());
return list.stream().filter(t -> selectIds.contains(t.getCompanyId())).collect(Collectors.toList());
}else{
return list;
}
}
}
/**
* 其他条件拼接
*/
private void otherConditions(SuppinfoPagination companyPagination, MPJLambdaWrapper<CompanyEntity> wrapper, boolean isPc) {
String databaseName;
try {
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
} catch (SQLException e) {
throw new DataException(e.getMessage());
}
wrapper.isNull(CompanyEntity::getFlowId);
//关键词
if(ObjectUtil.isNotEmpty(companyPagination.getYunzhupaasKeyword())){
}
//普通查询
if(isPc){
if(ObjectUtil.isNotEmpty(companyPagination.getCompanyName())){
String value = companyPagination.getCompanyName() instanceof List ?
JsonUtil.getObjectToString(companyPagination.getCompanyName()) :
String.valueOf(companyPagination.getCompanyName());
wrapper.like(CompanyEntity::getCompanyName,value);
}
if(ObjectUtil.isNotEmpty(companyPagination.getOrgId())){
List<String> idList = new ArrayList<>();
try {
String[][] orgId = JsonUtil.getJsonToBean(companyPagination.getOrgId(),String[][].class);
for(int i=0;i<orgId.length;i++){
if(orgId[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(orgId[i])));
}
}
}catch (Exception e1){
try {
List<String> orgId = JsonUtil.getJsonToList(companyPagination.getOrgId(),String.class);
if(orgId.size()>0){
idList.add(JsonUtil.getObjectToString(orgId));
}
}catch (Exception e2){
idList.add(String.valueOf(companyPagination.getOrgId()));
}
}
wrapper.and(t->{
idList.forEach(tt->{
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
tt = tt.replaceFirst("\\[","[[]");
}
t.like(CompanyEntity::getOrgId, tt).or();
});
});
}
}
//排序
if(StringUtil.isEmpty(companyPagination.getSidx())){
wrapper.orderByDesc(CompanyEntity::getCompanyId);
}else{
try {
String[] split = companyPagination.getSidx().split(",");
for(String sidx:split){
CompanyEntity companyEntity = new CompanyEntity();
String oderTableField = companyEntity.getClass().getAnnotation(TableName.class).value();
boolean descFlag = sidx.startsWith("-");
String sidxField = descFlag ? sidx.substring(1) : sidx;
try{
Field declaredField = companyEntity.getClass().getDeclaredField(sidxField);
declaredField.setAccessible(true);
sidxField = declaredField.getAnnotation(TableField.class).value();
}catch (Exception e){
}
String finalOderTableField = oderTableField;
String finalSidxField = sidxField;
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
oderTableField = oderTableField + "." + sidxField;
if (select == null) {
wrapper.select(oderTableField);
}
if (descFlag) {
wrapper.orderByDesc(oderTableField);
} else {
wrapper.orderByAsc(oderTableField);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public CompanyEntity getInfo(String companyid){
MPJLambdaWrapper<CompanyEntity> wrapper = JoinWrappers
.lambda("mdm_company",CompanyEntity.class)
.selectCollection(CompanyBankEntity.class,CompanyEntity::getCompanyBank)
.leftJoin(CompanyBankEntity.class,"mdm_company_bank",CompanyBankEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectCollection(PanyInvoiceEntity.class,CompanyEntity::getPanyInvoice)
.leftJoin(PanyInvoiceEntity.class,"mdm_company_invoice",PanyInvoiceEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAssociation(SupplierEntity.class,CompanyEntity::getSupplier)
.leftJoin(SupplierEntity.class,"mdm_supplier",SupplierEntity::getCompanyId,CompanyEntity::getCompanyId)
.selectAll(CompanyEntity.class);
wrapper.and(
t->t.eq(CompanyEntity::getCompanyId, companyid )
.or().eq(CompanyEntity::getFlowTaskId, companyid)
);
return this.selectJoinOne(CompanyEntity.class,wrapper);
}
@Override
public void create(CompanyEntity entity){
this.save(entity);
}
@Override
public boolean update(String companyid, CompanyEntity entity){
return this.updateById(entity);
}
@Override
public void delete(CompanyEntity entity){
if(entity!=null){
this.removeById(entity.getCompanyId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(SuppinfoForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getCompanyId()) && !form.getCompanyId().equals("0");
Object id= null;
String countRecover = "";
String fieldTipName = "";
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
if (isUp){
id = form.getCompanyId();
}
//主表字段验证
fieldTipName = "企业编码";
fieldTipName = "企业名称";
if(StringUtil.isEmpty(form.getCompanyName())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getCompanyName())){
form.setCompanyName(form.getCompanyName().trim());
QueryWrapper<CompanyEntity> company_nameWrapper=new QueryWrapper<>();
company_nameWrapper.lambda().eq(CompanyEntity::getCompanyName,form.getCompanyName());
company_nameWrapper.lambda().isNull(CompanyEntity::getFlowId);
if (isUp){
company_nameWrapper.lambda().ne(CompanyEntity::getCompanyId, id);
}
if((int) this.count(company_nameWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "简称/昵称";
fieldTipName = "类型";
fieldTipName = "社会信用代码";
if(StringUtil.isEmpty(form.getCreditCode())){
return fieldTipName + canNotNull;
}
if(StringUtil.isNotEmpty(form.getCreditCode())){
form.setCreditCode(form.getCreditCode().trim());
QueryWrapper<CompanyEntity> credit_codeWrapper=new QueryWrapper<>();
credit_codeWrapper.lambda().eq(CompanyEntity::getCreditCode,form.getCreditCode());
credit_codeWrapper.lambda().isNull(CompanyEntity::getFlowId);
if (isUp){
credit_codeWrapper.lambda().ne(CompanyEntity::getCompanyId, id);
}
if((int) this.count(credit_codeWrapper)>0){
countRecover = fieldTipName + canNotRepeated;
}
}
fieldTipName = "归属组织";
fieldTipName = "所属地区";
fieldTipName = "纳税人类别";
fieldTipName = "企业规模";
fieldTipName = "企业类型";
fieldTipName = "行业代码";
fieldTipName = "成立日期";
fieldTipName = "注册资本";
fieldTipName = "法定代表人";
fieldTipName = "联系电话";
if(StringUtil.isNotEmpty(form.getPhone())){
if(!Pattern.compile("^1[3456789]\\d{9}$|^0\\d{2,3}-?\\d{7,8}$").matcher(String.valueOf(form.getPhone())).matches()){
return I18nUtil.getMessageStr("sys.validate.telephone", "请输入正确的电话号码");
}
}
fieldTipName = "邮箱";
if(StringUtil.isNotEmpty(form.getEmail())){
if(!Pattern.compile("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$").matcher(String.valueOf(form.getEmail())).matches()){
return I18nUtil.getMessageStr("sys.validate.email", "请输入正确的邮箱");
}
}
fieldTipName = "网站";
fieldTipName = "地址";
fieldTipName = "经营范围";
fieldTipName = "备注";
//副表字段验证
fieldTipName = "责任人";
if( form.getYunzhupaas_supplier_yunzhupaas_majorPersonId() == null ){
return fieldTipName + canNotNull;
}
fieldTipName = "供应商级别";
fieldTipName = "供应商类型";
fieldTipName = "供应商分类";
fieldTipName = "荣誉、资质";
fieldTipName = "供应商业绩";
fieldTipName = "完工项目";
//子表字段验证
if (form.getPanyInvoiceList()!=null){
fieldTipName = "设计子表"
+ "-" + "发票抬头编码";
fieldTipName = "设计子表"
+ "-" + "发票抬头名称";
fieldTipName = "设计子表"
+ "-" + "纳税人识别号";
fieldTipName = "设计子表"
+ "-" + "纳税人类别";
fieldTipName = "设计子表"
+ "-" + "地址";
fieldTipName = "设计子表"
+ "-" + "电话";
fieldTipName = "设计子表"
+ "-" + "开户银行";
fieldTipName = "设计子表"
+ "-" + "银行账户";
fieldTipName = "设计子表"
+ "-" + "是否默认";
fieldTipName = "设计子表"
+ "-" + "是否有效";
fieldTipName = "设计子表"
+ "-" + "备注";
}
if (form.getCompanyBankList()!=null){
fieldTipName = "设计子表"
+ "-" + "开户行";
fieldTipName = "设计子表"
+ "-" + "账户名";
fieldTipName = "设计子表"
+ "-" + "银行账号";
fieldTipName = "设计子表"
+ "-" + "开户行城市";
fieldTipName = "设计子表"
+ "-" + "备注";
}
return countRecover;
}
/**
* 新增修改数据(事务回滚)
* @param id
* @param companyForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(SuppinfoForm companyForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
companyForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(SuppinfoConstant.getFormData(),companyForm,SuppinfoConstant.TABLERENAMES),SuppinfoForm.class);
CompanyEntity entity = JsonUtil.getJsonToBean(companyForm, CompanyEntity.class);
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
if(isSave){
entity.setFlowTaskId(mainUuid);
entity.setCompanyCode(generaterSwapUtil.getBillNumber("CustomerCompanyCode", false));
entity.setCompanyId(mainUuid);
} else {
if(StringUtil.isEmpty(entity.getCompanyCode()) ){
entity.setCompanyCode(generaterSwapUtil.getBillNumber("CustomerCompanyCode", false));
}
}
boolean b = this.saveOrUpdate(entity);
CompanyEntity info = this.getInfo(mainUuid);
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
//PanyInvoice子表数据新增修改
QueryWrapper<PanyInvoiceEntity> PanyInvoicequeryWrapper = new QueryWrapper<>();
PanyInvoicequeryWrapper.lambda().eq(PanyInvoiceEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(companyForm.getPanyInvoiceList())){
panyInvoiceService.remove(PanyInvoicequeryWrapper);
}
if (CollectionUtils.isNotEmpty(companyForm.getPanyInvoiceList())){
List<PanyInvoiceEntity> tableField46dc53 = JsonUtil.getJsonToList(companyForm.getPanyInvoiceList(),PanyInvoiceEntity.class);
//移除的数据
List<Object> childIds = tableField46dc53.stream().filter(t->t.getInvoiceId()!=null).map(PanyInvoiceEntity::getInvoiceId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
PanyInvoicequeryWrapper.lambda().notIn(PanyInvoiceEntity::getInvoiceId,childIds);
}
panyInvoiceService.remove(PanyInvoicequeryWrapper);
for(PanyInvoiceEntity entitys : tableField46dc53){
entitys.setCompanyId(entity.getCompanyId());
if(isSave || entitys.getInvoiceId()==null){
entitys.setTitleCode(generaterSwapUtil.getBillNumber("InvoiceTitleCode", false));
}else{
if(StringUtil.isEmpty(entitys.getTitleCode()) || entitys.getInvoiceId() == null ){
entitys.setTitleCode(generaterSwapUtil.getBillNumber("InvoiceTitleCode", false));
}
}
if(entitys.getInvoiceId()==null){
entitys.setInvoiceId(RandomUtil.uuId());
}
panyInvoiceService.saveOrUpdate(entitys);
}
}
//CompanyBank子表数据新增修改
QueryWrapper<CompanyBankEntity> CompanyBankqueryWrapper = new QueryWrapper<>();
CompanyBankqueryWrapper.lambda().eq(CompanyBankEntity::getCompanyId, info.getCompanyId());
if(!isSave && !CollectionUtils.isNotEmpty(companyForm.getCompanyBankList())){
companyBankService.remove(CompanyBankqueryWrapper);
}
if (CollectionUtils.isNotEmpty(companyForm.getCompanyBankList())){
List<CompanyBankEntity> tableFieldad9d92 = JsonUtil.getJsonToList(companyForm.getCompanyBankList(),CompanyBankEntity.class);
//移除的数据
List<Object> childIds = tableFieldad9d92.stream().filter(t->t.getBankId()!=null).map(CompanyBankEntity::getBankId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(childIds)){
CompanyBankqueryWrapper.lambda().notIn(CompanyBankEntity::getBankId,childIds);
}
companyBankService.remove(CompanyBankqueryWrapper);
for(CompanyBankEntity entitys : tableFieldad9d92){
entitys.setCompanyId(entity.getCompanyId());
if(entitys.getBankId()==null){
entitys.setBankId(RandomUtil.uuId());
}
companyBankService.saveOrUpdate(entitys);
}
}
//mdm_supplier副表数据新增修改
Map<String, Object> SupplierMap = generaterSwapUtil.getMastTabelData(companyForm,"mdm_supplier");
SupplierEntity supplierentity = JsonUtil.getJsonToBean(SupplierMap,SupplierEntity.class);
//自动生成的字段
if(isSave){
supplierentity.setSupplierId(RandomUtil.uuId());
supplierentity.setCompanyId(entity.getCompanyId());
}else{
QueryWrapper<SupplierEntity> queryWrapperSupplier =new QueryWrapper<>();
queryWrapperSupplier.lambda().eq(SupplierEntity::getCompanyId,info.getCompanyId());
SupplierEntity supplierOneEntity= supplierService.getOne(queryWrapperSupplier);
supplierentity.setSupplierId(supplierOneEntity.getSupplierId());
supplierentity.setCompanyId(entity.getCompanyId());
}
supplierService.saveOrUpdate(supplierentity);
}
}

View File

@@ -0,0 +1,24 @@
package com.yunzhupaas.mdm.service.impl;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.mdm.mapper.SupplierMapper;
import com.yunzhupaas.mdm.service.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
/**
*
* 供应商信息
* 版本: V5.2.7
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* 作者: 深圳市乐程软件有限公司
* 日期: 2026-04-24
*/
@Service
public class SupplierServiceImpl extends SuperServiceImpl<SupplierMapper, SupplierEntity> implements SupplierService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
}

View File

@@ -1,265 +0,0 @@
package com.yunzhupaas.base.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.base.service.*;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.base.model.bcmprojecttype.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunzhupaas.flowable.entity.TaskEntity;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import com.yunzhupaas.flowable.entity.TaskEntity;
import com.yunzhupaas.exception.WorkFlowException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* 项目类型
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-26
*/
@Slf4j
@RestController
@Tag(name = "项目类型" , description = "bcm")
@RequestMapping("/api/bcm/BcmProjectType")
public class BcmProjectTypeController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private BcmProjectTypeService bcmProjectTypeService;
/**
* 列表
*
* @param bcmProjectTypePagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody BcmProjectTypePagination bcmProjectTypePagination)throws Exception{
List<BcmProjectTypeEntity> list= bcmProjectTypeService.getList(bcmProjectTypePagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (BcmProjectTypeEntity entity : list) {
Map<String, Object> bcmProjectTypeMap=JsonUtil.entityToMap(entity);
bcmProjectTypeMap.put("id", bcmProjectTypeMap.get("project_type_id"));
//副表数据
//子表数据
realList.add(bcmProjectTypeMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, BcmProjectTypeConstant.getFormData(), BcmProjectTypeConstant.getColumnData(), bcmProjectTypePagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(bcmProjectTypePagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param bcmProjectTypeForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid BcmProjectTypeForm bcmProjectTypeForm) {
String b = bcmProjectTypeService.checkForm(bcmProjectTypeForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
bcmProjectTypeService.saveOrUpdate(bcmProjectTypeForm, null ,true);
}catch(Exception e){
log.error("【项目类型新增接口异常】参数:{}", bcmProjectTypeForm, e);
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
BcmProjectTypeEntity entity= bcmProjectTypeService.getInfo(id);
if(entity!=null){
//假删除
entity.setDeleteMark(1);
entity.setDeleteUserId(userProvider.get().getUserId());
entity.setDeleteTime(new Date());
bcmProjectTypeService.setIgnoreLogicDelete().updateById(entity);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param bcmProjectTypeForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid BcmProjectTypeForm bcmProjectTypeForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
BcmProjectTypeEntity entity= bcmProjectTypeService.getInfo(id);
if(entity!=null){
bcmProjectTypeForm.setProjectTypeId(String.valueOf(entity.getProjectTypeId()));
if (!isImport) {
String b = bcmProjectTypeService.checkForm(bcmProjectTypeForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
bcmProjectTypeService.saveOrUpdate(bcmProjectTypeForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
log.error("【项目类型修改接口异常】参数:{}", bcmProjectTypeForm, e);
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
BcmProjectTypeEntity entity= bcmProjectTypeService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> bcmProjectTypeMap=JsonUtil.entityToMap(entity);
bcmProjectTypeMap.put("id", bcmProjectTypeMap.get("project_type_id"));
//副表数据
//子表数据
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
bcmProjectTypeMap = generaterSwapUtil.swapDataDetail(bcmProjectTypeMap,BcmProjectTypeConstant.getFormData(),"806852213774222853",isPc?false:false);
//子表数据
return ActionResult.success(bcmProjectTypeMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
BcmProjectTypeEntity entity= bcmProjectTypeService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> bcmProjectTypeMap=JsonUtil.entityToMap(entity);
bcmProjectTypeMap.put("id", bcmProjectTypeMap.get("project_type_id"));
//副表数据
//子表数据
bcmProjectTypeMap = generaterSwapUtil.swapDataForm(bcmProjectTypeMap,BcmProjectTypeConstant.getFormData(),BcmProjectTypeConstant.TABLEFIELDKEY,BcmProjectTypeConstant.TABLERENAMES);
return ActionResult.success(bcmProjectTypeMap);
}
/**
* 获取项目类型列表
*
* @param bcmProjectTypePagination
* @return
*/
@Operation(summary = "获取项目类型列表")
@PostMapping("/getBcmprojecttypeList")
public ActionResult getBcmprojecttypeList(@RequestBody BcmProjectTypePagination bcmProjectTypePagination)throws Exception{
List<BcmProjectTypeEntity> list= bcmProjectTypeService.getList(bcmProjectTypePagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (BcmProjectTypeEntity entity : list) {
Map<String, Object> bcmProjectTypeMap=JsonUtil.entityToMap(entity);
bcmProjectTypeMap.put("id", bcmProjectTypeMap.get("project_type_id"));
//副表数据
//子表数据
realList.add(bcmProjectTypeMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, BcmProjectTypeConstant.getFormData(), BcmProjectTypeConstant.getColumnData(), bcmProjectTypePagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(bcmProjectTypePagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
}

View File

@@ -1,273 +0,0 @@
package com.yunzhupaas.base.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.base.service.*;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.base.model.mdmcompany.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunzhupaas.flowable.entity.TaskEntity;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import com.yunzhupaas.flowable.entity.TaskEntity;
import com.yunzhupaas.exception.WorkFlowException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* mdm_company
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-270
*/
@Slf4j
@RestController
@Tag(name = "mdm_company" , description = "bcm")
@RequestMapping("/api/bcm/MdmCompany")
public class MdmCompanyController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private MdmCompanyService mdmCompanyService;
@Autowired
private CrmCustomerService crmCustomerService;
@Autowired
private MdmCompanyContactService mdmCompanyContactService;
@Autowired
private MdmCompanyBankService mdmCompanyBankService;
/**
* 列表
*
* @param mdmCompanyPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody MdmCompanyPagination mdmCompanyPagination)throws Exception{
List<MdmCompanyEntity> list= mdmCompanyService.getList(mdmCompanyPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (MdmCompanyEntity entity : list) {
Map<String, Object> mdmCompanyMap=JsonUtil.entityToMap(entity);
mdmCompanyMap.put("id", mdmCompanyMap.get("company_id"));
//副表数据
//子表数据
// CrmCustomerEntity crmCustomerList = entity.getCrmCustomer();
// mdmCompanyMap.put("tableField798457",JsonUtil.getJsonToBean(crmCustomerList,CrmCustomerEntity.class));
// mdmCompanyMap.put("crmCustomerList",JsonUtil.getJsonToBean(crmCustomerList,CrmCustomerEntity.class));
List<MdmCompanyContactEntity> mdmCompanyContactList = entity.getMdmCompanyContact();
mdmCompanyMap.put("tableFieldc4fb23",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyContactList)));
mdmCompanyMap.put("mdmCompanyContactList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyContactList)));
List<MdmCompanyBankEntity> mdmCompanyBankList = entity.getMdmCompanyBank();
mdmCompanyMap.put("tableFieldaafa82",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
mdmCompanyMap.put("mdmCompanyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
realList.add(mdmCompanyMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, MdmCompanyConstant.getFormData(), MdmCompanyConstant.getColumnData(), mdmCompanyPagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(mdmCompanyPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param mdmCompanyForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid MdmCompanyForm mdmCompanyForm) {
String b = mdmCompanyService.checkForm(mdmCompanyForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
mdmCompanyService.saveOrUpdate(mdmCompanyForm, null ,true);
}catch(Exception e){
log.error("【企业信息(包括:客商与企业内部单位)创建接口异常】参数:{}", mdmCompanyForm, e);
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
MdmCompanyEntity entity= mdmCompanyService.getInfo(id);
if(entity!=null){
//假删除
entity.setDeleteMark(1);
entity.setDeleteUserId(userProvider.get().getUserId());
entity.setDeleteTime(new Date());
mdmCompanyService.setIgnoreLogicDelete().updateById(entity);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param mdmCompanyForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid MdmCompanyForm mdmCompanyForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
MdmCompanyEntity entity= mdmCompanyService.getInfo(id);
if(entity!=null){
mdmCompanyForm.setCompanyId(String.valueOf(entity.getCompanyId()));
if (!isImport) {
String b = mdmCompanyService.checkForm(mdmCompanyForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
mdmCompanyService.saveOrUpdate(mdmCompanyForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
log.error("【企业信息(包括:客商与企业内部单位)编辑接口异常】参数:{}", mdmCompanyForm, e);
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
MdmCompanyEntity entity= mdmCompanyService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> mdmCompanyMap=JsonUtil.entityToMap(entity);
mdmCompanyMap.put("id", mdmCompanyMap.get("company_id"));
//副表数据
//子表数据
CrmCustomerEntity crmCustomerList = entity.getCrmCustomer();
mdmCompanyMap.put("tableField798457",JsonUtil.getJsonToBean(crmCustomerList,CrmCustomerEntity.class));
mdmCompanyMap.put("crmCustomerList",JsonUtil.getJsonToBean(crmCustomerList,CrmCustomerEntity.class));
List<MdmCompanyContactEntity> mdmCompanyContactList = entity.getMdmCompanyContact();
mdmCompanyMap.put("tableFieldc4fb23",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyContactList)));
mdmCompanyMap.put("mdmCompanyContactList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyContactList)));
List<MdmCompanyBankEntity> mdmCompanyBankList = entity.getMdmCompanyBank();
mdmCompanyMap.put("tableFieldaafa82",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
mdmCompanyMap.put("mdmCompanyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
mdmCompanyMap = generaterSwapUtil.swapDataDetail(mdmCompanyMap,MdmCompanyConstant.getFormData(),"807175611364673349",isPc?false:false);
//子表数据
mdmCompanyMap.put("crmCustomerList",mdmCompanyMap.get("tableField798457"));
mdmCompanyMap.put("mdmCompanyContactList",mdmCompanyMap.get("tableFieldc4fb23"));
mdmCompanyMap.put("mdmCompanyBankList",mdmCompanyMap.get("tableFieldaafa82"));
return ActionResult.success(mdmCompanyMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
MdmCompanyEntity entity= mdmCompanyService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> mdmCompanyMap=JsonUtil.entityToMap(entity);
mdmCompanyMap.put("id", mdmCompanyMap.get("company_id"));
//副表数据
//子表数据
CrmCustomerEntity crmCustomer = entity.getCrmCustomer();
// mdmCompanyMap.put("tableField798457",JsonUtil.getJsonToBean(crmCustomerList,CrmCustomerEntity.class));
mdmCompanyMap.put("crmCustomer",JsonUtil.getJsonToBean(crmCustomer,CrmCustomerEntity.class));
List<MdmCompanyContactEntity> mdmCompanyContactList = entity.getMdmCompanyContact();
mdmCompanyMap.put("tableFieldc4fb23",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyContactList)));
mdmCompanyMap.put("mdmCompanyContactList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyContactList)));
List<MdmCompanyBankEntity> mdmCompanyBankList = entity.getMdmCompanyBank();
mdmCompanyMap.put("tableFieldaafa82",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
mdmCompanyMap.put("mdmCompanyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
mdmCompanyMap = generaterSwapUtil.swapDataForm(mdmCompanyMap,MdmCompanyConstant.getFormData(),MdmCompanyConstant.TABLEFIELDKEY,MdmCompanyConstant.TABLERENAMES);
return ActionResult.success(mdmCompanyMap);
}
}

View File

@@ -1,257 +0,0 @@
package com.yunzhupaas.base.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.base.service.*;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.base.model.mdmcontracttype.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunzhupaas.flowable.entity.TaskEntity;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import com.yunzhupaas.flowable.entity.TaskEntity;
import com.yunzhupaas.exception.WorkFlowException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* mdmContractType
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-30
*/
@Slf4j
@RestController
@Tag(name = "mdmContractType" , description = "bcm")
@RequestMapping("/api/bcm/MdmContractType")
public class MdmContractTypeController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private MdmContractTypeService mdmContractTypeService;
/**
* 列表
*
* @param mdmContractTypePagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody MdmContractTypePagination mdmContractTypePagination)throws Exception{
List<MdmContractTypeEntity> list= mdmContractTypeService.getList(mdmContractTypePagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (MdmContractTypeEntity entity : list) {
Map<String, Object> mdmContractTypeMap=JsonUtil.entityToMap(entity);
mdmContractTypeMap.put("id", mdmContractTypeMap.get("id"));
//副表数据
//子表数据
realList.add(mdmContractTypeMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, MdmContractTypeConstant.getFormData(), MdmContractTypeConstant.getColumnData(), mdmContractTypePagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(mdmContractTypePagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param mdmContractTypeForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid MdmContractTypeForm mdmContractTypeForm) {
String b = mdmContractTypeService.checkForm(mdmContractTypeForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
mdmContractTypeService.saveOrUpdate(mdmContractTypeForm, null ,true);
}catch(Exception e){
log.error("【合同类型配置创建接口异常】参数:{}", mdmContractTypeForm, e);
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
MdmContractTypeEntity entity= mdmContractTypeService.getInfo(id);
if(entity!=null){
//假删除
entity.setDeleteMark(1);
entity.setDeleteUserId(userProvider.get().getUserId());
entity.setDeleteTime(new Date());
mdmContractTypeService.setIgnoreLogicDelete().updateById(entity);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param mdmContractTypeForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid MdmContractTypeForm mdmContractTypeForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
MdmContractTypeEntity entity= mdmContractTypeService.getInfo(id);
if(entity!=null){
mdmContractTypeForm.setId(String.valueOf(entity.getId()));
if (!isImport) {
String b = mdmContractTypeService.checkForm(mdmContractTypeForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
mdmContractTypeService.saveOrUpdate(mdmContractTypeForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
log.error("【合同类型配置编辑接口异常】参数:{}", mdmContractTypeForm, e);
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
MdmContractTypeEntity entity= mdmContractTypeService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> mdmContractTypeMap=JsonUtil.entityToMap(entity);
mdmContractTypeMap.put("id", mdmContractTypeMap.get("id"));
//副表数据
//子表数据
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
mdmContractTypeMap = generaterSwapUtil.swapDataDetail(mdmContractTypeMap,MdmContractTypeConstant.getFormData(),"808252366691240901",isPc?false:false);
//子表数据
return ActionResult.success(mdmContractTypeMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
MdmContractTypeEntity entity= mdmContractTypeService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> mdmContractTypeMap=JsonUtil.entityToMap(entity);
mdmContractTypeMap.put("id", mdmContractTypeMap.get("id"));
//副表数据
//子表数据
mdmContractTypeMap = generaterSwapUtil.swapDataForm(mdmContractTypeMap,MdmContractTypeConstant.getFormData(),MdmContractTypeConstant.TABLEFIELDKEY,MdmContractTypeConstant.TABLERENAMES);
return ActionResult.success(mdmContractTypeMap);
}
/**
* 根据类型查询
*
* @param mdmContractTypePagination
* @return
*/
@Operation(summary = "根据类型查询")
@PostMapping("/listByContractMode")
public ActionResult listByContractMode(@RequestBody MdmContractTypePagination mdmContractTypePagination)throws Exception{
List<MdmContractTypeEntity> list= mdmContractTypeService.getList(mdmContractTypePagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (MdmContractTypeEntity entity : list) {
Map<String, Object> mdmContractTypeMap=JsonUtil.entityToMap(entity);
mdmContractTypeMap.put("id", mdmContractTypeMap.get("id"));
//副表数据
//子表数据
realList.add(mdmContractTypeMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, MdmContractTypeConstant.getFormData(), MdmContractTypeConstant.getColumnData(), mdmContractTypePagination.getModuleId(),isPc?false:false);
return ActionResult.success(realList);
}
}

View File

@@ -1,232 +0,0 @@
package com.yunzhupaas.base.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.base.service.*;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.base.model.mdmproject.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunzhupaas.flowable.entity.TaskEntity;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import com.yunzhupaas.flowable.entity.TaskEntity;
import com.yunzhupaas.exception.WorkFlowException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* 项目结构
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-03-26
*/
@Slf4j
@RestController
@Tag(name = "项目结构" , description = "bcm")
@RequestMapping("/api/bcm/MdmProject")
public class MdmProjectController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private MdmProjectService mdmProjectService;
/**
* 列表
*
* @param mdmProjectPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody MdmProjectPagination mdmProjectPagination)throws Exception{
List<MdmProjectEntity> list= mdmProjectService.getList(mdmProjectPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (MdmProjectEntity entity : list) {
Map<String, Object> mdmProjectMap=JsonUtil.entityToMap(entity);
mdmProjectMap.put("id", mdmProjectMap.get("project_id"));
//副表数据
//子表数据
realList.add(mdmProjectMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, MdmProjectConstant.getFormData(), MdmProjectConstant.getColumnData(), mdmProjectPagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(mdmProjectPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param mdmProjectForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid MdmProjectForm mdmProjectForm) {
String b = mdmProjectService.checkForm(mdmProjectForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
mdmProjectService.saveOrUpdate(mdmProjectForm, null ,true);
}catch(Exception e){
log.error("【项目结构创建项目接口异常】参数:{}", mdmProjectForm, e);
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
MdmProjectEntity entity= mdmProjectService.getInfo(id);
if(entity!=null){
//主表数据删除
mdmProjectService.delete(entity);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param mdmProjectForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid MdmProjectForm mdmProjectForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
MdmProjectEntity entity= mdmProjectService.getInfo(id);
if(entity!=null){
mdmProjectForm.setProjectId(String.valueOf(entity.getProjectId()));
if (!isImport) {
String b = mdmProjectService.checkForm(mdmProjectForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
mdmProjectService.saveOrUpdate(mdmProjectForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
log.error("【项目结构修改项目接口异常】参数:{}", mdmProjectForm, e);
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
MdmProjectEntity entity= mdmProjectService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> mdmProjectMap=JsonUtil.entityToMap(entity);
mdmProjectMap.put("id", mdmProjectMap.get("project_id"));
//副表数据
//子表数据
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
mdmProjectMap = generaterSwapUtil.swapDataDetail(mdmProjectMap,MdmProjectConstant.getFormData(),"806868519370098181",isPc?false:false);
//子表数据
return ActionResult.success(mdmProjectMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
MdmProjectEntity entity= mdmProjectService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> mdmProjectMap=JsonUtil.entityToMap(entity);
mdmProjectMap.put("id", mdmProjectMap.get("project_id"));
//副表数据
//子表数据
mdmProjectMap = generaterSwapUtil.swapDataForm(mdmProjectMap,MdmProjectConstant.getFormData(),MdmProjectConstant.TABLEFIELDKEY,MdmProjectConstant.TABLERENAMES);
return ActionResult.success(mdmProjectMap);
}
}

View File

@@ -0,0 +1,697 @@
package com.yunzhupaas.mdm.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.mdm.service.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.mdm.model.asset.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunzhupaas.flowable.entity.TaskEntity;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.annotation.YunzhupaasField;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import com.yunzhupaas.flowable.entity.TaskEntity;
import com.yunzhupaas.exception.WorkFlowException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.web.multipart.MultipartFile;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import com.yunzhupaas.onlinedev.model.ExcelImFieldModel;
import com.yunzhupaas.base.model.OnlineImport.ImportDataModel;
import com.yunzhupaas.base.model.OnlineImport.ImportFormCheckUniqueModel;
import com.yunzhupaas.base.model.OnlineImport.ExcelImportModel;
import com.yunzhupaas.base.model.OnlineImport.VisualImportModel;
import cn.xuyanwu.spring.file.storage.FileInfo;
import lombok.Cleanup;
import com.yunzhupaas.model.visualJson.config.HeaderModel;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.yunzhupaas.base.util.VisualUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* 资产信息
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-04-28
*/
@Slf4j
@RestController
@Tag(name = "资产信息" , description = "bcm")
@RequestMapping("/api/bcm/Asset")
public class AssetController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private AssetService assetService;
@Autowired
private SuppinfoService companyService;
@Autowired
private ConfigValueUtil configValueUtil;
/**
* 列表
*
* @param assetPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody AssetPagination assetPagination)throws Exception{
List<AssetEntity> list= assetService.getList(assetPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (AssetEntity entity : list) {
Map<String, Object> assetMap=JsonUtil.entityToMap(entity);
assetMap.put("id", assetMap.get("asset_id"));
//副表数据
//子表数据
realList.add(assetMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, AssetConstant.getFormData(), AssetConstant.getColumnData(), assetPagination.getModuleId(),isPc?false:false);
for (Map<String, Object> map : realList) {
if(ObjectUtil.isNotEmpty( map.get("supplier_id"))){
map.put("supplier_id", companyService.getInfo(map.get("supplier_id").toString()).getCompanyName());
}
}
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(assetPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param assetForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid AssetForm assetForm) {
String b = assetService.checkForm(assetForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
assetService.saveOrUpdate(assetForm, null ,true);
}catch(Exception e){
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 导出Excel
*
* @return
*/
@Operation(summary = "导出Excel")
@PostMapping("/Actions/Export")
public ActionResult Export(@RequestBody AssetPagination assetPagination) throws IOException {
if (StringUtil.isEmpty(assetPagination.getSelectKey())){
return ActionResult.fail(MsgCode.IMP011.get());
}
List<AssetEntity> list= assetService.getList(assetPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (AssetEntity entity : list) {
Map<String, Object> assetMap=JsonUtil.entityToMap(entity);
assetMap.put("id", assetMap.get("asset_id"));
//副表数据
//子表数据
realList.add(assetMap);
}
//数据转换
realList = generaterSwapUtil.swapDataList(realList, AssetConstant.getFormData(), AssetConstant.getColumnData(), assetPagination.getModuleId(),false);
String[]keys=!StringUtil.isEmpty(assetPagination.getSelectKey())?assetPagination.getSelectKey():new String[0];
UserInfo userInfo=userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(assetPagination.getMenuId());
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo,menuFullName);
return ActionResult.success(vo);
}
/**
* 导出表格方法
*/
public DownloadVO creatModelExcel(String path,List<Map<String, Object>>list,String[]keys,UserInfo userInfo,String menuFullName){
DownloadVO vo=DownloadVO.builder().build();
List<ExcelExportEntity> entitys=new ArrayList<>();
if(keys.length>0){
for(String key:keys){
switch(key){
case "asset_code" :
entitys.add(new ExcelExportEntity("资产编码" ,"asset_code"));
break;
case "asset_name" :
entitys.add(new ExcelExportEntity("资产名称" ,"asset_name"));
break;
case "asset_type" :
entitys.add(new ExcelExportEntity("资产类型" ,"asset_type"));
break;
case "asset_category" :
entitys.add(new ExcelExportEntity("资产分类" ,"asset_category"));
break;
case "asset_status" :
entitys.add(new ExcelExportEntity("资产状态" ,"asset_status"));
break;
case "asset_location" :
entitys.add(new ExcelExportEntity("资产位置" ,"asset_location"));
break;
case "current_org_id" :
entitys.add(new ExcelExportEntity("使用组织" ,"current_org_id"));
break;
case "current_user_id" :
entitys.add(new ExcelExportEntity("保管用户" ,"current_user_id"));
break;
case "asset_ownership" :
entitys.add(new ExcelExportEntity("资产权属" ,"asset_ownership"));
break;
case "measurement_unit" :
entitys.add(new ExcelExportEntity("单位" ,"measurement_unit"));
break;
case "quantity" :
entitys.add(new ExcelExportEntity("数量" ,"quantity"));
break;
case "purchase_date" :
entitys.add(new ExcelExportEntity("购置日期" ,"purchase_date"));
break;
case "commissioning_date" :
entitys.add(new ExcelExportEntity("启用日期" ,"commissioning_date"));
break;
case "expected_life" :
entitys.add(new ExcelExportEntity("预计使用年限" ,"expected_life"));
break;
case "supplier_id" :
entitys.add(new ExcelExportEntity("供应商" ,"supplier_id"));
break;
case "remark" :
entitys.add(new ExcelExportEntity("备注" ,"remark"));
break;
default:
break;
}
}
}
ExportParams exportParams = new ExportParams(null, "表单信息");
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//去除空数据
List<Map<String, Object>> dataList = new ArrayList<>();
for (Map<String, Object> map : list) {
int i = 0;
for (String key : keys) {
//子表
if (key.toLowerCase().startsWith("tablefield")) {
String tableField = key.substring(0, key.indexOf("-" ));
String field = key.substring(key.indexOf("-" ) + 1);
Object o = map.get(tableField);
if (o != null) {
List<Map<String, Object>> childList = (List<Map<String, Object>>) o;
for (Map<String, Object> childMap : childList) {
if (childMap.get(field) != null) {
i++;
}
}
}
} else {
Object o = map.get(key);
if (o != null) {
i++;
}
}
}
if (i > 0) {
dataList.add(map);
}
}
List<ExcelExportEntity> mergerEntitys = new ArrayList<>(entitys);
List<Map<String, Object>> mergerList=new ArrayList<>(dataList);
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(AssetConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
dataList = VisualUtils.complexHeaderDataHandel(dataList, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
}
exportParams.setStyle(ExcelExportStyler.class);
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, dataList);
VisualUtils.mergerVertical(workbook, mergerEntitys, mergerList);
ExcelModel excelModel = generaterSwapUtil.getExcelParams(AssetConstant.getFormData(),Arrays.asList(keys));
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName +"_"+ DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return vo;
}
@Operation(summary = "上传文件")
@PostMapping("/Uploader")
public ActionResult<Object> Uploader() {
List<MultipartFile> list = UpUtil.getFileAll();
MultipartFile file = list.get(0);
if (file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls")) {
String filePath = XSSEscape.escape(configValueUtil.getTemporaryFilePath());
String fileName = XSSEscape.escape(RandomUtil.uuId() + "." + UpUtil.getFileType(file));
//上传文件
FileInfo fileInfo = FileUploadUtils.uploadFile(file, filePath, fileName);
DownloadVO vo = DownloadVO.builder().build();
vo.setName(fileInfo.getFilename());
return ActionResult.success(vo);
} else {
return ActionResult.fail(MsgCode.FA017.get());
}
}
/**
* 模板下载
*
* @return
*/
@Operation(summary = "模板下载")
@GetMapping("/TemplateDownload")
public ActionResult<DownloadVO> TemplateDownload(@RequestParam("menuId") String menuId){
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(menuId);
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("资产名称(asset_name)" ,"asset_name"));
selectKeys.add("asset_name");
entitys.add(new ExcelExportEntity("资产类型(asset_type)" ,"asset_type"));
selectKeys.add("asset_type");
entitys.add(new ExcelExportEntity("资产分类(asset_category)" ,"asset_category"));
selectKeys.add("asset_category");
entitys.add(new ExcelExportEntity("资产状态(asset_status)" ,"asset_status"));
selectKeys.add("asset_status");
entitys.add(new ExcelExportEntity("资产权属(asset_ownership)" ,"asset_ownership"));
selectKeys.add("asset_ownership");
entitys.add(new ExcelExportEntity("资产位置(asset_location)" ,"asset_location"));
selectKeys.add("asset_location");
entitys.add(new ExcelExportEntity("使用组织(current_org_id)" ,"current_org_id"));
selectKeys.add("current_org_id");
entitys.add(new ExcelExportEntity("单位(measurement_unit)" ,"measurement_unit"));
selectKeys.add("measurement_unit");
entitys.add(new ExcelExportEntity("启用日期(commissioning_date)" ,"commissioning_date"));
selectKeys.add("commissioning_date");
entitys.add(new ExcelExportEntity("购置日期(purchase_date)" ,"purchase_date"));
selectKeys.add("purchase_date");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
entitys.add(new ExcelExportEntity("预计使用年限(expected_life)" ,"expected_life"));
selectKeys.add("expected_life");
entitys.add(new ExcelExportEntity("数量(quantity)" ,"quantity"));
selectKeys.add("quantity");
entitys.add(new ExcelExportEntity("保管用户(current_user_id)" ,"current_user_id"));
selectKeys.add("current_user_id");
ExcelModel excelModel = generaterSwapUtil.getExcelParams(AssetConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.add(excelModel.getDataMap());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(AssetConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "导入模板.xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("模板信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 导入预览
*
* @return
*/
@Operation(summary = "导入预览" )
@GetMapping("/ImportPreview")
public ActionResult<Map<String, Object>> ImportPreview(String fileName) throws Exception {
Map<String, Object> headAndDataMap = new HashMap<>(2);
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
FileUploadUtils.downLocal(configValueUtil.getTemporaryFilePath(), filePath, fileName);
File temporary = new File(XSSEscape.escapePath(filePath + fileName));
int headerRowIndex = 1;
ImportParams params = new ImportParams();
params.setTitleRows(0);
params.setHeadRows(headerRowIndex);
params.setNeedVerify(true);
try {
InputStream inputStream = ExcelUtil.solveOrginTitle(temporary, headerRowIndex);
List<Map> excelDataList = ExcelUtil.importExcelByInputStream(inputStream, 0, headerRowIndex, Map.class);
//数据超过1000条
if(excelDataList != null && excelDataList.size() > 1000) {
return ActionResult.fail(MsgCode.ETD117.get());
}
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(AssetConstant.getColumnData(), ColumnDataModel.class);
UploaderTemplateModel uploaderTemplateModel = JsonUtil.getJsonToBean(columnDataModel.getUploaderTemplateJson(), UploaderTemplateModel.class);
List<String> selectKey = uploaderTemplateModel.getSelectKey();
//子表合并
List<Map<String, Object>> results = FormExecelUtils.dataMergeChildTable(excelDataList,selectKey);
// 导入字段
List<ExcelImFieldModel> columns = new ArrayList<>();
columns.add(new ExcelImFieldModel("asset_name","资产名称","input"));
columns.add(new ExcelImFieldModel("asset_type","资产类型","select"));
columns.add(new ExcelImFieldModel("asset_category","资产分类","select"));
columns.add(new ExcelImFieldModel("asset_status","资产状态","select"));
columns.add(new ExcelImFieldModel("asset_ownership","资产权属","select"));
columns.add(new ExcelImFieldModel("asset_location","资产位置","cascader"));
columns.add(new ExcelImFieldModel("current_org_id","使用组织","organizeSelect"));
columns.add(new ExcelImFieldModel("measurement_unit","单位","input"));
columns.add(new ExcelImFieldModel("commissioning_date","启用日期","datePicker"));
columns.add(new ExcelImFieldModel("purchase_date","购置日期","datePicker"));
columns.add(new ExcelImFieldModel("remark","备注","textarea"));
columns.add(new ExcelImFieldModel("expected_life","预计使用年限","inputNumber"));
columns.add(new ExcelImFieldModel("quantity","数量","inputNumber"));
columns.add(new ExcelImFieldModel("current_user_id","保管用户","userSelect"));
headAndDataMap.put("dataRow" , results);
headAndDataMap.put("headerRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
} catch (Exception e){
e.printStackTrace();
return ActionResult.fail(MsgCode.VS407.get());
}
return ActionResult.success(headAndDataMap);
}
/**
* 导入数据
*
* @return
*/
@Operation(summary = "导入数据" )
@PostMapping("/ImportData")
public ActionResult<ExcelImportModel> ImportData(@RequestBody VisualImportModel visualImportModel) throws Exception {
List<Map<String, Object>> listData = visualImportModel.getList();
ImportFormCheckUniqueModel uniqueModel = new ImportFormCheckUniqueModel();
uniqueModel.setDbLinkId(AssetConstant.DBLINKID);
uniqueModel.setUpdate(Objects.equals("1", "2"));
Map<String,String> tablefieldkey = new HashMap<>();
for(String key:AssetConstant.TABLEFIELDKEY.keySet()){
tablefieldkey.put(key,AssetConstant.TABLERENAMES.get(AssetConstant.TABLEFIELDKEY.get(key)));
}
ExcelImportModel excelImportModel = generaterSwapUtil.importData(AssetConstant.getFormData(),listData,uniqueModel, tablefieldkey,AssetConstant.getTableList());
List<ImportDataModel> importDataModel = uniqueModel.getImportDataModel();
for (ImportDataModel model : importDataModel) {
String id = model.getId();
Map<String, Object> result = model.getResultData();
if(StringUtil.isNotEmpty(id)){
update(id, JsonUtil.getJsonToBean(result,AssetForm.class), true);
}else {
create( JsonUtil.getJsonToBean(result,AssetForm.class));
}
}
return ActionResult.success(excelImportModel);
}
/**
* 导出异常报告
*
* @return
*/
@Operation(summary = "导出异常报告")
@PostMapping("/ImportExceptionData")
public ActionResult<DownloadVO> ImportExceptionData(@RequestBody VisualImportModel visualImportModel) {
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(visualImportModel.getMenuId());
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
entitys.add(new ExcelExportEntity("异常原因", "errorsInfo",30));
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("资产名称(asset_name)" ,"asset_name"));
selectKeys.add("asset_name");
entitys.add(new ExcelExportEntity("资产类型(asset_type)" ,"asset_type"));
selectKeys.add("asset_type");
entitys.add(new ExcelExportEntity("资产分类(asset_category)" ,"asset_category"));
selectKeys.add("asset_category");
entitys.add(new ExcelExportEntity("资产状态(asset_status)" ,"asset_status"));
selectKeys.add("asset_status");
entitys.add(new ExcelExportEntity("资产权属(asset_ownership)" ,"asset_ownership"));
selectKeys.add("asset_ownership");
entitys.add(new ExcelExportEntity("资产位置(asset_location)" ,"asset_location"));
selectKeys.add("asset_location");
entitys.add(new ExcelExportEntity("使用组织(current_org_id)" ,"current_org_id"));
selectKeys.add("current_org_id");
entitys.add(new ExcelExportEntity("单位(measurement_unit)" ,"measurement_unit"));
selectKeys.add("measurement_unit");
entitys.add(new ExcelExportEntity("启用日期(commissioning_date)" ,"commissioning_date"));
selectKeys.add("commissioning_date");
entitys.add(new ExcelExportEntity("购置日期(purchase_date)" ,"purchase_date"));
selectKeys.add("purchase_date");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
entitys.add(new ExcelExportEntity("预计使用年限(expected_life)" ,"expected_life"));
selectKeys.add("expected_life");
entitys.add(new ExcelExportEntity("数量(quantity)" ,"quantity"));
selectKeys.add("quantity");
entitys.add(new ExcelExportEntity("保管用户(current_user_id)" ,"current_user_id"));
selectKeys.add("current_user_id");
ExcelModel excelModel = generaterSwapUtil.getExcelParams(AssetConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.addAll(visualImportModel.getList());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
exportParams.setFreezeCol(1);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(AssetConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "错误报告_" + DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
AssetEntity entity= assetService.getInfo(id);
if(entity!=null){
//假删除
entity.setDeleteMark(1);
entity.setDeleteUserId(userProvider.get().getUserId());
entity.setDeleteTime(new Date());
assetService.setIgnoreLogicDelete().updateById(entity);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param assetForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid AssetForm assetForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
AssetEntity entity= assetService.getInfo(id);
if(entity!=null){
assetForm.setAssetId(String.valueOf(entity.getAssetId()));
if (!isImport) {
String b = assetService.checkForm(assetForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
assetService.saveOrUpdate(assetForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
AssetEntity entity= assetService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> assetMap=JsonUtil.entityToMap(entity);
assetMap.put("id", assetMap.get("asset_id"));
//副表数据
//子表数据
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
assetMap = generaterSwapUtil.swapDataDetail(assetMap,AssetConstant.getFormData(),"818770027560829701",isPc?false:false);
assetMap.put("supplier_id", companyService.getInfo(assetMap.get("supplier_id").toString()).getCompanyName());
//子表数据
return ActionResult.success(assetMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
AssetEntity entity= assetService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> assetMap=JsonUtil.entityToMap(entity);
assetMap.put("id", assetMap.get("asset_id"));
//副表数据
//子表数据
assetMap = generaterSwapUtil.swapDataForm(assetMap,AssetConstant.getFormData(),AssetConstant.TABLEFIELDKEY,AssetConstant.TABLERENAMES);
return ActionResult.success(assetMap);
}
}

View File

@@ -0,0 +1,932 @@
package com.yunzhupaas.mdm.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.mdm.service.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.mdm.model.company.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunzhupaas.flowable.entity.TaskEntity;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.annotation.YunzhupaasField;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import com.yunzhupaas.flowable.entity.TaskEntity;
import com.yunzhupaas.exception.WorkFlowException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.web.multipart.MultipartFile;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import com.yunzhupaas.onlinedev.model.ExcelImFieldModel;
import com.yunzhupaas.base.model.OnlineImport.ImportDataModel;
import com.yunzhupaas.base.model.OnlineImport.ImportFormCheckUniqueModel;
import com.yunzhupaas.base.model.OnlineImport.ExcelImportModel;
import com.yunzhupaas.base.model.OnlineImport.VisualImportModel;
import cn.xuyanwu.spring.file.storage.FileInfo;
import lombok.Cleanup;
import com.yunzhupaas.model.visualJson.config.HeaderModel;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.yunzhupaas.base.util.VisualUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* 企业信息
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-04-24
*/
@Slf4j
@RestController
@Tag(name = "企业信息" , description = "bcm")
@RequestMapping("/api/bcm/Company")
public class CompanyController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private CompanyService companyService;
@Autowired
private CompanyBankService mdmCompanyBankService;
@Autowired
private CompanyInvoiceService companyInvoiceService;
@Autowired
private ConfigValueUtil configValueUtil;
/**
* 列表
*
* @param companyPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody CompanyPagination companyPagination)throws Exception{
List<CompanyEntity> list= companyService.getList(companyPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (CompanyEntity entity : list) {
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
//子表数据
List<CompanyBankEntity> mdmCompanyBankList = entity.getCompanyBank();
companyMap.put("tableFieldad9d92",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
companyMap.put("mdmCompanyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
List<CompanyInvoiceEntity> companyInvoiceList = entity.getCompanyInvoice();
companyMap.put("tableField46dc53",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
companyMap.put("companyInvoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
realList.add(companyMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, CompanyConstant.getFormData(), CompanyConstant.getColumnData(), companyPagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(companyPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param companyForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid CompanyForm companyForm) {
String b = companyService.checkForm(companyForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
companyService.saveOrUpdate(companyForm, null ,true);
}catch(Exception e){
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 导出Excel
*
* @return
*/
@Operation(summary = "导出Excel")
@PostMapping("/Actions/Export")
public ActionResult Export(@RequestBody CompanyPagination companyPagination) throws IOException {
if (StringUtil.isEmpty(companyPagination.getSelectKey())){
return ActionResult.fail(MsgCode.IMP011.get());
}
List<CompanyEntity> list= companyService.getList(companyPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (CompanyEntity entity : list) {
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
//子表数据
List<CompanyBankEntity> mdmCompanyBankList = entity.getCompanyBank();
companyMap.put("tableFieldad9d92",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
companyMap.put("mdmCompanyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
List<CompanyInvoiceEntity> companyInvoiceList = entity.getCompanyInvoice();
companyMap.put("tableField46dc53",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
companyMap.put("companyInvoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
realList.add(companyMap);
}
//数据转换
realList = generaterSwapUtil.swapDataList(realList, CompanyConstant.getFormData(), CompanyConstant.getColumnData(), companyPagination.getModuleId(),false);
String[]keys=!StringUtil.isEmpty(companyPagination.getSelectKey())?companyPagination.getSelectKey():new String[0];
UserInfo userInfo=userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(companyPagination.getMenuId());
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo,menuFullName);
return ActionResult.success(vo);
}
/**
* 导出表格方法
*/
public DownloadVO creatModelExcel(String path,List<Map<String, Object>>list,String[]keys,UserInfo userInfo,String menuFullName){
DownloadVO vo=DownloadVO.builder().build();
List<ExcelExportEntity> entitys=new ArrayList<>();
if(keys.length>0){
ExcelExportEntity tableFieldad9d92ExcelEntity = new ExcelExportEntity("设计子表(tableFieldad9d92)","tableFieldad9d92");
List<ExcelExportEntity> tableFieldad9d92List = new ArrayList<>();
ExcelExportEntity tableField46dc53ExcelEntity = new ExcelExportEntity("设计子表(tableField46dc53)","tableField46dc53");
List<ExcelExportEntity> tableField46dc53List = new ArrayList<>();
for(String key:keys){
switch(key){
case "company_code" :
entitys.add(new ExcelExportEntity("企业编码" ,"company_code"));
break;
case "company_name" :
entitys.add(new ExcelExportEntity("企业名称" ,"company_name"));
break;
case "short_name" :
entitys.add(new ExcelExportEntity("简称/昵称" ,"short_name"));
break;
case "entity_type" :
entitys.add(new ExcelExportEntity("类型" ,"entity_type"));
break;
case "credit_code" :
entitys.add(new ExcelExportEntity("社会信用代码" ,"credit_code"));
break;
case "org_id" :
entitys.add(new ExcelExportEntity("归属组织" ,"org_id"));
break;
case "province_id" :
entitys.add(new ExcelExportEntity("所属地区" ,"province_id"));
break;
case "tax_type" :
entitys.add(new ExcelExportEntity("纳税人类别" ,"tax_type"));
break;
case "enterprise_scale" :
entitys.add(new ExcelExportEntity("企业规模" ,"enterprise_scale"));
break;
case "enterprise_nature" :
entitys.add(new ExcelExportEntity("企业类型" ,"enterprise_nature"));
break;
case "industry_code" :
entitys.add(new ExcelExportEntity("行业代码" ,"industry_code"));
break;
case "registration_date" :
entitys.add(new ExcelExportEntity("成立日期" ,"registration_date"));
break;
case "registered_capital" :
entitys.add(new ExcelExportEntity("注册资本" ,"registered_capital"));
break;
case "legal_representative" :
entitys.add(new ExcelExportEntity("法定代表人" ,"legal_representative"));
break;
case "phone" :
entitys.add(new ExcelExportEntity("联系电话" ,"phone"));
break;
case "email" :
entitys.add(new ExcelExportEntity("邮箱" ,"email"));
break;
case "website" :
entitys.add(new ExcelExportEntity("网站" ,"website"));
break;
case "address" :
entitys.add(new ExcelExportEntity("地址" ,"address"));
break;
case "business_scope" :
entitys.add(new ExcelExportEntity("经营范围" ,"business_scope"));
break;
case "remark" :
entitys.add(new ExcelExportEntity("备注" ,"remark"));
break;
case "tableFieldad9d92-bank_name":
tableFieldad9d92List.add(new ExcelExportEntity("开户行" ,"bank_name"));
break;
case "tableFieldad9d92-bank_account_name":
tableFieldad9d92List.add(new ExcelExportEntity("账户名" ,"bank_account_name"));
break;
case "tableFieldad9d92-bank_account_number":
tableFieldad9d92List.add(new ExcelExportEntity("银行账号" ,"bank_account_number"));
break;
case "tableFieldad9d92-bank_province":
tableFieldad9d92List.add(new ExcelExportEntity("开户行城市" ,"bank_province"));
break;
case "tableFieldad9d92-remark":
tableFieldad9d92List.add(new ExcelExportEntity("备注" ,"remark"));
break;
case "tableField46dc53-title_code":
tableField46dc53List.add(new ExcelExportEntity("发票抬头编码" ,"title_code"));
break;
case "tableField46dc53-title_name":
tableField46dc53List.add(new ExcelExportEntity("发票抬头名称" ,"title_name"));
break;
case "tableField46dc53-credit_code":
tableField46dc53List.add(new ExcelExportEntity("纳税人识别号" ,"credit_code"));
break;
case "tableField46dc53-tax_type":
tableField46dc53List.add(new ExcelExportEntity("纳税人类别" ,"tax_type"));
break;
case "tableField46dc53-address":
tableField46dc53List.add(new ExcelExportEntity("地址" ,"address"));
break;
case "tableField46dc53-phone":
tableField46dc53List.add(new ExcelExportEntity("电话" ,"phone"));
break;
case "tableField46dc53-bank_name":
tableField46dc53List.add(new ExcelExportEntity("开户银行" ,"bank_name"));
break;
case "tableField46dc53-bank_account":
tableField46dc53List.add(new ExcelExportEntity("银行账户" ,"bank_account"));
break;
case "tableField46dc53-is_defalut":
tableField46dc53List.add(new ExcelExportEntity("是否默认" ,"is_defalut"));
break;
case "tableField46dc53-is_valid":
tableField46dc53List.add(new ExcelExportEntity("是否有效" ,"is_valid"));
break;
case "tableField46dc53-remark":
tableField46dc53List.add(new ExcelExportEntity("备注" ,"remark"));
break;
default:
break;
}
}
if(tableFieldad9d92List.size() > 0){
tableFieldad9d92ExcelEntity.setList(tableFieldad9d92List);
entitys.add(tableFieldad9d92ExcelEntity);
}
if(tableField46dc53List.size() > 0){
tableField46dc53ExcelEntity.setList(tableField46dc53List);
entitys.add(tableField46dc53ExcelEntity);
}
}
ExportParams exportParams = new ExportParams(null, "表单信息");
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//去除空数据
List<Map<String, Object>> dataList = new ArrayList<>();
for (Map<String, Object> map : list) {
int i = 0;
for (String key : keys) {
//子表
if (key.toLowerCase().startsWith("tablefield")) {
String tableField = key.substring(0, key.indexOf("-" ));
String field = key.substring(key.indexOf("-" ) + 1);
Object o = map.get(tableField);
if (o != null) {
List<Map<String, Object>> childList = (List<Map<String, Object>>) o;
for (Map<String, Object> childMap : childList) {
if (childMap.get(field) != null) {
i++;
}
}
}
} else {
Object o = map.get(key);
if (o != null) {
i++;
}
}
}
if (i > 0) {
dataList.add(map);
}
}
List<ExcelExportEntity> mergerEntitys = new ArrayList<>(entitys);
List<Map<String, Object>> mergerList=new ArrayList<>(dataList);
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CompanyConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
dataList = VisualUtils.complexHeaderDataHandel(dataList, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
}
exportParams.setStyle(ExcelExportStyler.class);
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, dataList);
VisualUtils.mergerVertical(workbook, mergerEntitys, mergerList);
ExcelModel excelModel = generaterSwapUtil.getExcelParams(CompanyConstant.getFormData(),Arrays.asList(keys));
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName +"_"+ DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return vo;
}
@Operation(summary = "上传文件")
@PostMapping("/Uploader")
public ActionResult<Object> Uploader() {
List<MultipartFile> list = UpUtil.getFileAll();
MultipartFile file = list.get(0);
if (file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls")) {
String filePath = XSSEscape.escape(configValueUtil.getTemporaryFilePath());
String fileName = XSSEscape.escape(RandomUtil.uuId() + "." + UpUtil.getFileType(file));
//上传文件
FileInfo fileInfo = FileUploadUtils.uploadFile(file, filePath, fileName);
DownloadVO vo = DownloadVO.builder().build();
vo.setName(fileInfo.getFilename());
return ActionResult.success(vo);
} else {
return ActionResult.fail(MsgCode.FA017.get());
}
}
/**
* 模板下载
*
* @return
*/
@Operation(summary = "模板下载")
@GetMapping("/TemplateDownload")
public ActionResult<DownloadVO> TemplateDownload(@RequestParam("menuId") String menuId){
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(menuId);
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("企业名称(company_name)" ,"company_name"));
selectKeys.add("company_name");
entitys.add(new ExcelExportEntity("社会信用代码(credit_code)" ,"credit_code"));
selectKeys.add("credit_code");
entitys.add(new ExcelExportEntity("归属组织(org_id)" ,"org_id"));
selectKeys.add("org_id");
entitys.add(new ExcelExportEntity("企业编码(company_code)" ,"company_code"));
selectKeys.add("company_code");
entitys.add(new ExcelExportEntity("简称/昵称(short_name)" ,"short_name"));
selectKeys.add("short_name");
entitys.add(new ExcelExportEntity("类型(entity_type)" ,"entity_type"));
selectKeys.add("entity_type");
entitys.add(new ExcelExportEntity("纳税人类别(tax_type)" ,"tax_type"));
selectKeys.add("tax_type");
entitys.add(new ExcelExportEntity("企业规模(enterprise_scale)" ,"enterprise_scale"));
selectKeys.add("enterprise_scale");
entitys.add(new ExcelExportEntity("企业类型(enterprise_nature)" ,"enterprise_nature"));
selectKeys.add("enterprise_nature");
entitys.add(new ExcelExportEntity("行业代码(industry_code)" ,"industry_code"));
selectKeys.add("industry_code");
entitys.add(new ExcelExportEntity("成立日期(registration_date)" ,"registration_date"));
selectKeys.add("registration_date");
entitys.add(new ExcelExportEntity("注册资本(registered_capital)" ,"registered_capital"));
selectKeys.add("registered_capital");
entitys.add(new ExcelExportEntity("法定代表人(legal_representative)" ,"legal_representative"));
selectKeys.add("legal_representative");
entitys.add(new ExcelExportEntity("联系电话(phone)" ,"phone"));
selectKeys.add("phone");
entitys.add(new ExcelExportEntity("邮箱(email)" ,"email"));
selectKeys.add("email");
entitys.add(new ExcelExportEntity("网站(website)" ,"website"));
selectKeys.add("website");
entitys.add(new ExcelExportEntity("地址(address)" ,"address"));
selectKeys.add("address");
entitys.add(new ExcelExportEntity("所属地区(province_id)" ,"province_id"));
selectKeys.add("province_id");
entitys.add(new ExcelExportEntity("经营范围(business_scope)" ,"business_scope"));
selectKeys.add("business_scope");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
//tableFieldad9d92子表对象
ExcelExportEntity tableFieldad9d92ExcelEntity = new ExcelExportEntity("设计子表(tableFieldad9d92)","tableFieldad9d92");
List<ExcelExportEntity> tableFieldad9d92ExcelEntityList = new ArrayList<>();
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("开户行(tableFieldad9d92-bank_name)" ,"bank_name"));
selectKeys.add("tableFieldad9d92-bank_name");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("账户名(tableFieldad9d92-bank_account_name)" ,"bank_account_name"));
selectKeys.add("tableFieldad9d92-bank_account_name");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("银行账号(tableFieldad9d92-bank_account_number)" ,"bank_account_number"));
selectKeys.add("tableFieldad9d92-bank_account_number");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("开户行城市(tableFieldad9d92-bank_province)" ,"bank_province"));
selectKeys.add("tableFieldad9d92-bank_province");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("备注(tableFieldad9d92-remark)" ,"remark"));
selectKeys.add("tableFieldad9d92-remark");
tableFieldad9d92ExcelEntity.setList(tableFieldad9d92ExcelEntityList);
if(tableFieldad9d92ExcelEntityList.size() > 0){
entitys.add(tableFieldad9d92ExcelEntity);
}
//tableField46dc53子表对象
ExcelExportEntity tableField46dc53ExcelEntity = new ExcelExportEntity("设计子表(tableField46dc53)","tableField46dc53");
List<ExcelExportEntity> tableField46dc53ExcelEntityList = new ArrayList<>();
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("发票抬头名称(tableField46dc53-title_name)" ,"title_name"));
selectKeys.add("tableField46dc53-title_name");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("纳税人识别号(tableField46dc53-credit_code)" ,"credit_code"));
selectKeys.add("tableField46dc53-credit_code");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("纳税人类别(tableField46dc53-tax_type)" ,"tax_type"));
selectKeys.add("tableField46dc53-tax_type");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("地址(tableField46dc53-address)" ,"address"));
selectKeys.add("tableField46dc53-address");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("电话(tableField46dc53-phone)" ,"phone"));
selectKeys.add("tableField46dc53-phone");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("开户银行(tableField46dc53-bank_name)" ,"bank_name"));
selectKeys.add("tableField46dc53-bank_name");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("银行账户(tableField46dc53-bank_account)" ,"bank_account"));
selectKeys.add("tableField46dc53-bank_account");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("是否默认(tableField46dc53-is_defalut)" ,"is_defalut"));
selectKeys.add("tableField46dc53-is_defalut");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("是否有效(tableField46dc53-is_valid)" ,"is_valid"));
selectKeys.add("tableField46dc53-is_valid");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("备注(tableField46dc53-remark)" ,"remark"));
selectKeys.add("tableField46dc53-remark");
tableField46dc53ExcelEntity.setList(tableField46dc53ExcelEntityList);
if(tableField46dc53ExcelEntityList.size() > 0){
entitys.add(tableField46dc53ExcelEntity);
}
ExcelModel excelModel = generaterSwapUtil.getExcelParams(CompanyConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.add(excelModel.getDataMap());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CompanyConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "导入模板.xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("模板信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 导入预览
*
* @return
*/
@Operation(summary = "导入预览" )
@GetMapping("/ImportPreview")
public ActionResult<Map<String, Object>> ImportPreview(String fileName) throws Exception {
Map<String, Object> headAndDataMap = new HashMap<>(2);
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
FileUploadUtils.downLocal(configValueUtil.getTemporaryFilePath(), filePath, fileName);
File temporary = new File(XSSEscape.escapePath(filePath + fileName));
int headerRowIndex = 2;
ImportParams params = new ImportParams();
params.setTitleRows(0);
params.setHeadRows(headerRowIndex);
params.setNeedVerify(true);
try {
InputStream inputStream = ExcelUtil.solveOrginTitle(temporary, headerRowIndex);
List<Map> excelDataList = ExcelUtil.importExcelByInputStream(inputStream, 0, headerRowIndex, Map.class);
//数据超过1000条
if(excelDataList != null && excelDataList.size() > 1000) {
return ActionResult.fail(MsgCode.ETD117.get());
}
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CompanyConstant.getColumnData(), ColumnDataModel.class);
UploaderTemplateModel uploaderTemplateModel = JsonUtil.getJsonToBean(columnDataModel.getUploaderTemplateJson(), UploaderTemplateModel.class);
List<String> selectKey = uploaderTemplateModel.getSelectKey();
//子表合并
List<Map<String, Object>> results = FormExecelUtils.dataMergeChildTable(excelDataList,selectKey);
// 导入字段
List<ExcelImFieldModel> columns = new ArrayList<>();
columns.add(new ExcelImFieldModel("company_name","企业名称","input"));
columns.add(new ExcelImFieldModel("credit_code","社会信用代码","input"));
columns.add(new ExcelImFieldModel("org_id","归属组织","organizeSelect"));
columns.add(new ExcelImFieldModel("company_code","企业编码","billRule"));
columns.add(new ExcelImFieldModel("short_name","简称/昵称","input"));
columns.add(new ExcelImFieldModel("entity_type","类型","radio"));
columns.add(new ExcelImFieldModel("tax_type","纳税人类别","select"));
columns.add(new ExcelImFieldModel("enterprise_scale","企业规模","select"));
columns.add(new ExcelImFieldModel("enterprise_nature","企业类型","select"));
columns.add(new ExcelImFieldModel("industry_code","行业代码","select"));
columns.add(new ExcelImFieldModel("registration_date","成立日期","datePicker"));
columns.add(new ExcelImFieldModel("registered_capital","注册资本","inputNumber"));
columns.add(new ExcelImFieldModel("legal_representative","法定代表人","input"));
columns.add(new ExcelImFieldModel("phone","联系电话","input"));
columns.add(new ExcelImFieldModel("email","邮箱","input"));
columns.add(new ExcelImFieldModel("website","网站","input"));
columns.add(new ExcelImFieldModel("address","地址","input"));
columns.add(new ExcelImFieldModel("province_id","所属地区","areaSelect"));
columns.add(new ExcelImFieldModel("business_scope","经营范围","textarea"));
columns.add(new ExcelImFieldModel("remark","备注","textarea"));
//tableFieldad9d92子表对象
List<ExcelImFieldModel> tableFieldad9d92columns = new ArrayList<>();
tableFieldad9d92columns.add(new ExcelImFieldModel("bank_name" ,"开户行"));
tableFieldad9d92columns.add(new ExcelImFieldModel("bank_account_name" ,"账户名"));
tableFieldad9d92columns.add(new ExcelImFieldModel("bank_account_number" ,"银行账号"));
tableFieldad9d92columns.add(new ExcelImFieldModel("bank_province" ,"开户行城市"));
tableFieldad9d92columns.add(new ExcelImFieldModel("remark" ,"备注"));
columns.add(new ExcelImFieldModel("tableFieldad9d92","设计子表","table",tableFieldad9d92columns));
//tableField46dc53子表对象
List<ExcelImFieldModel> tableField46dc53columns = new ArrayList<>();
tableField46dc53columns.add(new ExcelImFieldModel("title_name" ,"发票抬头名称"));
tableField46dc53columns.add(new ExcelImFieldModel("credit_code" ,"纳税人识别号"));
tableField46dc53columns.add(new ExcelImFieldModel("tax_type" ,"纳税人类别"));
tableField46dc53columns.add(new ExcelImFieldModel("address" ,"地址"));
tableField46dc53columns.add(new ExcelImFieldModel("phone" ,"电话"));
tableField46dc53columns.add(new ExcelImFieldModel("bank_name" ,"开户银行"));
tableField46dc53columns.add(new ExcelImFieldModel("bank_account" ,"银行账户"));
tableField46dc53columns.add(new ExcelImFieldModel("is_defalut" ,"是否默认"));
tableField46dc53columns.add(new ExcelImFieldModel("is_valid" ,"是否有效"));
tableField46dc53columns.add(new ExcelImFieldModel("remark" ,"备注"));
columns.add(new ExcelImFieldModel("tableField46dc53","设计子表","table",tableField46dc53columns));
headAndDataMap.put("dataRow" , results);
headAndDataMap.put("headerRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
} catch (Exception e){
e.printStackTrace();
return ActionResult.fail(MsgCode.VS407.get());
}
return ActionResult.success(headAndDataMap);
}
/**
* 导入数据
*
* @return
*/
@Operation(summary = "导入数据" )
@PostMapping("/ImportData")
public ActionResult<ExcelImportModel> ImportData(@RequestBody VisualImportModel visualImportModel) throws Exception {
List<Map<String, Object>> listData = visualImportModel.getList();
ImportFormCheckUniqueModel uniqueModel = new ImportFormCheckUniqueModel();
uniqueModel.setDbLinkId(CompanyConstant.DBLINKID);
uniqueModel.setUpdate(Objects.equals("2", "2"));
Map<String,String> tablefieldkey = new HashMap<>();
for(String key:CompanyConstant.TABLEFIELDKEY.keySet()){
tablefieldkey.put(key,CompanyConstant.TABLERENAMES.get(CompanyConstant.TABLEFIELDKEY.get(key)));
}
ExcelImportModel excelImportModel = generaterSwapUtil.importData(CompanyConstant.getFormData(),listData,uniqueModel, tablefieldkey,CompanyConstant.getTableList());
List<ImportDataModel> importDataModel = uniqueModel.getImportDataModel();
for (ImportDataModel model : importDataModel) {
String id = model.getId();
Map<String, Object> result = model.getResultData();
if(StringUtil.isNotEmpty(id)){
update(id, JsonUtil.getJsonToBean(result,CompanyForm.class), true);
}else {
create( JsonUtil.getJsonToBean(result,CompanyForm.class));
}
}
return ActionResult.success(excelImportModel);
}
/**
* 导出异常报告
*
* @return
*/
@Operation(summary = "导出异常报告")
@PostMapping("/ImportExceptionData")
public ActionResult<DownloadVO> ImportExceptionData(@RequestBody VisualImportModel visualImportModel) {
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(visualImportModel.getMenuId());
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
entitys.add(new ExcelExportEntity("异常原因", "errorsInfo",30));
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("企业名称(company_name)" ,"company_name"));
selectKeys.add("company_name");
entitys.add(new ExcelExportEntity("社会信用代码(credit_code)" ,"credit_code"));
selectKeys.add("credit_code");
entitys.add(new ExcelExportEntity("归属组织(org_id)" ,"org_id"));
selectKeys.add("org_id");
entitys.add(new ExcelExportEntity("企业编码(company_code)" ,"company_code"));
selectKeys.add("company_code");
entitys.add(new ExcelExportEntity("简称/昵称(short_name)" ,"short_name"));
selectKeys.add("short_name");
entitys.add(new ExcelExportEntity("类型(entity_type)" ,"entity_type"));
selectKeys.add("entity_type");
entitys.add(new ExcelExportEntity("纳税人类别(tax_type)" ,"tax_type"));
selectKeys.add("tax_type");
entitys.add(new ExcelExportEntity("企业规模(enterprise_scale)" ,"enterprise_scale"));
selectKeys.add("enterprise_scale");
entitys.add(new ExcelExportEntity("企业类型(enterprise_nature)" ,"enterprise_nature"));
selectKeys.add("enterprise_nature");
entitys.add(new ExcelExportEntity("行业代码(industry_code)" ,"industry_code"));
selectKeys.add("industry_code");
entitys.add(new ExcelExportEntity("成立日期(registration_date)" ,"registration_date"));
selectKeys.add("registration_date");
entitys.add(new ExcelExportEntity("注册资本(registered_capital)" ,"registered_capital"));
selectKeys.add("registered_capital");
entitys.add(new ExcelExportEntity("法定代表人(legal_representative)" ,"legal_representative"));
selectKeys.add("legal_representative");
entitys.add(new ExcelExportEntity("联系电话(phone)" ,"phone"));
selectKeys.add("phone");
entitys.add(new ExcelExportEntity("邮箱(email)" ,"email"));
selectKeys.add("email");
entitys.add(new ExcelExportEntity("网站(website)" ,"website"));
selectKeys.add("website");
entitys.add(new ExcelExportEntity("地址(address)" ,"address"));
selectKeys.add("address");
entitys.add(new ExcelExportEntity("所属地区(province_id)" ,"province_id"));
selectKeys.add("province_id");
entitys.add(new ExcelExportEntity("经营范围(business_scope)" ,"business_scope"));
selectKeys.add("business_scope");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
//tableFieldad9d92子表对象
ExcelExportEntity tableFieldad9d92ExcelEntity = new ExcelExportEntity("设计子表(tableFieldad9d92)","tableFieldad9d92");
List<ExcelExportEntity> tableFieldad9d92ExcelEntityList = new ArrayList<>();
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("开户行(tableFieldad9d92-bank_name)" ,"bank_name"));
selectKeys.add("tableFieldad9d92-bank_name");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("账户名(tableFieldad9d92-bank_account_name)" ,"bank_account_name"));
selectKeys.add("tableFieldad9d92-bank_account_name");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("银行账号(tableFieldad9d92-bank_account_number)" ,"bank_account_number"));
selectKeys.add("tableFieldad9d92-bank_account_number");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("开户行城市(tableFieldad9d92-bank_province)" ,"bank_province"));
selectKeys.add("tableFieldad9d92-bank_province");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("备注(tableFieldad9d92-remark)" ,"remark"));
selectKeys.add("tableFieldad9d92-remark");
tableFieldad9d92ExcelEntity.setList(tableFieldad9d92ExcelEntityList);
entitys.add(tableFieldad9d92ExcelEntity);
//tableField46dc53子表对象
ExcelExportEntity tableField46dc53ExcelEntity = new ExcelExportEntity("设计子表(tableField46dc53)","tableField46dc53");
List<ExcelExportEntity> tableField46dc53ExcelEntityList = new ArrayList<>();
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("发票抬头名称(tableField46dc53-title_name)" ,"title_name"));
selectKeys.add("tableField46dc53-title_name");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("纳税人识别号(tableField46dc53-credit_code)" ,"credit_code"));
selectKeys.add("tableField46dc53-credit_code");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("纳税人类别(tableField46dc53-tax_type)" ,"tax_type"));
selectKeys.add("tableField46dc53-tax_type");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("地址(tableField46dc53-address)" ,"address"));
selectKeys.add("tableField46dc53-address");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("电话(tableField46dc53-phone)" ,"phone"));
selectKeys.add("tableField46dc53-phone");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("开户银行(tableField46dc53-bank_name)" ,"bank_name"));
selectKeys.add("tableField46dc53-bank_name");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("银行账户(tableField46dc53-bank_account)" ,"bank_account"));
selectKeys.add("tableField46dc53-bank_account");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("是否默认(tableField46dc53-is_defalut)" ,"is_defalut"));
selectKeys.add("tableField46dc53-is_defalut");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("是否有效(tableField46dc53-is_valid)" ,"is_valid"));
selectKeys.add("tableField46dc53-is_valid");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("备注(tableField46dc53-remark)" ,"remark"));
selectKeys.add("tableField46dc53-remark");
tableField46dc53ExcelEntity.setList(tableField46dc53ExcelEntityList);
entitys.add(tableField46dc53ExcelEntity);
ExcelModel excelModel = generaterSwapUtil.getExcelParams(CompanyConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.addAll(visualImportModel.getList());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
exportParams.setFreezeCol(1);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CompanyConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "错误报告_" + DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
CompanyEntity entity= companyService.getInfo(id);
if(entity!=null){
//主表数据删除
companyService.delete(entity);
QueryWrapper<CompanyBankEntity> queryWrapperMdmCompanyBank=new QueryWrapper<>();
queryWrapperMdmCompanyBank.lambda().eq(CompanyBankEntity::getCompanyId,entity.getCompanyId());
//子表数据删除
mdmCompanyBankService.remove(queryWrapperMdmCompanyBank);
QueryWrapper<CompanyInvoiceEntity> queryWrapperCompanyInvoice=new QueryWrapper<>();
queryWrapperCompanyInvoice.lambda().eq(CompanyInvoiceEntity::getCompanyId,entity.getCompanyId());
//子表数据删除
companyInvoiceService.remove(queryWrapperCompanyInvoice);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param companyForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid CompanyForm companyForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
CompanyEntity entity= companyService.getInfo(id);
if(entity!=null){
companyForm.setCompanyId(String.valueOf(entity.getCompanyId()));
if (!isImport) {
String b = companyService.checkForm(companyForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
companyService.saveOrUpdate(companyForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
CompanyEntity entity= companyService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
//子表数据
List<CompanyBankEntity> mdmCompanyBankList = entity.getCompanyBank();
companyMap.put("tableFieldad9d92",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
companyMap.put("mdmCompanyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
List<CompanyInvoiceEntity> companyInvoiceList = entity.getCompanyInvoice();
companyMap.put("tableField46dc53",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
companyMap.put("companyInvoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
companyMap = generaterSwapUtil.swapDataDetail(companyMap,CompanyConstant.getFormData(),"806858527036409349",isPc?false:false);
//子表数据
companyMap.put("mdmCompanyBankList",companyMap.get("tableFieldad9d92"));
companyMap.put("companyInvoiceList",companyMap.get("tableField46dc53"));
return ActionResult.success(companyMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
CompanyEntity entity= companyService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
//子表数据
List<CompanyBankEntity> mdmCompanyBankList = entity.getCompanyBank();
companyMap.put("tableFieldad9d92",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
companyMap.put("mdmCompanyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(mdmCompanyBankList)));
List<CompanyInvoiceEntity> companyInvoiceList = entity.getCompanyInvoice();
companyMap.put("tableField46dc53",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
companyMap.put("companyInvoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
companyMap = generaterSwapUtil.swapDataForm(companyMap,CompanyConstant.getFormData(),CompanyConstant.TABLEFIELDKEY,CompanyConstant.TABLERENAMES);
return ActionResult.success(companyMap);
}
}

View File

@@ -0,0 +1,970 @@
package com.yunzhupaas.mdm.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunzhupaas.mdm.model.custinfo.CustinfoConstant;
import com.yunzhupaas.mdm.model.custinfo.CustinfoForm;
import com.yunzhupaas.mdm.model.custinfo.CustinfoPagination;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.mdm.service.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.util.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import java.io.IOException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.web.multipart.MultipartFile;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.File;
import java.io.InputStream;
import com.yunzhupaas.onlinedev.model.ExcelImFieldModel;
import com.yunzhupaas.base.model.OnlineImport.ImportDataModel;
import com.yunzhupaas.base.model.OnlineImport.ImportFormCheckUniqueModel;
import com.yunzhupaas.base.model.OnlineImport.ExcelImportModel;
import com.yunzhupaas.base.model.OnlineImport.VisualImportModel;
import cn.xuyanwu.spring.file.storage.FileInfo;
import lombok.Cleanup;
import com.yunzhupaas.model.visualJson.config.HeaderModel;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.yunzhupaas.base.util.VisualUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* 客户信息
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-04-24
*/
@Slf4j
@RestController
@Tag(name = "客户信息" , description = "bcm")
@RequestMapping("/api/bcm/Custinfo")
public class CustinfoController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private CustinfoService companyService;
@Autowired
private CompanyInvoiceService companyInvoiceService;
@Autowired
private CompanyBankService companyBankService;
@Autowired
private CustomerService customerService;
@Autowired
private ConfigValueUtil configValueUtil;
/**
* 列表
*
* @param companyPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody CustinfoPagination companyPagination)throws Exception{
List<CompanyEntity> list= companyService.getList(companyPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (CompanyEntity entity : list) {
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
CustomerEntity customerEntity = entity.getCustomer();
if(ObjectUtil.isNotEmpty(customerEntity)){
Map<String, Object> customerMap=JsonUtil.entityToMap(customerEntity);
for(String key:customerMap.keySet()){
companyMap.put("yunzhupaas_mdm_customer_yunzhupaas_"+key,customerMap.get(key));
}
}
//子表数据
List<CompanyInvoiceEntity> companyInvoiceList = entity.getCompanyInvoice();
companyMap.put("tableField46dc53",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
companyMap.put("companyInvoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
List<CompanyBankEntity> companyBankList = entity.getCompanyBank();
companyMap.put("tableFieldad9d92",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap.put("companyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
realList.add(companyMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, CustinfoConstant.getFormData(), CustinfoConstant.getColumnData(), companyPagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(companyPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param companyForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid CustinfoForm companyForm) {
String b = companyService.checkForm(companyForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
companyService.saveOrUpdate(companyForm, null ,true);
}catch(Exception e){
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 导出Excel
*
* @return
*/
@Operation(summary = "导出Excel")
@PostMapping("/Actions/Export")
public ActionResult Export(@RequestBody CustinfoPagination companyPagination) throws IOException {
if (StringUtil.isEmpty(companyPagination.getSelectKey())){
return ActionResult.fail(MsgCode.IMP011.get());
}
List<CompanyEntity> list= companyService.getList(companyPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (CompanyEntity entity : list) {
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
CustomerEntity customerEntity = entity.getCustomer();
if(ObjectUtil.isNotEmpty(customerEntity)){
Map<String, Object> customerMap=JsonUtil.entityToMap(customerEntity);
for(String key:customerMap.keySet()){
companyMap.put("yunzhupaas_mdm_customer_yunzhupaas_"+key,customerMap.get(key));
}
}
//子表数据
List<CompanyInvoiceEntity> companyInvoiceList = entity.getCompanyInvoice();
companyMap.put("tableField46dc53",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
companyMap.put("companyInvoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
List<CompanyBankEntity> companyBankList = entity.getCompanyBank();
companyMap.put("tableFieldad9d92",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap.put("companyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
realList.add(companyMap);
}
//数据转换
realList = generaterSwapUtil.swapDataList(realList, CustinfoConstant.getFormData(), CustinfoConstant.getColumnData(), companyPagination.getModuleId(),false);
String[]keys=!StringUtil.isEmpty(companyPagination.getSelectKey())?companyPagination.getSelectKey():new String[0];
UserInfo userInfo=userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(companyPagination.getMenuId());
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo,menuFullName);
return ActionResult.success(vo);
}
/**
* 导出表格方法
*/
public DownloadVO creatModelExcel(String path,List<Map<String, Object>>list,String[]keys,UserInfo userInfo,String menuFullName){
DownloadVO vo=DownloadVO.builder().build();
List<ExcelExportEntity> entitys=new ArrayList<>();
if(keys.length>0){
ExcelExportEntity tableField46dc53ExcelEntity = new ExcelExportEntity("设计子表(tableField46dc53)","tableField46dc53");
List<ExcelExportEntity> tableField46dc53List = new ArrayList<>();
ExcelExportEntity tableFieldad9d92ExcelEntity = new ExcelExportEntity("设计子表(tableFieldad9d92)","tableFieldad9d92");
List<ExcelExportEntity> tableFieldad9d92List = new ArrayList<>();
for(String key:keys){
switch(key){
case "company_code" :
entitys.add(new ExcelExportEntity("客户编码" ,"company_code"));
break;
case "company_name" :
entitys.add(new ExcelExportEntity("客户名称" ,"company_name"));
break;
case "short_name" :
entitys.add(new ExcelExportEntity("简称/昵称" ,"short_name"));
break;
case "entity_type" :
entitys.add(new ExcelExportEntity("类型" ,"entity_type"));
break;
case "credit_code" :
entitys.add(new ExcelExportEntity("社会信用代码" ,"credit_code"));
break;
case "org_id" :
entitys.add(new ExcelExportEntity("归属组织" ,"org_id"));
break;
case "province_id" :
entitys.add(new ExcelExportEntity("所属地区" ,"province_id"));
break;
case "tax_type" :
entitys.add(new ExcelExportEntity("纳税人类别" ,"tax_type"));
break;
case "enterprise_scale" :
entitys.add(new ExcelExportEntity("企业规模" ,"enterprise_scale"));
break;
case "enterprise_nature" :
entitys.add(new ExcelExportEntity("企业类型" ,"enterprise_nature"));
break;
case "industry_code" :
entitys.add(new ExcelExportEntity("行业代码" ,"industry_code"));
break;
case "registration_date" :
entitys.add(new ExcelExportEntity("成立日期" ,"registration_date"));
break;
case "registered_capital" :
entitys.add(new ExcelExportEntity("注册资本" ,"registered_capital"));
break;
case "legal_representative" :
entitys.add(new ExcelExportEntity("法定代表人" ,"legal_representative"));
break;
case "phone" :
entitys.add(new ExcelExportEntity("联系电话" ,"phone"));
break;
case "email" :
entitys.add(new ExcelExportEntity("邮箱" ,"email"));
break;
case "website" :
entitys.add(new ExcelExportEntity("网站" ,"website"));
break;
case "address" :
entitys.add(new ExcelExportEntity("地址" ,"address"));
break;
case "business_scope" :
entitys.add(new ExcelExportEntity("经营范围" ,"business_scope"));
break;
case "remark" :
entitys.add(new ExcelExportEntity("备注" ,"remark"));
break;
case "yunzhupaas_mdm_customer_yunzhupaas_major_person_id" :
entitys.add(new ExcelExportEntity("销售责任人" ,"yunzhupaas_mdm_customer_yunzhupaas_major_person_id"));
break;
case "yunzhupaas_mdm_customer_yunzhupaas_customer_level" :
entitys.add(new ExcelExportEntity("客户级别" ,"yunzhupaas_mdm_customer_yunzhupaas_customer_level"));
break;
case "yunzhupaas_mdm_customer_yunzhupaas_customer_source" :
entitys.add(new ExcelExportEntity("客户来源" ,"yunzhupaas_mdm_customer_yunzhupaas_customer_source"));
break;
case "tableField46dc53-title_code":
tableField46dc53List.add(new ExcelExportEntity("发票抬头编码" ,"title_code"));
break;
case "tableField46dc53-title_name":
tableField46dc53List.add(new ExcelExportEntity("发票抬头名称" ,"title_name"));
break;
case "tableField46dc53-credit_code":
tableField46dc53List.add(new ExcelExportEntity("纳税人识别号" ,"credit_code"));
break;
case "tableField46dc53-tax_type":
tableField46dc53List.add(new ExcelExportEntity("纳税人类别" ,"tax_type"));
break;
case "tableField46dc53-address":
tableField46dc53List.add(new ExcelExportEntity("地址" ,"address"));
break;
case "tableField46dc53-phone":
tableField46dc53List.add(new ExcelExportEntity("电话" ,"phone"));
break;
case "tableField46dc53-bank_name":
tableField46dc53List.add(new ExcelExportEntity("开户银行" ,"bank_name"));
break;
case "tableField46dc53-bank_account":
tableField46dc53List.add(new ExcelExportEntity("银行账户" ,"bank_account"));
break;
case "tableField46dc53-is_defalut":
tableField46dc53List.add(new ExcelExportEntity("是否默认" ,"is_defalut"));
break;
case "tableField46dc53-is_valid":
tableField46dc53List.add(new ExcelExportEntity("是否有效" ,"is_valid"));
break;
case "tableField46dc53-remark":
tableField46dc53List.add(new ExcelExportEntity("备注" ,"remark"));
break;
case "tableFieldad9d92-bank_name":
tableFieldad9d92List.add(new ExcelExportEntity("开户行" ,"bank_name"));
break;
case "tableFieldad9d92-bank_account_name":
tableFieldad9d92List.add(new ExcelExportEntity("账户名" ,"bank_account_name"));
break;
case "tableFieldad9d92-bank_account_number":
tableFieldad9d92List.add(new ExcelExportEntity("银行账号" ,"bank_account_number"));
break;
case "tableFieldad9d92-bank_province":
tableFieldad9d92List.add(new ExcelExportEntity("开户行城市" ,"bank_province"));
break;
case "tableFieldad9d92-remark":
tableFieldad9d92List.add(new ExcelExportEntity("备注" ,"remark"));
break;
default:
break;
}
}
if(tableField46dc53List.size() > 0){
tableField46dc53ExcelEntity.setList(tableField46dc53List);
entitys.add(tableField46dc53ExcelEntity);
}
if(tableFieldad9d92List.size() > 0){
tableFieldad9d92ExcelEntity.setList(tableFieldad9d92List);
entitys.add(tableFieldad9d92ExcelEntity);
}
}
ExportParams exportParams = new ExportParams(null, "表单信息");
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//去除空数据
List<Map<String, Object>> dataList = new ArrayList<>();
for (Map<String, Object> map : list) {
int i = 0;
for (String key : keys) {
//子表
if (key.toLowerCase().startsWith("tablefield")) {
String tableField = key.substring(0, key.indexOf("-" ));
String field = key.substring(key.indexOf("-" ) + 1);
Object o = map.get(tableField);
if (o != null) {
List<Map<String, Object>> childList = (List<Map<String, Object>>) o;
for (Map<String, Object> childMap : childList) {
if (childMap.get(field) != null) {
i++;
}
}
}
} else {
Object o = map.get(key);
if (o != null) {
i++;
}
}
}
if (i > 0) {
dataList.add(map);
}
}
List<ExcelExportEntity> mergerEntitys = new ArrayList<>(entitys);
List<Map<String, Object>> mergerList=new ArrayList<>(dataList);
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CustinfoConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
dataList = VisualUtils.complexHeaderDataHandel(dataList, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
}
exportParams.setStyle(ExcelExportStyler.class);
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, dataList);
VisualUtils.mergerVertical(workbook, mergerEntitys, mergerList);
ExcelModel excelModel = generaterSwapUtil.getExcelParams(CustinfoConstant.getFormData(),Arrays.asList(keys));
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName +"_"+ DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return vo;
}
@Operation(summary = "上传文件")
@PostMapping("/Uploader")
public ActionResult<Object> Uploader() {
List<MultipartFile> list = UpUtil.getFileAll();
MultipartFile file = list.get(0);
if (file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls")) {
String filePath = XSSEscape.escape(configValueUtil.getTemporaryFilePath());
String fileName = XSSEscape.escape(RandomUtil.uuId() + "." + UpUtil.getFileType(file));
//上传文件
FileInfo fileInfo = FileUploadUtils.uploadFile(file, filePath, fileName);
DownloadVO vo = DownloadVO.builder().build();
vo.setName(fileInfo.getFilename());
return ActionResult.success(vo);
} else {
return ActionResult.fail(MsgCode.FA017.get());
}
}
/**
* 模板下载
*
* @return
*/
@Operation(summary = "模板下载")
@GetMapping("/TemplateDownload")
public ActionResult<DownloadVO> TemplateDownload(@RequestParam("menuId") String menuId){
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(menuId);
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("客户名称(company_name)" ,"company_name"));
selectKeys.add("company_name");
entitys.add(new ExcelExportEntity("社会信用代码(credit_code)" ,"credit_code"));
selectKeys.add("credit_code");
entitys.add(new ExcelExportEntity("归属组织(org_id)" ,"org_id"));
selectKeys.add("org_id");
entitys.add(new ExcelExportEntity("客户编码(company_code)" ,"company_code"));
selectKeys.add("company_code");
entitys.add(new ExcelExportEntity("简称/昵称(short_name)" ,"short_name"));
selectKeys.add("short_name");
entitys.add(new ExcelExportEntity("类型(entity_type)" ,"entity_type"));
selectKeys.add("entity_type");
entitys.add(new ExcelExportEntity("纳税人类别(tax_type)" ,"tax_type"));
selectKeys.add("tax_type");
entitys.add(new ExcelExportEntity("企业规模(enterprise_scale)" ,"enterprise_scale"));
selectKeys.add("enterprise_scale");
entitys.add(new ExcelExportEntity("企业类型(enterprise_nature)" ,"enterprise_nature"));
selectKeys.add("enterprise_nature");
entitys.add(new ExcelExportEntity("行业代码(industry_code)" ,"industry_code"));
selectKeys.add("industry_code");
entitys.add(new ExcelExportEntity("成立日期(registration_date)" ,"registration_date"));
selectKeys.add("registration_date");
entitys.add(new ExcelExportEntity("注册资本(registered_capital)" ,"registered_capital"));
selectKeys.add("registered_capital");
entitys.add(new ExcelExportEntity("法定代表人(legal_representative)" ,"legal_representative"));
selectKeys.add("legal_representative");
entitys.add(new ExcelExportEntity("联系电话(phone)" ,"phone"));
selectKeys.add("phone");
entitys.add(new ExcelExportEntity("邮箱(email)" ,"email"));
selectKeys.add("email");
entitys.add(new ExcelExportEntity("网站(website)" ,"website"));
selectKeys.add("website");
entitys.add(new ExcelExportEntity("地址(address)" ,"address"));
selectKeys.add("address");
entitys.add(new ExcelExportEntity("所属地区(province_id)" ,"province_id"));
selectKeys.add("province_id");
entitys.add(new ExcelExportEntity("经营范围(business_scope)" ,"business_scope"));
selectKeys.add("business_scope");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
//tableField46dc53子表对象
ExcelExportEntity tableField46dc53ExcelEntity = new ExcelExportEntity("设计子表(tableField46dc53)","tableField46dc53");
List<ExcelExportEntity> tableField46dc53ExcelEntityList = new ArrayList<>();
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("发票抬头名称(tableField46dc53-title_name)" ,"title_name"));
selectKeys.add("tableField46dc53-title_name");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("纳税人识别号(tableField46dc53-credit_code)" ,"credit_code"));
selectKeys.add("tableField46dc53-credit_code");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("纳税人类别(tableField46dc53-tax_type)" ,"tax_type"));
selectKeys.add("tableField46dc53-tax_type");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("地址(tableField46dc53-address)" ,"address"));
selectKeys.add("tableField46dc53-address");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("电话(tableField46dc53-phone)" ,"phone"));
selectKeys.add("tableField46dc53-phone");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("开户银行(tableField46dc53-bank_name)" ,"bank_name"));
selectKeys.add("tableField46dc53-bank_name");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("银行账户(tableField46dc53-bank_account)" ,"bank_account"));
selectKeys.add("tableField46dc53-bank_account");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("是否默认(tableField46dc53-is_defalut)" ,"is_defalut"));
selectKeys.add("tableField46dc53-is_defalut");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("是否有效(tableField46dc53-is_valid)" ,"is_valid"));
selectKeys.add("tableField46dc53-is_valid");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("备注(tableField46dc53-remark)" ,"remark"));
selectKeys.add("tableField46dc53-remark");
tableField46dc53ExcelEntity.setList(tableField46dc53ExcelEntityList);
if(tableField46dc53ExcelEntityList.size() > 0){
entitys.add(tableField46dc53ExcelEntity);
}
//tableFieldad9d92子表对象
ExcelExportEntity tableFieldad9d92ExcelEntity = new ExcelExportEntity("设计子表(tableFieldad9d92)","tableFieldad9d92");
List<ExcelExportEntity> tableFieldad9d92ExcelEntityList = new ArrayList<>();
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("开户行(tableFieldad9d92-bank_name)" ,"bank_name"));
selectKeys.add("tableFieldad9d92-bank_name");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("账户名(tableFieldad9d92-bank_account_name)" ,"bank_account_name"));
selectKeys.add("tableFieldad9d92-bank_account_name");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("银行账号(tableFieldad9d92-bank_account_number)" ,"bank_account_number"));
selectKeys.add("tableFieldad9d92-bank_account_number");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("开户行城市(tableFieldad9d92-bank_province)" ,"bank_province"));
selectKeys.add("tableFieldad9d92-bank_province");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("备注(tableFieldad9d92-remark)" ,"remark"));
selectKeys.add("tableFieldad9d92-remark");
tableFieldad9d92ExcelEntity.setList(tableFieldad9d92ExcelEntityList);
if(tableFieldad9d92ExcelEntityList.size() > 0){
entitys.add(tableFieldad9d92ExcelEntity);
}
ExcelModel excelModel = generaterSwapUtil.getExcelParams(CustinfoConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.add(excelModel.getDataMap());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CustinfoConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "导入模板.xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("模板信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 导入预览
*
* @return
*/
@Operation(summary = "导入预览" )
@GetMapping("/ImportPreview")
public ActionResult<Map<String, Object>> ImportPreview(String fileName) throws Exception {
Map<String, Object> headAndDataMap = new HashMap<>(2);
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
FileUploadUtils.downLocal(configValueUtil.getTemporaryFilePath(), filePath, fileName);
File temporary = new File(XSSEscape.escapePath(filePath + fileName));
int headerRowIndex = 2;
ImportParams params = new ImportParams();
params.setTitleRows(0);
params.setHeadRows(headerRowIndex);
params.setNeedVerify(true);
try {
InputStream inputStream = ExcelUtil.solveOrginTitle(temporary, headerRowIndex);
List<Map> excelDataList = ExcelUtil.importExcelByInputStream(inputStream, 0, headerRowIndex, Map.class);
//数据超过1000条
if(excelDataList != null && excelDataList.size() > 1000) {
return ActionResult.fail(MsgCode.ETD117.get());
}
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CustinfoConstant.getColumnData(), ColumnDataModel.class);
UploaderTemplateModel uploaderTemplateModel = JsonUtil.getJsonToBean(columnDataModel.getUploaderTemplateJson(), UploaderTemplateModel.class);
List<String> selectKey = uploaderTemplateModel.getSelectKey();
//子表合并
List<Map<String, Object>> results = FormExecelUtils.dataMergeChildTable(excelDataList,selectKey);
// 导入字段
List<ExcelImFieldModel> columns = new ArrayList<>();
columns.add(new ExcelImFieldModel("company_name","客户名称","input"));
columns.add(new ExcelImFieldModel("credit_code","社会信用代码","input"));
columns.add(new ExcelImFieldModel("org_id","归属组织","organizeSelect"));
columns.add(new ExcelImFieldModel("company_code","客户编码","billRule"));
columns.add(new ExcelImFieldModel("short_name","简称/昵称","input"));
columns.add(new ExcelImFieldModel("entity_type","类型","radio"));
columns.add(new ExcelImFieldModel("tax_type","纳税人类别","select"));
columns.add(new ExcelImFieldModel("enterprise_scale","企业规模","select"));
columns.add(new ExcelImFieldModel("enterprise_nature","企业类型","select"));
columns.add(new ExcelImFieldModel("industry_code","行业代码","select"));
columns.add(new ExcelImFieldModel("registration_date","成立日期","datePicker"));
columns.add(new ExcelImFieldModel("registered_capital","注册资本","inputNumber"));
columns.add(new ExcelImFieldModel("legal_representative","法定代表人","input"));
columns.add(new ExcelImFieldModel("phone","联系电话","input"));
columns.add(new ExcelImFieldModel("email","邮箱","input"));
columns.add(new ExcelImFieldModel("website","网站","input"));
columns.add(new ExcelImFieldModel("address","地址","input"));
columns.add(new ExcelImFieldModel("province_id","所属地区","areaSelect"));
columns.add(new ExcelImFieldModel("business_scope","经营范围","textarea"));
columns.add(new ExcelImFieldModel("remark","备注","textarea"));
//tableField46dc53子表对象
List<ExcelImFieldModel> tableField46dc53columns = new ArrayList<>();
tableField46dc53columns.add(new ExcelImFieldModel("title_name" ,"发票抬头名称"));
tableField46dc53columns.add(new ExcelImFieldModel("credit_code" ,"纳税人识别号"));
tableField46dc53columns.add(new ExcelImFieldModel("tax_type" ,"纳税人类别"));
tableField46dc53columns.add(new ExcelImFieldModel("address" ,"地址"));
tableField46dc53columns.add(new ExcelImFieldModel("phone" ,"电话"));
tableField46dc53columns.add(new ExcelImFieldModel("bank_name" ,"开户银行"));
tableField46dc53columns.add(new ExcelImFieldModel("bank_account" ,"银行账户"));
tableField46dc53columns.add(new ExcelImFieldModel("is_defalut" ,"是否默认"));
tableField46dc53columns.add(new ExcelImFieldModel("is_valid" ,"是否有效"));
tableField46dc53columns.add(new ExcelImFieldModel("remark" ,"备注"));
columns.add(new ExcelImFieldModel("tableField46dc53","设计子表","table",tableField46dc53columns));
//tableFieldad9d92子表对象
List<ExcelImFieldModel> tableFieldad9d92columns = new ArrayList<>();
tableFieldad9d92columns.add(new ExcelImFieldModel("bank_name" ,"开户行"));
tableFieldad9d92columns.add(new ExcelImFieldModel("bank_account_name" ,"账户名"));
tableFieldad9d92columns.add(new ExcelImFieldModel("bank_account_number" ,"银行账号"));
tableFieldad9d92columns.add(new ExcelImFieldModel("bank_province" ,"开户行城市"));
tableFieldad9d92columns.add(new ExcelImFieldModel("remark" ,"备注"));
columns.add(new ExcelImFieldModel("tableFieldad9d92","设计子表","table",tableFieldad9d92columns));
headAndDataMap.put("dataRow" , results);
headAndDataMap.put("headerRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
} catch (Exception e){
e.printStackTrace();
return ActionResult.fail(MsgCode.VS407.get());
}
return ActionResult.success(headAndDataMap);
}
/**
* 导入数据
*
* @return
*/
@Operation(summary = "导入数据" )
@PostMapping("/ImportData")
public ActionResult<ExcelImportModel> ImportData(@RequestBody VisualImportModel visualImportModel) throws Exception {
List<Map<String, Object>> listData = visualImportModel.getList();
ImportFormCheckUniqueModel uniqueModel = new ImportFormCheckUniqueModel();
uniqueModel.setDbLinkId(CustinfoConstant.DBLINKID);
uniqueModel.setUpdate(Objects.equals("2", "2"));
Map<String,String> tablefieldkey = new HashMap<>();
for(String key:CustinfoConstant.TABLEFIELDKEY.keySet()){
tablefieldkey.put(key,CustinfoConstant.TABLERENAMES.get(CustinfoConstant.TABLEFIELDKEY.get(key)));
}
ExcelImportModel excelImportModel = generaterSwapUtil.importData(CustinfoConstant.getFormData(),listData,uniqueModel, tablefieldkey,CustinfoConstant.getTableList());
List<ImportDataModel> importDataModel = uniqueModel.getImportDataModel();
for (ImportDataModel model : importDataModel) {
String id = model.getId();
Map<String, Object> result = model.getResultData();
if(StringUtil.isNotEmpty(id)){
update(id, JsonUtil.getJsonToBean(result,CustinfoForm.class), true);
}else {
create( JsonUtil.getJsonToBean(result,CustinfoForm.class));
}
}
return ActionResult.success(excelImportModel);
}
/**
* 导出异常报告
*
* @return
*/
@Operation(summary = "导出异常报告")
@PostMapping("/ImportExceptionData")
public ActionResult<DownloadVO> ImportExceptionData(@RequestBody VisualImportModel visualImportModel) {
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(visualImportModel.getMenuId());
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
entitys.add(new ExcelExportEntity("异常原因", "errorsInfo",30));
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("客户名称(company_name)" ,"company_name"));
selectKeys.add("company_name");
entitys.add(new ExcelExportEntity("社会信用代码(credit_code)" ,"credit_code"));
selectKeys.add("credit_code");
entitys.add(new ExcelExportEntity("归属组织(org_id)" ,"org_id"));
selectKeys.add("org_id");
entitys.add(new ExcelExportEntity("客户编码(company_code)" ,"company_code"));
selectKeys.add("company_code");
entitys.add(new ExcelExportEntity("简称/昵称(short_name)" ,"short_name"));
selectKeys.add("short_name");
entitys.add(new ExcelExportEntity("类型(entity_type)" ,"entity_type"));
selectKeys.add("entity_type");
entitys.add(new ExcelExportEntity("纳税人类别(tax_type)" ,"tax_type"));
selectKeys.add("tax_type");
entitys.add(new ExcelExportEntity("企业规模(enterprise_scale)" ,"enterprise_scale"));
selectKeys.add("enterprise_scale");
entitys.add(new ExcelExportEntity("企业类型(enterprise_nature)" ,"enterprise_nature"));
selectKeys.add("enterprise_nature");
entitys.add(new ExcelExportEntity("行业代码(industry_code)" ,"industry_code"));
selectKeys.add("industry_code");
entitys.add(new ExcelExportEntity("成立日期(registration_date)" ,"registration_date"));
selectKeys.add("registration_date");
entitys.add(new ExcelExportEntity("注册资本(registered_capital)" ,"registered_capital"));
selectKeys.add("registered_capital");
entitys.add(new ExcelExportEntity("法定代表人(legal_representative)" ,"legal_representative"));
selectKeys.add("legal_representative");
entitys.add(new ExcelExportEntity("联系电话(phone)" ,"phone"));
selectKeys.add("phone");
entitys.add(new ExcelExportEntity("邮箱(email)" ,"email"));
selectKeys.add("email");
entitys.add(new ExcelExportEntity("网站(website)" ,"website"));
selectKeys.add("website");
entitys.add(new ExcelExportEntity("地址(address)" ,"address"));
selectKeys.add("address");
entitys.add(new ExcelExportEntity("所属地区(province_id)" ,"province_id"));
selectKeys.add("province_id");
entitys.add(new ExcelExportEntity("经营范围(business_scope)" ,"business_scope"));
selectKeys.add("business_scope");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
//tableField46dc53子表对象
ExcelExportEntity tableField46dc53ExcelEntity = new ExcelExportEntity("设计子表(tableField46dc53)","tableField46dc53");
List<ExcelExportEntity> tableField46dc53ExcelEntityList = new ArrayList<>();
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("发票抬头名称(tableField46dc53-title_name)" ,"title_name"));
selectKeys.add("tableField46dc53-title_name");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("纳税人识别号(tableField46dc53-credit_code)" ,"credit_code"));
selectKeys.add("tableField46dc53-credit_code");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("纳税人类别(tableField46dc53-tax_type)" ,"tax_type"));
selectKeys.add("tableField46dc53-tax_type");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("地址(tableField46dc53-address)" ,"address"));
selectKeys.add("tableField46dc53-address");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("电话(tableField46dc53-phone)" ,"phone"));
selectKeys.add("tableField46dc53-phone");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("开户银行(tableField46dc53-bank_name)" ,"bank_name"));
selectKeys.add("tableField46dc53-bank_name");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("银行账户(tableField46dc53-bank_account)" ,"bank_account"));
selectKeys.add("tableField46dc53-bank_account");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("是否默认(tableField46dc53-is_defalut)" ,"is_defalut"));
selectKeys.add("tableField46dc53-is_defalut");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("是否有效(tableField46dc53-is_valid)" ,"is_valid"));
selectKeys.add("tableField46dc53-is_valid");
tableField46dc53ExcelEntityList.add(new ExcelExportEntity("备注(tableField46dc53-remark)" ,"remark"));
selectKeys.add("tableField46dc53-remark");
tableField46dc53ExcelEntity.setList(tableField46dc53ExcelEntityList);
entitys.add(tableField46dc53ExcelEntity);
//tableFieldad9d92子表对象
ExcelExportEntity tableFieldad9d92ExcelEntity = new ExcelExportEntity("设计子表(tableFieldad9d92)","tableFieldad9d92");
List<ExcelExportEntity> tableFieldad9d92ExcelEntityList = new ArrayList<>();
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("开户行(tableFieldad9d92-bank_name)" ,"bank_name"));
selectKeys.add("tableFieldad9d92-bank_name");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("账户名(tableFieldad9d92-bank_account_name)" ,"bank_account_name"));
selectKeys.add("tableFieldad9d92-bank_account_name");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("银行账号(tableFieldad9d92-bank_account_number)" ,"bank_account_number"));
selectKeys.add("tableFieldad9d92-bank_account_number");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("开户行城市(tableFieldad9d92-bank_province)" ,"bank_province"));
selectKeys.add("tableFieldad9d92-bank_province");
tableFieldad9d92ExcelEntityList.add(new ExcelExportEntity("备注(tableFieldad9d92-remark)" ,"remark"));
selectKeys.add("tableFieldad9d92-remark");
tableFieldad9d92ExcelEntity.setList(tableFieldad9d92ExcelEntityList);
entitys.add(tableFieldad9d92ExcelEntity);
ExcelModel excelModel = generaterSwapUtil.getExcelParams(CustinfoConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.addAll(visualImportModel.getList());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
exportParams.setFreezeCol(1);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CustinfoConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "错误报告_" + DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
CompanyEntity entity= companyService.getInfo(id);
if(entity!=null){
//主表数据删除
companyService.delete(entity);
QueryWrapper<CustomerEntity> queryWrapperCustomer=new QueryWrapper<>();
queryWrapperCustomer.lambda().eq(CustomerEntity::getCompanyId,entity.getCompanyId());
//副表数据删除
customerService.remove(queryWrapperCustomer);
QueryWrapper<CompanyInvoiceEntity> queryWrapperCompanyInvoice=new QueryWrapper<>();
queryWrapperCompanyInvoice.lambda().eq(CompanyInvoiceEntity::getCompanyId,entity.getCompanyId());
//子表数据删除
companyInvoiceService.remove(queryWrapperCompanyInvoice);
QueryWrapper<CompanyBankEntity> queryWrapperCompanyBank=new QueryWrapper<>();
queryWrapperCompanyBank.lambda().eq(CompanyBankEntity::getCompanyId,entity.getCompanyId());
//子表数据删除
companyBankService.remove(queryWrapperCompanyBank);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param companyForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid CustinfoForm companyForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
CompanyEntity entity= companyService.getInfo(id);
if(entity!=null){
companyForm.setCompanyId(String.valueOf(entity.getCompanyId()));
if (!isImport) {
String b = companyService.checkForm(companyForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
companyService.saveOrUpdate(companyForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
CompanyEntity entity= companyService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
CustomerEntity customerEntity = entity.getCustomer();
if(ObjectUtil.isNotEmpty(customerEntity)){
Map<String, Object> customerMap=JsonUtil.entityToMap(customerEntity);
for(String key:customerMap.keySet()){
companyMap.put("yunzhupaas_mdm_customer_yunzhupaas_"+key,customerMap.get(key));
}
}
//子表数据
List<CompanyInvoiceEntity> companyInvoiceList = entity.getCompanyInvoice();
companyMap.put("tableField46dc53",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
companyMap.put("companyInvoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
List<CompanyBankEntity> companyBankList = entity.getCompanyBank();
companyMap.put("tableFieldad9d92",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap.put("companyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
companyMap = generaterSwapUtil.swapDataDetail(companyMap,CustinfoConstant.getFormData(),"816972827587510981",isPc?false:false);
//子表数据
companyMap.put("companyInvoiceList",companyMap.get("tableField46dc53"));
companyMap.put("companyBankList",companyMap.get("tableFieldad9d92"));
return ActionResult.success(companyMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
CompanyEntity entity= companyService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
CustomerEntity customerEntity = entity.getCustomer();
if(ObjectUtil.isNotEmpty(customerEntity)){
Map<String, Object> customerMap=JsonUtil.entityToMap(customerEntity);
for(String key:customerMap.keySet()){
companyMap.put("yunzhupaas_mdm_customer_yunzhupaas_"+key,customerMap.get(key));
}
}
//子表数据
List<CompanyInvoiceEntity> companyInvoiceList = entity.getCompanyInvoice();
companyMap.put("tableField46dc53",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
companyMap.put("companyInvoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyInvoiceList)));
List<CompanyBankEntity> companyBankList = entity.getCompanyBank();
companyMap.put("tableFieldad9d92",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap.put("companyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap = generaterSwapUtil.swapDataForm(companyMap,CustinfoConstant.getFormData(),CustinfoConstant.TABLEFIELDKEY,CustinfoConstant.TABLERENAMES);
return ActionResult.success(companyMap);
}
}

View File

@@ -0,0 +1,947 @@
package com.yunzhupaas.mdm.controller;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.mdm.service.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.mdm.model.lpc.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import java.io.IOException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.web.multipart.MultipartFile;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.File;
import java.io.InputStream;
import com.yunzhupaas.onlinedev.model.ExcelImFieldModel;
import com.yunzhupaas.base.model.OnlineImport.ImportDataModel;
import com.yunzhupaas.base.model.OnlineImport.ImportFormCheckUniqueModel;
import com.yunzhupaas.base.model.OnlineImport.ExcelImportModel;
import com.yunzhupaas.base.model.OnlineImport.VisualImportModel;
import cn.xuyanwu.spring.file.storage.FileInfo;
import lombok.Cleanup;
import com.yunzhupaas.model.visualJson.config.HeaderModel;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.yunzhupaas.base.util.VisualUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* 法人公司
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-04-24
*/
@Slf4j
@RestController
@Tag(name = "法人公司" , description = "bcm")
@RequestMapping("/api/bcm/Lpc")
public class LpcController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private LpcService companyService;
@Autowired
private CompanyInvoiceService company_invoiceService;
@Autowired
private CompanyBankService companyBankService;
@Autowired
private CorporationService corporationService;
@Autowired
private ConfigValueUtil configValueUtil;
/**
* 列表
*
* @param companyPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody LpcPagination companyPagination)throws Exception{
List<CompanyEntity> list= companyService.getList(companyPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (CompanyEntity entity : list) {
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
CorporationEntity corporationEntity = entity.getCorporation();
if(ObjectUtil.isNotEmpty(corporationEntity)){
Map<String, Object> corporationMap=JsonUtil.entityToMap(corporationEntity);
for(String key:corporationMap.keySet()){
companyMap.put("yunzhupaas_mdm_corporation_yunzhupaas_"+key,corporationMap.get(key));
}
}
//子表数据
List<CompanyInvoiceEntity> company_invoiceList = entity.getCompanyInvoice();
companyMap.put("tableField5ced3a",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(company_invoiceList)));
companyMap.put("company_invoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(company_invoiceList)));
List<CompanyBankEntity> companyBankList = entity.getCompanyBank();
companyMap.put("tableFieldbd0aa4",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap.put("companyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
realList.add(companyMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, LpcConstant.getFormData(), LpcConstant.getColumnData(), companyPagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(companyPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param companyForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid LpcForm companyForm) throws Exception {
String b = companyService.checkForm(companyForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
// try{
companyService.saveOrUpdate(companyForm, null ,true);
// }catch(Exception e){
// return ActionResult.fail(MsgCode.FA028.get());
// }
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 导出Excel
*
* @return
*/
@Operation(summary = "导出Excel")
@PostMapping("/Actions/Export")
public ActionResult Export(@RequestBody LpcPagination companyPagination) throws IOException {
if (StringUtil.isEmpty(companyPagination.getSelectKey())){
return ActionResult.fail(MsgCode.IMP011.get());
}
List<CompanyEntity> list= companyService.getList(companyPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (CompanyEntity entity : list) {
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
CorporationEntity corporationEntity = entity.getCorporation();
if(ObjectUtil.isNotEmpty(corporationEntity)){
Map<String, Object> corporationMap=JsonUtil.entityToMap(corporationEntity);
for(String key:corporationMap.keySet()){
companyMap.put("yunzhupaas_mdm_corporation_yunzhupaas_"+key,corporationMap.get(key));
}
}
//子表数据
List<CompanyInvoiceEntity> company_invoiceList = entity.getCompanyInvoice();
companyMap.put("tableField5ced3a",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(company_invoiceList)));
companyMap.put("company_invoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(company_invoiceList)));
List<CompanyBankEntity> companyBankList = entity.getCompanyBank();
companyMap.put("tableFieldbd0aa4",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap.put("companyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
realList.add(companyMap);
}
//数据转换
realList = generaterSwapUtil.swapDataList(realList, LpcConstant.getFormData(),LpcConstant.getColumnData(), companyPagination.getModuleId(),false);
String[]keys=!StringUtil.isEmpty(companyPagination.getSelectKey())?companyPagination.getSelectKey():new String[0];
UserInfo userInfo=userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(companyPagination.getMenuId());
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo,menuFullName);
return ActionResult.success(vo);
}
/**
* 导出表格方法
*/
public DownloadVO creatModelExcel(String path,List<Map<String, Object>>list,String[]keys,UserInfo userInfo,String menuFullName){
DownloadVO vo=DownloadVO.builder().build();
List<ExcelExportEntity> entitys=new ArrayList<>();
if(keys.length>0){
ExcelExportEntity tableField5ced3aExcelEntity = new ExcelExportEntity("设计子表(tableField5ced3a)","tableField5ced3a");
List<ExcelExportEntity> tableField5ced3aList = new ArrayList<>();
ExcelExportEntity tableFieldbd0aa4ExcelEntity = new ExcelExportEntity("设计子表(tableFieldbd0aa4)","tableFieldbd0aa4");
List<ExcelExportEntity> tableFieldbd0aa4List = new ArrayList<>();
for(String key:keys){
switch(key){
case "entity_type" :
entitys.add(new ExcelExportEntity("实体类型" ,"entity_type"));
break;
case "company_code" :
entitys.add(new ExcelExportEntity("企业编码" ,"company_code"));
break;
case "company_name" :
entitys.add(new ExcelExportEntity("企业名称" ,"company_name"));
break;
case "short_name" :
entitys.add(new ExcelExportEntity("简称/昵称" ,"short_name"));
break;
case "credit_code" :
entitys.add(new ExcelExportEntity("社会信用代码" ,"credit_code"));
break;
case "tax_type" :
entitys.add(new ExcelExportEntity("纳税人类别" ,"tax_type"));
break;
case "org_id" :
entitys.add(new ExcelExportEntity("归属组织" ,"org_id"));
break;
case "province_id" :
entitys.add(new ExcelExportEntity("所属地区" ,"province_id"));
break;
case "enterprise_nature" :
entitys.add(new ExcelExportEntity("企业类型" ,"enterprise_nature"));
break;
case "industry_code" :
entitys.add(new ExcelExportEntity("行业代码" ,"industry_code"));
break;
case "enterprise_scale" :
entitys.add(new ExcelExportEntity("企业规模" ,"enterprise_scale"));
break;
case "registration_date" :
entitys.add(new ExcelExportEntity("成立日期" ,"registration_date"));
break;
case "registered_capital" :
entitys.add(new ExcelExportEntity("注册资本" ,"registered_capital"));
break;
case "legal_representative" :
entitys.add(new ExcelExportEntity("法定代表人" ,"legal_representative"));
break;
case "phone" :
entitys.add(new ExcelExportEntity("联系电话" ,"phone"));
break;
case "email" :
entitys.add(new ExcelExportEntity("邮箱" ,"email"));
break;
case "website" :
entitys.add(new ExcelExportEntity("网站" ,"website"));
break;
case "address" :
entitys.add(new ExcelExportEntity("地址" ,"address"));
break;
case "business_scope" :
entitys.add(new ExcelExportEntity("经营范围" ,"business_scope"));
break;
case "remark" :
entitys.add(new ExcelExportEntity("备注" ,"remark"));
break;
case "yunzhupaas_mdm_corporation_yunzhupaas_major_person_id" :
entitys.add(new ExcelExportEntity("负责人" ,"yunzhupaas_mdm_corporation_yunzhupaas_major_person_id"));
break;
case "tableField5ced3a-title_code":
tableField5ced3aList.add(new ExcelExportEntity("发票抬头编码" ,"title_code"));
break;
case "tableField5ced3a-title_name":
tableField5ced3aList.add(new ExcelExportEntity("发票抬头名称" ,"title_name"));
break;
case "tableField5ced3a-credit_code":
tableField5ced3aList.add(new ExcelExportEntity("纳税人识别号" ,"credit_code"));
break;
case "tableField5ced3a-tax_type":
tableField5ced3aList.add(new ExcelExportEntity("纳税人类别" ,"tax_type"));
break;
case "tableField5ced3a-address":
tableField5ced3aList.add(new ExcelExportEntity("地址" ,"address"));
break;
case "tableField5ced3a-phone":
tableField5ced3aList.add(new ExcelExportEntity("电话" ,"phone"));
break;
case "tableField5ced3a-bank_name":
tableField5ced3aList.add(new ExcelExportEntity("开户银行" ,"bank_name"));
break;
case "tableField5ced3a-bank_account":
tableField5ced3aList.add(new ExcelExportEntity("银行账户" ,"bank_account"));
break;
case "tableField5ced3a-is_defalut":
tableField5ced3aList.add(new ExcelExportEntity("是否默认抬头" ,"is_defalut"));
break;
case "tableField5ced3a-is_valid":
tableField5ced3aList.add(new ExcelExportEntity("是否有效" ,"is_valid"));
break;
case "tableField5ced3a-remark":
tableField5ced3aList.add(new ExcelExportEntity("备注" ,"remark"));
break;
case "tableFieldbd0aa4-bank_name":
tableFieldbd0aa4List.add(new ExcelExportEntity("开户行" ,"bank_name"));
break;
case "tableFieldbd0aa4-bank_account_name":
tableFieldbd0aa4List.add(new ExcelExportEntity("账户名" ,"bank_account_name"));
break;
case "tableFieldbd0aa4-bank_account_number":
tableFieldbd0aa4List.add(new ExcelExportEntity("银行账号" ,"bank_account_number"));
break;
case "tableFieldbd0aa4-bank_province":
tableFieldbd0aa4List.add(new ExcelExportEntity("开户行城市" ,"bank_province"));
break;
case "tableFieldbd0aa4-remark":
tableFieldbd0aa4List.add(new ExcelExportEntity("备注" ,"remark"));
break;
default:
break;
}
}
if(tableField5ced3aList.size() > 0){
tableField5ced3aExcelEntity.setList(tableField5ced3aList);
entitys.add(tableField5ced3aExcelEntity);
}
if(tableFieldbd0aa4List.size() > 0){
tableFieldbd0aa4ExcelEntity.setList(tableFieldbd0aa4List);
entitys.add(tableFieldbd0aa4ExcelEntity);
}
}
ExportParams exportParams = new ExportParams(null, "表单信息");
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//去除空数据
List<Map<String, Object>> dataList = new ArrayList<>();
for (Map<String, Object> map : list) {
int i = 0;
for (String key : keys) {
//子表
if (key.toLowerCase().startsWith("tablefield")) {
String tableField = key.substring(0, key.indexOf("-" ));
String field = key.substring(key.indexOf("-" ) + 1);
Object o = map.get(tableField);
if (o != null) {
List<Map<String, Object>> childList = (List<Map<String, Object>>) o;
for (Map<String, Object> childMap : childList) {
if (childMap.get(field) != null) {
i++;
}
}
}
} else {
Object o = map.get(key);
if (o != null) {
i++;
}
}
}
if (i > 0) {
dataList.add(map);
}
}
List<ExcelExportEntity> mergerEntitys = new ArrayList<>(entitys);
List<Map<String, Object>> mergerList=new ArrayList<>(dataList);
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(LpcConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
dataList = VisualUtils.complexHeaderDataHandel(dataList, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
}
exportParams.setStyle(ExcelExportStyler.class);
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, dataList);
VisualUtils.mergerVertical(workbook, mergerEntitys, mergerList);
ExcelModel excelModel = generaterSwapUtil.getExcelParams(LpcConstant.getFormData(),Arrays.asList(keys));
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName +"_"+ DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return vo;
}
@Operation(summary = "上传文件")
@PostMapping("/Uploader")
public ActionResult<Object> Uploader() {
List<MultipartFile> list = UpUtil.getFileAll();
MultipartFile file = list.get(0);
if (file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls")) {
String filePath = XSSEscape.escape(configValueUtil.getTemporaryFilePath());
String fileName = XSSEscape.escape(RandomUtil.uuId() + "." + UpUtil.getFileType(file));
//上传文件
FileInfo fileInfo = FileUploadUtils.uploadFile(file, filePath, fileName);
DownloadVO vo = DownloadVO.builder().build();
vo.setName(fileInfo.getFilename());
return ActionResult.success(vo);
} else {
return ActionResult.fail(MsgCode.FA017.get());
}
}
/**
* 模板下载
*
* @return
*/
@Operation(summary = "模板下载")
@GetMapping("/TemplateDownload")
public ActionResult<DownloadVO> TemplateDownload(@RequestParam("menuId") String menuId){
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(menuId);
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("企业名称(company_name)" ,"company_name"));
selectKeys.add("company_name");
entitys.add(new ExcelExportEntity("简称/昵称(short_name)" ,"short_name"));
selectKeys.add("short_name");
entitys.add(new ExcelExportEntity("社会信用代码(credit_code)" ,"credit_code"));
selectKeys.add("credit_code");
entitys.add(new ExcelExportEntity("纳税人类别(tax_type)" ,"tax_type"));
selectKeys.add("tax_type");
entitys.add(new ExcelExportEntity("归属组织(org_id)" ,"org_id"));
selectKeys.add("org_id");
entitys.add(new ExcelExportEntity("所属地区(province_id)" ,"province_id"));
selectKeys.add("province_id");
entitys.add(new ExcelExportEntity("企业类型(enterprise_nature)" ,"enterprise_nature"));
selectKeys.add("enterprise_nature");
entitys.add(new ExcelExportEntity("行业代码(industry_code)" ,"industry_code"));
selectKeys.add("industry_code");
entitys.add(new ExcelExportEntity("企业规模(enterprise_scale)" ,"enterprise_scale"));
selectKeys.add("enterprise_scale");
entitys.add(new ExcelExportEntity("成立日期(registration_date)" ,"registration_date"));
selectKeys.add("registration_date");
entitys.add(new ExcelExportEntity("注册资本(registered_capital)" ,"registered_capital"));
selectKeys.add("registered_capital");
entitys.add(new ExcelExportEntity("法定代表人(legal_representative)" ,"legal_representative"));
selectKeys.add("legal_representative");
entitys.add(new ExcelExportEntity("联系电话(phone)" ,"phone"));
selectKeys.add("phone");
entitys.add(new ExcelExportEntity("邮箱(email)" ,"email"));
selectKeys.add("email");
entitys.add(new ExcelExportEntity("网站(website)" ,"website"));
selectKeys.add("website");
entitys.add(new ExcelExportEntity("地址(address)" ,"address"));
selectKeys.add("address");
entitys.add(new ExcelExportEntity("负责人(yunzhupaas_mdm_corporation_yunzhupaas_major_person_id)" ,"yunzhupaas_mdm_corporation_yunzhupaas_major_person_id"));
selectKeys.add("yunzhupaas_mdm_corporation_yunzhupaas_major_person_id");
entitys.add(new ExcelExportEntity("经营范围(business_scope)" ,"business_scope"));
selectKeys.add("business_scope");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
//tableField5ced3a子表对象
ExcelExportEntity tableField5ced3aExcelEntity = new ExcelExportEntity("设计子表(tableField5ced3a)","tableField5ced3a");
List<ExcelExportEntity> tableField5ced3aExcelEntityList = new ArrayList<>();
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("发票抬头名称(tableField5ced3a-title_name)" ,"title_name"));
selectKeys.add("tableField5ced3a-title_name");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("纳税人识别号(tableField5ced3a-credit_code)" ,"credit_code"));
selectKeys.add("tableField5ced3a-credit_code");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("纳税人类别(tableField5ced3a-tax_type)" ,"tax_type"));
selectKeys.add("tableField5ced3a-tax_type");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("地址(tableField5ced3a-address)" ,"address"));
selectKeys.add("tableField5ced3a-address");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("电话(tableField5ced3a-phone)" ,"phone"));
selectKeys.add("tableField5ced3a-phone");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("开户银行(tableField5ced3a-bank_name)" ,"bank_name"));
selectKeys.add("tableField5ced3a-bank_name");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("银行账户(tableField5ced3a-bank_account)" ,"bank_account"));
selectKeys.add("tableField5ced3a-bank_account");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("是否默认抬头(tableField5ced3a-is_defalut)" ,"is_defalut"));
selectKeys.add("tableField5ced3a-is_defalut");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("是否有效(tableField5ced3a-is_valid)" ,"is_valid"));
selectKeys.add("tableField5ced3a-is_valid");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("备注(tableField5ced3a-remark)" ,"remark"));
selectKeys.add("tableField5ced3a-remark");
tableField5ced3aExcelEntity.setList(tableField5ced3aExcelEntityList);
if(tableField5ced3aExcelEntityList.size() > 0){
entitys.add(tableField5ced3aExcelEntity);
}
//tableFieldbd0aa4子表对象
ExcelExportEntity tableFieldbd0aa4ExcelEntity = new ExcelExportEntity("设计子表(tableFieldbd0aa4)","tableFieldbd0aa4");
List<ExcelExportEntity> tableFieldbd0aa4ExcelEntityList = new ArrayList<>();
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("开户行(tableFieldbd0aa4-bank_name)" ,"bank_name"));
selectKeys.add("tableFieldbd0aa4-bank_name");
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("账户名(tableFieldbd0aa4-bank_account_name)" ,"bank_account_name"));
selectKeys.add("tableFieldbd0aa4-bank_account_name");
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("银行账号(tableFieldbd0aa4-bank_account_number)" ,"bank_account_number"));
selectKeys.add("tableFieldbd0aa4-bank_account_number");
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("开户行城市(tableFieldbd0aa4-bank_province)" ,"bank_province"));
selectKeys.add("tableFieldbd0aa4-bank_province");
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("备注(tableFieldbd0aa4-remark)" ,"remark"));
selectKeys.add("tableFieldbd0aa4-remark");
tableFieldbd0aa4ExcelEntity.setList(tableFieldbd0aa4ExcelEntityList);
if(tableFieldbd0aa4ExcelEntityList.size() > 0){
entitys.add(tableFieldbd0aa4ExcelEntity);
}
ExcelModel excelModel = generaterSwapUtil.getExcelParams(LpcConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.add(excelModel.getDataMap());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(LpcConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "导入模板.xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("模板信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 导入预览
*
* @return
*/
@Operation(summary = "导入预览" )
@GetMapping("/ImportPreview")
public ActionResult<Map<String, Object>> ImportPreview(String fileName) throws Exception {
Map<String, Object> headAndDataMap = new HashMap<>(2);
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
FileUploadUtils.downLocal(configValueUtil.getTemporaryFilePath(), filePath, fileName);
File temporary = new File(XSSEscape.escapePath(filePath + fileName));
int headerRowIndex = 2;
ImportParams params = new ImportParams();
params.setTitleRows(0);
params.setHeadRows(headerRowIndex);
params.setNeedVerify(true);
try {
InputStream inputStream = ExcelUtil.solveOrginTitle(temporary, headerRowIndex);
List<Map> excelDataList = ExcelUtil.importExcelByInputStream(inputStream, 0, headerRowIndex, Map.class);
//数据超过1000条
if(excelDataList != null && excelDataList.size() > 1000) {
return ActionResult.fail(MsgCode.ETD117.get());
}
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(LpcConstant.getColumnData(), ColumnDataModel.class);
UploaderTemplateModel uploaderTemplateModel = JsonUtil.getJsonToBean(columnDataModel.getUploaderTemplateJson(), UploaderTemplateModel.class);
List<String> selectKey = uploaderTemplateModel.getSelectKey();
//子表合并
List<Map<String, Object>> results = FormExecelUtils.dataMergeChildTable(excelDataList,selectKey);
// 导入字段
List<ExcelImFieldModel> columns = new ArrayList<>();
columns.add(new ExcelImFieldModel("company_name","企业名称","input"));
columns.add(new ExcelImFieldModel("short_name","简称/昵称","input"));
columns.add(new ExcelImFieldModel("credit_code","社会信用代码","input"));
columns.add(new ExcelImFieldModel("tax_type","纳税人类别","select"));
columns.add(new ExcelImFieldModel("org_id","归属组织","organizeSelect"));
columns.add(new ExcelImFieldModel("province_id","所属地区","areaSelect"));
columns.add(new ExcelImFieldModel("enterprise_nature","企业类型","select"));
columns.add(new ExcelImFieldModel("industry_code","行业代码","select"));
columns.add(new ExcelImFieldModel("enterprise_scale","企业规模","select"));
columns.add(new ExcelImFieldModel("registration_date","成立日期","datePicker"));
columns.add(new ExcelImFieldModel("registered_capital","注册资本","inputNumber"));
columns.add(new ExcelImFieldModel("legal_representative","法定代表人","input"));
columns.add(new ExcelImFieldModel("phone","联系电话","input"));
columns.add(new ExcelImFieldModel("email","邮箱","input"));
columns.add(new ExcelImFieldModel("website","网站","input"));
columns.add(new ExcelImFieldModel("address","地址","input"));
columns.add(new ExcelImFieldModel("yunzhupaas_mdm_corporation_yunzhupaas_major_person_id","负责人","userSelect"));
columns.add(new ExcelImFieldModel("business_scope","经营范围","textarea"));
columns.add(new ExcelImFieldModel("remark","备注","textarea"));
//tableField5ced3a子表对象
List<ExcelImFieldModel> tableField5ced3acolumns = new ArrayList<>();
tableField5ced3acolumns.add(new ExcelImFieldModel("title_name" ,"*发票抬头名称"));
tableField5ced3acolumns.add(new ExcelImFieldModel("credit_code" ,"*纳税人识别号"));
tableField5ced3acolumns.add(new ExcelImFieldModel("tax_type" ,"*纳税人类别"));
tableField5ced3acolumns.add(new ExcelImFieldModel("address" ,"地址"));
tableField5ced3acolumns.add(new ExcelImFieldModel("phone" ,"电话"));
tableField5ced3acolumns.add(new ExcelImFieldModel("bank_name" ,"开户银行"));
tableField5ced3acolumns.add(new ExcelImFieldModel("bank_account" ,"银行账户"));
tableField5ced3acolumns.add(new ExcelImFieldModel("is_defalut" ,"是否默认抬头"));
tableField5ced3acolumns.add(new ExcelImFieldModel("is_valid" ,"是否有效"));
tableField5ced3acolumns.add(new ExcelImFieldModel("remark" ,"备注"));
columns.add(new ExcelImFieldModel("tableField5ced3a","设计子表","table",tableField5ced3acolumns));
//tableFieldbd0aa4子表对象
List<ExcelImFieldModel> tableFieldbd0aa4columns = new ArrayList<>();
tableFieldbd0aa4columns.add(new ExcelImFieldModel("bank_name" ,"开户行"));
tableFieldbd0aa4columns.add(new ExcelImFieldModel("bank_account_name" ,"账户名"));
tableFieldbd0aa4columns.add(new ExcelImFieldModel("bank_account_number" ,"银行账号"));
tableFieldbd0aa4columns.add(new ExcelImFieldModel("bank_province" ,"开户行城市"));
tableFieldbd0aa4columns.add(new ExcelImFieldModel("remark" ,"备注"));
columns.add(new ExcelImFieldModel("tableFieldbd0aa4","设计子表","table",tableFieldbd0aa4columns));
headAndDataMap.put("dataRow" , results);
headAndDataMap.put("headerRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
} catch (Exception e){
e.printStackTrace();
return ActionResult.fail(MsgCode.VS407.get());
}
return ActionResult.success(headAndDataMap);
}
/**
* 导入数据
*
* @return
*/
@Operation(summary = "导入数据" )
@PostMapping("/ImportData")
public ActionResult<ExcelImportModel> ImportData(@RequestBody VisualImportModel visualImportModel) throws Exception {
List<Map<String, Object>> listData = visualImportModel.getList();
ImportFormCheckUniqueModel uniqueModel = new ImportFormCheckUniqueModel();
uniqueModel.setDbLinkId(LpcConstant.DBLINKID);
uniqueModel.setUpdate(Objects.equals("2", "2"));
Map<String,String> tablefieldkey = new HashMap<>();
for(String key:LpcConstant.TABLEFIELDKEY.keySet()){
tablefieldkey.put(key,LpcConstant.TABLERENAMES.get(LpcConstant.TABLEFIELDKEY.get(key)));
}
ExcelImportModel excelImportModel = generaterSwapUtil.importData(LpcConstant.getFormData(),listData,uniqueModel, tablefieldkey,LpcConstant.getTableList());
List<ImportDataModel> importDataModel = uniqueModel.getImportDataModel();
for (ImportDataModel model : importDataModel) {
String id = model.getId();
Map<String, Object> result = model.getResultData();
if(StringUtil.isNotEmpty(id)){
update(id, JsonUtil.getJsonToBean(result,LpcForm.class), true);
}else {
create( JsonUtil.getJsonToBean(result,LpcForm.class));
}
}
return ActionResult.success(excelImportModel);
}
/**
* 导出异常报告
*
* @return
*/
@Operation(summary = "导出异常报告")
@PostMapping("/ImportExceptionData")
public ActionResult<DownloadVO> ImportExceptionData(@RequestBody VisualImportModel visualImportModel) {
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(visualImportModel.getMenuId());
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
entitys.add(new ExcelExportEntity("异常原因", "errorsInfo",30));
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("企业名称(company_name)" ,"company_name"));
selectKeys.add("company_name");
entitys.add(new ExcelExportEntity("简称/昵称(short_name)" ,"short_name"));
selectKeys.add("short_name");
entitys.add(new ExcelExportEntity("社会信用代码(credit_code)" ,"credit_code"));
selectKeys.add("credit_code");
entitys.add(new ExcelExportEntity("纳税人类别(tax_type)" ,"tax_type"));
selectKeys.add("tax_type");
entitys.add(new ExcelExportEntity("归属组织(org_id)" ,"org_id"));
selectKeys.add("org_id");
entitys.add(new ExcelExportEntity("所属地区(province_id)" ,"province_id"));
selectKeys.add("province_id");
entitys.add(new ExcelExportEntity("企业类型(enterprise_nature)" ,"enterprise_nature"));
selectKeys.add("enterprise_nature");
entitys.add(new ExcelExportEntity("行业代码(industry_code)" ,"industry_code"));
selectKeys.add("industry_code");
entitys.add(new ExcelExportEntity("企业规模(enterprise_scale)" ,"enterprise_scale"));
selectKeys.add("enterprise_scale");
entitys.add(new ExcelExportEntity("成立日期(registration_date)" ,"registration_date"));
selectKeys.add("registration_date");
entitys.add(new ExcelExportEntity("注册资本(registered_capital)" ,"registered_capital"));
selectKeys.add("registered_capital");
entitys.add(new ExcelExportEntity("法定代表人(legal_representative)" ,"legal_representative"));
selectKeys.add("legal_representative");
entitys.add(new ExcelExportEntity("联系电话(phone)" ,"phone"));
selectKeys.add("phone");
entitys.add(new ExcelExportEntity("邮箱(email)" ,"email"));
selectKeys.add("email");
entitys.add(new ExcelExportEntity("网站(website)" ,"website"));
selectKeys.add("website");
entitys.add(new ExcelExportEntity("地址(address)" ,"address"));
selectKeys.add("address");
entitys.add(new ExcelExportEntity("负责人(yunzhupaas_mdm_corporation_yunzhupaas_major_person_id)" ,"yunzhupaas_mdm_corporation_yunzhupaas_major_person_id"));
selectKeys.add("yunzhupaas_mdm_corporation_yunzhupaas_major_person_id");
entitys.add(new ExcelExportEntity("经营范围(business_scope)" ,"business_scope"));
selectKeys.add("business_scope");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
//tableField5ced3a子表对象
ExcelExportEntity tableField5ced3aExcelEntity = new ExcelExportEntity("设计子表(tableField5ced3a)","tableField5ced3a");
List<ExcelExportEntity> tableField5ced3aExcelEntityList = new ArrayList<>();
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("发票抬头名称(tableField5ced3a-title_name)" ,"title_name"));
selectKeys.add("tableField5ced3a-title_name");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("纳税人识别号(tableField5ced3a-credit_code)" ,"credit_code"));
selectKeys.add("tableField5ced3a-credit_code");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("纳税人类别(tableField5ced3a-tax_type)" ,"tax_type"));
selectKeys.add("tableField5ced3a-tax_type");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("地址(tableField5ced3a-address)" ,"address"));
selectKeys.add("tableField5ced3a-address");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("电话(tableField5ced3a-phone)" ,"phone"));
selectKeys.add("tableField5ced3a-phone");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("开户银行(tableField5ced3a-bank_name)" ,"bank_name"));
selectKeys.add("tableField5ced3a-bank_name");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("银行账户(tableField5ced3a-bank_account)" ,"bank_account"));
selectKeys.add("tableField5ced3a-bank_account");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("是否默认抬头(tableField5ced3a-is_defalut)" ,"is_defalut"));
selectKeys.add("tableField5ced3a-is_defalut");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("是否有效(tableField5ced3a-is_valid)" ,"is_valid"));
selectKeys.add("tableField5ced3a-is_valid");
tableField5ced3aExcelEntityList.add(new ExcelExportEntity("备注(tableField5ced3a-remark)" ,"remark"));
selectKeys.add("tableField5ced3a-remark");
tableField5ced3aExcelEntity.setList(tableField5ced3aExcelEntityList);
entitys.add(tableField5ced3aExcelEntity);
//tableFieldbd0aa4子表对象
ExcelExportEntity tableFieldbd0aa4ExcelEntity = new ExcelExportEntity("设计子表(tableFieldbd0aa4)","tableFieldbd0aa4");
List<ExcelExportEntity> tableFieldbd0aa4ExcelEntityList = new ArrayList<>();
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("开户行(tableFieldbd0aa4-bank_name)" ,"bank_name"));
selectKeys.add("tableFieldbd0aa4-bank_name");
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("账户名(tableFieldbd0aa4-bank_account_name)" ,"bank_account_name"));
selectKeys.add("tableFieldbd0aa4-bank_account_name");
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("银行账号(tableFieldbd0aa4-bank_account_number)" ,"bank_account_number"));
selectKeys.add("tableFieldbd0aa4-bank_account_number");
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("开户行城市(tableFieldbd0aa4-bank_province)" ,"bank_province"));
selectKeys.add("tableFieldbd0aa4-bank_province");
tableFieldbd0aa4ExcelEntityList.add(new ExcelExportEntity("备注(tableFieldbd0aa4-remark)" ,"remark"));
selectKeys.add("tableFieldbd0aa4-remark");
tableFieldbd0aa4ExcelEntity.setList(tableFieldbd0aa4ExcelEntityList);
entitys.add(tableFieldbd0aa4ExcelEntity);
ExcelModel excelModel = generaterSwapUtil.getExcelParams(LpcConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.addAll(visualImportModel.getList());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
exportParams.setFreezeCol(1);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(LpcConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "错误报告_" + DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
CompanyEntity entity= companyService.getInfo(id);
if(entity!=null){
//假删除
entity.setDeleteMark(1);
entity.setDeleteUserId(userProvider.get().getUserId());
entity.setDeleteTime(new Date());
companyService.setIgnoreLogicDelete().updateById(entity);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param companyForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid LpcForm companyForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
CompanyEntity entity= companyService.getInfo(id);
if(entity!=null){
companyForm.setCompanyId(String.valueOf(entity.getCompanyId()));
if (!isImport) {
String b = companyService.checkForm(companyForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
companyService.saveOrUpdate(companyForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
CompanyEntity entity= companyService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
CorporationEntity corporationEntity = entity.getCorporation();
if(ObjectUtil.isNotEmpty(corporationEntity)){
Map<String, Object> corporationMap=JsonUtil.entityToMap(corporationEntity);
for(String key:corporationMap.keySet()){
companyMap.put("yunzhupaas_mdm_corporation_yunzhupaas_"+key,corporationMap.get(key));
}
}
//子表数据
List<CompanyInvoiceEntity> company_invoiceList = entity.getCompanyInvoice();
companyMap.put("tableField5ced3a",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(company_invoiceList)));
companyMap.put("company_invoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(company_invoiceList)));
List<CompanyBankEntity> companyBankList = entity.getCompanyBank();
companyMap.put("tableFieldbd0aa4",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap.put("companyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
companyMap = generaterSwapUtil.swapDataDetail(companyMap,LpcConstant.getFormData(),"816296614598542021",isPc?false:false);
//子表数据
companyMap.put("company_invoiceList",companyMap.get("tableField5ced3a"));
companyMap.put("companyBankList",companyMap.get("tableFieldbd0aa4"));
return ActionResult.success(companyMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
CompanyEntity entity= companyService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> companyMap=JsonUtil.entityToMap(entity);
companyMap.put("id", companyMap.get("company_id"));
//副表数据
CorporationEntity corporationEntity = entity.getCorporation();
if(ObjectUtil.isNotEmpty(corporationEntity)){
Map<String, Object> corporationMap=JsonUtil.entityToMap(corporationEntity);
for(String key:corporationMap.keySet()){
companyMap.put("yunzhupaas_mdm_corporation_yunzhupaas_"+key,corporationMap.get(key));
}
}
//子表数据
List<CompanyInvoiceEntity> company_invoiceList = entity.getCompanyInvoice();
companyMap.put("tableField5ced3a",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(company_invoiceList)));
companyMap.put("company_invoiceList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(company_invoiceList)));
List<CompanyBankEntity> companyBankList = entity.getCompanyBank();
companyMap.put("tableFieldbd0aa4",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap.put("companyBankList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(companyBankList)));
companyMap = generaterSwapUtil.swapDataForm(companyMap,LpcConstant.getFormData(),LpcConstant.TABLEFIELDKEY,LpcConstant.TABLERENAMES);
return ActionResult.success(companyMap);
}
}

View File

@@ -1,4 +1,4 @@
package com.yunzhupaas.base.controller;
package com.yunzhupaas.mdm.controller;
import cn.hutool.core.util.ObjectUtil;
@@ -10,10 +10,10 @@ import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.base.service.*;
import com.yunzhupaas.base.entity.*;
import com.yunzhupaas.mdm.service.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.base.model.crmlead.*;
import com.yunzhupaas.mdm.model.material.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -23,6 +23,7 @@ import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.annotation.YunzhupaasField;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
@@ -59,17 +60,17 @@ import com.yunzhupaas.base.util.VisualUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* crm_lead
* 物料信息
* @版本 V5.2.7
* @版权 Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者 深圳市乐程软件有限公司
* @日期 2026-03-27
* @日期 2026-04-27
*/
@Slf4j
@RestController
@Tag(name = "crm_lead" , description = "bcm")
@RequestMapping("/api/bcm/CrmLead")
public class CrmLeadController {
@Tag(name = "物料信息" , description = "bcm")
@RequestMapping("/api/bcm/Material")
public class MaterialController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@@ -78,7 +79,7 @@ public class CrmLeadController {
private UserProvider userProvider;
@Autowired
private CrmLeadService crmLeadService;
private MaterialService materialService;
@@ -88,49 +89,48 @@ public class CrmLeadController {
/**
* 列表
*
* @param crmLeadPagination
* @param materialPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody CrmLeadPagination crmLeadPagination)throws Exception{
List<CrmLeadEntity> list= crmLeadService.getList(crmLeadPagination);
public ActionResult list(@RequestBody MaterialPagination materialPagination)throws Exception{
List<MaterialEntity> list= materialService.getList(materialPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (CrmLeadEntity entity : list) {
Map<String, Object> crmLeadMap=JsonUtil.entityToMap(entity);
crmLeadMap.put("id", crmLeadMap.get("lead_id"));
for (MaterialEntity entity : list) {
Map<String, Object> materialMap=JsonUtil.entityToMap(entity);
materialMap.put("id", materialMap.get("material_id"));
//副表数据
//子表数据
realList.add(crmLeadMap);
realList.add(materialMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, CrmLeadConstant.getFormData(), CrmLeadConstant.getColumnData(), crmLeadPagination.getModuleId(),isPc?false:false);
realList = generaterSwapUtil.swapDataList(realList, MaterialConstant.getFormData(), MaterialConstant.getColumnData(), materialPagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(crmLeadPagination, PaginationVO.class);
PaginationVO page = JsonUtil.getJsonToBean(materialPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param crmLeadForm
* @param materialForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid CrmLeadForm crmLeadForm) {
String b = crmLeadService.checkForm(crmLeadForm,0);
public ActionResult create(@RequestBody @Valid MaterialForm materialForm) {
String b = materialService.checkForm(materialForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
crmLeadService.saveOrUpdate(crmLeadForm, null ,true);
materialService.saveOrUpdate(materialForm, null ,true);
}catch(Exception e){
log.error("【创建接口异常】参数:{}", crmLeadForm, e);
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
@@ -142,24 +142,24 @@ public class CrmLeadController {
*/
@Operation(summary = "导出Excel")
@PostMapping("/Actions/Export")
public ActionResult Export(@RequestBody CrmLeadPagination crmLeadPagination) throws IOException {
if (StringUtil.isEmpty(crmLeadPagination.getSelectKey())){
public ActionResult Export(@RequestBody MaterialPagination materialPagination) throws IOException {
if (StringUtil.isEmpty(materialPagination.getSelectKey())){
return ActionResult.fail(MsgCode.IMP011.get());
}
List<CrmLeadEntity> list= crmLeadService.getList(crmLeadPagination);
List<MaterialEntity> list= materialService.getList(materialPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (CrmLeadEntity entity : list) {
Map<String, Object> crmLeadMap=JsonUtil.entityToMap(entity);
crmLeadMap.put("id", crmLeadMap.get("lead_id"));
for (MaterialEntity entity : list) {
Map<String, Object> materialMap=JsonUtil.entityToMap(entity);
materialMap.put("id", materialMap.get("material_id"));
//副表数据
//子表数据
realList.add(crmLeadMap);
realList.add(materialMap);
}
//数据转换
realList = generaterSwapUtil.swapDataList(realList, CrmLeadConstant.getFormData(), CrmLeadConstant.getColumnData(), crmLeadPagination.getModuleId(),false);
String[]keys=!StringUtil.isEmpty(crmLeadPagination.getSelectKey())?crmLeadPagination.getSelectKey():new String[0];
realList = generaterSwapUtil.swapDataList(realList, MaterialConstant.getFormData(), MaterialConstant.getColumnData(), materialPagination.getModuleId(),false);
String[]keys=!StringUtil.isEmpty(materialPagination.getSelectKey())?materialPagination.getSelectKey():new String[0];
UserInfo userInfo=userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(crmLeadPagination.getMenuId());
String menuFullName = generaterSwapUtil.getMenuName(materialPagination.getMenuId());
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo,menuFullName);
return ActionResult.success(vo);
@@ -174,26 +174,47 @@ public class CrmLeadController {
if(keys.length>0){
for(String key:keys){
switch(key){
case "lead_name" :
entitys.add(new ExcelExportEntity("线索名称" ,"lead_name"));
case "material_code" :
entitys.add(new ExcelExportEntity("物料编码" ,"material_code"));
break;
case "mobile" :
entitys.add(new ExcelExportEntity("手机号" ,"mobile"));
case "material_name" :
entitys.add(new ExcelExportEntity("物料名称" ,"material_name"));
break;
case "email" :
entitys.add(new ExcelExportEntity("邮箱" ,"email"));
case "material_category" :
entitys.add(new ExcelExportEntity("物料分类" ,"material_category"));
break;
case "lead_status" :
entitys.add(new ExcelExportEntity("状态" ,"lead_status"));
case "material_model" :
entitys.add(new ExcelExportEntity("规格型号" ,"material_model"));
break;
case "sales_id" :
entitys.add(new ExcelExportEntity("销售人员" ,"sales_id"));
case "unit_name" :
entitys.add(new ExcelExportEntity("单位名称" ,"unit_name"));
break;
case "customer_source" :
entitys.add(new ExcelExportEntity("来源" ,"customer_source"));
case "brand" :
entitys.add(new ExcelExportEntity("品牌" ,"brand"));
break;
case "remark" :
entitys.add(new ExcelExportEntity("备注" ,"remark"));
case "tax_rate" :
entitys.add(new ExcelExportEntity("税率" ,"tax_rate"));
break;
case "tax_code" :
entitys.add(new ExcelExportEntity("税收分类" ,"tax_code"));
break;
case "texture" :
entitys.add(new ExcelExportEntity("材质/纹理" ,"texture"));
break;
case "quality_standard" :
entitys.add(new ExcelExportEntity("质量标准" ,"quality_standard"));
break;
case "technical_standard" :
entitys.add(new ExcelExportEntity("技术标准" ,"technical_standard"));
break;
case "acceptance_criteria" :
entitys.add(new ExcelExportEntity("验收标准" ,"acceptance_criteria"));
break;
case "delivery_requirements" :
entitys.add(new ExcelExportEntity("交付要求" ,"delivery_requirements"));
break;
case "storage_conditions" :
entitys.add(new ExcelExportEntity("储存条件" ,"storage_conditions"));
break;
default:
break;
@@ -241,7 +262,7 @@ public class CrmLeadController {
List<ExcelExportEntity> mergerEntitys = new ArrayList<>(entitys);
List<Map<String, Object>> mergerList=new ArrayList<>(dataList);
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CrmLeadConstant.getColumnData(), ColumnDataModel.class);
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(MaterialConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
@@ -251,7 +272,7 @@ public class CrmLeadController {
exportParams.setStyle(ExcelExportStyler.class);
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, dataList);
VisualUtils.mergerVertical(workbook, mergerEntitys, mergerList);
ExcelModel excelModel = generaterSwapUtil.getExcelParams(CrmLeadConstant.getFormData(),Arrays.asList(keys));
ExcelModel excelModel = generaterSwapUtil.getExcelParams(MaterialConstant.getFormData(),Arrays.asList(keys));
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
@@ -302,21 +323,33 @@ public class CrmLeadController {
List<ExcelExportEntity> entitys = new ArrayList<>();
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("线索名称(lead_name)" ,"lead_name"));
selectKeys.add("lead_name");
entitys.add(new ExcelExportEntity("手机号(mobile)" ,"mobile"));
selectKeys.add("mobile");
entitys.add(new ExcelExportEntity("状态(lead_status)" ,"lead_status"));
selectKeys.add("lead_status");
entitys.add(new ExcelExportEntity("销售人员(sales_id)" ,"sales_id"));
selectKeys.add("sales_id");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
entitys.add(new ExcelExportEntity("邮箱(email)" ,"email"));
selectKeys.add("email");
entitys.add(new ExcelExportEntity("来源(customer_source)" ,"customer_source"));
selectKeys.add("customer_source");
ExcelModel excelModel = generaterSwapUtil.getExcelParams(CrmLeadConstant.getFormData(),selectKeys);
entitys.add(new ExcelExportEntity("物料名称(material_name)" ,"material_name"));
selectKeys.add("material_name");
entitys.add(new ExcelExportEntity("物料分类(material_category)" ,"material_category"));
selectKeys.add("material_category");
entitys.add(new ExcelExportEntity("规格型号(material_model)" ,"material_model"));
selectKeys.add("material_model");
entitys.add(new ExcelExportEntity("单位名称(unit_name)" ,"unit_name"));
selectKeys.add("unit_name");
entitys.add(new ExcelExportEntity("品牌(brand)" ,"brand"));
selectKeys.add("brand");
entitys.add(new ExcelExportEntity("税率(tax_rate)" ,"tax_rate"));
selectKeys.add("tax_rate");
entitys.add(new ExcelExportEntity("税收分类(tax_code)" ,"tax_code"));
selectKeys.add("tax_code");
entitys.add(new ExcelExportEntity("材质/纹理(texture)" ,"texture"));
selectKeys.add("texture");
entitys.add(new ExcelExportEntity("质量标准(quality_standard)" ,"quality_standard"));
selectKeys.add("quality_standard");
entitys.add(new ExcelExportEntity("技术标准(technical_standard)" ,"technical_standard"));
selectKeys.add("technical_standard");
entitys.add(new ExcelExportEntity("验收标准(acceptance_criteria)" ,"acceptance_criteria"));
selectKeys.add("acceptance_criteria");
entitys.add(new ExcelExportEntity("交付要求(delivery_requirements)" ,"delivery_requirements"));
selectKeys.add("delivery_requirements");
entitys.add(new ExcelExportEntity("储存条件(storage_conditions)" ,"storage_conditions"));
selectKeys.add("storage_conditions");
ExcelModel excelModel = generaterSwapUtil.getExcelParams(MaterialConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.add(excelModel.getDataMap());
@@ -330,7 +363,7 @@ public class CrmLeadController {
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CrmLeadConstant.getColumnData(), ColumnDataModel.class);
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(MaterialConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
@@ -380,20 +413,26 @@ public class CrmLeadController {
return ActionResult.fail(MsgCode.ETD117.get());
}
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CrmLeadConstant.getColumnData(), ColumnDataModel.class);
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(MaterialConstant.getColumnData(), ColumnDataModel.class);
UploaderTemplateModel uploaderTemplateModel = JsonUtil.getJsonToBean(columnDataModel.getUploaderTemplateJson(), UploaderTemplateModel.class);
List<String> selectKey = uploaderTemplateModel.getSelectKey();
//子表合并
List<Map<String, Object>> results = FormExecelUtils.dataMergeChildTable(excelDataList,selectKey);
// 导入字段
List<ExcelImFieldModel> columns = new ArrayList<>();
columns.add(new ExcelImFieldModel("lead_name","线索名称","input"));
columns.add(new ExcelImFieldModel("mobile","手机号","input"));
columns.add(new ExcelImFieldModel("lead_status","状态","select"));
columns.add(new ExcelImFieldModel("sales_id","销售人员","usersSelect"));
columns.add(new ExcelImFieldModel("remark","备注","textarea"));
columns.add(new ExcelImFieldModel("email","邮箱","input"));
columns.add(new ExcelImFieldModel("customer_source","来源","select"));
columns.add(new ExcelImFieldModel("material_name","物料名称","input"));
columns.add(new ExcelImFieldModel("material_category","物料分类","cascader"));
columns.add(new ExcelImFieldModel("material_model","规格型号","input"));
columns.add(new ExcelImFieldModel("unit_name","单位名称","input"));
columns.add(new ExcelImFieldModel("brand","品牌","input"));
columns.add(new ExcelImFieldModel("tax_rate","税率","select"));
columns.add(new ExcelImFieldModel("tax_code","税收分类","cascader"));
columns.add(new ExcelImFieldModel("texture","材质/纹理","input"));
columns.add(new ExcelImFieldModel("quality_standard","质量标准","input"));
columns.add(new ExcelImFieldModel("technical_standard","技术标准","textarea"));
columns.add(new ExcelImFieldModel("acceptance_criteria","验收标准","textarea"));
columns.add(new ExcelImFieldModel("delivery_requirements","交付要求","textarea"));
columns.add(new ExcelImFieldModel("storage_conditions","储存条件","textarea"));
headAndDataMap.put("dataRow" , results);
headAndDataMap.put("headerRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
} catch (Exception e){
@@ -413,22 +452,22 @@ public class CrmLeadController {
public ActionResult<ExcelImportModel> ImportData(@RequestBody VisualImportModel visualImportModel) throws Exception {
List<Map<String, Object>> listData = visualImportModel.getList();
ImportFormCheckUniqueModel uniqueModel = new ImportFormCheckUniqueModel();
uniqueModel.setDbLinkId(CrmLeadConstant.DBLINKID);
uniqueModel.setUpdate(Objects.equals("1", "2"));
uniqueModel.setDbLinkId(MaterialConstant.DBLINKID);
uniqueModel.setUpdate(Objects.equals("2", "2"));
Map<String,String> tablefieldkey = new HashMap<>();
for(String key:CrmLeadConstant.TABLEFIELDKEY.keySet()){
tablefieldkey.put(key,CrmLeadConstant.TABLERENAMES.get(CrmLeadConstant.TABLEFIELDKEY.get(key)));
for(String key:MaterialConstant.TABLEFIELDKEY.keySet()){
tablefieldkey.put(key,MaterialConstant.TABLERENAMES.get(MaterialConstant.TABLEFIELDKEY.get(key)));
}
ExcelImportModel excelImportModel = generaterSwapUtil.importData(CrmLeadConstant.getFormData(),listData,uniqueModel, tablefieldkey,CrmLeadConstant.getTableList());
ExcelImportModel excelImportModel = generaterSwapUtil.importData(MaterialConstant.getFormData(),listData,uniqueModel, tablefieldkey,MaterialConstant.getTableList());
List<ImportDataModel> importDataModel = uniqueModel.getImportDataModel();
for (ImportDataModel model : importDataModel) {
String id = model.getId();
Map<String, Object> result = model.getResultData();
if(StringUtil.isNotEmpty(id)){
update(id, JsonUtil.getJsonToBean(result,CrmLeadForm.class), true);
update(id, JsonUtil.getJsonToBean(result,MaterialForm.class), true);
}else {
create( JsonUtil.getJsonToBean(result,CrmLeadForm.class));
create( JsonUtil.getJsonToBean(result,MaterialForm.class));
}
}
return ActionResult.success(excelImportModel);
@@ -450,21 +489,33 @@ public class CrmLeadController {
entitys.add(new ExcelExportEntity("异常原因", "errorsInfo",30));
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("线索名称(lead_name)" ,"lead_name"));
selectKeys.add("lead_name");
entitys.add(new ExcelExportEntity("手机号(mobile)" ,"mobile"));
selectKeys.add("mobile");
entitys.add(new ExcelExportEntity("状态(lead_status)" ,"lead_status"));
selectKeys.add("lead_status");
entitys.add(new ExcelExportEntity("销售人员(sales_id)" ,"sales_id"));
selectKeys.add("sales_id");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
entitys.add(new ExcelExportEntity("邮箱(email)" ,"email"));
selectKeys.add("email");
entitys.add(new ExcelExportEntity("来源(customer_source)" ,"customer_source"));
selectKeys.add("customer_source");
ExcelModel excelModel = generaterSwapUtil.getExcelParams(CrmLeadConstant.getFormData(),selectKeys);
entitys.add(new ExcelExportEntity("物料名称(material_name)" ,"material_name"));
selectKeys.add("material_name");
entitys.add(new ExcelExportEntity("物料分类(material_category)" ,"material_category"));
selectKeys.add("material_category");
entitys.add(new ExcelExportEntity("规格型号(material_model)" ,"material_model"));
selectKeys.add("material_model");
entitys.add(new ExcelExportEntity("单位名称(unit_name)" ,"unit_name"));
selectKeys.add("unit_name");
entitys.add(new ExcelExportEntity("品牌(brand)" ,"brand"));
selectKeys.add("brand");
entitys.add(new ExcelExportEntity("税率(tax_rate)" ,"tax_rate"));
selectKeys.add("tax_rate");
entitys.add(new ExcelExportEntity("税收分类(tax_code)" ,"tax_code"));
selectKeys.add("tax_code");
entitys.add(new ExcelExportEntity("材质/纹理(texture)" ,"texture"));
selectKeys.add("texture");
entitys.add(new ExcelExportEntity("质量标准(quality_standard)" ,"quality_standard"));
selectKeys.add("quality_standard");
entitys.add(new ExcelExportEntity("技术标准(technical_standard)" ,"technical_standard"));
selectKeys.add("technical_standard");
entitys.add(new ExcelExportEntity("验收标准(acceptance_criteria)" ,"acceptance_criteria"));
selectKeys.add("acceptance_criteria");
entitys.add(new ExcelExportEntity("交付要求(delivery_requirements)" ,"delivery_requirements"));
selectKeys.add("delivery_requirements");
entitys.add(new ExcelExportEntity("储存条件(storage_conditions)" ,"storage_conditions"));
selectKeys.add("storage_conditions");
ExcelModel excelModel = generaterSwapUtil.getExcelParams(MaterialConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.addAll(visualImportModel.getList());
@@ -479,7 +530,7 @@ public class CrmLeadController {
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(CrmLeadConstant.getColumnData(), ColumnDataModel.class);
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(MaterialConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
@@ -513,13 +564,13 @@ public class CrmLeadController {
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
CrmLeadEntity entity= crmLeadService.getInfo(id);
MaterialEntity entity= materialService.getInfo(id);
if(entity!=null){
//假删除
entity.setDeleteMark(1);
entity.setDeleteUserId(userProvider.get().getUserId());
entity.setDeleteTime(new Date());
crmLeadService.setIgnoreLogicDelete().updateById(entity);
materialService.setIgnoreLogicDelete().updateById(entity);
}
return ActionResult.success(MsgCode.SU003.get());
}
@@ -552,30 +603,29 @@ public class CrmLeadController {
/**
* 编辑
* @param id
* @param crmLeadForm
* @param materialForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid CrmLeadForm crmLeadForm,
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid MaterialForm materialForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
CrmLeadEntity entity= crmLeadService.getInfo(id);
MaterialEntity entity= materialService.getInfo(id);
if(entity!=null){
crmLeadForm.setLeadId(String.valueOf(entity.getLeadId()));
materialForm.setMaterialId(String.valueOf(entity.getMaterialId()));
if (!isImport) {
String b = crmLeadService.checkForm(crmLeadForm,1);
String b = materialService.checkForm(materialForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
crmLeadService.saveOrUpdate(crmLeadForm,id,false);
materialService.saveOrUpdate(materialForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
log.error("【编辑接口异常】参数:{}", crmLeadForm, e);
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
@@ -592,18 +642,18 @@ public class CrmLeadController {
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
CrmLeadEntity entity= crmLeadService.getInfo(id);
MaterialEntity entity= materialService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> crmLeadMap=JsonUtil.entityToMap(entity);
crmLeadMap.put("id", crmLeadMap.get("lead_id"));
Map<String, Object> materialMap=JsonUtil.entityToMap(entity);
materialMap.put("id", materialMap.get("material_id"));
//副表数据
//子表数据
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
crmLeadMap = generaterSwapUtil.swapDataDetail(crmLeadMap,CrmLeadConstant.getFormData(),"807145376418105157",isPc?false:false);
materialMap = generaterSwapUtil.swapDataDetail(materialMap,MaterialConstant.getFormData(),"817350987260887813",isPc?false:false);
//子表数据
return ActionResult.success(crmLeadMap);
return ActionResult.success(materialMap);
}
/**
* 获取详情(编辑页)
@@ -614,16 +664,16 @@ public class CrmLeadController {
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
CrmLeadEntity entity= crmLeadService.getInfo(id);
MaterialEntity entity= materialService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> crmLeadMap=JsonUtil.entityToMap(entity);
crmLeadMap.put("id", crmLeadMap.get("lead_id"));
Map<String, Object> materialMap=JsonUtil.entityToMap(entity);
materialMap.put("id", materialMap.get("material_id"));
//副表数据
//子表数据
crmLeadMap = generaterSwapUtil.swapDataForm(crmLeadMap,CrmLeadConstant.getFormData(),CrmLeadConstant.TABLEFIELDKEY,CrmLeadConstant.TABLERENAMES);
return ActionResult.success(crmLeadMap);
materialMap = generaterSwapUtil.swapDataForm(materialMap,MaterialConstant.getFormData(),MaterialConstant.TABLEFIELDKEY,MaterialConstant.TABLERENAMES);
return ActionResult.success(materialMap);
}
}

View File

@@ -0,0 +1,743 @@
package com.yunzhupaas.mdm.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.mdm.service.*;
import com.yunzhupaas.mdm.entity.*;
import com.yunzhupaas.util.*;
import com.yunzhupaas.mdm.model.product.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunzhupaas.flowable.entity.TaskEntity;
import jakarta.validation.Valid;
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
import com.yunzhupaas.annotation.YunzhupaasField;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import com.yunzhupaas.flowable.entity.TaskEntity;
import com.yunzhupaas.exception.WorkFlowException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
import org.springframework.web.multipart.MultipartFile;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import com.yunzhupaas.onlinedev.model.ExcelImFieldModel;
import com.yunzhupaas.base.model.OnlineImport.ImportDataModel;
import com.yunzhupaas.base.model.OnlineImport.ImportFormCheckUniqueModel;
import com.yunzhupaas.base.model.OnlineImport.ExcelImportModel;
import com.yunzhupaas.base.model.OnlineImport.VisualImportModel;
import cn.xuyanwu.spring.file.storage.FileInfo;
import lombok.Cleanup;
import com.yunzhupaas.model.visualJson.config.HeaderModel;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.yunzhupaas.base.util.VisualUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* 商品信息
* @版本: V5.2.7
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
* @作者: 深圳市乐程软件有限公司
* @日期: 2026-04-27
*/
@Slf4j
@RestController
@Tag(name = "商品信息" , description = "bcm")
@RequestMapping("/api/bcm/Products")
public class ProductsController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private ProductsService productsService;
@Autowired
private ConfigValueUtil configValueUtil;
/**
* 列表
*
* @param productPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody ProductPagination productPagination)throws Exception{
List<ProductEntity> list= productsService.getList(productPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (ProductEntity entity : list) {
Map<String, Object> productMap=JsonUtil.entityToMap(entity);
productMap.put("id", productMap.get("product_id"));
//副表数据
//子表数据
realList.add(productMap);
}
//数据转换
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
realList = generaterSwapUtil.swapDataList(realList, ProductsConstant.getFormData(), ProductsConstant.getColumnData(), productPagination.getModuleId(),isPc?false:false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(productPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 创建
*
* @param productForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid ProductForm productForm) {
String b = productsService.checkForm(productForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
productsService.saveOrUpdate(productForm, null ,true);
}catch(Exception e){
return ActionResult.fail(MsgCode.FA028.get());
}
return ActionResult.success(MsgCode.SU001.get());
}
/**
* 导出Excel
*
* @return
*/
@Operation(summary = "导出Excel")
@PostMapping("/Actions/Export")
public ActionResult Export(@RequestBody ProductPagination productPagination) throws IOException {
if (StringUtil.isEmpty(productPagination.getSelectKey())){
return ActionResult.fail(MsgCode.IMP011.get());
}
List<ProductEntity> list= productsService.getList(productPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (ProductEntity entity : list) {
Map<String, Object> productMap=JsonUtil.entityToMap(entity);
productMap.put("id", productMap.get("product_id"));
//副表数据
//子表数据
realList.add(productMap);
}
//数据转换
realList = generaterSwapUtil.swapDataList(realList, ProductsConstant.getFormData(), ProductsConstant.getColumnData(), productPagination.getModuleId(),false);
String[]keys=!StringUtil.isEmpty(productPagination.getSelectKey())?productPagination.getSelectKey():new String[0];
UserInfo userInfo=userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(productPagination.getMenuId());
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo,menuFullName);
return ActionResult.success(vo);
}
/**
* 导出表格方法
*/
public DownloadVO creatModelExcel(String path,List<Map<String, Object>>list,String[]keys,UserInfo userInfo,String menuFullName){
DownloadVO vo=DownloadVO.builder().build();
List<ExcelExportEntity> entitys=new ArrayList<>();
if(keys.length>0){
for(String key:keys){
switch(key){
case "product_code" :
entitys.add(new ExcelExportEntity("商品编码" ,"product_code"));
break;
case "product_name" :
entitys.add(new ExcelExportEntity("商品名称" ,"product_name"));
break;
case "product_type" :
entitys.add(new ExcelExportEntity("商品类型" ,"product_type"));
break;
case "product_category" :
entitys.add(new ExcelExportEntity("商品分类" ,"product_category"));
break;
case "short_name" :
entitys.add(new ExcelExportEntity("商品简称" ,"short_name"));
break;
case "brand" :
entitys.add(new ExcelExportEntity("品牌" ,"brand"));
break;
case "product_model" :
entitys.add(new ExcelExportEntity("规格型号" ,"product_model"));
break;
case "color" :
entitys.add(new ExcelExportEntity("颜色" ,"color"));
break;
case "product_size" :
entitys.add(new ExcelExportEntity("尺寸/规格" ,"product_size"));
break;
case "weight" :
entitys.add(new ExcelExportEntity("重量" ,"weight"));
break;
case "min_order_quantity" :
entitys.add(new ExcelExportEntity("最小起订量" ,"min_order_quantity"));
break;
case "standard_sales_price" :
entitys.add(new ExcelExportEntity("标准销售单价" ,"standard_sales_price"));
break;
case "gross_weight" :
entitys.add(new ExcelExportEntity("毛重" ,"gross_weight"));
break;
case "net_weight" :
entitys.add(new ExcelExportEntity("净重" ,"net_weight"));
break;
case "unit_name" :
entitys.add(new ExcelExportEntity("单位名称" ,"unit_name"));
break;
case "packagesize" :
entitys.add(new ExcelExportEntity("包装尺寸" ,"packagesize"));
break;
case "cost_price" :
entitys.add(new ExcelExportEntity("成本价" ,"cost_price"));
break;
case "warranty_period" :
entitys.add(new ExcelExportEntity("保修期" ,"warranty_period"));
break;
case "tax_rate" :
entitys.add(new ExcelExportEntity("税率" ,"tax_rate"));
break;
case "tax_code" :
entitys.add(new ExcelExportEntity("税收分类" ,"tax_code"));
break;
case "warranty_terms" :
entitys.add(new ExcelExportEntity("保修条款" ,"warranty_terms"));
break;
case "remark" :
entitys.add(new ExcelExportEntity("备注" ,"remark"));
break;
default:
break;
}
}
}
ExportParams exportParams = new ExportParams(null, "表单信息");
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//去除空数据
List<Map<String, Object>> dataList = new ArrayList<>();
for (Map<String, Object> map : list) {
int i = 0;
for (String key : keys) {
//子表
if (key.toLowerCase().startsWith("tablefield")) {
String tableField = key.substring(0, key.indexOf("-" ));
String field = key.substring(key.indexOf("-" ) + 1);
Object o = map.get(tableField);
if (o != null) {
List<Map<String, Object>> childList = (List<Map<String, Object>>) o;
for (Map<String, Object> childMap : childList) {
if (childMap.get(field) != null) {
i++;
}
}
}
} else {
Object o = map.get(key);
if (o != null) {
i++;
}
}
}
if (i > 0) {
dataList.add(map);
}
}
List<ExcelExportEntity> mergerEntitys = new ArrayList<>(entitys);
List<Map<String, Object>> mergerList=new ArrayList<>(dataList);
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(ProductsConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
dataList = VisualUtils.complexHeaderDataHandel(dataList, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
}
exportParams.setStyle(ExcelExportStyler.class);
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, dataList);
VisualUtils.mergerVertical(workbook, mergerEntitys, mergerList);
ExcelModel excelModel = generaterSwapUtil.getExcelParams(ProductsConstant.getFormData(),Arrays.asList(keys));
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName +"_"+ DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return vo;
}
@Operation(summary = "上传文件")
@PostMapping("/Uploader")
public ActionResult<Object> Uploader() {
List<MultipartFile> list = UpUtil.getFileAll();
MultipartFile file = list.get(0);
if (file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls")) {
String filePath = XSSEscape.escape(configValueUtil.getTemporaryFilePath());
String fileName = XSSEscape.escape(RandomUtil.uuId() + "." + UpUtil.getFileType(file));
//上传文件
FileInfo fileInfo = FileUploadUtils.uploadFile(file, filePath, fileName);
DownloadVO vo = DownloadVO.builder().build();
vo.setName(fileInfo.getFilename());
return ActionResult.success(vo);
} else {
return ActionResult.fail(MsgCode.FA017.get());
}
}
/**
* 模板下载
*
* @return
*/
@Operation(summary = "模板下载")
@GetMapping("/TemplateDownload")
public ActionResult<DownloadVO> TemplateDownload(@RequestParam("menuId") String menuId){
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(menuId);
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("商品名称(product_name)" ,"product_name"));
selectKeys.add("product_name");
entitys.add(new ExcelExportEntity("商品类型(product_type)" ,"product_type"));
selectKeys.add("product_type");
entitys.add(new ExcelExportEntity("商品分类(product_category)" ,"product_category"));
selectKeys.add("product_category");
entitys.add(new ExcelExportEntity("商品简称(short_name)" ,"short_name"));
selectKeys.add("short_name");
entitys.add(new ExcelExportEntity("品牌(brand)" ,"brand"));
selectKeys.add("brand");
entitys.add(new ExcelExportEntity("规格型号(product_model)" ,"product_model"));
selectKeys.add("product_model");
entitys.add(new ExcelExportEntity("颜色(color)" ,"color"));
selectKeys.add("color");
entitys.add(new ExcelExportEntity("尺寸/规格(product_size)" ,"product_size"));
selectKeys.add("product_size");
entitys.add(new ExcelExportEntity("重量(weight)" ,"weight"));
selectKeys.add("weight");
entitys.add(new ExcelExportEntity("最小起订量(min_order_quantity)" ,"min_order_quantity"));
selectKeys.add("min_order_quantity");
entitys.add(new ExcelExportEntity("标准销售单价(standard_sales_price)" ,"standard_sales_price"));
selectKeys.add("standard_sales_price");
entitys.add(new ExcelExportEntity("毛重(gross_weight)" ,"gross_weight"));
selectKeys.add("gross_weight");
entitys.add(new ExcelExportEntity("净重(net_weight)" ,"net_weight"));
selectKeys.add("net_weight");
entitys.add(new ExcelExportEntity("单位名称(unit_name)" ,"unit_name"));
selectKeys.add("unit_name");
entitys.add(new ExcelExportEntity("包装尺寸(packagesize)" ,"packagesize"));
selectKeys.add("packagesize");
entitys.add(new ExcelExportEntity("成本价(cost_price)" ,"cost_price"));
selectKeys.add("cost_price");
entitys.add(new ExcelExportEntity("保修期(warranty_period)" ,"warranty_period"));
selectKeys.add("warranty_period");
entitys.add(new ExcelExportEntity("税率(tax_rate)" ,"tax_rate"));
selectKeys.add("tax_rate");
entitys.add(new ExcelExportEntity("税收分类(tax_code)" ,"tax_code"));
selectKeys.add("tax_code");
entitys.add(new ExcelExportEntity("保修条款(warranty_terms)" ,"warranty_terms"));
selectKeys.add("warranty_terms");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
ExcelModel excelModel = generaterSwapUtil.getExcelParams(ProductsConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.add(excelModel.getDataMap());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(ProductsConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "导入模板.xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("模板信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 导入预览
*
* @return
*/
@Operation(summary = "导入预览" )
@GetMapping("/ImportPreview")
public ActionResult<Map<String, Object>> ImportPreview(String fileName) throws Exception {
Map<String, Object> headAndDataMap = new HashMap<>(2);
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
FileUploadUtils.downLocal(configValueUtil.getTemporaryFilePath(), filePath, fileName);
File temporary = new File(XSSEscape.escapePath(filePath + fileName));
int headerRowIndex = 1;
ImportParams params = new ImportParams();
params.setTitleRows(0);
params.setHeadRows(headerRowIndex);
params.setNeedVerify(true);
try {
InputStream inputStream = ExcelUtil.solveOrginTitle(temporary, headerRowIndex);
List<Map> excelDataList = ExcelUtil.importExcelByInputStream(inputStream, 0, headerRowIndex, Map.class);
//数据超过1000条
if(excelDataList != null && excelDataList.size() > 1000) {
return ActionResult.fail(MsgCode.ETD117.get());
}
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(ProductsConstant.getColumnData(), ColumnDataModel.class);
UploaderTemplateModel uploaderTemplateModel = JsonUtil.getJsonToBean(columnDataModel.getUploaderTemplateJson(), UploaderTemplateModel.class);
List<String> selectKey = uploaderTemplateModel.getSelectKey();
//子表合并
List<Map<String, Object>> results = FormExecelUtils.dataMergeChildTable(excelDataList,selectKey);
// 导入字段
List<ExcelImFieldModel> columns = new ArrayList<>();
columns.add(new ExcelImFieldModel("product_name","商品名称","input"));
columns.add(new ExcelImFieldModel("product_type","商品类型","select"));
columns.add(new ExcelImFieldModel("product_category","商品分类","cascader"));
columns.add(new ExcelImFieldModel("short_name","商品简称","input"));
columns.add(new ExcelImFieldModel("brand","品牌","input"));
columns.add(new ExcelImFieldModel("product_model","规格型号","input"));
columns.add(new ExcelImFieldModel("color","颜色","input"));
columns.add(new ExcelImFieldModel("product_size","尺寸/规格","input"));
columns.add(new ExcelImFieldModel("weight","重量","input"));
columns.add(new ExcelImFieldModel("min_order_quantity","最小起订量","inputNumber"));
columns.add(new ExcelImFieldModel("standard_sales_price","标准销售单价","inputNumber"));
columns.add(new ExcelImFieldModel("gross_weight","毛重","inputNumber"));
columns.add(new ExcelImFieldModel("net_weight","净重","inputNumber"));
columns.add(new ExcelImFieldModel("unit_name","单位名称","input"));
columns.add(new ExcelImFieldModel("packagesize","包装尺寸","input"));
columns.add(new ExcelImFieldModel("cost_price","成本价","inputNumber"));
columns.add(new ExcelImFieldModel("warranty_period","保修期","inputNumber"));
columns.add(new ExcelImFieldModel("tax_rate","税率","select"));
columns.add(new ExcelImFieldModel("tax_code","税收分类","cascader"));
columns.add(new ExcelImFieldModel("warranty_terms","保修条款","textarea"));
columns.add(new ExcelImFieldModel("remark","备注","textarea"));
headAndDataMap.put("dataRow" , results);
headAndDataMap.put("headerRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
} catch (Exception e){
e.printStackTrace();
return ActionResult.fail(MsgCode.VS407.get());
}
return ActionResult.success(headAndDataMap);
}
/**
* 导入数据
*
* @return
*/
@Operation(summary = "导入数据" )
@PostMapping("/ImportData")
public ActionResult<ExcelImportModel> ImportData(@RequestBody VisualImportModel visualImportModel) throws Exception {
List<Map<String, Object>> listData = visualImportModel.getList();
ImportFormCheckUniqueModel uniqueModel = new ImportFormCheckUniqueModel();
uniqueModel.setDbLinkId(ProductsConstant.DBLINKID);
uniqueModel.setUpdate(Objects.equals("2", "2"));
Map<String,String> tablefieldkey = new HashMap<>();
for(String key:ProductsConstant.TABLEFIELDKEY.keySet()){
tablefieldkey.put(key,ProductsConstant.TABLERENAMES.get(ProductsConstant.TABLEFIELDKEY.get(key)));
}
ExcelImportModel excelImportModel = generaterSwapUtil.importData(ProductsConstant.getFormData(),listData,uniqueModel, tablefieldkey,ProductsConstant.getTableList());
List<ImportDataModel> importDataModel = uniqueModel.getImportDataModel();
for (ImportDataModel model : importDataModel) {
String id = model.getId();
Map<String, Object> result = model.getResultData();
if(StringUtil.isNotEmpty(id)){
update(id, JsonUtil.getJsonToBean(result,ProductForm.class), true);
}else {
create( JsonUtil.getJsonToBean(result,ProductForm.class));
}
}
return ActionResult.success(excelImportModel);
}
/**
* 导出异常报告
*
* @return
*/
@Operation(summary = "导出异常报告")
@PostMapping("/ImportExceptionData")
public ActionResult<DownloadVO> ImportExceptionData(@RequestBody VisualImportModel visualImportModel) {
DownloadVO vo = DownloadVO.builder().build();
UserInfo userInfo = userProvider.get();
String menuFullName = generaterSwapUtil.getMenuName(visualImportModel.getMenuId());
//主表对象
List<ExcelExportEntity> entitys = new ArrayList<>();
entitys.add(new ExcelExportEntity("异常原因", "errorsInfo",30));
List<String> selectKeys = new ArrayList<>();
//以下添加字段
entitys.add(new ExcelExportEntity("商品名称(product_name)" ,"product_name"));
selectKeys.add("product_name");
entitys.add(new ExcelExportEntity("商品类型(product_type)" ,"product_type"));
selectKeys.add("product_type");
entitys.add(new ExcelExportEntity("商品分类(product_category)" ,"product_category"));
selectKeys.add("product_category");
entitys.add(new ExcelExportEntity("商品简称(short_name)" ,"short_name"));
selectKeys.add("short_name");
entitys.add(new ExcelExportEntity("品牌(brand)" ,"brand"));
selectKeys.add("brand");
entitys.add(new ExcelExportEntity("规格型号(product_model)" ,"product_model"));
selectKeys.add("product_model");
entitys.add(new ExcelExportEntity("颜色(color)" ,"color"));
selectKeys.add("color");
entitys.add(new ExcelExportEntity("尺寸/规格(product_size)" ,"product_size"));
selectKeys.add("product_size");
entitys.add(new ExcelExportEntity("重量(weight)" ,"weight"));
selectKeys.add("weight");
entitys.add(new ExcelExportEntity("最小起订量(min_order_quantity)" ,"min_order_quantity"));
selectKeys.add("min_order_quantity");
entitys.add(new ExcelExportEntity("标准销售单价(standard_sales_price)" ,"standard_sales_price"));
selectKeys.add("standard_sales_price");
entitys.add(new ExcelExportEntity("毛重(gross_weight)" ,"gross_weight"));
selectKeys.add("gross_weight");
entitys.add(new ExcelExportEntity("净重(net_weight)" ,"net_weight"));
selectKeys.add("net_weight");
entitys.add(new ExcelExportEntity("单位名称(unit_name)" ,"unit_name"));
selectKeys.add("unit_name");
entitys.add(new ExcelExportEntity("包装尺寸(packagesize)" ,"packagesize"));
selectKeys.add("packagesize");
entitys.add(new ExcelExportEntity("成本价(cost_price)" ,"cost_price"));
selectKeys.add("cost_price");
entitys.add(new ExcelExportEntity("保修期(warranty_period)" ,"warranty_period"));
selectKeys.add("warranty_period");
entitys.add(new ExcelExportEntity("税率(tax_rate)" ,"tax_rate"));
selectKeys.add("tax_rate");
entitys.add(new ExcelExportEntity("税收分类(tax_code)" ,"tax_code"));
selectKeys.add("tax_code");
entitys.add(new ExcelExportEntity("保修条款(warranty_terms)" ,"warranty_terms"));
selectKeys.add("warranty_terms");
entitys.add(new ExcelExportEntity("备注(remark)" ,"remark"));
selectKeys.add("remark");
ExcelModel excelModel = generaterSwapUtil.getExcelParams(ProductsConstant.getFormData(),selectKeys);
List<Map<String, Object>> list = new ArrayList<>();
list.addAll(visualImportModel.getList());
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
exportParams.setStyle(ExcelExportStyler.class);
exportParams.setType(ExcelType.XSSF);
exportParams.setFreezeCol(1);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(ProductsConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
ExcelHelper helper = new ExcelHelper();
helper.init(workbook, exportParams, entitys, excelModel);
helper.doPreHandle();
helper.doPostHandle();
}
String fileName = menuFullName + "错误报告_" + DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
e.printStackTrace();
}
return ActionResult.success(vo);
}
/**
* 删除
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
ProductEntity entity= productsService.getInfo(id);
if(entity!=null){
//假删除
entity.setDeleteMark(1);
entity.setDeleteUserId(userProvider.get().getUserId());
entity.setDeleteTime(new Date());
productsService.setIgnoreLogicDelete().updateById(entity);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 批量删除
* @param obj
* @return
*/
@DeleteMapping("/batchRemove")
@Transactional
@Operation(summary = "批量删除")
public ActionResult batchRemove(@RequestBody Object obj){
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
String errInfo = "";
List<String> successList = new ArrayList<>();
for (String allId : idList){
try {
this.delete(allId,false);
successList.add(allId);
} catch (Exception e) {
errInfo = e.getMessage();
}
}
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
return ActionResult.fail(errInfo);
}
return ActionResult.success(MsgCode.SU003.get());
}
/**
* 编辑
* @param id
* @param productForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid ProductForm productForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
ProductEntity entity= productsService.getInfo(id);
if(entity!=null){
productForm.setProductId(String.valueOf(entity.getProductId()));
if (!isImport) {
String b = productsService.checkForm(productForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
try{
productsService.saveOrUpdate(productForm,id,false);
}catch (DataException e1){
return ActionResult.fail(e1.getMessage());
}catch(Exception e){
return ActionResult.fail(MsgCode.FA029.get());
}
return ActionResult.success(MsgCode.SU004.get());
}else{
return ActionResult.fail(MsgCode.FA002.get());
}
}
/**
* 表单信息(详情页)
* 详情页面使用-转换数据
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
ProductEntity entity= productsService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> productMap=JsonUtil.entityToMap(entity);
productMap.put("id", productMap.get("product_id"));
//副表数据
//子表数据
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
productMap = generaterSwapUtil.swapDataDetail(productMap,ProductsConstant.getFormData(),"817386322065883909",isPc?false:false);
//子表数据
return ActionResult.success(productMap);
}
/**
* 获取详情(编辑页)
* 编辑页面使用-不转换数据
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
ProductEntity entity= productsService.getInfo(id);
if(entity==null){
return ActionResult.fail(MsgCode.FA001.get());
}
Map<String, Object> productMap=JsonUtil.entityToMap(entity);
productMap.put("id", productMap.get("product_id"));
//副表数据
//子表数据
productMap = generaterSwapUtil.swapDataForm(productMap,ProductsConstant.getFormData(),ProductsConstant.TABLEFIELDKEY,ProductsConstant.TABLERENAMES);
return ActionResult.success(productMap);
}
}

Some files were not shown because too many files have changed in this diff Show More