增加商品校验
This commit is contained in:
@@ -55,8 +55,9 @@ public class MaterialController {
|
|||||||
@RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit,@RequestParam("unitId") Long unitId,
|
@RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit,@RequestParam("unitId") Long unitId,
|
||||||
HttpServletRequest request)throws Exception {
|
HttpServletRequest request)throws Exception {
|
||||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
int exist = materialService.checkIsExist(id, name, model, color, standard, mfrs,
|
int exist = materialService.checkIsExist(id, name, StringUtil.toNull(model), StringUtil.toNull(color),
|
||||||
otherField1, otherField2, otherField3, unit, unitId);
|
StringUtil.toNull(standard), StringUtil.toNull(mfrs), StringUtil.toNull(otherField1),
|
||||||
|
StringUtil.toNull(otherField2), StringUtil.toNull(otherField3), StringUtil.toNull(unit), unitId);
|
||||||
if(exist > 0) {
|
if(exist > 0) {
|
||||||
objectMap.put("status", true);
|
objectMap.put("status", true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -102,4 +102,17 @@ public interface MaterialMapperEx {
|
|||||||
@Param("depotId") Long depotId,
|
@Param("depotId") Long depotId,
|
||||||
@Param("idList") List<Long> idList,
|
@Param("idList") List<Long> idList,
|
||||||
@Param("materialParam") String materialParam);
|
@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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,28 +298,8 @@ public class MaterialService {
|
|||||||
|
|
||||||
public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs,
|
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 {
|
String otherField1, String otherField2, String otherField3, String unit, Long unitId)throws Exception {
|
||||||
MaterialExample example = new MaterialExample();
|
return materialMapperEx.checkIsExist(id, name, model, color, standard, mfrs, otherField1,
|
||||||
MaterialExample.Criteria criteria = example.createCriteria();
|
otherField2, otherField3, unit, unitId);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
|||||||
@@ -406,4 +406,42 @@
|
|||||||
</if>
|
</if>
|
||||||
and ifnull(m.delete_flag,'0') !='1'
|
and ifnull(m.delete_flag,'0') !='1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="checkIsExist" resultType="java.lang.Integer">
|
||||||
|
select count(1) from jsh_material m
|
||||||
|
where ifnull(m.delete_flag,'0') !='1'
|
||||||
|
<if test="name != null">
|
||||||
|
and m.name = #{name}
|
||||||
|
</if>
|
||||||
|
<if test="model != null">
|
||||||
|
and m.model = #{model}
|
||||||
|
</if>
|
||||||
|
<if test="color != null">
|
||||||
|
and m.color = #{color}
|
||||||
|
</if>
|
||||||
|
<if test="standard != null">
|
||||||
|
and m.standard = #{standard}
|
||||||
|
</if>
|
||||||
|
<if test="mfrs != null">
|
||||||
|
and m.mfrs = #{mfrs}
|
||||||
|
</if>
|
||||||
|
<if test="otherField1 != null">
|
||||||
|
and m.other_field1 = #{otherField1}
|
||||||
|
</if>
|
||||||
|
<if test="otherField2 != null">
|
||||||
|
and m.other_field2 = #{otherField2}
|
||||||
|
</if>
|
||||||
|
<if test="otherField3 != null">
|
||||||
|
and m.other_field3 = #{otherField3}
|
||||||
|
</if>
|
||||||
|
<if test="unit != null">
|
||||||
|
and m.unit = #{unit}
|
||||||
|
</if>
|
||||||
|
<if test="unitId != null">
|
||||||
|
and m.unit_id = #{unitId}
|
||||||
|
</if>
|
||||||
|
<if test="id != null">
|
||||||
|
and m.id != #{id}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user