|
|
|
|
@ -2,11 +2,14 @@ package org.springblade.modules.business.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import org.apache.ibatis.annotations.Param; |
|
|
|
|
import org.beetl.core.util.ArrayMap; |
|
|
|
|
import org.springblade.common.cache.DeptCache; |
|
|
|
|
import org.springblade.common.cache.DictBizCache; |
|
|
|
|
import org.springblade.common.constant.BusinessConstant; |
|
|
|
|
import org.springblade.common.constant.CommonConstant; |
|
|
|
|
import org.springblade.common.utils.CommonDateUtil; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
@ -23,6 +26,7 @@ import org.springblade.modules.business.service.IApmConfigService; |
|
|
|
|
import org.springblade.modules.business.service.IApmRecordService; |
|
|
|
|
import org.springblade.modules.business.vo.ApmConfigListVO; |
|
|
|
|
import org.springblade.modules.business.wrapper.ApmConfigListWrapper; |
|
|
|
|
import org.springblade.modules.system.entity.Dept; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
@ -31,12 +35,14 @@ import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 服务实现类 |
|
|
|
|
* <p> |
|
|
|
|
* BaseServiceImpl中的存储对象方法会自动更新bean中的公共字段, 如create_time, update_time等 |
|
|
|
|
* |
|
|
|
|
* @author Chill |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
public class ApmConfigServiceImpl extends BaseServiceImpl<ApmConfigMapper, ApmConfig> implements IApmConfigService { |
|
|
|
|
public class ApmConfigServiceImpl extends ServiceImpl<ApmConfigMapper, ApmConfig> implements IApmConfigService { |
|
|
|
|
|
|
|
|
|
private final IApmRecordService recordService; |
|
|
|
|
|
|
|
|
|
@ -73,11 +79,13 @@ public class ApmConfigServiceImpl extends BaseServiceImpl<ApmConfigMapper, ApmCo |
|
|
|
|
@Override |
|
|
|
|
public IPage<ApmConfigListVO> selectPage(IPage<ApmConfig> page, Long createDept, String startTime, String endTime, String project) { |
|
|
|
|
// 由于每个时段保存了一条记录, 故分页时, 先使用distinct查询(医院, 项目 配置天)进行分页
|
|
|
|
|
List<ApmConfig> pageRecord = baseMapper.selectConfigPage(page, createDept, startTime, endTime, project); |
|
|
|
|
page.setRecords(pageRecord); |
|
|
|
|
IPage<ApmConfig> pageRecord = baseMapper.selectConfigPage(page, createDept, startTime, endTime, project); |
|
|
|
|
|
|
|
|
|
IPage<ApmConfigListVO> result = ApmConfigListWrapper.build().pageVO(page); |
|
|
|
|
IPage<ApmConfigListVO> result = ApmConfigListWrapper.build().pageVO(pageRecord); |
|
|
|
|
result.getRecords().forEach(vo -> { |
|
|
|
|
Dept hospital = DeptCache.getDept(vo.getCreateDept()); |
|
|
|
|
vo.setCreateDeptName(Func.isNotEmpty(hospital) ? hospital.getDeptName() : ""); |
|
|
|
|
|
|
|
|
|
// 根据(医院, 项目 配置天)获取配置详细
|
|
|
|
|
List<ApmConfig> configList = baseMapper.selectConfigList(vo.getCreateDept(), DateUtil.format(vo.getApmDay(), DateUtil.PATTERN_DATETIME), vo.getProject()); |
|
|
|
|
|
|
|
|
|
@ -201,6 +209,7 @@ public class ApmConfigServiceImpl extends BaseServiceImpl<ApmConfigMapper, ApmCo |
|
|
|
|
Integer numberNum = detail.containsKey(BusinessConstant.MAP_KEY_APM_CONFIG_LIST_NUMBER_NUM) ? (Integer) detail.get(BusinessConstant.MAP_KEY_APM_CONFIG_LIST_NUMBER_NUM) : 0; |
|
|
|
|
|
|
|
|
|
ApmConfig config = BeanUtil.copy(vo, ApmConfig.class); |
|
|
|
|
config.setCreateDept(createDept); |
|
|
|
|
config.setApmDay(configApmDay); |
|
|
|
|
config.setPeriod(period); |
|
|
|
|
config.setTimeFrame(timeFrame); |
|
|
|
|
@ -235,14 +244,18 @@ public class ApmConfigServiceImpl extends BaseServiceImpl<ApmConfigMapper, ApmCo |
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
for (ApmConfig config : configList) { |
|
|
|
|
String key = config.getProject() + config.getApmDay() + config.getProject() + config.getTimeFrame(); |
|
|
|
|
String key = config.getProject() + DateUtil.format(config.getApmDay(), DateUtil.PATTERN_DATE) + config.getProject() + config.getTimeFrame(); |
|
|
|
|
|
|
|
|
|
if (Func.isEmpty(config.getNumberNum()) || config.getNumberNum() <= 0) { |
|
|
|
|
return "保存失败, 放号数量必须大于0"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 若此次修改的放号没有对应的放号配置或已预约统计为0, 验证通过
|
|
|
|
|
if (alreadyConfMap.containsKey(key) || alreadyConfCountMap.containsKey(key)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (config.getNumberNum() < alreadyConfCountMap.get(key)) { |
|
|
|
|
if (alreadyConfCountMap.containsKey(key) && config.getNumberNum() < alreadyConfCountMap.get(key)) { |
|
|
|
|
return "保存失败, 放号数量不能低于已预约的数量"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -266,6 +279,12 @@ public class ApmConfigServiceImpl extends BaseServiceImpl<ApmConfigMapper, ApmCo |
|
|
|
|
Integer numberNum = detail.containsKey(BusinessConstant.MAP_KEY_APM_CONFIG_LIST_NUMBER_NUM) ? (Integer) detail.get(BusinessConstant.MAP_KEY_APM_CONFIG_LIST_NUMBER_NUM) : 0; |
|
|
|
|
|
|
|
|
|
ApmConfig config = BeanUtil.copy(vo, ApmConfig.class); |
|
|
|
|
config.setCreateDept(createDept); |
|
|
|
|
config.setCreateUser(AuthUtil.getUserId()); |
|
|
|
|
config.setCreateTime(DateUtil.now()); |
|
|
|
|
config.setUpdateUser(AuthUtil.getUserId()); |
|
|
|
|
config.setUpdateTime(DateUtil.now()); |
|
|
|
|
config.setStatus(BusinessConstant.BOOLEAN_INT_TRUE); |
|
|
|
|
config.setApmDay(DateUtil.parse(day, DateUtil.PATTERN_DATE)); |
|
|
|
|
config.setPeriod(period); |
|
|
|
|
config.setTimeFrame(timeFrame); |
|
|
|
|
|