fix:物料产品管理中的SIP和SOP图片展示顺序和图片和导入功能问题解决

This commit is contained in:
zhangxuanming 2024-12-23 15:07:42 +08:00
parent 1fc0123e17
commit f675187f81
8 changed files with 108 additions and 33 deletions

View File

@ -76,7 +76,7 @@ public class MdProductSipController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody MdProductSip mdProductSip) public AjaxResult add(@RequestBody MdProductSip mdProductSip)
{ {
return toAjax(mdProductSipService.insertMdProductSip(mdProductSip)); return mdProductSipService.insertMdProductSip(mdProductSip);
} }
/** /**
@ -87,7 +87,7 @@ public class MdProductSipController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody MdProductSip mdProductSip) public AjaxResult edit(@RequestBody MdProductSip mdProductSip)
{ {
return toAjax(mdProductSipService.updateMdProductSip(mdProductSip)); return mdProductSipService.updateMdProductSip(mdProductSip);
} }
/** /**

View File

@ -76,7 +76,7 @@ public class MdProductSopController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody MdProductSop mdProdutSop) public AjaxResult add(@RequestBody MdProductSop mdProdutSop)
{ {
return toAjax(mdProductSopService.insertMdProductSop(mdProdutSop)); return mdProductSopService.insertMdProductSop(mdProdutSop);
} }
/** /**
@ -87,7 +87,7 @@ public class MdProductSopController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody MdProductSop mdProdutSop) public AjaxResult edit(@RequestBody MdProductSop mdProdutSop)
{ {
return toAjax(mdProductSopService.updateMdProductSop(mdProdutSop)); return mdProductSopService.updateMdProductSop(mdProdutSop);
} }
/** /**

View File

@ -1,6 +1,8 @@
package com.ktg.mes.md.service; package com.ktg.mes.md.service;
import java.util.List; import java.util.List;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.mes.md.domain.MdProductSip; import com.ktg.mes.md.domain.MdProductSip;
/** /**
@ -33,7 +35,7 @@ public interface IMdProductSipService
* @param mdProductSip 产品SIP * @param mdProductSip 产品SIP
* @return 结果 * @return 结果
*/ */
public int insertMdProductSip(MdProductSip mdProductSip); public AjaxResult insertMdProductSip(MdProductSip mdProductSip);
/** /**
* 修改产品SIP * 修改产品SIP
@ -41,7 +43,7 @@ public interface IMdProductSipService
* @param mdProductSip 产品SIP * @param mdProductSip 产品SIP
* @return 结果 * @return 结果
*/ */
public int updateMdProductSip(MdProductSip mdProductSip); public AjaxResult updateMdProductSip(MdProductSip mdProductSip);
/** /**
* 批量删除产品SIP * 批量删除产品SIP

View File

@ -1,6 +1,8 @@
package com.ktg.mes.md.service; package com.ktg.mes.md.service;
import java.util.List; import java.util.List;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.mes.md.domain.MdProductSop; import com.ktg.mes.md.domain.MdProductSop;
/** /**
@ -33,7 +35,7 @@ public interface IMdProductSopService
* @param mdProdutSop 产品SOP * @param mdProdutSop 产品SOP
* @return 结果 * @return 结果
*/ */
public int insertMdProductSop(MdProductSop mdProductSop); public AjaxResult insertMdProductSop(MdProductSop mdProductSop);
/** /**
* 修改产品SOP * 修改产品SOP
@ -41,7 +43,7 @@ public interface IMdProductSopService
* @param mdProdutSop 产品SOP * @param mdProdutSop 产品SOP
* @return 结果 * @return 结果
*/ */
public int updateMdProductSop(MdProductSop mdProductSop); public AjaxResult updateMdProductSop(MdProductSop mdProductSop);
/** /**
* 批量删除产品SOP * 批量删除产品SOP

View File

@ -1,5 +1,6 @@
package com.ktg.mes.md.service.impl; package com.ktg.mes.md.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.ktg.common.core.domain.entity.ItemType; import com.ktg.common.core.domain.entity.ItemType;
import com.ktg.common.exception.ServiceException; import com.ktg.common.exception.ServiceException;
import com.ktg.common.utils.bean.BeanValidators; import com.ktg.common.utils.bean.BeanValidators;
@ -65,6 +66,21 @@ public class MdItemServiceImpl implements IMdItemService {
for (MdItem item : itemList) for (MdItem item : itemList)
{ {
try{ try{
if (ObjectUtil.isEmpty(item.getItemCode())) {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 缺少必填项");
continue;
}
if (ObjectUtil.isEmpty(item.getItemName())) {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 缺少必填项");
continue;
}
if (ObjectUtil.isEmpty(item.getUnitOfMeasure())) {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 缺少必填项");
continue;
}
//物料分类是否正确 //物料分类是否正确
if(StringUtils.isNotNull(item.getItemTypeName())){ if(StringUtils.isNotNull(item.getItemTypeName())){
List<ItemType> types = itemTypeMapper.selectItemTypeByName(item.getItemTypeName()); List<ItemType> types = itemTypeMapper.selectItemTypeByName(item.getItemTypeName());

View File

@ -1,6 +1,10 @@
package com.ktg.mes.md.service.impl; package com.ktg.mes.md.service.impl;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.utils.DateUtils; import com.ktg.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -41,7 +45,9 @@ public class MdProductSipServiceImpl implements IMdProductSipService
@Override @Override
public List<MdProductSip> selectMdProductSipList(MdProductSip mdProductSip) public List<MdProductSip> selectMdProductSipList(MdProductSip mdProductSip)
{ {
return mdProductSipMapper.selectMdProductSipList(mdProductSip); List<MdProductSip> mdProductSips = mdProductSipMapper.selectMdProductSipList(mdProductSip);
List<MdProductSip> collect = mdProductSips.stream().sorted(Comparator.comparing(MdProductSip::getOrderNum)).collect(Collectors.toList());
return collect;
} }
/** /**
@ -51,10 +57,19 @@ public class MdProductSipServiceImpl implements IMdProductSipService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertMdProductSip(MdProductSip mdProductSip) public AjaxResult insertMdProductSip(MdProductSip mdProductSip)
{ {
// 查询当前物料下所有的SIP
MdProductSip parame = new MdProductSip();
parame.setItemId(mdProductSip.getItemId());
List<MdProductSip> list = mdProductSipMapper.selectMdProductSipList(parame);
for (MdProductSip item : list) {
if (item.getOrderNum() == mdProductSip.getOrderNum()) {
return AjaxResult.error("展示序号已存在");
}
}
mdProductSip.setCreateTime(DateUtils.getNowDate()); mdProductSip.setCreateTime(DateUtils.getNowDate());
return mdProductSipMapper.insertMdProductSip(mdProductSip); return AjaxResult.success(mdProductSipMapper.insertMdProductSip(mdProductSip));
} }
/** /**
@ -64,10 +79,19 @@ public class MdProductSipServiceImpl implements IMdProductSipService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateMdProductSip(MdProductSip mdProductSip) public AjaxResult updateMdProductSip(MdProductSip mdProductSip)
{ {
// 查询当前物料下所有的SIP
MdProductSip parame = new MdProductSip();
parame.setItemId(mdProductSip.getItemId());
List<MdProductSip> list = mdProductSipMapper.selectMdProductSipList(parame);
for (MdProductSip item : list) {
if (item.getOrderNum() == mdProductSip.getOrderNum()) {
return AjaxResult.error("展示序号已存在");
}
}
mdProductSip.setUpdateTime(DateUtils.getNowDate()); mdProductSip.setUpdateTime(DateUtils.getNowDate());
return mdProductSipMapper.updateMdProductSip(mdProductSip); return AjaxResult.success(mdProductSipMapper.updateMdProductSip(mdProductSip));
} }
/** /**

View File

@ -1,7 +1,12 @@
package com.ktg.mes.md.service.impl; package com.ktg.mes.md.service.impl;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.utils.DateUtils; import com.ktg.common.utils.DateUtils;
import com.ktg.mes.md.domain.MdProductSip;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ktg.mes.md.mapper.MdProductSopMapper; import com.ktg.mes.md.mapper.MdProductSopMapper;
@ -41,7 +46,9 @@ public class MdProductSopServiceImpl implements IMdProductSopService
@Override @Override
public List<MdProductSop> selectMdProductSopList(MdProductSop mdProdutSop) public List<MdProductSop> selectMdProductSopList(MdProductSop mdProdutSop)
{ {
return mdProductSopMapper.selectMdProductSopList(mdProdutSop); List<MdProductSop> mdProductSops = mdProductSopMapper.selectMdProductSopList(mdProdutSop);
List<MdProductSop> collect = mdProductSops.stream().sorted(Comparator.comparing(MdProductSop::getOrderNum)).collect(Collectors.toList());
return collect;
} }
/** /**
@ -51,10 +58,19 @@ public class MdProductSopServiceImpl implements IMdProductSopService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertMdProductSop(MdProductSop mdProdutSop) public AjaxResult insertMdProductSop(MdProductSop mdProdutSop)
{ {
// 查询当前物料下所有的SOP
MdProductSop parame = new MdProductSop();
parame.setItemId(mdProdutSop.getItemId());
List<MdProductSop> list = mdProductSopMapper.selectMdProductSopList(mdProdutSop);
for (MdProductSop item : list) {
if (item.getOrderNum() == mdProdutSop.getOrderNum()) {
return AjaxResult.error("展示序号已存在");
}
}
mdProdutSop.setCreateTime(DateUtils.getNowDate()); mdProdutSop.setCreateTime(DateUtils.getNowDate());
return mdProductSopMapper.insertMdProductSop(mdProdutSop); return AjaxResult.success(mdProductSopMapper.insertMdProductSop(mdProdutSop));
} }
/** /**
@ -64,10 +80,19 @@ public class MdProductSopServiceImpl implements IMdProductSopService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateMdProductSop(MdProductSop mdProdutSop) public AjaxResult updateMdProductSop(MdProductSop mdProdutSop)
{ {
// 查询当前物料下所有的SOP
MdProductSop parame = new MdProductSop();
parame.setItemId(mdProdutSop.getItemId());
List<MdProductSop> list = mdProductSopMapper.selectMdProductSopList(mdProdutSop);
for (MdProductSop item : list) {
if (item.getOrderNum() == mdProdutSop.getOrderNum()) {
return AjaxResult.error("展示序号已存在");
}
}
mdProdutSop.setUpdateTime(DateUtils.getNowDate()); mdProdutSop.setUpdateTime(DateUtils.getNowDate());
return mdProductSopMapper.updateMdProductSop(mdProdutSop); return AjaxResult.success(mdProductSopMapper.updateMdProductSop(mdProdutSop));
} }
/** /**

View File

@ -84,15 +84,21 @@
where item_type_name=#{itemTypeName} and parent_type_id = #{parentTypeId} limit 1 where item_type_name=#{itemTypeName} and parent_type_id = #{parentTypeId} limit 1
</select> </select>
<!-- <select id="selectItemTypeByName" parameterType="String" resultMap="ItemTypeResult">-->
<!-- select *-->
<!-- from (-->
<!-- select CONCAT((select group_concat(item_type_name separator '/')-->
<!-- from md_item_type b-->
<!-- where FIND_IN_SET(CAST(item_type_id as CHAR),a.ancestors)>0),'/',a.item_type_name) as fullType,a.*-->
<!-- from md_item_type a-->
<!-- ) t-->
<!-- where fullType = #{itemTypeName} or t.item_type_name = #{itemTypeName}-->
<!-- </select>-->
<select id="selectItemTypeByName" parameterType="String" resultMap="ItemTypeResult"> <select id="selectItemTypeByName" parameterType="String" resultMap="ItemTypeResult">
select * select *
from ( from md_item_type
select CONCAT((select group_concat(item_type_name separator '/') where item_type_name = #{itemTypeName}
from md_item_type b
where FIND_IN_SET(CAST(item_type_id as CHAR),a.ancestors)>0),'/',a.item_type_name) as fullType,a.*
from md_item_type a
) t
where fullType = #{itemTypeName} or t.item_type_name = #{itemTypeName}
</select> </select>
<select id="checkItemTypeCodeUnique" resultMap="ItemTypeResult"> <select id="checkItemTypeCodeUnique" resultMap="ItemTypeResult">