优化供应商和客户的校验逻辑
This commit is contained in:
@@ -55,6 +55,22 @@ public class SupplierController {
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping(value = "/checkIsNameAndTypeExist")
|
||||
@ApiOperation(value = "检查名称和类型是否存在")
|
||||
public String checkIsNameAndTypeExist(@RequestParam Long id,
|
||||
@RequestParam(value ="name") String name,
|
||||
@RequestParam(value ="type") String type,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
int exist = supplierService.checkIsNameAndTypeExist(id, name, type);
|
||||
if(exist > 0) {
|
||||
objectMap.put("status", true);
|
||||
} else {
|
||||
objectMap.put("status", false);
|
||||
}
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找客户信息-下拉框
|
||||
* @param request
|
||||
@@ -135,7 +151,7 @@ public class SupplierController {
|
||||
for (Supplier supplier : supplierList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", supplier.getId());
|
||||
item.put("supplier", supplier.getSupplier()); //供应商名称
|
||||
item.put("supplier", supplier.getSupplier() + "[供应商]"); //供应商名称
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
@@ -151,7 +167,7 @@ public class SupplierController {
|
||||
Boolean flag = ubValue.contains("[" + supplier.getId().toString() + "]");
|
||||
if (!customerFlag || flag) {
|
||||
item.put("id", supplier.getId());
|
||||
item.put("supplier", supplier.getSupplier()); //客户名称
|
||||
item.put("supplier", supplier.getSupplier() + "[客户]"); //客户名称
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public interface SupplierMapperEx {
|
||||
|
||||
int batchDeleteSupplierByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
|
||||
|
||||
Supplier getSupplierByName(
|
||||
@Param("supplier") String supplier);
|
||||
Supplier getSupplierByNameAndType(
|
||||
@Param("supplier") String supplier,
|
||||
@Param("type") String type);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class SupplierService {
|
||||
//新增客户时给当前用户自动授权
|
||||
if("客户".equals(supplier.getType())) {
|
||||
Long userId = userService.getUserId(request);
|
||||
Supplier sInfo = supplierMapperEx.getSupplierByName(supplier.getSupplier());
|
||||
Supplier sInfo = supplierMapperEx.getSupplierByNameAndType(supplier.getSupplier(), supplier.getType());
|
||||
String ubKey = "[" + sInfo.getId() + "]";
|
||||
List<UserBusiness> ubList = userBusinessService.getBasicData(userId.toString(), "UserCustomer");
|
||||
if(ubList ==null || ubList.size() == 0) {
|
||||
@@ -271,6 +271,19 @@ public class SupplierService {
|
||||
return list==null?0:list.size();
|
||||
}
|
||||
|
||||
public int checkIsNameAndTypeExist(Long id, String name, String type)throws Exception {
|
||||
SupplierExample example = new SupplierExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name).andTypeEqualTo(type)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<Supplier> list=null;
|
||||
try{
|
||||
list= supplierMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list==null?0:list.size();
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int updateAdvanceIn(Long supplierId, BigDecimal advanceIn)throws Exception{
|
||||
Supplier supplier=null;
|
||||
|
||||
Reference in New Issue
Block a user