use of com.itrus.portal.db.SysRegion in project portal by ixinportal.
the class SysRegionController method getTreeInfo.
// 树形结构数据的获取
@RequestMapping(value = "/srTree")
@ResponseBody
public List<Map<String, Object>> getTreeInfo(Long id, String name, Integer level) {
List<Map<String, Object>> retList = new ArrayList<Map<String, Object>>();
Map<String, Object> noteMap = new HashMap<String, Object>();
SysRegionExample sysRegionExample = new SysRegionExample();
SysRegionExample.Criteria srCriteria = sysRegionExample.createCriteria();
// 若id为null,则赋值为根节点id
if (id == null) {
srCriteria.andParentIdEqualTo(0l);
sysRegionExample.setLimit(1);
SysRegion parentSR = sqlSession.selectOne("com.itrus.portal.db.SysRegionMapper.selectByExample", sysRegionExample);
id = parentSR.getId();
noteMap.put("open", true);
noteMap.put("id", parentSR.getId());
noteMap.put("name", parentSR.getNameCn());
}
// 查询子节点
sysRegionExample.clear();
sysRegionExample.setLimit(null);
srCriteria = sysRegionExample.createCriteria();
srCriteria.andParentIdEqualTo(id);
Map<Long, SysRegion> childSR = sqlSession.selectMap("com.itrus.portal.db.SysRegionMapper.selectByExample", sysRegionExample, "id");
// 若没有子节点,直接返回
if (childSR == null || childSR.isEmpty()) {
// 若为根节点加载,则将根节点信息返回
if (!noteMap.isEmpty()) {
// 便于进行异步更新
noteMap.put("isParent", false);
retList.add(noteMap);
}
return retList;
}
// 查询子节点是否包含下级节点
sysRegionExample.clear();
srCriteria = sysRegionExample.createCriteria();
srCriteria.andParentIdIn(new ArrayList<Long>(childSR.keySet()));
Map<Long, Object> childNumMap = sqlSession.selectMap("com.itrus.portal.db.SysRegionMapper.selectChildNumByExample", sysRegionExample, "parentId");
// 组装子节点信息
List<Map<String, Object>> childList = new ArrayList<Map<String, Object>>();
// 对节点按照行政区代码顺序排序
List<SysRegion> regionList = sysRegionService.sortRegionMap(childSR);
for (SysRegion sr : regionList) {
Map<String, Object> childMap = new HashMap<String, Object>();
childMap.put("id", sr.getId());
childMap.put("name", sr.getNameCn());
if (childNumMap != null && childNumMap.containsKey(sr.getId()))
childMap.put("isParent", true);
childList.add(childMap);
}
// 如果是加载根节点,则返回根节点信息和子节点信息,否则只返回子节点信息
if (!noteMap.isEmpty()) {
noteMap.put("isParent", true);
noteMap.put("children", childList);
retList.add(noteMap);
} else
retList = childList;
return retList;
}
use of com.itrus.portal.db.SysRegion in project portal by ixinportal.
the class SysRegionController method deleteSysRegion.
/**
* 删除行政区
* @param id
* @param sourceId 触发页面 0:列表页面;1:详情页面; 默认为列表页面
* @param model
* @return
*/
@RequestMapping(value = "/{pid}/{type}/{id}", method = RequestMethod.DELETE)
public String deleteSysRegion(@PathVariable("id") Long id, @PathVariable("pid") Long pid, @PathVariable("type") Integer type, @RequestParam(value = "fromId", required = false) Integer sourceId, RedirectAttributesModelMap model) {
String retUrl = "redirect:/sysregion/list?parentId=" + pid + "&type=" + type;
try {
SysRegion sysRegion = sysRegionService.delRegion(id);
// 删除成功标记,用于刷新树
model.addFlashAttribute("reNode", 1);
model.addFlashAttribute("errMsg", "成功删除行政区【" + sysRegion.getNameCn() + "】");
retUrl = "redirect:/sysregion/list?parentId=" + sysRegion.getParentId() + "&type=" + sysRegion.getType();
LogUtil.adminlog(sqlSession, "删除行政区", "删除行政区【" + sysRegion.getNameCn() + "】,代码为【" + sysRegion.getCode() + "】");
} catch (ServiceDelException e) {
model.addFlashAttribute("errMsg", e.getMessage());
} catch (Exception e) {
e.printStackTrace();
model.addFlashAttribute("errMsg", e.getMessage());
}
if (!model.getFlashAttributes().containsKey("reNode") && sourceId != null && 1 == sourceId) {
retUrl = "redirect:/sysregion/" + id;
}
return retUrl;
}
use of com.itrus.portal.db.SysRegion in project portal by ixinportal.
the class SysRegionService method getRegionByCode.
/**
* 根据行政区代码获取行政区信息
* @param code
* @return
*/
public SysRegion getRegionByCode(String code) {
SysRegionExample sysRegionExample = new SysRegionExample();
SysRegionExample.Criteria srCriteria = sysRegionExample.createCriteria();
srCriteria.andCodeEqualTo(code);
sysRegionExample.setLimit(1);
SysRegion region = sqlSession.selectOne("com.itrus.portal.db.SysRegionMapper.selectByExample", sysRegionExample);
return region;
}
use of com.itrus.portal.db.SysRegion in project portal by ixinportal.
the class SysRegionService method delRegion.
/**
* 删除行政区
* @return 删除成功返回删除对象,否则返回null
*/
public SysRegion delRegion(Long id) throws ServiceDelException {
SysRegion sysRegion = sqlSession.selectOne("com.itrus.portal.db.SysRegionMapper.selectByPrimaryKey", id);
if (sysRegion == null) {
throw new ServiceDelException("不存在将要删除的行政区信息");
}
SysRegionExample sysRegionExample = new SysRegionExample();
SysRegionExample.Criteria srCriteria = sysRegionExample.createCriteria();
srCriteria.andParentIdEqualTo(id);
Integer num = sqlSession.selectOne("com.itrus.portal.db.SysRegionMapper.countByExample", sysRegionExample);
// 若包含子节点,不允许删除
if (num != null && num > 0) {
throw new ServiceDelException("无法删除存在下级的行政区");
}
sqlSession.delete("com.itrus.portal.db.SysRegionMapper.deleteByPrimaryKey", id);
return sysRegion;
}
use of com.itrus.portal.db.SysRegion in project portal by ixinportal.
the class PsCourierController method show.
// 显示详情
@RequestMapping(value = "show/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
Map param = new HashMap();
param.put("id", id);
// 管理员项目权限
Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
param.put("hasProjects", Arrays.asList(projectsOfAdmin));
Map bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPsCourier", param);
if (null == bill || bill.isEmpty()) {
uiModel.addAttribute("errorMsg", "未找到该订单");
return "status403";
}
uiModel.addAttribute("bill", bill);
/*UserInfoExample userinfoex = new UserInfoExample();
UserInfoExample.Criteria userc = userinfoex.createCriteria();
userc.andIdEqualTo(bill.getUniqueId());
UserInfo userinfo = sqlSession.selectOne(
"com.itrus.portal.db.UserInfoMapper.selectByExample",userinfoex);
uiModel.addAttribute("userinfo", userinfo);*/
/*EnterpriseExample enterpriseex = new EnterpriseExample();
EnterpriseExample.Criteria entc = enterpriseex.createCriteria();
Enterprise enterprise = sqlSession.selectOne(
"com.itrus.portal.db.EnterpriseMapper.selectByExample",enterpriseex);
uiModel.addAttribute("enterprise", enterprise);
CourierExample courierex = new CourierExample();
Map<Long, Courier> couriermap = sqlSession.selectMap(
"com.itrus.portal.db.CourierMapper.selectByExample",
courierex, "id");
uiModel.addAttribute("couriermap", couriermap);
DeliveryExample deliveryex = new DeliveryExample();
Map<Long, Delivery> deliverymap = sqlSession.selectMap(
"com.itrus.portal.db.DeliveryMapper.selectByExample",
deliveryex, "id");
uiModel.addAttribute("deliverymap", deliverymap);
ProductExample productex = new ProductExample();
Map<Long, Product> productmap = sqlSession.selectMap(
"com.itrus.portal.db.ProductMapper.selectByExample",
productex, "id");
uiModel.addAttribute("productmap", productmap);
*/
SysRegionExample sysregionex = new SysRegionExample();
List sysregionexall = sqlSession.selectList("com.itrus.portal.db.SysRegionMapper.selectByExample", sysregionex);
uiModel.addAttribute("sysregions", sysregionexall);
/*CourierInfoExample courierinfoex = new CourierInfoExample();
Map<Long, CourierInfo> courierinfomap = sqlSession.selectMap(
"com.itrus.portal.db.CourierInfoMapper.selectByExample",
productex, "id");*/
List courierexall = sqlSession.selectList("com.itrus.portal.db.CourierMapper.selectTypeByCourier", bill.get("de_courier"));
uiModel.addAttribute("courierexall", courierexall);
SysRegion sys = (SysRegion) sysregionexall.get(100);
int num = sys.getParentIds().split(",").length;
List<Map> courierinfoall = sqlSession.selectList("com.itrus.portal.db.CourierInfoMapper.selectItemsByCourierInfo", bill.get("id"));
// 判断有没有已经快递过的物品
int itemsnum = 0;
int itemsnums = 0;
if (courierinfoall == null || courierinfoall.size() == 0) {
itemsnum = 0;
itemsnums = 0;
} else {
itemsnum = 1;
itemsnums = Integer.parseInt(courierinfoall.get(0).get("courier_items").toString());
uiModel.addAttribute("courierinfoalls", courierinfoall);
}
uiModel.addAttribute("itemsnum", itemsnum);
uiModel.addAttribute("itemsnums", itemsnums);
return "pscourier/show";
}
Aggregations