zds
4 weeks ago
26 changed files with 145 additions and 271 deletions
@ -1,45 +0,0 @@ |
|||||
package org.nl.wms.basedata.st.rest; |
|
||||
|
|
||||
import com.alibaba.fastjson.JSONObject; |
|
||||
import lombok.RequiredArgsConstructor; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.nl.modules.logging.annotation.Log; |
|
||||
import org.nl.wms.basedata.st.service.UserAreaService; |
|
||||
import org.springframework.data.domain.Pageable; |
|
||||
import org.springframework.http.HttpStatus; |
|
||||
import org.springframework.http.ResponseEntity; |
|
||||
import org.springframework.web.bind.annotation.*; |
|
||||
|
|
||||
import java.util.Map; |
|
||||
|
|
||||
@RestController |
|
||||
@RequiredArgsConstructor |
|
||||
|
|
||||
@RequestMapping("/api/userArea2") |
|
||||
@Slf4j |
|
||||
public class UserAreaController { |
|
||||
private final UserAreaService userAreaService; |
|
||||
|
|
||||
@GetMapping |
|
||||
@Log("查询用户信息") |
|
||||
|
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) { |
|
||||
return new ResponseEntity<>(userAreaService.pageQuery(whereJson, page), HttpStatus.OK); |
|
||||
} |
|
||||
|
|
||||
@PostMapping("/queryUserArea") |
|
||||
@Log("查询用户对应区域") |
|
||||
|
|
||||
public ResponseEntity<Object> queryUserArea(@RequestBody JSONObject whereJson) { |
|
||||
return new ResponseEntity<>(userAreaService.queryUserArea(whereJson), HttpStatus.OK); |
|
||||
} |
|
||||
|
|
||||
@PostMapping("/save") |
|
||||
@Log("保存用户仓库信息") |
|
||||
|
|
||||
public ResponseEntity<Object> save(@RequestBody JSONObject whereJson) { |
|
||||
userAreaService.save(whereJson); |
|
||||
return new ResponseEntity<>(HttpStatus.OK); |
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,33 +0,0 @@ |
|||||
package org.nl.wms.basedata.st.service; |
|
||||
|
|
||||
import com.alibaba.fastjson.JSONArray; |
|
||||
import com.alibaba.fastjson.JSONObject; |
|
||||
import org.springframework.data.domain.Pageable; |
|
||||
|
|
||||
import java.util.Map; |
|
||||
|
|
||||
public interface UserAreaService { |
|
||||
/** |
|
||||
* 查询数据分页 |
|
||||
* |
|
||||
* @param whereJson 条件 |
|
||||
* @param page 分页参数 |
|
||||
* @return Map<String, Object> |
|
||||
*/ |
|
||||
Map<String, Object> pageQuery(Map whereJson, Pageable page); |
|
||||
|
|
||||
/** |
|
||||
* 查询用户对应仓库 |
|
||||
* |
|
||||
* @param whereJson / |
|
||||
*/ |
|
||||
JSONArray queryUserArea(JSONObject whereJson); |
|
||||
|
|
||||
/** |
|
||||
* 保存 |
|
||||
* |
|
||||
* @param whereJson / |
|
||||
*/ |
|
||||
void save(JSONObject whereJson); |
|
||||
|
|
||||
} |
|
@ -1,100 +0,0 @@ |
|||||
package org.nl.wms.basedata.st.service.impl; |
|
||||
|
|
||||
import cn.hutool.core.util.ObjectUtil; |
|
||||
import cn.hutool.core.util.StrUtil; |
|
||||
import com.alibaba.fastjson.JSONArray; |
|
||||
import com.alibaba.fastjson.JSONObject; |
|
||||
import lombok.RequiredArgsConstructor; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.nl.common.utils.SecurityUtils; |
|
||||
import org.nl.modules.wql.WQL; |
|
||||
import org.nl.modules.wql.core.bean.WQLObject; |
|
||||
import org.nl.modules.wql.util.WqlUtil; |
|
||||
import org.nl.wms.basedata.st.service.UserAreaService; |
|
||||
import org.springframework.data.domain.Pageable; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
import java.util.HashMap; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
/** |
|
||||
* PC端出入库新增 |
|
||||
*/ |
|
||||
@Service |
|
||||
@RequiredArgsConstructor |
|
||||
@Slf4j |
|
||||
public class UserAreaServiceImpl implements UserAreaService { |
|
||||
|
|
||||
@Override |
|
||||
public Map<String, Object> pageQuery(Map whereJson, Pageable page) { |
|
||||
HashMap<String, String> map = new HashMap<>(whereJson); |
|
||||
map.put("flag", "3"); |
|
||||
if (StrUtil.isNotEmpty(map.get("blurry"))) { |
|
||||
map.put("blurry", "%" + map.get("blurry") + "%"); |
|
||||
} |
|
||||
JSONObject jo = WQL.getWO("QST_STOR_ATTR").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "username desc"); |
|
||||
return jo; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public JSONArray queryUserArea(JSONObject whereJson) { |
|
||||
String user_id = whereJson.getString("user_id"); |
|
||||
JSONArray rows = WQLObject.getWQLObject("st_ivt_userarea").query("user_id = '" + user_id + "'").getResultJSONArray(0); |
|
||||
return rows; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void save(JSONObject whereJson) { |
|
||||
JSONObject jo = whereJson.getJSONObject("jo"); |
|
||||
JSONArray rows = whereJson.getJSONArray("rows"); |
|
||||
|
|
||||
String user_id = jo.getString("user_id"); |
|
||||
|
|
||||
WQLObject.getWQLObject("st_ivt_userarea").delete("user_id ='" + user_id + "'"); |
|
||||
for (int i = 0; i < rows.size(); i++) { |
|
||||
JSONObject row = rows.getJSONObject(i); |
|
||||
String product_area = row.getString("product_area"); |
|
||||
JSONObject user_stor = new JSONObject(); |
|
||||
user_stor.put("product_area", product_area); |
|
||||
user_stor.put("user_id", user_id); |
|
||||
WQLObject.getWQLObject("st_ivt_userarea").insert(user_stor); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public String getInArea() { |
|
||||
String currentUserId = SecurityUtils.getCurrentUserId().toString(); |
|
||||
WQLObject userStorTab = WQLObject.getWQLObject("st_ivt_userarea"); |
|
||||
|
|
||||
JSONArray userStorArr = userStorTab.query("user_id = '" + currentUserId + "'").getResultJSONArray(0); |
|
||||
int size = userStorArr.size(); |
|
||||
// 将仓库id拼成字符串
|
|
||||
String in_stor_id = ""; |
|
||||
|
|
||||
for (int i = 0; i < userStorArr.size(); i++) { |
|
||||
JSONObject json = userStorArr.getJSONObject(i); |
|
||||
|
|
||||
if (size == 1) { |
|
||||
// 如果只有一条记录
|
|
||||
in_stor_id = "('" + json.getString("product_area") + "')"; |
|
||||
} else { |
|
||||
if (i == 0) { |
|
||||
// 第一条记录拼接
|
|
||||
in_stor_id = "('" + json.getString("product_area") + "','"; |
|
||||
} else { |
|
||||
if ((size - 1) == i) { |
|
||||
// 最后一条记录拼接
|
|
||||
in_stor_id += json.getString("product_area") + "')"; |
|
||||
} else { |
|
||||
in_stor_id += json.getString("product_area") + "','"; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (ObjectUtil.isEmpty(in_stor_id)) { |
|
||||
in_stor_id = "('')"; |
|
||||
} |
|
||||
return in_stor_id; |
|
||||
} |
|
||||
|
|
||||
} |
|
Loading…
Reference in new issue