SupplierController.java 9.2 KB
Newer Older
苗卫卫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
package com.boco.nbd.wios.manage.controller;

import cn.hutool.core.lang.Assert;
import com.boco.nbd.cams.core.constant.CamsConstant;
import com.boco.nbd.cams.core.constant.MessageConstant;
import com.boco.nbd.wios.manage.contants.WiosConstant;
import com.boco.nbd.wios.manage.entity.bo.SupplierBo;
import com.boco.nbd.wios.manage.service.impl.SupplierService;
import com.boco.nbd.wios.manage.util.CommonUtils;
import com.ihidea.component.api.v2.BaseResponse;
import com.ihidea.core.support.exception.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.ArrayList;
import java.util.List;

/**
 * 服务商管理接口
 *
 * @author
 */
@RestController
@RequestMapping("api")
@Api(tags = "服务商管理接口")
@ApiIgnore
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    /**
     * 查询服务商列表
     *
     * @param supplierBo
     * @return
     */
    @GetMapping(value = "supplier/list")
    @ApiOperation(value = "查询列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "一页显示数量", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pagecount", value = "页码", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "code", value = "编码", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "status", value = "状态 0禁用 1启用", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "contactName", value = "联系人姓名", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "contactPhone", value = "联系人手机", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "organizationCode", value = "组织机构代码", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "maxOrderQuantity", value = "日接单能力", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "checkStatus", value = "派单查询列表审核状态传1(0:未审核,1:审核通过,2:审核不通过)", dataType = "int", paramType = "query", required = false),
    })
    public BaseResponse<Object> list(SupplierBo supplierBo) {
        return new BaseResponse<>(supplierService.getList(supplierBo));
    }

    /**
     * 添加服务商
     *
     * @param supplierBo
     * @return
     */
    @PostMapping(value = "supplier/add")
    @ApiOperation(value = "添加")
    public BaseResponse<Object> add(SupplierBo supplierBo) {
        Assert.notNull(supplierBo.getName(), "缺少name");
        Assert.notNull(supplierBo.getCode(), "缺少code");
        Assert.notNull(supplierBo.getAccount(), "缺少account");

        //营业执照
        supplierBo.setBusinessLicense(getFilePaths(supplierBo.getBusinessLicense()));
        //安装资质
        supplierBo.setInstallLicense(getFilePaths(supplierBo.getInstallLicense()));
        //莱茵认证
        supplierBo.setTuvCert(getFilePaths(supplierBo.getTuvCert()));
        //安装工程一切责任险
        supplierBo.setInstallInsurance(getFilePaths(supplierBo.getInstallInsurance()));
        //雇主责任险
        supplierBo.setEmployerInsurance(getFilePaths(supplierBo.getEmployerInsurance()));

        supplierService.add(supplierBo);
        return new BaseResponse<>();
    }

    private String getFilePaths(String paths) {
        if (!StringUtils.isEmpty(paths)) {
            String[] arr = paths.split(CamsConstant.COMMA);
            List<String> fileList = new ArrayList<>();
            for (String str : arr) {
                fileList.add(CommonUtils.urlHandle(str));
            }
            return StringUtils.collectionToCommaDelimitedString(fileList);
        }
        return null;
    }

    /**
     * 批量添加
     *
     * @param supplierJson
     * @return
     */
    @PostMapping(value = "supplier/batchAdd")
    @ApiOperation(value = "批量添加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "supplierJson", value = "json数据", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> batchAdd(String supplierJson) {
        Assert.notEmpty(supplierJson, MessageConstant.MISSING_PARAM);
        supplierService.batchAdd(supplierJson);
        return new BaseResponse<>();
    }

    /**
     * 更新服务商
     *
     * @param supplier
     * @return
     */
    @PostMapping(value = "supplier/update")
    @ApiOperation(value = "更新")
    public BaseResponse<Object> update(SupplierBo supplier) {
        //营业执照
        supplier.setBusinessLicense(getFilePaths(supplier.getBusinessLicense()));
        //安装资质
        supplier.setInstallLicense(getFilePaths(supplier.getInstallLicense()));
        //莱茵认证
        supplier.setTuvCert(getFilePaths(supplier.getTuvCert()));
        //安装工程一切责任险
        supplier.setInstallInsurance(getFilePaths(supplier.getInstallInsurance()));
        //雇主责任险
        supplier.setEmployerInsurance(getFilePaths(supplier.getEmployerInsurance()));
        supplierService.update(Integer.valueOf(supplier.getId()), supplier);
        return new BaseResponse<>();
    }

    /**
     * 更新账号
     *
     * @param accountId
     * @param account
     * @return
     */
    @PostMapping(value = "supplier/updateAccount")
    @ApiOperation(value = "更新账号")
    @ApiImplicitParams({@ApiImplicitParam(name = "accountId", value = "账号id", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "account", value = "登陆手机号", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> updateAccount(Integer accountId, String account) {
        if (StringUtils.isEmpty(account) || accountId == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        supplierService.updateAccount(accountId, account);
        return new BaseResponse<>();
    }

    /**
     * @return com.ihidea.component.api.v2.BaseResponse<java.lang.Object>
     * @Description 审核新建的安装服务商
     * @Param [id, checkStatus, checkRemark]
     * @author liwenxiang
     * @date 2021/7/27 13:33
     */
    @PostMapping(value = "supplier/checkSupplier")
    @ApiOperation(value = "审核新建的安装服务商")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "安装服务商id", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "checkStatus", value = "审核状态:1:审核通过,2:审核不通过", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "checkRemark", value = "审核备注", dataType = "String", paramType = "query", required = false)})
    public BaseResponse<Object> checkSupplier(Integer id, Integer checkStatus, String checkRemark) {
        supplierService.checkSupplier(id, checkStatus, checkRemark);
        return new BaseResponse<>();
    }

    /**
     * @return com.ihidea.component.api.v2.BaseResponse<java.lang.Object>
     * @Description 查询服务商自动派单配置
     * @Param [id]
     * @author liwenxiang
     * @date 2021/8/20 10:07
     */
    @GetMapping(value = "supplier/getDispatchConfig")
    @ApiOperation(value = "查询服务商自动派单配置")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "安装服务商id", dataType = "int", paramType = "query", required = true)})
    public BaseResponse<Object> getDispatchConfig(Integer id) {
        return new BaseResponse<>(supplierService.getDispatchConfig(id));
    }

    /**
     * @return com.ihidea.component.api.v2.BaseResponse<java.lang.Object>
     * @Description 新增/修改服务商自动派单配置
     * @Param [supplierId, jsonStr]
     * @author liwenxiang
     * @date 2021/8/20 14:11
     */
    @PostMapping(value = "supplier/updateDispatchConfig")
    @ApiOperation(value = "新增/修改服务商自动派单配置")
    @ApiImplicitParams({@ApiImplicitParam(name = "supplierId", value = "服务商id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "id", value = "主键id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "regionId", value = "地区id", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "dispatchNum", value = "派单数量", dataType = "int", paramType = "query", required = true)})
    public BaseResponse<Object> updateDispatchConfig(String supplierId, String jsonStr) {
        supplierService.updateDispatchConfig(supplierId, jsonStr);
        return new BaseResponse<>();
    }

}