【生产订单】
This commit is contained in:
parent
542ceb23c1
commit
6e9466004b
|
|
@ -123,6 +123,12 @@ public class ProductionOrderEntity implements Serializable {
|
|||
@ApiModelProperty(value = "确认情况 0设计待确认 1供应链待确认 2计划待确认 3计划已确认")
|
||||
private Integer confirmStatus;
|
||||
|
||||
/**
|
||||
* 同步状态 0未同步 1已同步
|
||||
*/
|
||||
@TableField(value = "sync_status")
|
||||
private Integer syncStatus;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ public class ProductionOrderItemEntity implements Serializable {
|
|||
@ApiModelProperty(value = "物料编码")
|
||||
private String materialNo;
|
||||
|
||||
/**
|
||||
* 物料描述
|
||||
*/
|
||||
@TableField(value = "material_desc")
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String materialDesc;
|
||||
// /**
|
||||
// * 物料描述
|
||||
// */
|
||||
// @TableField(value = "material_desc")
|
||||
// @ApiModelProperty(value = "物料描述")
|
||||
// private String materialDesc;
|
||||
|
||||
/**
|
||||
* 父物料 0否 1是
|
||||
|
|
@ -158,12 +158,12 @@ public class ProductionOrderItemEntity implements Serializable {
|
|||
@ApiModelProperty(value = "提交 0否 1是")
|
||||
private Integer submit;
|
||||
|
||||
/**
|
||||
* 操作类型:0不变 1新增 2修改 3删除
|
||||
*/
|
||||
@TableField(value = "operate_type")
|
||||
@ApiModelProperty(value = "操作类型:0不变 1新增 2修改 3删除")
|
||||
private Integer operateType;
|
||||
// /**
|
||||
// * 操作类型:0不变 1新增 2修改 3删除
|
||||
// */
|
||||
// @TableField(value = "operate_type")
|
||||
// @ApiModelProperty(value = "操作类型:0不变 1新增 2修改 3删除")
|
||||
// private Integer operateType;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
|
|
|
|||
|
|
@ -98,10 +98,10 @@ public class ProductionOrderSapEntity implements Serializable {
|
|||
private String ERNAM;
|
||||
|
||||
/**
|
||||
* 处理状态 0未处理 1已处理
|
||||
* 同步状态 0未同步 1已同步
|
||||
*/
|
||||
@TableField(value = "handle_status")
|
||||
private Integer handleStatus;
|
||||
@TableField(value = "sync_status")
|
||||
private Integer syncStatus;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,4 +47,10 @@ public class ProductionOrderQuery extends BasePageQuery implements Serializable
|
|||
@ApiModelProperty(value = "确认情况 0设计待确认 1供应链待确认 2计划待确认 3计划已确认")
|
||||
private Integer confirmStatus;
|
||||
|
||||
/**
|
||||
* 同步状态
|
||||
*/
|
||||
@ApiModelProperty(value = "同步状态")
|
||||
private Integer syncStatus;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import java.time.LocalDateTime;
|
|||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="com-nflg-product-bomnew-pojo-new-vo-ProductionOrderItemVO")
|
||||
public class ProductionOrderItemVO implements Serializable {
|
||||
public class ProductionOrderItemVO extends BaseMaterialVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 行ID 雪花
|
||||
|
|
@ -32,17 +32,17 @@ public class ProductionOrderItemVO implements Serializable {
|
|||
@ApiModelProperty(value = "项目号")
|
||||
private String itemNo;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@ApiModelProperty(value = "物料编码")
|
||||
private String materialNo;
|
||||
|
||||
/**
|
||||
* 物料描述
|
||||
*/
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String materialDesc;
|
||||
// /**
|
||||
// * 物料编码
|
||||
// */
|
||||
// @ApiModelProperty(value = "物料编码")
|
||||
// private String materialNo;
|
||||
//
|
||||
// /**
|
||||
// * 物料描述
|
||||
// */
|
||||
// @ApiModelProperty(value = "物料描述")
|
||||
// private String materialDesc;
|
||||
|
||||
/**
|
||||
* 父物料 0否 1是
|
||||
|
|
@ -74,11 +74,11 @@ public class ProductionOrderItemVO implements Serializable {
|
|||
@ApiModelProperty(value = "单位")
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 项目类别
|
||||
*/
|
||||
@ApiModelProperty(value = "项目类别")
|
||||
private String projectType;
|
||||
// /**
|
||||
// * 项目类别
|
||||
// */
|
||||
// @ApiModelProperty(value = "项目类别")
|
||||
// private String projectType;
|
||||
|
||||
/**
|
||||
* 工序
|
||||
|
|
@ -128,11 +128,11 @@ public class ProductionOrderItemVO implements Serializable {
|
|||
@ApiModelProperty(value = "提交 0否 1是")
|
||||
private Integer submit;
|
||||
|
||||
/**
|
||||
* 操作类型:0不变 1新增 2修改 3删除
|
||||
*/
|
||||
@ApiModelProperty(value = "操作类型:0不变 1新增 2修改 3删除")
|
||||
private Integer operateType;
|
||||
// /**
|
||||
// * 操作类型:0不变 1新增 2修改 3删除
|
||||
// */
|
||||
// @ApiModelProperty(value = "操作类型:0不变 1新增 2修改 3删除")
|
||||
// private Integer operateType;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.convert.Converter;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
|
@ -19,6 +21,7 @@ import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams;
|
|||
import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
|
||||
import com.nflg.product.bomnew.pojo.entity.ProductionOrderEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.ProductionOrderItemEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.ProductionOrderItemSapEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.ProductionOrderSapEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.ProductionOrderQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.ProductionOrderSaveQuery;
|
||||
|
|
@ -35,6 +38,7 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -56,6 +60,7 @@ public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, P
|
|||
private ProductionOrderItemSapMapper productionOrderItemSapMapper;
|
||||
|
||||
public IPage<ProductionOrderVO> getListByPage(ProductionOrderQuery query){
|
||||
query.setSyncStatus(0);
|
||||
Page<ProductionOrderQuery> page = new Page<>(query.getPage(),query.getPageSize());
|
||||
Page<ProductionOrderVO> listByPage = this.getBaseMapper().getListByPage(page, query);
|
||||
if (CollUtil.isNotEmpty(listByPage.getRecords())) {
|
||||
|
|
@ -67,7 +72,11 @@ public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, P
|
|||
public List<ProductionOrderItemVO> getItemList(Long rowId) {
|
||||
VUtils.isTure(ObjectUtil.isEmpty(rowId)).throwMessage("生产订单 rowId 不能为空");
|
||||
List<ProductionOrderItemEntity> itemList = productionOrderItemService.lambdaQuery().eq(ProductionOrderItemEntity::getOrderRowId, rowId).list();
|
||||
return Convert.toList(ProductionOrderItemVO.class, itemList);
|
||||
List<ProductionOrderItemVO> itemVOList = Convert.toList(ProductionOrderItemVO.class, itemList);
|
||||
if (CollUtil.isNotEmpty(itemVOList)) {
|
||||
materialMainService.intiMaterialInfo(itemVOList, "projectType");
|
||||
}
|
||||
return itemVOList;
|
||||
}
|
||||
|
||||
public String queryPostByUser() {
|
||||
|
|
@ -162,9 +171,14 @@ public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, P
|
|||
ProductionOrderEntity updateEntity = new ProductionOrderEntity();
|
||||
updateEntity.setRowId(rowId);
|
||||
updateEntity.setEditStatus(2);
|
||||
updateEntity.setSyncStatus(1); // 已同步
|
||||
updateEntity.setUpdatedBy(SessionUtil.getUserCode());
|
||||
updateEntity.setUpdatedTime(LocalDateTime.now());
|
||||
this.updateById(updateEntity);
|
||||
ProductionOrderSapEntity updateSapEntity = new ProductionOrderSapEntity();
|
||||
updateSapEntity.setRowId(rowId);
|
||||
updateSapEntity.setSyncStatus(1); // 已同步
|
||||
this.productionOrderSapMapper.updateById(updateSapEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -229,23 +243,28 @@ public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, P
|
|||
*/
|
||||
List<Map<String, Object>> headList = outTablesMap.get("HEAD");
|
||||
if (CollUtil.isNotEmpty(headList)) {
|
||||
List<ProductionOrderEntity> saveList = new ArrayList<>();
|
||||
for (Map<String, Object> head : headList) {
|
||||
if (ObjectUtil.isEmpty(head.get("AUFNR"))) {
|
||||
continue;
|
||||
}
|
||||
String productionOrder = head.get("AUFNR").toString().replaceAll("^0+", "");
|
||||
// 生产订单号存在且未处理则跳过
|
||||
String aufnr = head.get("AUFNR").toString();
|
||||
// 生产订单号存在且未同步则跳过
|
||||
QueryWrapper<ProductionOrderSapEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("AUFNR", productionOrder)
|
||||
.eq("handle_status", 0);
|
||||
List<ProductionOrderSapEntity> exist = this.productionOrderSapMapper.selectList(queryWrapper);
|
||||
List<ProductionOrderEntity> exists = this.lambdaQuery().eq(ProductionOrderEntity::getProductionOrder, productionOrder).list();
|
||||
queryWrapper.eq("AUFNR", aufnr)
|
||||
.eq("sync_status", 0);
|
||||
List<ProductionOrderSapEntity> exists = this.productionOrderSapMapper.selectList(queryWrapper);
|
||||
if (CollUtil.isNotEmpty(exists)) {
|
||||
continue;
|
||||
}
|
||||
// 存入SAP原始表
|
||||
ProductionOrderSapEntity productionOrderSapEntity = BeanUtil.toBean(head, ProductionOrderSapEntity.class);
|
||||
Long rowId = IdWorker.getId();
|
||||
productionOrderSapEntity.setRowId(rowId);
|
||||
this.productionOrderSapMapper.insert(productionOrderSapEntity);
|
||||
// 存入生产订单抬头表
|
||||
String productionOrder = aufnr.replaceAll("^0+", "");
|
||||
ProductionOrderEntity save = new ProductionOrderEntity();
|
||||
save.setRowId(IdWorker.getId());
|
||||
save.setRowId(rowId);
|
||||
save.setFactory(ObjectUtil.isNotEmpty(head.get("WERKS")) ? head.get("WERKS").toString() : "");
|
||||
save.setProductionOrder(productionOrder);
|
||||
save.setMaterialNo(ObjectUtil.isNotEmpty(head.get("STLBEZ")) ? head.get("STLBEZ").toString().replaceAll("^0+", "") : "");
|
||||
|
|
@ -259,35 +278,75 @@ public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, P
|
|||
save.setCreatedTime(ObjectUtil.isNotEmpty(head.get("ERDAT")) ? LocalDateTime.parse(head.get("ERDAT").toString(), dateTimeFormatter) : null);
|
||||
save.setUpdatedBy(ObjectUtil.isNotEmpty(head.get("AENAM")) ? head.get("AENAM").toString() : "");
|
||||
save.setUpdatedTime(ObjectUtil.isNotEmpty(head.get("AEDAT")) ? LocalDateTime.parse(head.get("AEDAT").toString(), dateTimeFormatter) : null);
|
||||
saveList.add(save);
|
||||
this.save(save);
|
||||
|
||||
// 过滤出该生产订单的明细
|
||||
// 生产订单明细
|
||||
if (outTablesMap.containsKey("ITEM")) {
|
||||
/**
|
||||
* CHARG=, 批号
|
||||
* BAUGR=000000002120230002, 高层次组装的物料号
|
||||
* WERKS=1010, 工厂
|
||||
* LGORT=0022, 库存地点
|
||||
* BDMNG=1.000, 需求量
|
||||
* MEINS=ST, 基本计量单位
|
||||
* ENMNG=0.000, 提货数
|
||||
* AUFNR=000010435564, 订单号
|
||||
* RSNUM=0001308129, 预留/相关需求的编号
|
||||
* NOMAT=, 后继/原始物料
|
||||
* POSNR=0010, BOM 项目号
|
||||
* NOMNG=0.000, 需求数量
|
||||
* RSPOS=0001, 预留/相关需求的项目编号
|
||||
* DUMPS=, 虚拟项目标识
|
||||
* PRVBE=, 供应区域
|
||||
* POSTP=L, 项目类别(物料单)
|
||||
* BDTER=Tue Jan 02 00:00:00 CST 2024, 组件的需求日期
|
||||
* SORTF=, 排序字符串
|
||||
* MATNR=000000002100330331 物料号
|
||||
*/
|
||||
List<Map<String, Object>> itemList = outTablesMap.get("ITEM");
|
||||
if (CollUtil.isNotEmpty(itemList)) {
|
||||
List<Map<String, Object>> filterItemList = itemList.stream().filter(item -> aufnr.equals(item.get("AUFNR"))).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(filterItemList)) {
|
||||
List<ProductionOrderItemEntity> saveItemList = new ArrayList<>(filterItemList.size());
|
||||
for (Map<String, Object> filterItem : filterItemList) {
|
||||
// 存入SAP原始表
|
||||
ProductionOrderItemSapEntity productionOrderItemSapEntity = BeanUtil.toBean(filterItem, ProductionOrderItemSapEntity.class);
|
||||
Long itemRowId = IdWorker.getId();
|
||||
productionOrderItemSapEntity.setRowId(itemRowId);
|
||||
productionOrderItemSapEntity.setOrderRowId(rowId);
|
||||
this.productionOrderItemSapMapper.insert(productionOrderItemSapEntity);
|
||||
|
||||
// 存入生产订单明细表
|
||||
ProductionOrderItemEntity productionOrderItemEntity = new ProductionOrderItemEntity();
|
||||
productionOrderItemEntity.setRowId(itemRowId);
|
||||
productionOrderItemEntity.setOrderRowId(rowId);
|
||||
productionOrderItemEntity.setItemNo(ObjectUtil.isNotEmpty(filterItem.get("POSNR")) ? filterItem.get("POSNR").toString() : "");
|
||||
productionOrderItemEntity.setMaterialNo(ObjectUtil.isNotEmpty(filterItem.get("MATNR")) ? filterItem.get("MATNR").toString().replaceAll("^0+", "") : "");
|
||||
productionOrderItemEntity.setCommandNum(ObjectUtil.isNotEmpty(filterItem.get("BDMNG")) ? new BigDecimal(filterItem.get("BDMNG").toString()) : null);
|
||||
// productionOrderItemEntity.setPromiseNum(ObjectUtil.isNotEmpty(filterItem.get("WERKS")) ? filterItem.get("WERKS").toString() : "");
|
||||
productionOrderItemEntity.setPickNum(ObjectUtil.isNotEmpty(filterItem.get("ENMNG")) ? new BigDecimal(filterItem.get("ENMNG").toString()) : null);
|
||||
productionOrderItemEntity.setUnit(ObjectUtil.isNotEmpty(filterItem.get("MEINS")) ? filterItem.get("MEINS").toString() : "");
|
||||
productionOrderItemEntity.setProjectType(ObjectUtil.isNotEmpty(filterItem.get("POSTP")) ? filterItem.get("POSTP").toString() : "");
|
||||
// productionOrderItemEntity.setProgress(ObjectUtil.isNotEmpty(filterItem.get("")) ? filterItem.get("").toString() : "");
|
||||
productionOrderItemEntity.setBatchNo(ObjectUtil.isNotEmpty(filterItem.get("CHARG")) ? filterItem.get("CHARG").toString() : "");
|
||||
productionOrderItemEntity.setFactory(ObjectUtil.isNotEmpty(filterItem.get("WERKS")) ? filterItem.get("WERKS").toString() : "");
|
||||
productionOrderItemEntity.setStorage(ObjectUtil.isNotEmpty(filterItem.get("LGORT")) ? filterItem.get("LGORT").toString() : "");
|
||||
|
||||
productionOrderItemEntity.setCreatedBy(SessionUtil.getUserCode());
|
||||
productionOrderItemEntity.setCreatedTime(LocalDateTime.now());
|
||||
productionOrderItemEntity.setUpdatedBy(SessionUtil.getUserCode());
|
||||
productionOrderItemEntity.setUpdatedTime(LocalDateTime.now());
|
||||
saveItemList.add(productionOrderItemEntity);
|
||||
}
|
||||
this.productionOrderItemService.saveBatch(saveItemList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.saveBatch(saveList);
|
||||
}
|
||||
}
|
||||
// 生产订单明细
|
||||
if (outTablesMap.containsKey("ITEM")) {
|
||||
/**
|
||||
* CHARG=, 批号
|
||||
* BAUGR=000000002120230002, 高层次组装的物料号
|
||||
* WERKS=1010, 工厂
|
||||
* LGORT=0022, 库存地点
|
||||
* BDMNG=1.000, 需求量
|
||||
* MEINS=ST, 基本计量单位
|
||||
* ENMNG=0.000, 提货数
|
||||
* AUFNR=000010435564, 订单号
|
||||
* RSNUM=0001308129, 预留/相关需求的编号
|
||||
* NOMAT=, 后继/原始物料
|
||||
* POSNR=0010, BOM 项目号
|
||||
* NOMNG=0.000, 需求数量
|
||||
* RSPOS=0001, 预留/相关需求的项目编号
|
||||
* DUMPS=, 虚拟项目标识
|
||||
* PRVBE=, 供应区域
|
||||
* POSTP=L, 项目类别(物料单)
|
||||
* BDTER=Tue Jan 02 00:00:00 CST 2024, 组件的需求日期
|
||||
* SORTF=, 排序字符串
|
||||
* MATNR=000000002100330331 物料号
|
||||
*/
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("从SAP获取生产订单报错: {}", e.getMessage());
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@
|
|||
</resultMap>
|
||||
|
||||
<sql id="whr">
|
||||
<if test="query.syncStatus!=null and query.syncStatus!=''">
|
||||
and sync_status = #{query.syncStatus}
|
||||
</if>
|
||||
<if test="query.productionOrder!=null and query.productionOrder!=''">
|
||||
and production_order like concat('%',#{query.productionOrder},'%')
|
||||
</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue