Merge remote-tracking branch 'origin/master-stock-lhj1104'
This commit is contained in:
commit
8c3384f053
|
|
@ -0,0 +1,66 @@
|
|||
package com.nflg.product.material.api.user.material;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.nflg.product.base.core.api.BaseApi;
|
||||
import com.nflg.product.material.pojo.entity.MaterialDeadStockEntity;
|
||||
import com.nflg.product.material.pojo.sop.SopStockVo;
|
||||
import com.nflg.product.material.pojo.vo.MaterialAttrValueVO;
|
||||
import com.nflg.product.material.pojo.vo.MaterialDeadStockVo;
|
||||
import com.nflg.product.material.pojo.vo.MaterialOrderPlanVo;
|
||||
import com.nflg.product.material.service.MaterialDeadStockService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.Wrapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* packageName com.nflg.product.material.api.user.material
|
||||
*
|
||||
* @author luohj
|
||||
* @className MaterialDeadStockApi
|
||||
* @date 2024/11/4 0004
|
||||
* @description TODO
|
||||
*/
|
||||
@Api(tags = "呆滞库存记录")
|
||||
@RestController
|
||||
@RequestMapping("materialDeadStock")
|
||||
public class MaterialDeadStockApi extends BaseApi {
|
||||
|
||||
@Resource
|
||||
private MaterialDeadStockService materialDeadStockService;
|
||||
|
||||
@GetMapping("listByType")
|
||||
@ApiOperation("呆滞库存记录集合")
|
||||
public ResultVO<List<MaterialDeadStockVo>> listByType(@RequestParam("type") Integer type) {
|
||||
List<MaterialDeadStockEntity> deadStockEntityList = materialDeadStockService.list(Wrappers.<MaterialDeadStockEntity>lambdaQuery()
|
||||
.eq(MaterialDeadStockEntity::getType,type));
|
||||
return ResultVO.success(Convert.toList(MaterialDeadStockVo.class,deadStockEntityList));
|
||||
}
|
||||
|
||||
@GetMapping("querySopStock")
|
||||
@ApiOperation("SAP呆滞库存")
|
||||
public ResultVO<Map<String,List<SopStockVo>>> querySopStock(@RequestParam("type") Integer type
|
||||
, @RequestParam(value = "orderBy",required = false) Integer orderBy) {
|
||||
return ResultVO.success(materialDeadStockService.querySopStock(type,orderBy));
|
||||
}
|
||||
|
||||
@GetMapping("orderPlanList")
|
||||
@ApiOperation("MES订单计划接口")
|
||||
public ResultVO<List<MaterialOrderPlanVo>> orderPlanList() {
|
||||
return ResultVO.success(materialDeadStockService.orderPlanList());
|
||||
}
|
||||
|
||||
@PostMapping("saveDeadStock")
|
||||
@ApiOperation("保存呆滞库存记录")
|
||||
public ResultVO<List<MaterialDeadStockEntity>> saveDeadStock(@RequestBody List<MaterialDeadStockEntity> deadStockList){
|
||||
return ResultVO.success(materialDeadStockService.saveDeadStock(deadStockList));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
|
|||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.nflg.product.base.core.api.BaseApi;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
package com.nflg.product.material.config;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nflg.product.material.pojo.vo.MaterialNoticeRtx;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* packageName com.nflg.product.material.config
|
||||
*
|
||||
* @author luohj
|
||||
* @className MaterialHomeBiConfig
|
||||
* @date 2024/8/13 0013
|
||||
* @description MES相关配置
|
||||
*/
|
||||
|
||||
@Component
|
||||
@Data
|
||||
@RefreshScope
|
||||
@ConfigurationProperties(prefix = "material.mes")
|
||||
public class MaterialMesConfig {
|
||||
|
||||
/**
|
||||
* MES服务地址
|
||||
*/
|
||||
private String domain;
|
||||
|
||||
/**
|
||||
* MES计划订单地址
|
||||
*/
|
||||
private String orderPlanListUrl;
|
||||
|
||||
/**
|
||||
* 呆滞天数
|
||||
*/
|
||||
private Integer deadDays;
|
||||
|
||||
/**
|
||||
* 外购件库位
|
||||
*/
|
||||
private String purchaseLgort;
|
||||
|
||||
/**
|
||||
* 金工件库位
|
||||
*/
|
||||
private String metalLgort;
|
||||
|
||||
/**
|
||||
* 售后库位
|
||||
*/
|
||||
private String afterSalesLgort;
|
||||
|
||||
/**
|
||||
* 移动破库位
|
||||
*/
|
||||
private String ydpLgort;
|
||||
|
||||
/**
|
||||
* 事业部库位
|
||||
*/
|
||||
private String deptLgort;
|
||||
|
||||
/**
|
||||
* 半成品库位库位
|
||||
*/
|
||||
private String semiFinishedLgort;
|
||||
|
||||
/**
|
||||
* 成品库位
|
||||
*/
|
||||
private String finishedLgort;
|
||||
|
||||
/**
|
||||
* 采购组负责人RTX通知
|
||||
*/
|
||||
private List<MaterialNoticeRtx> purchaseNoticeList;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.nflg.product.material.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum MaterialDeadStockTypeEnum {
|
||||
STOCK(1,"物料仓库"),
|
||||
DEPT(2,"事业部/技术研发仓库"),
|
||||
ALL(3,"全局"),
|
||||
PRODUCT(4,"半成品库和成品库");
|
||||
|
||||
private final Integer code;
|
||||
private final String msg;
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.nflg.product.material.mapper.master;
|
||||
|
||||
import com.nflg.product.material.pojo.entity.MaterialDeadStockEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 10002327
|
||||
* @description 针对表【t_material_dead_stock(呆滞库存记录)】的数据库操作Mapper
|
||||
* @createDate 2024-11-04 16:54:07
|
||||
* @Entity com.nflg.product.material.pojo.entity.MaterialDeadStockEntity
|
||||
*/
|
||||
public interface MaterialDeadStockMapper extends BaseMapper<MaterialDeadStockEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -2,7 +2,9 @@ package com.nflg.product.material.mapper.sop;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.product.material.pojo.sop.SopMaterialInfo;
|
||||
import com.nflg.product.material.pojo.sop.SopStockVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,128 @@
|
|||
package com.nflg.product.material.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 呆滞库存记录
|
||||
* @TableName t_material_dead_stock
|
||||
*/
|
||||
@TableName(value ="t_material_dead_stock")
|
||||
@Data
|
||||
public class MaterialDeadStockEntity implements Serializable {
|
||||
/**
|
||||
* 行ID
|
||||
*/
|
||||
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
|
||||
private Long rowId;
|
||||
|
||||
/**
|
||||
* 工厂
|
||||
*/
|
||||
@TableField(value = "werks")
|
||||
private String werks;
|
||||
|
||||
/**
|
||||
* 库存地点
|
||||
*/
|
||||
@TableField(value = "lgort")
|
||||
private String lgort;
|
||||
|
||||
/**
|
||||
* 物料号
|
||||
*/
|
||||
@TableField(value = "matnr")
|
||||
private String matnr;
|
||||
|
||||
/**
|
||||
* 呆滞原因
|
||||
*/
|
||||
@TableField(value = "dead_reason")
|
||||
private String deadReason;
|
||||
|
||||
/**
|
||||
* 呆滞处理情况
|
||||
*/
|
||||
@TableField(value = "handle_result")
|
||||
private String handleResult;
|
||||
|
||||
/**
|
||||
* 事业部
|
||||
*/
|
||||
@TableField(value = "dept_name")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 类型:1物料仓库、2事业部/技术研发仓库、3全局、4半成品库和成品库
|
||||
*/
|
||||
@TableField(value = "type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 客户名称
|
||||
*/
|
||||
@TableField(value = "customer_name")
|
||||
private String customerName;
|
||||
|
||||
/**
|
||||
* 工厂
|
||||
*/
|
||||
@TableField(value = "order_plan_id")
|
||||
private String orderPlanId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField(value = "ekgrp")
|
||||
private String ekgrp;
|
||||
|
||||
/**
|
||||
* 采购维护日期
|
||||
*/
|
||||
@TableField(value = "purchase_maintain_date")
|
||||
private LocalDateTime purchaseMaintainDate;
|
||||
|
||||
/**
|
||||
* 呆滞处理结果日期
|
||||
*/
|
||||
@TableField(value = "handle_result_date")
|
||||
private LocalDateTime handleResultDate;
|
||||
|
||||
/**
|
||||
* 创建人编码
|
||||
*/
|
||||
@TableField(value = "created_by",fill = FieldFill.INSERT)
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "created_time",fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人编码
|
||||
*/
|
||||
@TableField(value = "updated_by",fill = FieldFill.INSERT_UPDATE)
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(value = "updated_time",fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.nflg.product.material.pojo.sop;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* packageName com.nflg.product.material.pojo.sop
|
||||
*
|
||||
* @author luohj
|
||||
* @className SopStockVo
|
||||
* @date 2024/11/4 0004
|
||||
* @description sap呆滞库存信息
|
||||
*/
|
||||
@Data
|
||||
public class SopStockVo implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "物料号")
|
||||
private String matnr;
|
||||
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String txtlg;
|
||||
|
||||
@ApiModelProperty(value = "库存地点")
|
||||
private String lgort;
|
||||
|
||||
@ApiModelProperty(value = "工厂")
|
||||
private String werks;
|
||||
|
||||
@ApiModelProperty(value = "单价")
|
||||
private BigDecimal dj;
|
||||
|
||||
@ApiModelProperty(value = "呆滞数量")
|
||||
private BigDecimal labst;
|
||||
|
||||
@ApiModelProperty(value = "呆滞金额")
|
||||
private BigDecimal dzje;
|
||||
|
||||
@ApiModelProperty(value = "呆滞天数")
|
||||
private BigDecimal dzts;
|
||||
|
||||
@ApiModelProperty(value = "采购组")
|
||||
private String ekgrp;
|
||||
|
||||
@ApiModelProperty(value = "最后入库日期")
|
||||
private String zhrkrq;
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.nflg.product.material.pojo.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.nflg.product.material.pojo.sop.SopStockVo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* packageName com.nflg.product.material.pojo.sop
|
||||
*
|
||||
* @author luohj
|
||||
* @className SopStockVo
|
||||
* @date 2024/11/4 0004
|
||||
* @description sap呆滞库存信息
|
||||
*/
|
||||
@Data
|
||||
public class MaterialDeadStockVo implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "rowId")
|
||||
private Long rowId;
|
||||
|
||||
@ApiModelProperty(value = "werks")
|
||||
private String werks;
|
||||
|
||||
@ApiModelProperty(value = "lgort")
|
||||
private String lgort;
|
||||
|
||||
@ApiModelProperty(value = "matnr")
|
||||
private String matnr;
|
||||
|
||||
@ApiModelProperty(value = "事业部")
|
||||
private String deptName;
|
||||
|
||||
@ApiModelProperty(value = "呆滞原因")
|
||||
private String deadReason;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "客户名称")
|
||||
private String customerName;
|
||||
|
||||
@ApiModelProperty(value = "呆滞处理结果")
|
||||
private String handleResult;
|
||||
|
||||
@ApiModelProperty(value = "呆滞处理日期")
|
||||
private String handleResultDate;
|
||||
|
||||
@ApiModelProperty(value = "计划订单id")
|
||||
private String orderPlanId;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.nflg.product.material.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* packageName com.nflg.product.material.pojo.vo
|
||||
*
|
||||
* @author luohj
|
||||
* @className MaterialNoticeRtx
|
||||
* @date 2024/11/7 0007
|
||||
* @description TODO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class MaterialNoticeRtx {
|
||||
|
||||
@ApiModelProperty(value = "ekgrp")
|
||||
private String ekgrp;
|
||||
|
||||
@ApiModelProperty(value = "rtx账号")
|
||||
private String rtx;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.nflg.product.material.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* packageName com.nflg.product.material.pojo.sop
|
||||
*
|
||||
* @author luohj
|
||||
* @className SopStockVo
|
||||
* @date 2024/11/4 0004
|
||||
* @description MES订单计划信息
|
||||
*/
|
||||
@Data
|
||||
public class MaterialOrderPlanVo implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "订单计划id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "事业部")
|
||||
private String contractNo;
|
||||
|
||||
@ApiModelProperty(value = "SAP订单号")
|
||||
private String sapOrderNo;
|
||||
|
||||
@ApiModelProperty(value = "机型")
|
||||
private String machineType;
|
||||
|
||||
@ApiModelProperty(value = "机台编号")
|
||||
private String machineNo;
|
||||
|
||||
@ApiModelProperty(value = "客户名称简称")
|
||||
private String customerName;
|
||||
|
||||
@ApiModelProperty(value = "物料号")
|
||||
private String materialNo;
|
||||
|
||||
@ApiModelProperty(value = "图号")
|
||||
private String chartNo;
|
||||
|
||||
@ApiModelProperty(value = "品名 产品线/事业部 对应CRM的产品二级目录")
|
||||
private String typeName;
|
||||
|
||||
@ApiModelProperty(value = "订单编号")
|
||||
private String orderNo;
|
||||
|
||||
@ApiModelProperty(value = "订单状态")
|
||||
private String orderStatus;
|
||||
}
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
package com.nflg.product.material.service;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nflg.product.material.config.MaterialMesConfig;
|
||||
import com.nflg.product.material.mapper.master.MaterialDeadStockMapper;
|
||||
import com.nflg.product.material.pojo.entity.MaterialDeadStockEntity;
|
||||
import com.nflg.product.material.pojo.sop.SopStockVo;
|
||||
import com.nflg.product.material.pojo.vo.MaterialNoticeRtx;
|
||||
import com.nflg.product.material.pojo.vo.MaterialOrderPlanVo;
|
||||
import com.nflg.product.material.util.HttpUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 10002327
|
||||
* @description 针对表【t_material_dead_stock(呆滞库存记录)】的数据库操作Service
|
||||
* @createDate 2024-11-04 16:54:07
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MaterialDeadStockService extends ServiceImpl<MaterialDeadStockMapper, MaterialDeadStockEntity> {
|
||||
|
||||
@Resource
|
||||
@Qualifier("sopConnection")
|
||||
private Connection sopConnection;
|
||||
|
||||
@Resource
|
||||
private MaterialMesConfig materialMesConfig;
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String profiles;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<MaterialDeadStockEntity> saveDeadStock(@RequestBody List<MaterialDeadStockEntity> deadStockList){
|
||||
//采购组通知rtx
|
||||
Set<String> purchaseSet = new HashSet<>();
|
||||
deadStockList.forEach(deadStock -> {
|
||||
if(deadStock.getRowId() == null){
|
||||
// 如果有填写呆滞处理结果,则记录处理时间
|
||||
if(StrUtil.isNotBlank(deadStock.getHandleResult())){
|
||||
deadStock.setHandleResultDate(LocalDateTime.now());
|
||||
}
|
||||
if(StrUtil.isNotBlank(deadStock.getEkgrp())){
|
||||
purchaseSet.add(deadStock.getEkgrp());
|
||||
}
|
||||
this.save(deadStock);
|
||||
}else{
|
||||
//更新
|
||||
// 如果呆滞处理结果日期为空 && 有填写呆滞处理结果,则记录处理时间
|
||||
if(deadStock.getHandleResultDate() == null && StrUtil.isNotBlank(deadStock.getHandleResult())){
|
||||
deadStock.setHandleResultDate(LocalDateTime.now());
|
||||
}
|
||||
this.updateById(deadStock);
|
||||
}
|
||||
});
|
||||
//通知rtx
|
||||
if(!purchaseSet.isEmpty()){
|
||||
HttpUtils httpUtils = new HttpUtils();
|
||||
String title = "呆滞物料提醒";
|
||||
String msg = "有新增呆滞物料,请及时查看!";
|
||||
String receiver = materialMesConfig.getPurchaseNoticeList().stream().filter(pur -> purchaseSet.contains(pur.getEkgrp()))
|
||||
.map(MaterialNoticeRtx::getRtx).collect(Collectors.joining(","));
|
||||
httpUtils.rtxMessage(profiles,title,msg,receiver);
|
||||
}
|
||||
return deadStockList;
|
||||
}
|
||||
|
||||
public List<MaterialOrderPlanVo> orderPlanList(){
|
||||
HttpUtils httpUtils = new HttpUtils();
|
||||
List<MaterialOrderPlanVo> reList = Lists.newArrayList();
|
||||
try {
|
||||
String res = httpUtils.doGet(String.format("%s%s",materialMesConfig.getDomain(),materialMesConfig.getOrderPlanListUrl()));
|
||||
reList = JSON.parseArray(res, MaterialOrderPlanVo.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return reList;
|
||||
}
|
||||
|
||||
/**
|
||||
* SAP呆滞库存
|
||||
* @param type 类型
|
||||
* @param orderBy 排序:1 DZTS,2 DZJE
|
||||
* @return
|
||||
*/
|
||||
public Map<String,List<SopStockVo>> querySopStock(Integer type,Integer orderBy){
|
||||
String order = Objects.equals(orderBy,1)?"DZTS":"DZJE";
|
||||
Map<String,List<SopStockVo>> resMap = Maps.newHashMap();
|
||||
// 呆滞仓库-列表数据集
|
||||
Map<String,List<String>> reMap =Maps.newHashMap();
|
||||
switch (type){
|
||||
case 1:
|
||||
reMap.put("purchaseLgort", Arrays.asList(materialMesConfig.getPurchaseLgort().split(",")));
|
||||
reMap.put("metalLgort", Arrays.asList(materialMesConfig.getMetalLgort().split(",")));
|
||||
reMap.put("afterSalesLgort", Arrays.asList(materialMesConfig.getAfterSalesLgort().split(",")));
|
||||
reMap.put("ydpLgort", Arrays.asList(materialMesConfig.getYdpLgort().split(",")));
|
||||
break;
|
||||
case 2:
|
||||
reMap.put("deptLgort", Arrays.asList(materialMesConfig.getDeptLgort().split(",")));
|
||||
break;
|
||||
case 3:
|
||||
reMap.put("purchaseLgort", Arrays.asList(materialMesConfig.getPurchaseLgort().split(",")));
|
||||
reMap.put("metalLgort", Arrays.asList(materialMesConfig.getMetalLgort().split(",")));
|
||||
reMap.put("afterSalesLgort", Arrays.asList(materialMesConfig.getAfterSalesLgort().split(",")));
|
||||
reMap.put("ydpLgort", Arrays.asList(materialMesConfig.getYdpLgort().split(",")));
|
||||
reMap.put("deptLgort", Arrays.asList(materialMesConfig.getDeptLgort().split(",")));
|
||||
break;
|
||||
case 4:
|
||||
reMap.put("semiFinishedLgort", Arrays.asList(materialMesConfig.getSemiFinishedLgort().split(",")));
|
||||
reMap.put("finishedLgort", Arrays.asList(materialMesConfig.getFinishedLgort().split(",")));
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
String budatDate = DateUtil.format(DateUtil.offsetDay(new Date(),-materialMesConfig.getDeadDays()),"yyyyMMdd");
|
||||
reMap.forEach((k,v) -> {
|
||||
String werks = Objects.equals("afterSalesLgort",k)?"1030":"1010";
|
||||
List<SopStockVo> stockVoList = stockList(werks,v,budatDate,order);
|
||||
resMap.put(k,stockVoList);
|
||||
});
|
||||
|
||||
return resMap;
|
||||
}
|
||||
|
||||
private List<SopStockVo> stockList(String werks,List<String> lgortList,String budatDate,String orderBy){
|
||||
List<SopStockVo> rList = Lists.newArrayList();
|
||||
String lb = " and t1.lgort in (";
|
||||
String we = "";
|
||||
for (String str:lgortList) {
|
||||
we += "'"+str+"',";
|
||||
}
|
||||
we = we.substring(0,we.length() -1 );
|
||||
lb = lb + we + ") ";
|
||||
// 20200414 add 物料号不以71开头,且不为2190000290、2100030260
|
||||
String sql = "select t1.werks,t1.lgort,LTRIM(t1.matnr,'0')matnr,t1.labst,t2.txtlg,t3.budat,current_date,days_between(t3.budat,current_date) dzts,\n" +
|
||||
"(case when peinh <> 0 and vprsv = 'V' then t4.verpr / t4.peinh * t1.labst else t4.stprs / t4.peinh * t1.labst end)dzje," +
|
||||
"(case when peinh <> 0 and vprsv = 'V' then t4.verpr / t4.peinh else t4.stprs / t4.peinh end)dj,t5.EKGRP,t6.zhrkrq "+
|
||||
"from SAPABAP1.\"/BIC/AZMM_T00132\" as t1\n" +
|
||||
"inner join \"SAPABAP1\".\"/BI0/TMATERIAL\" t2 on t1.matnr = t2.material and t2.langu = '1'\n" +
|
||||
"inner join (select matnr,max(budat) as budat from SAPABAP1.\"/BIC/AZMM_E00052\" \n" +
|
||||
"\t\t\twhere matnr != '' and werks = ? " +
|
||||
"\t\t\tgroup by matnr having max(budat) <= ? ) t3 on t1.matnr = t3.matnr\n" +
|
||||
"inner join (select distinct bwkey,matnr,verpr,peinh,stprs,vprsv from \"STG_ECC\".\"MBEW\" ) t4 on t1.werks = t4.bwkey and t1.matnr = t4.matnr " +
|
||||
"left join \"STG_ECC\".\"MARC\" as t5 on t1.werks = t5.werks and t1.matnr = t5.matnr "+
|
||||
"left join (select matnr,max( budat ) zhrkrq from SAPABAP1.\"/BIC/AZMM_E00052\" where shkzg = 'S' and BWART in ('101','105') and werks=? group by matnr ) as t6 on t1.matnr = t6.matnr " +
|
||||
"where t1.labst > 0 and LTRIM(t1.matnr,'0') not like '71%' and LTRIM(t1.matnr,'0') not in ('2190000290','2100030260') and t1.werks = ? " + lb;
|
||||
if(StrUtil.isNotBlank(orderBy)){
|
||||
sql += " order by "+orderBy+" desc ";
|
||||
}
|
||||
|
||||
try {
|
||||
PreparedStatement pstmt = sopConnection.prepareStatement(sql);
|
||||
pstmt.setObject(1,werks);
|
||||
pstmt.setObject(2,budatDate);
|
||||
pstmt.setObject(3,werks);
|
||||
pstmt.setObject(4,werks);
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
List<Map<String, Object>> list = resultSetToList(resultSet);
|
||||
rList = JSON.parseArray(JSON.toJSONString(list),SopStockVo.class);
|
||||
//rList = Convert.toList(SopStockVo.class,list);
|
||||
} catch (Exception e) {
|
||||
log.error("呆滞库存获取失败:{}",e.getMessage() );
|
||||
}
|
||||
return rList;
|
||||
}
|
||||
|
||||
/**
|
||||
* ResultSet转List
|
||||
*/
|
||||
public List<Map<String,Object>> resultSetToList(ResultSet resultSet) throws SQLException {
|
||||
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
|
||||
ResultSetMetaData md = resultSet.getMetaData(); //获得结果集结构信息,元数据
|
||||
int columnCount = md.getColumnCount(); //获得列数
|
||||
while (resultSet.next()) {
|
||||
Map<String,Object> rowData = new HashMap<String,Object>();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
rowData.put(md.getColumnName(i), resultSet.getObject(i));
|
||||
}
|
||||
list.add(rowData);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,9 @@ spring.cloud.nacos.config.extension-configs[0].refresh=true
|
|||
spring.cloud.nacos.config.extension-configs[1].data-id=mysql-${spring.profiles.active}.properties
|
||||
spring.cloud.nacos.config.extension-configs[1].group=${spring.profiles.active}
|
||||
spring.cloud.nacos.config.extension-configs[1].refresh=true
|
||||
spring.cloud.nacos.config.extension-configs[2].data-id=material-conf-${spring.profiles.active}.yaml
|
||||
spring.cloud.nacos.config.extension-configs[2].group=${spring.profiles.active}
|
||||
spring.cloud.nacos.config.extension-configs[2].refresh=true
|
||||
|
||||
#discovery
|
||||
spring.cloud.nacos.discovery.server-addr=${nacos.server-addr}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
<?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.material.mapper.master.MaterialDeadStockMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.nflg.product.material.pojo.entity.MaterialDeadStockEntity">
|
||||
<id property="rowId" column="row_id" jdbcType="BIGINT"/>
|
||||
<result property="werks" column="werks" jdbcType="VARCHAR"/>
|
||||
<result property="lgort" column="lgort" jdbcType="VARCHAR"/>
|
||||
<result property="matnr" column="matnr" jdbcType="VARCHAR"/>
|
||||
<result property="deadReason" column="dead_reason" jdbcType="VARCHAR"/>
|
||||
<result property="handleResult" column="handle_result" jdbcType="VARCHAR"/>
|
||||
<result property="deptName" column="dept_name" jdbcType="VARCHAR"/>
|
||||
<result property="type" column="type" jdbcType="TINYINT"/>
|
||||
<result property="customerName" column="customer_name" jdbcType="VARCHAR"/>
|
||||
<result property="orderPlanId" column="order_plan_id" jdbcType="VARCHAR"/>
|
||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
||||
<result property="purchaseMaintainDate" column="purchase_maintain_date" jdbcType="TIMESTAMP"/>
|
||||
<result property="handleResultDate" column="handle_result_date" jdbcType="TIMESTAMP"/>
|
||||
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
row_id,werks,lgort,
|
||||
matnr,dead_reason,handle_result,
|
||||
dept_name,type,customer_name,
|
||||
order_plan_id,remark,purchase_maintain_date,
|
||||
handle_result_date,created_by,created_time,
|
||||
update_by,update_time
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
@ -2,5 +2,4 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.product.material.mapper.sop.SopMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue