修改商品模块,解决修改条码的逻辑问题

This commit is contained in:
季圣华
2022-05-16 18:28:04 +08:00
parent 473edd3d0f
commit 5a87de50b2
5 changed files with 47 additions and 65 deletions

View File

@@ -304,13 +304,11 @@ public class MaterialController {
@GetMapping(value = "/exportExcel") @GetMapping(value = "/exportExcel")
@ApiOperation(value = "生成excel表格") @ApiOperation(value = "生成excel表格")
public void exportExcel(@RequestParam(value = "categoryId", required = false) String categoryId, public void exportExcel(@RequestParam(value = "categoryId", required = false) String categoryId,
@RequestParam(value = "barCode", required = false) String barCode, @RequestParam(value = "materialParam", required = false) String materialParam,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "standard", required = false) String standard,
@RequestParam(value = "model", required = false) String model,
@RequestParam(value = "color", required = false) String color, @RequestParam(value = "color", required = false) String color,
@RequestParam(value = "weight", required = false) String weight, @RequestParam(value = "weight", required = false) String weight,
@RequestParam(value = "expiryNum", required = false) String expiryNum, @RequestParam(value = "expiryNum", required = false) String expiryNum,
@RequestParam(value = "enabled", required = false) String enabled,
@RequestParam(value = "enableSerialNumber", required = false) String enableSerialNumber, @RequestParam(value = "enableSerialNumber", required = false) String enableSerialNumber,
@RequestParam(value = "enableBatchNumber", required = false) String enableBatchNumber, @RequestParam(value = "enableBatchNumber", required = false) String enableBatchNumber,
@RequestParam(value = "remark", required = false) String remark, @RequestParam(value = "remark", required = false) String remark,
@@ -321,10 +319,9 @@ public class MaterialController {
if(StringUtil.isNotEmpty(mpList)){ if(StringUtil.isNotEmpty(mpList)){
mpArr= mpList.split(","); mpArr= mpList.split(",");
} }
List<MaterialVo4Unit> dataList = materialService.findByAll(StringUtil.toNull(barCode), StringUtil.toNull(name), List<MaterialVo4Unit> dataList = materialService.exportExcel(StringUtil.toNull(materialParam), StringUtil.toNull(color),
StringUtil.toNull(standard), StringUtil.toNull(model), StringUtil.toNull(color), StringUtil.toNull(weight), StringUtil.toNull(weight), StringUtil.toNull(expiryNum), StringUtil.toNull(enabled), StringUtil.toNull(enableSerialNumber),
StringUtil.toNull(expiryNum), StringUtil.toNull(enableSerialNumber), StringUtil.toNull(enableBatchNumber), StringUtil.toNull(enableBatchNumber), StringUtil.toNull(remark), StringUtil.toNull(categoryId));
StringUtil.toNull(remark), StringUtil.toNull(categoryId));
String[] names = {"条码", "名称", "规格", "型号", "颜色", "类别", "扩展信息", "单位", "基础重量", "保质期", "采购价", "零售价", "销售价", "最低售价", "备注", "状态", "序列号", "批号"}; String[] names = {"条码", "名称", "规格", "型号", "颜色", "类别", "扩展信息", "单位", "基础重量", "保质期", "采购价", "零售价", "销售价", "最低售价", "备注", "状态", "序列号", "批号"};
String title = "商品信息"; String title = "商品信息";
List<String[]> objects = new ArrayList<>(); List<String[]> objects = new ArrayList<>();

View File

@@ -60,14 +60,12 @@ public interface MaterialMapperEx {
int findBySelectWithBarCodeCount(@Param("idList") List<Long> idList, int findBySelectWithBarCodeCount(@Param("idList") List<Long> idList,
@Param("q") String q); @Param("q") String q);
List<MaterialVo4Unit> findByAll( List<MaterialVo4Unit> exportExcel(
@Param("barCode") String barCode, @Param("materialParam") String materialParam,
@Param("name") String name,
@Param("standard") String standard,
@Param("model") String model,
@Param("color") String color, @Param("color") String color,
@Param("weight") String weight, @Param("weight") String weight,
@Param("expiryNum") String expiryNum, @Param("expiryNum") String expiryNum,
@Param("enabled") String enabled,
@Param("enableSerialNumber") String enableSerialNumber, @Param("enableSerialNumber") String enableSerialNumber,
@Param("enableBatchNumber") String enableBatchNumber, @Param("enableBatchNumber") String enableBatchNumber,
@Param("remark") String remark, @Param("remark") String remark,

View File

@@ -430,9 +430,8 @@ public class MaterialService {
return result; return result;
} }
public List<MaterialVo4Unit> findByAll(String barCode, String name, String standard, String model, String color, public List<MaterialVo4Unit> exportExcel(String materialParam, String color, String weight, String expiryNum, String enabled,
String weight, String expiryNum, String enableSerialNumber, String enableBatchNumber, String enableSerialNumber, String enableBatchNumber, String remark, String categoryId)throws Exception {
String remark, String categoryId)throws Exception {
List<MaterialVo4Unit> resList = new ArrayList<>(); List<MaterialVo4Unit> resList = new ArrayList<>();
List<MaterialVo4Unit> list =null; List<MaterialVo4Unit> list =null;
try{ try{
@@ -440,8 +439,8 @@ public class MaterialService {
if(StringUtil.isNotEmpty(categoryId)){ if(StringUtil.isNotEmpty(categoryId)){
idList = getListByParentId(Long.parseLong(categoryId)); idList = getListByParentId(Long.parseLong(categoryId));
} }
list= materialMapperEx.findByAll(barCode, name, standard, model, color, weight, expiryNum, list= materialMapperEx.exportExcel(materialParam, color, weight, expiryNum, enabled, enableSerialNumber,
enableSerialNumber, enableBatchNumber, remark, idList); enableBatchNumber, remark, idList);
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -654,9 +653,13 @@ public class MaterialService {
} }
//批量更新库存 //批量更新库存
batchDeleteInitialStockByMaterialList(deleteStockMaterialIdList); batchDeleteInitialStockByMaterialList(deleteStockMaterialIdList);
if(insertInitialStockMaterialList.size()>0) {
materialInitialStockMapperEx.batchInsert(insertInitialStockMaterialList); materialInitialStockMapperEx.batchInsert(insertInitialStockMaterialList);
}
batchDeleteCurrentStockByMaterialList(deleteStockMaterialIdList); batchDeleteCurrentStockByMaterialList(deleteStockMaterialIdList);
if(insertCurrentStockMaterialList.size()>0) {
materialCurrentStockMapperEx.batchInsert(insertCurrentStockMaterialList); materialCurrentStockMapperEx.batchInsert(insertCurrentStockMaterialList);
}
logService.insertLog("商品", logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());

View File

@@ -85,8 +85,8 @@ public class MaterialExtendService {
JSONArray meArr = obj.getJSONArray("meList"); JSONArray meArr = obj.getJSONArray("meList");
JSONArray insertedJson = new JSONArray(); JSONArray insertedJson = new JSONArray();
JSONArray updatedJson = new JSONArray(); JSONArray updatedJson = new JSONArray();
JSONArray deletedJson = new JSONArray(); JSONArray deletedJson = obj.getJSONArray("meDeleteIdList");
List<String> barCodeList=new ArrayList<>(); JSONArray sortJson = JSONArray.parseArray(sortList);
if (null != meArr) { if (null != meArr) {
if("insert".equals(type)){ if("insert".equals(type)){
for (int i = 0; i < meArr.size(); i++) { for (int i = 0; i < meArr.size(); i++) {
@@ -97,23 +97,25 @@ public class MaterialExtendService {
for (int i = 0; i < meArr.size(); i++) { for (int i = 0; i < meArr.size(); i++) {
JSONObject tempJson = meArr.getJSONObject(i); JSONObject tempJson = meArr.getJSONObject(i);
String barCode = tempJson.getString("barCode"); String barCode = tempJson.getString("barCode");
barCodeList.add(barCode); String tempId = tempJson.getString("id");
MaterialExtend materialExtend = getInfoByBarCode(barCode); if(tempId.length()>19){
if (materialExtend.getBarCode() == null) {
insertedJson.add(tempJson); insertedJson.add(tempJson);
} else { } else {
updatedJson.add(tempJson); updatedJson.add(tempJson);
} }
} }
List<MaterialExtend> materialExtendList = getMeListByBarCodeAndMid(barCodeList, materialId);
for (MaterialExtend meObj : materialExtendList) {
JSONObject deleteObj = new JSONObject();
deleteObj.put("id", meObj.getId());
deletedJson.add(deleteObj);
} }
} }
if (null != deletedJson) {
StringBuffer bf=new StringBuffer();
for (int i = 0; i < deletedJson.size(); i++) {
bf.append(deletedJson.getString(i));
if(i<(deletedJson.size()-1)){
bf.append(",");
}
}
this.batchDeleteMaterialExtendByIds(bf.toString(), request);
} }
JSONArray sortJson = JSONArray.parseArray(sortList);
if (null != insertedJson) { if (null != insertedJson) {
for (int i = 0; i < insertedJson.size(); i++) { for (int i = 0; i < insertedJson.size(); i++) {
MaterialExtend materialExtend = new MaterialExtend(); MaterialExtend materialExtend = new MaterialExtend();
@@ -149,17 +151,6 @@ public class MaterialExtendService {
this.insertMaterialExtend(materialExtend); this.insertMaterialExtend(materialExtend);
} }
} }
if (null != deletedJson) {
StringBuffer bf=new StringBuffer();
for (int i = 0; i < deletedJson.size(); i++) {
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
bf.append(tempDeletedJson.getLong("id"));
if(i<(deletedJson.size()-1)){
bf.append(",");
}
}
this.batchDeleteMaterialExtendByIds(bf.toString(), request);
}
if (null != updatedJson) { if (null != updatedJson) {
for (int i = 0; i < updatedJson.size(); i++) { for (int i = 0; i < updatedJson.size(); i++) {
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i)); JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
@@ -379,11 +370,13 @@ public class MaterialExtendService {
* @throws Exception * @throws Exception
*/ */
public List<MaterialExtend> getMeListByBarCodeAndMid(List<String> barCodeList, Long mId)throws Exception { public List<MaterialExtend> getMeListByBarCodeAndMid(List<String> barCodeList, Long mId)throws Exception {
MaterialExtend materialExtend = new MaterialExtend(); List<MaterialExtend> list = new ArrayList<>();
if(barCodeList.size()>0) {
MaterialExtendExample example = new MaterialExtendExample(); MaterialExtendExample example = new MaterialExtendExample();
example.createCriteria().andBarCodeNotIn(barCodeList).andMaterialIdEqualTo(mId) example.createCriteria().andBarCodeNotIn(barCodeList).andMaterialIdEqualTo(mId)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<MaterialExtend> list = materialExtendMapper.selectByExample(example); list = materialExtendMapper.selectByExample(example);
}
return list; return list;
} }
} }

View File

@@ -59,7 +59,7 @@
<if test="enableBatchNumber != null and enableBatchNumber !=''"> <if test="enableBatchNumber != null and enableBatchNumber !=''">
and m.enable_batch_number = #{enableBatchNumber} and m.enable_batch_number = #{enableBatchNumber}
</if> </if>
<if test="enabled != null"> <if test="enabled != null and enabled !=''">
and m.enabled = #{enabled} and m.enabled = #{enabled}
</if> </if>
<if test="remark != null and remark !=''"> <if test="remark != null and remark !=''">
@@ -323,7 +323,7 @@
and ifnull(m.delete_flag,'0') !='1' and ifnull(m.delete_flag,'0') !='1'
</select> </select>
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList"> <select id="exportExcel" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
select m.*,u.name unitName, mc.name categoryName,me.bar_code,me.commodity_unit,me.purchase_decimal, me.commodity_decimal, select m.*,u.name unitName, mc.name categoryName,me.bar_code,me.commodity_unit,me.purchase_decimal, me.commodity_decimal,
me.wholesale_decimal, me.low_decimal me.wholesale_decimal, me.low_decimal
FROM jsh_material m FROM jsh_material m
@@ -332,21 +332,9 @@
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1' left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
where 1=1 where 1=1
and me.default_flag=1 and me.default_flag=1
<if test="barCode != null and barCode !=''"> <if test="materialParam != null and materialParam !=''">
<bind name="bindBarCode" value="'%'+barCode+'%'"/> <bind name="bindKey" value="'%'+materialParam+'%'"/>
and me.bar_code like #{bindBarCode} and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
<if test="name != null and name !=''">
<bind name="bindName" value="'%'+name+'%'"/>
and m.name like #{bindName}
</if>
<if test="standard != null and standard !=''">
<bind name="bindStandard" value="'%'+standard+'%'"/>
and m.standard like #{bindStandard}
</if>
<if test="model != null and model !=''">
<bind name="bindModel" value="'%'+standard+'%'"/>
and m.model like #{bindModel}
</if> </if>
<if test="color != null and color !=''"> <if test="color != null and color !=''">
<bind name="bindColor" value="'%'+color+'%'"/> <bind name="bindColor" value="'%'+color+'%'"/>
@@ -358,6 +346,9 @@
<if test="expiryNum != null and expiryNum !=''"> <if test="expiryNum != null and expiryNum !=''">
and m.expiry_num = #{expiryNum} and m.expiry_num = #{expiryNum}
</if> </if>
<if test="enabled != null and enabled !=''">
and m.enabled = #{enabled}
</if>
<if test="enableSerialNumber != null and enableSerialNumber !=''"> <if test="enableSerialNumber != null and enableSerialNumber !=''">
and m.enable_serial_number = #{enableSerialNumber} and m.enable_serial_number = #{enableSerialNumber}
</if> </if>