liujie
2023-05-15 6225c37d2f53adf26daf6b4859af5fb5c6fad088
src/main/java/com/stylefeng/guns/modular/system/controller/TCompanyController.java
@@ -47,141 +47,140 @@
    /**
     * 获取列表
     */
    @ApiOperation(value = "卡车公司列表",notes="卡车公司列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称/id", required = false, dataType = "String"),
            @ApiImplicitParam(name = "account", value = "account", required = false, dataType = "String"),
    })
    @GetMapping(value = "/list")
    @ResponseBody
    public Object list(int pageNumber,int pageSize,String name,String account) {
        Page<TCompanyVo> tCompanyVoPage = new Page<>(pageNumber, pageSize);
        List<TCompanyVo> tCompanyVos = tCompanyService.selectList1(tCompanyVoPage, name, account);
        tCompanyVoPage.setRecords(tCompanyVos);
        return new SuccessTip(tCompanyVoPage);
    }
    @ApiOperation(value = "卡车公司审核列表",notes="卡车公司审核列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称/id", required = false, dataType = "String"),
            @ApiImplicitParam(name = "account", value = "account", required = false, dataType = "String"),
            @ApiImplicitParam(name = "state", value = "state", required = false, dataType = "int"),
    })
    @GetMapping(value = "/listCheck")
    @ResponseBody
    public Object listCheck(int pageNumber,int pageSize,String name,String account,Integer state) {
        Page<TCompanyVo> tCompanyVoPage = new Page<>(pageNumber, pageSize);
        tCompanyVoPage.setRecords(tCompanyService.selectList2(tCompanyVoPage,name,account,state));
        return new SuccessTip(tCompanyVoPage);
    }
    /**
     * 新增
     */
    @ApiOperation(value = "新增卡车公司",notes="新增卡车公司")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/add")
    @ResponseBody
    public Object add(@RequestBody TCompanyDto tCompany)  {
        try {
            List<TCompany> companies = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("account", tCompany.getAccount()));
            if(companies.size()>0){
                return new ErrorTip(5002,"Account already exists");
            }
            TCompany company = new TCompany();
            BeanUtil.copyProperties(tCompany,company);
            tCompanyService.insert(company);
            List<TCompanyService> list = tCompany.getList();
            list.forEach(e->e.setCompanyId(company.getId()));
            itCompanyServiceService.insertBatch(tCompany.getList());
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    /**
     * 删除
     */
    @ApiOperation(value = "删除卡车公司",notes="删除卡车公司")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
    })
    @DeleteMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tCompanyId) {
        TCompany tCompany = tCompanyService.selectById(tCompanyId);
        tCompany.setRemove(1);
        tCompanyService.updateById(tCompany);
        return SUCCESS_TIP;
    }
    @ApiOperation(value = "冻结卡车公司",notes="冻结卡车公司")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "type", value = "1解冻 2冻结", required = true, dataType = "int"),
    })
    @DeleteMapping(value = "/freeze")
    @ResponseBody
    public Object freeze(@RequestParam Integer tCompanyId,Integer type) {
        TCompany tCompany = tCompanyService.selectById(tCompanyId);
        if(type==1){
            tCompany.setStatus(1);
        }else if(type==2){
            tCompany.setStatus(3);
        }
        tCompanyService.updateById(tCompany);
        return SUCCESS_TIP;
    }
//    /**
//     * 获取列表
//     */
//    @ApiOperation(value = "卡车公司列表",notes="卡车公司列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
//            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "名称/id", required = false, dataType = "String"),
//            @ApiImplicitParam(name = "account", value = "account", required = false, dataType = "String"),
//    })
//    @GetMapping(value = "/list")
//    @ResponseBody
//    public Object list(int pageNumber,int pageSize,String name,String account) {
//
//        Page<TCompanyVo> tCompanyVoPage = new Page<>(pageNumber, pageSize);
//        List<TCompanyVo> tCompanyVos = tCompanyService.selectList1(tCompanyVoPage, name, account);
//        tCompanyVoPage.setRecords(tCompanyVos);
//        return new SuccessTip(tCompanyVoPage);
//    }
//
//    @ApiOperation(value = "卡车公司审核列表",notes="卡车公司审核列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
//            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "名称/id", required = false, dataType = "String"),
//            @ApiImplicitParam(name = "account", value = "account", required = false, dataType = "String"),
//            @ApiImplicitParam(name = "state", value = "state", required = false, dataType = "int"),
//    })
//    @GetMapping(value = "/listCheck")
//    @ResponseBody
//    public Object listCheck(int pageNumber,int pageSize,String name,String account,Integer state) {
//
//        Page<TCompanyVo> tCompanyVoPage = new Page<>(pageNumber, pageSize);
//        tCompanyVoPage.setRecords(tCompanyService.selectList2(tCompanyVoPage,name,account,state));
//        return new SuccessTip(tCompanyVoPage);
//    }
//
//    /**
//     * 新增
//     */
//    @ApiOperation(value = "新增卡车公司",notes="新增卡车公司")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//    })
//    @PostMapping(value = "/add")
//    @ResponseBody
//    public Object add(@RequestBody TCompanyDto tCompany)  {
//        try {
//            List<TCompany> companies = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("account", tCompany.getAccount()));
//            if(companies.size()>0){
//                return new ErrorTip(5002,"Account already exists");
//            }
//            TCompany company = new TCompany();
//            BeanUtil.copyProperties(tCompany,company);
//            tCompanyService.insert(company);
//            List<TCompanyService> list = tCompany.getList();
//            list.forEach(e->e.setCompanyId(company.getId()));
//            itCompanyServiceService.insertBatch(tCompany.getList());
//            return SUCCESS_TIP;
//        }catch (Exception e){
//            e.printStackTrace();
//            return ERROR;
//        }
//    }
//
//    /**
//     * 删除
//     */
//    @ApiOperation(value = "删除卡车公司",notes="删除卡车公司")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
//    })
//    @DeleteMapping(value = "/delete")
//    @ResponseBody
//    public Object delete(@RequestParam Integer tCompanyId) {
//        TCompany tCompany = tCompanyService.selectById(tCompanyId);
//        tCompany.setRemove(1);
//        tCompanyService.updateById(tCompany);
//        return SUCCESS_TIP;
//    }
//
//    @ApiOperation(value = "冻结卡车公司",notes="冻结卡车公司")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
//            @ApiImplicitParam(name = "type", value = "1解冻 2冻结", required = true, dataType = "int"),
//    })
//    @DeleteMapping(value = "/freeze")
//    @ResponseBody
//    public Object freeze(@RequestParam Integer tCompanyId,Integer type) {
//        TCompany tCompany = tCompanyService.selectById(tCompanyId);
//        if(type==1){
//            tCompany.setStatus(1);
//        }else if(type==2){
//            tCompany.setStatus(3);
//        }
//        tCompanyService.updateById(tCompany);
//        return SUCCESS_TIP;
//    }
    @ApiOperation(value = "审核卡车公司",notes="审核卡车公司")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "type", value = "1通过 2拒绝", required = true, dataType = "int"),
            @ApiImplicitParam(name = "remark", value = "拒绝原因/通过填时间(2023-01-31 17:49:08)", required = true, dataType = "String"),
    })
    @DeleteMapping(value = "/audit")
    @ResponseBody
    public Object audit(@RequestParam Integer tCompanyId,Integer type,String remark) {
        TCompany tCompany = tCompanyService.selectById(tCompanyId);
        if(type==1){
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            try {
                Date parse = simpleDateFormat.parse(remark);
                tCompany.setExpirationTime(parse);
            } catch (ParseException e) {
                e.printStackTrace();
                return new ErrorTip(5010, "时间格式错误!");
            }
            tCompany.setStatus(1);
        }else if(type==2){
            tCompany.setStatus(2);
            tCompany.setRemark(remark);
        }
        tCompanyService.updateById(tCompany);
        return SUCCESS_TIP;
    }
//    @ApiOperation(value = "审核卡车公司",notes="审核卡车公司")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
//            @ApiImplicitParam(name = "type", value = "1通过 2拒绝", required = true, dataType = "int"),
//            @ApiImplicitParam(name = "remark", value = "拒绝原因/通过填时间(2023-01-31 17:49:08)", required = true, dataType = "String"),
//    })
//    @DeleteMapping(value = "/audit")
//    @ResponseBody
//    public Object audit(@RequestParam Integer tCompanyId,Integer type,String remark) {
//        TCompany tCompany = tCompanyService.selectById(tCompanyId);
//        if(type==1){
//            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            try {
//                Date parse = simpleDateFormat.parse(remark);
//                tCompany.setExpirationTime(parse);
//
//
//            } catch (ParseException e) {
//                e.printStackTrace();
//                return new ErrorTip(5010, "时间格式错误!");
//            }
//            tCompany.setStatus(1);
//        }else if(type==2){
//            tCompany.setStatus(2);
//            tCompany.setRemark(remark);
//        }
//        tCompanyService.updateById(tCompany);
//        return SUCCESS_TIP;
//    }
    /**
     * 修改
@@ -248,79 +247,79 @@
        return new SuccessTip(objects);
    }
    @ApiOperation(value = "根据卡车公司id获取卡车公司费用设置",notes="根据卡车公司id获取卡车公司费用设置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
    })
    @GetMapping(value = "/getCompanySetting/{tCompanyId}")
    @ResponseBody
    public Object getCompanySetting(@PathVariable("tCompanyId") Integer tCompanyId) {
        List<TCompanyFeeSetting> feeSettings = itCompanyFeeSettingService.selectList(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", tCompanyId));
        ArrayList<TCompanyFeeSettingVo> vos = new ArrayList<>();
        feeSettings.stream().forEach(e->{
            TCompanyFeeSettingVo tCompanyFeeSettingVo = new TCompanyFeeSettingVo();
            BeanUtil.copyProperties(e,tCompanyFeeSettingVo);
            vos.add(tCompanyFeeSettingVo);
        });
        vos.forEach(e->{
            if(("Pool chassis").equals(e.getSetName()) ||"wccp chassis".equals(e.getSetName()) || "trl-axle chassis".equals(e.getSetName())){
                e.setCost("Chassis fee");
            }
        });
        return new SuccessTip(vos);
    }
//    @ApiOperation(value = "根据卡车公司id获取卡车公司费用设置",notes="根据卡车公司id获取卡车公司费用设置")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
//    })
//    @GetMapping(value = "/getCompanySetting/{tCompanyId}")
//    @ResponseBody
//    public Object getCompanySetting(@PathVariable("tCompanyId") Integer tCompanyId) {
//        List<TCompanyFeeSetting> feeSettings = itCompanyFeeSettingService.selectList(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", tCompanyId));
//        ArrayList<TCompanyFeeSettingVo> vos = new ArrayList<>();
//        feeSettings.stream().forEach(e->{
//            TCompanyFeeSettingVo tCompanyFeeSettingVo = new TCompanyFeeSettingVo();
//            BeanUtil.copyProperties(e,tCompanyFeeSettingVo);
//            vos.add(tCompanyFeeSettingVo);
//        });
//        vos.forEach(e->{
//            if(("Pool chassis").equals(e.getSetName()) ||"wccp chassis".equals(e.getSetName()) || "trl-axle chassis".equals(e.getSetName())){
//                e.setCost("Chassis fee");
//            }
//        });
//        return new SuccessTip(vos);
//    }
    @ApiOperation(value = "卡车公司服务修改设置",notes="卡车公司服务修改设置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @GetMapping(value = "/updateSetting")
    @ResponseBody
    public Object updateSetting(TCompanySettingDto dto) {
        TCompany tCompany = tCompanyService.selectById(dto.getId());
        tCompany.setClass9(dto.getClass9());
        tCompany.setClass8(dto.getClass8());
        tCompany.setClass7(dto.getClass7());
        tCompany.setClass6(dto.getClass6());
        tCompany.setClass5(dto.getClass5());
        tCompany.setClass4(dto.getClass4());
        tCompany.setClass3(dto.getClass3());
        tCompany.setClass2(dto.getClass2());
        tCompany.setClass1(dto.getClass1());
        tCompany.setDg(dto.getDg());
        tCompany.setFr(dto.getFr());
        tCompany.setTk(dto.getTk());
        tCompany.setOt(dto.getOt());
        tCompany.setRh(dto.getRh());
        tCompany.setRf(dto.getRf());
        tCompany.setHc(dto.getHc());
        tCompany.setHq(dto.getHq());
        tCompany.setGp(dto.getGp());
        tCompany.setLanguage(dto.getLanguage());
        tCompany.setEld(dto.getEld());
        tCompany.setTwic(dto.getTwic());
        tCompany.setPrivateChassis(dto.getPrivateChassis());
        tCompany.setIsoTankDrayage(dto.getIsoTankDrayage());
        tCompany.setTankEndorsedDrayage(dto.getTankEndorsedDrayage());
        tCompany.setOpenTopDrayage(dto.getOpenTopDrayage());
        tCompany.setReeferDrayage(dto.getReeferDrayage());
        tCompany.setDryContainerDrayage(dto.getDryContainerDrayage());
        tCompany.setRailRampDrayage(dto.getRailRampDrayage());
        tCompany.setOceanPortDrayage(dto.getOceanPortDrayage());
        tCompany.setContainerSizes(dto.getContainerSizes());
        tCompany.setChains(dto.getChains());
        tCompany.setTransloadService(dto.getTransloadService());
        tCompany.setAmazon(dto.getAmazon());
        tCompany.setTsa(dto.getTsa());
        tCompany.setResidentialDelivery(dto.getResidentialDelivery());
        tCompany.setHouseholdGoods(dto.getHouseholdGoods());
        tCompany.setLiquor(dto.getLiquor());
        tCompany.setOverweightPermit(dto.getOverweightPermit());
        tCompany.setHAZMAT(dto.getHAZMAT());
        return tCompanyService.updateById(tCompany);
    }
//    @ApiOperation(value = "卡车公司服务修改设置",notes="卡车公司服务修改设置")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//    })
//    @GetMapping(value = "/updateSetting")
//    @ResponseBody
//    public Object updateSetting(TCompanySettingDto dto) {
//        TCompany tCompany = tCompanyService.selectById(dto.getId());
//        tCompany.setClass9(dto.getClass9());
//        tCompany.setClass8(dto.getClass8());
//        tCompany.setClass7(dto.getClass7());
//        tCompany.setClass6(dto.getClass6());
//        tCompany.setClass5(dto.getClass5());
//        tCompany.setClass4(dto.getClass4());
//        tCompany.setClass3(dto.getClass3());
//        tCompany.setClass2(dto.getClass2());
//        tCompany.setClass1(dto.getClass1());
//        tCompany.setDg(dto.getDg());
//        tCompany.setFr(dto.getFr());
//        tCompany.setTk(dto.getTk());
//        tCompany.setOt(dto.getOt());
//        tCompany.setRh(dto.getRh());
//        tCompany.setRf(dto.getRf());
//        tCompany.setHc(dto.getHc());
//        tCompany.setHq(dto.getHq());
//        tCompany.setGp(dto.getGp());
//        tCompany.setLanguage(dto.getLanguage());
//        tCompany.setEld(dto.getEld());
//        tCompany.setTwic(dto.getTwic());
//        tCompany.setPrivateChassis(dto.getPrivateChassis());
//        tCompany.setIsoTankDrayage(dto.getIsoTankDrayage());
//        tCompany.setTankEndorsedDrayage(dto.getTankEndorsedDrayage());
//        tCompany.setOpenTopDrayage(dto.getOpenTopDrayage());
//        tCompany.setReeferDrayage(dto.getReeferDrayage());
//        tCompany.setDryContainerDrayage(dto.getDryContainerDrayage());
//        tCompany.setRailRampDrayage(dto.getRailRampDrayage());
//        tCompany.setOceanPortDrayage(dto.getOceanPortDrayage());
//        tCompany.setContainerSizes(dto.getContainerSizes());
//        tCompany.setChains(dto.getChains());
//        tCompany.setTransloadService(dto.getTransloadService());
//        tCompany.setAmazon(dto.getAmazon());
//        tCompany.setTsa(dto.getTsa());
//        tCompany.setResidentialDelivery(dto.getResidentialDelivery());
//        tCompany.setHouseholdGoods(dto.getHouseholdGoods());
//        tCompany.setLiquor(dto.getLiquor());
//        tCompany.setOverweightPermit(dto.getOverweightPermit());
//        tCompany.setHAZMAT(dto.getHAZMAT());
//        return tCompanyService.updateById(tCompany);
//    }
}