This commit is contained in:
2025-12-02 10:21:51 +08:00
9 changed files with 146 additions and 49 deletions

View File

@ -96,6 +96,14 @@ public class UpdateLngCustomerDocDto implements Serializable {
@ApiModelProperty("租户id")
private Long tenantId;
private String filePath;
/**
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
@LogJoin(name = "lngFileUpload子表",
columns = {
@LogJoinColumn(field = "tableId",relatedField = "id", valueDirection = ValueDirectionType.RIGHT)
},
caseType = JoinCaseType.FULL, target = UpdateLngFileUploadDto.class, type = JoinType.MANY)
private List<UpdateLngFileUploadDto> fileList;
}

View File

@ -122,7 +122,11 @@ public class LngCustomerDocVo {
private Long ruleUserId;
/**
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
private List<LngFileUploadVo> fileList;
}

View File

@ -1,5 +1,8 @@
package com.xjrsoft.module.sales.vo;
import com.xjrsoft.common.annotation.Trans;
import com.xjrsoft.common.enums.TransType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -41,26 +44,34 @@ public class LngCustomerPageVo {
* 企业性质(国有企业/非国有企业)
*/
@ApiModelProperty("企业性质(国有企业/非国有企业)")
@Trans(type = TransType.DIC, id = "1990667133987635201")
private String natureCode;
/**
* 客户分类(一类/二类)
*/
@ApiModelProperty("客户分类(一类/二类)")
@Trans(type = TransType.DIC, id = "1990668094164484097")
private String classCode;
/**
* 客户类别(电厂/工业用户/城燃/贸易商)
*/
@ApiModelProperty("客户类别(电厂/工业用户/城燃/贸易商)")
@Trans(type = TransType.DIC, id = "1990668471983194113")
private String typeCode;
/**
* 有效标志(不在黑名单)(Y-有效N-无效)
*/
@ApiModelProperty("有效标志(不在黑名单)(Y-有效N-无效)")
@Trans(type = TransType.DIC, id = "1978057078528327681")
private String valid;
/**
* 状态(未提交/审批中/已审批/已驳回)
*/
@ApiModelProperty("状态(未提交/审批中/已审批/已驳回)")
@Trans(type = TransType.DIC, id = "1990669393069129729", transToFieldName = "approName")
private String approCode;
@ApiModelProperty("状态(未提交/审批中/已审批/已驳回)")
private String approName;
}

View File

@ -8,6 +8,8 @@ import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
/**
* @title: 表单出参
* @Author 管理员
@ -129,7 +131,8 @@ public class LngFileUploadVo {
private Long ruleUserId;
@ApiModelProperty("")
private String presignedUrl;
}

View File

@ -15,6 +15,7 @@ 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.utils.StringUtils;
import com.xjrsoft.common.model.result.R;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
@ -85,7 +86,7 @@ public class CustomerController {
@ApiOperation(value="根据id查询LngCustomer信息")
@SaCheckPermission("customer:detail")
public R info(@RequestParam Long id){
LngCustomer lngCustomer = customerService.getByIdDeep(id);
LngCustomer lngCustomer = customerService.getCustomerById(id);
if (lngCustomer == null) {
return R.error("找不到此数据!");
}
@ -107,9 +108,10 @@ public class CustomerController {
public R add(@Valid @RequestBody UpdateLngCustomerDto dto){
String code = codeRuleClient.genEncode(CUSTOMER_CODE);
dto.setCuCode("C"+code);
customerService.add(dto);
Long id = customerService.add(dto);
dto.setId(id);
codeRuleClient.useEncode(CUSTOMER_CODE);
return R.ok();
return R.ok(dto);
/**
return R.ok(dataService.insert(dto,new DataOperationListener<UpdateLngCustomerDto>() {
@ -138,7 +140,6 @@ public class CustomerController {
@ApiOperation(value = "修改LngCustomer")
@SaCheckPermission("customer:edit")
public R update(@Valid @RequestBody UpdateLngCustomerDto dto){
// return R.ok(dataService.updateById(dto));
customerService.update(dto);
return R.ok();
}

View File

@ -1,20 +1,24 @@
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.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
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;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
/**
@ -127,6 +131,18 @@ 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

@ -133,6 +133,8 @@ public class LngFileUpload implements Serializable {
@TableField(fill = FieldFill.INSERT)
private Long ruleUserId;
@ApiModelProperty("")
@TableField(exist = false)
private String presignedUrl;
}

View File

@ -24,7 +24,7 @@ public interface ICustomerService extends MPJBaseService<LngCustomer>, MPJDeepSe
* @return
*/
Boolean add(UpdateLngCustomerDto updateLngCustomerDto);
Long add(UpdateLngCustomerDto updateLngCustomerDto);
/**
* 更新
@ -42,4 +42,6 @@ public interface ICustomerService extends MPJBaseService<LngCustomer>, MPJDeepSe
*/
Boolean delete(List<Long> ids);
LngCustomer getCustomerById(Long id);
}

View File

@ -12,6 +12,8 @@ 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;
@ -24,9 +26,13 @@ import com.xjrsoft.module.sales.mapper.LngFileUploadMapper;
import com.xjrsoft.module.sales.service.ICustomerService;
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;
@ -52,7 +58,7 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean add(UpdateLngCustomerDto updateLngCustomerDto) {
public Long add(UpdateLngCustomerDto updateLngCustomerDto) {
LngCustomer lngCustomer = new LngCustomer();
BeanUtil.copyProperties(updateLngCustomerDto, lngCustomer);
@ -75,21 +81,25 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
lngCustomerDoc.setCuCode(lngCustomer.getCuCode());
lngCustomerDocMapper.insert(lngCustomerDoc);
if(StringUtils.isNotEmpty(updateLngCustomerDocDto.getFilePath())) {
if(CollectionUtil.isNotEmpty(updateLngCustomerDocDto.getFileList())) {
for(UpdateLngFileUploadDto lngFileUploadDto:updateLngCustomerDocDto.getFileList()) {
LngFileUpload lngFileUpload = new LngFileUpload();
lngFileUpload.setFilePath(updateLngCustomerDocDto.getFilePath());
BeanUtil.copyProperties(lngFileUploadDto, lngFileUpload);
lngFileUpload.setTableName("lng_customer_doc");
lngFileUpload.setTableId(lngCustomer.getId());
lngFileUpload.setTableId(lngCustomerDoc.getId());
lngFileUploadMapper.insert(lngFileUpload);
}
}
}
for (UpdateLngCustomerContactDto updateLngCustomerContactDto : updateLngCustomerDto.getLngCustomerContactList()) {
LngCustomerContact lngCustomerContact = new LngCustomerContact();
BeanUtil.copyProperties(updateLngCustomerContactDto, lngCustomerContact);
lngCustomerContact.setCuCode(lngCustomer.getCuCode());
lngCustomerContactMapper.insert(lngCustomerContact);
}
if(updateLngCustomerDto.getLngFileUploadList() != null) {
for (UpdateLngFileUploadDto lngFileUploadDto : updateLngCustomerDto.getLngFileUploadList()) {
LngFileUpload lngFileUpload = new LngFileUpload();
BeanUtil.copyProperties(lngFileUploadDto, lngFileUpload);
@ -97,7 +107,9 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
lngFileUpload.setTableId(lngCustomer.getId());
lngFileUploadMapper.insert(lngFileUpload);
}
return true;
}
return lngCustomer.getId();
}
@Override
@ -194,13 +206,16 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
lngCustomerDoc.setCuCode(lngCustomer.getCuCode());
lngCustomerDocMapper.insert(lngCustomerDoc);
}
if(StringUtils.isNotEmpty(lngCustomerDocDto.getFilePath())) {
if(CollectionUtil.isNotEmpty(lngCustomerDocDto.getFileList())) {
for(UpdateLngFileUploadDto lngFileUploadDto:lngCustomerDocDto.getFileList()) {
LngFileUpload lngFileUpload = new LngFileUpload();
lngFileUpload.setFilePath(lngCustomerDocDto.getFilePath());
BeanUtil.copyProperties(lngFileUploadDto, lngFileUpload);
lngFileUpload.setTableName("lng_customer_doc");
lngFileUpload.setTableId(lngCustomerDoc.getId());
lngFileUploadMapper.insert(lngFileUpload);
}
}
}
//已经不存在的id 删除
if(lngCustomerDocRemoveIds.size() > 0){
@ -278,12 +293,47 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean delete(List<Long> ids) {
List<LngCustomer> customerList = lngCustomerMapper.selectList(Wrappers.lambdaQuery(LngCustomer.class).in(LngCustomer::getId, ids));
List<String> cuCodeList = customerList.stream().map(LngCustomer::getCuCode).filter(Objects::nonNull).collect(Collectors.toList());
lngCustomerMapper.deleteBatchIds(ids);
lngCustomerAttrPowerMapper.delete(Wrappers.lambdaQuery(LngCustomerAttrPower.class).in(LngCustomerAttrPower::getCuCode, ids));
lngCustomerBankMapper.delete(Wrappers.lambdaQuery(LngCustomerBank.class).in(LngCustomerBank::getCuCode, ids));
lngCustomerDocMapper.delete(Wrappers.lambdaQuery(LngCustomerDoc.class).in(LngCustomerDoc::getCuCode, ids));
lngCustomerContactMapper.delete(Wrappers.lambdaQuery(LngCustomerContact.class).in(LngCustomerContact::getCuCode, ids));
lngFileUploadMapper.delete(Wrappers.lambdaQuery(LngFileUpload.class).in(LngFileUpload::getTableId, ids));
if(CollectionUtil.isNotEmpty(cuCodeList)) {
lngCustomerAttrPowerMapper.delete(Wrappers.lambdaQuery(LngCustomerAttrPower.class).in(LngCustomerAttrPower::getCuCode, cuCodeList));
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"));
}
return true;
}
@Override
public LngCustomer getCustomerById(Long id) {
LngCustomer lngCustomer = this.getByIdDeep(id);
if(lngCustomer == null) {
return null;
}
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> 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;
}
}