物料产品导出导入功能
This commit is contained in:
parent
1b1215080e
commit
902814c027
@ -62,7 +62,7 @@ public class MdItemController extends BaseController {
|
|||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, MdItem mdItem)
|
public void export(HttpServletResponse response, MdItem mdItem)
|
||||||
{
|
{
|
||||||
List<MdItem> list = mdItemService.selectMdItemList(mdItem);
|
List<MdItem> list = mdItemService.getExeportList(mdItem);
|
||||||
ExcelUtil<MdItem> util = new ExcelUtil<MdItem>(MdItem.class);
|
ExcelUtil<MdItem> util = new ExcelUtil<MdItem>(MdItem.class);
|
||||||
util.exportExcel(response, list, "物料产品数据");
|
util.exportExcel(response, list, "物料产品数据");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,6 @@ public class MdItem extends BaseEntity {
|
|||||||
private String unitName;
|
private String unitName;
|
||||||
private String itemOrProduct;
|
private String itemOrProduct;
|
||||||
private Long itemTypeId;
|
private Long itemTypeId;
|
||||||
@Excel(name = "分类编码")
|
|
||||||
private String itemTypeCode;
|
private String itemTypeCode;
|
||||||
@Excel(name = "分类名称")
|
@Excel(name = "分类名称")
|
||||||
private String itemTypeName;
|
private String itemTypeName;
|
||||||
@ -47,7 +46,6 @@ public class MdItem extends BaseEntity {
|
|||||||
this.itemId = itemId;
|
this.itemId = itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "物料产品编码不能为空")
|
|
||||||
@Size(min = 0,max = 64,message = "物料产品编码长度不能超过64个字符")
|
@Size(min = 0,max = 64,message = "物料产品编码长度不能超过64个字符")
|
||||||
public String getItemCode() {
|
public String getItemCode() {
|
||||||
return itemCode;
|
return itemCode;
|
||||||
@ -76,7 +74,7 @@ public class MdItem extends BaseEntity {
|
|||||||
this.specification = specification;
|
this.specification = specification;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "单位不能为空")
|
@NotBlank(message = "单位编码不能为空")
|
||||||
public String getUnitOfMeasure() {
|
public String getUnitOfMeasure() {
|
||||||
return unitOfMeasure;
|
return unitOfMeasure;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,14 @@ public interface ItemTypeMapper {
|
|||||||
*/
|
*/
|
||||||
public ItemType selectItemTypeById(Long itemTypeId);
|
public ItemType selectItemTypeById(Long itemTypeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分类名称查找分类
|
||||||
|
* 在重名的情况下,支持按【上级分类】/【下级分类】的模式进行查找
|
||||||
|
* @param itemTypeName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<ItemType> selectItemTypeByName(String itemTypeName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据父类ID查询是否有子类
|
* 根据父类ID查询是否有子类
|
||||||
* @param parentTypeId
|
* @param parentTypeId
|
||||||
|
|||||||
@ -19,6 +19,9 @@ public interface MdItemMapper {
|
|||||||
public List<MdItem> selectMdItemAll();
|
public List<MdItem> selectMdItemAll();
|
||||||
|
|
||||||
|
|
||||||
|
public List<MdItem> getExeportList(MdItem mdItem);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据物料ID查询物料
|
* 根据物料ID查询物料
|
||||||
* @param itemId
|
* @param itemId
|
||||||
|
|||||||
@ -9,6 +9,8 @@ public interface IItemTypeService {
|
|||||||
|
|
||||||
public List<ItemType> selectItemTypeList(ItemType itemType);
|
public List<ItemType> selectItemTypeList(ItemType itemType);
|
||||||
|
|
||||||
|
public ItemType selectItemTypeByName(String typeName);
|
||||||
|
|
||||||
public ItemType selectItemTypeById(Long itemTypeId);
|
public ItemType selectItemTypeById(Long itemTypeId);
|
||||||
|
|
||||||
public List<TreeSelect> buildTreeSelect(List<ItemType> list);
|
public List<TreeSelect> buildTreeSelect(List<ItemType> list);
|
||||||
|
|||||||
@ -20,10 +20,18 @@ public interface IMdItemService {
|
|||||||
*/
|
*/
|
||||||
public List<MdItem> selectMdItemAll();
|
public List<MdItem> selectMdItemAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取导出格式的物料产品清单
|
||||||
|
* 主要区别是物料分类会以【父级分类】/【子集分类】的方式组合
|
||||||
|
* @param mdItem
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<MdItem> getExeportList(MdItem mdItem);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入物料信息
|
* 导入物料信息
|
||||||
* @param vendorList
|
* @param itemList
|
||||||
* @param isUpdateSupport
|
* @param isUpdateSupport
|
||||||
* @param operName
|
* @param operName
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.ktg.mes.md.mapper.ItemTypeMapper;
|
|||||||
import com.ktg.mes.md.service.IItemTypeService;
|
import com.ktg.mes.md.service.IItemTypeService;
|
||||||
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 org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -25,6 +26,21 @@ public class ItemTypeServiceImpl implements IItemTypeService {
|
|||||||
return itemTypeMapper.selectItemTypeList(itemType);
|
return itemTypeMapper.selectItemTypeList(itemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分类名称查找分类
|
||||||
|
* 在重名的情况下,支持按【上级分类】/【下级分类】的模式进行查找
|
||||||
|
* @param itemTypeName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemType selectItemTypeByName(String itemTypeName) {
|
||||||
|
List<ItemType> types = itemTypeMapper.selectItemTypeByName(itemTypeName);
|
||||||
|
if(!CollectionUtils.isEmpty(types)){
|
||||||
|
return types.get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemType selectItemTypeById(Long itemTypeId) {
|
public ItemType selectItemTypeById(Long itemTypeId) {
|
||||||
return itemTypeMapper.selectItemTypeById(itemTypeId);
|
return itemTypeMapper.selectItemTypeById(itemTypeId);
|
||||||
|
|||||||
@ -189,6 +189,7 @@ public class MdClientServiceImpl implements IMdClientService
|
|||||||
String msg = "<br/>" + failureNum + "、客户 " + client.getClientName() + " 导入失败:";
|
String msg = "<br/>" + failureNum + "、客户 " + client.getClientName() + " 导入失败:";
|
||||||
failureMsg.append(msg + e.getMessage());
|
failureMsg.append(msg + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (failureNum > 0)
|
if (failureNum > 0)
|
||||||
{
|
{
|
||||||
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
@ -198,7 +199,6 @@ public class MdClientServiceImpl implements IMdClientService
|
|||||||
{
|
{
|
||||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return successMsg.toString();
|
return successMsg.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,11 +47,16 @@ public class MdItemServiceImpl implements IMdItemService {
|
|||||||
return mdItemMapper.selectMdItemAll();
|
return mdItemMapper.selectMdItemAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MdItem> getExeportList(MdItem mdItem) {
|
||||||
|
return mdItemMapper.getExeportList(mdItem);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String importItem(List<MdItem> itemList, Boolean isUpdateSupport, String operName) {
|
public String importItem(List<MdItem> itemList, Boolean isUpdateSupport, String operName) {
|
||||||
if (StringUtils.isNull(itemList) || itemList.size() == 0)
|
if (StringUtils.isNull(itemList) || itemList.size() == 0)
|
||||||
{
|
{
|
||||||
throw new ServiceException("导入供应商数据不能为空!");
|
throw new ServiceException("导入物料产品数据不能为空!");
|
||||||
}
|
}
|
||||||
int successNum = 0;
|
int successNum = 0;
|
||||||
int failureNum = 0;
|
int failureNum = 0;
|
||||||
@ -61,13 +66,17 @@ public class MdItemServiceImpl implements IMdItemService {
|
|||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
//物料分类是否正确
|
//物料分类是否正确
|
||||||
if(StringUtils.isNotNull(item.getItemTypeCode())){
|
if(StringUtils.isNotNull(item.getItemTypeName())){
|
||||||
ItemType q = new ItemType();
|
List<ItemType> types = itemTypeMapper.selectItemTypeByName(item.getItemTypeName());
|
||||||
q.setItemTypeCode(item.getItemTypeCode());
|
if(!CollectionUtils.isEmpty(types)){
|
||||||
List<ItemType> types = itemTypeMapper.selectItemTypeList(q);
|
|
||||||
if(CollectionUtils.isEmpty(types)){
|
|
||||||
item.setItemTypeId(types.get(0).getItemTypeId());
|
item.setItemTypeId(types.get(0).getItemTypeId());
|
||||||
|
item.setItemTypeCode(types.get(0).getItemTypeCode());
|
||||||
item.setItemTypeName(types.get(0).getItemTypeName());
|
item.setItemTypeName(types.get(0).getItemTypeName());
|
||||||
|
item.setItemOrProduct(types.get(0).getItemOrProduct());
|
||||||
|
|
||||||
|
item.setSafeStockFlag(UserConstants.NO);
|
||||||
|
item.setEnableFlag(UserConstants.YES);
|
||||||
|
item.setHighValue(UserConstants.NO);
|
||||||
|
|
||||||
//是否存在
|
//是否存在
|
||||||
MdItem v = mdItemMapper.checkItemCodeUnique(item);
|
MdItem v = mdItemMapper.checkItemCodeUnique(item);
|
||||||
@ -90,17 +99,18 @@ public class MdItemServiceImpl implements IMdItemService {
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
failureNum++;
|
failureNum++;
|
||||||
failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 请填写正确的分类编码");
|
failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 请填写正确的分类");
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
failureNum++;
|
failureNum++;
|
||||||
failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 请填写分类编码");
|
failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 请填写分类");
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
failureNum++;
|
failureNum++;
|
||||||
String msg = "<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 导入失败:";
|
String msg = "<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 导入失败:";
|
||||||
failureMsg.append(msg + e.getMessage());
|
failureMsg.append(msg + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (failureNum > 0)
|
if (failureNum > 0)
|
||||||
{
|
{
|
||||||
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
@ -110,7 +120,6 @@ public class MdItemServiceImpl implements IMdItemService {
|
|||||||
{
|
{
|
||||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return successMsg.toString();
|
return successMsg.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -132,6 +132,7 @@ public class MdVendorServiceImpl implements IMdVendorService
|
|||||||
String msg = "<br/>" + failureNum + "、供应商 " + vendor.getVendorName() + " 导入失败:";
|
String msg = "<br/>" + failureNum + "、供应商 " + vendor.getVendorName() + " 导入失败:";
|
||||||
failureMsg.append(msg + e.getMessage());
|
failureMsg.append(msg + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (failureNum > 0)
|
if (failureNum > 0)
|
||||||
{
|
{
|
||||||
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
@ -141,7 +142,6 @@ public class MdVendorServiceImpl implements IMdVendorService
|
|||||||
{
|
{
|
||||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return successMsg.toString();
|
return successMsg.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -83,6 +83,18 @@
|
|||||||
<include refid="selectItemTypeVo"/>
|
<include refid="selectItemTypeVo"/>
|
||||||
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="checkItemTypeCodeUnique" resultMap="ItemTypeResult">
|
<select id="checkItemTypeCodeUnique" resultMap="ItemTypeResult">
|
||||||
<include refid="selectItemTypeVo"/>
|
<include refid="selectItemTypeVo"/>
|
||||||
where item_type_code=#{itemTypeCode} and parent_type_id = #{parentTypeId} limit 1
|
where item_type_code=#{itemTypeCode} and parent_type_id = #{parentTypeId} limit 1
|
||||||
|
|||||||
@ -55,6 +55,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getExeportList" parameterType="MdItem" resultMap="MdItemResult">
|
||||||
|
select i.item_id, i.item_code, i.item_name, i.specification, i.unit_of_measure,i.unit_name, i.item_or_product,
|
||||||
|
i.item_type_id,i.item_type_code,i.enable_flag,i.safe_stock_flag,i.min_stock,i.max_stock,i.high_value, i.create_by, i.create_time, i.remark,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 item_type_name
|
||||||
|
from md_item i
|
||||||
|
left join md_item_type a
|
||||||
|
on i.item_type_id = a.item_type_id
|
||||||
|
<where>
|
||||||
|
<if test="itemCode != null and itemCode != ''">
|
||||||
|
AND i.item_code like concat('%', #{itemCode}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="itemTypeId != null and itemTypeId != 0 ">
|
||||||
|
AND (i.item_type_id = #{itemTypeId} OR i.item_type_id in (select item_type_id from md_item_type where find_in_set(#{itemTypeId},ancestors)))
|
||||||
|
</if>
|
||||||
|
<if test="itemName != null and itemName != ''">
|
||||||
|
AND i.item_name like concat('%', #{itemName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="enableFlag != null and enableFlag != ''">
|
||||||
|
AND i.enable_flag = #{enableFlag}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectMdItemAll" resultMap="MdItemResult">
|
<select id="selectMdItemAll" resultMap="MdItemResult">
|
||||||
<include refid="selectMdItemVo"></include>
|
<include refid="selectMdItemVo"></include>
|
||||||
</select>
|
</select>
|
||||||
@ -80,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
item_name,
|
item_name,
|
||||||
<if test="specification !=null and specification !=''">specification,</if>
|
<if test="specification !=null and specification !=''">specification,</if>
|
||||||
unit_of_measure,
|
unit_of_measure,
|
||||||
<if test="unitName != null and unitName !=''">unitName,</if>
|
<if test="unitName != null and unitName !=''">unit_name,</if>
|
||||||
item_or_product,
|
item_or_product,
|
||||||
item_type_id,
|
item_type_id,
|
||||||
<if test="itemTypeCode !=null and itemTypeCode !=''">item_type_code,</if>
|
<if test="itemTypeCode !=null and itemTypeCode !=''">item_type_code,</if>
|
||||||
@ -89,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
safe_stock_flag,
|
safe_stock_flag,
|
||||||
<if test="safeStockFlag =='Y'.toString()">min_stock,</if>
|
<if test="safeStockFlag =='Y'.toString()">min_stock,</if>
|
||||||
<if test="safeStockFlag =='Y'.toString()">max_stock,</if>
|
<if test="safeStockFlag =='Y'.toString()">max_stock,</if>
|
||||||
<if test="highValue !=null and highValue !=''">#{high_value},</if>
|
<if test="highValue !=null and highValue !=''">high_value,</if>
|
||||||
<if test="remark !=null and remark !=''">remark,</if>
|
<if test="remark !=null and remark !=''">remark,</if>
|
||||||
<if test="attr1 !=null and attr1 !=''">attr1,</if>
|
<if test="attr1 !=null and attr1 !=''">attr1,</if>
|
||||||
<if test="attr2 !=null and attr2 !=''">attr2,</if>
|
<if test="attr2 !=null and attr2 !=''">attr2,</if>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user