Merge remote-tracking branch 'origin/master-order-20240830' into test
This commit is contained in:
commit
a616106b70
|
|
@ -284,6 +284,19 @@ public class MaterialExcelService {
|
|||
excelEnt.setProcessState(MaterialProcessStateEnum.WAIT_SUBMIT.getValue());
|
||||
if (ObjectUtil.isNotEmpty(excelEnt.getMaterialName())) {
|
||||
excelEnt.setMaterialDescEn(query21MaterialDescEn(excelEnt.getMaterialName().split(" ")[0]));
|
||||
if ("201101".equals(excelEnt.getMaterialCategoryCode())) {
|
||||
if (excelEnt.getMaterialName().endsWith("(发货)")) {
|
||||
excelEnt.setMaterialDescEn("Deliver Goods Package");
|
||||
} else if (excelEnt.getMaterialName().endsWith("(制作)")) {
|
||||
excelEnt.setMaterialDescEn("Make Package");
|
||||
} else if (excelEnt.getMaterialName().endsWith("(直发)")) {
|
||||
excelEnt.setMaterialDescEn("Inventory Deliver Goods Package");
|
||||
} else if (excelEnt.getMaterialName().endsWith("(油漆)")) {
|
||||
excelEnt.setMaterialDescEn("Paint Package");
|
||||
} else if (excelEnt.getMaterialName().endsWith("(发货前装配)")) {
|
||||
excelEnt.setMaterialDescEn("Assembly before Shipment");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -304,6 +317,14 @@ public class MaterialExcelService {
|
|||
List<String> descDbExites = dbExitstDesc.stream().map(MaterialMainEntity::getMaterialDesc).collect(Collectors.toList());
|
||||
throw new NflgBusinessException(STATE.ParamErr, StrUtil.join(",", descDbExites).concat("图号+名称在数据库中已存在"));
|
||||
}
|
||||
// 检查英文描述不能为空
|
||||
List<MaterialSelfExcelDTO> emptyMaterialDescEnList = datas.stream()
|
||||
.filter(item -> !"201301".equals(item.getMaterialCategoryCode()) && ObjectUtil.isEmpty(item.getMaterialDescEn()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(emptyMaterialDescEnList)) {
|
||||
List<String> emptyDescEnList = emptyMaterialDescEnList.stream().map(MaterialSelfExcelDTO::getMaterialName).collect(Collectors.toList());
|
||||
throw new NflgBusinessException(STATE.ParamErr, StrUtil.join(",", emptyDescEnList).concat("未匹配到英文描述"));
|
||||
}
|
||||
List<MaterialMainEntity> result = Convert.convert(new TypeReference<List<MaterialMainEntity>>() {
|
||||
}, datas);
|
||||
|
||||
|
|
|
|||
|
|
@ -1202,14 +1202,14 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
|||
*/
|
||||
public void initPic(MaterialMainVO data) {
|
||||
MaterialFilesEntity file = materialFilesService.lambdaQuery().eq(MaterialFilesEntity::getFileType, 0)
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, data.getMaterialNo()).one();
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, data.getMaterialNo()).orderByDesc(MaterialFilesEntity::getCreatedTime).last(" limit 1").one();
|
||||
if (Objects.isNull(file)) {
|
||||
file = materialFilesService.lambdaQuery().eq(MaterialFilesEntity::getFileType, 0)
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, data.getMaterialCategoryCode()).one();
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, data.getMaterialCategoryCode()).orderByDesc(MaterialFilesEntity::getCreatedTime).last(" limit 1").one();
|
||||
}
|
||||
if (Objects.isNull(file)) {
|
||||
file = materialFilesService.lambdaQuery().eq(MaterialFilesEntity::getFileType, 0)
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, String.valueOf(data.getRowId())).one();
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, String.valueOf(data.getRowId())).orderByDesc(MaterialFilesEntity::getCreatedTime).last(" limit 1").one();
|
||||
}
|
||||
if (!Objects.isNull(file)) {
|
||||
data.setPicUrl(file.getFileUrl());
|
||||
|
|
@ -1223,14 +1223,14 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
|||
*/
|
||||
public void initPic2(MaterialMainVO data) {
|
||||
MaterialFilesEntity file = materialFilesService.lambdaQuery().eq(MaterialFilesEntity::getFileType, 0)
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, String.valueOf(data.getRowId())).one();
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, String.valueOf(data.getRowId())).orderByDesc(MaterialFilesEntity::getCreatedTime).last(" limit 1").one();
|
||||
if (Objects.isNull(file)) {
|
||||
file = materialFilesService.lambdaQuery().eq(MaterialFilesEntity::getFileType, 0)
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, data.getMaterialNo()).one();
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, data.getMaterialNo()).orderByDesc(MaterialFilesEntity::getCreatedTime).last(" limit 1").one();
|
||||
}
|
||||
if (Objects.isNull(file)) {
|
||||
file = materialFilesService.lambdaQuery().eq(MaterialFilesEntity::getFileType, 0)
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, data.getMaterialCategoryCode()).one();
|
||||
.eq(MaterialFilesEntity::getMaterialOrCategoryNo, data.getMaterialCategoryCode()).orderByDesc(MaterialFilesEntity::getCreatedTime).last(" limit 1").one();
|
||||
}
|
||||
if (!Objects.isNull(file)) {
|
||||
data.setPicUrl(file.getFileUrl());
|
||||
|
|
|
|||
|
|
@ -101,4 +101,16 @@ public class ProductionOrderApi extends BaseApi {
|
|||
return ResultVO.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从SAP获取生产订单
|
||||
*
|
||||
* @param query Query 查询实体
|
||||
* @return 所有数据
|
||||
*/
|
||||
@PostMapping("syncProductionOrderFromSap")
|
||||
@ApiOperation("从SAP获取生产订单")
|
||||
public ResultVO<String> syncProductionOrderFromSap(@RequestBody ProductionOrderQuery query) {
|
||||
return productionOrderService.syncProductionOrderFromSap(query);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.nflg.product.bomnew.mapper.master;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.ProductionOrderItemSapEntity;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
*/
|
||||
public interface ProductionOrderItemSapMapper extends BaseMapper<ProductionOrderItemSapEntity> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.nflg.product.bomnew.mapper.master;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.ProductionOrderSapEntity;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
*/
|
||||
public interface ProductionOrderSapMapper extends BaseMapper<ProductionOrderSapEntity> {
|
||||
|
||||
}
|
||||
|
|
@ -52,7 +52,14 @@ public class MaterialMainEntity implements Serializable {
|
|||
@TableField(value = "material_desc")
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String materialDesc;
|
||||
|
||||
|
||||
/**
|
||||
* 英文描述
|
||||
*/
|
||||
@TableField(value = "material_desc_en")
|
||||
@ApiModelProperty(value = "英文描述")
|
||||
private String materialDescEn;
|
||||
|
||||
/**
|
||||
* 物料描述(简写)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ public class ProductionOrderEntity 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;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
|
|
|
|||
|
|
@ -158,6 +158,13 @@ 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,0 +1,121 @@
|
|||
package com.nflg.product.bomnew.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* t_production_order_item_sap
|
||||
* 生产订单明细表(SAP原始数据)
|
||||
*
|
||||
* @author makejava
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "com-nflg-product-bomnew-pojo-main-entity-ProductionOrderItemSapEntity")
|
||||
@TableName(value = "t_production_order_item_sap")
|
||||
public class ProductionOrderItemSapEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 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 物料号
|
||||
*/
|
||||
|
||||
/**
|
||||
* 行ID 雪花
|
||||
*/
|
||||
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "行ID 雪花")
|
||||
private Long rowId;
|
||||
|
||||
/**
|
||||
* 生产订单行ID
|
||||
*/
|
||||
@TableField(value = "order_row_id")
|
||||
@ApiModelProperty(value = "生产订单行ID")
|
||||
private Long orderRowId;
|
||||
|
||||
@TableField(value = "CHARG")
|
||||
private String CHARG;
|
||||
|
||||
@TableField(value = "BAUGR")
|
||||
private String BAUGR;
|
||||
|
||||
@TableField(value = "WERKS")
|
||||
private String WERKS;
|
||||
|
||||
@TableField(value = "LGORT")
|
||||
private String LGORT;
|
||||
|
||||
@TableField(value = "BDMNG")
|
||||
private String BDMNG;
|
||||
|
||||
@TableField(value = "MEINS")
|
||||
private String MEINS;
|
||||
|
||||
@TableField(value = "ENMNG")
|
||||
private String ENMNG;
|
||||
|
||||
@TableField(value = "AUFNR")
|
||||
private String AUFNR;
|
||||
|
||||
@TableField(value = "RSNUM")
|
||||
private String RSNUM;
|
||||
|
||||
@TableField(value = "NOMAT")
|
||||
private String NOMAT;
|
||||
|
||||
@TableField(value = "POSNR")
|
||||
private String POSNR;
|
||||
|
||||
@TableField(value = "NOMNG")
|
||||
private String NOMNG;
|
||||
|
||||
@TableField(value = "RSPOS")
|
||||
private String RSPOS;
|
||||
|
||||
@TableField(value = "DUMPS")
|
||||
private String DUMPS;
|
||||
|
||||
@TableField(value = "PRVBE")
|
||||
private String PRVBE;
|
||||
|
||||
@TableField(value = "POSTP")
|
||||
private String POSTP;
|
||||
|
||||
@TableField(value = "BDTER")
|
||||
private String BDTER;
|
||||
|
||||
@TableField(value = "SORTF")
|
||||
private String SORTF;
|
||||
|
||||
@TableField(value = "MATNR")
|
||||
private String MATNR;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package com.nflg.product.bomnew.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* t_production_order_sap
|
||||
* 生产订单抬头表(SAP原始数据)
|
||||
*
|
||||
* @author makejava
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "com-nflg-product-bomnew-pojo-main-entity-ProductionOrderSapEntity")
|
||||
@TableName(value = "t_production_order_sap")
|
||||
public class ProductionOrderSapEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* FTRMI=Wed Aug 07 00:00:00 CST 2024, 实际下达日期
|
||||
* AENAM=MM014, 最后更改人
|
||||
* WERKS=1010, 工厂
|
||||
* AEDAT=Wed Aug 07 00:00:00 CST 2024, 更改订单主文件日期
|
||||
* SBMNG=1.000, 基本数量
|
||||
* GMEIN=ST, 基本计量单位
|
||||
* STLBEZ=000000002120230002, 物料号
|
||||
* GAMNG=1.000, 订单数量总计
|
||||
* AUTYP=10, 订单类型
|
||||
* AUFNR=000010435564, 订单号
|
||||
* RSNUM=0001308129, 预留/相关需求的编号
|
||||
* ERFZEIT=Thu Jan 01 21:59:00 CST 1970, 创建的时间
|
||||
* SBMEH=ST, 基本计量单位
|
||||
* ERDAT=Tue Jan 02 00:00:00 CST 2024, 创建日期
|
||||
* AEZEIT=Thu Jan 01 09:57:04 CST 1970, 更改在
|
||||
* ERNAM=PANF 输入者
|
||||
*/
|
||||
|
||||
/**
|
||||
* 行ID 雪花
|
||||
*/
|
||||
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "行ID 雪花")
|
||||
private Long rowId;
|
||||
|
||||
@TableField(value = "FTRMI")
|
||||
private String FTRMI;
|
||||
|
||||
@TableField(value = "AENAM")
|
||||
private String AENAM;
|
||||
|
||||
@TableField(value = "WERKS")
|
||||
private String WERKS;
|
||||
|
||||
@TableField(value = "AEDAT")
|
||||
private String AEDAT;
|
||||
|
||||
@TableField(value = "SBMNG")
|
||||
private String SBMNG;
|
||||
|
||||
@TableField(value = "GMEIN")
|
||||
private String GMEIN;
|
||||
|
||||
@TableField(value = "STLBEZ")
|
||||
private String STLBEZ;
|
||||
|
||||
@TableField(value = "GAMNG")
|
||||
private String GAMNG;
|
||||
|
||||
@TableField(value = "AUTYP")
|
||||
private String AUTYP;
|
||||
|
||||
@TableField(value = "AUFNR")
|
||||
private String AUFNR;
|
||||
|
||||
@TableField(value = "RSNUM")
|
||||
private String RSNUM;
|
||||
|
||||
@TableField(value = "ERFZEIT")
|
||||
private String ERFZEIT;
|
||||
|
||||
@TableField(value = "SBMEH")
|
||||
private String SBMEH;
|
||||
|
||||
@TableField(value = "ERDAT")
|
||||
private String ERDAT;
|
||||
|
||||
@TableField(value = "AEZEIT")
|
||||
private String AEZEIT;
|
||||
|
||||
@TableField(value = "ERNAM")
|
||||
private String ERNAM;
|
||||
|
||||
/**
|
||||
* 处理状态 0未处理 1已处理
|
||||
*/
|
||||
@TableField(value = "handle_status")
|
||||
private Integer handleStatus;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
|
|
@ -128,6 +128,12 @@ 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;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import java.time.LocalDateTime;
|
|||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="com-nflg-product-bomnew-pojo-new-vo-ProductionOrderVO")
|
||||
public class ProductionOrderVO implements Serializable {
|
||||
public class ProductionOrderVO extends BaseMaterialVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 行ID 雪花
|
||||
|
|
@ -33,17 +33,17 @@ public class ProductionOrderVO implements Serializable {
|
|||
@ApiModelProperty(value = "生产订单号")
|
||||
private String productionOrder;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@ApiModelProperty(value = "物料编码")
|
||||
private String materialNo;
|
||||
// /**
|
||||
// * 物料编码
|
||||
// */
|
||||
// @ApiModelProperty(value = "物料编码")
|
||||
// private String materialNo;
|
||||
|
||||
/**
|
||||
* 物料描述
|
||||
*/
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String materialDesc;
|
||||
// /**
|
||||
// * 物料描述
|
||||
// */
|
||||
// @ApiModelProperty(value = "物料描述")
|
||||
// private String materialDesc;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
|
@ -206,6 +207,7 @@ public class MaterialService {
|
|||
ma.setProjectType(md.getProjectType());
|
||||
}
|
||||
ma.setMaterialGetType(md.getMaterialGetType());
|
||||
this.get201101MaterialDescEn(ma);
|
||||
resultList.add(ma);
|
||||
|
||||
AddMaterialMainDTO ent = new AddMaterialMainDTO();
|
||||
|
|
@ -236,6 +238,22 @@ public class MaterialService {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void get201101MaterialDescEn(MaterialMainEntity ma) {
|
||||
if ("201101".equals(ma.getMaterialCategoryCode()) && ObjectUtil.isNotEmpty(ma.getMaterialName())) {
|
||||
if (ma.getMaterialName().endsWith("(发货)")) {
|
||||
ma.setMaterialDescEn("Deliver Goods Package");
|
||||
} else if (ma.getMaterialName().endsWith("(制作)")) {
|
||||
ma.setMaterialDescEn("Make Package");
|
||||
} else if (ma.getMaterialName().endsWith("(直发)")) {
|
||||
ma.setMaterialDescEn("Inventory Deliver Goods Package");
|
||||
} else if (ma.getMaterialName().endsWith("(油漆)")) {
|
||||
ma.setMaterialDescEn("Paint Package");
|
||||
} else if (ma.getMaterialName().endsWith("(发货前装配)")) {
|
||||
ma.setMaterialDescEn("Assembly before Shipment");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, AddVirtrualMaterialDTO> batchAddMaterial(List<AddVirtrualMaterialDTO> mds) {
|
||||
return batchAddMaterial(mds, SessionUtil.getUser());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,43 +3,65 @@ package com.nflg.product.bomnew.service;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.mapper.master.ProductionOrderItemSapMapper;
|
||||
import com.nflg.product.bomnew.mapper.master.ProductionOrderMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||
import com.nflg.product.bomnew.mapper.master.ProductionOrderSapMapper;
|
||||
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.ProductionOrderSapEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.ProductionOrderQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.ProductionOrderSaveQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.ProductionOrderItemVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.ProductionOrderVO;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, ProductionOrderEntity> {
|
||||
|
||||
@Resource
|
||||
private ProductionOrderItemService productionOrderItemService;
|
||||
@Resource
|
||||
SapService sapService;
|
||||
@Resource
|
||||
private MaterialMainService materialMainService;
|
||||
@Resource
|
||||
private ProductionOrderSapMapper productionOrderSapMapper;
|
||||
@Resource
|
||||
private ProductionOrderItemSapMapper productionOrderItemSapMapper;
|
||||
|
||||
public IPage<ProductionOrderVO> getListByPage(ProductionOrderQuery query){
|
||||
Page<ProductionOrderQuery> page=new Page<>(query.getPage(),query.getPageSize());
|
||||
return this.getBaseMapper().getListByPage(page,query);
|
||||
Page<ProductionOrderQuery> page = new Page<>(query.getPage(),query.getPageSize());
|
||||
Page<ProductionOrderVO> listByPage = this.getBaseMapper().getListByPage(page, query);
|
||||
if (CollUtil.isNotEmpty(listByPage.getRecords())) {
|
||||
materialMainService.intiMaterialInfo(listByPage.getRecords());
|
||||
}
|
||||
return listByPage;
|
||||
}
|
||||
|
||||
public List<ProductionOrderItemVO> getItemList(Long rowId) {
|
||||
|
|
@ -144,4 +166,133 @@ public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, P
|
|||
updateEntity.setUpdatedTime(LocalDateTime.now());
|
||||
this.updateById(updateEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从SAP获取生产订单
|
||||
* @param query
|
||||
*/
|
||||
public ResultVO<String> syncProductionOrderFromSap(ProductionOrderQuery query) {
|
||||
SapReqParams params = new SapReqParams();
|
||||
// 接口名
|
||||
params.setFunName("ZMDM_PP_ORD_SYNC");
|
||||
if (ObjectUtil.isNotEmpty(query.getProductionOrder())) {
|
||||
Map<String, List<Map<String, String>>> inputTables = new HashMap<>();
|
||||
Map<String, String> aufnrMap = new HashMap<>(1);
|
||||
aufnrMap.put("AUFNR", "0000" + query.getProductionOrder());
|
||||
List<Map<String, String>> inputList = Collections.singletonList(aufnrMap);
|
||||
inputTables.put("INPUT", inputList);
|
||||
params.setInputTables(inputTables);
|
||||
}
|
||||
Map<String, Object> inputParams = new HashMap<>();
|
||||
if (ObjectUtil.isNotEmpty(query.getStartDate())) {
|
||||
inputParams.put("I_BDATE", query.getStartDate());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(query.getEndDate())) {
|
||||
inputParams.put("I_EDATE", query.getEndDate());
|
||||
}
|
||||
params.setInputParams(inputParams);
|
||||
log.info("从SAP获取生产订单--参数:" + JSON.toJSONString(params));
|
||||
try {
|
||||
SapResult sapResult = sapService.doSapFun(params);
|
||||
// System.out.println("sapResult");
|
||||
// System.out.println(sapResult);
|
||||
if (!sapResult.isSuccess()) {
|
||||
return ResultVO.error(STATE.Error, "接口连接失败");
|
||||
}
|
||||
Map<String, Object> exportMap = sapResult.getExportMap();
|
||||
if (CollUtil.isNotEmpty(exportMap) && !"S".equals(exportMap.get("E_TYPE"))) {
|
||||
log.error("从SAP获取生产订单失败: {}", exportMap.get("E_MSG"));
|
||||
return ResultVO.error("从SAP获取生产订单失败: {}", exportMap.get("E_MSG"));
|
||||
}
|
||||
Map<String, List<Map<String, Object>>> outTablesMap = sapResult.getOutTablesMap();
|
||||
log.info("从SAP获取生产订单--返回数据:" + JSON.toJSONString(outTablesMap));
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss z yyyy", java.util.Locale.US);
|
||||
// 生产订单抬头
|
||||
if (outTablesMap.containsKey("HEAD")) {
|
||||
/**
|
||||
* FTRMI=Wed Aug 07 00:00:00 CST 2024, 实际下达日期
|
||||
* AENAM=MM014, 最后更改人
|
||||
* WERKS=1010, 工厂
|
||||
* AEDAT=Wed Aug 07 00:00:00 CST 2024, 更改订单主文件日期
|
||||
* SBMNG=1.000, 基本数量
|
||||
* GMEIN=ST, 基本计量单位
|
||||
* STLBEZ=000000002120230002, 物料号
|
||||
* GAMNG=1.000, 订单数量总计
|
||||
* AUTYP=10, 订单类型
|
||||
* AUFNR=000010435564, 订单号
|
||||
* RSNUM=0001308129, 预留/相关需求的编号
|
||||
* ERFZEIT=Thu Jan 01 21:59:00 CST 1970, 创建的时间
|
||||
* SBMEH=ST, 基本计量单位
|
||||
* ERDAT=Tue Jan 02 00:00:00 CST 2024, 创建日期
|
||||
* AEZEIT=Thu Jan 01 09:57:04 CST 1970, 更改在
|
||||
* ERNAM=PANF 输入者
|
||||
*/
|
||||
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+", "");
|
||||
// 生产订单号存在且未处理则跳过
|
||||
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();
|
||||
if (CollUtil.isNotEmpty(exists)) {
|
||||
continue;
|
||||
}
|
||||
ProductionOrderEntity save = new ProductionOrderEntity();
|
||||
save.setRowId(IdWorker.getId());
|
||||
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+", "") : "");
|
||||
save.setNum(ObjectUtil.isNotEmpty(head.get("GAMNG")) ? new BigDecimal(head.get("GAMNG").toString()) : null);
|
||||
save.setUnit(ObjectUtil.isNotEmpty(head.get("GMEIN")) ? head.get("GMEIN").toString() : "");
|
||||
save.setOrderType(ObjectUtil.isNotEmpty(head.get("AUTYP")) ? head.get("AUTYP").toString() : "");
|
||||
save.setLongText("");
|
||||
save.setContractNo("");
|
||||
save.setFindId("");
|
||||
save.setCreatedBy(ObjectUtil.isNotEmpty(head.get("ERNAM")) ? head.get("ERNAM").toString() : "");
|
||||
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.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());
|
||||
return ResultVO.error("从SAP获取生产订单报错: {}", e.getMessage());
|
||||
}
|
||||
return ResultVO.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.product.bomnew.mapper.master.ProductionOrderItemSapMapper">
|
||||
</mapper>
|
||||
|
|
@ -36,7 +36,9 @@
|
|||
</sql>
|
||||
|
||||
<select id="getListByPage" resultType="com.nflg.product.bomnew.pojo.vo.ProductionOrderVO">
|
||||
select * from t_production_order where 1=1
|
||||
select po.*, mm.material_desc materialDesc from t_production_order po
|
||||
left join t_material_main mm on po.material_no = mm.material_no
|
||||
where 1=1
|
||||
<include refid="whr"/>
|
||||
order by row_id desc
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.product.bomnew.mapper.master.ProductionOrderSapMapper">
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue