refactor(物料管理): 同步小型刀具库功能完善

This commit is contained in:
Kelvin 2024-12-13 14:38:48 +08:00
parent 36fdaa5687
commit b608fcb2bf
6 changed files with 68 additions and 37 deletions

View File

@ -18,6 +18,7 @@ import com.ktg.mes.md.service.IMdUnitMeasureService;
import com.ktg.mes.wm.utils.WmBarCodeUtil; import com.ktg.mes.wm.utils.WmBarCodeUtil;
import com.ktg.system.domain.SysOperLog; import com.ktg.system.domain.SysOperLog;
import com.ktg.system.service.ISysOperLogService; import com.ktg.system.service.ISysOperLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -29,22 +30,13 @@ import java.util.*;
@RestController @RestController
@RequestMapping("/mes/md/mditem") @RequestMapping("/mes/md/mditem")
@RequiredArgsConstructor
public class MdItemController extends BaseController { public class MdItemController extends BaseController {
private final IMdItemService mdItemService;
@Autowired private final IItemTypeService iItemTypeService;
private IMdItemService mdItemService; private final IMdUnitMeasureService mdUnitMeasureService;
private final WmBarCodeUtil barcodeUtil;
@Autowired private final ISysOperLogService operLogService;
private IItemTypeService iItemTypeService;
@Autowired
private IMdUnitMeasureService mdUnitMeasureService;
@Autowired
private WmBarCodeUtil barcodeUtil;
@Autowired
private ISysOperLogService operLogService;
/** /**
* 列表查询 * 列表查询
@ -140,6 +132,15 @@ public class MdItemController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
/**
* 同步小型刀具库 物料数据
* @return
*/
@GetMapping("/asyncSmallKnife")
public AjaxResult asyncSmallKnifeData() {
return AjaxResult.success(mdItemService.asyncSmallKnifeData());
}
/** /**
* 导出物料列表 * 导出物料列表
*/ */

View File

@ -1,10 +1,12 @@
package com.ktg.mes.md.mapper; package com.ktg.mes.md.mapper;
import com.ktg.common.core.domain.entity.ItemType; import com.ktg.common.core.domain.entity.ItemType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@Mapper
public interface ItemTypeMapper { public interface ItemTypeMapper {
/** /**

View File

@ -20,6 +20,12 @@ public interface IMdItemService {
*/ */
public List<MdItem> selectMdItemAll(); public List<MdItem> selectMdItemAll();
/**
* 同步小型刀具库数据
* @return
*/
public int asyncSmallKnifeData();
/** /**
* 获取导出格式的物料产品清单 * 获取导出格式的物料产品清单
* 主要区别是物料分类会以父级分类/子集分类的方式组合 * 主要区别是物料分类会以父级分类/子集分类的方式组合

View File

@ -10,8 +10,11 @@ import com.ktg.mes.md.mapper.BaseKnifeMapper;
import com.ktg.mes.md.mapper.ItemTypeMapper; import com.ktg.mes.md.mapper.ItemTypeMapper;
import com.ktg.mes.md.mapper.MdItemMapper; import com.ktg.mes.md.mapper.MdItemMapper;
import com.ktg.mes.md.service.IMdItemService; import com.ktg.mes.md.service.IMdItemService;
import com.ktg.mes.stl.domain.StlMaterial;
import com.ktg.mes.stl.mapper.StlMaterialMapper;
import com.ktg.mes.wm.utils.WmBarCodeUtil; import com.ktg.mes.wm.utils.WmBarCodeUtil;
import com.ktg.system.strategy.AutoCodeUtil; import com.ktg.system.strategy.AutoCodeUtil;
import lombok.RequiredArgsConstructor;
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 org.springframework.util.CollectionUtils;
@ -20,24 +23,15 @@ import javax.validation.Validator;
import java.util.List; import java.util.List;
@Service @Service
@RequiredArgsConstructor
public class MdItemServiceImpl implements IMdItemService { public class MdItemServiceImpl implements IMdItemService {
@Autowired private final BaseKnifeMapper baseKnifeMapper;
private BaseKnifeMapper baseKnifeMapper; private final MdItemMapper mdItemMapper;
private final ItemTypeMapper itemTypeMapper;
@Autowired protected final Validator validator;
private MdItemMapper mdItemMapper; private final WmBarCodeUtil barCodeUtil;
private final AutoCodeUtil autoCodeUtil;
@Autowired private final StlMaterialMapper stlMaterialMapper;
private ItemTypeMapper itemTypeMapper;
@Autowired
protected Validator validator;
@Autowired
private WmBarCodeUtil barCodeUtil;
@Autowired
private AutoCodeUtil autoCodeUtil;
@Override @Override
public List<MdItem> selectMdItemList(MdItem mdItem) { public List<MdItem> selectMdItemList(MdItem mdItem) {
@ -53,6 +47,36 @@ public class MdItemServiceImpl implements IMdItemService {
return mdItemMapper.selectMdItemAll(); return mdItemMapper.selectMdItemAll();
} }
@Override
public int asyncSmallKnifeData() {
List<StlMaterial> stlMaterials = stlMaterialMapper.selectList();
int count = 0;
for (StlMaterial stlMaterial : stlMaterials) {
MdItem mdItem = new MdItem();
mdItem.setItemCode(stlMaterial.getProductNumber());
mdItem.setItemName(stlMaterial.getProductName());
mdItem.setUnitName(stlMaterial.getSpecification());
mdItem.setUnitOfMeasure(stlMaterial.getSpecification());
// 产品物料标识 设置为 刀片
mdItem.setItemOrProduct("BLADE");
// 物料类型
mdItem.setItemTypeId(298L);
mdItem.setItemTypeCode("XXDJK");
mdItem.setItemTypeName("小型刀具库");
// 是否设置安全库存
mdItem.setSafeStockFlag("N");
// 查重
List<MdItem> mdItems = this.selectMdItemList(mdItem);
if (!mdItems.isEmpty()) {
continue;
}
this.insertMdItem(mdItem);
count++;
}
return count;
}
@Override @Override
public List<MdItem> getExeportList(MdItem mdItem) { public List<MdItem> getExeportList(MdItem mdItem) {
return mdItemMapper.getExeportList(mdItem); return mdItemMapper.getExeportList(mdItem);

View File

@ -3,6 +3,7 @@ package com.ktg.mes.stl.mapper;
import com.ktg.common.annotation.DataSource; import com.ktg.common.annotation.DataSource;
import com.ktg.common.enums.DataSourceType; import com.ktg.common.enums.DataSourceType;
import com.ktg.mes.md.domain.AP0AD; import com.ktg.mes.md.domain.AP0AD;
import com.ktg.mes.stl.domain.StlMaterial;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
@ -13,8 +14,5 @@ import java.util.List;
@Mapper @Mapper
public interface StlMaterialMapper { public interface StlMaterialMapper {
@DataSource(DataSourceType.SQLSERVER) @DataSource(DataSourceType.SQLSERVER)
List<AP0AD> selectOutNewData(); List<StlMaterial> selectList();
@DataSource(DataSourceType.SQLSERVER)
int updateOutDataToOld(AP0AD ap0ad);
} }

View File

@ -106,7 +106,7 @@
UDF54, UDF54,
UDF55, UDF55,
USER01, USER01,
DATE01, DATE01
from AP0AA from AP0AA
</sql> </sql>