| | |
| | | package com.stylefeng.guns.modular.system.controller; |
| | | |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.TCarriers; |
| | | import com.stylefeng.guns.modular.system.service.TCarriersService; |
| | | import com.stylefeng.guns.modular.system.utils.UserInfoUtil; |
| | | import com.stylefeng.guns.modular.system.utils.CargoQueryInteraceUtil; |
| | | import com.stylefeng.guns.modular.system.utils.InsertCargoDetailsWarpper; |
| | | import com.stylefeng.guns.modular.system.utils.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.utils.WoUtil; |
| | | import com.stylefeng.guns.modular.system.utils.tips.ErrorTip; |
| | | import com.stylefeng.guns.modular.system.utils.tips.SuccessTip; |
| | |
| | | @Autowired |
| | | private TCarriersService carriersService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | private String CARGO_LIST = "cargo_list:"; |
| | | |
| | | |
| | | /** |
| | | * 获取列表 |
| | |
| | | @ApiImplicitParam(name = "name", value = "powerUnitNumber", required = false, dataType = "String",paramType = "query"), |
| | | @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"), |
| | | @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"), |
| | | @ApiImplicitParam(name = "companyId", value = "companyId", required = true, dataType = "int",paramType = "query"), |
| | | }) |
| | | @GetMapping(value = "/list") |
| | | @ResponseBody |
| | | public Object list(String time,String name,int pageNumber,int pageSize) { |
| | | public Object list(String time,String name,int pageNumber,int pageSize,int companyId) { |
| | | Page<TCarriers> tCarriersPage = new Page<>(pageNumber, pageSize); |
| | | String sTime=null; |
| | | String eTime=null; |
| | | EntityWrapper<TCarriers> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("company_id",companyId); |
| | | wrapper.eq("remove",0); |
| | | if(ToolUtil.isNotEmpty(name)){ |
| | | wrapper.like("company_name",name).or().like("account",name); |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "卡车公司-添加承运商",notes="卡车公司-添加承运商") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | |
| | | @PostMapping(value = "/addCarriers") |
| | | @ResponseBody |
| | | public Object addCarriers(@RequestBody TCarriers tCarriers) { |
| | | tCarriers.setCompanyId(UserInfoUtil.getId()); |
| | | tCarriers.setCreateTime(new Date()); |
| | | carriersService.insert(tCarriers); |
| | | return new SuccessTip(); |
| | | } |
| | | |
| | | |
| | | // 根据输入框的输入信息,调用第三方接口获取数据 |
| | | @ApiOperation(value = "查询卡车公司",notes="查询卡车公司") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | @PostMapping(value = "/query") |
| | | @ResponseBody |
| | | public Object queryCargoData(String MCNumber,String USdot){ |
| | | if(ToolUtil.isEmpty(MCNumber)&&ToolUtil.isEmpty(USdot)){ |
| | | return new SuccessTip(); |
| | | } |
| | | String value = ""; |
| | | InsertCargoDetailsWarpper insertCargoDetailsWarpper = new InsertCargoDetailsWarpper(); |
| | | try { |
| | | |
| | | InsertCargoDetailsWarpper data = CargoQueryInteraceUtil.getData(MCNumber,USdot); |
| | | value = JSON.toJSONString(data); |
| | | JSONObject o = JSONObject.parseObject(value); |
| | | if (ToolUtil.isNotEmpty(o)){ |
| | | insertCargoDetailsWarpper.setUSDot(o.get("uSDot").toString()); |
| | | insertCargoDetailsWarpper.setAddress(o.get("address").toString()); |
| | | insertCargoDetailsWarpper.setDrivers(o.get("drivers").toString().equals("null")?"0":o.get("drivers").toString()); |
| | | insertCargoDetailsWarpper.setCompanyName(o.get("companyName").toString()); |
| | | insertCargoDetailsWarpper.setPowerUnits(o.get("powerUnits").toString()); |
| | | insertCargoDetailsWarpper.setInspection(o.get("inspection").toString()); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ERROR; |
| | | } |
| | | return new SuccessTip(insertCargoDetailsWarpper); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "卡车公司-承运商详情",notes="卡车公司-承运商详情") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int",paramType = "query"), |
| | | }) |
| | | @PostMapping(value = "/carriersInfo") |
| | | @ResponseBody |
| | | public Object carriersInfo( int id) { |
| | | TCarriers tCarriers = carriersService.selectById(id); |
| | | return new SuccessTip(tCarriers); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "卡车公司-编辑承运商",notes="卡车公司-编辑承运商") |
| | | @ApiImplicitParams({ |
| | |
| | | }) |
| | | @RequestMapping(value = "/exportCarriers", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | public Object exportCarriers(HttpServletRequest request, MultipartFile file) { |
| | | public Object exportCarriers(HttpServletRequest request, MultipartFile file,int id) { |
| | | try { |
| | | Workbook book = WoUtil.ImportFile(file); |
| | | Sheet sh = book.getSheetAt(0); //获取到第一个表 |
| | |
| | | continue; |
| | | } |
| | | TCarriers tCarriers = new TCarriers(); |
| | | tCarriers.setCompanyId(UserInfoUtil.getId()); |
| | | tCarriers.setCompanyId(id); |
| | | tCarriers.setRemove(0); |
| | | tCarriers.setCompanyName(zero); |
| | | tCarriers.setScacCode(one); |
| | |
| | | tCarriers.setPassword(SecureUtil.md5(seventeen)); |
| | | list.add(tCarriers); |
| | | } |
| | | carriersService.insertBatch(list); |
| | | if(list.size()>0){ |
| | | |
| | | carriersService.insertBatch(list); |
| | | } |
| | | return new SuccessTip(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |