Explorar el Código

添加酒店数据初始化处理

WIN-B904R0U0NNS\Administrator hace 2 años
padre
commit
7fe77da4bb

+ 4 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusDictController.java

@@ -216,7 +216,8 @@ public class BusDictController extends JeecgController<BusDict, IBusDictService>
 	  * @return
 	  */
 	 @RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
-	 public Result<List<BusDictTreeModel>> queryTreeList(@RequestParam(name = "ids", required = false) String ids) {
+	 public Result<List<BusDictTreeModel>> queryTreeList(@RequestParam(name = "ids", required = false) String ids
+	 ,@RequestParam(name = "hotelId", required = false) String hotelId) {
 		 Result<List<BusDictTreeModel>> result = new Result<>();
 		 try {
 			 // 从内存中读取
@@ -225,10 +226,10 @@ public class BusDictController extends JeecgController<BusDict, IBusDictService>
 //				list = sysDepartService.queryTreeList();
 //			}
 			 if(oConvertUtils.isNotEmpty(ids)){
-				 List<BusDictTreeModel> departList = busDictService.queryTreeList(ids);
+				 List<BusDictTreeModel> departList = busDictService.queryTreeList(ids,hotelId);
 				 result.setResult(departList);
 			 }else{
-				 List<BusDictTreeModel> list = busDictService.queryTreeList();
+				 List<BusDictTreeModel> list = busDictService.queryTreeList(hotelId);
 				 result.setResult(list);
 			 }
 			 result.setSuccess(true);

+ 3 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusDictItemController.java

@@ -308,9 +308,12 @@ public class BusDictItemController extends JeecgController<BusDictItem, IBusDict
 		 }
 		 List<BusDictItem> list = new ArrayList<>();
 		 String dictName = req.getParameter("dictName");
+		 String hotelId = req.getParameter("hotelId");
 		 if(oConvertUtils.isNotEmpty(dictName)){
 			 LambdaQueryWrapper<BusDict> queryDictWrapper = new LambdaQueryWrapper<>();
 			 queryDictWrapper.eq(BusDict::getDictName,dictName);
+			 queryDictWrapper.eq(BusDict::getTenantId,user.getRelTenantIds());
+			 queryDictWrapper.eq(BusDict::getHotelId,hotelId);
 			 BusDict busDict = busDictService.getOne(queryDictWrapper);
 
 			 if (busDict != null) {

+ 33 - 5
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusHotelController.java

@@ -1,9 +1,6 @@
 package org.jeecg.modules.business.controller;
 
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -28,7 +25,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 
 import org.jeecg.modules.base.service.BaseCommonService;
+import org.jeecg.modules.business.entity.BusDict;
 import org.jeecg.modules.business.entity.BusHotel;
+import org.jeecg.modules.business.service.IBusDictService;
 import org.jeecg.modules.business.service.IBusHotelService;
 import org.jeecg.modules.business.util.MapUtil;
 import org.jeecg.modules.system.entity.SysTenant;
@@ -68,6 +67,9 @@ public class BusHotelController extends JeecgController<BusHotel, IBusHotelServi
 	 @Autowired
 	 private ISysTenantService sysTenantService;
 
+	 @Autowired
+	 private IBusDictService busDictService;
+
 	/**
 	 * 分页列表查询
 	 *
@@ -118,8 +120,8 @@ public class BusHotelController extends JeecgController<BusHotel, IBusHotelServi
 		busHotel.setStatus(1);
 		busHotel.setDelFlag(CommonConstant.DEL_FLAG_0);
 		busHotel.setCheckStatus(0);
+		LoginUser user = TokenUtils.getAuthUser();
 		if(busHotel.getTenantId() == null || busHotel.getTenantId().equals("")){
-			LoginUser user = TokenUtils.getAuthUser();
 			if(user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")){
 				busHotel.setTenantId(user.getRelTenantIds());
 			} else {
@@ -127,6 +129,32 @@ public class BusHotelController extends JeecgController<BusHotel, IBusHotelServi
 			}
 		}
 		busHotelService.save(busHotel);
+
+		//添加酒店后需要初始化部分数据
+		//初始化系统设置-字典管理
+		LambdaQueryWrapper<BusDict> queryDict = new LambdaQueryWrapper<BusDict>();
+		queryDict.eq(BusDict::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
+		queryDict.eq(BusDict::getHotelId, "0");
+		queryDict.eq(BusDict::getTenantId, "0");
+		List<BusDict> listDict = busDictService.list(queryDict);
+		if (listDict != null && listDict.size() > 0){
+//			for (BusDict busDict : listDict) {
+//
+//			}
+			List<BusDict> batchDict = new ArrayList<>();
+			listDict.forEach( busDict -> {
+				BusDict newDict = busDict;
+				newDict.setTenantId(busHotel.getTenantId());
+				newDict.setHotelId(busHotel.getId());
+				batchDict.add(newDict);
+			});
+			busDictService.saveBatch(batchDict);
+		}
+
+		//初始化打印模板
+		//初始化参数设置
+
+
 		return Result.OK("添加成功!");
 	}
 

+ 2 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusDictService.java

@@ -18,11 +18,11 @@ public interface IBusDictService extends IService<BusDict> {
      * 查询所有字典信息,并分节点进行显示
      * @return
      */
-    List<BusDictTreeModel> queryTreeList();
+    List<BusDictTreeModel> queryTreeList(String hotelId);
     /**
      * 查询所有部门信息,并分节点进行显示
      * @param ids 多个部门id
      * @return
      */
-    List<BusDictTreeModel> queryTreeList(String ids);
+    List<BusDictTreeModel> queryTreeList(String ids,String hotelId);
 }

+ 4 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusDictServiceImpl.java

@@ -32,9 +32,10 @@ public class BusDictServiceImpl extends ServiceImpl<BusDictMapper, BusDict> impl
      * queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端
      */
     @Override
-    public List<BusDictTreeModel> queryTreeList() {
+    public List<BusDictTreeModel> queryTreeList(String hotelId) {
         LambdaQueryWrapper<BusDict> query = new LambdaQueryWrapper<BusDict>();
         query.eq(BusDict::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
+        query.eq(BusDict::getHotelId, hotelId);
 //        query.orderByAsc(BusDict::getCreateTime);
         List<BusDict> list = this.list(query);
         //update-begin---author:wangshuai ---date:20220307  for:[JTC-119]在部门管理菜单下设置部门负责人 创建用户的时候不需要处理
@@ -50,10 +51,11 @@ public class BusDictServiceImpl extends ServiceImpl<BusDictMapper, BusDict> impl
      * queryTreeList 根据部门id查询,前端回显调用
      */
     @Override
-    public List<BusDictTreeModel> queryTreeList(String ids) {
+    public List<BusDictTreeModel> queryTreeList(String ids,String hotelId) {
         List<BusDictTreeModel> listResult=new ArrayList<>();
         LambdaQueryWrapper<BusDict> query = new LambdaQueryWrapper<BusDict>();
         query.eq(BusDict::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
+        query.eq(BusDict::getHotelId, hotelId);
         if(oConvertUtils.isNotEmpty(ids)){
             query.in(true,BusDict::getId,ids.split(","));
         }