| | |
| | | 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.dao.TOpenCitySiteMapper; |
| | | import com.stylefeng.guns.modular.system.model.TOpenCityBusiness; |
| | | import com.stylefeng.guns.modular.system.model.TOpenCitySite; |
| | | import com.stylefeng.guns.modular.system.model.TRegion; |
| | | import com.stylefeng.guns.modular.system.service.ITOpenCityBusinessService; |
| | | import com.stylefeng.guns.modular.system.service.ITRegionService; |
| | |
| | | import com.stylefeng.guns.modular.system.model.TOpenCity; |
| | | import com.stylefeng.guns.modular.system.service.ITOpenCityService; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * 城市管理控制器 |
| | |
| | | |
| | | @Autowired |
| | | private ITOpenCityBusinessService tOpenCityBusinessService; |
| | | |
| | | @Autowired |
| | | private TOpenCitySiteMapper tOpenCitySiteMapper; |
| | | /** |
| | | * 跳转到城市管理首页 |
| | | */ |
| | |
| | | TOpenCity tOpenCity = tOpenCityService.selectById(tOpenCityId); |
| | | model.addAttribute("item",tOpenCity); |
| | | LogObjectHolder.me().set(tOpenCity); |
| | | |
| | | //省 |
| | | List<TRegion> provinceList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | model.addAttribute("provinceList",provinceList); |
| | |
| | | //经营业务 |
| | | List<Map<String,Object>> businessList = tOpenCityService.getBusinessByCityId(tOpenCityId); |
| | | model.addAttribute("businessList",businessList); |
| | | // 机场/动车站点 |
| | | List<TOpenCitySite> siteList = tOpenCitySiteMapper.selectList(new EntityWrapper<TOpenCitySite>() |
| | | .eq("openCityId", tOpenCityId) |
| | | .ne("flag",3)); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd"); |
| | | for (TOpenCitySite openCitySite : siteList) { |
| | | String format = simpleDateFormat.format(openCitySite.getInsertTime()); |
| | | openCitySite.setInsertTime1(format); |
| | | } |
| | | model.addAttribute("siteList",siteList); |
| | | return PREFIX + "tOpenCity_edit.html"; |
| | | } |
| | | |
| | |
| | | */ |
| | | @RequestMapping(value = "/add") |
| | | @ResponseBody |
| | | public Object add(TOpenCity tOpenCity,@RequestParam String businessTypeStr,Integer areaId,Integer cityId,Integer provinceId) { |
| | | public Object add(TOpenCity tOpenCity,@RequestParam String businessTypeStr, |
| | | String sites, |
| | | Integer areaId,Integer cityId, |
| | | Integer provinceId) { |
| | | //获取code |
| | | if (SinataUtil.isNotEmpty(areaId)){ |
| | | TRegion area = tRegionService.selectById(areaId); |
| | |
| | | |
| | | //添加经营业务 |
| | | testJSONStrToJSONArray(businessTypeStr,tOpenCity.getId()); |
| | | // 添加机场/动车站点 |
| | | JSONArray jsonArray = JSON.parseArray(sites); |
| | | int size = jsonArray.size(); |
| | | for (int i = 0; i < size; i++){ |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | TOpenCitySite openCitySite = new TOpenCitySite(); |
| | | openCitySite.setOpenCityId(tOpenCity.getId()); |
| | | String string = jsonObject.getString("lonAndLat"); |
| | | // 去除转义符 |
| | | String unescaped = string.replaceAll("& #40;", "(").replaceAll("& #41;", ")"); |
| | | // 提取括号中的内容 |
| | | Pattern pattern = Pattern.compile("\\(([^)]+)\\)"); |
| | | Matcher matcher = pattern.matcher(unescaped); |
| | | if (matcher.find()) { |
| | | String lonAndLat = matcher.group(1); |
| | | System.out.println("括号中的内容: " + lonAndLat); |
| | | // 使用逗号分割字符串 |
| | | String[] parts = lonAndLat.split(","); |
| | | // 提取需要的部分 |
| | | String lon = parts[0]; |
| | | String lat = parts[1]; |
| | | openCitySite.setLon(lon); |
| | | openCitySite.setLat(lat); |
| | | } |
| | | openCitySite.setFlag(1); |
| | | openCitySite.setName(jsonObject.getString("name")); |
| | | openCitySite.setInsertTime(DateUtil.parse(jsonObject.getString("time")+" 00:00:00","yyyy-MM-dd HH:mm:ss")); |
| | | tOpenCitySiteMapper.insert(openCitySite); |
| | | } |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | |
| | | */ |
| | | @RequestMapping(value = "/update") |
| | | @ResponseBody |
| | | public Object update(TOpenCity tOpenCity,@RequestParam String businessTypeStr,Integer areaId,Integer cityId,Integer provinceId) { |
| | | public Object update(TOpenCity tOpenCity,@RequestParam String businessTypeStr,Integer areaId,Integer cityId,Integer provinceId,String sites) { |
| | | if (SinataUtil.isNotEmpty(areaId)){ |
| | | TRegion area = tRegionService.selectById(areaId); |
| | | tOpenCity.setCode(area.getCode()); |
| | |
| | | tOpenCityBusinessService.update(business,new EntityWrapper<TOpenCityBusiness>().eq("openCityId",tOpenCity.getId())); |
| | | //添加经营业务 |
| | | testJSONStrToJSONArray(businessTypeStr,tOpenCity.getId()); |
| | | // TOpenCitySite openCitySite = new TOpenCitySite(); |
| | | // // 删除站点 |
| | | // tOpenCitySiteMapper.update(openCitySite,new EntityWrapper<TOpenCitySite>().eq("openCityId",tOpenCity.getId())); |
| | | List<TOpenCitySite> openCityId = tOpenCitySiteMapper.selectList(new EntityWrapper<TOpenCitySite>() |
| | | .eq("openCityId", tOpenCity.getId())); |
| | | for (TOpenCitySite openCitySite : openCityId) { |
| | | openCitySite.setFlag(3); |
| | | tOpenCitySiteMapper.updateById(openCitySite); |
| | | } |
| | | // 添加站点 |
| | | // 添加机场/动车站点 |
| | | JSONArray jsonArray = JSON.parseArray(sites); |
| | | int size = jsonArray.size(); |
| | | for (int i = 0; i < size; i++){ |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | String string = jsonObject.getString("lonAndLat"); |
| | | // 去除转义符 |
| | | String unescaped = string.replaceAll("& #40;", "(").replaceAll("& #41;", ")"); |
| | | // 提取括号中的内容 |
| | | Pattern pattern = Pattern.compile("\\(([^)]+)\\)"); |
| | | Matcher matcher = pattern.matcher(unescaped); |
| | | String lon = ""; |
| | | String lat = ""; |
| | | if (matcher.find()) { |
| | | String lonAndLat = matcher.group(1); |
| | | System.out.println("括号中的内容: " + lonAndLat); |
| | | // 使用逗号分割字符串 |
| | | String[] parts = lonAndLat.split(","); |
| | | // 提取需要的部分 |
| | | lon = parts[0]; |
| | | lat = parts[1]; |
| | | } |
| | | if (SinataUtil.isNotEmpty(jsonObject.getInteger("busId")) && jsonObject.getInteger("busId") != 0){ |
| | | // 修改 |
| | | TOpenCitySite openCitySite1 = tOpenCitySiteMapper.selectById(jsonObject.getInteger("busId")); |
| | | openCitySite1.setLon(lon); |
| | | openCitySite1.setLat(lat); |
| | | openCitySite1.setName(jsonObject.getString("name")); |
| | | openCitySite1.setFlag(2); |
| | | openCitySite1.setType(jsonObject.getInteger("siteType")); |
| | | tOpenCitySiteMapper.updateById(openCitySite1); |
| | | }else{ |
| | | // 新增 |
| | | TOpenCitySite openCitySite3 = new TOpenCitySite(); |
| | | openCitySite3.setOpenCityId(tOpenCity.getId()); |
| | | openCitySite3.setLon(lon); |
| | | openCitySite3.setLat(lat); |
| | | openCitySite3.setFlag(1); |
| | | openCitySite3.setName(jsonObject.getString("name")); |
| | | openCitySite3.setType(jsonObject.getInteger("siteType")); |
| | | openCitySite3.setInsertTime(DateUtil.parse(jsonObject.getString("time")+" 00:00:00","yyyy-MM-dd HH:mm:ss")); |
| | | tOpenCitySiteMapper.insert(openCitySite3); |
| | | } |
| | | |
| | | } |
| | | return SUCCESS_TIP; |
| | | } |
| | | |