jiangping
2024-01-24 beea81f59962e10358672365cb16f0eeda7893df
开发业务接口
已修改6个文件
179 ■■■■ 文件已修改
server/platform/src/main/java/com/doumee/api/business/DispatchUnitController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/common/PublicController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/shiro/ShiroConfig.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/DuWorktypeMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/DispatchUnitService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/business/DispatchUnitController.java
@@ -38,6 +38,18 @@
    public ApiResponse create(@RequestBody SaveDispatchUnitDTO saveDispatchUnitDTO) {
        return ApiResponse.success(dispatchUnitService.create(saveDispatchUnitDTO));
    }
    @ApiOperation("派遣单位审核")
    @PostMapping("/check")
    @RequiresPermissions("business:dispatchunit:check")
    public ApiResponse check(@RequestBody DispatchUnit param) {
        return ApiResponse.success(dispatchUnitService.check(param));
    }
    @ApiOperation("派遣单位工种审核")
    @PostMapping("/checkWorktype")
    @RequiresPermissions("business:dispatchunit:checkWorktype")
    public ApiResponse checkWorktype(@RequestBody DispatchUnit param) {
        return ApiResponse.success(dispatchUnitService.checkWorktype(param));
    }
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
server/platform/src/main/java/com/doumee/api/common/PublicController.java
@@ -41,12 +41,8 @@
@RequestMapping("/public")
@Slf4j
public class PublicController extends BaseController {
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @ApiOperation(value = "上传", notes = "上传", httpMethod = "POST", position = 6)
    @ApiImplicitParams({
        @ApiImplicitParam(name = "folder", value = "文件夹", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class),
@@ -61,8 +57,6 @@
            systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode(),
            systemDictDataBiz.queryByCode(Constants.OSS,Constants.ENDPOINT).getCode());
    }
    @ApiOperation(value = "上传图片", notes = "上传图片", httpMethod = "POST", position = 6)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "folder", value = "文件夹", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class),
@@ -88,7 +82,6 @@
                systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode(),
                systemDictDataBiz.queryByCode(Constants.OSS,Constants.ENDPOINT).getCode());
    }
    public void upload(HttpServletRequest request, HttpServletResponse response, String folder, String bucketName,
        String access_id, String access_key, String resourcePath, String endpoint) throws Exception {
        response.setCharacterEncoding("UTF-8");
server/platform/src/main/java/com/doumee/shiro/ShiroConfig.java
@@ -88,17 +88,10 @@
        shiroFilterFactoryBean.setSecurityManager(securityManager);
        Map<String, String> map = new LinkedHashMap<>();
        // 路径拦截配置
        map.put("/system/dictData/companyUserRules","anon");
        map.put("/system/login", "anon");
        map.put("/system/logout", "anon");
        map.put("/system/loginH5", "anon");
        map.put("/common/captcha", "anon");
        map.put("/business/areas/*", "anon");
        map.put("/public/uploadPicture","anon");
        map.put("/public/uploadLocal","anon");
        // - 放行swagger
        map.put("/doc.html", "anon");
        map.put("/webjars/**", "anon");
server/service/src/main/java/com/doumee/dao/business/DuWorktypeMapper.java
@@ -1,12 +1,16 @@
package com.doumee.dao.business;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.doumee.dao.business.model.ApplyDetail;
import com.doumee.dao.business.model.DuWorktype;
import java.util.List;
/**
 * @author 江蹄蹄
 * @date 2024/01/16 10:03
 */
public interface DuWorktypeMapper extends BaseMapper<DuWorktype> {
    void insertBatchSomeColumn(List<DuWorktype> list);
}
server/service/src/main/java/com/doumee/service/business/DispatchUnitService.java
@@ -130,4 +130,8 @@
     * @return
     */
    List<DispatchUnit> findByDTO(DispatchUnitQueryDTO dispatchUnitQueryDTO);
    Integer check(DispatchUnit param);
    Integer checkWorktype(DispatchUnit param);
}
server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java
@@ -30,10 +30,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.*;
/**
 * 派遣单位信息表Service实现
@@ -64,7 +61,147 @@
    @Autowired
    private DuWorkTypeJoinMapper duWorkTypeJoinMapper;
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public Integer checkWorktype(DispatchUnit param) {
        if(Objects.isNull(param)
                ||Objects.isNull(param.getId())
                ||param.getWorktypeStatus() == null
                ||!(param.getWorktypeStatus() ==Constants.ONE || param.getWorktypeStatus() == Constants.TWO)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        DispatchUnit model = dispatchUnitMapper.selectById(param.getId());
        if(Objects.isNull(model) || Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) ||!Constants.equalsInteger(model.getDataType(),Constants.ZERO)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到派遣单位信息");
        }
        if(!Constants.equalsInteger(model.getStatus(),Constants.ONE)){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该派遣单位尚未审核通过,不支持该操作!");
        }
        if(Constants.equalsInteger(model.getWorktypeStatus(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该派遣单位工种已审核,请勿重复提交~");
        }
        DispatchUnit update = new DispatchUnit();
        update.setEditor(user.getId());
        update.setEditDate(new Date());
        update.setId(model.getId());
        update.setWorktypeStatus(param.getWorktypeStatus());
        update.setCheckDate(update.getEditDate());
        update.setCheckUserId(user.getId());
        update.setCheckInfo(param.getCheckInfo());
        dispatchUnitMapper.updateById(update);
        if(Constants.equalsInteger(param.getWorktypeStatus(),Constants.ONE)){
            //审核通过,修改状态,产生历史版本
            newVersionData(model,update);
        }else{
            //更新明细数据为审核失败
            duSolutionMapper.update(null,new UpdateWrapper<DuSolution>().lambda()
                    .set(DuSolution::getCheckDate,new Date() )
                    .set(DuSolution::getStatus,Constants.TWO)
                    .set(DuSolution::getCheckUserId,update.getCheckUserId())
                    .set(DuSolution::getCheckInfo,update.getCheckInfo())
                    .eq(DuSolution::getDispatchUnitId,update.getId()));
        }
        return  1;
    }
    private void newVersionData(DispatchUnit model, DispatchUnit update) {
        dispatchUnitMapper.update(null,new UpdateWrapper<DispatchUnit>().lambda()
                .set(DispatchUnit::getDataType,Constants.ZERO)
                .eq(DispatchUnit::getIsdeleted,Constants.ZERO)
                .eq(DispatchUnit::getBaseId,model.getId()));
        DispatchUnit newVersion = new DispatchUnit();
        BeanUtils.copyProperties(model, newVersion);
        newVersion.setWorktypeStatus(Constants.ONE);
        newVersion.setCheckDate(update.getEditDate());
        newVersion.setCheckUserId(update.getCheckUserId());
        newVersion.setCheckInfo(update.getCheckInfo());
        newVersion.setCreateDate(update.getCreateDate());
        newVersion.setCreator(update.getEditor());
        newVersion.setBaseId(model.getBaseId());
        newVersion.setDataType(Constants.TWO);
        dispatchUnitMapper.insert(newVersion);
        List<DuWorktype> newWorktypes = new ArrayList<>();
        List<DuSolution> solutions = duSolutionMapper.selectList(new QueryWrapper<DuSolution>().lambda()
                .eq(DuSolution::getIsdeleted,Constants.ZERO)
                .eq(DuSolution::getDispatchUnitId,model.getSolutionId()));
        if(solutions == null || solutions.size() ==0){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该派遣单位未设置方案工种信息,审核通过失败!");
        }
        for (DuSolution s : solutions){
            DuSolution ns = new DuSolution();
            BeanUtils.copyProperties(s, ns);
            ns.setDispatchUnitId(newVersion.getId());
            ns.setCheckDate(update.getEditDate());
            ns.setStatus(Constants.ONE);
            ns.setCheckInfo(update.getCheckInfo());
            ns.setCheckUserId(update.getCheckUserId());
            duSolutionMapper.insert(ns);
            List<DuWorktype> worktypes = duWorktypeMapper.selectList(new QueryWrapper<DuWorktype>().lambda()
                    .eq(DuWorktype::getIsdeleted,Constants.ZERO)
                    .eq(DuWorktype::getDuSolutionId,s.getId()));
            if(worktypes == null || worktypes.size() ==0){
                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该派遣单位方案存在方案是未设置工种信息信息,审核通过失败!");
            }
            for (DuWorktype w : worktypes) {
                DuWorktype nw = new DuWorktype();
                BeanUtils.copyProperties(w, nw);
                nw.setCheckDate(update.getEditDate());
                nw.setStatus(Constants.ONE);
                nw.setDuSolutionId(ns.getId());
                nw.setCheckInfo(update.getCheckInfo());
                nw.setCheckUserId(update.getCheckUserId());
                newWorktypes.add(nw);
            }
        }
        if(newWorktypes!=null &&newWorktypes.size()>0){
            //批量查询工种关联记录
            duWorktypeMapper.insertBatchSomeColumn(newWorktypes);
        }
    }
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public Integer check(DispatchUnit param) {
        if(Objects.isNull(param)
                ||Objects.isNull(param.getId())
                ||param.getStatus() == null
                ||!(param.getStatus() ==Constants.ONE || param.getStatus() == Constants.TWO)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        DispatchUnit model = dispatchUnitMapper.selectById(param.getId());
        if(Objects.isNull(model) || Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) ||!Constants.equalsInteger(model.getDataType(),Constants.ZERO)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到派遣单位信息");
        }
        if(Constants.equalsInteger(model.getStatus(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该派遣单位工种已审核,请勿重复提交~");
        }
        DispatchUnit update = new DispatchUnit();
        update.setEditor(user.getId());
        update.setEditDate(new Date());
        update.setId(model.getId());
        update.setStatus(param.getStatus());
        update.setWorktypeStatus(param.getWorktypeStatus());
        update.setCheckDate(update.getEditDate());
        update.setCheckUserId(user.getId());
        update.setCheckInfo(param.getCheckInfo());
        dispatchUnitMapper.updateById(update);
        if(Constants.equalsInteger(model.getStatus(),Constants.ONE)){
            //审核通过,修改状态,产生历史版本
            newVersionData(model,update);
        }else{
            //更新明细数据为审核失败
            duSolutionMapper.update(null,new UpdateWrapper<DuSolution>().lambda()
                    .set(DuSolution::getCheckDate,new Date() )
                    .set(DuSolution::getStatus,Constants.TWO)
                    .set(DuSolution::getCheckUserId,update.getCheckUserId())
                    .set(DuSolution::getCheckInfo,update.getCheckInfo())
                    .eq(DuSolution::getDispatchUnitId,update.getId()));
        }
        return  1;
    }
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public Integer create(SaveDispatchUnitDTO saveDispatchUnitDTO) {