v1.0.12 #19
@@ -48,6 +48,9 @@ public class GaoStore extends UUIDEntity {
|
|||||||
/// 备注
|
/// 备注
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/// true 为启用自动计算营业日休息日
|
||||||
|
private Boolean autoClosedDay;
|
||||||
|
|
||||||
/// 排序值
|
/// 排序值
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class GaoStoreBusinessDay extends UUIDEntity {
|
|||||||
///
|
///
|
||||||
/// @author Codex
|
/// @author Codex
|
||||||
/// @since 2026-08-06
|
/// @since 2026-08-06
|
||||||
public enum OpenStatus {
|
public enum Status {
|
||||||
|
|
||||||
/// 营业
|
/// 营业
|
||||||
OPEN,
|
OPEN,
|
||||||
@@ -34,7 +34,7 @@ public class GaoStoreBusinessDay extends UUIDEntity {
|
|||||||
private Integer dateValue;
|
private Integer dateValue;
|
||||||
|
|
||||||
/// 营业状态
|
/// 营业状态
|
||||||
private OpenStatus openStatus;
|
private Status status;
|
||||||
|
|
||||||
/// 营业日递增序号,仅营业日有值
|
/// 营业日递增序号,仅营业日有值
|
||||||
private Long businessDayNo;
|
private Long businessDayNo;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.imyeyu.api.modules.gao.mapper;
|
|||||||
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,6 +17,12 @@ public interface GaoStoreMapper extends BaseMapper<GaoStore, String> {
|
|||||||
|
|
||||||
List<GaoStore> selectByIdList(@Param("idList") Collection<String> idList);
|
List<GaoStore> selectByIdList(@Param("idList") Collection<String> idList);
|
||||||
|
|
||||||
|
/// 查询启用自动计算营业日休息日的可用门店
|
||||||
|
///
|
||||||
|
/// @return 门店列表
|
||||||
|
@Select("SELECT * FROM `gao_store` WHERE `auto_closed_day` = TRUE AND `status` = 'ACTIVE' " + NOT_DELETE)
|
||||||
|
List<GaoStore> selectAllByAutoClosedDay();
|
||||||
|
|
||||||
/// 查询用户所属的可用门店
|
/// 查询用户所属的可用门店
|
||||||
///
|
///
|
||||||
/// @param userId 用户 ID
|
/// @param userId 用户 ID
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ public interface GaoStoreBusinessDayService extends BaseService<GaoStoreBusiness
|
|||||||
/// @param beginDateValue 开始日期值,格式为 yyyyMMdd
|
/// @param beginDateValue 开始日期值,格式为 yyyyMMdd
|
||||||
void rebuildBusinessDayNo(String storeId, Integer beginDateValue);
|
void rebuildBusinessDayNo(String storeId, Integer beginDateValue);
|
||||||
|
|
||||||
|
/// 自动补记门店休息日
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
/// @param dateValue 日期值,格式为 yyyyMMdd
|
||||||
|
void autoCloseBusinessDay(String storeId, Integer dateValue);
|
||||||
|
|
||||||
/// 查询日期范围内的营业日
|
/// 查询日期范围内的营业日
|
||||||
///
|
///
|
||||||
/// @param storeId 门店 ID
|
/// @param storeId 门店 ID
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ public interface GaoStoreService extends BaseService<GaoStore, String> {
|
|||||||
|
|
||||||
String getBelongIdByRequiredLoginUserId();
|
String getBelongIdByRequiredLoginUserId();
|
||||||
|
|
||||||
|
List<GaoStore> listByAutoClosedDay();
|
||||||
|
|
||||||
/// 导出门店列表
|
/// 导出门店列表
|
||||||
///
|
///
|
||||||
/// @param page 分页查询条件
|
/// @param page 分页查询条件
|
||||||
|
|||||||
+27
-7
@@ -37,7 +37,7 @@ public class GaoStoreBusinessDayServiceImplement extends AbstractEntityService<G
|
|||||||
public void create(GaoStoreBusinessDay businessDay) {
|
public void create(GaoStoreBusinessDay businessDay) {
|
||||||
prepareBusinessDay(businessDay);
|
prepareBusinessDay(businessDay);
|
||||||
super.create(businessDay);
|
super.create(businessDay);
|
||||||
if (businessDay.getOpenStatus() == GaoStoreBusinessDay.OpenStatus.OPEN) {
|
if (businessDay.getStatus() == GaoStoreBusinessDay.Status.OPEN) {
|
||||||
rebuildBusinessDayNo(businessDay.getStoreId(), businessDay.getDateValue());
|
rebuildBusinessDayNo(businessDay.getStoreId(), businessDay.getDateValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ public class GaoStoreBusinessDayServiceImplement extends AbstractEntityService<G
|
|||||||
TimiException.required(dbBusinessDay, "not found dbBusinessDay");
|
TimiException.required(dbBusinessDay, "not found dbBusinessDay");
|
||||||
TimiException.requiredTrue(dbBusinessDay.getStoreId().equals(businessDay.getStoreId()), "businessDay.storeId invalid");
|
TimiException.requiredTrue(dbBusinessDay.getStoreId().equals(businessDay.getStoreId()), "businessDay.storeId invalid");
|
||||||
TimiException.requiredTrue(dbBusinessDay.getDateValue().equals(businessDay.getDateValue()), "businessDay.dateValue invalid");
|
TimiException.requiredTrue(dbBusinessDay.getDateValue().equals(businessDay.getDateValue()), "businessDay.dateValue invalid");
|
||||||
if (businessDay.getOpenStatus() == GaoStoreBusinessDay.OpenStatus.CLOSED) {
|
if (businessDay.getStatus() == GaoStoreBusinessDay.Status.CLOSED) {
|
||||||
checkNoRecord(dbBusinessDay);
|
checkNoRecord(dbBusinessDay);
|
||||||
}
|
}
|
||||||
prepareBusinessDay(businessDay);
|
prepareBusinessDay(businessDay);
|
||||||
@@ -64,7 +64,7 @@ public class GaoStoreBusinessDayServiceImplement extends AbstractEntityService<G
|
|||||||
public void delete(String id) {
|
public void delete(String id) {
|
||||||
GaoStoreBusinessDay businessDay = get(id);
|
GaoStoreBusinessDay businessDay = get(id);
|
||||||
TimiException.required(businessDay, "not found businessDay");
|
TimiException.required(businessDay, "not found businessDay");
|
||||||
if (businessDay.getOpenStatus() == GaoStoreBusinessDay.OpenStatus.OPEN) {
|
if (businessDay.getStatus() == GaoStoreBusinessDay.Status.OPEN) {
|
||||||
checkNoRecord(businessDay);
|
checkNoRecord(businessDay);
|
||||||
}
|
}
|
||||||
super.delete(id);
|
super.delete(id);
|
||||||
@@ -78,14 +78,14 @@ public class GaoStoreBusinessDayServiceImplement extends AbstractEntityService<G
|
|||||||
TimiException.required(dateValue, "not found dateValue");
|
TimiException.required(dateValue, "not found dateValue");
|
||||||
GaoStoreBusinessDay businessDay = mapper.selectByStoreIdAndDateValue(storeId, dateValue);
|
GaoStoreBusinessDay businessDay = mapper.selectByStoreIdAndDateValue(storeId, dateValue);
|
||||||
if (businessDay != null) {
|
if (businessDay != null) {
|
||||||
TimiException.requiredTrue(businessDay.getOpenStatus() == GaoStoreBusinessDay.OpenStatus.OPEN, "门店当日休息,不能登记");
|
TimiException.requiredTrue(businessDay.getStatus() == GaoStoreBusinessDay.Status.OPEN, "门店当日休息,不能登记");
|
||||||
TimiException.required(businessDay.getBusinessDayNo(), "not found businessDay.businessDayNo");
|
TimiException.required(businessDay.getBusinessDayNo(), "not found businessDay.businessDayNo");
|
||||||
return businessDay;
|
return businessDay;
|
||||||
}
|
}
|
||||||
businessDay = new GaoStoreBusinessDay();
|
businessDay = new GaoStoreBusinessDay();
|
||||||
businessDay.setStoreId(storeId);
|
businessDay.setStoreId(storeId);
|
||||||
businessDay.setDateValue(dateValue);
|
businessDay.setDateValue(dateValue);
|
||||||
businessDay.setOpenStatus(GaoStoreBusinessDay.OpenStatus.OPEN);
|
businessDay.setStatus(GaoStoreBusinessDay.Status.OPEN);
|
||||||
super.create(businessDay);
|
super.create(businessDay);
|
||||||
rebuildBusinessDayNo(storeId, dateValue);
|
rebuildBusinessDayNo(storeId, dateValue);
|
||||||
return mapper.selectByStoreIdAndDateValue(storeId, dateValue);
|
return mapper.selectByStoreIdAndDateValue(storeId, dateValue);
|
||||||
@@ -107,6 +107,26 @@ public class GaoStoreBusinessDayServiceImplement extends AbstractEntityService<G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void autoCloseBusinessDay(String storeId, Integer dateValue) {
|
||||||
|
TimiException.required(storeId, "not found storeId");
|
||||||
|
TimiException.required(dateValue, "not found dateValue");
|
||||||
|
if (mapper.selectByStoreIdAndDateValue(storeId, dateValue) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Long count = eventRecordMapper.countByStoreIdAndRegisteredDateValue(storeId, dateValue);
|
||||||
|
if (0 < TimiJava.defaultIfNull(count, 0L)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GaoStoreBusinessDay businessDay = new GaoStoreBusinessDay();
|
||||||
|
businessDay.setStoreId(storeId);
|
||||||
|
businessDay.setDateValue(dateValue);
|
||||||
|
businessDay.setStatus(GaoStoreBusinessDay.Status.CLOSED);
|
||||||
|
businessDay.setReason("系统自动判定休息");
|
||||||
|
super.create(businessDay);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GaoStoreBusinessDay> listByDateRange(String storeId, Integer beginDateValue, Integer endDateValue) {
|
public List<GaoStoreBusinessDay> listByDateRange(String storeId, Integer beginDateValue, Integer endDateValue) {
|
||||||
TimiException.required(storeId, "not found storeId");
|
TimiException.required(storeId, "not found storeId");
|
||||||
@@ -120,8 +140,8 @@ public class GaoStoreBusinessDayServiceImplement extends AbstractEntityService<G
|
|||||||
TimiException.required(businessDay, "not found businessDay");
|
TimiException.required(businessDay, "not found businessDay");
|
||||||
TimiException.required(businessDay.getStoreId(), "not found businessDay.storeId");
|
TimiException.required(businessDay.getStoreId(), "not found businessDay.storeId");
|
||||||
TimiException.required(businessDay.getDateValue(), "not found businessDay.dateValue");
|
TimiException.required(businessDay.getDateValue(), "not found businessDay.dateValue");
|
||||||
businessDay.setOpenStatus(TimiJava.defaultIfNull(businessDay.getOpenStatus(), GaoStoreBusinessDay.OpenStatus.OPEN));
|
businessDay.setStatus(TimiJava.defaultIfNull(businessDay.getStatus(), GaoStoreBusinessDay.Status.OPEN));
|
||||||
if (businessDay.getOpenStatus() == GaoStoreBusinessDay.OpenStatus.CLOSED) {
|
if (businessDay.getStatus() == GaoStoreBusinessDay.Status.CLOSED) {
|
||||||
businessDay.setBusinessDayNo(null);
|
businessDay.setBusinessDayNo(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -62,6 +62,7 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
logger.setContent(jackson.writeValueAsString(store));
|
logger.setContent(jackson.writeValueAsString(store));
|
||||||
checkUnique(store);
|
checkUnique(store);
|
||||||
store.setStatus(TimiJava.defaultIfNull(store.getStatus(), GaoStore.Status.ACTIVE));
|
store.setStatus(TimiJava.defaultIfNull(store.getStatus(), GaoStore.Status.ACTIVE));
|
||||||
|
store.setAutoClosedDay(TimiJava.defaultIfNull(store.getAutoClosedDay(), false));
|
||||||
store.setSort(TimiJava.defaultIfNull(store.getSort(), 0));
|
store.setSort(TimiJava.defaultIfNull(store.getSort(), 0));
|
||||||
super.create(store);
|
super.create(store);
|
||||||
logger.setLevel(Logger.Level.INFO);
|
logger.setLevel(Logger.Level.INFO);
|
||||||
@@ -99,6 +100,7 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
dbStore.setTelephone(store.getTelephone());
|
dbStore.setTelephone(store.getTelephone());
|
||||||
dbStore.setAddress(store.getAddress());
|
dbStore.setAddress(store.getAddress());
|
||||||
dbStore.setRemark(store.getRemark());
|
dbStore.setRemark(store.getRemark());
|
||||||
|
dbStore.setAutoClosedDay(TimiJava.defaultIfNull(store.getAutoClosedDay(), false));
|
||||||
super.update(dbStore);
|
super.update(dbStore);
|
||||||
logger.setLevel(Logger.Level.INFO);
|
logger.setLevel(Logger.Level.INFO);
|
||||||
logger.setResult(store.getId());
|
logger.setResult(store.getId());
|
||||||
@@ -153,6 +155,11 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
return getByUserId(userLoginService.getRequireLoginUserId()).getId();
|
return getByUserId(userLoginService.getRequireLoginUserId()).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GaoStore> listByAutoClosedDay() {
|
||||||
|
return mapper.selectAllByAutoClosedDay();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] export(Page<GaoStore> page) throws IOException {
|
public byte[] export(Page<GaoStore> page) throws IOException {
|
||||||
page.setIndex(0);
|
page.setIndex(0);
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.task;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreBusinessDayService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// GAO 门店营业日自动休息任务
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-12
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GaoStoreAutoCloseDayTask {
|
||||||
|
|
||||||
|
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
|
||||||
|
private final GaoStoreService storeService;
|
||||||
|
private final GaoStoreBusinessDayService businessDayService;
|
||||||
|
|
||||||
|
/// 每天零点后自动补记前一天无登记门店的休息日
|
||||||
|
@Scheduled(cron = "0 1 0 * * ?")
|
||||||
|
public void run() {
|
||||||
|
int dateValue = Integer.parseInt(DAY_FORMATTER.format(LocalDate.now().minusDays(1)));
|
||||||
|
List<GaoStore> storeList = storeService.listByAutoClosedDay();
|
||||||
|
for (GaoStore store : storeList) {
|
||||||
|
try {
|
||||||
|
businessDayService.autoCloseBusinessDay(store.getId(), dateValue);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("自动补记 GAO 门店休息日失败: storeId[{}], dateValue[{}]", store.getId(), dateValue, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ public class StoreXSSFBuilder extends BaseXSSFBuilder<GaoStore> {
|
|||||||
appendRow(sheet, 0, titleStyle, "门店列表导出");
|
appendRow(sheet, 0, titleStyle, "门店列表导出");
|
||||||
appendRow(sheet, 1, null, "生成时间", Time.nowString());
|
appendRow(sheet, 1, null, "生成时间", Time.nowString());
|
||||||
appendRow(sheet, 2, null, "记录总数", String.valueOf(list.size()));
|
appendRow(sheet, 2, null, "记录总数", String.valueOf(list.size()));
|
||||||
appendRow(sheet, 3, headerStyle, "门店编码", "门店名称", "状态", "电话", "地址", "备注", "排序", "创建时间");
|
appendRow(sheet, 3, headerStyle, "门店编码", "门店名称", "状态", "电话", "地址", "备注", "自动计算休息日", "排序", "创建时间");
|
||||||
int rowIndex = 4;
|
int rowIndex = 4;
|
||||||
for (GaoStore store : list) {
|
for (GaoStore store : list) {
|
||||||
appendRow(sheet, rowIndex, null,
|
appendRow(sheet, rowIndex, null,
|
||||||
@@ -45,12 +45,13 @@ public class StoreXSSFBuilder extends BaseXSSFBuilder<GaoStore> {
|
|||||||
text(store.getTelephone()),
|
text(store.getTelephone()),
|
||||||
text(store.getAddress()),
|
text(store.getAddress()),
|
||||||
text(store.getRemark()),
|
text(store.getRemark()),
|
||||||
|
Boolean.TRUE.equals(store.getAutoClosedDay()) ? "是" : "否",
|
||||||
store.getSort() == null ? "" : String.valueOf(store.getSort()),
|
store.getSort() == null ? "" : String.valueOf(store.getSort()),
|
||||||
Time.toDateTime(store.getCreatedAt())
|
Time.toDateTime(store.getCreatedAt())
|
||||||
);
|
);
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
}
|
}
|
||||||
for (int index = 0; index < 8; index++) {
|
for (int index = 0; index < 9; index++) {
|
||||||
sheet.autoSizeColumn(index);
|
sheet.autoSizeColumn(index);
|
||||||
sheet.setColumnWidth(index, Math.clamp(sheet.getColumnWidth(index), 10 * 256, 36 * 256));
|
sheet.setColumnWidth(index, Math.clamp(sheet.getColumnWidth(index), 10 * 256, 36 * 256));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE `gao_store`
|
||||||
|
ADD COLUMN `auto_closed_day` BOOLEAN NOT NULL DEFAULT FALSE COMMENT 'true 为启用自动计算休息日' AFTER `remark`;
|
||||||
|
ALTER TABLE `gao_store_business_day`
|
||||||
|
RENAME COLUMN `open_status` TO `status`;
|
||||||
Reference in New Issue
Block a user