add:增加退料入库

This commit is contained in:
zhangzq
2026-07-08 14:22:52 +08:00
parent 8dd3726f68
commit acee4f0695
35 changed files with 1109 additions and 163 deletions

View File

@@ -1,11 +1,14 @@
package org.nl.common.base;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpStatus;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@@ -28,8 +31,9 @@ public class TableDataInfo<T> implements Serializable {
/**
* 列表数据
*/
private List<T> content = new ArrayList<>();
private Object content = new ArrayList<>();
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime timestamp = LocalDateTime.now();
/**
* 消息状态码
*/
@@ -38,11 +42,9 @@ public class TableDataInfo<T> implements Serializable {
/**
* 消息内容
*/
private String msg;
/**
* 反馈数据
*/
private Object data;
private String message;
private Integer respCode;
private String respMsg;
/**
* 分页
*
@@ -57,34 +59,30 @@ public class TableDataInfo<T> implements Serializable {
public static <T> TableDataInfo<T> build(IPage<T> page) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(String.valueOf(HttpStatus.HTTP_OK));
rspData.setMsg("操作成功");
rspData.setMessage("操作成功");
rspData.setRespMsg("操作成功");
rspData.setRespCode(0);
rspData.setContent(page.getRecords());
rspData.setTotalElements(page.getTotal());
return rspData;
}
public static <T> TableDataInfo<T> build(List<T> list) {
public static <T> TableDataInfo<T> build(Object list) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(String.valueOf(HttpStatus.HTTP_OK));
rspData.setMsg("操作成功");
rspData.setMessage("操作成功");
rspData.setContent(list);
rspData.setTotalElements(list.size());
rspData.setRespMsg("操作成功");
rspData.setRespCode(0);
return rspData;
}
public static <T> TableDataInfo<T> build() {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(String.valueOf(HttpStatus.HTTP_OK));
rspData.setMsg("操作成功");
rspData.setMessage("操作成功");
rspData.setRespMsg("操作成功");
rspData.setRespCode(0);
return rspData;
}
public static <T> TableDataInfo<T> buildJson(Object result) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(String.valueOf(HttpStatus.HTTP_OK));
rspData.setData(result);
rspData.setMsg("操作成功");
return rspData;
}
}

View File

@@ -31,7 +31,7 @@ import static org.springframework.http.HttpStatus.BAD_REQUEST;
@Getter
public class BadRequestException extends RuntimeException{
private Integer status = BAD_REQUEST.value();
private String code = "400";
public BadRequestException(String msg){
super(msg);
@@ -40,6 +40,6 @@ public class BadRequestException extends RuntimeException{
public BadRequestException(HttpStatus status,String msg){
super(msg);
this.status = status.value();
this.code = String.valueOf(status.value());
}
}

View File

@@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.ArrayList;
/**
* @author Zheng Jie
@@ -27,9 +28,26 @@ import java.time.LocalDateTime;
@Data
class ApiError {
private Integer status = 400;
/**
* 总记录数
*/
private long totalElements = 0;
/**
* 列表数据
*/
private Object content = new ArrayList<>();
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime timestamp;
/**
* 消息状态码
*/
private String code;
private Integer respCode;
private String respMsg;
/**
* 消息内容
*/
private String message;
private ApiError() {
@@ -38,14 +56,19 @@ class ApiError {
public static ApiError error(String message) {
ApiError apiError = new ApiError();
apiError.setCode("400");
apiError.setRespCode(1);
apiError.setMessage(message);
apiError.setRespMsg(message);
return apiError;
}
public static ApiError error(Integer status, String message) {
public static ApiError error(String status, String message) {
ApiError apiError = new ApiError();
apiError.setStatus(status);
apiError.setCode(status);
apiError.setMessage(message);
apiError.setMessage(message);
apiError.setRespMsg(message);
return apiError;
}
}

View File

@@ -58,7 +58,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(value = NotLoginException.class)
public ResponseEntity<ApiError> notLoginException(Exception e) {
log.error(ThrowableUtil.getStackTrace(e));
return buildResponseEntity(ApiError.error(401, "token 失效"));
return buildResponseEntity(ApiError.error("401", "token 失效"));
}
@@ -69,7 +69,7 @@ public class GlobalExceptionHandler {
public ResponseEntity<ApiError> badRequestException(BadRequestException e) {
// 打印堆栈信息
log.error(ThrowableUtil.getStackTrace(e));
return buildResponseEntity(ApiError.error(e.getStatus(), e.getMessage()));
return buildResponseEntity(ApiError.error(e.getCode(), e.getMessage()));
}
/**
@@ -89,7 +89,7 @@ public class GlobalExceptionHandler {
public ResponseEntity<ApiError> entityNotFoundException(EntityNotFoundException e) {
// 打印堆栈信息
log.error(ThrowableUtil.getStackTrace(e));
return buildResponseEntity(ApiError.error(NOT_FOUND.value(), e.getMessage()));
return buildResponseEntity(ApiError.error("404", e.getMessage()));
}
/**
@@ -112,6 +112,6 @@ public class GlobalExceptionHandler {
* 统一返回
*/
private ResponseEntity<ApiError> buildResponseEntity(ApiError apiError) {
return new ResponseEntity<>(apiError, HttpStatus.valueOf(apiError.getStatus()));
return new ResponseEntity<>(apiError, HttpStatus.OK);
}
}

View File

@@ -31,6 +31,6 @@ public class GateWayController {
@SaIgnore
@Log("外层服务请求wms")
public ResponseEntity<Object> apply(@RequestBody InteracteDto form) {
return new ResponseEntity<>(TableDataInfo.buildJson(gateWayService.apply(form)),HttpStatus.OK);
return new ResponseEntity<>(TableDataInfo.build(gateWayService.apply(form)),HttpStatus.OK);
}
}

View File

@@ -0,0 +1,64 @@
package org.nl.wms.ext_manage.api;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder;
import org.nl.wms.ext_manage.enums.EXTConstant;
import org.nl.wms.ext_manage.util.AcsUtil;
import org.nl.wms.pm_manage.demand.service.dao.PmDemand;
import org.nl.wms.system_manage.enums.SysParamConstant;
import org.nl.wms.system_manage.service.param.impl.SysParamServiceImpl;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class MesApi {
@Data
public static class PmDemandCall {
private String Id;
private String ReqId;
private String CreatedOn;
private String TargetLocNo;
private Integer DeliveryMethod;
private String ContainerCode;
private String Qty;
public PmDemandCall(String id, String reqId, String createdOn, String targetLocNo, Integer deliveryMethod, String containerCode, String qty) {
Id = id;
ReqId = reqId;
CreatedOn = createdOn;
TargetLocNo = targetLocNo;
DeliveryMethod = deliveryMethod;
ContainerCode = containerCode;
Qty = qty;
}
}
public <T> ResponseEntity pmDemandCallback(List<PmDemandCall> pmDemands) {
final String param = JSON.toJSONString(pmDemands);
log.info("pmDemandCallback需求单回传参数-------------------" + param);
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.MES_URL_DEMAND_CALL).getValue();
try {
String resultMsg = HttpRequest.post(url)
.body(param)
.execute().body();
JSONObject result = JSONObject.parseObject(resultMsg);
Integer respCode = result.getInteger("ResultCode");
log.info("pmDemandCallback需求单回传参数-------------------" + result.toString());
if (respCode == null || respCode != 0) {
throw new BadRequestException("中鼎单据下推失败:" + result.getString("Message"));
}
return new ResponseEntity<>(result, HttpStatus.OK);
} catch (Exception e) {
throw new BadRequestException("中鼎单据下推失败:" + e.getMessage());
}
}
}

View File

@@ -19,9 +19,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* MES需求单同步接口
*/
@Slf4j
@RestController
@RequestMapping("api/mes/structLine")

View File

@@ -2,13 +2,20 @@ package org.nl.wms.ext_manage.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.base.TableDataInfo;
import org.nl.common.exception.BadRequestException;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.ext_manage.service.MesToWmsService;
import org.nl.wms.ext_manage.service.dto.MesTaskParams;
import org.nl.wms.pm_manage.pmreturn.service.IPmReturnService;
import org.nl.wms.pm_manage.pmreturn.service.dao.PmReturn;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnParam;
import org.nl.wms.welding_manage.service.work_order.IWorkOrderService;
import org.nl.wms.welding_manage.service.work_order.dto.WorkOrderDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -16,9 +23,10 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/mes")
@RequestMapping("/")
@Slf4j
public class MesToWmsController {
@@ -27,20 +35,47 @@ public class MesToWmsController {
@Autowired
private IWorkOrderService iWorkOrderService;
@PostMapping("/lineLackMat")
@Autowired
private IPmReturnService iPmReturnService;
@PostMapping("api/mes/lineLackMat")
@SaIgnore
public ResponseEntity task(@Valid @RequestBody MesTaskParams mesTaskParams){
mesToWmsService.task(mesTaskParams);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/subWorkOrder")
/**
* 工单同步
* @param dtos
* @return
*/
@PostMapping("app/restful/api/v3/wms/mesRequisitionSync")
@SaIgnore
public ResponseEntity subWorkOrder(@RequestBody List<WorkOrderDto.WorkOrderDataDto> dtos){
for (WorkOrderDto.WorkOrderDataDto dto : dtos) {
iWorkOrderService.insert(dto);
}
return new ResponseEntity<>(HttpStatus.OK);
}
/**
* 退料单同步
* @param dtos
* @return
*/
@PostMapping("app/restful/api/v3/wms/mesReturnSync")
@SaIgnore
@Log("新增生产退料单")
public ResponseEntity<Object> create(@Valid @RequestBody List<PmReturnParam> param) {
final List<PmReturn> pmReturns = iPmReturnService.listByIds(param.stream().map(PmReturnParam::getId).collect(Collectors.toList()));
if (!CollectionUtils.isEmpty(pmReturns)){
throw new BadRequestException("当前退料单已存在");
}
for (PmReturnParam pmReturnParam : param) {
iPmReturnService.create(pmReturnParam);
}
return new ResponseEntity<>(TableDataInfo.build(),HttpStatus.OK);
}
}

View File

@@ -57,7 +57,7 @@ public class PdaResponse<T> {
public static <T> TableDataInfo<T> build(IPage<T> page) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(String.valueOf(HttpStatus.HTTP_OK));
rspData.setMsg("查询成功");
rspData.setMessage("查询成功");
rspData.setContent(page.getRecords());
rspData.setTotalElements(page.getTotal());
return rspData;

View File

@@ -1,43 +0,0 @@
package org.nl.wms.pm_manage.demand.listenerHandler;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.nl.wms.pm_manage.demand.service.IPmDemandService;
import org.nl.wms.pm_manage.demand.service.dao.PmDemand;
import org.nl.wms.pm_manage.demand.service.enums.DemandStatus;
import org.nl.wms.pm_manage.listener.core.BaseFormListenerHandler;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component("pm_demand")
public class DemandFormListenerHandler extends BaseFormListenerHandler<DemandListenerParams> {
@Autowired
IPmDemandService iPmDemandService;
@Autowired
IPmStockReturnService iPmStockReturnService;
@Override
public void onApplicationEvent(DemandListenerParams params) {
iPmDemandService.update(new LambdaUpdateWrapper<PmDemand>()
.set(PmDemand::getAssign_qty,params.getQty())
.set(PmDemand::getStatus, DemandStatus.FINISH.getValue())
.eq(PmDemand::getId,params.getBillCode())
);
PmDemand one = iPmDemandService.getOne(new LambdaQueryWrapper<PmDemand>()
.eq(PmDemand::getId, params.getBillCode()));
if (one!=null){
final PmStockReturn stockReturn = new PmStockReturn();
stockReturn.setCreate_time(DateUtil.now());
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("调拨出库"));
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode());
stockReturn.setRequest_data(JSON.toJSONString(one));
iPmStockReturnService.save(stockReturn);
}
//需求单昨晚,执行调拨流程
}
}

View File

@@ -1,18 +0,0 @@
package org.nl.wms.pm_manage.demand.listenerHandler;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class DemandListenerParams {
private String billCode;
private BigDecimal qty;
private String materialCode;
public DemandListenerParams(String billCode, BigDecimal qty, String materialCode) {
this.billCode = billCode;
this.qty = qty;
this.materialCode = materialCode;
}
}

View File

@@ -7,12 +7,12 @@ import lombok.Getter;
@AllArgsConstructor
public enum DemandStatus {
CREATE("0","生成"),
DIS("01","分配"),
SEND("10","下发"),
RUN("20","执行"),
FINISH("80","完成"),
DIS("01","分配"),
DORETURN("50","待回传"),
RETURN_FAIL("70","回传失败"),
FINISH("80","完成"),
CANCEL("90","取消"),
;
private String value;

View File

@@ -262,7 +262,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
detailRow.put("qty_unit_id", codeToIdMap.get(demand.getSkuCode()).getQty_unit_id());
detailRow.put("qty", demand.getQty());
detailRow.put("source_bill_code", demand.getId());
detailRow.put("source_bill_type", "pm_demand");
//走调拨回传
detailRow.put("source_bill_type", "DealLLDBBillPmDeamndCallBack");
detailRow.put("source_billdtl_id", demand.getId());
detailRow.put("remark", "关联工单:" + demand.getWorkOrder());
detailRow.put("load_port", demand.getTargetArea());

View File

@@ -0,0 +1,64 @@
package org.nl.wms.pm_manage.pmreturn.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import org.nl.common.base.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.pm_manage.pmreturn.service.IPmReturnService;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnDto;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnParam;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnQuery;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;
@RestController
@RequestMapping("/api/pmReturn")
@SaIgnore
public class PmReturnController {
@Resource
private IPmReturnService pmReturnService;
@GetMapping
@Log("查询生产退料单")
public ResponseEntity<Object> queryAll(PmReturnQuery query, PageQuery page) {
return new ResponseEntity<>(TableDataInfo.build(pmReturnService.queryPage(query, page)), HttpStatus.OK);
}
@GetMapping("/{id}")
@Log("查询生产退料单详情")
public ResponseEntity<Object> getById(@PathVariable String id) {
return new ResponseEntity<>(pmReturnService.getDtoById(id), HttpStatus.OK);
}
@PostMapping
@Log("新增生产退料单")
public ResponseEntity<Object> create(@Valid @RequestBody PmReturnParam param) {
pmReturnService.create(param);
return new ResponseEntity<>(HttpStatus.OK);
}
@PutMapping
@Log("修改生产退料单")
public ResponseEntity<Object> update(@Validated @RequestBody PmReturnDto param) {
pmReturnService.update(param);
return new ResponseEntity<>(HttpStatus.OK);
}
@DeleteMapping
@Log("删除生产退料单")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
List<String> idList = Arrays.asList(ids);
pmReturnService.deleteByIds(idList);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -0,0 +1,24 @@
package org.nl.wms.pm_manage.pmreturn.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
import org.nl.wms.pm_manage.pmreturn.service.dao.PmReturn;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnDto;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnParam;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnQuery;
import java.util.List;
public interface IPmReturnService extends IService<PmReturn> {
Page<PmReturnDto> queryPage(PmReturnQuery query, PageQuery pageQuery);
PmReturnDto getDtoById(String id);
void create(PmReturnParam param);
void update(PmReturnDto param);
void deleteByIds(List<String> ids);
}

View File

@@ -0,0 +1,72 @@
package org.nl.wms.pm_manage.pmreturn.service.dao;
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 com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pm_return")
public class PmReturn extends Model<PmReturn> {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.INPUT)
private String id;
@TableField("order_code")
private String order_code;
@TableField("serial_no")
private String serial_no;
@TableField("sku_code")
private String sku_code;
@TableField("sku_name")
private String sku_name;
private BigDecimal qty;
@TableField("assign_qty")
private BigDecimal assign_qty;
private String unit;
@TableField("target_area")
private String target_area;
@TableField("container_code")
private String container_code;
@TableField("delivery_method")
private Integer delivery_method;
private String creator;
@TableField("create_time")
private String create_time;
@TableField("source_house_code")
private String source_house_code;
private Integer status;
@TableField("update_time")
private String update_time;
@TableField("update_name")
private String update_name;
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@@ -0,0 +1,14 @@
package org.nl.wms.pm_manage.pmreturn.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.nl.wms.pm_manage.pmreturn.service.dao.PmReturn;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnDto;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnQuery;
import java.util.List;
public interface PmReturnMapper extends BaseMapper<PmReturn> {
List<PmReturnDto> queryPage(@Param("query") PmReturnQuery query);
}

View File

@@ -0,0 +1,64 @@
<?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="org.nl.wms.pm_manage.pmreturn.service.dao.mapper.PmReturnMapper">
<resultMap id="PmReturnDtoMap" type="org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnDto">
<result property="id" column="id"/>
<result property="orderCode" column="order_code"/>
<result property="serialNo" column="serial_no"/>
<result property="skuCode" column="sku_code"/>
<result property="skuName" column="sku_name"/>
<result property="qty" column="qty"/>
<result property="assignQty" column="assign_qty"/>
<result property="unit" column="unit"/>
<result property="targetArea" column="target_area"/>
<result property="containerCode" column="container_code"/>
<result property="deliveryMethod" column="delivery_method"/>
<result property="creator" column="creator"/>
<result property="createTime" column="create_time"/>
<result property="sourceHouseCode" column="source_house_code"/>
<result property="status" column="status"/>
<result property="updateTime" column="update_time"/>
<result property="updateName" column="update_name"/>
</resultMap>
<select id="queryPage" resultMap="PmReturnDtoMap">
select *
from pm_return
<where>
<if test="query.blurry != null and query.blurry != ''">
and (
order_code like concat('%', #{query.blurry}, '%')
or sku_code like concat('%', #{query.blurry}, '%')
or sku_name like concat('%', #{query.blurry}, '%')
or container_code like concat('%', #{query.blurry}, '%')
)
</if>
<if test="query.orderCode != null and query.orderCode != ''">
and order_code like concat('%', #{query.orderCode}, '%')
</if>
<if test="query.skuCode != null and query.skuCode != ''">
and sku_code like concat('%', #{query.skuCode}, '%')
</if>
<if test="query.skuName != null and query.skuName != ''">
and sku_name like concat('%', #{query.skuName}, '%')
</if>
<if test="query.targetArea != null and query.targetArea != ''">
and target_area like concat('%', #{query.targetArea}, '%')
</if>
<if test="query.sourceHouseCode != null and query.sourceHouseCode != ''">
and source_house_code like concat('%', #{query.sourceHouseCode}, '%')
</if>
<if test="query.status != null">
and status = #{query.status}
</if>
<if test="query.startTime != null and query.startTime != ''">
and create_time &gt;= #{query.startTime}
</if>
<if test="query.endTime != null and query.endTime != ''">
and create_time &lt;= #{query.endTime}
</if>
</where>
order by create_time desc, update_time desc
</select>
</mapper>

View File

@@ -0,0 +1,28 @@
package org.nl.wms.pm_manage.pmreturn.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class PmReturnDto implements Serializable {
private String id;
private String orderCode;
private String serialNo;
private String skuCode;
private String skuName;
private BigDecimal qty;
private BigDecimal assignQty;
private String unit;
private String targetArea;
private String containerCode;
private Integer deliveryMethod;
private String creator;
private String createTime;
private String sourceHouseCode;
private Integer status;
private String updateTime;
private String updateName;
}

View File

@@ -0,0 +1,76 @@
package org.nl.wms.pm_manage.pmreturn.service.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Data
public class PmReturnParam {
@NotBlank(message = "单据唯一ID不能为空")
@JsonProperty(value = "id")
private String id;
@NotBlank(message = "退料单号不能为空")
@JsonProperty(value = "orderCode")
private String orderCode;
@NotBlank(message = "序号不能为空")
@JsonProperty(value = "serialNo")
private String serialNo;
@NotBlank(message = "物料编码不能为空")
@JsonProperty(value = "skuCode")
private String skuCode;
@NotBlank(message = "物料名称不能为空")
@JsonProperty(value = "skuName")
private String skuName;
@NotNull(message = "数量不能为空")
@DecimalMin(value = "0", inclusive = false, message = "数量必须大于0")
@JsonProperty(value = "qty")
private BigDecimal qty;
@JsonProperty(value = "assignQty")
private BigDecimal assignQty;
@NotBlank(message = "单位不能为空")
@JsonProperty(value = "unit")
private String unit;
@NotBlank(message = "线边库位不能为空")
@JsonProperty(value = "targetArea")
private String targetArea;
@NotBlank(message = "容器编号不能为空")
@JsonProperty(value = "containerCode")
private String containerCode;
@NotNull(message = "配送方式不能为空")
@JsonProperty(value = "deliveryMethod")
private Integer deliveryMethod;
@NotBlank(message = "操作人工号不能为空")
@JsonProperty(value = "creator")
private String creator;
@NotBlank(message = "操作时间不能为空")
@JsonProperty(value = "createTime")
private String createTime;
@NotBlank(message = "来源仓别不能为空")
@JsonProperty(value = "sourceHouseCode")
private String sourceHouseCode;
@NotNull(message = "状态不能为空")
@JsonProperty(value = "status")
private Integer status;
@JsonProperty(value = "updateName")
private String updateName;
}

View File

@@ -0,0 +1,19 @@
package org.nl.wms.pm_manage.pmreturn.service.dto;
import lombok.Data;
import org.nl.common.domain.query.BaseQuery;
import org.nl.wms.pm_manage.pmreturn.service.dao.PmReturn;
@Data
public class PmReturnQuery extends BaseQuery<PmReturn> {
private String blurry;
private String orderCode;
private String skuCode;
private String skuName;
private String targetArea;
private String sourceHouseCode;
private Integer status;
private String startTime;
private String endTime;
}

View File

@@ -0,0 +1,129 @@
package org.nl.wms.pm_manage.pmreturn.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.pm_manage.pmreturn.service.IPmReturnService;
import org.nl.wms.pm_manage.pmreturn.service.dao.PmReturn;
import org.nl.wms.pm_manage.pmreturn.service.dao.mapper.PmReturnMapper;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnDto;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnParam;
import org.nl.wms.pm_manage.pmreturn.service.dto.PmReturnQuery;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.List;
import static org.nl.common.domain.query.PageQuery.trimStringFields;
@Service
public class PmReturnServiceImpl extends ServiceImpl<PmReturnMapper, PmReturn> implements IPmReturnService {
@Override
public Page<PmReturnDto> queryPage(PmReturnQuery query, PageQuery pageQuery) {
trimStringFields(query);
com.github.pagehelper.Page<Object> page = PageHelper.startPage(pageQuery.getPage() + 1, pageQuery.getSize());
page.setOrderBy("create_time desc, update_time desc");
List<PmReturnDto> records = this.baseMapper.queryPage(query);
Page<PmReturnDto> dtoPage = new Page<>(page.getPageNum(), page.getPageSize(), page.getTotal());
dtoPage.setRecords(records);
return dtoPage;
}
@Override
public PmReturnDto getDtoById(String id) {
PmReturn entity = this.getById(id);
if (entity == null) {
throw new BadRequestException("生产退料单不存在");
}
return toDto(entity);
}
@Override
public void create(PmReturnParam param) {
PmReturn entity = new PmReturn();
entity.setId(param.getId());
entity.setOrder_code(param.getOrderCode());
entity.setSerial_no(param.getSerialNo());
entity.setSku_code(param.getSkuCode());
entity.setSku_name(param.getSkuName());
entity.setQty(param.getQty());
entity.setAssign_qty(defaultAssignQty(param.getAssignQty()));
entity.setUnit(param.getUnit());
entity.setTarget_area(param.getTargetArea());
entity.setContainer_code(param.getContainerCode());
entity.setDelivery_method(param.getDeliveryMethod());
entity.setCreator(param.getCreator());
entity.setCreate_time(param.getCreateTime());
entity.setSource_house_code(param.getSourceHouseCode());
entity.setStatus(param.getStatus());
entity.setUpdate_name(param.getUpdateName());
entity.setUpdate_time(DateUtil.now());
this.save(entity);
}
@Override
public void update(PmReturnDto param) {
PmReturn dbEntity = this.getById(param.getId());
if (dbEntity == null) {
throw new BadRequestException("生产退料单不存在");
}
PmReturn entity = new PmReturn();
entity.setId(param.getId());
entity.setOrder_code(param.getOrderCode());
entity.setSerial_no(param.getSerialNo());
entity.setSku_code(param.getSkuCode());
entity.setSku_name(param.getSkuName());
entity.setQty(param.getQty());
entity.setAssign_qty(defaultAssignQty(param.getAssignQty()));
entity.setUnit(param.getUnit());
entity.setTarget_area(param.getTargetArea());
entity.setContainer_code(param.getContainerCode());
entity.setDelivery_method(param.getDeliveryMethod());
entity.setCreator(param.getCreator());
entity.setCreate_time(param.getCreateTime());
entity.setSource_house_code(param.getSourceHouseCode());
entity.setStatus(param.getStatus());
entity.setUpdate_name(param.getUpdateName());
entity.setUpdate_time(DateUtil.now());
this.updateById(entity);
}
@Override
public void deleteByIds(List<String> ids) {
if (CollectionUtils.isEmpty(ids)) {
return;
}
this.removeByIds(ids);
}
private BigDecimal defaultAssignQty(BigDecimal assignQty) {
return assignQty == null ? BigDecimal.ZERO : assignQty;
}
private PmReturnDto toDto(PmReturn entity) {
PmReturnDto dto = new PmReturnDto();
dto.setId(entity.getId());
dto.setOrderCode(entity.getOrder_code());
dto.setSerialNo(entity.getSerial_no());
dto.setSkuCode(entity.getSku_code());
dto.setSkuName(entity.getSku_name());
dto.setQty(entity.getQty());
dto.setAssignQty(entity.getAssign_qty());
dto.setUnit(entity.getUnit());
dto.setTargetArea(entity.getTarget_area());
dto.setContainerCode(entity.getContainer_code());
dto.setDeliveryMethod(entity.getDelivery_method());
dto.setCreator(entity.getCreator());
dto.setCreateTime(entity.getCreate_time());
dto.setSourceHouseCode(entity.getSource_house_code());
dto.setStatus(entity.getStatus());
dto.setUpdateTime(entity.getUpdate_time());
dto.setUpdateName(entity.getUpdate_name());
return dto;
}
}

View File

@@ -1,30 +0,0 @@
package org.nl.wms.pm_manage.preceiving.listenerHandler;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import org.nl.wms.pm_manage.demand.service.IPmDemandService;
import org.nl.wms.pm_manage.listener.core.BaseFormListenerHandler;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component("p_receiving")
public class PReceivingListenerHandler extends BaseFormListenerHandler<PReceivingParams> {
@Autowired
IPmDemandService iPmDemandService;
@Autowired
IPmStockReturnService iPmStockReturnService;
@Override
public void onApplicationEvent(PReceivingParams params) {
final PmStockReturn stockReturn = new PmStockReturn();
stockReturn.setCreate_time(DateUtil.now());
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("生产入库"));
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode());
stockReturn.setRequest_data(JSON.toJSONString(params));
iPmStockReturnService.save(stockReturn);
//需求单昨晚,执行调拨流程
}
}

View File

@@ -1,19 +0,0 @@
package org.nl.wms.pm_manage.preceiving.listenerHandler;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Map;
@Data
public class PReceivingParams {
private String billCode;
private String sectCode;
private Map<String,BigDecimal> materialQty;
public PReceivingParams(String billCode, Map materialQty,String sectCode) {
this.billCode = billCode;
this.materialQty = materialQty;
this.sectCode = sectCode;
}
}

View File

@@ -20,10 +20,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.*;
/**
* @author Liuxy
@@ -101,6 +98,19 @@ public class SchBasePointController {
result.add(parent);
return new ResponseEntity<>(TableDataInfo.build(result), HttpStatus.OK);
}
@GetMapping("/getRegionPointSet")
@Log("获取区域下拉点")
public ResponseEntity<Object> getRegionPointSet(String regionCode) {
List<SchBasePoint> points = schBasePointService.list(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getRegion_code, regionCode)
.eq(SchBasePoint::getIs_used, Boolean.TRUE)
.isNull(SchBasePoint::getVehicle_code));
List<Map> result = new ArrayList<>();
for (SchBasePoint point : points) {
result.add(MapOf.of("value",point.getVehicle_code(),"label",point.getVehicle_code()));
}
return new ResponseEntity<>(TableDataInfo.build(result), HttpStatus.OK);
}
@Log("锁定与解锁")
@PostMapping("/changeLock")

View File

@@ -75,7 +75,7 @@ public class MobileAuthorizationController {
result.put("token", StpUtil.getTokenValue());
result.put("roles", permissionList);
result.put("user", user);
return new ResponseEntity<>(TableDataInfo.buildJson(result), HttpStatus.OK);
return new ResponseEntity<>(TableDataInfo.build(result), HttpStatus.OK);
}

View File

@@ -32,6 +32,7 @@ public class SysParamConstant {
* MES URL
*/
public final static String MES_URL = "mes_url";
public final static String MES_URL_DEMAND_CALL = "MES_URL_DEMAND_CALL";
/**
* 打印机ip
*/

View File

@@ -28,7 +28,7 @@ public enum IOSEnum {
BILL_STATUS(MapOf.of("生成","10", "分配中", "20", "分配完", "30", "完成", "99")),
// 入库业务类型
BILL_TYPE(MapOf.of("生产入库","0001", "采购入库", "0005","生产领料", "0006","库存调拨", "0007", "手工入库", "0009","销售出库","1001","生产出库","1005","调拨出库","1004", "手工出库", "1009")),
BILL_TYPE(MapOf.of("生产入库","0001", "采购入库", "0005","生产领料", "0006","库存调拨", "0007", "手工入库", "0009","销售出库","1001","生产出库","1005","调拨出库","1004", "手工出库", "1009","库存调拨", "2001")),
//入库分配明细状态
INBILL_DIS_STATUS(MapOf.of("未生成", "00", "生成", "01", "执行中", "02", "完成", "99")),

View File

@@ -939,8 +939,8 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
@Transactional
public void allSetPoint(JSONObject whereJson) {
//出库点
if (StrUtil.isBlank(whereJson.getString("region_code"))){
throw new BadRequestException("未选择出库");
if (StrUtil.isBlank(whereJson.getString("point_code"))){
throw new BadRequestException("未选择出库");
}
String pointCode = whereJson.getString("point_code");
//----根据区域找点,特殊业务比如找空点位在这边----

View File

@@ -0,0 +1,108 @@
package org.nl.wms.warehouse_manage.stockReturn.strategy.core.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.MapOf;
import org.nl.wms.ext_manage.api.MesApi;
import org.nl.wms.pm_manage.demand.service.IPmDemandService;
import org.nl.wms.pm_manage.demand.service.dao.PmDemand;
import org.nl.wms.pm_manage.demand.service.enums.DemandStatus;
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDtl;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDisMapper;
import org.nl.wms.warehouse_manage.inAndOut.service.dto.IOStorInvDisDto;
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
import org.nl.wms.warehouse_manage.stockReturn.strategy.core.CallbackStrategy;
import org.nl.wms.welding_manage.service.work_order.IWorkOrderService;
import org.nl.wms.welding_manage.service.work_order.dao.WorkOrderDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* 需求单库存调拨回传
*/
@Service(value = "DealLLDBBillPmDeamndCallBack")
public class DealLLDBBillPmDeamndCallBack implements CallbackStrategy {
@Autowired
private IPmDemandService iPmDemandService;
@Autowired
private IPmStockReturnService iPmStockReturnService;
@Resource
private IOStorInvDisMapper ioStorInvDisMapper;
@Autowired
private ISchBaseRegionService iSchBaseRegionService;
@Autowired
private MesApi mesApi;
@Override
public void buildCallback(IOStorInvDtl param) {
final String orderCode = param.getSource_bill_code();
PmDemand one = iPmDemandService.getOne(new LambdaQueryWrapper<PmDemand>().eq(PmDemand::getId, orderCode));
if (one == null){
throw new BadRequestException("需求单不存在");
}
final SchBaseRegion region = iSchBaseRegionService.getOne(new LambdaQueryWrapper<SchBaseRegion>()
.eq(SchBaseRegion::getRegion_code, one.getProduction_line())
.select(SchBaseRegion::getPoint_type_explain));
if (region==null){
throw new BadRequestException("当前产线未配置对应仓库编码getPoint_type_explain");
}
final String now = DateUtil.now();
JSONObject callbackData = new JSONObject();
callbackData.put("method", "DealLLDBBill");
callbackData.put("type", "WMS");
// 组装data节点
JSONObject data = new JSONObject();
data.put("issueStorageOrgUnitNo", "01.09.14"); // 业务状态,可根据实际业务逻辑设置
data.put("bizTypeNo", 311); // 业务日期
data.put("receiptStorageOrgUnitNo", "01.09.14"); // 创建人编号,从当前登录用户获取
data.put("billNo", param.getIostorinv_id()); // 使用工单编号作为MES单号
// 组装明细列表
JSONArray entrys = new JSONArray();
final List<IOStorInvDisDto> disSet = ioStorInvDisMapper.queryOutBillDisDtl(MapOf.of("iostorinvdtl_id", param.getIostorinvdtl_id()));
for (IOStorInvDisDto ioStorInvDisDto : disSet) {
JSONObject entry = new JSONObject();
entry.put("unitNo", "PCS"); // 序号
entry.put("qty", ioStorInvDisDto.getPlan_qty()); // 数量
entry.put("materialNo", ioStorInvDisDto.getMaterial_code()); // 来源单据标识
entry.put("issueWarehouseNo", region.getPoint_type_explain());
entry.put("receiptWarehouseNo", ioStorInvDisDto.getSect_code());
entrys.add(entry);
}
data.put("entrys", entrys);
callbackData.put("data", data);
PmStockReturn stockReturn = new PmStockReturn();
stockReturn.setRequest_Id(one.getId());
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
stockReturn.setCreate_time(now);
stockReturn.setRequest_data(callbackData.toString());
//回传MES
mesApi.pmDemandCallback(Arrays.asList(new MesApi.PmDemandCall(
param.getIostorinv_id(),one.getId()
,now,one.getTarget_area()
,1
,disSet.get(0).getStoragevehicle_code(),
param.getAssign_qty().toString())));
iPmStockReturnService.save(stockReturn);
one.setAssign_qty(param.getAssign_qty());
one.setStatus(DemandStatus.FINISH.getValue());
this.iPmDemandService.updateById(one);
}
}

View File

@@ -58,3 +58,25 @@ ADD COLUMN `source_load_port` varchar(255) NULL COMMENT '来源单指定上料
ALTER TABLE `st_ivt_iostorinvdtl`
ADD COLUMN `callback_strategy` varchar(64) NULL COMMENT '单据回传策略配置类名' AFTER `source_load_port`;
CREATE TABLE `pm_return` (
`id` VARCHAR(64) NOT NULL COMMENT '唯一ID必填',
`order_code` VARCHAR(64) DEFAULT NULL COMMENT '退料单号',
`serial_no` VARCHAR(50) NOT NULL COMMENT '序号(必填)',
`sku_code` VARCHAR(50) NOT NULL COMMENT '物料编码(必填)',
`sku_name` VARCHAR(200) NOT NULL COMMENT '物料名称(必填)',
`qty` DECIMAL(9, 3) NOT NULL DEFAULT 0.000000 COMMENT '数量(必填)',
`assign_qty` DECIMAL(9, 3) DEFAULT 0.000000 COMMENT '已分配数量',
`unit` VARCHAR(20) NOT NULL COMMENT '单位(必填)',
`target_area` VARCHAR(50) NOT NULL COMMENT '线边库位(必填)',
`container_code` VARCHAR(50) NOT NULL COMMENT '容器编号(必填)',
`delivery_method` TINYINT(4) NOT NULL DEFAULT 1 COMMENT '配送方式必填1:人工2:AGV',
`creator` VARCHAR(50) NOT NULL COMMENT '操作人工号(必填)',
`create_time` DATETIME NOT NULL COMMENT '操作时间必填格式yyyy-MM-dd HH:mm:ss',
`source_house_code` VARCHAR(50) NOT NULL COMMENT '来源仓别(必填)',
`status` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '状态必填0生成1失效,20执行80完成',
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '系统更新时间',
`update_name` VARCHAR(50) DEFAULT NULL COMMENT '系统更新人',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='生产退料单表';