diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/SupplierController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/SupplierController.java index 1cbe2904..7cd5acf0 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/SupplierController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/SupplierController.java @@ -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 supplierList = supplierService.findBySelectCus(); + List 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 supplierList = supplierService.findBySelectSup(); + String key = jsonObject.get("key")!=null ? jsonObject.getString("key") : null; + Long organId = jsonObject.get("organId")!=null ? jsonObject.getLong("organId") : null; + List 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 supplierList = supplierService.findBySelectSup(); + List 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 customerList = supplierService.findBySelectCus(); + List 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 supplierList = supplierService.findBySelectRetail(); + String key = jsonObject.get("key")!=null ? jsonObject.getString("key") : null; + Long organId = jsonObject.get("organId")!=null ? jsonObject.getLong("organId") : null; + List supplierList = supplierService.findBySelectRetail(key, organId); JSONArray dataArray = new JSONArray(); if (null != supplierList) { for (Supplier supplier : supplierList) { diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapperEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapperEx.java index d22361af..5f8f98a1 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapperEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapperEx.java @@ -31,4 +31,11 @@ public interface SupplierMapperEx { @Param("type") String type); List getAllCustomer(); + + List findByTypeAndKey( + @Param("type") String type, + @Param("key") String key); + + Supplier getInfoById( + @Param("id") Long id); } \ No newline at end of file diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/DepotHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/DepotHeadService.java index c90d4639..c9a35a37 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/DepotHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/DepotHeadService.java @@ -275,7 +275,7 @@ public class DepotHeadService { Long userId = userService.getCurrentUser().getId(); //获取权限信息 String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, userId.toString()); - List supplierList = supplierService.findBySelectCus(); + List 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 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()); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/SupplierService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/SupplierService.java index 18d6565f..dc4c031d 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/SupplierService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/SupplierService.java @@ -288,47 +288,68 @@ public class SupplierService { } } - public List 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 findBySelectCus(String key, Long organId)throws Exception { List 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 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 findBySelectSup(String key, Long organId)throws Exception { List 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 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 findBySelectRetail(String key, Long organId)throws Exception { List 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 addOrganToList(List 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 findById(Long supplierId)throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andIdEqualTo(supplierId) diff --git a/jshERP-boot/src/main/resources/mapper_xml/SupplierMapperEx.xml b/jshERP-boot/src/main/resources/mapper_xml/SupplierMapperEx.xml index 0fde392a..a4454f7f 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/SupplierMapperEx.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/SupplierMapperEx.xml @@ -82,4 +82,22 @@ and ifnull(delete_flag,'0') !='1' order by sort asc, id desc + + + + \ No newline at end of file