jiaosong
2023-12-08 36baabb9fc5f74a22f798651d33fa8c0ff32a1ce
#来访配置 劳务配置 获取或修改
已添加1个文件
已修改5个文件
312 ■■■■■ 文件已修改
server/dmvisit_admin/src/main/java/com/doumee/api/system/SystemDictDataController.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/core/utils/Constants.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/dao/admin/request/LaborConfigDTO.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/dao/admin/request/VisitConfigDTO.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/service/system/SystemDictDataService.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_admin/src/main/java/com/doumee/api/system/SystemDictDataController.java
@@ -8,6 +8,8 @@
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.dao.admin.request.LaborConfigDTO;
import com.doumee.dao.admin.request.VisitConfigDTO;
import com.doumee.dao.system.dto.QuerySystemDictDataDTO;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.dao.system.vo.SystemDictDataListVO;
@@ -111,4 +113,47 @@
    public ApiResponse<SystemDictData> getSystemDictData(@RequestParam String dictCode, @RequestParam String label) {
        return ApiResponse.success(systemDictDataBiz.queryByCode(dictCode,label));
    }
    /**
     * è®¿å®¢æ¥è®¿é…ç½®
     * @return
     */
    @ApiOperation(value = "访客来访配置" )
    @GetMapping("/getVisitConfigDTO")
    public ApiResponse<VisitConfigDTO> getVisitConfigDTO(){
        return ApiResponse.success(systemDictDataService.getVisitConfigDTO());
    };
    /**
     * ä¿®æ”¹è®¿å®¢æ¥è®¿é…ç½®
     * @param visitConfigDTO
     */
    @ApiOperation(value = "修改访客来访配置" )
    @PostMapping("/updateVisitConfig")
    public ApiResponse updateVisitConfig(@RequestBody VisitConfigDTO visitConfigDTO){
        systemDictDataService.updateVisitConfig(visitConfigDTO);
        return ApiResponse.success(null);
    };
    /**
     * åŠ³åŠ¡æ¥è®¿é…ç½®
     * @return
     */
    @ApiOperation(value = "劳务来访配置" )
    @GetMapping("/getLaborConfigDTO")
    public ApiResponse<LaborConfigDTO> getLaborConfigDTO(){
        return ApiResponse.success(systemDictDataService.getLaborConfigDTO());
    };
    /**
     * ä¿®æ”¹åŠ³åŠ¡æ¥è®¿é…ç½®
     * @param miniProgrammeDTO
     */
    @ApiOperation(value = "修改劳务来访配置" )
    @PostMapping("/updateLaborConfigDTO")
    public ApiResponse updateLaborConfigDTO(@RequestBody LaborConfigDTO miniProgrammeDTO){
        systemDictDataService.updateLaborConfigDTO(miniProgrammeDTO);
        return ApiResponse.success(null);
    };
}
server/dmvisit_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -1,8 +1,13 @@
package com.doumee.core.utils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
@@ -37,6 +42,10 @@
    public static final String EDS_PWD ="!@#$%^&QWERTY" ;
    public static final String ROOT_PATH = "";
    public static final String FILE_DIR = "";
    // è®¿å®¢æ¥è®¿é…ç½®
    public static final String VISIT_CONFIG = "VISIT_CONFIG";
    // åŠ³åŠ¡æ¥è®¿é…ç½®
    public static final String LABOR_CONFIG = "LABOR_CONFIG";
    public static  Date  getBirthdyByCardNo(String idCard){
@@ -255,7 +264,27 @@
        }
    }
    /**
     * å¯¹è±¡é©¼å³°å±žæ€§è½¬ä¸‹åˆ’线
     * @param object
     * @return
     * @throws JsonProcessingException
     */
    public static String toUnderlineJSONString(Object object) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        String reqJson = mapper.writeValueAsString(object);
        return reqJson;
    }
    public static <T> T toSnakeObject(String json, Class<T> clazz) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
        T reqJson =  mapper.readValue(json, clazz);
        return reqJson;
    }
}
server/dmvisit_service/src/main/java/com/doumee/dao/admin/request/LaborConfigDTO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
package com.doumee.dao.admin.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @author T14
 */
@Data
@ApiModel("劳务访客配置")
public class LaborConfigDTO {
    @ApiModelProperty(value = "来访预约方式")
    private String reservationWay = "";
    @ApiModelProperty(value = "被访人校验方式")
    private String checkVisit = "";
    @ApiModelProperty(value = "健康证是否必填")
    private String healthCard = "";
    @ApiModelProperty(value = "劳务是否答题")
    private String isAnswer = "";
    @ApiModelProperty(value = "劳务答题主题")
    private String theme = "";
    @ApiModelProperty(value = "劳务答题说明")
    private String description = "";
}
server/dmvisit_service/src/main/java/com/doumee/dao/admin/request/VisitConfigDTO.java
@@ -1,8 +1,14 @@
package com.doumee.dao.admin.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.IOException;
/**
@@ -13,20 +19,42 @@
public class VisitConfigDTO {
    @ApiModelProperty(value = "来访预约方式")
    private Integer reservationWay;
    private String reservationWay = "";
    @ApiModelProperty(value = "被访人校验方式")
    private Integer checkVisit;
    private String checkVisit = "";
    @ApiModelProperty(value = "健康证是否必填")
    private Integer healthCard;
    private String healthCard = "";
    @ApiModelProperty(value = "劳务是否答题")
    private Integer isAnswer;
    private String isAnswer = "";
    @ApiModelProperty(value = "劳务答题主题")
    private String theme;
    private String theme = "";
    @ApiModelProperty(value = "劳务答题说明")
    private String description;
    private String description = "";
//    /**
//     * å¯¹è±¡é©¼å³°å±žæ€§è½¬ä¸‹åˆ’线
//     * @param object
//     * @return
//     * @throws JsonProcessingException
//     */
//    public static String toUnderlineJSONString(Object object) throws JsonProcessingException {
//        ObjectMapper mapper = new ObjectMapper();
//        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
//        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
//        String reqJson = mapper.writeValueAsString(object);
//        return reqJson;
//    }
//
//
//    public static <T> T toSnakeObject(String json, Class<T> clazz) throws IOException {
//        ObjectMapper mapper = new ObjectMapper();
//        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
//        T reqJson =  mapper.readValue(json, clazz);
//        return reqJson;
//    }
}
server/dmvisit_service/src/main/java/com/doumee/service/system/SystemDictDataService.java
@@ -2,6 +2,8 @@
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.dao.admin.request.LaborConfigDTO;
import com.doumee.dao.admin.request.VisitConfigDTO;
import com.doumee.dao.system.dto.QuerySystemDictDataDTO;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.dao.system.vo.SystemDictDataListVO;
@@ -70,7 +72,7 @@
     * @date 2023/03/21 14:49
     */
    List<SystemDictData> findList(SystemDictData systemDictData);
    /**
     * åˆ†é¡µæŸ¥è¯¢
     * @author Eva.Caesar Liu
@@ -96,5 +98,28 @@
    List<SystemDictData> findList(Integer dicId,List<String> codes);
    /**
     * è®¿å®¢æ¥è®¿é…ç½®
     * @return
     */
    VisitConfigDTO getVisitConfigDTO();
    /**
     * ä¿®æ”¹è®¿å®¢æ¥è®¿é…ç½®
     * @param miniProgrammeDTO
     */
    void updateVisitConfig(VisitConfigDTO miniProgrammeDTO);
    /**
     * åŠ³åŠ¡æ¥è®¿é…ç½®
     * @return
     */
    LaborConfigDTO getLaborConfigDTO();
    /**
     * ä¿®æ”¹åŠ³åŠ¡æ¥è®¿é…ç½®
     * @param miniProgrammeDTO
     */
    void updateLaborConfigDTO(LaborConfigDTO miniProgrammeDTO);
}
server/dmvisit_service/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
@@ -1,9 +1,15 @@
package com.doumee.service.system.impl;
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.utils.Constants;
import com.doumee.dao.admin.request.LaborConfigDTO;
import com.doumee.dao.admin.request.VisitConfigDTO;
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;
@@ -22,6 +28,7 @@
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * å­—典数据Service实现
@@ -34,6 +41,8 @@
    @Autowired
    private SystemDictDataMapper systemDictDataMapper;
    @Autowired
    private SystemDictMapper systemDictMapper;
    @Override
    public Integer create(SystemDictData systemDictData) {
        systemDictDataMapper.insert(systemDictData);
@@ -91,7 +100,7 @@
        Wrapper<SystemDictData> wrapper = new QueryWrapper<>(systemDictData);
        return systemDictDataMapper.selectList(wrapper);
    }
    @Override
    public PageData<SystemDictDataListVO> findPage(PageWrap<QuerySystemDictDataDTO> pageWrap) {
        PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
@@ -112,4 +121,132 @@
                .in(SystemDictData::getLabel,codes);
        return systemDictDataMapper.selectList(wrapper);
    }
    @Override
    public VisitConfigDTO getVisitConfigDTO() {
        try {
            String jasonStr = Constants.toUnderlineJSONString(new VisitConfigDTO());
            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.VISIT_CONFIG);
            SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery);
            if (Objects.isNull(systemDict)){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典不存在");
            }
            QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>();
            wrapper.lambda()
                    .eq(SystemDictData::getDictId,systemDict.getId())
                    .in(SystemDictData::getLabel,collect);
            List<SystemDictData> systemDictData = systemDictDataMapper.selectList(wrapper);
            if (CollectionUtils.isEmpty(systemDictData)){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典值不存在");
            }
            systemDictData.forEach(s->{
                parse.put(s.getLabel().toLowerCase(),s.getCode());
            });
            String s = parse.toJSONString();
            VisitConfigDTO miniProgrammeDTO = Constants.toSnakeObject(s, VisitConfigDTO.class);
            return miniProgrammeDTO;
        } catch (Exception e) {
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"字典值解析有误");
        }
    }
    @Override
    public void updateVisitConfig(VisitConfigDTO miniProgrammeDTO) {
        try {
            QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>();
            systemDictQuery.lambda()
                    .eq(SystemDict::getDeleted,Boolean.FALSE)
                    .eq(SystemDict::getCode,Constants.VISIT_CONFIG);
            SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery);
            if (Objects.isNull(systemDict)){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典不存在");
            }
            String jasonStr = Constants.toUnderlineJSONString(miniProgrammeDTO);
            JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
            parse.entrySet().forEach(s->{
                UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>();
                wrapper.lambda()
                        .eq(SystemDictData::getDictId,systemDict.getId())
                        .eq(SystemDictData::getLabel,s.getKey().toUpperCase())
                        .set(SystemDictData::getCode,s.getValue());
                systemDictDataMapper.update(null,wrapper);
            });
        } catch (JsonProcessingException e) {
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"字典值解析有误");
        }
    }
    @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);
            if (Objects.isNull(systemDict)){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典不存在");
            }
            QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>();
            wrapper.lambda()
                    .eq(SystemDictData::getDictId,systemDict.getId())
                    .in(SystemDictData::getLabel,collect);
            List<SystemDictData> systemDictData = systemDictDataMapper.selectList(wrapper);
            if (CollectionUtils.isEmpty(systemDictData)){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典值不存在");
            }
            systemDictData.forEach(s->{
                parse.put(s.getLabel().toLowerCase(),s.getCode());
            });
            String s = parse.toJSONString();
            LaborConfigDTO miniProgrammeDTO = Constants.toSnakeObject(s, LaborConfigDTO.class);
            return miniProgrammeDTO;
        } catch (Exception e) {
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"字典值解析有误");
        }
    }
    @Override
    public void updateLaborConfigDTO(LaborConfigDTO miniProgrammeDTO) {
        try {
            QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>();
            systemDictQuery.lambda()
                    .eq(SystemDict::getDeleted,Boolean.FALSE)
                    .eq(SystemDict::getCode,Constants.VISIT_CONFIG);
            SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery);
            if (Objects.isNull(systemDict)){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"字典不存在");
            }
            String jasonStr = Constants.toUnderlineJSONString(miniProgrammeDTO);
            JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
            parse.entrySet().forEach(s->{
                UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>();
                wrapper.lambda()
                        .eq(SystemDictData::getDictId,systemDict.getId())
                        .eq(SystemDictData::getLabel,s.getKey().toUpperCase())
                        .set(SystemDictData::getCode,s.getValue());
                systemDictDataMapper.update(null,wrapper);
            });
        } catch (JsonProcessingException e) {
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"字典值解析有误");
        }
    }
}