解决excel导入商品遇到的条码重复的问题
This commit is contained in:
parent
e49b8e05d4
commit
f41dbb34e1
@ -350,6 +350,9 @@ public class ExceptionConstants {
|
||||
//基本条码为空
|
||||
public static final int MATERIAL_BARCODE_EMPTY_CODE = 8000027;
|
||||
public static final String MATERIAL_BARCODE_EMPTY_MSG = "第%s行基本条码为空";
|
||||
//EXCEL中有副条码在系统中已存在(除自身商品之外)
|
||||
public static final int MATERIAL_EXCEL_IMPORT_MANY_BARCODE_EXIST_CODE = 80000028;
|
||||
public static final String MATERIAL_EXCEL_IMPORT_MANY_BARCODE_EXIST_MSG = "抱歉,EXCEL中有副条码在系统中已存在,具体副条码为:%s";
|
||||
|
||||
/**
|
||||
* 单据信息
|
||||
|
||||
@ -24,4 +24,7 @@ public interface MaterialExtendMapperEx {
|
||||
int batchDeleteMaterialExtendByMIds(@Param("ids") String ids[]);
|
||||
|
||||
int specialUpdatePrice(MaterialExtend record);
|
||||
|
||||
List<MaterialExtend> getBasicInfoByMid(
|
||||
@Param("materialId") Long materialId);
|
||||
}
|
||||
@ -705,7 +705,7 @@ public class MaterialService {
|
||||
}
|
||||
//批量校验excel中有无重复商品,是指名称、规格、型号、颜色、单位、多属性
|
||||
batchCheckExistMaterialListByParam(mList, name, standard, model, color, unit, sku);
|
||||
//批量校验excel中有无重复条码
|
||||
//批量校验excel中有无重复条码(1-文档自身校验,2-和数据库里面的商品校验)
|
||||
batchCheckExistBarCodeByParam(mList, barCode, manyBarCode);
|
||||
JSONObject materialExObj = new JSONObject();
|
||||
JSONObject basicObj = new JSONObject();
|
||||
@ -946,11 +946,24 @@ public class MaterialService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量校验excel中有无重复条码
|
||||
* 批量校验excel中有无重复条码(1-文档自身校验,2-和数据库里面的商品校验)
|
||||
* @param mList
|
||||
*/
|
||||
public void batchCheckExistBarCodeByParam(List<MaterialWithInitStock> mList,
|
||||
String barCode, String manyBarCode) {
|
||||
String barCode, String manyBarCode) throws Exception {
|
||||
if(barCode.equals(manyBarCode)) {
|
||||
//同一个商品的主副条码重复了,进行提醒
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_MSG, manyBarCode));
|
||||
}
|
||||
if(StringUtil.isNotEmpty(manyBarCode)) {
|
||||
//EXCEL中有副条码在系统中已存在(除自身商品之外)
|
||||
int count = materialExtendService.getCountByManyBarCodeWithoutUs(manyBarCode, barCode);
|
||||
if (count>0) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXCEL_IMPORT_MANY_BARCODE_EXIST_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_EXCEL_IMPORT_MANY_BARCODE_EXIST_MSG, manyBarCode));
|
||||
}
|
||||
}
|
||||
for(MaterialWithInitStock material: mList){
|
||||
JSONObject materialExObj = material.getMaterialExObj();
|
||||
String basicBarCode = "";
|
||||
|
||||
@ -376,7 +376,6 @@ public class MaterialExtendService {
|
||||
}
|
||||
|
||||
public MaterialExtend getInfoByBarCode(String barCode)throws Exception {
|
||||
MaterialExtend materialExtend = new MaterialExtend();
|
||||
MaterialExtendExample example = new MaterialExtendExample();
|
||||
example.createCriteria().andBarCodeEqualTo(barCode)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
@ -389,20 +388,25 @@ public class MaterialExtendService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某个商品里面被清除的条码信息
|
||||
* @param barCodeList
|
||||
* @param mId
|
||||
* 商品的副条码和数据库里面的商品条码存在重复(除自身商品之外)
|
||||
* @param manyBarCode
|
||||
* @param barCode
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<MaterialExtend> getMeListByBarCodeAndMid(List<String> barCodeList, Long mId)throws Exception {
|
||||
List<MaterialExtend> list = new ArrayList<>();
|
||||
if(barCodeList.size()>0) {
|
||||
MaterialExtendExample example = new MaterialExtendExample();
|
||||
example.createCriteria().andBarCodeNotIn(barCodeList).andMaterialIdEqualTo(mId)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
list = materialExtendMapper.selectByExample(example);
|
||||
public int getCountByManyBarCodeWithoutUs(String manyBarCode, String barCode) {
|
||||
MaterialExtendExample example = new MaterialExtendExample();
|
||||
example.createCriteria().andBarCodeEqualTo(manyBarCode).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<MaterialExtend> list = materialExtendMapper.selectByExample(example);
|
||||
if(list!=null && list.size()>0) {
|
||||
for(MaterialExtend me: list) {
|
||||
List<MaterialExtend> basicMeList = materialExtendMapperEx.getBasicInfoByMid(me.getMaterialId());
|
||||
for(MaterialExtend basicMe: basicMeList) {
|
||||
if(basicMe!=null && !barCode.equals(basicMe.getBarCode())) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,4 +75,10 @@
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
and ifnull(delete_flag,'0') !='1'
|
||||
</update>
|
||||
|
||||
<select id="getBasicInfoByMid" resultType="com.jsh.erp.datasource.entities.MaterialExtend">
|
||||
select * from jsh_material_extend
|
||||
where material_id=#{materialId} and default_flag='1'
|
||||
and ifnull(delete_Flag,'0') !='1'
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user