增加商品校验

This commit is contained in:
季圣华
2021-06-20 23:53:58 +08:00
parent e5ce3194ee
commit 09cf354086
4 changed files with 56 additions and 24 deletions

View File

@@ -55,8 +55,9 @@ public class MaterialController {
@RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit,@RequestParam("unitId") Long unitId,
HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<String, Object>();
int exist = materialService.checkIsExist(id, name, model, color, standard, mfrs,
otherField1, otherField2, otherField3, unit, unitId);
int exist = materialService.checkIsExist(id, name, StringUtil.toNull(model), StringUtil.toNull(color),
StringUtil.toNull(standard), StringUtil.toNull(mfrs), StringUtil.toNull(otherField1),
StringUtil.toNull(otherField2), StringUtil.toNull(otherField3), StringUtil.toNull(unit), unitId);
if(exist > 0) {
objectMap.put("status", true);
} else {

View File

@@ -102,4 +102,17 @@ public interface MaterialMapperEx {
@Param("depotId") Long depotId,
@Param("idList") List<Long> idList,
@Param("materialParam") String materialParam);
int checkIsExist(
@Param("id") Long id,
@Param("name") String name,
@Param("model") String model,
@Param("color") String color,
@Param("standard") String standard,
@Param("mfrs") String mfrs,
@Param("otherField1") String otherField1,
@Param("otherField2") String otherField2,
@Param("otherField3") String otherField3,
@Param("unit") String unit,
@Param("unitId") Long unitId);
}

View File

@@ -298,28 +298,8 @@ public class MaterialService {
public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs,
String otherField1, String otherField2, String otherField3, String unit, Long unitId)throws Exception {
MaterialExample example = new MaterialExample();
MaterialExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color)
.andStandardEqualTo(standard).andMfrsEqualTo(mfrs)
.andOtherField1EqualTo(otherField1).andOtherField2EqualTo(otherField2).andOtherField2EqualTo(otherField3)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
if (id > 0) {
criteria.andIdNotEqualTo(id);
}
if (!StringUtil.isEmpty(unit)) {
criteria.andUnitEqualTo(unit);
}
if (unitId !=null) {
criteria.andUnitIdEqualTo(unitId);
}
List<Material> list =null;
try{
list= materialMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list==null?0:list.size();
return materialMapperEx.checkIsExist(id, name, model, color, standard, mfrs, otherField1,
otherField2, otherField3, unit, unitId);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)