【生产订单管理】
This commit is contained in:
parent
91be7b8de1
commit
fa3dfc210e
|
|
@ -101,4 +101,16 @@ public class ProductionOrderApi extends BaseApi {
|
||||||
return ResultVO.success();
|
return ResultVO.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从SAP获取生产订单
|
||||||
|
*
|
||||||
|
* @param query Query 查询实体
|
||||||
|
* @return 所有数据
|
||||||
|
*/
|
||||||
|
@PostMapping("syncProductionOrderFromSap")
|
||||||
|
@ApiOperation("从SAP获取生产订单")
|
||||||
|
public ResultVO<String> syncProductionOrderFromSap(@RequestBody ProductionOrderQuery query) {
|
||||||
|
return productionOrderService.syncProductionOrderFromSap(query);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,12 @@ public class ProductionOrderEntity implements Serializable {
|
||||||
@ApiModelProperty(value = "物料编码")
|
@ApiModelProperty(value = "物料编码")
|
||||||
private String materialNo;
|
private String materialNo;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 物料描述
|
// * 物料描述
|
||||||
*/
|
// */
|
||||||
@TableField(value = "material_desc")
|
// @TableField(value = "material_desc")
|
||||||
@ApiModelProperty(value = "物料描述")
|
// @ApiModelProperty(value = "物料描述")
|
||||||
private String materialDesc;
|
// private String materialDesc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数量
|
* 数量
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import java.time.LocalDateTime;
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@ApiModel(value="com-nflg-product-bomnew-pojo-new-vo-ProductionOrderVO")
|
@ApiModel(value="com-nflg-product-bomnew-pojo-new-vo-ProductionOrderVO")
|
||||||
public class ProductionOrderVO implements Serializable {
|
public class ProductionOrderVO extends BaseMaterialVO implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 行ID 雪花
|
* 行ID 雪花
|
||||||
|
|
@ -33,17 +33,17 @@ public class ProductionOrderVO implements Serializable {
|
||||||
@ApiModelProperty(value = "生产订单号")
|
@ApiModelProperty(value = "生产订单号")
|
||||||
private String productionOrder;
|
private String productionOrder;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 物料编码
|
// * 物料编码
|
||||||
*/
|
// */
|
||||||
@ApiModelProperty(value = "物料编码")
|
// @ApiModelProperty(value = "物料编码")
|
||||||
private String materialNo;
|
// private String materialNo;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 物料描述
|
// * 物料描述
|
||||||
*/
|
// */
|
||||||
@ApiModelProperty(value = "物料描述")
|
// @ApiModelProperty(value = "物料描述")
|
||||||
private String materialDesc;
|
// private String materialDesc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数量
|
* 数量
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.lang.TypeReference;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
|
@ -12,7 +12,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||||
import com.nflg.product.bomnew.mapper.master.ProductionOrderMapper;
|
import com.nflg.product.bomnew.mapper.master.ProductionOrderMapper;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
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.ProductionOrderEntity;
|
||||||
import com.nflg.product.bomnew.pojo.entity.ProductionOrderItemEntity;
|
import com.nflg.product.bomnew.pojo.entity.ProductionOrderItemEntity;
|
||||||
import com.nflg.product.bomnew.pojo.query.ProductionOrderQuery;
|
import com.nflg.product.bomnew.pojo.query.ProductionOrderQuery;
|
||||||
|
|
@ -20,26 +21,41 @@ import com.nflg.product.bomnew.pojo.query.ProductionOrderSaveQuery;
|
||||||
import com.nflg.product.bomnew.pojo.vo.ProductionOrderItemVO;
|
import com.nflg.product.bomnew.pojo.vo.ProductionOrderItemVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.ProductionOrderVO;
|
import com.nflg.product.bomnew.pojo.vo.ProductionOrderVO;
|
||||||
import com.nflg.product.bomnew.util.VUtils;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author makejava
|
* @author makejava
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, ProductionOrderEntity> {
|
public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, ProductionOrderEntity> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ProductionOrderItemService productionOrderItemService;
|
private ProductionOrderItemService productionOrderItemService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
SapService sapService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialMainService materialMainService;
|
||||||
|
|
||||||
public IPage<ProductionOrderVO> getListByPage(ProductionOrderQuery query){
|
public IPage<ProductionOrderVO> getListByPage(ProductionOrderQuery query){
|
||||||
Page<ProductionOrderQuery> page=new Page<>(query.getPage(),query.getPageSize());
|
Page<ProductionOrderQuery> page = new Page<>(query.getPage(),query.getPageSize());
|
||||||
return this.getBaseMapper().getListByPage(page,query);
|
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) {
|
public List<ProductionOrderItemVO> getItemList(Long rowId) {
|
||||||
|
|
@ -144,4 +160,129 @@ public class ProductionOrderService extends ServiceImpl<ProductionOrderMapper, P
|
||||||
updateEntity.setUpdatedTime(LocalDateTime.now());
|
updateEntity.setUpdatedTime(LocalDateTime.now());
|
||||||
this.updateById(updateEntity);
|
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+", "");
|
||||||
|
// 生产订单号存在则跳过
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="getListByPage" resultType="com.nflg.product.bomnew.pojo.vo.ProductionOrderVO">
|
<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"/>
|
<include refid="whr"/>
|
||||||
order by row_id desc
|
order by row_id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue