去除无用代码,新增主数据功能
This commit is contained in:
@@ -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> {
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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.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 MdmProjectMapper extends SuperMapper<MdmProjectEntity> {
|
||||
public interface AssetMapper extends SuperMapper<AssetEntity> {
|
||||
|
||||
}
|
||||
@@ -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.CompanyBankEntity;
|
||||
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 CompanyBankMapper extends SuperMapper<CompanyBankEntity> {
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.yunzhupaas.base.mapper;
|
||||
package com.yunzhupaas.mdm.mapper;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.entity.MdmCompanyContactEntity;
|
||||
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 MdmCompanyContactMapper extends SuperMapper<MdmCompanyContactEntity> {
|
||||
public interface CompanyInvoiceMapper extends SuperMapper<CompanyInvoiceEntity>, BaseMapper<CompanyInvoiceEntity> {
|
||||
|
||||
}
|
||||
@@ -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.CompanyEntity;
|
||||
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 MdmCompanyMapper extends SuperMapper<MdmCompanyEntity> {
|
||||
public interface CompanyMapper extends SuperMapper<CompanyEntity> {
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.yunzhupaas.base.mapper;
|
||||
package com.yunzhupaas.mdm.mapper;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.entity.MdmCompanyBankEntity;
|
||||
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-03-26
|
||||
* 日期: 2026-04-24
|
||||
*/
|
||||
public interface MdmCompanyBankMapper extends SuperMapper<MdmCompanyBankEntity> {
|
||||
public interface CorporationMapper extends SuperMapper<CorporationEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.mdm.mapper;
|
||||
|
||||
|
||||
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-04-24
|
||||
*/
|
||||
public interface CustomersMapper extends SuperMapper<CustomerEntity> {
|
||||
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 CompanyBankService extends SuperService<CompanyBankEntity> {
|
||||
}
|
||||
@@ -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 CompanyInvoiceService extends SuperService<CompanyInvoiceEntity> {
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 CorporationService extends SuperService<CorporationEntity> {
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 CustomerService extends SuperService<CustomerEntity> {
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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.MdmCompanyBankMapper;
|
||||
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.mdmcompany.*;
|
||||
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;
|
||||
/**
|
||||
*
|
||||
* 企业信息
|
||||
* 客户信息
|
||||
* 版本: V5.2.7
|
||||
* 版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
|
||||
* 作者: 深圳市乐程软件有限公司
|
||||
* 日期: 2026-03-26
|
||||
* 日期: 2026-04-24
|
||||
*/
|
||||
@Service
|
||||
public class MdmCompanyBankServiceImpl extends SuperServiceImpl<MdmCompanyBankMapper, MdmCompanyBankEntity> implements MdmCompanyBankService{
|
||||
public class CustomersServiceImpl extends SuperServiceImpl<CustomersMapper, CustomerEntity> implements CustomerService{
|
||||
@Autowired
|
||||
private GeneraterSwapUtil generaterSwapUtil;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user