package com.stylefeng.guns.modular.system.controller; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.plugins.Page; import com.stylefeng.guns.core.base.controller.BaseController; import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.ITCompanyFeeSettingService; import com.stylefeng.guns.modular.system.service.ITCompanyService; import com.stylefeng.guns.modular.system.service.ITCompanyServiceService; import com.stylefeng.guns.modular.system.utils.tips.ErrorTip; import com.stylefeng.guns.modular.system.utils.tips.SuccessTip; 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.stereotype.Controller; import org.springframework.web.bind.annotation.*; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * 控制器 * * @author fengshuonan * @Date 2023-01-30 16:34:16 */ @Controller @Api(tags = "卡车公司") @RequestMapping("/api/tCompany") public class TCompanyController extends BaseController { @Autowired private ITCompanyService tCompanyService; @Autowired private ITCompanyFeeSettingService itCompanyFeeSettingService; @Autowired private ITCompanyServiceService itCompanyServiceService; // /** // * 获取列表 // */ // @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 tCompanyVoPage = new Page<>(pageNumber, pageSize); // List 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 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 companies = tCompanyService.selectList(new EntityWrapper().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 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....."), }) @PostMapping(value = "/update") @ResponseBody public Object update(@RequestBody TCompanyDto tCompany) { try { List companies = tCompanyService.selectList(new EntityWrapper().eq("account", tCompany.getAccount()).ne("id",tCompany.getId())); if(companies.size()>0){ return new ErrorTip(5002,"Account already exists"); } TCompany company = new TCompany(); BeanUtil.copyProperties(tCompany,company); tCompanyService.updateById(company); itCompanyServiceService.updateBatchById(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"), }) @GetMapping(value = "/detail/{tCompanyId}") @ResponseBody public Object detail(@PathVariable("tCompanyId") Integer tCompanyId) { TCompanyDto tCompanyDto = new TCompanyDto(); TCompany company = tCompanyService.selectById(tCompanyId); BeanUtil.copyProperties(company,tCompanyDto); List companyServiceList = itCompanyServiceService.selectList(new EntityWrapper().eq("company_id", tCompanyId).eq("type",0)); tCompanyDto.setList(companyServiceList); return new SuccessTip(tCompanyDto); } /** * 详情 */ @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"), }) @GetMapping(value = "/detailOne/{tCompanyId}") @ResponseBody public Object detailOne(@PathVariable("tCompanyId") Integer tCompanyId) { ArrayList> objects = new ArrayList<>(); List companyServiceList = itCompanyServiceService.selectList(new EntityWrapper().eq("company_id", tCompanyId).eq("type",1)); List companyServiceListOne = itCompanyServiceService.selectList(new EntityWrapper().eq("company_id", tCompanyId).eq("type",2)); objects.add(companyServiceList); objects.add(companyServiceListOne); 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 feeSettings = itCompanyFeeSettingService.selectList(new EntityWrapper().eq("company_id", tCompanyId)); // ArrayList 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); // } }