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

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

View File

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

View File

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

View File

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

View File

@ -59,7 +59,7 @@
<if test="enableBatchNumber != null and enableBatchNumber !=''">
and m.enable_batch_number = #{enableBatchNumber}
</if>
<if test="enabled != null">
<if test="enabled != null and enabled !=''">
and m.enabled = #{enabled}
</if>
<if test="remark != null and remark !=''">
@ -323,7 +323,7 @@
and ifnull(m.delete_flag,'0') !='1'
</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,
me.wholesale_decimal, me.low_decimal
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'
where 1=1
and me.default_flag=1
<if test="barCode != null and barCode !=''">
<bind name="bindBarCode" value="'%'+barCode+'%'"/>
and me.bar_code like #{bindBarCode}
</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 test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
<if test="color != null and color !=''">
<bind name="bindColor" value="'%'+color+'%'"/>
@ -358,6 +346,9 @@
<if test="expiryNum != null and expiryNum !=''">
and m.expiry_num = #{expiryNum}
</if>
<if test="enabled != null and enabled !=''">
and m.enabled = #{enabled}
</if>
<if test="enableSerialNumber != null and enableSerialNumber !=''">
and m.enable_serial_number = #{enableSerialNumber}
</if>