解决商品不能录入的问题
This commit is contained in:
@@ -31,7 +31,7 @@ public class MaterialController {
|
||||
private MaterialService materialService;
|
||||
|
||||
@GetMapping(value = "/checkIsExist")
|
||||
public String checkIsExist(@RequestParam("materialId") Long id, @RequestParam("name") String name,
|
||||
public String checkIsExist(@RequestParam("id") Long id, @RequestParam("name") String name,
|
||||
@RequestParam("model") String model, @RequestParam("color") String color,
|
||||
@RequestParam("standard") String standard, @RequestParam("mfrs") String mfrs,
|
||||
@RequestParam("otherField1") String otherField1, @RequestParam("otherField2") String otherField2,
|
||||
|
||||
@@ -118,4 +118,7 @@ public interface MaterialMapper {
|
||||
|
||||
List<MaterialVo4Unit> findBySelect();
|
||||
|
||||
int updatePriceNullByPrimaryKey(Long id);
|
||||
|
||||
int updateUnitIdNullByPrimaryKey(Long id);
|
||||
}
|
||||
@@ -72,13 +72,21 @@ public class MaterialService {
|
||||
|
||||
public int insertMaterial(String beanJson, HttpServletRequest request) {
|
||||
Material material = JSONObject.parseObject(beanJson, Material.class);
|
||||
material.setEnabled(true);
|
||||
return materialMapper.insertSelective(material);
|
||||
}
|
||||
|
||||
public int updateMaterial(String beanJson, Long id) {
|
||||
Material material = JSONObject.parseObject(beanJson, Material.class);
|
||||
material.setId(id);
|
||||
return materialMapper.updateByPrimaryKeySelective(material);
|
||||
int res = materialMapper.updateByPrimaryKeySelective(material);
|
||||
Long unitId = material.getUnitid();
|
||||
if(unitId != null) {
|
||||
materialMapper.updatePriceNullByPrimaryKey(id); //将价格置空
|
||||
} else {
|
||||
materialMapper.updateUnitIdNullByPrimaryKey(id); //将多单位置空
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public int deleteMaterial(Long id) {
|
||||
@@ -102,17 +110,18 @@ 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) {
|
||||
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);
|
||||
if (id > 0) {
|
||||
example.createCriteria().andIdNotEqualTo(id);
|
||||
criteria.andIdNotEqualTo(id);
|
||||
}
|
||||
example.createCriteria().andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color)
|
||||
.andStandardEqualTo(standard).andMfrsEqualTo(mfrs)
|
||||
.andOtherfield1EqualTo(otherField1).andOtherfield2EqualTo(otherField2).andOtherfield2EqualTo(otherField3);
|
||||
if (unit !=null) {
|
||||
example.createCriteria().andUnitEqualTo(unit);
|
||||
if (!StringUtil.isEmpty(unit)) {
|
||||
criteria.andUnitEqualTo(unit);
|
||||
}
|
||||
if (unitId !=null) {
|
||||
example.createCriteria().andUnitidEqualTo(unitId);
|
||||
criteria.andUnitidEqualTo(unitId);
|
||||
}
|
||||
List<Material> list = materialMapper.selectByExample(example);
|
||||
return list.size();
|
||||
|
||||
@@ -60,4 +60,21 @@
|
||||
<select id="findBySelect" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
|
||||
select m.*,u.UName from jsh_material m left join jsh_unit u on m.UnitId=u.id where m.enabled=1 ORDER BY Id asc
|
||||
</select>
|
||||
|
||||
<update id="updatePriceNullByPrimaryKey" parameterType="java.lang.Long">
|
||||
update jsh_material
|
||||
set
|
||||
RetailPrice = null,
|
||||
LowPrice = null,
|
||||
PresetPriceOne = null,
|
||||
PresetPriceTwo = null
|
||||
where Id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
|
||||
<update id="updateUnitIdNullByPrimaryKey" parameterType="java.lang.Long">
|
||||
update jsh_material
|
||||
set
|
||||
UnitId = null
|
||||
where Id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user