package com.stylefeng.guns.modular.system.controller.general; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; 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.common.constant.factory.PageFactory; import com.stylefeng.guns.core.log.LogObjectHolder; import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.util.DateUtil; import com.stylefeng.guns.core.util.SinataUtil; import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.GaoDeMapUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import java.math.BigDecimal; import java.util.*; /** * 城市管理控制器 * * @author fengshuonan * @Date 2020-06-02 11:40:31 */ @Controller @RequestMapping("/tOpenCity") public class TOpenCityController extends BaseController { private String PREFIX = "/system/tOpenCity/"; @Autowired private ITOpenCityService tOpenCityService; @Autowired private ITRegionService tRegionService; @Autowired private ITOpenCityBusinessService tOpenCityBusinessService; @Autowired private ITSysReformistService tSysReformistService; @Autowired private ITSysIntegralService tSysIntegralService; @Autowired private ITSysFaceDistinguishService tSysFaceDistinguishService; @Autowired private ITSysPushOrderService tSysPushOrderService; @Autowired private ITSysPushTypeService tSysPushTypeService; @Autowired private ITSysCancleOrderService tSysCancleOrderService; @Autowired private ITPhoneService tPhoneService; @Autowired private ITCompanyService companyService; @Autowired private ISpellOrderRuleService spellOrderRuleService; @Autowired private IShowModularService showModularService; @Autowired private ITSysTimeoutMoneyService timeoutMoneyService; @Autowired private ITSysWithdrawalPoundageService sysWithdrawalPoundageService; @Autowired private ITDriverPayDaysService driverPayDaysService; /** * 跳转到城市管理首页 */ @RequestMapping("") public String index() { return PREFIX + "tOpenCity.html"; } /** * 跳转到添加城市管理 */ @RequestMapping("/tOpenCity_add") public String tOpenCityAdd(Model model) { List provinceList = tRegionService.selectList(new EntityWrapper().eq("parent_id", 0)); model.addAttribute("provinceList",provinceList); return PREFIX + "tOpenCity_add.html"; } /** * 跳转到修改城市管理 */ @RequestMapping("/tOpenCity_update/{tOpenCityId}") public String tOpenCityUpdate(@PathVariable Integer tOpenCityId, Model model) { TOpenCity tOpenCity = tOpenCityService.selectById(tOpenCityId); model.addAttribute("item",tOpenCity); LogObjectHolder.me().set(tOpenCity); //省 List provinceList = tRegionService.selectList(new EntityWrapper().eq("parent_id", 0)); model.addAttribute("provinceList",provinceList); //市 List cityList = tRegionService.selectList(new EntityWrapper().eq("parent_id", tOpenCity.getAreaId())); model.addAttribute("cityList",cityList); //区 List areaList = tRegionService.selectList(new EntityWrapper().eq("parent_id", tOpenCity.getCityId())); model.addAttribute("areaList",areaList); //经营业务 List> businessList = tOpenCityService.getBusinessByCityId(tOpenCityId); model.addAttribute("businessList",businessList); return PREFIX + "tOpenCity_edit.html"; } /** * 跳转到基础配置 * @param tOpenCityId * @param model * @return */ @RequestMapping("/tOpenCity_systemSet/{tOpenCityId}") public String tOpenCity_systemSet(@PathVariable Integer tOpenCityId, Model model){ model.addAttribute("openCityId", tOpenCityId);//改派设置 TSysReformist reformist = tSysReformistService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId)); model.addAttribute("reformist",reformist); //积分设置 TSysIntegral integral = tSysIntegralService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId)); model.addAttribute("integral",integral); //人脸识别 TSysFaceDistinguish faceDistinguish = tSysFaceDistinguishService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId)); model.addAttribute("faceDistinguish",faceDistinguish); //快车推单(第一轮) TSysPushOrder zcOne = tSysPushOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("pushType", 1).eq("type", 1)); model.addAttribute("zcOne",zcOne); //快车推单(第二轮) TSysPushOrder zcTwo = tSysPushOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("pushType", 1).eq("type", 2)); model.addAttribute("zcTwo",zcTwo); //快车推单(第三轮) TSysPushOrder zcThree = tSysPushOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("pushType", 1).eq("type", 3)); model.addAttribute("zcThree",zcThree); //出租车推单(第一轮) TSysPushOrder czcOne = tSysPushOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("pushType", 2).eq("type", 1)); model.addAttribute("czcOne",czcOne); //出租车推单(第二轮) TSysPushOrder czcTwo = tSysPushOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("pushType", 2).eq("type", 2)); model.addAttribute("czcTwo",czcTwo); //出租车推单(第三轮) TSysPushOrder czcThree = tSysPushOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("pushType", 2).eq("type", 3)); model.addAttribute("czcThree",czcThree); //普通取消设置(快车) TSysCancleOrder ptCancel1 = tSysCancleOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 1).eq("orderType", 1)); model.addAttribute("ptCancel1",ptCancel1); //普通取消设置(出租车) TSysCancleOrder ptCancel2 = tSysCancleOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 1).eq("orderType", 2)); model.addAttribute("ptCancel2",ptCancel2); //普通取消设置(跨城出行) TSysCancleOrder ptCancel3 = tSysCancleOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 1).eq("orderType", 3)); model.addAttribute("ptCancel3",ptCancel3); //预约取消设置(快车) TSysCancleOrder yyCancel1 = tSysCancleOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 2).eq("orderType", 1)); model.addAttribute("yyCancel1",yyCancel1); //预约取消设置(出租车) TSysCancleOrder yyCancel2 = tSysCancleOrderService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 2).eq("orderType", 2)); model.addAttribute("yyCancel2",yyCancel2); //拼车设置 SpellOrderRule spellOrderRule = spellOrderRuleService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId)); model.addAttribute("spellOrderRule", null == spellOrderRule ? "" : JSONObject.parseObject(spellOrderRule.getContent())); //报警电话 TPhone phone1 = tPhoneService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 1)); model.addAttribute("phone1",phone1); //客服电话 TPhone phone2 = tPhoneService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 2)); model.addAttribute("phone2",phone2); //客服电话 TPhone phone3 = tPhoneService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 3)); model.addAttribute("phone3",phone3); //95128电召电话 TPhone phone4 = tPhoneService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 4)); model.addAttribute("phone4",phone4); //招聘电话 TPhone phone5 = tPhoneService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId).eq("type", 5)); model.addAttribute("phone5",phone5); //节假日服务费 BigDecimal holidayFee = companyService.selectById(ShiroKit.getUser().getObjectId()).getHolidayFee(); model.addAttribute("holidayFee",holidayFee); //超时扣款 TSysTimeoutMoney tSysTimeoutMoney = timeoutMoneyService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId)); model.addAttribute("tSysTimeoutMoney",tSysTimeoutMoney); //提现手续费 TSysWithdrawalPoundage tSysWithdrawalPoundage = sysWithdrawalPoundageService.selectOne(null); model.addAttribute("tSysWithdrawalPoundage",tSysWithdrawalPoundage); //模块管理 List showModulars = showModularService.selectList(new EntityWrapper().eq("openCityId", tOpenCityId)); Map map = new HashMap<>(); for (ShowModular showModular : showModulars) { switch (showModular.getType()){ case 1: map.put("sjzp1", showModular.getUserShow()); map.put("sjzp2", showModular.getDriverShow()); break; case 2: map.put("zuc1", showModular.getUserShow()); map.put("zuc2", showModular.getDriverShow()); break; case 3: map.put("mc1", showModular.getUserShow()); map.put("mc2", showModular.getDriverShow()); break; case 4: map.put("czgrcl1", showModular.getUserShow()); map.put("czgrcl2", showModular.getDriverShow()); break; case 5: map.put("mac1", showModular.getUserShow()); map.put("mac2", showModular.getDriverShow()); break; case 6: map.put("sjzx1", showModular.getUserShow()); map.put("sjzx2", showModular.getDriverShow()); break; case 7: map.put("dck1", showModular.getUserShow()); map.put("dck2", showModular.getDriverShow()); break; } } model.addAttribute("showModulars", map); TDriverPayDays tDriverPayDays = driverPayDaysService.selectOne(null); if(tDriverPayDays!=null){ model.addAttribute("driverDay", tDriverPayDays.getDay()); }else { model.addAttribute("driverDay", ""); } TSysPushType sysPushType = tSysPushTypeService.selectOne(new EntityWrapper().eq("openCityId", tOpenCityId)); if (sysPushType != null){ model.addAttribute("pushType", sysPushType.getPushType()); }else { model.addAttribute("pushType", 1); } return PREFIX + "tSysReformist.html"; } @RequestMapping(value = "/change") @ResponseBody public Object change(@RequestParam Integer id) { List list = new ArrayList<>(); if (SinataUtil.isNotEmpty(id)){ list = tRegionService.selectList(new EntityWrapper().eq("parent_id", id)); } return list; } /** * 获取城市管理列表 */ @RequestMapping(value = "/list") @ResponseBody public Object list(String insertTime,String condition) { String beginTime = null; String endTime = null; if (SinataUtil.isNotEmpty(insertTime)){ String[] timeArray = insertTime.split(" - "); beginTime = timeArray[0]; endTime = timeArray[1]; } Page> page = new PageFactory>().defaultPage(); page.setRecords(tOpenCityService.getOpenCityList(page,beginTime,endTime,condition)); return super.packForBT(page); } /** * 新增城市管理 */ @RequestMapping(value = "/add") @ResponseBody public Object add(TOpenCity tOpenCity,@RequestParam String businessTypeStr,Integer areaId,Integer cityId,Integer provinceId) { //获取code if (SinataUtil.isNotEmpty(areaId)){ TRegion area = tRegionService.selectById(areaId); tOpenCity.setCode(area.getCode()); } if (SinataUtil.isNotEmpty(cityId)){ TRegion city = tRegionService.selectById(cityId); tOpenCity.setCode(city.getCode()); } if (SinataUtil.isNotEmpty(provinceId)){ TRegion province = tRegionService.selectById(provinceId); tOpenCity.setCode(province.getCode()); } tOpenCity.setAreaId(areaId); tOpenCity.setCityId(cityId); tOpenCity.setProvinceId(provinceId); //获取经纬度 String address = tOpenCity.getAreaName(); if (SinataUtil.isNotEmpty(tOpenCity.getCityName())){ address+=tOpenCity.getCityName(); } if (SinataUtil.isNotEmpty(tOpenCity.getProvinceName())) { address += tOpenCity.getProvinceName(); } JSONObject positionObj = GaoDeMapUtil.getLngAndLat(address); String longitude = positionObj.getString("longitude"); String latitude = positionObj.getString("latitude"); tOpenCity.setLon(Double.valueOf(longitude)); tOpenCity.setLat(Double.valueOf(latitude)); tOpenCity.setInsertTime(new Date()); tOpenCity.setInsertUser(ShiroKit.getUser().getId()); tOpenCityService.insert(tOpenCity); //添加经营业务 testJSONStrToJSONArray(businessTypeStr, tOpenCity.getId()); return SUCCESS_TIP; } public void testJSONStrToJSONArray(String subArr,Integer tOpenCityId){ JSONArray jsonArray = JSON.parseArray(subArr); int size = jsonArray.size(); for (int i = 0; i < size; i++){ JSONObject jsonObject = jsonArray.getJSONObject(i); TOpenCityBusiness business = new TOpenCityBusiness(); if (SinataUtil.isNotEmpty(jsonObject.getInteger("busId")) && jsonObject.getInteger("busId") != 0) { business = tOpenCityBusinessService.selectById(jsonObject.getInteger("busId")); business.setUpdateTime(new Date()); business.setUpdateUser(ShiroKit.getUser().getId()); business.setFlag("2"); }else { business.setInsertTime(DateUtil.parse(jsonObject.getString("time") + " 00:00:00", "yyyy-MM-dd HH:mm:ss")); business.setInsertUser(ShiroKit.getUser().getId()); } business.setOpenCityId(tOpenCityId); String type = jsonObject.getString("type"); Integer businessType = 0; if ("快车".equals(type)){ businessType = 1; }else if ("出租车".equals(type)){ businessType = 2; }else if ("跨城出行".equals(type)){ businessType = 3; }else if ("跨城小件物流".equals(type)){ businessType = 5; }else if ("同城小件物流".equals(type)){ businessType = 4; }else if ("包车".equals(type)){ businessType = 6; }else if ("顺风车".equals(type)){ businessType = 8; }else if ("代驾".equals(type)){ businessType = 9; }else{ businessType = 7; } business.setBusinessType(businessType); business.setSort(jsonObject.getInteger("sort")); if (SinataUtil.isNotEmpty(jsonObject.getInteger("busId")) && jsonObject.getInteger("busId") != 0){ tOpenCityBusinessService.updateById(business); }else{ tOpenCityBusinessService.insert(business); } } } /** * 删除城市管理 */ @RequestMapping(value = "/delete") @ResponseBody public Object delete(@RequestParam Integer tOpenCityId) { TOpenCity tOpenCity = tOpenCityService.selectById(tOpenCityId); tOpenCity.setFlag("3"); tOpenCityService.updateById(tOpenCity); return SUCCESS_TIP; } /** * 修改城市管理 */ @RequestMapping(value = "/update") @ResponseBody public Object update(TOpenCity tOpenCity,@RequestParam String businessTypeStr,Integer areaId,Integer cityId,Integer provinceId) { if (SinataUtil.isNotEmpty(areaId)){ TRegion area = tRegionService.selectById(areaId); tOpenCity.setCode(area.getCode()); } if (SinataUtil.isNotEmpty(cityId)){ TRegion city = tRegionService.selectById(cityId); tOpenCity.setCode(city.getCode()); } if (SinataUtil.isNotEmpty(provinceId)){ TRegion province = tRegionService.selectById(provinceId); tOpenCity.setCode(province.getCode()); } if (SinataUtil.isEmpty(areaId)){ tOpenCity.setAreaId(0); tOpenCity.setAreaName(""); }else{ tOpenCity.setAreaId(areaId); } if (SinataUtil.isEmpty(cityId)){ tOpenCity.setCityId(0); tOpenCity.setCityName(""); }else{ tOpenCity.setCityId(cityId); } if (SinataUtil.isEmpty(provinceId)){ tOpenCity.setProvinceId(0); tOpenCity.setProvinceName(""); }else{ tOpenCity.setProvinceId(provinceId); } //获取经纬度 String address = tOpenCity.getAreaName(); if (SinataUtil.isNotEmpty(tOpenCity.getCityName())){ address += tOpenCity.getCityName(); } if (SinataUtil.isNotEmpty(tOpenCity.getProvinceName())) { address += tOpenCity.getProvinceName(); } JSONObject positionObj = GaoDeMapUtil.getLngAndLat(address); String longitude = positionObj.getString("longitude"); String latitude = positionObj.getString("latitude"); tOpenCity.setLon(Double.valueOf(longitude)); tOpenCity.setLat(Double.valueOf(latitude)); tOpenCity.setUpdateTime(new Date()); tOpenCity.setUpdateUser(ShiroKit.getUser().getId()); tOpenCityService.updateById(tOpenCity); //删除经营业务 TOpenCityBusiness business = new TOpenCityBusiness(); business.setFlag("3"); tOpenCityBusinessService.update(business, new EntityWrapper().eq("openCityId", tOpenCity.getId())); //添加经营业务 testJSONStrToJSONArray(businessTypeStr, tOpenCity.getId()); return SUCCESS_TIP; } /** * 城市管理详情 */ @RequestMapping(value = "/detail/{tOpenCityId}") @ResponseBody public Object detail(@PathVariable("tOpenCityId") Integer tOpenCityId) { return tOpenCityService.selectById(tOpenCityId); } }