| | |
| | | package com.doumee.service.system.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.admin.request.*; |
| | | import com.doumee.dao.system.SystemDictMapper; |
| | | import com.doumee.dao.system.model.SystemDict; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.doumee.core.model.PageData; |
| | |
| | | import com.doumee.service.system.SystemDictDataService; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static net.sf.jsqlparser.parser.feature.Feature.set; |
| | | import static net.sf.jsqlparser.parser.feature.Feature.update; |
| | | |
| | | /** |
| | | * 字典数据Service实现 |
| | |
| | | @Autowired |
| | | private SystemDictDataMapper systemDictDataMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictMapper systemDictMapper; |
| | | @Override |
| | | public Integer create(SystemDictData systemDictData) { |
| | | systemDictDataMapper.insert(systemDictData); |
| | |
| | | Wrapper<SystemDictData> wrapper = new QueryWrapper<>(systemDictData); |
| | | return systemDictDataMapper.selectList(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public PageData<SystemDictDataListVO> findPage(PageWrap<QuerySystemDictDataDTO> pageWrap) { |
| | | PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity()); |
| | |
| | | .in(SystemDictData::getLabel,codes); |
| | | return systemDictDataMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public VisitConfigDTO getVisitConfigDTO() { |
| | | VisitConfigDTO visitConfigDTO = new VisitConfigDTO(); |
| | | SystemDict systemDict = systemDictMapper.selectOne(new QueryWrapper<SystemDict>().lambda().eq(SystemDict::getCode,Constants.SYSTEM)); |
| | | if(Objects.isNull(systemDict)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典类不存在"); |
| | | } |
| | | List<SystemDictData> systemDictList = systemDictDataMapper.selectList( |
| | | new QueryWrapper<SystemDictData>().lambda().eq(SystemDictData::getDictId,systemDict.getId())); |
| | | if(!com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(systemDictList)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典不存在"); |
| | | } |
| | | SystemDictData reservationWay = systemDictList.stream().filter(m->m.getLabel().equals(Constants.MDJ_VISIT_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(reservationWay)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客来访预约方式 字典不存在"); |
| | | } |
| | | visitConfigDTO.setReservationWay(Integer.valueOf(reservationWay.getCode())); |
| | | |
| | | SystemDictData checkVisit = systemDictList.stream().filter(m->m.getLabel().equals(Constants.BEVISITED_USER_VALID)).findFirst().get(); |
| | | if(Objects.isNull(checkVisit)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客被访人校验方式 字典不存在"); |
| | | } |
| | | visitConfigDTO.setCheckVisit(Integer.valueOf(checkVisit.getCode())); |
| | | SystemDictData healthCard = systemDictList.stream().filter(m->m.getLabel().equals(Constants.HEALTH_CARD)).findFirst().get(); |
| | | if(Objects.isNull(healthCard)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客健康证是否必填 字典不存在"); |
| | | } |
| | | visitConfigDTO.setHealthCard(Integer.valueOf(healthCard.getCode())); |
| | | SystemDictData isAnswer = systemDictList.stream().filter(m->m.getLabel().equals(Constants.PROBLEM_VISIT_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(isAnswer)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客是否需要答题 字典不存在"); |
| | | } |
| | | visitConfigDTO.setIsAnswer(Integer.valueOf(isAnswer.getCode())); |
| | | SystemDictData theme = systemDictList.stream().filter(m->m.getLabel().equals(Constants.THEME)).findFirst().get(); |
| | | if(Objects.isNull(theme)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客答题主题 字典不存在"); |
| | | } |
| | | visitConfigDTO.setTheme(theme.getCode()); |
| | | |
| | | SystemDictData description = systemDictList.stream().filter(m->m.getLabel().equals(Constants.DESCRIPTION)).findFirst().get(); |
| | | if(Objects.isNull(description)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客答题说明 字典不存在"); |
| | | } |
| | | visitConfigDTO.setDescription(description.getCode()); |
| | | |
| | | SystemDictData visitNotice = systemDictList.stream().filter(m->m.getLabel().equals(Constants.VISIT_NOTICE)).findFirst().get(); |
| | | if(Objects.isNull(visitNotice)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"入厂须知 字典不存在"); |
| | | } |
| | | visitConfigDTO.setVisitNotice(visitNotice.getCode()); |
| | | SystemDictData doorsVisitRequired = systemDictList.stream().filter(m->m.getLabel().equals(Constants.SELECT_DOORS_VISIT_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(doorsVisitRequired)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"自选门禁配置 字典不存在"); |
| | | } |
| | | visitConfigDTO.setDoorsVisitRequired(Integer.valueOf(doorsVisitRequired.getCode())); |
| | | return visitConfigDTO; |
| | | } |
| | | |
| | | @Override |
| | | public void updateVisitConfig(VisitConfigDTO visitConfigDTO) { |
| | | if(Objects.isNull(visitConfigDTO) |
| | | ||Objects.isNull(visitConfigDTO.getReservationWay()) |
| | | ||Objects.isNull(visitConfigDTO.getCheckVisit()) |
| | | ||Objects.isNull(visitConfigDTO.getHealthCard()) |
| | | ||Objects.isNull(visitConfigDTO.getIsAnswer()) |
| | | || StringUtils.isEmpty(visitConfigDTO.getTheme()) |
| | | || StringUtils.isEmpty(visitConfigDTO.getDescription()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | SystemDict systemDict = systemDictMapper.selectOne(new QueryWrapper<SystemDict>().lambda().eq(SystemDict::getCode,Constants.SYSTEM)); |
| | | if(Objects.isNull(systemDict)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典类不存在"); |
| | | } |
| | | List<SystemDictData> systemDictList = systemDictDataMapper.selectList( |
| | | new QueryWrapper<SystemDictData>().lambda().eq(SystemDictData::getDictId,systemDict.getId())); |
| | | if(!com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(systemDictList)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典不存在"); |
| | | } |
| | | |
| | | SystemDictData reservationWay = systemDictList.stream().filter(m->m.getLabel().equals(Constants.MDJ_VISIT_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(reservationWay)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客来访预约方式 字典不存在"); |
| | | } |
| | | reservationWay.setCode(visitConfigDTO.getReservationWay().toString()); |
| | | |
| | | SystemDictData checkVisit = systemDictList.stream().filter(m->m.getLabel().equals(Constants.BEVISITED_USER_VALID)).findFirst().get(); |
| | | if(Objects.isNull(checkVisit)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客被访人校验方式 字典不存在"); |
| | | } |
| | | checkVisit.setCode(visitConfigDTO.getCheckVisit().toString()); |
| | | SystemDictData healthCard = systemDictList.stream().filter(m->m.getLabel().equals(Constants.HEALTH_CARD)).findFirst().get(); |
| | | if(Objects.isNull(healthCard)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客健康证是否必填 字典不存在"); |
| | | } |
| | | healthCard.setCode(visitConfigDTO.getHealthCard().toString()); |
| | | SystemDictData isAnswer = systemDictList.stream().filter(m->m.getLabel().equals(Constants.PROBLEM_VISIT_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(isAnswer)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客是否需要答题 字典不存在"); |
| | | } |
| | | isAnswer.setCode(visitConfigDTO.getIsAnswer().toString()); |
| | | SystemDictData theme = systemDictList.stream().filter(m->m.getLabel().equals(Constants.THEME)).findFirst().get(); |
| | | if(Objects.isNull(theme)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客答题主题 字典不存在"); |
| | | } |
| | | theme.setCode(visitConfigDTO.getTheme()); |
| | | |
| | | SystemDictData description = systemDictList.stream().filter(m->m.getLabel().equals(Constants.DESCRIPTION)).findFirst().get(); |
| | | if(Objects.isNull(description)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"访客答题说明 字典不存在"); |
| | | } |
| | | description.setCode(visitConfigDTO.getDescription()); |
| | | |
| | | SystemDictData visitNotice = systemDictList.stream().filter(m->m.getLabel().equals(Constants.VISIT_NOTICE)).findFirst().get(); |
| | | if(Objects.isNull(visitNotice)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"入厂须知 字典不存在"); |
| | | } |
| | | visitNotice.setCode(visitConfigDTO.getVisitNotice()); |
| | | |
| | | SystemDictData doorsVisitRequired = systemDictList.stream().filter(m->m.getLabel().equals(Constants.SELECT_DOORS_VISIT_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(doorsVisitRequired)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"自选门禁配置 字典不存在"); |
| | | } |
| | | doorsVisitRequired.setCode(visitConfigDTO.getDoorsVisitRequired().toString()); |
| | | |
| | | systemDictDataMapper.updateById(reservationWay); |
| | | systemDictDataMapper.updateById(checkVisit); |
| | | systemDictDataMapper.updateById(healthCard); |
| | | systemDictDataMapper.updateById(isAnswer); |
| | | systemDictDataMapper.updateById(theme); |
| | | systemDictDataMapper.updateById(description); |
| | | systemDictDataMapper.updateById(visitNotice); |
| | | systemDictDataMapper.updateById(doorsVisitRequired); |
| | | |
| | | } |
| | | |
| | | private SystemDictData getSystemDictDataListVO(SystemDict systemDict) { |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | SystemDictData systemDictData = new SystemDictData(); |
| | | systemDictData.setDictId(systemDict.getId()); |
| | | systemDictData.setDisabled(true); |
| | | systemDictData.setSort(Constants.ONE); |
| | | systemDictData.setCreateTime(new Date()); |
| | | systemDictData.setUpdateTime(new Date()); |
| | | systemDictData.setCreateUser(loginUserInfo.getId()); |
| | | systemDictData.setUpdateUser(loginUserInfo.getId()); |
| | | |
| | | return systemDictData; |
| | | } |
| | | |
| | | @Override |
| | | public VisitConfigDTO getLaborConfigDTO() { |
| | | VisitConfigDTO visitConfigDTO = new VisitConfigDTO(); |
| | | SystemDict systemDict = systemDictMapper.selectOne(new QueryWrapper<SystemDict>().lambda().eq(SystemDict::getCode,Constants.SYSTEM)); |
| | | if(Objects.isNull(systemDict)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典类不存在"); |
| | | } |
| | | List<SystemDictData> systemDictList = systemDictDataMapper.selectList( |
| | | new QueryWrapper<SystemDictData>().lambda().eq(SystemDictData::getDictId,systemDict.getId())); |
| | | if(!com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(systemDictList)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典不存在"); |
| | | } |
| | | SystemDictData reservationWay = systemDictList.stream().filter(m->m.getLabel().equals(Constants.MDJ_LW_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(reservationWay)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客来访预约方式 字典不存在"); |
| | | } |
| | | visitConfigDTO.setReservationWay(Integer.valueOf(reservationWay.getCode())); |
| | | |
| | | SystemDictData checkVisit = systemDictList.stream().filter(m->m.getLabel().equals(Constants.LW_BEVISITED_USER_VALID)).findFirst().get(); |
| | | if(Objects.isNull(checkVisit)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客被访人校验方式 字典不存在"); |
| | | } |
| | | visitConfigDTO.setCheckVisit(Integer.valueOf(checkVisit.getCode())); |
| | | |
| | | SystemDictData healthCard = systemDictList.stream().filter(m->m.getLabel().equals(Constants.LW_HEALTH_CARD)).findFirst().get(); |
| | | if(Objects.isNull(healthCard)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客健康证是否必填 字典不存在"); |
| | | } |
| | | visitConfigDTO.setHealthCard(Integer.valueOf(healthCard.getCode())); |
| | | |
| | | SystemDictData isAnswer = systemDictList.stream().filter(m->m.getLabel().equals(Constants.PROBLEM_LW_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(isAnswer)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客是否需要答题 字典不存在"); |
| | | } |
| | | visitConfigDTO.setIsAnswer(Integer.valueOf(isAnswer.getCode())); |
| | | |
| | | SystemDictData theme = systemDictList.stream().filter(m->m.getLabel().equals(Constants.LW_THEME)).findFirst().get(); |
| | | if(Objects.isNull(theme)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客答题主题 字典不存在"); |
| | | } |
| | | visitConfigDTO.setTheme(theme.getCode()); |
| | | |
| | | SystemDictData description = systemDictList.stream().filter(m->m.getLabel().equals(Constants.LW_DESCRIPTION)).findFirst().get(); |
| | | if(Objects.isNull(description)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客答题说明 字典不存在"); |
| | | } |
| | | visitConfigDTO.setDescription(description.getCode()); |
| | | return visitConfigDTO; |
| | | } |
| | | |
| | | @Override |
| | | public void updateLaborConfigDTO(VisitConfigDTO visitConfigDTO) { |
| | | if(Objects.isNull(visitConfigDTO) |
| | | ||Objects.isNull(visitConfigDTO.getReservationWay()) |
| | | ||Objects.isNull(visitConfigDTO.getCheckVisit()) |
| | | ||Objects.isNull(visitConfigDTO.getHealthCard()) |
| | | ||Objects.isNull(visitConfigDTO.getIsAnswer()) |
| | | || StringUtils.isEmpty(visitConfigDTO.getTheme()) |
| | | || StringUtils.isEmpty(visitConfigDTO.getDescription()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | SystemDict systemDict = systemDictMapper.selectOne(new QueryWrapper<SystemDict>().lambda().eq(SystemDict::getCode,Constants.SYSTEM)); |
| | | if(Objects.isNull(systemDict)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典类不存在"); |
| | | } |
| | | List<SystemDictData> systemDictList = systemDictDataMapper.selectList( |
| | | new QueryWrapper<SystemDictData>().lambda().eq(SystemDictData::getDictId,systemDict.getId())); |
| | | if(!com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(systemDictList)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典不存在"); |
| | | } |
| | | |
| | | SystemDictData reservationWay = systemDictList.stream().filter(m->m.getLabel().equals(Constants.MDJ_LW_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(reservationWay)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客来访预约方式 字典不存在"); |
| | | } |
| | | reservationWay.setCode(visitConfigDTO.getReservationWay().toString()); |
| | | |
| | | SystemDictData checkVisit = systemDictList.stream().filter(m->m.getLabel().equals(Constants.LW_BEVISITED_USER_VALID)).findFirst().get(); |
| | | if(Objects.isNull(checkVisit)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客被访人校验方式 字典不存在"); |
| | | } |
| | | checkVisit.setCode(visitConfigDTO.getCheckVisit().toString()); |
| | | SystemDictData healthCard = systemDictList.stream().filter(m->m.getLabel().equals(Constants.LW_HEALTH_CARD)).findFirst().get(); |
| | | if(Objects.isNull(healthCard)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客健康证是否必填 字典不存在"); |
| | | } |
| | | healthCard.setCode(visitConfigDTO.getHealthCard().toString()); |
| | | SystemDictData isAnswer = systemDictList.stream().filter(m->m.getLabel().equals(Constants.PROBLEM_LW_REQUIRED)).findFirst().get(); |
| | | if(Objects.isNull(isAnswer)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客是否需要答题 字典不存在"); |
| | | } |
| | | isAnswer.setCode(visitConfigDTO.getIsAnswer().toString()); |
| | | SystemDictData theme = systemDictList.stream().filter(m->m.getLabel().equals(Constants.LW_THEME)).findFirst().get(); |
| | | if(Objects.isNull(theme)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客答题主题 字典不存在"); |
| | | } |
| | | theme.setCode(visitConfigDTO.getTheme()); |
| | | SystemDictData description = systemDictList.stream().filter(m->m.getLabel().equals(Constants.LW_DESCRIPTION)).findFirst().get(); |
| | | if(Objects.isNull(description)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"劳务访客答题说明 字典不存在"); |
| | | } |
| | | description.setCode(visitConfigDTO.getDescription()); |
| | | |
| | | systemDictDataMapper.updateById(reservationWay); |
| | | systemDictDataMapper.updateById(checkVisit); |
| | | systemDictDataMapper.updateById(healthCard); |
| | | systemDictDataMapper.updateById(isAnswer); |
| | | systemDictDataMapper.updateById(theme); |
| | | systemDictDataMapper.updateById(description); |
| | | } |
| | | } |