v1.0.9 #16

Merged
timi merged 12 commits from dev into master 2026-08-11 16:01:10 +00:00
7 changed files with 67 additions and 10 deletions
Showing only changes of commit 7ffdd715ee - Show all commits
@@ -100,7 +100,7 @@ public class GaoCustomerController {
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE) @RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
@PostMapping("/update") @PostMapping("/update")
public void update(@RequestBody GaoCustomer customer) { public void update(@RequestBody GaoCustomer customer) {
service.update(customer); service.updateWithAttachment(customer);
} }
@AOPLog @AOPLog
@@ -93,11 +93,24 @@ public class GaoEventRecordController {
@AOPLog @AOPLog
@RequestRateLimit @RequestRateLimit
@PostMapping("/create") @PostMapping("/create")
@JsonView(ResponseView.Public.class)
public void create(@RequestBody GaoEventRecord record) { public void create(@RequestBody GaoEventRecord record) {
service.create(record); service.create(record);
} }
@AOPLog
@RequestRateLimit
@PostMapping("/create/batch")
public void createBatch(@RequestBody List<GaoEventRecord> recordList) {
service.createBatch(recordList);
}
@AOPLog
@RequestRateLimit
@PostMapping("/create/customer")
public void createWithCustomer(@RequestBody GaoCustomer customer) {
service.createWithCustomer(customer);
}
@AOPLog @AOPLog
@RequestRateLimit @RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_UPDATE) @RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_UPDATE)
@@ -99,6 +99,9 @@ public class GaoCustomer extends UUIDEntity {
@Transient @Transient
private GaoEventRecord eventRecord; private GaoEventRecord eventRecord;
@Transient
private List<GaoEventRecord> eventRecordList;
public boolean hasIntroducer() { public boolean hasIntroducer() {
return TimiJava.isNotEmpty(introducerCustomerId); return TimiJava.isNotEmpty(introducerCustomerId);
} }
@@ -19,6 +19,8 @@ import java.util.stream.Collectors;
/// @since 2026-07-27 14:12 /// @since 2026-07-27 14:12
public interface GaoCustomerService extends BaseService<GaoCustomer, String> { public interface GaoCustomerService extends BaseService<GaoCustomer, String> {
void updateWithAttachment(GaoCustomer customer);
/// 按编码查询客户 /// 按编码查询客户
/// ///
/// @param code 客户编码 /// @param code 客户编码
@@ -1,13 +1,16 @@
package com.imyeyu.api.modules.gao.service; package com.imyeyu.api.modules.gao.service;
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
import com.imyeyu.api.modules.gao.entity.GaoEventRecord; import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView; import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage; import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage; import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage;
import com.imyeyu.java.TimiJava;
import com.imyeyu.spring.bean.PageResult; import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.service.BaseService; import com.imyeyu.spring.service.BaseService;
import java.io.IOException; import java.io.IOException;
import java.util.List;
/// 登记事件记录服务 /// 登记事件记录服务
/// ///
@@ -15,6 +18,14 @@ import java.io.IOException;
/// @since 2026-07-27 14:09 /// @since 2026-07-27 14:09
public interface GaoEventRecordService extends BaseService<GaoEventRecord, String> { public interface GaoEventRecordService extends BaseService<GaoEventRecord, String> {
default void createBatch(List<GaoEventRecord> recordList) {
for (GaoEventRecord record : TimiJava.safeIterable(recordList)) {
create(record);
}
}
void createWithCustomer(GaoCustomer customer);
/// 按任意时间范围查询登记事件记录 /// 按任意时间范围查询登记事件记录
/// ///
/// @param req 范围查询请求 /// @param req 范围查询请求
@@ -146,10 +146,8 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
dbCustomer.setRemark(customer.getRemark()); dbCustomer.setRemark(customer.getRemark());
dbCustomer.setDisease(customer.getDisease()); dbCustomer.setDisease(customer.getDisease());
dbCustomer.setConditioningPart(customer.getConditioningPart()); dbCustomer.setConditioningPart(customer.getConditioningPart());
mapper.update(dbCustomer); mapper.update(dbCustomer);
// 附件
attachmentService.updateByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId(), customer.getAttachmentList());
logger.setLevel(Logger.Level.INFO); logger.setLevel(Logger.Level.INFO);
logger.setResult(customer.getId()); logger.setResult(customer.getId());
} catch (TimiException e) { } catch (TimiException e) {
@@ -191,6 +189,12 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
} }
} }
@Override
public void updateWithAttachment(GaoCustomer customer) {
update(customer);
attachmentService.updateByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId(), customer.getAttachmentList());
}
@Override @Override
public GaoCustomer getByCode(String code) { public GaoCustomer getByCode(String code) {
TimiException.required(code, "not found code"); TimiException.required(code, "not found code");
@@ -5,6 +5,7 @@ import com.imyeyu.api.bean.ModuleCode;
import com.imyeyu.api.config.dbsource.TimiServerDBConfig; import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
import com.imyeyu.api.modules.common.entity.Attachment; import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.AttachmentService; import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
import com.imyeyu.api.modules.gao.entity.GaoEvent; import com.imyeyu.api.modules.gao.entity.GaoEvent;
import com.imyeyu.api.modules.gao.entity.GaoEventRecord; import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
import com.imyeyu.api.modules.gao.mapper.GaoEventRecordMapper; import com.imyeyu.api.modules.gao.mapper.GaoEventRecordMapper;
@@ -82,11 +83,6 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
checkEventPermission(event); checkEventPermission(event);
List<String> customerIdList = TimiJava.defaultIfEmpty(record.getCustomerIdList(), List.of(record.getCustomerId())); List<String> customerIdList = TimiJava.defaultIfEmpty(record.getCustomerIdList(), List.of(record.getCustomerId()));
if (TimiJava.isNotEmpty(record.getCustomer())) {
// 客户未创建,补录客户后登记
customerService.create(record.getCustomer());
customerIdList.add(record.getCustomer().getId());
}
TimiException.required(customerIdList, "not found customerId or empty customerIdList"); TimiException.required(customerIdList, "not found customerId or empty customerIdList");
GaoEventRecord firstRecord = null; GaoEventRecord firstRecord = null;
@@ -171,6 +167,34 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
} }
} }
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void createWithCustomer(GaoCustomer customer) {
TimiException.required(customer, "not found customer");
if (TimiJava.isNotEmpty(customer.getId())) {
// 有 ID 表示给已有客户绑定新编码;编码不能被其他客户占用
GaoCustomer dbCustomer = customerService.get(customer.getId());
TimiException.required(dbCustomer, "not found customer");
if (TimiJava.isNotEmpty(customer.getCode())) {
GaoCustomer byCode = customerService.getByCode(customer.getCode());
TimiException.requiredTrue(byCode == null || dbCustomer.getId().equals(byCode.getId()), "该编码客户已登记");
dbCustomer.setCode(customer.getCode());
customerService.update(dbCustomer);
}
customer.setId(dbCustomer.getId());
} else {
// 无 ID 表示新开客户档案;创建客户只强制姓名唯一,其余字段按请求透传
customerService.create(customer);
}
if (TimiJava.isEmpty(customer.getEventRecordList())) {
return;
}
for (GaoEventRecord record : TimiJava.safeIterable(customer.getEventRecordList())) {
record.setCustomerId(customer.getId());
}
createBatch(customer.getEventRecordList());
}
@Override @Override
public PageResult<GaoEventRecord> pageByRange(GaoEventRecordPage page) { public PageResult<GaoEventRecord> pageByRange(GaoEventRecordPage page) {
PageResult<GaoEventRecord> result = new PageResult<>(); PageResult<GaoEventRecord> result = new PageResult<>();