1、添加附件注解

2、完善附件保存
This commit is contained in:
2025-12-09 14:57:14 +08:00
parent b615df5612
commit a6aa52c318
16 changed files with 246 additions and 585 deletions

View File

@ -31,6 +31,12 @@
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.geg</groupId>
<artifactId>itc-ms-system-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.geg</groupId>
<artifactId>itc-ms-workflow-api</artifactId>

View File

@ -0,0 +1,24 @@
package com.pictc.datalog;
import java.lang.reflect.Field;
import com.pictc.utils.ClassUtils;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class LogAttrFieldInfo {
private String tableName;
private Field field;
private boolean list;
public static LogAttrFieldInfo ofField(String tableName,Field field) {
return new LogAttrFieldInfo().setField(field).setTableName(tableName).setList(ClassUtils.isList(field.getType()));
}
}

View File

@ -9,6 +9,7 @@ import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.pictc.annotations.datalog.LogAttrField;
import com.pictc.annotations.datalog.LogField;
import com.pictc.annotations.datalog.LogJoin;
import com.pictc.annotations.datalog.LogTable;
@ -34,6 +35,8 @@ public class LogTableInfo {
private List<LogFieldInfo> fields = CollectionUtils.newArrayList();
private List<LogAttrFieldInfo> attrs = CollectionUtils.newArrayList();
private Map<String,LogFieldInfo> fieldMap = CollectionUtils.newConcurrentHashMap();
private Map<String,LogFieldInfo> columnMap = CollectionUtils.newConcurrentHashMap();
@ -49,9 +52,11 @@ public class LogTableInfo {
info = MybatisTools.getTableInfo(table.source());
initId();
initFields();
initAttrs();
initJoins();
}
public String getName() {
return table.name();
}
@ -68,6 +73,17 @@ public class LogTableInfo {
idField = BeanUtils.getField(idKey,klazz);
}
private void initAttrs() {
if(isValid()) {
List<Field> _fields = BeanUtils.getFields(klazz, LogAttrField.class);
if(CollectionUtils.isNotEmpty(_fields)) {
for (Field field : _fields) {
attrs.add(LogAttrFieldInfo.ofField(table.source(),field));
}
}
}
}
private void initFields() {
if(isValid()) {
List<Field> _fields = BeanUtils.getFields(klazz, LogField.class);
@ -127,7 +143,7 @@ public class LogTableInfo {
return fieldInfo==null?null:BeanUtils.getFieldValue(fieldInfo.getField(),entity);
}
public Object getFieldValue(Object entity,Field field) {
public <T>T getFieldValue(Object entity,Field field) {
if(entity==null) return null;
return BeanUtils.getFieldValue(field,entity);
}

View File

@ -39,6 +39,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
import com.alibaba.nacos.shaded.com.google.common.collect.Maps;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@ -52,6 +53,7 @@ import com.pictc.converts.ConverUtil;
import com.pictc.datalog.DataOperationContent;
import com.pictc.datalog.DataOperationListener;
import com.pictc.datalog.DefaultDataOperationListener;
import com.pictc.datalog.LogAttrFieldInfo;
import com.pictc.datalog.LogFieldInfo;
import com.pictc.datalog.LogJoinInfo;
import com.pictc.datalog.LogTableInfo;
@ -70,6 +72,10 @@ import com.xjrsoft.module.datalog.mapper.DatalogMapper;
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
import com.xjrsoft.module.datalog.vo.OperationType;
import com.xjrsoft.module.organization.dto.UserDto;
import com.xjrsoft.module.system.client.IFileClient;
import com.xjrsoft.module.system.dto.LngFileUploadBindDto;
import com.xjrsoft.module.system.dto.UpdateLngFileUploadDto;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
@ -97,11 +103,18 @@ public class DataLogTools {
private static DatalogMapper logDbService;
private static IFileClient fileClient;
@Autowired
public void setLogDbService(DatalogMapper logDbService) {
DataLogTools.logDbService = logDbService;
}
@Autowired
public void setFileClient(IFileClient fileClient) {
DataLogTools.fileClient = fileClient;
}
public static DataChangeLog createLog(Class<?> klazz,OperationType type) {
DataChangeLog createLog = createLog(klazz, type, null);
return createLog.setFlowId(IdUtil.getSnowflakeNextIdStr());
@ -163,6 +176,7 @@ public class DataLogTools {
try {
mapper.insert(BeanUtil.toBean(entity,tabInfo.getEntityType()));
saveAttrs(tabInfo,entity);
datalog.setEntityId(idValue);
buildFields(datalog,tabInfo,entity,null);
logs.add(datalog);
@ -193,6 +207,32 @@ public class DataLogTools {
return entity;
}
private static <T> void saveAttrs(LogTableInfo tabInfo, T entity) {
saveAttrs(tabInfo, entity, false);
}
private static <T> void saveAttrs(LogTableInfo tabInfo, T entity,boolean remove) {
List<LogAttrFieldInfo> attrs = tabInfo.getAttrs();
if(CollectionUtils.isNotEmpty(attrs)) {
for (LogAttrFieldInfo item : attrs) {
LngFileUploadBindDto bindDto = new LngFileUploadBindDto();
bindDto.setTableId(tabInfo.getIdValue(entity));
bindDto.setTableName(item.getTableName());
bindDto.setColumnName(item.getField().getName());
bindDto.setRemove(remove);
if(item.isList()) {
bindDto.setFiles(tabInfo.getFieldValue(entity,item.getField()));
}else {
UpdateLngFileUploadDto vo = tabInfo.getFieldValue(entity,item.getField());
if(vo!=null) {
bindDto.setFiles(Lists.newArrayList(vo));
}
}
fileClient.bindTableData(bindDto);
}
}
}
public static <T>T update(T dto) {
return update(dto, new DefaultDataOperationListener<T>());
}
@ -215,8 +255,8 @@ public class DataLogTools {
List<DataChangeLog> logs = CollectionUtils.newArrayList();
DataChangeLog datalog = createLog(klazz,OperationType.UPDATE);
initJoinValue(dto,tabInfo,null);
mapper.updateById(tabInfo.toEntity(dto));
saveAttrs(tabInfo,dto);
datalog.setEntityId(idValue);
buildFields(datalog,tabInfo,dto,old);
logs.add(datalog);
@ -331,6 +371,7 @@ public class DataLogTools {
List<DataChangeLog> logs = CollectionUtils.newArrayList();
try {
delete(entity, tabInfo, mapper);
saveAttrs(tabInfo,entity,true);
DataChangeLog datalog = createLog(klazz,OperationType.DELETE);
datalog.setEntityId(id);
buildFields(datalog,tabInfo,entity,null);
@ -640,29 +681,32 @@ public class DataLogTools {
datalog.setEntityId(idValue);
Object bean = BeanUtil.toBean(item,joinTable.getEntityType());
mapper.insert(bean);
saveAttrs(joinTable,item);
buildFields(datalog,joinTable,item,null);
logs.add(datalog);
}
}else {
for (Object item : listValue) {
Long idValue = joinTable.getIdValue(item);
Object voOjb = BeanUtil.toBean(item,joinTable.getKlazz());
DataChangeLog datalog = createLog(join.getTargetClass(),type,parent);
datalog.setEntityId(idValue);
delete(voOjb, joinTable, mapper);
buildFields(datalog,joinTable,voOjb,null);
Object pojo = BeanUtil.toBean(item,joinTable.getKlazz());
delete(pojo, joinTable, mapper);
saveAttrs(joinTable,item,true);
buildFields(datalog,joinTable,item,null);
logs.add(datalog);
}
}
}else {
for (Object item : listValue) {
Long idValue = joinTable.getIdValue(item);
Object nval = BeanUtil.toBean(item,joinTable.getKlazz());
DataChangeLog datalog = createLog(join.getTargetClass(),type,parent);
datalog.setEntityId(idValue);
Object old = findById(join.getTargetClass(), idValue);
mapper.updateById(nval);
buildFields(datalog,joinTable,nval,old);
Object pojo = BeanUtil.toBean(item,joinTable.getKlazz());
mapper.updateById(pojo);
saveAttrs(joinTable,item);
buildFields(datalog,joinTable,item,old);
logs.add(datalog);
}
}
@ -671,12 +715,13 @@ public class DataLogTools {
List oldList = getJoinList(joinTable, join, mapper, parentInfo, entity);
if(oldList!=null) {
for (Object item : oldList) {
Object voOjb = BeanUtil.toBean(item,joinTable.getKlazz());
Long idValue = joinTable.getIdValue(item);
DataChangeLog datalog = createLog(join.getTargetClass(),OperationType.DELETE,parent);
datalog.setEntityId(idValue);
delete(voOjb, joinTable, mapper);
buildFields(datalog,joinTable,voOjb,null);
Object pojo = BeanUtil.toBean(item,joinTable.getKlazz());
delete(pojo, joinTable, mapper);
saveAttrs(joinTable,item,true);
buildFields(datalog,joinTable,item,null);
logs.add(datalog);
}
}
@ -688,29 +733,33 @@ public class DataLogTools {
DataChangeLog datalog = createLog(join.getTargetClass(),type,parent);
logs.add(datalog);
datalog.setEntityId(idValue);
Object pojo = BeanUtil.toBean(val,joinTable.getKlazz());
if(type==OperationType.INSERT || type==OperationType.DELETE) {
if(type==OperationType.INSERT) {
mapper.insert(val);
mapper.insert(pojo);
saveAttrs(joinTable,val);
}else {
delete(val, joinTable, mapper);
delete(pojo, joinTable, mapper);
saveAttrs(joinTable,val,true);
}
buildFields(datalog,joinTable, val, null);
}else {
Object old = mapper.selectById(idValue);
mapper.updateById(pojo);
saveAttrs(joinTable,val,true);
buildFields(datalog,joinTable,val,old);
Object bean = BeanUtil.toBean(val,joinTable.getEntityType());
mapper.updateById(bean);
}
} else if(type==OperationType.UPDATE || type==OperationType.DELETE){
//进行修改或者删除时,级联对象为空时,需要删除旧数据
Object old = getJoinObj(joinTable, join, mapper, parentInfo, entity);
if(old!=null) {
Object voOjb = BeanUtil.toBean(old,joinTable.getKlazz());
Object dto = BeanUtil.toBean(old,joinTable.getKlazz());
Long idValue = joinTable.getIdValue(old);
DataChangeLog datalog = createLog(join.getTargetClass(),OperationType.DELETE,parent);
datalog.setEntityId(idValue);
delete(voOjb, joinTable, mapper);
buildFields(datalog,joinTable,voOjb,null);
delete(dto, joinTable, mapper);
saveAttrs(joinTable,dto,true);
buildFields(datalog,joinTable,dto,null);
}
}
}
@ -1185,11 +1234,6 @@ public class DataLogTools {
}
public static void main(String[] args) {
long id = IdWorker.getId();
System.out.println(""+id);
System.out.println((""+id).length());
}
}

View File

@ -16,7 +16,10 @@ import com.pictc.annotations.datalog.LogJoin;
import com.pictc.annotations.datalog.LogJoinColumn;
import com.pictc.annotations.datalog.JoinCaseType;
import com.pictc.annotations.datalog.JoinType;
import com.pictc.annotations.datalog.LogAttrField;
import com.pictc.annotations.datalog.ValueDirectionType;
import com.xjrsoft.module.system.dto.UpdateLngFileUploadDto;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
@ -100,10 +103,6 @@ public class UpdateLngCustomerDocDto implements Serializable {
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
@LogJoin(name = "lngFileUpload子表",
columns = {
@LogJoinColumn(field = "tableId",relatedField = "id", valueDirection = ValueDirectionType.RIGHT)
},
caseType = JoinCaseType.FULL, target = UpdateLngFileUploadDto.class, type = JoinType.MANY)
@LogAttrField
private List<UpdateLngFileUploadDto> fileList;
}

View File

@ -7,11 +7,14 @@ import java.util.List;
import com.pictc.annotations.datalog.JoinCaseType;
import com.pictc.annotations.datalog.JoinType;
import com.pictc.annotations.datalog.LogAttrField;
import com.pictc.annotations.datalog.LogField;
import com.pictc.annotations.datalog.LogJoin;
import com.pictc.annotations.datalog.LogJoinColumn;
import com.pictc.annotations.datalog.LogTable;
import com.pictc.annotations.datalog.ValueDirectionType;
import com.xjrsoft.module.system.dto.UpdateLngFileUploadDto;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -292,10 +295,6 @@ public class UpdateLngCustomerDto implements Serializable {
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
@LogJoin(name = "lngFileUpload子表",
columns = {
@LogJoinColumn(field = "tableId",relatedField = "id", valueDirection = ValueDirectionType.RIGHT)
},
caseType = JoinCaseType.FULL, target = UpdateLngFileUploadDto.class, type = JoinType.MANY)
@LogAttrField
private List<UpdateLngFileUploadDto> lngFileUploadList;
}

View File

@ -1,109 +0,0 @@
package com.xjrsoft.module.sales.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.List;
import com.pictc.annotations.datalog.LogTable;
import com.pictc.annotations.datalog.LogField;
import com.pictc.annotations.datalog.LogJoin;
import com.pictc.annotations.datalog.LogJoinColumn;
import com.pictc.annotations.datalog.JoinCaseType;
import com.pictc.annotations.datalog.JoinType;
import com.pictc.annotations.datalog.ValueDirectionType;
/**
* @title: 客户
* @Author 管理员
* @Date: 2025-11-21
* @Version 1.0
*/
@Data
@LogTable(source="lng_file_upload",name="客户")
public class UpdateLngFileUploadDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@LogField(name="",index=0)
@ApiModelProperty("")
private Long id;
/**
*
*/
@LogField(name="",index=1)
@ApiModelProperty("")
private String tableName;
/**
*
*/
@LogField(name="",index=2)
@ApiModelProperty("")
private Long tableId;
/**
*
*/
@LogField(name="",index=3)
@ApiModelProperty("")
private String columnName;
/**
*
*/
@LogField(name="",index=4)
@ApiModelProperty("")
private String fileOrg;
/**
*
*/
@LogField(name="",index=5)
@ApiModelProperty("")
private String filePath;
/**
*
*/
@LogField(name="",index=6)
@ApiModelProperty("")
private Long fileSize;
/**
*
*/
@LogField(name="",index=7)
@ApiModelProperty("")
private String docDesc;
/**
*
*/
@LogField(name="",index=8)
@ApiModelProperty("")
private Short sort;
/**
*
*/
@LogField(name="",index=9)
@ApiModelProperty("")
private Long tenantId;
@LogField(name="",index=10)
@ApiModelProperty("")
private Long xjrFileId;
}

View File

@ -8,6 +8,8 @@ import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
/**
* @title: 表单出参
* @Author 管理员

View File

@ -4,6 +4,8 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

View File

@ -1,143 +0,0 @@
package com.xjrsoft.module.sales.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
import com.pictc.annotations.datalog.LogField;
/**
* @title: 表单出参
* @Author 管理员
* @Date: 2025-11-21
* @Version 1.0
*/
@Data
public class LngFileUploadVo {
/**
*
*/
@ApiModelProperty("")
private Long id;
/**
*
*/
@ApiModelProperty("")
private String tableName;
/**
*
*/
@ApiModelProperty("")
private Long tableId;
/**
*
*/
@ApiModelProperty("")
private String columnName;
/**
*
*/
@ApiModelProperty("")
private String fileOrg;
/**
*
*/
@ApiModelProperty("")
private String filePath;
/**
*
*/
@ApiModelProperty("")
private Long fileSize;
/**
*
*/
@ApiModelProperty("")
private String docDesc;
/**
*
*/
@ApiModelProperty("")
private Short sort;
/**
*
*/
@ApiModelProperty("")
private Long createUserId;
/**
*
*/
@ApiModelProperty("")
private LocalDateTime createDate;
/**
*
*/
@ApiModelProperty("")
private Long modifyUserId;
/**
*
*/
@ApiModelProperty("")
private LocalDateTime modifyDate;
/**
*
*/
@ApiModelProperty("")
private Long tenantId;
/**
*
*/
@ApiModelProperty("")
private Long deptId;
/**
*
*/
@ApiModelProperty("")
private Long ruleUserId;
@ApiModelProperty("")
private String presignedUrl;
@LogField(name="",index=10)
@ApiModelProperty("")
private Long xjrFileId;
}

View File

@ -15,11 +15,17 @@ import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.pictc.datalog.DataOperationContent;
import com.pictc.datalog.DataOperationListener;
import com.pictc.enums.BusinessCode;
import com.pictc.enums.ExceptionCommonCode;
import com.pictc.utils.StringUtils;
import com.xjrsoft.common.exception.BusinessException;
import com.xjrsoft.common.model.result.R;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.utils.VoToColumnUtil;
import com.xjrsoft.module.common.db.utils.CommonCallUtils;
import com.xjrsoft.module.datalog.service.DatalogService;
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
import com.xjrsoft.module.sales.dto.LngCustomerPageDto;
@ -106,13 +112,13 @@ public class CustomerController {
@ApiOperation(value = "新增LngCustomer")
@SaCheckPermission("customer:add")
public R add(@Valid @RequestBody UpdateLngCustomerDto dto){
String code = codeRuleClient.genEncode(CUSTOMER_CODE);
dto.setCuCode("C"+code);
Long id = customerService.add(dto);
dto.setId(id);
codeRuleClient.useEncode(CUSTOMER_CODE);
return R.ok(dto);
/**
// String code = codeRuleClient.genEncode(CUSTOMER_CODE);
// dto.setCuCode("C"+code);
// Long id = customerService.add(dto);
// dto.setId(id);
// codeRuleClient.useEncode(CUSTOMER_CODE);
// return R.ok(dto);
return R.ok(dataService.insert(dto,new DataOperationListener<UpdateLngCustomerDto>() {
@Override
@ -125,14 +131,14 @@ public class CustomerController {
@Override
public UpdateLngCustomerDto after(DataOperationContent<UpdateLngCustomerDto> content) {
String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue());
if (StringUtils.isNotBlank(msg)) {
if (StringUtils.isNotEmpty(msg)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
}
codeRuleClient.useEncode(CUSTOMER_CODE);
return content.getObj();
}
}));
**/
}
@ -140,8 +146,27 @@ public class CustomerController {
@ApiOperation(value = "修改LngCustomer")
@SaCheckPermission("customer:edit")
public R update(@Valid @RequestBody UpdateLngCustomerDto dto){
customerService.update(dto);
return R.ok();
// customerService.update(dto);
// return R.ok();
return R.ok(dataService.updateById(dto,new DataOperationListener<UpdateLngCustomerDto>() {
@Override
public UpdateLngCustomerDto before(DataOperationContent<UpdateLngCustomerDto> content) {
String code = codeRuleClient.genEncode(CUSTOMER_CODE);
dto.setCuCode("C"+code);
return content.getObj();
}
@Override
public UpdateLngCustomerDto after(DataOperationContent<UpdateLngCustomerDto> content) {
String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue());
if (StringUtils.isNotEmpty(msg)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
}
codeRuleClient.useEncode(CUSTOMER_CODE);
return content.getObj();
}
}));
}
@DeleteMapping

View File

@ -15,7 +15,6 @@ import com.pictc.annotations.datalog.JoinType;
import com.pictc.annotations.datalog.LogJoin;
import com.pictc.annotations.datalog.LogJoinColumn;
import com.pictc.annotations.datalog.ValueDirectionType;
import com.xjrsoft.module.sales.dto.UpdateLngFileUploadDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -314,17 +313,4 @@ public class LngCustomer implements Serializable {
private List<LngCustomerContact> lngCustomerContactList;
/**
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
@TableField(exist = false)
@EntityMapping(thisField = "id", joinField = "tableId")
@LogJoin(name = "lngFileUpload子表",
columns = {
@LogJoinColumn(field = "tableId",relatedField = "id", valueDirection = ValueDirectionType.RIGHT)
},
caseType = JoinCaseType.FULL, target = UpdateLngFileUploadDto.class, type = JoinType.MANY)
private List<LngFileUpload> lngFileUploadList;
}

View File

@ -2,19 +2,11 @@ package com.xjrsoft.module.sales.entity;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.yulichang.annotation.EntityMapping;
import com.pictc.annotations.datalog.JoinCaseType;
import com.pictc.annotations.datalog.JoinType;
import com.pictc.annotations.datalog.LogJoin;
import com.pictc.annotations.datalog.LogJoinColumn;
import com.pictc.annotations.datalog.ValueDirectionType;
import com.xjrsoft.module.sales.dto.UpdateLngFileUploadDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -131,18 +123,5 @@ public class LngCustomerDoc implements Serializable {
@TableField(fill = FieldFill.INSERT)
private Long ruleUserId;
/**
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
@TableField(exist = false)
@EntityMapping(thisField = "id", joinField = "tableId")
@LogJoin(name = "lngFileUpload子表",
columns = {
@LogJoinColumn(field = "tableId",relatedField = "id", valueDirection = ValueDirectionType.RIGHT)
},
caseType = JoinCaseType.FULL, target = UpdateLngFileUploadDto.class, type = JoinType.MANY)
private List<LngFileUpload> fileList;
}

View File

@ -1,143 +0,0 @@
package com.xjrsoft.module.sales.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import com.github.yulichang.annotation.EntityMapping;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
/**
* @title: 客户
* @Author 管理员
* @Date: 2025-11-21
* @Version 1.0
*/
@Data
@TableName("lng_file_upload")
@ApiModel(value = "客户对象", description = "客户")
public class LngFileUpload implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("")
@TableId
private Long id;
/**
*
*/
@ApiModelProperty("")
private String tableName;
/**
*
*/
@ApiModelProperty("")
private Long tableId;
/**
*
*/
@ApiModelProperty("")
private String columnName;
/**
*
*/
@ApiModelProperty("")
private String fileOrg;
/**
*
*/
@ApiModelProperty("")
private String filePath;
/**
*
*/
@ApiModelProperty("")
private Long fileSize;
/**
*
*/
@ApiModelProperty("")
private String docDesc;
/**
*
*/
@ApiModelProperty("")
private Short sort;
/**
*
*/
@ApiModelProperty("")
@TableField(fill = FieldFill.INSERT)
private Long createUserId;
/**
*
*/
@ApiModelProperty("")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createDate;
/**
*
*/
@ApiModelProperty("")
@TableField(fill = FieldFill.UPDATE)
private Long modifyUserId;
/**
*
*/
@ApiModelProperty("")
@TableField(fill = FieldFill.UPDATE)
private LocalDateTime modifyDate;
/**
*
*/
@ApiModelProperty("")
private Long tenantId;
/**
*
*/
@ApiModelProperty("")
@TableField(fill = FieldFill.INSERT)
private Long deptId;
/**
*
*/
@ApiModelProperty("")
@TableField(fill = FieldFill.INSERT)
private Long ruleUserId;
@ApiModelProperty("")
@TableField(exist = false)
private String presignedUrl;
//@ApiModelProperty("")
//private Long xjrFileId;
}

View File

@ -1,18 +0,0 @@
package com.xjrsoft.module.sales.mapper;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.module.sales.entity.LngFileUpload;
/**
* @title: mapper
* @Author 管理员
* @Date: 2025-11-21
* @Version 1.0
*/
@Mapper
public interface LngFileUploadMapper extends MPJBaseMapper<LngFileUpload>,BaseMapper<LngFileUpload> {
}

View File

@ -1,42 +1,36 @@
package com.xjrsoft.module.sales.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.pictc.utils.StringUtils;
import com.xjrsoft.module.sales.entity.LngCustomerAttrPower;
import com.xjrsoft.module.sales.mapper.LngCustomerAttrPowerMapper;
import com.xjrsoft.module.sales.entity.LngCustomerBank;
import com.xjrsoft.module.sales.mapper.LngCustomerBankMapper;
import com.xjrsoft.module.sales.entity.LngCustomerDoc;
import com.xjrsoft.module.sales.entity.LngFileUpload;
import com.xjrsoft.module.sales.mapper.LngCustomerDocMapper;
import com.xjrsoft.module.sales.entity.LngCustomerContact;
import com.xjrsoft.module.sales.mapper.LngCustomerContactMapper;
import com.xjrsoft.common.factory.CloudStorageService;
import com.xjrsoft.common.factory.OssFactory;
import com.xjrsoft.module.sales.dto.UpdateLngCustomerAttrPowerDto;
import com.xjrsoft.module.sales.dto.UpdateLngCustomerBankDto;
import com.xjrsoft.module.sales.dto.UpdateLngCustomerContactDto;
import com.xjrsoft.module.sales.dto.UpdateLngCustomerDocDto;
import com.xjrsoft.module.sales.dto.UpdateLngCustomerDto;
import com.xjrsoft.module.sales.dto.UpdateLngFileUploadDto;
import com.xjrsoft.module.sales.entity.LngCustomer;
import com.xjrsoft.module.sales.entity.LngCustomerAttrPower;
import com.xjrsoft.module.sales.entity.LngCustomerBank;
import com.xjrsoft.module.sales.entity.LngCustomerContact;
import com.xjrsoft.module.sales.entity.LngCustomerDoc;
import com.xjrsoft.module.sales.mapper.LngCustomerAttrPowerMapper;
import com.xjrsoft.module.sales.mapper.LngCustomerBankMapper;
import com.xjrsoft.module.sales.mapper.LngCustomerContactMapper;
import com.xjrsoft.module.sales.mapper.LngCustomerDocMapper;
import com.xjrsoft.module.sales.mapper.LngCustomerMapper;
import com.xjrsoft.module.sales.mapper.LngFileUploadMapper;
import com.xjrsoft.module.sales.service.ICustomerService;
import com.xjrsoft.module.system.client.IFileClient;
import com.xjrsoft.module.system.dto.LngFileUploadBindDto;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
/**
* @title: service
@ -53,7 +47,8 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
private final LngCustomerBankMapper lngCustomerBankMapper;
private final LngCustomerDocMapper lngCustomerDocMapper;
private final LngCustomerContactMapper lngCustomerContactMapper;
private final LngFileUploadMapper lngFileUploadMapper;
private final IFileClient fileClient;
@Override
@ -82,14 +77,12 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
lngCustomerDocMapper.insert(lngCustomerDoc);
if(CollectionUtil.isNotEmpty(updateLngCustomerDocDto.getFileList())) {
for(UpdateLngFileUploadDto lngFileUploadDto:updateLngCustomerDocDto.getFileList()) {
LngFileUpload lngFileUpload = new LngFileUpload();
BeanUtil.copyProperties(lngFileUploadDto, lngFileUpload);
lngFileUpload.setTableName("lng_customer_doc");
lngFileUpload.setTableId(lngCustomerDoc.getId());
lngFileUploadMapper.insert(lngFileUpload);
}
LngFileUploadBindDto bindDto = new LngFileUploadBindDto();
bindDto.setTableId(updateLngCustomerDocDto.getId());
bindDto.setTableName("lng_customer_doc");
bindDto.setColumnName("fileList");
bindDto.setFiles(updateLngCustomerDocDto.getFileList());
fileClient.bindTableData(bindDto);
}
}
@ -100,13 +93,13 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
lngCustomerContactMapper.insert(lngCustomerContact);
}
if(updateLngCustomerDto.getLngFileUploadList() != null) {
for (UpdateLngFileUploadDto lngFileUploadDto : updateLngCustomerDto.getLngFileUploadList()) {
LngFileUpload lngFileUpload = new LngFileUpload();
BeanUtil.copyProperties(lngFileUploadDto, lngFileUpload);
lngFileUpload.setTableName("lng_customer");
lngFileUpload.setTableId(lngCustomer.getId());
lngFileUploadMapper.insert(lngFileUpload);
}
LngFileUploadBindDto bindDto = new LngFileUploadBindDto();
bindDto.setTableId(updateLngCustomerDto.getId());
bindDto.setTableName("lng_customer");
bindDto.setColumnName("lngFileUploadList");
bindDto.setFiles(updateLngCustomerDto.getLngFileUploadList());
fileClient.bindTableData(bindDto);
}
return lngCustomer.getId();
@ -198,7 +191,7 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
if (lngCustomerDoc.getId() != null) {
lngCustomerDocMapper.updateById(lngCustomerDoc);
lngFileUploadMapper.delete(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableName, "lng_customer_doc").eq(LngFileUpload::getTableId, lngCustomerDoc.getId()));
//lngFileUploadMapper.delete(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableName, "lng_customer_doc").eq(LngFileUpload::getTableId, lngCustomerDoc.getId()));
}
//如果等于空 则新增
else {
@ -207,20 +200,20 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
lngCustomerDocMapper.insert(lngCustomerDoc);
}
if(CollectionUtil.isNotEmpty(lngCustomerDocDto.getFileList())) {
for(UpdateLngFileUploadDto lngFileUploadDto:lngCustomerDocDto.getFileList()) {
LngFileUpload lngFileUpload = new LngFileUpload();
BeanUtil.copyProperties(lngFileUploadDto, lngFileUpload);
lngFileUpload.setTableName("lng_customer_doc");
lngFileUpload.setTableId(lngCustomerDoc.getId());
lngFileUploadMapper.insert(lngFileUpload);
}
// for(UpdateLngFileUploadDto lngFileUploadDto:lngCustomerDocDto.getFileList()) {
// LngFileUpload lngFileUpload = new LngFileUpload();
// BeanUtil.copyProperties(lngFileUploadDto, lngFileUpload);
// lngFileUpload.setTableName("lng_customer_doc");
// lngFileUpload.setTableId(lngCustomerDoc.getId());
// lngFileUploadMapper.insert(lngFileUpload);
// }
}
}
//已经不存在的id 删除
if(lngCustomerDocRemoveIds.size() > 0){
lngCustomerDocMapper.deleteBatchIds(lngCustomerDocRemoveIds);
lngFileUploadMapper.delete(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableName, "lng_customer_doc").in(LngFileUpload::getTableId, lngCustomerDocRemoveIds));
//lngFileUploadMapper.delete(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableName, "lng_customer_doc").in(LngFileUpload::getTableId, lngCustomerDocRemoveIds));
}
}
@ -260,31 +253,31 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
//********************************* LngFileUpload 增删改 开始 *******************************************/
{
// 查出所有子级的id
List<LngFileUpload> lngFileUploadList = lngFileUploadMapper.selectList(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableName, "lng_customer").eq(LngFileUpload::getTableId, lngCustomer.getId()).select(LngFileUpload::getId));
List<Long> lngFileUploadIds = lngFileUploadList.stream().map(LngFileUpload::getId).collect(Collectors.toList());
//原有子表单 没有被删除的主键
List<Long> lngFileUploadOldIds = updateLngCustomerDto.getLngFileUploadList().stream().map(UpdateLngFileUploadDto::getId).filter(Objects::nonNull).collect(Collectors.toList());
//找到需要删除的id
List<Long> lngFileUploadRemoveIds = lngFileUploadIds.stream().filter(item -> !lngFileUploadOldIds.contains(item)).collect(Collectors.toList());
for (UpdateLngFileUploadDto lngFileUploadDto : updateLngCustomerDto.getLngFileUploadList()) {
LngFileUpload lngFileUpload = new LngFileUpload();
BeanUtil.copyProperties(lngFileUploadDto, lngFileUpload);
lngFileUpload.setTableName("lng_customer");
//如果不等于空则修改
if (lngFileUpload.getId() != null) {
lngFileUploadMapper.updateById(lngFileUpload);
}
//如果等于空 则新增
else {
lngFileUpload.setTableId(lngCustomer.getId());
lngFileUploadMapper.insert(lngFileUpload);
}
}
//已经不存在的id 删除
if(lngFileUploadRemoveIds.size() > 0){
lngFileUploadMapper.deleteBatchIds(lngFileUploadRemoveIds);
}
// List<LngFileUpload> lngFileUploadList = lngFileUploadMapper.selectList(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableName, "lng_customer").eq(LngFileUpload::getTableId, lngCustomer.getId()).select(LngFileUpload::getId));
// List<Long> lngFileUploadIds = lngFileUploadList.stream().map(LngFileUpload::getId).collect(Collectors.toList());
// //原有子表单 没有被删除的主键
// List<Long> lngFileUploadOldIds = updateLngCustomerDto.getLngFileUploadList().stream().map(UpdateLngFileUploadDto::getId).filter(Objects::nonNull).collect(Collectors.toList());
// //找到需要删除的id
// List<Long> lngFileUploadRemoveIds = lngFileUploadIds.stream().filter(item -> !lngFileUploadOldIds.contains(item)).collect(Collectors.toList());
//
// for (UpdateLngFileUploadDto lngFileUploadDto : updateLngCustomerDto.getLngFileUploadList()) {
// LngFileUpload lngFileUpload = new LngFileUpload();
// BeanUtil.copyProperties(lngFileUploadDto, lngFileUpload);
// lngFileUpload.setTableName("lng_customer");
// //如果不等于空则修改
// if (lngFileUpload.getId() != null) {
// lngFileUploadMapper.updateById(lngFileUpload);
// }
// //如果等于空 则新增
// else {
// lngFileUpload.setTableId(lngCustomer.getId());
// lngFileUploadMapper.insert(lngFileUpload);
// }
// }
// //已经不存在的id 删除
// if(lngFileUploadRemoveIds.size() > 0){
// lngFileUploadMapper.deleteBatchIds(lngFileUploadRemoveIds);
// }
}
//********************************* LngFileUpload 增删改 结束 *******************************************/
return true;
@ -301,8 +294,7 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
lngCustomerBankMapper.delete(Wrappers.lambdaQuery(LngCustomerBank.class).in(LngCustomerBank::getCuCode, cuCodeList));
lngCustomerDocMapper.delete(Wrappers.lambdaQuery(LngCustomerDoc.class).in(LngCustomerDoc::getCuCode, cuCodeList));
lngCustomerContactMapper.delete(Wrappers.lambdaQuery(LngCustomerContact.class).in(LngCustomerContact::getCuCode, cuCodeList));
lngFileUploadMapper.delete(Wrappers.lambdaQuery(LngFileUpload.class).in(LngFileUpload::getTableId, ids).eq(LngFileUpload::getTableName, "lng_customer"));
// lngFileUploadMapper.delete(Wrappers.lambdaQuery(LngFileUpload.class).in(LngFileUpload::getTableId, ids).eq(LngFileUpload::getTableName, "lng_customer"));
}
return true;
}
@ -316,24 +308,24 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
}
if(CollectionUtil.isNotEmpty(lngCustomer.getLngCustomerDocList())) {
for(LngCustomerDoc lngCustomerDoc: lngCustomer.getLngCustomerDocList()) {
List<LngFileUpload> tempList = lngFileUploadMapper.selectList(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableId, lngCustomerDoc.getId()).eq(LngFileUpload::getTableName, "lng_customer_doc"));
if(CollectionUtil.isNotEmpty(tempList)) {
CloudStorageService storageService = OssFactory.build();
tempList.forEach(file -> {
file.setPresignedUrl(storageService.fixUrl(file.getFilePath()));
});
lngCustomerDoc.setFileList(tempList);
// List<LngFileUpload> tempList = lngFileUploadMapper.selectList(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableId, lngCustomerDoc.getId()).eq(LngFileUpload::getTableName, "lng_customer_doc"));
// if(CollectionUtil.isNotEmpty(tempList)) {
// CloudStorageService storageService = OssFactory.build();
// tempList.forEach(file -> {
// file.setPresignedUrl(storageService.fixUrl(file.getFilePath()));
// });
// lngCustomerDoc.setFileList(tempList);
// }
}
}
}
List<LngFileUpload> fileList = lngFileUploadMapper.selectList(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableId, lngCustomer.getId()).eq(LngFileUpload::getTableName, "lng_customer"));
if (CollUtil.isNotEmpty(fileList)) {
CloudStorageService storageService = OssFactory.build();
fileList.forEach(file -> {
file.setPresignedUrl(storageService.fixUrl(file.getFilePath()));
});
}
lngCustomer.setLngFileUploadList(fileList);
// List<LngFileUpload> fileList = lngFileUploadMapper.selectList(Wrappers.lambdaQuery(LngFileUpload.class).eq(LngFileUpload::getTableId, lngCustomer.getId()).eq(LngFileUpload::getTableName, "lng_customer"));
// if (CollUtil.isNotEmpty(fileList)) {
// CloudStorageService storageService = OssFactory.build();
// fileList.forEach(file -> {
// file.setPresignedUrl(storageService.fixUrl(file.getFilePath()));
// });
// }
//lngCustomer.setLngFileUploadList(fileList);
return lngCustomer;
}
}