Commit 661f0a09 authored by 温志超's avatar 温志超

Merge remote-tracking branch 'origin/master'

parents aab82a3d c4798beb
......@@ -81,9 +81,6 @@ public class MdItem extends BaseEntity {
@ApiModelProperty("客户品号")
private String customerProNo;
@ApiModelProperty("主要仓库")
private String mainWarehouseCode;
@ApiModelProperty("主要仓库")
private String mainWarehouseId;
......
......@@ -30,5 +30,6 @@ public interface IItemTypeService {
boolean checkHasItem(Long itemTypeId);
void synchroItemType(List<MdItemTypeVo> mdItemTypeVos);
void synchroItemType();
}
......@@ -16,7 +16,7 @@ import java.util.List;
public interface IMdWorkunitService {
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;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.ximai.common.constant.UserConstants;
import com.ximai.common.core.domain.TreeSelect;
import com.ximai.common.core.domain.entity.MdItemType;
import com.ximai.common.utils.data.DateUtils;
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.service.IItemTypeService;
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 org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,6 +33,8 @@ public class ItemTypeServiceImpl implements IItemTypeService {
@Autowired
private AutoCodeUtil autoCodeUtil;
@Autowired
private ErpService erpService;
@Override
public List<MdItemType> selectItemTypeList(MdItemType mdItemType) {
......@@ -157,85 +166,24 @@ public class ItemTypeServiceImpl implements IItemTypeService {
@Override
public void synchroItemType(List<MdItemTypeVo> mdItemTypeVos) {
for (MdItemTypeVo c : mdItemTypeVos) {
MdItemType mdItemType = new MdItemType();
BeanUtils.copyProperties(c, mdItemType);
String itemTypeCode = mdItemType.getSapTypeCode();
//一级添加
if (itemTypeCode.length() == 3) {
MdItemType mdItem = new MdItemType();
mdItem.setItemTypeName(mdItemType.getItemTypeName());
List<MdItemType> mdItemTypes = itemTypeMapper.selectItemTypeList(mdItem);
if (CollUtil.isEmpty(mdItemTypes)) {
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;
} 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;
}
}
}
public void synchroItemType() {
MdItemTypeErpQuery itemTypeErpQuery = new MdItemTypeErpQuery();
itemTypeErpQuery.setCurrent(1);
itemTypeErpQuery.setPageSize(1000);//每次抓取1000行
List<MdItemTypeErpDto> list = erpService.getInvmaList(itemTypeErpQuery).getData();
list.forEach(s->{
MdItemType itemType = new MdItemType();
itemType.setItemTypeCode(s.getItemTypeCode());
List<MdItemType> dbList = this.selectItemTypeList(itemType);
if(dbList.size()==0){
MdItemType insertTemp = BeanUtil.toBeanIgnoreError(s, MdItemType.class);
insertTemp.setItemTypeId(Long.valueOf(insertTemp.getItemTypeCode()));
insertTemp.setAncestors("0");
this.insertItemType(insertTemp);
}else{
BeanUtil.copyProperties(s, dbList.get(0));
this.updateItemType(dbList.get(0));
}
});
}
}
......@@ -470,7 +470,7 @@ public class MdItemServiceImpl implements IMdItemService {
@Override
public void syncErpData() {
//优先更新修改数据
iItemTypeService.synchroItemType();
mdItemService.syncEditErpData();
}
......@@ -547,11 +547,14 @@ public class MdItemServiceImpl implements IMdItemService {
if(dbList.size()==0) {
if ("Y".equalsIgnoreCase(s.getVerifyStatus())) {
MdItem insertTemp = BeanUtil.toBean(s, MdItem.class);
//仅处理物料编号不为空数据
if(StringUtils.isEmpty(s.getItemCode())){
if(itemTypeMap.containsKey(s.getItemTypeId())){
insertTemp.setItemTypeName(itemTypeMap.get(s.getItemTypeId()).getItemTypeName());
}
this.insertMdItem(insertTemp);
}
}
}else{
BeanUtil.copyProperties(s, dbList.get(0));
if(!"Y".equalsIgnoreCase(s.getVerifyStatus())){
......
......@@ -1316,6 +1316,7 @@ public class ProTaskServiceImpl implements IProTaskService {
query.eq(proTask.getOutsourced() != null, "ptw.outsourced", proTask.getOutsourced());
query.eq(StringUtils.isNotEmpty(proTask.getArrangeCode()), "t.arrange_code", proTask.getArrangeCode());
query.gt(proTask.getAllowProduce() != null && proTask.getAllowProduce() == 1, "t.quantity_wait", 0);
query.gt("ptw.quantity", 0);
query.orderByAsc("statusIndex").orderByAsc("ptw.schedule_start_date");
//搜索条件为工单号查询相应任务ID作为查询条件
if (StringUtils.isNotEmpty(proTask.getWorkorderCode())) {
......
......@@ -36,6 +36,10 @@ public interface ErpService {
@ApiOperation(value = "查询ERP物料")
@PostMapping(value = "/invmb/getInvmbList")
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)
......
......@@ -69,7 +69,7 @@ public class MdItemErpDto
@JsonProperty("mb017")
@JsonDeserialize(using = TrimStringDeserializer.class)
@ApiModelProperty("主要仓库")
private String manWarehouseId;
private String mainWarehouseId;
/**
* 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
@JsonProperty("ta002")
private String requisitionCode;
@ApiModelProperty("数量合计")
@JsonProperty("ta011")
private BigDecimal totalQuantity;
@ApiModelProperty("明细")
private List<PurchasingRequisitionDetailCreate> details;
}
......@@ -44,7 +44,6 @@ public class PurchasingRequisitionCreateProcess implements IExtendedProcess {
create.setWorkorderCode(workorderList.get(0).getWorkorderCode());
}
create.setRequisitionCode(requestCode);
create.setTotalQuantity(taskWorkunit.getQuantity());
List<PurchasingRequisitionDetailCreate> details = new ArrayList<>();
PurchasingRequisitionDetailCreate detailCreate = new PurchasingRequisitionDetailCreate();
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 @@
<result property="customerDrawingNo" column="customer_drawing_no"/>
<result property="customerProNo" column="customer_pro_no"/>
<result property="mainWarehouseId" column="main_warehouse_id"/>
<result property="mainWarehouseCode" column="main_warehouse_code"/>
<result property="erpCreateTime" column="erp_create_time"/>
<result property="erpUpdateTime" column="erp_update_time"/>
</resultMap>
......@@ -270,7 +269,6 @@
<if test="customerDrawingNo != null">customer_drawing_no,</if>
<if test="customerProNo != null">customer_pro_no,</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="erpUpdateTime !=null">erp_update_time,</if>
</trim>
......@@ -307,7 +305,6 @@
<if test="customerDrawingNo != null">#{customerDrawingNo},</if>
<if test="customerProNo != null">#{customerProNo},</if>
<if test="mainWarehouseId !=null">#{mainWarehouseId},</if>
<if test="mainWarehouseCode !=null">#{mainWarehouseCode},</if>
<if test="erpCreateTime != null">#{erpCreateTime},</if>
<if test="erpUpdateTime != null">#{erpUpdateTime},</if>
</trim>
......@@ -343,7 +340,6 @@
<if test="customerDrawingNo !=null">customer_drawing_no=#{customerDrawingNo},</if>
<if test="customerProNo !=null">customer_pro_no=#{customerProNo},</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="erpUpdateTime != null">erp_update_time = #{erpUpdateTime},</if>
</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