优化给仓库分配用户的接口
This commit is contained in:
@@ -7,9 +7,11 @@ import com.jsh.erp.base.TableDataInfo;
|
||||
import com.jsh.erp.datasource.entities.Depot;
|
||||
import com.jsh.erp.datasource.entities.DepotEx;
|
||||
import com.jsh.erp.datasource.entities.MaterialInitialStock;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.service.DepotService;
|
||||
import com.jsh.erp.service.MaterialService;
|
||||
import com.jsh.erp.service.UserBusinessService;
|
||||
import com.jsh.erp.service.UserService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.ErpInfo;
|
||||
@@ -27,6 +29,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnStr;
|
||||
@@ -49,6 +53,9 @@ public class DepotController extends BaseController {
|
||||
@Resource
|
||||
private MaterialService materialService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping(value = "/info")
|
||||
@ApiOperation(value = "根据id获取信息")
|
||||
public String getList(@RequestParam("id") Long id,
|
||||
|
||||
@@ -350,54 +350,6 @@ public class SupplierController extends BaseController {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户对应用户显示
|
||||
* @param type
|
||||
* @param oneValue
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getCustomerUser")
|
||||
@ApiOperation(value = "客户对应用户显示")
|
||||
public JSONArray findUserCustomer(@RequestParam("UBType") String type, @RequestParam("UBValue") String oneValue,
|
||||
HttpServletRequest request) throws Exception{
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
//获取权限信息
|
||||
List<Long> keyIdList = userBusinessService.getUBKeyIdByTypeAndOneValue(type, oneValue);
|
||||
Map<Long, Long> keyIdMap = keyIdList.stream().collect(Collectors.toMap(Function.identity(),Function.identity()));
|
||||
List<User> dataList = userService.getUser(request);
|
||||
//开始拼接json数据
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("id", 0);
|
||||
outer.put("key", 0);
|
||||
outer.put("value", 0);
|
||||
outer.put("title", "用户列表");
|
||||
outer.put("attributes", "用户列表");
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (User user : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", user.getId());
|
||||
item.put("key", user.getId());
|
||||
item.put("value", user.getId());
|
||||
item.put("title", user.getLoginName() + "(" + user.getUsername() + ")");
|
||||
item.put("attributes", user.getLoginName());
|
||||
if (keyIdMap.get(user.getId())!=null) {
|
||||
item.put("checked", true);
|
||||
}
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("children", dataArray);
|
||||
arr.add(outer);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据客户或供应商查询期初、期初已收等信息
|
||||
* @param organId
|
||||
|
||||
@@ -13,10 +13,7 @@ import com.jsh.erp.datasource.entities.UserEx;
|
||||
import com.jsh.erp.datasource.vo.TreeNodeEx;
|
||||
import com.jsh.erp.exception.BusinessParamCheckingException;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.RedisService;
|
||||
import com.jsh.erp.service.RoleService;
|
||||
import com.jsh.erp.service.TenantService;
|
||||
import com.jsh.erp.service.UserService;
|
||||
import com.jsh.erp.service.*;
|
||||
import com.jsh.erp.utils.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -29,6 +26,8 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnStr;
|
||||
@@ -54,6 +53,9 @@ public class UserController extends BaseController {
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@@ -454,6 +456,54 @@ public class UserController extends BaseController {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应的用户显示
|
||||
* @param type
|
||||
* @param oneValue
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getUserWithChecked")
|
||||
@ApiOperation(value = "获取对应的用户显示")
|
||||
public JSONArray getUserWithChecked(@RequestParam("UBType") String type, @RequestParam("UBValue") String oneValue,
|
||||
HttpServletRequest request) throws Exception{
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
//获取权限信息
|
||||
List<Long> keyIdList = userBusinessService.getUBKeyIdByTypeAndOneValue(type, oneValue);
|
||||
Map<Long, Long> keyIdMap = keyIdList.stream().collect(Collectors.toMap(Function.identity(),Function.identity()));
|
||||
List<User> dataList = userService.getUser(request);
|
||||
//开始拼接json数据
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("id", 0);
|
||||
outer.put("key", 0);
|
||||
outer.put("value", 0);
|
||||
outer.put("title", "用户列表");
|
||||
outer.put("attributes", "用户列表");
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (User user : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", user.getId());
|
||||
item.put("key", user.getId());
|
||||
item.put("value", user.getId());
|
||||
item.put("title", user.getLoginName() + "(" + user.getUsername() + ")");
|
||||
item.put("attributes", user.getLoginName());
|
||||
if (keyIdMap.get(user.getId())!=null) {
|
||||
item.put("checked", true);
|
||||
}
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("children", dataArray);
|
||||
arr.add(outer);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机校验码
|
||||
* @param response
|
||||
|
||||
@@ -22,11 +22,12 @@
|
||||
update jsh_user_business
|
||||
set value= #{ubValue}
|
||||
where type = #{type} and key_id = #{keyId}
|
||||
and ifnull(delete_flag,'0') !='1'
|
||||
</update>
|
||||
|
||||
<select id="getUBKeyIdByTypeAndOneValue" resultType="java.lang.Long">
|
||||
select ub.key_id from jsh_user_business ub
|
||||
where ub.type='UserCustomer'
|
||||
where ub.type = #{type}
|
||||
<bind name="bindOneValue" value="'%['+oneValue+']%'"/>
|
||||
and ub.value like #{bindOneValue}
|
||||
and ifnull(ub.delete_flag,'0') !='1'
|
||||
@@ -34,7 +35,7 @@
|
||||
|
||||
<select id="getOldListByType" resultType="com.jsh.erp.datasource.entities.UserBusiness">
|
||||
select * from jsh_user_business ub
|
||||
where ub.type='UserCustomer'
|
||||
where ub.type = #{type}
|
||||
and ifnull(ub.delete_flag,'0') !='1'
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user