完善供应商、客户、会员查询接口,支持模糊查询

This commit is contained in:
jishenghua
2025-09-26 17:19:06 +08:00
parent 6a108649e6
commit d9a9a1b118
5 changed files with 86 additions and 28 deletions

View File

@@ -149,14 +149,17 @@ public class SupplierController extends BaseController {
*/
@PostMapping(value = "/findBySelect_cus")
@ApiOperation(value = "查找客户信息")
public JSONArray findBySelectCus(HttpServletRequest request) {
public JSONArray findBySelectCus(@RequestBody JSONObject jsonObject,
HttpServletRequest request) {
JSONArray arr = new JSONArray();
try {
String key = jsonObject.get("key")!=null ? jsonObject.getString("key") : null;
Long organId = jsonObject.get("organId")!=null ? jsonObject.getLong("organId") : null;
String type = "UserCustomer";
Long userId = userService.getUserId(request);
//获取权限信息
String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, userId.toString());
List<Supplier> supplierList = supplierService.findBySelectCus();
List<Supplier> supplierList = supplierService.findBySelectCus(key, organId);
JSONArray dataArray = new JSONArray();
if (null != supplierList) {
boolean customerFlag = systemConfigService.getCustomerFlag();
@@ -184,10 +187,13 @@ public class SupplierController extends BaseController {
*/
@PostMapping(value = "/findBySelect_sup")
@ApiOperation(value = "查找供应商信息")
public JSONArray findBySelectSup(HttpServletRequest request) throws Exception{
public JSONArray findBySelectSup(@RequestBody JSONObject jsonObject,
HttpServletRequest request) throws Exception{
JSONArray arr = new JSONArray();
try {
List<Supplier> supplierList = supplierService.findBySelectSup();
String key = jsonObject.get("key")!=null ? jsonObject.getString("key") : null;
Long organId = jsonObject.get("organId")!=null ? jsonObject.getLong("organId") : null;
List<Supplier> supplierList = supplierService.findBySelectSup(key, organId);
JSONArray dataArray = new JSONArray();
if (null != supplierList) {
for (Supplier supplier : supplierList) {
@@ -212,12 +218,15 @@ public class SupplierController extends BaseController {
*/
@PostMapping(value = "/findBySelect_organ")
@ApiOperation(value = "查找往来单位,含供应商和客户信息")
public JSONArray findBySelectOrgan(HttpServletRequest request) throws Exception{
public JSONArray findBySelectOrgan(@RequestBody JSONObject jsonObject,
HttpServletRequest request) throws Exception{
JSONArray arr = new JSONArray();
try {
String key = jsonObject.get("key")!=null ? jsonObject.getString("key") : null;
Long organId = jsonObject.get("organId")!=null ? jsonObject.getLong("organId") : null;
JSONArray dataArray = new JSONArray();
//1、获取供应商信息
List<Supplier> supplierList = supplierService.findBySelectSup();
List<Supplier> supplierList = supplierService.findBySelectSup(key, organId);
if (null != supplierList) {
for (Supplier supplier : supplierList) {
JSONObject item = new JSONObject();
@@ -230,7 +239,7 @@ public class SupplierController extends BaseController {
String type = "UserCustomer";
Long userId = userService.getUserId(request);
String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, userId.toString());
List<Supplier> customerList = supplierService.findBySelectCus();
List<Supplier> customerList = supplierService.findBySelectCus(key, organId);
if (null != customerList) {
boolean customerFlag = systemConfigService.getCustomerFlag();
for (Supplier supplier : customerList) {
@@ -257,10 +266,13 @@ public class SupplierController extends BaseController {
*/
@PostMapping(value = "/findBySelect_retail")
@ApiOperation(value = "查找会员信息")
public JSONArray findBySelectRetail(HttpServletRequest request)throws Exception {
public JSONArray findBySelectRetail(@RequestBody JSONObject jsonObject,
HttpServletRequest request)throws Exception {
JSONArray arr = new JSONArray();
try {
List<Supplier> supplierList = supplierService.findBySelectRetail();
String key = jsonObject.get("key")!=null ? jsonObject.getString("key") : null;
Long organId = jsonObject.get("organId")!=null ? jsonObject.getLong("organId") : null;
List<Supplier> supplierList = supplierService.findBySelectRetail(key, organId);
JSONArray dataArray = new JSONArray();
if (null != supplierList) {
for (Supplier supplier : supplierList) {

View File

@@ -31,4 +31,11 @@ public interface SupplierMapperEx {
@Param("type") String type);
List<SupplierSimple> getAllCustomer();
List<Supplier> findByTypeAndKey(
@Param("type") String type,
@Param("key") String key);
Supplier getInfoById(
@Param("id") Long id);
}

View File

@@ -275,7 +275,7 @@ public class DepotHeadService {
Long userId = userService.getCurrentUser().getId();
//获取权限信息
String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, userId.toString());
List<Supplier> supplierList = supplierService.findBySelectCus();
List<SupplierSimple> supplierList = supplierService.getAllCustomer();
if(BusinessConstants.SUB_TYPE_SALES_ORDER.equals(subType) || BusinessConstants.SUB_TYPE_SALES.equals(subType)
||BusinessConstants.SUB_TYPE_SALES_RETURN.equals(subType) ) {
//采购订单里面选择销售订单的时候不要过滤
@@ -283,7 +283,7 @@ public class DepotHeadService {
if (null != supplierList && supplierList.size() > 0) {
boolean customerFlag = systemConfigService.getCustomerFlag();
List<String> organList = new ArrayList<>();
for (Supplier supplier : supplierList) {
for (SupplierSimple supplier : supplierList) {
boolean flag = ubValue.contains("[" + supplier.getId().toString() + "]");
if (!customerFlag || flag) {
organList.add(supplier.getId().toString());

View File

@@ -288,47 +288,68 @@ public class SupplierService {
}
}
public List<Supplier> findBySelectCus()throws Exception {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("sort asc, id desc");
public List<Supplier> findBySelectCus(String key, Long organId)throws Exception {
List<Supplier> list=null;
try{
list = supplierMapper.selectByExample(example);
list = supplierMapperEx.findByTypeAndKey("客户", key);
if(organId!=null) {
list = addOrganToList(list, organId);
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Supplier> findBySelectSup()throws Exception {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("sort asc, id desc");
public List<Supplier> findBySelectSup(String key, Long organId)throws Exception {
List<Supplier> list=null;
try{
list = supplierMapper.selectByExample(example);
list = supplierMapperEx.findByTypeAndKey("供应商", key);
if(organId!=null) {
list = addOrganToList(list, organId);
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Supplier> findBySelectRetail()throws Exception {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("sort asc, id desc");
public List<Supplier> findBySelectRetail(String key, Long organId)throws Exception {
List<Supplier> list=null;
try{
list = supplierMapper.selectByExample(example);
list = supplierMapperEx.findByTypeAndKey("会员", key);
if(organId!=null) {
list = addOrganToList(list, organId);
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
/**
* 给列表追加供应商信息
* @param list
* @param organId
* @return
*/
public List<Supplier> addOrganToList(List<Supplier> list, Long organId) {
boolean isExist = false;
for(Supplier supplier: list) {
if(supplier.getId().equals(organId)) {
isExist = true;
}
}
if(!isExist) {
//列表里面不存在则追加
Supplier info = supplierMapperEx.getInfoById(organId);
if(info!=null) {
list.add(info);
}
}
return list;
}
public List<Supplier> findById(Long supplierId)throws Exception {
SupplierExample example = new SupplierExample();
example.createCriteria().andIdEqualTo(supplierId)