diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/controller/MdItemController.java b/ktg-mes/src/main/java/com/ktg/mes/md/controller/MdItemController.java index 1c9cd4c..927b870 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/controller/MdItemController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/controller/MdItemController.java @@ -18,6 +18,7 @@ import com.ktg.mes.md.service.IMdUnitMeasureService; import com.ktg.mes.wm.utils.WmBarCodeUtil; import com.ktg.system.domain.SysOperLog; import com.ktg.system.service.ISysOperLogService; +import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -29,22 +30,13 @@ import java.util.*; @RestController @RequestMapping("/mes/md/mditem") +@RequiredArgsConstructor public class MdItemController extends BaseController { - - @Autowired - private IMdItemService mdItemService; - - @Autowired - private IItemTypeService iItemTypeService; - - @Autowired - private IMdUnitMeasureService mdUnitMeasureService; - - @Autowired - private WmBarCodeUtil barcodeUtil; - - @Autowired - private ISysOperLogService operLogService; + private final IMdItemService mdItemService; + private final IItemTypeService iItemTypeService; + private final IMdUnitMeasureService mdUnitMeasureService; + private final WmBarCodeUtil barcodeUtil; + private final ISysOperLogService operLogService; /** * 列表查询 @@ -140,6 +132,15 @@ public class MdItemController extends BaseController { return getDataTable(list); } + /** + * 同步小型刀具库 物料数据 + * @return + */ + @GetMapping("/asyncSmallKnife") + public AjaxResult asyncSmallKnifeData() { + return AjaxResult.success(mdItemService.asyncSmallKnifeData()); + } + /** * 导出物料列表 */ diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/ItemTypeMapper.java b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/ItemTypeMapper.java index 0994abd..a7c5b76 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/ItemTypeMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/ItemTypeMapper.java @@ -1,10 +1,12 @@ package com.ktg.mes.md.mapper; import com.ktg.common.core.domain.entity.ItemType; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +@Mapper public interface ItemTypeMapper { /** diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/IMdItemService.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/IMdItemService.java index 2a3cb5f..d9615e4 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/IMdItemService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/IMdItemService.java @@ -20,6 +20,12 @@ public interface IMdItemService { */ public List selectMdItemAll(); + /** + * 同步小型刀具库数据 + * @return + */ + public int asyncSmallKnifeData(); + /** * 获取导出格式的物料产品清单 * 主要区别是物料分类会以【父级分类】/【子集分类】的方式组合 diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MdItemServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MdItemServiceImpl.java index 4c5d478..218c164 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MdItemServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MdItemServiceImpl.java @@ -10,8 +10,11 @@ import com.ktg.mes.md.mapper.BaseKnifeMapper; import com.ktg.mes.md.mapper.ItemTypeMapper; import com.ktg.mes.md.mapper.MdItemMapper; 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.system.strategy.AutoCodeUtil; +import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -20,24 +23,15 @@ import javax.validation.Validator; import java.util.List; @Service +@RequiredArgsConstructor public class MdItemServiceImpl implements IMdItemService { - @Autowired - private BaseKnifeMapper baseKnifeMapper; - - @Autowired - private MdItemMapper mdItemMapper; - - @Autowired - private ItemTypeMapper itemTypeMapper; - - @Autowired - protected Validator validator; - - @Autowired - private WmBarCodeUtil barCodeUtil; - - @Autowired - private AutoCodeUtil autoCodeUtil; + private final BaseKnifeMapper baseKnifeMapper; + private final MdItemMapper mdItemMapper; + private final ItemTypeMapper itemTypeMapper; + protected final Validator validator; + private final WmBarCodeUtil barCodeUtil; + private final AutoCodeUtil autoCodeUtil; + private final StlMaterialMapper stlMaterialMapper; @Override public List selectMdItemList(MdItem mdItem) { @@ -53,6 +47,36 @@ public class MdItemServiceImpl implements IMdItemService { return mdItemMapper.selectMdItemAll(); } + @Override + public int asyncSmallKnifeData() { + List 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 mdItems = this.selectMdItemList(mdItem); + if (!mdItems.isEmpty()) { + continue; + } + this.insertMdItem(mdItem); + count++; + } + return count; + } + @Override public List getExeportList(MdItem mdItem) { return mdItemMapper.getExeportList(mdItem); diff --git a/ktg-mes/src/main/java/com/ktg/mes/stl/mapper/StlMaterialMapper.java b/ktg-mes/src/main/java/com/ktg/mes/stl/mapper/StlMaterialMapper.java index 557c2a4..f11236b 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/stl/mapper/StlMaterialMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/stl/mapper/StlMaterialMapper.java @@ -3,6 +3,7 @@ package com.ktg.mes.stl.mapper; import com.ktg.common.annotation.DataSource; import com.ktg.common.enums.DataSourceType; import com.ktg.mes.md.domain.AP0AD; +import com.ktg.mes.stl.domain.StlMaterial; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -13,8 +14,5 @@ import java.util.List; @Mapper public interface StlMaterialMapper { @DataSource(DataSourceType.SQLSERVER) - List selectOutNewData(); - - @DataSource(DataSourceType.SQLSERVER) - int updateOutDataToOld(AP0AD ap0ad); + List selectList(); } diff --git a/ktg-mes/src/main/resources/mapper/stl/StlMaterialMapper.xml b/ktg-mes/src/main/resources/mapper/stl/StlMaterialMapper.xml index 834c660..8f8395c 100644 --- a/ktg-mes/src/main/resources/mapper/stl/StlMaterialMapper.xml +++ b/ktg-mes/src/main/resources/mapper/stl/StlMaterialMapper.xml @@ -106,7 +106,7 @@ UDF54, UDF55, USER01, - DATE01, + DATE01 from AP0AA