Commit c4798beb authored by 李驰骋's avatar 李驰骋

物料分类同步添加

parent 12d68cc5
...@@ -81,9 +81,6 @@ public class MdItem extends BaseEntity { ...@@ -81,9 +81,6 @@ public class MdItem extends BaseEntity {
@ApiModelProperty("客户品号") @ApiModelProperty("客户品号")
private String customerProNo; private String customerProNo;
@ApiModelProperty("主要仓库")
private String mainWarehouseCode;
@ApiModelProperty("主要仓库") @ApiModelProperty("主要仓库")
private String mainWarehouseId; private String mainWarehouseId;
......
...@@ -30,5 +30,6 @@ public interface IItemTypeService { ...@@ -30,5 +30,6 @@ public interface IItemTypeService {
boolean checkHasItem(Long itemTypeId); boolean checkHasItem(Long itemTypeId);
void synchroItemType(List<MdItemTypeVo> mdItemTypeVos); void synchroItemType();
} }
...@@ -16,7 +16,7 @@ import java.util.List; ...@@ -16,7 +16,7 @@ import java.util.List;
public interface IMdWorkunitService { public interface IMdWorkunitService {
public static Long OUTSOURCE_WORKUNIT_ID = 1l; public static Long OUTSOURCE_WORKUNIT_ID = 1l;
public static String OUTSOURCE_WORKUNIT_CODE = "XMSWWDY"; public static String OUTSOURCE_WORKUNIT_CODE = "XMWWDY";
/** /**
* 查询工作单元 * 查询工作单元
* *
......
package com.ximai.mes.md.service.impl; package com.ximai.mes.md.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.ximai.common.constant.UserConstants; import com.ximai.common.constant.UserConstants;
import com.ximai.common.core.domain.TreeSelect; import com.ximai.common.core.domain.TreeSelect;
import com.ximai.common.core.domain.entity.MdItemType; import com.ximai.common.core.domain.entity.MdItemType;
import com.ximai.common.utils.data.DateUtils; import com.ximai.common.utils.data.DateUtils;
import com.ximai.common.utils.data.StringUtils; import com.ximai.common.utils.data.StringUtils;
import com.ximai.mes.md.domain.MdVendor;
import com.ximai.mes.md.mapper.ItemTypeMapper; import com.ximai.mes.md.mapper.ItemTypeMapper;
import com.ximai.mes.md.service.IItemTypeService; import com.ximai.mes.md.service.IItemTypeService;
import com.ximai.mes.md.vo.MdItemTypeVo; import com.ximai.mes.md.vo.MdItemTypeVo;
import com.ximai.mes.remote.ErpService;
import com.ximai.mes.remote.dto.MdItemTypeErpDto;
import com.ximai.mes.remote.dto.MdItemTypeErpQuery;
import com.ximai.mes.remote.dto.MdVendorErpDto;
import com.ximai.mes.remote.dto.MdVendorErpQuery;
import com.ximai.system.strategy.AutoCodeUtil; import com.ximai.system.strategy.AutoCodeUtil;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -26,6 +33,8 @@ public class ItemTypeServiceImpl implements IItemTypeService { ...@@ -26,6 +33,8 @@ public class ItemTypeServiceImpl implements IItemTypeService {
@Autowired @Autowired
private AutoCodeUtil autoCodeUtil; private AutoCodeUtil autoCodeUtil;
@Autowired
private ErpService erpService;
@Override @Override
public List<MdItemType> selectItemTypeList(MdItemType mdItemType) { public List<MdItemType> selectItemTypeList(MdItemType mdItemType) {
...@@ -157,85 +166,24 @@ public class ItemTypeServiceImpl implements IItemTypeService { ...@@ -157,85 +166,24 @@ public class ItemTypeServiceImpl implements IItemTypeService {
@Override @Override
public void synchroItemType(List<MdItemTypeVo> mdItemTypeVos) { public void synchroItemType() {
MdItemTypeErpQuery itemTypeErpQuery = new MdItemTypeErpQuery();
for (MdItemTypeVo c : mdItemTypeVos) { itemTypeErpQuery.setCurrent(1);
MdItemType mdItemType = new MdItemType(); itemTypeErpQuery.setPageSize(1000);//每次抓取1000行
BeanUtils.copyProperties(c, mdItemType); List<MdItemTypeErpDto> list = erpService.getInvmaList(itemTypeErpQuery).getData();
String itemTypeCode = mdItemType.getSapTypeCode(); list.forEach(s->{
//一级添加 MdItemType itemType = new MdItemType();
if (itemTypeCode.length() == 3) { itemType.setItemTypeCode(s.getItemTypeCode());
MdItemType mdItem = new MdItemType(); List<MdItemType> dbList = this.selectItemTypeList(itemType);
mdItem.setItemTypeName(mdItemType.getItemTypeName()); if(dbList.size()==0){
List<MdItemType> mdItemTypes = itemTypeMapper.selectItemTypeList(mdItem); MdItemType insertTemp = BeanUtil.toBeanIgnoreError(s, MdItemType.class);
if (CollUtil.isEmpty(mdItemTypes)) { insertTemp.setItemTypeId(Long.valueOf(insertTemp.getItemTypeCode()));
MdItemType parent = itemTypeMapper.selectItemTypeById(200l); insertTemp.setAncestors("0");
mdItemType.setParentTypeId(parent.getItemTypeId()); this.insertItemType(insertTemp);
mdItemType.setAncestors(parent.getAncestors() + "," + parent.getItemTypeId()); }else{
mdItemType.setItemTypeCode(mdItemType.getSapTypeCode()); BeanUtil.copyProperties(s, dbList.get(0));
mdItemType.setEnableFlag("Y"); this.updateItemType(dbList.get(0));
mdItemType.setOrderNum(1);
mdItemType.setCreateTime(DateUtils.getNowDate());
itemTypeMapper.insertItemType(mdItemType);
continue;
} else {
boolean b = true;
for (MdItemType md : mdItemTypes) {
if (md.getItemTypeName().equals(mdItemType.getItemTypeName())) {
md.setSapTypeCode(mdItemType.getSapTypeCode());
md.setNameLongText(mdItemType.getNameLongText());
md.setMaximumSingle(mdItemType.getMaximumSingle());
itemTypeMapper.updateItemType(md);
b = false;
}
}
if (b == true) {
MdItemType parent = itemTypeMapper.selectItemTypeById(200l);
mdItemType.setParentTypeId(parent.getItemTypeId());
mdItemType.setAncestors(parent.getAncestors() + "," + parent.getItemTypeId());
mdItemType.setItemTypeCode(mdItemType.getSapTypeCode());
mdItemType.setEnableFlag("Y");
mdItemType.setOrderNum(1);
mdItemType.setCreateTime(DateUtils.getNowDate());
itemTypeMapper.insertItemType(mdItemType);
continue;
}
}
} }
//二级添加 });
if (itemTypeCode.length() == 5) {
MdItemType mdItem = new MdItemType();
mdItem.setItemTypeCode(mdItemType.getSapTypeCode());
List<MdItemType> mdItemTypes = itemTypeMapper.selectItemTypeList(mdItem);
if (CollUtil.isEmpty(mdItemTypes)) {
MdItemType mdItems = new MdItemType();
String substring = mdItemType.getSapTypeCode().substring(0, 3);
List<MdItemType> mdItemTypes1 = itemTypeMapper.selectItemTypeList(mdItems);
for (MdItemType md : mdItemTypes1) {
if (StringUtils.isNotEmpty(md.getSapTypeCode())) {
if (md.getSapTypeCode().equals(substring)) {
mdItemType.setParentTypeId(md.getItemTypeId());
mdItemType.setAncestors(md.getAncestors() + "," + md.getItemTypeId());
mdItemType.setItemTypeCode(mdItemType.getSapTypeCode());
mdItemType.setEnableFlag("Y");
mdItemType.setOrderNum(2);
mdItemType.setCreateTime(DateUtils.getNowDate());
itemTypeMapper.insertItemType(mdItemType);
continue;
}
}
}
} else {
continue;
}
}
}
} }
} }
...@@ -470,7 +470,7 @@ public class MdItemServiceImpl implements IMdItemService { ...@@ -470,7 +470,7 @@ public class MdItemServiceImpl implements IMdItemService {
@Override @Override
public void syncErpData() { public void syncErpData() {
//优先更新修改数据 iItemTypeService.synchroItemType();
mdItemService.syncEditErpData(); mdItemService.syncEditErpData();
} }
...@@ -547,10 +547,13 @@ public class MdItemServiceImpl implements IMdItemService { ...@@ -547,10 +547,13 @@ public class MdItemServiceImpl implements IMdItemService {
if(dbList.size()==0) { if(dbList.size()==0) {
if ("Y".equalsIgnoreCase(s.getVerifyStatus())) { if ("Y".equalsIgnoreCase(s.getVerifyStatus())) {
MdItem insertTemp = BeanUtil.toBean(s, MdItem.class); MdItem insertTemp = BeanUtil.toBean(s, MdItem.class);
if(itemTypeMap.containsKey(s.getItemTypeId())){ //仅处理物料编号不为空数据
insertTemp.setItemTypeName(itemTypeMap.get(s.getItemTypeId()).getItemTypeName()); if(StringUtils.isEmpty(s.getItemCode())){
if(itemTypeMap.containsKey(s.getItemTypeId())){
insertTemp.setItemTypeName(itemTypeMap.get(s.getItemTypeId()).getItemTypeName());
}
this.insertMdItem(insertTemp);
} }
this.insertMdItem(insertTemp);
} }
}else{ }else{
BeanUtil.copyProperties(s, dbList.get(0)); BeanUtil.copyProperties(s, dbList.get(0));
......
...@@ -36,6 +36,10 @@ public interface ErpService { ...@@ -36,6 +36,10 @@ public interface ErpService {
@ApiOperation(value = "查询ERP物料") @ApiOperation(value = "查询ERP物料")
@PostMapping(value = "/invmb/getInvmbList") @PostMapping(value = "/invmb/getInvmbList")
ErpResponseResult<List<MdItemErpDto>> getItemList(MdItemErpQuery itemErpQuery); ErpResponseResult<List<MdItemErpDto>> getItemList(MdItemErpQuery itemErpQuery);
@ApiLog(businessType = BusinessType.QUERY, inOutType = InOutType.OUT)
@ApiOperation(value = "查询ERP物料分类")
@PostMapping(value = "/invma/getInvmaList")
ErpResponseResult<List<MdItemTypeErpDto>> getInvmaList(MdItemTypeErpQuery itemTypeErpQuery);
@ApiLog(businessType = BusinessType.QUERY, inOutType = InOutType.OUT) @ApiLog(businessType = BusinessType.QUERY, inOutType = InOutType.OUT)
......
...@@ -69,7 +69,7 @@ public class MdItemErpDto ...@@ -69,7 +69,7 @@ public class MdItemErpDto
@JsonProperty("mb017") @JsonProperty("mb017")
@JsonDeserialize(using = TrimStringDeserializer.class) @JsonDeserialize(using = TrimStringDeserializer.class)
@ApiModelProperty("主要仓库") @ApiModelProperty("主要仓库")
private String manWarehouseId; private String mainWarehouseId;
/** /**
* 1:已核准、2:尚待核准、3:不准交易 * 1:已核准、2:尚待核准、3:不准交易
......
package com.ximai.mes.remote.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.ximai.mes.config.EmptyStringToLongDeserializer;
import com.ximai.mes.config.TrimStringDeserializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 物料对象 MdItemErpDto
*
* @date 2024-10-18
*/
@Data
public class MdItemTypeErpDto
{
private static final long serialVersionUID = 1L;
@JsonProperty("ma002")
@JsonDeserialize(using = TrimStringDeserializer.class)
@ApiModelProperty("品号类别编号")
private String itemTypeCode;
@JsonProperty("ma003")
@JsonDeserialize(using = TrimStringDeserializer.class)
@ApiModelProperty("品号类别名称")
private String itemTypeName;
}
package com.ximai.mes.remote.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 供应商对象 MdVendorErpQuery
*
* @date 2024-10-18
*/
@Data
public class MdItemTypeErpQuery extends ErpPageParams
{
@ApiModelProperty("供应商名称")
@JsonProperty("ma001")
private String vendorCode;
@ApiModelProperty("公司全称")
@JsonProperty("ma003")
private String vendorName;
@ApiModelProperty("简称")
@JsonProperty("ma002")
private String vendorNick;
@ApiModelProperty("核准状态")
@JsonProperty("ma016")
private String verifyStatus;
}
...@@ -27,10 +27,6 @@ public class PurchasingRequisitionCreate ...@@ -27,10 +27,6 @@ public class PurchasingRequisitionCreate
@JsonProperty("ta002") @JsonProperty("ta002")
private String requisitionCode; private String requisitionCode;
@ApiModelProperty("数量合计")
@JsonProperty("ta011")
private BigDecimal totalQuantity;
@ApiModelProperty("明细") @ApiModelProperty("明细")
private List<PurchasingRequisitionDetailCreate> details; private List<PurchasingRequisitionDetailCreate> details;
} }
...@@ -44,7 +44,6 @@ public class PurchasingRequisitionCreateProcess implements IExtendedProcess { ...@@ -44,7 +44,6 @@ public class PurchasingRequisitionCreateProcess implements IExtendedProcess {
create.setWorkorderCode(workorderList.get(0).getWorkorderCode()); create.setWorkorderCode(workorderList.get(0).getWorkorderCode());
} }
create.setRequisitionCode(requestCode); create.setRequisitionCode(requestCode);
create.setTotalQuantity(taskWorkunit.getQuantity());
List<PurchasingRequisitionDetailCreate> details = new ArrayList<>(); List<PurchasingRequisitionDetailCreate> details = new ArrayList<>();
PurchasingRequisitionDetailCreate detailCreate = new PurchasingRequisitionDetailCreate(); PurchasingRequisitionDetailCreate detailCreate = new PurchasingRequisitionDetailCreate();
detailCreate.setQuantity(taskWorkunit.getQuantity()+""); detailCreate.setQuantity(taskWorkunit.getQuantity()+"");
......
package com.ximai.mes.scheduled;
import com.ximai.mes.md.service.IMdClientService;
import com.ximai.mes.md.service.IMdItemService;
import com.ximai.mes.md.service.IMdVendorService;
import com.ximai.mes.pro.service.proWorkOrder.IProWorkorderService;
import com.ximai.mes.wm.service.IWmWarehouseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* ERP数据同步
*/
@Component
public class ErpDataSyncScheduled {
private static Logger logger = LoggerFactory.getLogger(ErpDataSyncScheduled.class);
@Autowired
private IMdClientService clientService;
@Autowired
private IMdVendorService vendorService;
@Autowired
private IProWorkorderService workorderService;
@Autowired
private IMdItemService itemService;
@Autowired
private IWmWarehouseService warehouseService;
public void process() {
try {
warehouseService.syncErpData();
}catch (Exception e){
logger.error("sync warehouse data error:", e);
}
try {
clientService.syncErpData();
}catch (Exception e){
logger.error("sync client data error:", e);
}
try {
vendorService.syncErpData();
}catch (Exception e){
logger.error("sync vendor data error:", e);
}
try {
itemService.syncErpData();
}catch (Exception e){
logger.error("sync item data error:", e);
}
try {
workorderService.syncErpData();
}catch (Exception e){
logger.error("sync workorder data error:", e);
}
}
}
package com.ximai.mes.scheduled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class VendorSyncScheduled {
private static Logger logger = LoggerFactory.getLogger(VendorSyncScheduled.class);
@Scheduled(cron = "0 */17 * * * ?")
public void process() {
}
}
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
<result property="customerDrawingNo" column="customer_drawing_no"/> <result property="customerDrawingNo" column="customer_drawing_no"/>
<result property="customerProNo" column="customer_pro_no"/> <result property="customerProNo" column="customer_pro_no"/>
<result property="mainWarehouseId" column="main_warehouse_id"/> <result property="mainWarehouseId" column="main_warehouse_id"/>
<result property="mainWarehouseCode" column="main_warehouse_code"/>
<result property="erpCreateTime" column="erp_create_time"/> <result property="erpCreateTime" column="erp_create_time"/>
<result property="erpUpdateTime" column="erp_update_time"/> <result property="erpUpdateTime" column="erp_update_time"/>
</resultMap> </resultMap>
...@@ -270,7 +269,6 @@ ...@@ -270,7 +269,6 @@
<if test="customerDrawingNo != null">customer_drawing_no,</if> <if test="customerDrawingNo != null">customer_drawing_no,</if>
<if test="customerProNo != null">customer_pro_no,</if> <if test="customerProNo != null">customer_pro_no,</if>
<if test="mainWarehouseId !=null">main_warehouse_id,</if> <if test="mainWarehouseId !=null">main_warehouse_id,</if>
<if test="mainWarehouseCode !=null">main_warehouse_code,</if>
<if test="erpCreateTime !=null">erp_create_time,</if> <if test="erpCreateTime !=null">erp_create_time,</if>
<if test="erpUpdateTime !=null">erp_update_time,</if> <if test="erpUpdateTime !=null">erp_update_time,</if>
</trim> </trim>
...@@ -307,7 +305,6 @@ ...@@ -307,7 +305,6 @@
<if test="customerDrawingNo != null">#{customerDrawingNo},</if> <if test="customerDrawingNo != null">#{customerDrawingNo},</if>
<if test="customerProNo != null">#{customerProNo},</if> <if test="customerProNo != null">#{customerProNo},</if>
<if test="mainWarehouseId !=null">#{mainWarehouseId},</if> <if test="mainWarehouseId !=null">#{mainWarehouseId},</if>
<if test="mainWarehouseCode !=null">#{mainWarehouseCode},</if>
<if test="erpCreateTime != null">#{erpCreateTime},</if> <if test="erpCreateTime != null">#{erpCreateTime},</if>
<if test="erpUpdateTime != null">#{erpUpdateTime},</if> <if test="erpUpdateTime != null">#{erpUpdateTime},</if>
</trim> </trim>
...@@ -343,7 +340,6 @@ ...@@ -343,7 +340,6 @@
<if test="customerDrawingNo !=null">customer_drawing_no=#{customerDrawingNo},</if> <if test="customerDrawingNo !=null">customer_drawing_no=#{customerDrawingNo},</if>
<if test="customerProNo !=null">customer_pro_no=#{customerProNo},</if> <if test="customerProNo !=null">customer_pro_no=#{customerProNo},</if>
<if test="mainWarehouseId !=null">main_warehouse_id = #{mainWarehouseId},</if> <if test="mainWarehouseId !=null">main_warehouse_id = #{mainWarehouseId},</if>
<if test="mainWarehouseCode !=null">main_warehouse_code = #{mainWarehouseCode},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="erpUpdateTime != null">erp_update_time = #{erpUpdateTime},</if> <if test="erpUpdateTime != null">erp_update_time = #{erpUpdateTime},</if>
</set> </set>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment