| | |
| | | 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; |
| | |
| | | |
| | | @Override |
| | | public VisitConfigDTO getVisitConfigDTO() { |
| | | |
| | | try { |
| | | QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>(); |
| | | systemDictQuery.lambda() |
| | | .eq(SystemDict::getDeleted,Boolean.FALSE) |
| | | .eq(SystemDict::getCode,Constants.VISIT_CONFIG); |
| | | SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery); |
| | | |
| | | 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(),"字典不存在"); |
| | | } |
| | | QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(SystemDictData::getDictId,systemDict.getId()); |
| | | List<SystemDictData> systemDictDatas = systemDictDataMapper.selectList(wrapper); |
| | | if (CollectionUtils.isEmpty(systemDictDatas)){ |
| | | 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 visitConfigDTO = null; |
| | | for (SystemDictData obj:systemDictDatas) { |
| | | visitConfigDTO = new VisitConfigDTO(); |
| | | visitConfigDTO.setVisitConfigParam(JSONObject.parseObject(obj.getCode(),VisitConfigParam.class)); |
| | | visitConfigDTO.setDescription(obj.getRemark()); |
| | | visitConfigDTO.setTheme(obj.getLabel()); |
| | | 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()); |
| | | return visitConfigDTO; |
| | | } catch (Exception e) { |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"字典值解析有误"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updateVisitConfig(VisitConfigDTO miniProgrammeDTO) { |
| | | |
| | | QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>(); |
| | | systemDictQuery.lambda() |
| | | .eq(SystemDict::getDeleted,Boolean.FALSE) |
| | | .eq(SystemDict::getCode,Constants.VISIT_CONFIG); |
| | | SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery); |
| | | |
| | | 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(),"字典不存在"); |
| | | } |
| | | QuerySystemDictDataDTO dictData = new QuerySystemDictDataDTO(); |
| | | dictData.setDictId((systemDict.getId())); |
| | | List<SystemDictDataListVO> systemDictDataListVOS = systemDictDataMapper.selectManageList(dictData); |
| | | SystemDictData systemDictData = getSystemDictDataListVO(systemDict); |
| | | systemDictData.setCode(JSON.toJSONString(miniProgrammeDTO.getVisitConfigParam())); |
| | | systemDictData.setLabel(miniProgrammeDTO.getTheme()); |
| | | systemDictData.setRemark(miniProgrammeDTO.getDescription()); |
| | | if(null != systemDictDataListVOS && systemDictDataListVOS.size() > 0) { |
| | | systemDictData.setId(systemDictDataListVOS.get(0).getId()); |
| | | systemDictDataMapper.updateById(systemDictData); |
| | | }else { |
| | | systemDictDataMapper.insert(systemDictData); |
| | | |
| | | 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()); |
| | | |
| | | systemDictDataMapper.updateById(reservationWay); |
| | | systemDictDataMapper.updateById(checkVisit); |
| | | systemDictDataMapper.updateById(healthCard); |
| | | systemDictDataMapper.updateById(isAnswer); |
| | | systemDictDataMapper.updateById(theme); |
| | | systemDictDataMapper.updateById(description); |
| | | |
| | | } |
| | | |
| | | private SystemDictData getSystemDictDataListVO(SystemDict systemDict) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public LaborConfigDTO getLaborConfigDTO() { |
| | | |
| | | try { |
| | | String jasonStr = Constants.toUnderlineJSONString(new LaborConfigDTO()); |
| | | JSONObject parse = (JSONObject) JSONObject.parse(jasonStr); |
| | | List<String> collect = parse.entrySet().stream().map(s -> s.getKey().toUpperCase()).collect(Collectors.toList()); |
| | | |
| | | QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>(); |
| | | systemDictQuery.lambda() |
| | | .eq(SystemDict::getDeleted,Boolean.FALSE) |
| | | .eq(SystemDict::getCode,Constants.LABOR_CONFIG); |
| | | SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery); |
| | | |
| | | 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(),"字典不存在"); |
| | | } |
| | | QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(SystemDictData::getDictId,systemDict.getId()); |
| | | List<SystemDictData> systemDictDatas = systemDictDataMapper.selectList(wrapper); |
| | | LaborConfigDTO laborConfigDTO = null; |
| | | for (SystemDictData obj:systemDictDatas) { |
| | | laborConfigDTO = new LaborConfigDTO(); |
| | | laborConfigDTO.setLaborConfigParam(JSONObject.parseObject(obj.getCode(), LaborConfigParam.class)); |
| | | laborConfigDTO.setDescription(obj.getRemark()); |
| | | laborConfigDTO.setTheme(obj.getLabel()); |
| | | 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(),"劳务访客来访预约方式 字典不存在"); |
| | | } |
| | | return laborConfigDTO; |
| | | } catch (Exception e) { |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.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(LaborConfigDTO miniProgrammeDTO) { |
| | | QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>(); |
| | | systemDictQuery.lambda() |
| | | .eq(SystemDict::getDeleted,Boolean.FALSE) |
| | | .eq(SystemDict::getCode,Constants.LABOR_CONFIG); |
| | | SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery); |
| | | |
| | | 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(),"字典不存在"); |
| | | } |
| | | QuerySystemDictDataDTO dictData = new QuerySystemDictDataDTO(); |
| | | dictData.setDictId((systemDict.getId())); |
| | | List<SystemDictDataListVO> systemDictDataListVOS = systemDictDataMapper.selectManageList(dictData); |
| | | SystemDictData systemDictData = getSystemDictDataListVO(systemDict); |
| | | systemDictData.setCode(JSON.toJSONString(miniProgrammeDTO.getLaborConfigParam())); |
| | | systemDictData.setLabel(miniProgrammeDTO.getTheme()); |
| | | systemDictData.setRemark(miniProgrammeDTO.getDescription()); |
| | | if(null != systemDictDataListVOS && systemDictDataListVOS.size() > 0) { |
| | | systemDictData.setId(systemDictDataListVOS.get(0).getId()); |
| | | systemDictDataMapper.updateById(systemDictData); |
| | | }else { |
| | | systemDictDataMapper.insert(systemDictData); |
| | | |
| | | 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); |
| | | } |
| | | } |