Commit 3abb818f authored by 季圣华's avatar 季圣华
Browse files

优化供应商和客户的校验逻辑

parent f24733fd
......@@ -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);
}
\ No newline at end of file
......@@ -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;
......
......@@ -83,9 +83,9 @@
)
</update>
<select id="getSupplierByName" resultType="com.jsh.erp.datasource.entities.Supplier">
<select id="getSupplierByNameAndType" resultType="com.jsh.erp.datasource.entities.Supplier">
select *
from jsh_supplier
where supplier = #{supplier}
where supplier = #{supplier} and type = #{type}
</select>
</mapper>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment