MES:接口扫描物料确认使用
WMS:PDA接口合库功能,PDA接口成品出库最终确认功能,车间接口一楼成品入库和四楼成品入库功能
master
xins 7 months ago
parent 05467aed61
commit f714ca4bad

@ -75,4 +75,7 @@ public class MesConstants {
/** 附件类别9-其他文件 */
public static final String MES_ATTACH_TYPE_OTHER = "9";
/**校验类型(0不校验,1人工校验,2自动校验)*/
public static final String MES_MATERIAL_BOM_CHECK_TYPE_MANUAL = "1";//人工校验
}

@ -70,6 +70,7 @@ public class WmsConstants {
public static final String WMS_EXECUTE_STATUS_EXECUTING = "1";//执行中
public static final String WMS_EXECUTE_STATUS_FINISH = "2";//完成执行
public static final String WMS_EXECUTE_STATUS_CONFIRM = "3";//已确认(适合成品出库在一楼最终确认使用)
public static final String WMS_EXECUTE_STATUS_NOT_FINISH = "notFinish";//未完成执行

@ -10,6 +10,7 @@ import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.domain.MesMaterialBom;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.domain.MesProductPlanDetail;
import com.hw.mes.domain.vo.MesMaterialScanVo;
import com.hw.mes.domain.vo.MesProductPlanDetailAttachVo;
import com.hw.mes.domain.vo.MesProductPlanDetailCompleteAttachVo;
import com.hw.mes.domain.vo.MesProductPlanDetailVo;
@ -135,7 +136,7 @@ public class MesApiController extends BaseController {
/**
*
*
* planId
*/
@Log(title = "生产计划明细", businessType = BusinessType.START)
@ -166,4 +167,13 @@ public class MesApiController extends BaseController {
return success(productPlanService.getDrawings(queryProductPlan));
}
/**
* 使
*/
@Log(title = "生产计划明细", businessType = BusinessType.CONFIRM)
@PostMapping(("/scanMaterial2Confirm"))
public AjaxResult scanMaterial2Confirm(@RequestBody MesMaterialScanVo mesMaterialScanVo) {
return success(productPlanService.scanMaterial2Confirm(mesMaterialScanVo));
}
}

@ -8,7 +8,7 @@ import com.hw.common.core.web.domain.BaseEntity;
/**
* mes_material_check_result
*
*
* @author xins
* @date 2024-02-21
*/
@ -39,61 +39,74 @@ public class MesMaterialCheckResult extends BaseEntity
@Excel(name = "检验数量")
private BigDecimal checkAmount;
public void setMaterialCheckResultId(Long materialCheckResultId)
/**
* (0,1,2)
*/
private String checkType;
public void setMaterialCheckResultId(Long materialCheckResultId)
{
this.materialCheckResultId = materialCheckResultId;
}
public Long getMaterialCheckResultId()
public Long getMaterialCheckResultId()
{
return materialCheckResultId;
}
public void setPlanId(Long planId)
public void setPlanId(Long planId)
{
this.planId = planId;
}
public Long getPlanId()
public Long getPlanId()
{
return planId;
}
public void setPlanDetailId(Long planDetailId)
public void setPlanDetailId(Long planDetailId)
{
this.planDetailId = planDetailId;
}
public Long getPlanDetailId()
public Long getPlanDetailId()
{
return planDetailId;
}
public void setMaterialId(Long materialId)
public void setMaterialId(Long materialId)
{
this.materialId = materialId;
}
public Long getMaterialId()
public Long getMaterialId()
{
return materialId;
}
public void setStandardAmount(BigDecimal standardAmount)
public void setStandardAmount(BigDecimal standardAmount)
{
this.standardAmount = standardAmount;
}
public BigDecimal getStandardAmount()
public BigDecimal getStandardAmount()
{
return standardAmount;
}
public void setCheckAmount(BigDecimal checkAmount)
public void setCheckAmount(BigDecimal checkAmount)
{
this.checkAmount = checkAmount;
}
public BigDecimal getCheckAmount()
public BigDecimal getCheckAmount()
{
return checkAmount;
}
public String getCheckType() {
return checkType;
}
public void setCheckType(String checkType) {
this.checkType = checkType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -0,0 +1,94 @@
package com.hw.mes.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.hw.common.core.annotation.Excel;
import com.hw.common.core.web.domain.BaseEntity;
/**
* mes_material_check_result_detail
*
* @author xins
* @date 2024-04-07
*/
public class MesMaterialCheckResultDetail extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键标识 */
private Long checkResultDetailId;
/** 生产计划明细校验信息ID */
@Excel(name = "生产计划明细校验信息ID")
private Long materialCheckResultId;
/** 物料条码 */
@Excel(name = "物料条码")
private String materialBarcode;
/** 批次码 */
@Excel(name = "批次码")
private String batchCode;
/** 检验数量 */
@Excel(name = "检验数量")
private BigDecimal checkAmount;
public void setCheckResultDetailId(Long checkResultDetailId)
{
this.checkResultDetailId = checkResultDetailId;
}
public Long getCheckResultDetailId()
{
return checkResultDetailId;
}
public void setMaterialCheckResultId(Long materialCheckResultId)
{
this.materialCheckResultId = materialCheckResultId;
}
public Long getMaterialCheckResultId()
{
return materialCheckResultId;
}
public void setMaterialBarcode(String materialBarcode)
{
this.materialBarcode = materialBarcode;
}
public String getMaterialBarcode()
{
return materialBarcode;
}
public void setBatchCode(String batchCode)
{
this.batchCode = batchCode;
}
public String getBatchCode()
{
return batchCode;
}
public void setCheckAmount(BigDecimal checkAmount)
{
this.checkAmount = checkAmount;
}
public BigDecimal getCheckAmount()
{
return checkAmount;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("checkResultDetailId", getCheckResultDetailId())
.append("materialCheckResultId", getMaterialCheckResultId())
.append("materialBarcode", getMaterialBarcode())
.append("batchCode", getBatchCode())
.append("checkAmount", getCheckAmount())
.toString();
}
}

@ -0,0 +1,35 @@
package com.hw.mes.domain.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* @Description: VO
* @ClassName: MesMaterialScanVo
* @Author : xins
* @Date :2024-04-07 10:17
* @Version :1.0
*/
@Data
public class MesMaterialScanVo {
//生产计划ID
@NotNull(message = "生产计划ID必须输入")
private Long planId;
//生产计划明细ID
@NotNull(message = "生产计划明细ID必须输入")
private Long planDetailId;
//物料条码
@NotBlank(message = "物料条码必须输入")
private String materialBarcode;
//数量
@NotNull(message = "数量必须输入")
private BigDecimal checkAmount;
}

@ -0,0 +1,61 @@
package com.hw.mes.mapper;
import java.util.List;
import com.hw.mes.domain.MesMaterialCheckResultDetail;
/**
* Mapper
*
* @author xins
* @date 2024-04-07
*/
public interface MesMaterialCheckResultDetailMapper
{
/**
*
*
* @param checkResultDetailId
* @return
*/
public MesMaterialCheckResultDetail selectMesMaterialCheckResultDetailByCheckResultDetailId(Long checkResultDetailId);
/**
*
*
* @param mesMaterialCheckResultDetail
* @return
*/
public List<MesMaterialCheckResultDetail> selectMesMaterialCheckResultDetailList(MesMaterialCheckResultDetail mesMaterialCheckResultDetail);
/**
*
*
* @param mesMaterialCheckResultDetail
* @return
*/
public int insertMesMaterialCheckResultDetail(MesMaterialCheckResultDetail mesMaterialCheckResultDetail);
/**
*
*
* @param mesMaterialCheckResultDetail
* @return
*/
public int updateMesMaterialCheckResultDetail(MesMaterialCheckResultDetail mesMaterialCheckResultDetail);
/**
*
*
* @param checkResultDetailId
* @return
*/
public int deleteMesMaterialCheckResultDetailByCheckResultDetailId(Long checkResultDetailId);
/**
*
*
* @param checkResultDetailIds
* @return
*/
public int deleteMesMaterialCheckResultDetailByCheckResultDetailIds(Long[] checkResultDetailIds);
}

@ -1,19 +1,20 @@
package com.hw.mes.mapper;
import java.util.List;
import com.hw.mes.domain.MesMaterialCheckResult;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
*
*
* @author xins
* @date 2024-02-21
*/
public interface MesMaterialCheckResultMapper
{
public interface MesMaterialCheckResultMapper {
/**
*
*
*
* @param materialCheckResultId
* @return
*/
@ -21,7 +22,7 @@ public interface MesMaterialCheckResultMapper
/**
*
*
*
* @param mesMaterialCheckResult
* @return
*/
@ -29,7 +30,7 @@ public interface MesMaterialCheckResultMapper
/**
*
*
*
* @param mesMaterialCheckResult
* @return
*/
@ -37,7 +38,7 @@ public interface MesMaterialCheckResultMapper
/**
*
*
*
* @param mesMaterialCheckResult
* @return
*/
@ -45,7 +46,7 @@ public interface MesMaterialCheckResultMapper
/**
*
*
*
* @param materialCheckResultId
* @return
*/
@ -53,9 +54,35 @@ public interface MesMaterialCheckResultMapper
/**
*
*
*
* @param materialCheckResultIds
* @return
*/
public int deleteMesMaterialCheckResultByMaterialCheckResultIds(Long[] materialCheckResultIds);
/**
*
*
* @param planId
* @param planDetailId
* @param materialId
* @return
*/
public MesMaterialCheckResult selectMesMaterialCheckResultByUI(@Param("planId") Long planId,
@Param("planDetailId") Long planDetailId,
@Param("materialId") Long materialId);
/**
*
* @param planId
* @param planDetailId
* @param ancestors
* @return
*/
public List<MesMaterialCheckResult> selectMesMaterialCheckResult(@Param("planId") Long planId,
@Param("planDetailId") Long planDetailId,
@Param("ancestors") String ancestors);
}

@ -5,6 +5,8 @@ import java.util.List;
import com.hw.mes.domain.MesBaseAttachInfo;
import com.hw.mes.domain.MesProductOrder;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.domain.vo.MesMaterialScanVo;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
@ -111,4 +113,12 @@ public interface IMesProductPlanService
*/
public List<MesBaseAttachInfo> getDrawings(MesProductPlan mesProductPlan);
/**
* 使
*
* @param mesMaterialScanVo
* @return
*/
public int scanMaterial2Confirm(MesMaterialScanVo mesMaterialScanVo);
}

@ -5,9 +5,12 @@ import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.uuid.Seq;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.domain.MesMaterialCheckResult;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.domain.MesProductPlanDetail;
import com.hw.mes.domain.vo.MesProductPlanDetailVo;
import com.hw.mes.mapper.MesMaterialBomMapper;
import com.hw.mes.mapper.MesMaterialCheckResultMapper;
import com.hw.mes.mapper.MesProductPlanDetailMapper;
import com.hw.mes.mapper.MesProductPlanMapper;
import com.hw.mes.service.IMesProductPlanDetailService;
@ -19,6 +22,7 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* Service
@ -34,6 +38,9 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
@Autowired
private MesProductPlanMapper mesProductPlanMapper;
@Autowired
private MesMaterialCheckResultMapper mesMaterialCheckResultMapper;
/**
*
*
@ -199,7 +206,9 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
@Override
@Transactional(rollbackFor = Exception.class)
public int completeMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
MesProductPlanDetail dbProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailId(mesProductPlanDetail.getPlanDetailId());
Long planDetailId = mesProductPlanDetail.getPlanDetailId();
MesProductPlanDetail dbProductPlanDetail = mesProductPlanDetailMapper.
selectMesProductPlanDetailByPlanDetailId(planDetailId);
String planDetailStatus = dbProductPlanDetail.getPlanDetailStatus();
if (planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_TO_START)) {
throw new ServiceException("此生产计划明细未开始");
@ -207,7 +216,8 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
throw new ServiceException("此生产计划明细已结束");
}
MesProductPlan dbProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(dbProductPlanDetail.getPlanId());
Long planId = dbProductPlanDetail.getPlanId();
MesProductPlan dbProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(planId);
String planStatus = dbProductPlan.getPlanStatus();
if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH)) {
throw new ServiceException("此生产计划未派工,不能结束");
@ -215,7 +225,19 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
throw new ServiceException("此生产计划已结束");
}
//todo校验生产计划明细校验信息 更新生产工单状态、结束时间和完成数量(需要获取所有生产计划,顺序工单是否都已完成等)
//校验生产计划明细校验信息(如果是多个工序只校验最后一个工序,一楼和四楼都是一个工序,暂时不校验最后一个工序),
List<MesMaterialCheckResult> checkResults =
mesMaterialCheckResultMapper.selectMesMaterialCheckResult(planId, planDetailId, "0," + dbProductPlan.getMaterialBomId());
List<MesMaterialCheckResult> filterCheckResults = checkResults.stream().filter(
materialCheckResult -> (materialCheckResult.getCheckAmount() == null ||
!materialCheckResult.getCheckAmount().equals(materialCheckResult.getStandardAmount()))
&& materialCheckResult.getCheckType().equals(MesConstants.MES_MATERIAL_BOM_CHECK_TYPE_MANUAL))
.collect(Collectors.toList());
String updatePlanDetailStatus = MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH;
if (filterCheckResults != null && !filterCheckResults.isEmpty()) {
updatePlanDetailStatus = MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_ABNORMAL_FINISH;
}
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
BigDecimal planAmount = null;
@ -233,6 +255,9 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
if (newComplementAmount.compareTo(planAmount) >= 0) {
dbProductPlan.setPlanStatus(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH);
dbProductPlan.setRealEndTime(currentDate);
//todo更新生产工单状态、结束时间和完成数量根据finalprocessFlag更新生产工单
}
dbProductPlan.setCompleteAmount(newComplementAmount);
dbProductPlan.setUpdateTime(currentDate);
@ -241,7 +266,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
mesProductPlanDetail.setUpdateTime(currentDate);
mesProductPlanDetail.setUpdateBy(userName);
mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH);
mesProductPlanDetail.setPlanDetailStatus(updatePlanDetailStatus);
mesProductPlanDetail.setRealEndTime(currentDate);
return mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail);
}

@ -1,6 +1,8 @@
package com.hw.mes.service.impl;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import com.hw.common.core.constant.MesConstants;
@ -8,10 +10,10 @@ import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.uuid.Seq;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.domain.MesBaseAttachInfo;
import com.hw.mes.domain.MesProductOrder;
import com.hw.mes.mapper.MesBaseAttachInfoMapper;
import com.hw.mes.mapper.MesProductPlanDetailMapper;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.mes.domain.*;
import com.hw.mes.domain.vo.MesMaterialScanVo;
import com.hw.mes.mapper.*;
import com.hw.mes.service.IMesBaseAttachInfoService;
import com.hw.mes.service.IMesProductOrderService;
import org.springframework.beans.factory.annotation.Autowired;
@ -21,9 +23,6 @@ import java.util.ArrayList;
import com.hw.common.core.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.hw.mes.domain.MesProductPlanDetail;
import com.hw.mes.mapper.MesProductPlanMapper;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.service.IMesProductPlanService;
/**
@ -49,6 +48,15 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
@Autowired
private MesProductPlanDetailMapper productPlanDetailMapper;
@Autowired
private MesMaterialCheckResultMapper mesMaterialCheckResultMapper;
@Autowired
private MesMaterialCheckResultDetailMapper mesMaterialCheckResultDetailMapper;
@Autowired
private MesBaseBarcodeInfoMapper mesBaseBarcodeInfoMapper;
/**
*
*
@ -286,4 +294,74 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
return null;
}
/**
* 使
*
* @param mesMaterialScanVo
* @return
*/
@Transactional
@Override
public int scanMaterial2Confirm(MesMaterialScanVo mesMaterialScanVo) {
Long planId = mesMaterialScanVo.getPlanId();
Long planDetailId = mesMaterialScanVo.getPlanDetailId();
BigDecimal checkAmount = mesMaterialScanVo.getCheckAmount();
String materialBarcode = mesMaterialScanVo.getMaterialBarcode();
if (checkAmount.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("数量需大于0");
}
MesMaterialCheckResultDetail queryCheckResultDetail = new MesMaterialCheckResultDetail();
queryCheckResultDetail.setMaterialBarcode(materialBarcode);
List<MesMaterialCheckResultDetail> checkResultDetailList = mesMaterialCheckResultDetailMapper.selectMesMaterialCheckResultDetailList(queryCheckResultDetail);
if (checkResultDetailList != null && !checkResultDetailList.isEmpty()) {
throw new ServiceException("此物料已经验证过,无需重复验证");
}
MesBaseBarcodeInfo baseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(materialBarcode);
if (baseBarcodeInfo == null) {
throw new ServiceException("物料条码有误");
}
Long materialId = baseBarcodeInfo.getMaterialId();
String batchFlag = baseBarcodeInfo.getBatchFlag();
String batchCode = baseBarcodeInfo.getBatchCode();
if (!batchFlag.equals(MesConstants.IS_BATCH)) {
if (checkAmount.compareTo(BigDecimal.ONE) != 0) {
throw new ServiceException("数量需等于1");
}
}
String userName = SecurityUtils.getUsername();
Date currentDate = new Date();
MesMaterialCheckResult mesMaterialCheckResult = mesMaterialCheckResultMapper.
selectMesMaterialCheckResultByUI(planId, planDetailId, materialId);
if (mesMaterialCheckResult == null) {
mesMaterialCheckResult = new MesMaterialCheckResult();
mesMaterialCheckResult.setPlanId(planId);
mesMaterialCheckResult.setPlanDetailId(planDetailId);
mesMaterialCheckResult.setMaterialId(materialId);
mesMaterialCheckResult.setCheckAmount(checkAmount);
mesMaterialCheckResult.setUpdateBy(userName);
mesMaterialCheckResult.setUpdateTime(currentDate);
mesMaterialCheckResultMapper.insertMesMaterialCheckResult(mesMaterialCheckResult);
} else {
mesMaterialCheckResult.setCheckAmount(mesMaterialCheckResult.getCheckAmount()
.add(checkAmount));
mesMaterialCheckResult.setUpdateBy(userName);
mesMaterialCheckResult.setUpdateTime(currentDate);
mesMaterialCheckResultMapper.updateMesMaterialCheckResult(mesMaterialCheckResult);
}
MesMaterialCheckResultDetail mesMaterialCheckResultDetail = new MesMaterialCheckResultDetail();
mesMaterialCheckResultDetail.setMaterialCheckResultId(mesMaterialCheckResult.getMaterialCheckResultId());
mesMaterialCheckResultDetail.setMaterialBarcode(materialBarcode);
mesMaterialCheckResultDetail.setBatchCode(batchCode);
mesMaterialCheckResultDetail.setCheckAmount(checkAmount);
mesMaterialCheckResultDetailMapper.insertMesMaterialCheckResultDetail(mesMaterialCheckResultDetail);
return 1;
}
}

@ -14,6 +14,7 @@
<result property="barcodeInfo" column="barcode_info"/>
<result property="batchCode" column="batch_code"/>
<result property="palletInfoCode" column="pallet_info_code"/>
<result property="bindBarcode" column="bind_barcode"/>
<result property="materialId" column="material_id"/>
<result property="manufacturerId" column="manufacturer_id"/>
<result property="amount" column="amount"/>
@ -47,6 +48,7 @@
bbi.barcode_info,
bbi.batch_code,
bbi.pallet_info_code,
bbi.bind_barcode,
bbi.material_id,
bmi.material_name,
bbi.manufacturer_id,
@ -235,4 +237,4 @@
<include refid="selectMesBaseBarcodeInfoVo"/>
where bbi.barcode_info = #{barcodeInfo} limit 1
</select>
</mapper>
</mapper>

@ -0,0 +1,71 @@
<?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.hw.mes.mapper.MesMaterialCheckResultDetailMapper">
<resultMap type="MesMaterialCheckResultDetail" id="MesMaterialCheckResultDetailResult">
<result property="checkResultDetailId" column="check_result_detail_id" />
<result property="materialCheckResultId" column="material_check_result_id" />
<result property="materialBarcode" column="material_barcode" />
<result property="batchCode" column="batch_code" />
<result property="checkAmount" column="check_amount" />
</resultMap>
<sql id="selectMesMaterialCheckResultDetailVo">
select check_result_detail_id, material_check_result_id, material_barcode, batch_code, check_amount from mes_material_check_result_detail
</sql>
<select id="selectMesMaterialCheckResultDetailList" parameterType="MesMaterialCheckResultDetail" resultMap="MesMaterialCheckResultDetailResult">
<include refid="selectMesMaterialCheckResultDetailVo"/>
<where>
<if test="materialCheckResultId != null "> and material_check_result_id = #{materialCheckResultId}</if>
<if test="materialBarcode != null and materialBarcode != ''"> and material_barcode = #{materialBarcode}</if>
<if test="batchCode != null and batchCode != ''"> and batch_code = #{batchCode}</if>
<if test="checkAmount != null "> and check_amount = #{checkAmount}</if>
</where>
</select>
<select id="selectMesMaterialCheckResultDetailByCheckResultDetailId" parameterType="Long" resultMap="MesMaterialCheckResultDetailResult">
<include refid="selectMesMaterialCheckResultDetailVo"/>
where check_result_detail_id = #{checkResultDetailId}
</select>
<insert id="insertMesMaterialCheckResultDetail" parameterType="MesMaterialCheckResultDetail" useGeneratedKeys="true" keyProperty="checkResultDetailId">
insert into mes_material_check_result_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="materialCheckResultId != null">material_check_result_id,</if>
<if test="materialBarcode != null and materialBarcode != ''">material_barcode,</if>
<if test="batchCode != null and batchCode != ''">batch_code,</if>
<if test="checkAmount != null">check_amount,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="materialCheckResultId != null">#{materialCheckResultId},</if>
<if test="materialBarcode != null and materialBarcode != ''">#{materialBarcode},</if>
<if test="batchCode != null and batchCode != ''">#{batchCode},</if>
<if test="checkAmount != null">#{checkAmount},</if>
</trim>
</insert>
<update id="updateMesMaterialCheckResultDetail" parameterType="MesMaterialCheckResultDetail">
update mes_material_check_result_detail
<trim prefix="SET" suffixOverrides=",">
<if test="materialCheckResultId != null">material_check_result_id = #{materialCheckResultId},</if>
<if test="materialBarcode != null and materialBarcode != ''">material_barcode = #{materialBarcode},</if>
<if test="batchCode != null and batchCode != ''">batch_code = #{batchCode},</if>
<if test="checkAmount != null">check_amount = #{checkAmount},</if>
</trim>
where check_result_detail_id = #{checkResultDetailId}
</update>
<delete id="deleteMesMaterialCheckResultDetailByCheckResultDetailId" parameterType="Long">
delete from mes_material_check_result_detail where check_result_detail_id = #{checkResultDetailId}
</delete>
<delete id="deleteMesMaterialCheckResultDetailByCheckResultDetailIds" parameterType="String">
delete from mes_material_check_result_detail where check_result_detail_id in
<foreach item="checkResultDetailId" collection="array" open="(" separator="," close=")">
#{checkResultDetailId}
</foreach>
</delete>
</mapper>

@ -13,6 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="checkAmount" column="check_amount" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="checkType" column="check_type" />
</resultMap>
<sql id="selectMesMaterialCheckResultVo">
@ -81,4 +83,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{materialCheckResultId}
</foreach>
</delete>
<select id="selectMesMaterialCheckResultByUI" resultMap="MesMaterialCheckResultResult">
<include refid="selectMesMaterialCheckResultVo"/>
where plan_id = #{planId} and plan_detail_id = #{planDetailId} and material_id = #{materialId} limit 1
</select>
<select id="selectMesMaterialCheckResult" resultMap="MesMaterialCheckResultResult">
SELECT mmb.standard_amount,mmcr.check_amount,mmb.check_type FROM `mes_material_check_result` mmcr
right join mes_material_bom mmb on mmb.material_id=mmcr.material_id
where mmb.ancestors like concat(#{ancestors}, '%') and mmcr.plan_id = #{planId} and mmcr.plan_detail_id = #{planDetailId}
</select>
</mapper>

@ -24,6 +24,17 @@ public class WmsConfig
*/
private Long fifthSemiWarehouseId;
/**
* ID
*/
private Long firstFloorProductWarehouseId;
/**
* ID
*/
private Long fourthFloorProductWarehouseId;
public String getFifthAssembleStationCode() {
return fifthAssembleStationCode;
}
@ -39,4 +50,20 @@ public class WmsConfig
public void setFifthSemiWarehouseId(Long fifthSemiWarehouseId) {
this.fifthSemiWarehouseId = fifthSemiWarehouseId;
}
public Long getFirstFloorProductWarehouseId() {
return firstFloorProductWarehouseId;
}
public void setFirstFloorProductWarehouseId(Long firstFloorProductWarehouseId) {
this.firstFloorProductWarehouseId = firstFloorProductWarehouseId;
}
public Long getFourthFloorProductWarehouseId() {
return fourthFloorProductWarehouseId;
}
public void setFourthFloorProductWarehouseId(Long fourthFloorProductWarehouseId) {
this.fourthFloorProductWarehouseId = fourthFloorProductWarehouseId;
}
}

@ -39,6 +39,9 @@ public class WmsApiController extends BaseController {
@Autowired
private IWmsStockTotalService wmsStockTotalService;
@Autowired
private IWmsProductInstockService wmsProductInstockService;
/**
*
@ -107,4 +110,24 @@ public class WmsApiController extends BaseController {
return toAjax(wmsRawOutstockService.directRawOutstock(wmsRawOutstock));
}
/**
*
*/
// @RequiresPermissions("wms:mobile:addrawinstock")
@Log(title = "成品入库记录", businessType = BusinessType.INSERT)
@PostMapping(("/firstFloorProduceInstock"))
public AjaxResult firstFloorProduceInstock(@Validated @RequestBody WmsProduceInstockVo wmsProduceInstockVo) {
return toAjax(wmsProductInstockService.firstFloorProduceInstock(wmsProduceInstockVo));
}
/**
*
*/
// @RequiresPermissions("wms:mobile:addrawinstock")
@Log(title = "成品入库记录", businessType = BusinessType.INSERT)
@PostMapping(("/fourthFloorProduceInstock"))
public AjaxResult fourthFloorProduceInstock(@Validated @RequestBody WmsProduceInstockVo wmsProduceInstockVo) {
return toAjax(wmsProductInstockService.fourthFloorProduceInstock(wmsProduceInstockVo));
}
}

@ -224,7 +224,7 @@ public class WmsMobileController extends BaseController {
/**
*
* 5
*/
@Log(title = "成品入库记录", businessType = BusinessType.INSERT)
@PostMapping(("/addProductInstock"))
@ -387,8 +387,8 @@ public class WmsMobileController extends BaseController {
@Log(title = "成品出库确认", businessType = BusinessType.UPDATE)
@PostMapping(("/finalConfirmProductOutstock"))
public AjaxResult finalConfirmProductOutstock(@RequestBody @Validated WmsProductOutstockConfirmVo wmsProductOutstockConfirmVo) {
wmsProductOutstockService.finalConfirmProductOutstock(wmsProductOutstockConfirmVo);
return toAjax(1);
return toAjax(wmsProductOutstockService.finalConfirmProductOutstock(wmsProductOutstockConfirmVo));
}
@ -407,8 +407,8 @@ public class WmsMobileController extends BaseController {
*/
@Log(title = "生产入库", businessType = BusinessType.INSERT)
@PostMapping(("/produceInstock"))
public AjaxResult produceInstock(@Validated @RequestBody WmsProduceInstockVo wmsProduceInstockVo) {
return toAjax(wmsProductInstockService.produceInstock(wmsProduceInstockVo));
public AjaxResult fifthFloorProduceInstock(@Validated @RequestBody WmsProduceInstockVo wmsProduceInstockVo) {
return toAjax(wmsProductInstockService.fifthFloorProduceInstock(wmsProduceInstockVo));
}

@ -68,6 +68,8 @@ public class WmsInventoryCheck extends BaseEntity
/** 盘点记录明细;盘点记录对应的明细信息信息 */
private List<WmsInventoryCheckDetail> wmsInventoryCheckDetailList;
private String warehouseName;
public void setInventoryCheckId(Long inventoryCheckId)
{
this.inventoryCheckId = inventoryCheckId;
@ -176,6 +178,14 @@ public class WmsInventoryCheck extends BaseEntity
this.wmsInventoryCheckDetailList = wmsInventoryCheckDetailList;
}
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -19,142 +19,122 @@ import com.hw.common.core.web.domain.BaseEntity;
public class WmsProductOutstock extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* ID
*/
/** 成品出库记录ID */
private Long productOutstockId;
/**
* ;
*/
@Excel(name = "任务编号;移库时必须")
/** 任务编号 */
@Excel(name = "任务编号")
private String taskCode;
/**
* ID;
*/
/** 仓库ID;领料时需要保存 */
@Excel(name = "仓库ID;领料时需要保存")
private Long warehouseId;
/**
* ;
*/
@Excel(name = "库位编码;移库时需要保存")
/** 库位编码 */
@Excel(name = "库位编码")
private String locationCode;
/**
* 2,3
*/
/** 成品类型2半成品,3成品 */
@Excel(name = "成品类型", readConverterExp = "2=半成品,3成品")
private String productType;
/**
* (0,1,2,3)
*/
@Excel(name = "操作类型(0自动,1手动,2强制,3调度)")
/** 操作类型(0自动,1人工,2强制,3调度) */
@Excel(name = "操作类型(0自动,1人工,2强制,3调度)")
private String operationType;
/**
* (1 9)
*/
/** 出库类型(1销售出库 9其他出库) */
@Excel(name = "出库类型(1销售出库 9其他出库)")
private String outstockType;
/**
* ,pd_base_plan_infoplan_id
*/
/** 计划编号,关联pd_base_plan_info的plan_code */
@Excel(name = "计划编号,关联pd_base_plan_info的plan_code")
private String planCode;
/**
* ID,pd_base_plan_detailplan_detail_id
*/
/** 计划明细编号,关联pd_base_plan_detail的plan_detail_code */
@Excel(name = "计划明细编号,关联pd_base_plan_detail的plan_detail_code")
private String planDetailCode;
/** 销售订单ID主键 */
@Excel(name = "销售订单ID主键")
private Long saleOrderId;
/** 销售订单编号 */
@Excel(name = "销售订单编号")
private String saleorderCode;
/** 项目号 */
@Excel(name = "项目号")
private String projectNo;
/** 成品ID关联物料信息主键 */
@Excel(name = "成品ID关联物料信息主键")
private Long productId;
/**
*
* */
/** 成品批次 */
@Excel(name = "成品批次")
private String productBatch;
/** 托盘RFID代码 */
@Excel(name = "托盘RFID代码")
private String palletInfoCode;
/** 出库目的地 */
@Excel(name = "出库目的地")
private String endStationCode;
/** 申请数量 */
@Excel(name = "申请数量")
private BigDecimal applyQty;
/**
*
* */
/** 已出数量 */
@Excel(name = "已出数量")
private BigDecimal outstockQty;
/**
*
*/
/** 申请原因 */
@Excel(name = "申请原因")
private String applyReason;
/**
*
*/
/** 审核原因 */
@Excel(name = "审核原因")
private String auditReason;
/**
* (0,1,2)
*/
/** 审核状态(0待审核,1审核通过,2审核未通过) */
@Excel(name = "审核状态(0待审核,1审核通过,2审核未通过)")
private String auditStatus;
/**
* (0,1,2)
*/
/** 执行状态(0待执行,1执行中,2执行完成) */
@Excel(name = "执行状态(0待执行,1执行中,2执行完成)")
private String executeStatus;
/**
*
*/
/** 申请人 */
@Excel(name = "申请人")
private String applyBy;
/**
*
*/
/** 申请时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date applyDate;
/**
*
*/
/** 审核人 */
@Excel(name = "审核人")
private String auditBy;
/**
*
*/
/** 审核时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date auditDate;
/**
*
*/
/** 最后更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updateDate;
/**
*
*/
/** 执行开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "执行开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date beginTime;
/**
*
*/
/** 执行结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "执行结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date endTime;
@ -405,6 +385,30 @@ public class WmsProductOutstock extends BaseEntity {
this.erpAmount = erpAmount;
}
public String getProductBatch() {
return productBatch;
}
public void setProductBatch(String productBatch) {
this.productBatch = productBatch;
}
public String getPalletInfoCode() {
return palletInfoCode;
}
public void setPalletInfoCode(String palletInfoCode) {
this.palletInfoCode = palletInfoCode;
}
public String getEndStationCode() {
return endStationCode;
}
public void setEndStationCode(String endStationCode) {
this.endStationCode = endStationCode;
}
public List<WmsProductOutstockDetail> getWmsProductOutstockDetailList() {
return wmsProductOutstockDetailList;
}

@ -5,15 +5,15 @@ import com.hw.wms.domain.WmsProductOutstockDetail;
/**
* Mapper
*
*
* @author xins
* @date 2024-01-16
*/
public interface WmsProductOutstockDetailMapper
public interface WmsProductOutstockDetailMapper
{
/**
*
*
*
* @param productOutstockDetailId
* @return
*/
@ -21,7 +21,7 @@ public interface WmsProductOutstockDetailMapper
/**
*
*
*
* @param wmsProductOutstockDetail
* @return
*/
@ -29,7 +29,7 @@ public interface WmsProductOutstockDetailMapper
/**
*
*
*
* @param wmsProductOutstockDetail
* @return
*/
@ -37,7 +37,7 @@ public interface WmsProductOutstockDetailMapper
/**
*
*
*
* @param wmsProductOutstockDetail
* @return
*/
@ -45,7 +45,7 @@ public interface WmsProductOutstockDetailMapper
/**
*
*
*
* @param productOutstockDetailId
* @return
*/
@ -53,9 +53,21 @@ public interface WmsProductOutstockDetailMapper
/**
*
*
*
* @param productOutstockDetailIds
* @return
*/
public int deleteWmsProductOutstockDetailByProductOutstockDetailIds(Long[] productOutstockDetailIds);
/**
*
*
* @param productBarcode
* @return
*/
public WmsProductOutstockDetail selectWmsProductOutstockDetailByProductBarcode(String productBarcode);
}

@ -1,6 +1,8 @@
package com.hw.wms.service;
import java.util.List;
import com.hw.common.core.constant.WmsConstants;
import com.hw.wms.domain.WmsProductInstock;
import com.hw.wms.domain.vo.WmsProduceInstockVo;
import com.hw.wms.domain.vo.WmsProductInstockVo;
@ -12,8 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
* @author xins
* @date 2023-12-25
*/
public interface IWmsProductInstockService
{
public interface IWmsProductInstockService {
/**
* ;
*
@ -71,10 +72,30 @@ public interface IWmsProductInstockService
*/
public int insertWmsProductInstock(WmsProductInstockVo wmsProductInstockVo);
/**
*
*
* @param wmsProduceInstockVo
* @return
*/
public int fifthFloorProduceInstock(WmsProduceInstockVo wmsProduceInstockVo);
/**
* (Web1)
*
* @param wmsProduceInstockVo
* @return
*/
public int firstFloorProduceInstock(WmsProduceInstockVo wmsProduceInstockVo);
/**
* (Web4)
*
* @param wmsProduceInstockVo
* @return
*/
public int produceInstock(WmsProduceInstockVo wmsProduceInstockVo);
public int fourthFloorProduceInstock(WmsProduceInstockVo wmsProduceInstockVo);
}

@ -231,12 +231,19 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
throw new ServiceException("原库位有占用库存信息,不能进行移库");
}
//目标库位需要是空库位
WmsRawStock queryTargetRawStock = new WmsRawStock();
queryTargetRawStock.setLocationCode(targetLocationCode);
List<WmsRawStock> targetRawStocks = wmsRawStockMapper.selectWmsRawStockInList(queryTargetRawStock);
if (targetRawStocks != null && !targetRawStocks.isEmpty()) {
throw new ServiceException("目标库位有库存,不能进行移库");
//移库时movetype为1时目标库位需要是空库位合库时(movetype为2时)目标库位需要是非空库位
if (wmsMoveApplyVo.getMoveType().equals(WmsConstants.WMS_MOVEMERGE_TYPE_MOVE)) {
if (targetRawStocks != null && !targetRawStocks.isEmpty()) {
throw new ServiceException("目标库位有库存,不能进行移库");
}
} else {
if (targetRawStocks == null || targetRawStocks.isEmpty()) {
throw new ServiceException("目标库位无库存,不能进行合库");
}
}
toInsertedMoves = getMovesByRawStocks(wmsRawStocks, wmsMoveApplyVo, userName, currentDate);

@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.stream.Collectors;
import com.hw.common.core.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
@ -157,7 +158,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
/**
* ()
* (5)
*
* @param wmsProductInstockVo
* @return
@ -181,7 +182,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
//todo 仓库可存储此物料判断是否可以入此库位
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();//todo 是否改成nickname
String userName = SecurityUtils.getUsername();
WmsProductInstock wmsProductInstock = new WmsProductInstock();
wmsProductInstock.setWarehouseId(baseLocation.getWarehouseId());
wmsProductInstock.setLocationCode(locationCode);
@ -190,8 +191,11 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
wmsProductInstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
wmsProductInstock.setPlanCode(baseBarcodeInfo.getPlanCode());
wmsProductInstock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode());
wmsProductInstock.setProductBatch(materialBarcode);
wmsProductInstock.setProductId(productId);
wmsProductInstock.setInstockType(WmsConstants.PRODUCT_INSTOCK_INSTOCK_TYPE_PRODUCT);
wmsProductInstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsProductInstock.setInstockAmount(BigDecimal.ONE);
wmsProductInstock.setApplyBy(userName);
wmsProductInstock.setApplyDate(currentDate);
@ -199,15 +203,15 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
int rows = wmsProductInstockMapper.insertWmsProductInstock(wmsProductInstock);
//插入明细
insertWmsProductInstockDetail(wmsProductInstock, materialBarcode, productId, wmsProductInstockVo);
// insertWmsProductInstockDetail(wmsProductInstock, materialBarcode, productId, wmsProductInstockVo);
//更新库存
updateProductStock(wmsProductInstock, baseBarcodeInfo, baseLocation,
materialBarcode, productId, userName, currentDate);
updateProductStock(baseBarcodeInfo, locationCode, baseLocation.getWarehouseId(), baseLocation.getWarehouseFloor(), userName, currentDate);
return rows;
}
/**
* 使4
*
@ -233,38 +237,45 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
/**
*
* ,PDA
*
* @param wmsProductInstock
* @param baseLocation
* @param productBatch
* @param productId
* @param baseBarcodeInfo
* @param locationCode
* @param warehouseId
* @param warehouseFloor
* @param userName
* @param currentDate
*/
public void updateProductStock(WmsProductInstock wmsProductInstock, MesBaseBarcodeInfo baseBarcodeInfo, WmsBaseLocation baseLocation,
String productBatch, Long productId, String userName, Date currentDate) {
String locationCode = wmsProductInstock.getLocationCode();
public void updateProductStock(MesBaseBarcodeInfo baseBarcodeInfo, String locationCode, Long warehouseId, Long warehouseFloor,
String userName, Date currentDate) {
BigDecimal instockAmount = new BigDecimal(1);
//判断此库位的数量限制,是否还能入库
// WmsProductStock queryProductStock = new WmsProductStock();
// queryProductStock.setLocationCode(locationCode);
// BigDecimal totalAmount = wmsProductStockMapper.getProductStockTotalAmount(queryProductStock);
// totalAmount = totalAmount == null ? BigDecimal.ZERO : totalAmount;
// if (totalAmount.add(instockAmount).compareTo(baseLocation.getQtyLimit()) > 0) {
// throw new ServiceException("已超出库位数量限制,请重新选择库位");
// }
String materialBarcode = baseBarcodeInfo.getBarcodeInfo();
WmsProductStock queryProductStock = new WmsProductStock();
queryProductStock.setLocationCode(locationCode);
BigDecimal totalAmount = wmsProductStockMapper.getProductStockTotalAmount(queryProductStock);
totalAmount = totalAmount == null ? BigDecimal.ZERO : totalAmount;
if (totalAmount.add(instockAmount).compareTo(baseLocation.getQtyLimit()) > 0) {
throw new ServiceException("已超出库位数量限制,请重新选择库位");
queryProductStock.setProductBatch(materialBarcode);
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByBatch(materialBarcode);
if (productStock != null) {
throw new ServiceException("此成品已经入库,无需重复入库");
}
//一个成品一个条码,对应一条库存信息
WmsProductStock wmsProductStock = new WmsProductStock();
wmsProductStock.setWarehouseId(wmsProductInstock.getWarehouseId());
wmsProductStock.setWarehouseId(warehouseId);
wmsProductStock.setLocationCode(locationCode);
wmsProductStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
wmsProductStock.setProductId(productId);
wmsProductStock.setProductBatch(productBatch);
wmsProductStock.setProductId(baseBarcodeInfo.getMaterialId());
wmsProductStock.setProductBatch(materialBarcode);
wmsProductStock.setPlanCode(baseBarcodeInfo.getPlanCode());
wmsProductStock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode());
wmsProductStock.setWarehouseFloor(baseLocation.getWarehouseFloor());
wmsProductStock.setWarehouseFloor(warehouseFloor);
wmsProductStock.setSaleorderCode(baseBarcodeInfo.getSaleorderCode());
// wmsProductStock.setQualityStatus(wmsRawInstockVo.getQualityStatus());
wmsProductStock.setTotalAmount(instockAmount);
@ -282,28 +293,96 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
* @return
*/
@Override
public int produceInstock(WmsProduceInstockVo wmsProduceInstockVo) {
public int fifthFloorProduceInstock(WmsProduceInstockVo wmsProduceInstockVo) {
Long warehouseId = wmsConfig.getFifthSemiWarehouseId();//五楼半成品库
String productType = WmsConstants.PRODUCT_STOCK_STOCK_TYPE_SEMI;
String operationType = WmsConstants.WMS_OPERATION_TYPE_AUTO;
String executeStatus = WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE;
return produceInstock(wmsProduceInstockVo, warehouseId, productType, operationType, executeStatus, 5L);
}
/**
* (Web1)
*
* @param wmsProduceInstockVo
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int firstFloorProduceInstock(WmsProduceInstockVo wmsProduceInstockVo) {
Long warehouseId = wmsConfig.getFirstFloorProductWarehouseId();
String productType = WmsConstants.PRODUCT_INSTOCK_STOCK_TYPE_PRODUCT;
String operationType = WmsConstants.WMS_OPERATION_TYPE_MANUAL;
String executeStatus = WmsConstants.WMS_EXECUTE_STATUS_FINISH;
return produceInstock(wmsProduceInstockVo, warehouseId, productType, operationType, executeStatus, 1L);
}
/**
* (Web4)
*
* @param wmsProduceInstockVo
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int fourthFloorProduceInstock(WmsProduceInstockVo wmsProduceInstockVo) {
Long warehouseId = wmsConfig.getFourthFloorProductWarehouseId();
String productType = WmsConstants.PRODUCT_INSTOCK_STOCK_TYPE_PRODUCT;
String operationType = WmsConstants.WMS_OPERATION_TYPE_MANUAL;
String executeStatus = WmsConstants.WMS_EXECUTE_STATUS_FINISH;
return produceInstock(wmsProduceInstockVo, warehouseId, productType, operationType, executeStatus, 4L);
}
/**
*
*
* @param wmsProduceInstockVo
* @param warehouseId
* @param productType
* @param operationType
* @param executeStatus
* @return
*/
public int produceInstock(WmsProduceInstockVo wmsProduceInstockVo, Long warehouseId, String productType, String operationType, String executeStatus, Long warehouseFloor) {
String materialBarcode = wmsProduceInstockVo.getMaterialBarcode();
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
if (baseBarcodeInfoR == null) {
throw new ServiceException("物料编码有误");
}
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
if (baseBarcodeInfo == null) {
throw new ServiceException("物料编码有误");
}
WmsProductInstock queryProductInstock = new WmsProductInstock();
queryProductInstock.setProductBatch(materialBarcode);
List<WmsProductInstock> wmsProductInstocks = wmsProductInstockMapper.selectWmsProductInstockList(queryProductInstock);
if (wmsProductInstocks != null && !wmsProductInstocks.isEmpty()) {
throw new ServiceException("已经有此物料入库记录");
if (baseBarcodeInfo.getBarcodeType().equals(WmsConstants.RWA_STOCK_STOCK_TYPE_RAW)) {
throw new ServiceException("此物料条码为原材料,非成品条码");
}
Long warehouseId = wmsConfig.getFifthSemiWarehouseId();//五楼半成品库
//如果执行状态不是已完成是agv入库则需要判断是否有入库记录避免重复提交如果执行状态是已完成人工入库则判断是否有此成品条码库存即可
if (!executeStatus.equals(WmsConstants.WMS_EXECUTE_STATUS_FINISH)) {
WmsProductInstock queryProductInstock = new WmsProductInstock();
queryProductInstock.setProductBatch(materialBarcode);//productbatch是索引查出来再过滤性能更快
List<WmsProductInstock> wmsProductInstocks = wmsProductInstockMapper.selectWmsProductInstockList(queryProductInstock);
if (wmsProductInstocks != null && !wmsProductInstocks.isEmpty()) {
List<WmsProductInstock> incompleteProductInstocks = wmsProductInstocks.stream().filter(
wmsProductInstock -> !wmsProductInstock.getExecuteStatus().equals(WmsConstants.WMS_EXECUTE_STATUS_FINISH)).collect(Collectors.toList());
if (incompleteProductInstocks != null && !incompleteProductInstocks.isEmpty()) {
throw new ServiceException("已经有此成品入库记录");
}
}
}
String userName = SecurityUtils.getUsername();
Date currentDate = new Date();
WmsProductInstock wmsProductInstock = new WmsProductInstock();
wmsProductInstock.setTaskCode(Seq.getId(Seq.productInstockSeqType, Seq.productInstockCode));
wmsProductInstock.setWarehouseId(warehouseId);
wmsProductInstock.setPalletInfoCode(baseBarcodeInfo.getPalletInfoCode());
wmsProductInstock.setProductType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_SEMI);
wmsProductInstock.setOperationType(WmsConstants.WMS_OPERATION_TYPE_AUTO);
wmsProductInstock.setProductType(productType);
wmsProductInstock.setOperationType(operationType);
wmsProductInstock.setPlanCode(baseBarcodeInfo.getPlanCode());
wmsProductInstock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode());
wmsProductInstock.setInstockType(WmsConstants.PRODUCT_INSTOCK_INSTOCK_TYPE_PRODUCT);
@ -311,14 +390,16 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
wmsProductInstock.setProductBatch(materialBarcode);
wmsProductInstock.setInstockAmount(BigDecimal.ONE);
wmsProductInstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsProductInstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
wmsProductInstock.setApplyBy(SecurityUtils.getUsername());
wmsProductInstock.setApplyDate(new Date());
wmsProductInstock.setExecuteStatus(executeStatus);
wmsProductInstock.setApplyBy(userName);
wmsProductInstock.setApplyDate(currentDate);
if (executeStatus.equals(WmsConstants.WMS_EXECUTE_STATUS_FINISH)) {
updateProductStock(baseBarcodeInfo, "", warehouseId, warehouseFloor, userName, currentDate);
}
return wmsProductInstockMapper.insertWmsProductInstock(wmsProductInstock);
}
public void syncToErp() {
//todo 根据质检状态是通过的同步给ERP
}

@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.domain.R;
@ -11,6 +12,7 @@ import com.hw.common.core.exception.ServiceException;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.RemoteMesService;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.wms.config.WmsConfig;
import com.hw.wms.domain.WmsBaseLocation;
import com.hw.wms.domain.WmsProductOutstock;
import com.hw.wms.domain.WmsProductStock;
@ -46,6 +48,12 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD
@Autowired
private WmsBaseLocationMapper wmsBaseLocationMapper;
@Autowired
private WmsConfig wmsConfig;
@Resource
private RemoteMesService remoteMesService;
/**
*
@ -83,9 +91,13 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD
String productBarcode = wmsProductOutstockDetail.getProductBarcode();//成品条码和批次码相同
Long productOutstockId = wmsProductOutstockDetail.getProductOutstockId();
WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
if (location == null) {
throw new ServiceException(String.format("库位编码%1$s错误", locationCode));
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(productBarcode, SecurityConstants.INNER);
if (baseBarcodeInfoR == null) {
throw new ServiceException("物料编码有误");
}
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
if (baseBarcodeInfo == null) {
throw new ServiceException("物料编码有误");
}
WmsProductOutstock productOutstock = wmsProductOutstockMapper.selectOnlyWmsProductOutstockByOutstockId(productOutstockId);
@ -93,17 +105,31 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD
throw new ServiceException("没有此成品出库任务信息");
}
if (!productOutstock.getWarehouseId().equals(location.getWarehouseId())) {
throw new ServiceException("没有此仓库出库任务");
if(!productOutstock.getProductId().equals(baseBarcodeInfo.getMaterialId())) {
throw new ServiceException("物料编码有误");
}
if(StringUtils.isEmpty(locationCode) &&
(wmsConfig.getFirstFloorProductWarehouseId().equals(productOutstock.getWarehouseId()) ||
wmsConfig.getFourthFloorProductWarehouseId().equals(productOutstock.getWarehouseId()))){
locationCode = "0";
wmsProductOutstockDetail.setLocationCode("0");
}else{
WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
if (location == null) {
throw new ServiceException(String.format("库位编码%1$s错误", locationCode));
}
if (!productOutstock.getWarehouseId().equals(location.getWarehouseId())) {
throw new ServiceException("没有此仓库出库任务");
}
}
if (productOutstock.getExecuteStatus().equals(WmsConstants.WMS_EXECUTE_STATUS_FINISH)) {
throw new ServiceException("此出库申请已完成,不能再出库");
}
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByLocationAndBatchAndSaleOrderId(locationCode,
productBarcode, productOutstock.getSaleOrderId(), WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
if (productStock == null) {
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByBatch(productBarcode);
if (productStock == null || !productStock.getSaleOrderId().equals(productOutstock.getSaleOrderId())) {
throw new ServiceException("此库位没有对应订单库存");
}
@ -155,7 +181,7 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD
wmsProductOutstockDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
wmsProductOutstockDetail.setBeginTime(currentDate);
wmsProductOutstockDetail.setEndTime(currentDate);
wmsProductOutstockDetail.setWarehouseId(location.getWarehouseId());
wmsProductOutstockDetail.setWarehouseId(productStock.getWarehouseId());
wmsProductOutstockDetail.setPlanAmount(BigDecimal.ONE);
wmsProductOutstockDetail.setOutstockAmount(BigDecimal.ONE);

@ -12,6 +12,7 @@ import com.hw.wms.domain.WmsBaseWarehouse;
import com.hw.wms.domain.WmsProductStock;
import com.hw.wms.domain.vo.WmsProductOutstockConfirmVo;
import com.hw.wms.mapper.WmsBaseWarehouseMapper;
import com.hw.wms.mapper.WmsProductOutstockDetailMapper;
import com.hw.wms.mapper.WmsProductStockMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -36,6 +37,9 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
@Autowired
private WmsProductOutstockMapper wmsProductOutstockMapper;
@Autowired
private WmsProductOutstockDetailMapper wmsProductOutstockDetailMapper;
@Autowired
private WmsProductStockMapper wmsProductStockMapper;
@ -94,7 +98,7 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
BigDecimal frozenAmount = productStock.getFrozenAmount() == null ? BigDecimal.ZERO : productStock.getFrozenAmount();//冻结数量暂时没用
BigDecimal occupyAmount = productStock.getOccupyAmount() == null ? BigDecimal.ZERO : productStock.getOccupyAmount();//
BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount);
BigDecimal sumApplyQty = productStock.getApplyAmount();//获取已申请出库数量
BigDecimal sumApplyQty = productStock.getApplyAmount() == null ? BigDecimal.ZERO : productStock.getApplyAmount();//获取已申请出库数量
// WmsProductOutstock queryProductOutStock = new WmsProductOutstock();
// queryProductOutStock.setSaleorderCode(saleorderCode);
@ -220,15 +224,39 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
/**
*
*
* @param wmsProductOutstockConfirmVo
* @return
*/
@Override
public int finalConfirmProductOutstock(WmsProductOutstockConfirmVo wmsProductOutstockConfirmVo){
System.out.println("111"+wmsProductOutstockConfirmVo.getSaleorderCode());
System.out.println("3333"+wmsProductOutstockConfirmVo.getMaterialBarcode());
public int finalConfirmProductOutstock(WmsProductOutstockConfirmVo wmsProductOutstockConfirmVo) {
WmsProductOutstockDetail productOutstockDetail = wmsProductOutstockDetailMapper.
selectWmsProductOutstockDetailByProductBarcode(wmsProductOutstockConfirmVo.getMaterialBarcode());
if (productOutstockDetail == null) {
throw new ServiceException("没有此成品出库信息");
}
String executeStatus = productOutstockDetail.getExecuteStatus();
if (executeStatus.equals(WmsConstants.WMS_EXECUTE_STATUS_CONFIRM)) {
throw new ServiceException("此成品出库已经确认,无需再次确认");
}
if (!executeStatus.equals(WmsConstants.WMS_EXECUTE_STATUS_FINISH)) {
throw new ServiceException("此成品还未出库,不能进行确认");
}
WmsProductOutstock wmsProductOutstock = wmsProductOutstockMapper.
selectOnlyWmsProductOutstockByOutstockId(productOutstockDetail.getProductOutstockId());
if (wmsProductOutstock.getSaleorderCode() == null ||
!wmsProductOutstock.getSaleorderCode().equals(wmsProductOutstockConfirmVo.getSaleorderCode())) {
throw new ServiceException("销售订单成品出库记录不匹配");
}
productOutstockDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_CONFIRM);
productOutstockDetail.setConfirmAmount(BigDecimal.ONE);
productOutstockDetail.setUpdateDate(new Date());
productOutstockDetail.setUpdateBy(SecurityUtils.getUsername());
return 1;
return wmsProductOutstockDetailMapper.updateWmsProductOutstockDetail(productOutstockDetail);
}
}

@ -287,6 +287,9 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
}
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
if (baseBarcodeInfoR == null) {
throw new ServiceException("物料编码有误");
}
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
if (baseBarcodeInfo == null) {
throw new ServiceException("物料编码有误");
@ -301,6 +304,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
String batchCode = baseBarcodeInfo.getBatchCode();
//todo后续判断outrequirement
//判断是否有此出库任务,人工出库的同一个出库记录同一个库位、同一个物料对应一个明细agv的有可能是多个
WmsRawOutstock queryRawOutstock = new WmsRawOutstock();
queryRawOutstock.setLocationCode(locationCode);

@ -221,6 +221,13 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
if (oriLocation == null) {
throw new ServiceException("库位不存在");
}
//删除成品库存
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByBatch(materialBarcode);
if (productStock == null) {
throw new ServiceException("无此成品库存");
}
WmsTransfer wmsTransfer = new WmsTransfer();
wmsTransfer.setTaskCode(Seq.getId(Seq.wmsTransferSeqType, Seq.wmsTransferSeqCode));
wmsTransfer.setOriWarehouseId(oriLocation.getWarehouseId());
@ -252,8 +259,6 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
wmsTransferDetailMapper.insertWmsTransferDetail(wmsTransferDetail);
//删除成品库存
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByBatch(materialBarcode);
wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId());
return 1;
@ -293,7 +298,7 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
queryTransfer.setProductBatch(materialBarcode);
queryTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH);
List<WmsTransfer> wmsTransfers = wmsTransferMapper.selectWmsTransferList(queryTransfer);
if(wmsTransfers==null || wmsTransfers.isEmpty()){
if (wmsTransfers == null || wmsTransfers.isEmpty()) {
throw new ServiceException("没有此成品的转库出库记录,不能转库入库");
}

@ -19,6 +19,7 @@
<result property="createDate" column="create_date" />
<result property="updateBy" column="update_by" />
<result property="updateDate" column="update_date" />
<result property="warehouseName" column="warehouse_name" />
</resultMap>
<resultMap id="WmsInventoryCheckWmsInventoryCheckDetailResult" type="WmsInventoryCheck" extends="WmsInventoryCheckResult">

@ -68,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="locationCode != null and locationCode != ''"> and location_code = #{locationCode}</if>
<if test="productType != null and productType != ''"> and product_type = #{productType}</if>
<if test="operationType != null and operationType != ''"> and operation_type = #{operationType}</if>
<if test="productBatch != null and productBatch != ''"> and product_batch = #{productBatch}</if>
<if test="planCode != null "> and plan_code = #{planCode}</if>
<if test="planDetailCode != null "> and plan_detail_code = #{planDetailCode}</if>
<if test="instockType != null and instockType != ''"> and instock_type = #{instockType}</if>

@ -120,4 +120,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{productOutstockDetailId}
</foreach>
</delete>
<select id="selectWmsProductOutstockDetailByProductBarcode" parameterType="String" resultMap="WmsProductOutstockDetailResult">
<include refid="selectWmsProductOutstockDetailVo"/>
where product_barcode = #{productBarcode} limit 1
</select>
</mapper>

@ -18,6 +18,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="saleorderCode" column="saleorder_code" />
<result property="projectNo" column="project_no" />
<result property="productId" column="product_id" />
<result property="productBatch" column="product_batch" />
<result property="palletInfoCode" column="pallet_info_code" />
<result property="endStationCode" column="end_station_code" />
<result property="applyQty" column="apply_qty" />
<result property="outstockQty" column="outstock_qty" />
<result property="applyReason" column="apply_reason" />
@ -282,7 +285,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectOnlyWmsProductOutstockByOutstockId" parameterType="Long" resultMap="WmsProductOutstockResult">
select a.product_outstock_id, a.task_code, a.warehouse_id, a.location_code, a.product_type, a.operation_type, a.outstock_type, a.plan_code, a.plan_detail_code, a.product_id,a.apply_qty,a.outstock_qty,a.sale_order_id, a.execute_status, a.apply_by, a.apply_date, a.begin_time, a.end_time
select a.product_outstock_id, a.task_code, a.warehouse_id, a.location_code, a.product_type, a.operation_type, a.outstock_type, a.plan_code, a.plan_detail_code, a.product_id,a.apply_qty,a.outstock_qty,a.sale_order_id, a.execute_status, a.apply_by, a.apply_date, a.saleorder_code, a.begin_time, a.end_time
from wms_product_outstock a
where a.product_outstock_id = #{productOutstockId}
</select>

@ -34,7 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectWmsProductStockVo">
select product_stock_id, warehouse_id, location_code, stock_type, product_batch, quality_status, product_id, plan_code, plan_detail_code,saleorder_code, total_amount, frozen_amount, occupy_amount, create_by, create_date, update_by, update_date, active_flag, instock_date from wms_product_stock
select product_stock_id, warehouse_id, location_code, stock_type, product_batch, quality_status, product_id, plan_code, plan_detail_code,sale_order_id,saleorder_code, total_amount, frozen_amount, occupy_amount, create_by, create_date, update_by, update_date, active_flag, instock_date from wms_product_stock
</sql>
<select id="selectWmsProductStockList" parameterType="WmsProductStock" resultMap="WmsProductStockResult">
@ -228,7 +228,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select wps.warehouse_id,wps.sale_order_id,wps.product_id,sum(total_amount) total_amount,sum(frozen_amount) frozen_amount,sum(occupy_amount) occupy_amount,
mbmi.material_code,mbmi.material_name,
wbw.warehouse_name,mso.order_amount,mso.saleorder_code,
(select sum(wpo.apply_qty) from wms_product_outstock wpo where wpo.sale_order_id=wps.sale_order_id and wpo.warehouse_id=wps.warehouse_id and wpo.product_id=wps.product_id) apply_amount
(select sum(wpo.apply_qty) from wms_product_outstock wpo where wpo.sale_order_id=wps.sale_order_id and wpo.warehouse_id=wps.warehouse_id and wpo.product_id=wps.product_id and (wpo.execute_status='0' or wpo.execute_status='1')) apply_amount
from wms_product_stock wps
left join mes_base_material_info mbmi on wps.product_id=mbmi.material_id
left join wms_base_warehouse wbw on wps.warehouse_id=wbw.warehouse_id

Loading…
Cancel
Save