新增盘点功能代码

test
anthonywj 1 year ago
parent 1b3c16482a
commit 474971fb2f

@ -6,6 +6,7 @@ import com.glxp.api.entity.basic.CompanyProductRelevanceEntity;
import com.glxp.api.req.basic.CompanyProductRelevanceRequest;
import com.glxp.api.res.basic.CompanyProductRelevanceResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -20,4 +21,12 @@ public interface CompanyProductRelevanceDao extends BaseMapperPlus<CompanyProduc
boolean deleteById(String id);
boolean deleteByRlId(String id);
/**
* IDID
*
* @param udiRlIdFk
* @return
*/
List<String> selectUnitFkByUdiRlIdFk(@Param("udiRlIdFk") String udiRlIdFk);
}

@ -27,4 +27,5 @@ public interface IoCodeDao extends BaseMapperPlus<IoCodeDao, IoCodeEntity, IoCod
List<IoCodeResponse> filterJoinProduct(FilterCodeRequest filterCodeRequest);
String selectSupIdByCode(String code);
}

@ -21,4 +21,7 @@ public interface IoCodeTempDao extends BaseMapperPlus<IoCodeTempDao, IoCodeTempE
Integer selectExitCount(FilterCodeRequest filterCodeRequest);
List<IoCodeResponse> filterJoinProduct(FilterCodeRequest filterCodeRequest);
}

@ -78,4 +78,5 @@ public interface IoOrderDao extends BaseMapperPlus<IoOrderDao, IoOrderEntity, Io
List<String> selectOrderfirstAndLastIdList(@Param("firstData") String firstData, @Param("lastData") String lastData);
String selectSupIdByCode(String code);
}

@ -0,0 +1,81 @@
package com.glxp.api.dao.inv;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.entity.inv.InvCountCodesEntity;
import com.glxp.api.entity.inv.InvCountSettingEntity;
import com.glxp.api.req.inv.FilterInvCountCodesRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface InvCountCodesMapper extends BaseMapper<InvCountCodesEntity> {
/**
*
*
* @param orderId
*/
void deleteByOrderId(@Param("orderId") String orderId);
/**
*
*
* @param codesRequest
* @return
*/
List<InvCountCodesEntity> filterList(FilterInvCountCodesRequest codesRequest);
/**
* ID
*
* @param orderIdFk
* @return
*/
Long countByOrderIdFk(@Param("orderIdFk") String orderIdFk);
/**
*
*
* @param orderIdFk
* @return
*/
Long countByOrderId(@Param("orderIdFk") String orderIdFk);
/**
*
*
* @param code
* @param orderIdFk
* @return
*/
Long selectCountByCodeAndOrderId(@Param("code") String code, @Param("orderIdFk") String orderIdFk);
/**
*
*
* @param orderId
*/
void resetCountFiledValue(@Param("orderId") String orderId);
/**
* ID
*
* @param orderIdFk
* @param productId
* @return
*/
List<InvCountCodesEntity> selectByOrderIdAndProductId(@Param("orderIdFk") String orderIdFk, @Param("productId") String productId);
/**
*
*
* @param codesRequest
* @return
*/
List<String> selectCodes(FilterInvCountCodesRequest codesRequest);
}

@ -0,0 +1,87 @@
package com.glxp.api.dao.inv;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.dao.BaseMapperPlus;
import com.glxp.api.entity.inv.InvCountOrderDetailEntity;
import com.glxp.api.req.inv.FilterInvCountOrderDetailRequest;
import com.glxp.api.req.inv.FilterInvCountOrderRequest;
import com.glxp.api.res.inv.InvCountOrderDetailResponse;
import com.glxp.api.res.inv.InvCountOrderResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface InvCountOrderDetailMapper extends BaseMapperPlus<InvCountOrderDetailMapper, InvCountOrderDetailEntity, InvCountOrderDetailEntity> {
/**
*
*
* @param orderId
*/
void deleteByOrderId(@Param("orderId") String orderId);
/**
*
*
* @param detailRequest
* @return
*/
List<InvCountOrderDetailEntity> filterList(FilterInvCountOrderDetailRequest detailRequest);
/**
* ID
*
* @param orderIdFk
* @return
*/
Long countByOrderIdFk(@Param("orderIdFk") String orderIdFk);
/**
*
*
* @param detailRequest
* @return
*/
List<InvCountOrderDetailResponse> filterCountDetail(FilterInvCountOrderDetailRequest detailRequest);
/**
* ID
*
* @param orderIdFk
* @param productId
*/
void deleteByOrderIdAndProductId(@Param("orderIdFk") String orderIdFk, @Param("productId") String productId);
/**
* DI
*
* @return
*/
InvCountOrderDetailEntity selectOrderDetail(@Param("productId") String productId, @Param("orderIdFk") String orderIdFk, @Param("nameCode") String nameCode, @Param("batchNo") String batchNo, @Param("produceDate") String produceDate, @Param("expireDate") String expireDate);
/**
*
*
* @param orderId
* @return
*/
List<InvCountOrderDetailEntity> selectByOrderId(@Param("orderId") String orderId);
/**
*
*
* @param orderId
*/
void resetCountFiledValue(@Param("orderId") String orderId);
/**
*
*
* @param detailRequest
* @return
*/
List<InvCountOrderDetailEntity> selectDetailList(FilterInvCountOrderDetailRequest detailRequest);
}

@ -0,0 +1,63 @@
package com.glxp.api.dao.inv;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.entity.inv.InvCountOrderEntity;
import com.glxp.api.req.inv.FilterInvCountOrderRequest;
import com.glxp.api.res.inv.InvCountOrderResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface InvCountOrderMapper extends BaseMapper<InvCountOrderEntity> {
/***
*
* @param filterInvCountOrderRequest
* @return
*/
List<InvCountOrderResponse> selectList(FilterInvCountOrderRequest filterInvCountOrderRequest);
/**
* id
*
* @param id
* @return
*/
String selectOrderIdById(@Param("id") String id);
/**
*
*
* @param invStorageCode
* @param invWarehouseCode
* @param invSpaceCode
* @return
*/
Integer countBySpaceCode(@Param("invStorageCode") String invStorageCode, @Param("invWarehouseCode") String invWarehouseCode, @Param("invSpaceCode") String invSpaceCode);
/**
*
*
* @param invCountOrder
*/
void updateByOrderId(InvCountOrderEntity invCountOrder);
/**
*
*
* @param orderId
* @return
*/
InvCountOrderEntity selectByOrderId(@Param("orderId") String orderId);
/**
*
*
* @param orderId
*/
void deleteByOrderId(@Param("orderId") String orderId);
}

@ -0,0 +1,23 @@
package com.glxp.api.dao.inv;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.entity.inv.InvCountSettingEntity;
import com.glxp.api.req.inv.FilterInvCountSettingRequest;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface InvCountSettingMapper extends BaseMapper<InvCountSettingEntity> {
List<InvCountSettingEntity> filterList(FilterInvCountSettingRequest settingRequest);
/**
*
*
* @return
*/
Long countSetting();
}

@ -0,0 +1,75 @@
package com.glxp.api.entity.inv;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*/
@ApiModel(value="com-glxp-api-entity-inv-InvCountCodes")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "inv_count_codes")
public class InvCountCodesEntity implements Serializable {
/**
* id
*/
@TableId(value = "id", type = IdType.INPUT)
@ApiModelProperty(value="id")
private Integer id;
/**
* ID
*/
@TableField(value = "orderIdFk")
@ApiModelProperty(value="盘点单ID")
private String orderIdFk;
/**
* ID
*/
@TableField(value = "productId")
@ApiModelProperty(value="产品ID")
private String productId;
/**
*
*/
@TableField(value = "code")
@ApiModelProperty(value="码")
private String code;
/**
* 0 1
*/
@TableField(value = "`status`")
@ApiModelProperty(value="条码状态(多码或少码) 0少 1多")
private Boolean status;
/**
*
*/
@TableField(value = "batchNo")
@ApiModelProperty(value="批次号")
private String batchNo;
/**
*
*/
@TableField(value = "`count`")
@ApiModelProperty(value="扫码数量")
private Integer count;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,117 @@
package com.glxp.api.entity.inv;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*/
@ApiModel(value="com-glxp-api-entity-inv-InvCountOrderDetail")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "inv_count_order_detail")
public class InvCountOrderDetailEntity implements Serializable {
/**
* id
*/
@TableId(value = "id", type = IdType.INPUT)
@ApiModelProperty(value="id")
private Integer id;
/**
*
*/
@TableField(value = "orderIdFk")
@ApiModelProperty(value="盘点单号")
private String orderIdFk;
/**
* ID
*/
@TableField(value = "productId")
@ApiModelProperty(value="产品ID")
private String productId;
/**
* DI
*/
@TableField(value = "nameCode")
@ApiModelProperty(value="产品DI")
private String nameCode;
/**
*
*/
@TableField(value = "batchNo")
@ApiModelProperty(value="批次号")
private String batchNo;
/**
*
*/
@TableField(value = "produceDate")
@ApiModelProperty(value="生产日期")
private String produceDate;
/**
*
*/
@TableField(value = "expireDate")
@ApiModelProperty(value="失效日期")
private String expireDate;
/**
*
*/
@TableField(value = "serialNo")
@ApiModelProperty(value="序列号")
private String serialNo;
/**
*
*/
@TableField(value = "countNum")
@ApiModelProperty(value="盘点数量")
private Integer countNum;
/**
*
*/
@TableField(value = "invNum")
@ApiModelProperty(value="账面数量")
private Integer invNum;
/**
*
*/
@TableField(value = "profitNum")
@ApiModelProperty(value="盘盈数量")
private Integer profitNum;
/**
*
*/
@TableField(value = "lossNum")
@ApiModelProperty(value="盘亏数量")
private Integer lossNum;
/**
* 0 1
*/
@TableField(value = "`status`")
@ApiModelProperty(value="盈亏状态 0亏损 1盈利")
private Integer status;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,132 @@
package com.glxp.api.entity.inv;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*/
@ApiModel(value="com-glxp-api-entity-inv-InvCountOrder")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "inv_count_order")
public class InvCountOrderEntity implements Serializable {
/**
* id
*/
@TableId(value = "id", type = IdType.INPUT)
@ApiModelProperty(value="id")
private Integer id;
/**
*
*/
@TableField(value = "orderId")
@ApiModelProperty(value="盘点单号")
private String orderId;
/**
*
*/
@TableField(value = "invStorageCode")
@ApiModelProperty(value="仓库号")
private String invStorageCode;
/**
*
*/
@TableField(value = "invWarehouseCode")
@ApiModelProperty(value="分库号")
private String invWarehouseCode;
/**
*
*/
@TableField(value = "invSpaceCode")
@ApiModelProperty(value="货位号")
private String invSpaceCode;
/**
* ID
*/
@TableField(value = "`createUser`")
@ApiModelProperty(value="盘点用户ID")
private String createUser;
/**
*
*/
@TableField(value = "createTime")
@ApiModelProperty(value="创建时间")
private Date createTime;
/**
*
*/
@TableField(value = "updateTime")
@ApiModelProperty(value="更新时间")
private Date updateTime;
/**
* ID
*/
@TableField(value = "auditUser")
@ApiModelProperty(value="审核用户ID")
private String auditUser;
/**
*
*/
@TableField(value = "auditTime")
@ApiModelProperty(value="审核时间")
private Date auditTime;
/**
*
*/
@TableField(value = "`status`")
@ApiModelProperty(value="状态")
private Integer status;
/**
*
*/
@TableField(value = "remark")
@ApiModelProperty(value="备注字段")
private String remark;
/**
* 使 ,
*/
@TableField(value = "inOrderIds")
@ApiModelProperty(value="入库扫码单据号,多个使用 , 隔开")
private String inOrderIds;
/**
* 使 ,
*/
@TableField(value = "outOrderIds")
@ApiModelProperty(value="出库扫码单据号,多个使用 , 隔开")
private String outOrderIds;
/**
* 0 1 2
*/
@TableField(value = "countType")
@ApiModelProperty(value="盘点类型0整库盘点 1按货位盘点 2部分盘点")
private Integer countType;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,47 @@
package com.glxp.api.entity.inv;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*/
@ApiModel(value="com-glxp-api-entity-inv-InvCountSetting")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "inv_count_setting")
public class InvCountSettingEntity implements Serializable {
/**
* ID
*/
@TableId(value = "id", type = IdType.INPUT)
@ApiModelProperty(value="ID")
private Integer id;
/**
*
*/
@TableField(value = "inAction")
@ApiModelProperty(value="盘点入库转单类型")
private String inAction;
/**
*
*/
@TableField(value = "outAction")
@ApiModelProperty(value="盘点出库转单类型")
private String outAction;
private static final long serialVersionUID = 1L;
}

@ -17,7 +17,7 @@ public class FilterInvCountCodesRequest extends ListPageRequest {
/**
* ID
*/
private String relId;
private String productId;
/**
*

@ -0,0 +1,28 @@
package com.glxp.api.req.inv;
import com.glxp.api.entity.inv.InvCountCodesEntity;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
*
*/
@Data
public class FilterInvCountOrderSaveRequest {
/**
*
*/
@NotBlank(message = "盘点单号为空")
private String orderId;
/**
*
*/
@NotEmpty(message = "盘点产品不能为空")
private List<InvCountCodesEntity> countCodeList;
}

@ -0,0 +1,15 @@
package com.glxp.api.req.inv;
import com.glxp.api.util.page.ListPageRequest;
import lombok.Data;
/**
*
*/
@Data
public class FilterInvCountSettingRequest extends ListPageRequest {
private Integer id;
}

@ -4,6 +4,7 @@ import com.glxp.api.util.page.ListPageRequest;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@ -77,7 +78,7 @@ public class FilterInvProductDetailRequest extends ListPageRequest {
/**
*
*/
private String updateTime;
private Date updateTime;
/**
*

@ -1,77 +1,13 @@
package com.glxp.api.res.inv;
import com.glxp.api.entity.inv.InvCountOrderDetailEntity;
import lombok.Data;
/**
*
*/
@Data
public class InvCountOrderDetailResponse {
/**
* id
*/
private Integer id;
/**
*
*/
private String orderIdFk;
/**
* ID
*/
private Long relId;
/**
* DI
*/
private String nameCode;
/**
*
*/
private String batchNo;
/**
*
*/
private String produceDate;
/**
*
*/
private String expireDate;
/**
*
*/
private String serialNo;
/**
*
*/
private Integer countNum;
/**
*
*/
private Integer invNum;
/**
*
*/
private Integer profitNum;
/**
*
*/
private Integer lossNum;
/**
* 0 1
*/
private Integer status;
public class InvCountOrderDetailResponse extends InvCountOrderDetailEntity {
/**
*

@ -1,5 +1,6 @@
package com.glxp.api.res.inv;
import com.glxp.api.entity.inv.InvCountOrderEntity;
import lombok.Data;
import java.util.Date;
@ -8,106 +9,21 @@ import java.util.Date;
*
*/
@Data
public class InvCountOrderResponse {
public class InvCountOrderResponse extends InvCountOrderEntity {
/**
* id
*/
private Integer id;
/**
*
*/
private String orderId;
/**
*
*/
private String deptCode;
/**
*
*/
private String invCode;
/**
*
*/
private String invSpaceCode;
/**
* 使 ,
*/
private String inOrderIds;
/**
* 使 ,
*/
private String outOrderIds;
/**
* 0 1 2
*/
private Integer countType;
/**
* 0 1 2
*/
private Integer status;
/**
* ID
*/
private String createUser;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
* ID
*/
private String auditUser;
/**
*
*/
private Date auditTime;
/**
*
*/
private String remark;
/**
*
*
*/
private String deptName;
private String invStorageName;
/**
*
*
*/
private String invName;
private String invSubStorageName;
/**
*
*/
private String invSpaceName;
/**
*
*/
private String createUserName;
/**
*
*/
private String auditUserName;
}

@ -0,0 +1,22 @@
package com.glxp.api.res.inv;
import com.glxp.api.entity.inv.InvCountSettingEntity;
import lombok.Data;
/**
*
*/
@Data
public class InvCountSettingResponse extends InvCountSettingEntity {
/**
*
*/
private String inBusTypeName;
/**
*
*/
private String outBusTypeName;
}

@ -105,7 +105,7 @@ public class UdiRelevanceServiceImpl extends ServiceImpl<UdiRelevanceDao, UdiRel
@Override
public UdiRelevanceResponse selectByRelId(String relId) {
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
filterUdiRelRequest.setRelId(relId);
filterUdiRelRequest.setId(Long.parseLong(relId));
List<UdiRelevanceResponse> udiRelevanceResponses = filterUdiRelevance(filterUdiRelRequest);
if (CollUtil.isNotEmpty(udiRelevanceResponses)) {
return udiRelevanceResponses.get(0);

@ -0,0 +1,149 @@
package com.glxp.api.service.inv;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.dao.basic.UdiRelevanceDao;
import com.glxp.api.dao.inv.InvCountOrderDetailMapper;
import com.glxp.api.entity.basic.UdiEntity;
import com.glxp.api.entity.basic.UdiRelevanceEntity;
import com.glxp.api.entity.inv.InvCountOrderDetailEntity;
import com.glxp.api.req.basic.FilterUdiInfoRequest;
import com.glxp.api.req.basic.FilterUdiRelRequest;
import com.glxp.api.req.inv.FilterInvCountCodesRequest;
import com.glxp.api.res.basic.UdiRelevanceResponse;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.udi.FilterUdiUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.entity.inv.InvCountCodesEntity;
import com.glxp.api.dao.inv.InvCountCodesMapper;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class InvCountCodesService extends ServiceImpl<InvCountCodesMapper, InvCountCodesEntity> {
@Resource
private InvCountCodesMapper invCountCodesDao;
@Resource
private InvCountOrderDetailMapper invCountOrderDetailDao;
@Resource
private UdiRelevanceDao udiRelevanceDao;
public List<InvCountCodesEntity> filterList(FilterInvCountCodesRequest codesRequest) {
if (null == codesRequest) {
return Collections.emptyList();
}
if (null != codesRequest.getPage() && null != codesRequest.getLimit()) {
PageHelper.offsetPage((codesRequest.getPage() - 1) * codesRequest.getLimit(), codesRequest.getLimit());
}
return invCountCodesDao.filterList(codesRequest);
}
public BaseResponse deleteCode(FilterInvCountCodesRequest codesRequest) {
//查询盘点单据码详情
List<InvCountCodesEntity> list = invCountCodesDao.filterList(codesRequest);
if (CollUtil.isEmpty(list)) {
return ResultVOUtils.error(ResultEnum.DATA_NOT);
}
UdiEntity udi = FilterUdiUtils.getUdi(list.get(0).getCode());
InvCountOrderDetailEntity invCountOrderDetailEntity = invCountOrderDetailDao.selectOrderDetail(null, list.get(0).getOrderIdFk(), udi.getUdi(), udi.getBatchNo(), udi.getProduceDate(), udi.getExpireDate());
InvCountCodesEntity countCodes = list.get(0);
if (countCodes.getCount() == 1) {
//条码数量等于1删除条码
invCountCodesDao.deleteById(list.get(0).getId());
} else {
//条码数量大于1将条码数量 -1
countCodes.setCount(countCodes.getCount() - 1);
invCountCodesDao.updateById(countCodes);
}
//将此单据详情的盘点数量 - 1
invCountOrderDetailEntity.setCountNum(invCountOrderDetailEntity.getCountNum() - getActCount(udi.getUdi()));
invCountOrderDetailDao.updateById(invCountOrderDetailEntity);
return ResultVOUtils.success();
}
public BaseResponse addCode(InvCountCodesEntity invCountCodes) {
//解析条码
UdiEntity udi = FilterUdiUtils.getUdi(invCountCodes.getCode());
InvCountOrderDetailEntity invCountOrderDetailEntity = null;
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.selectGroupByNameCode(udi.getUdi(), false);
if (CollUtil.isNotEmpty(udiRelevanceEntities)) {
for (UdiRelevanceResponse udiRelevanceEntity : udiRelevanceEntities) {
invCountOrderDetailEntity = invCountOrderDetailDao.selectOrderDetail(udiRelevanceEntity.getId() + "", invCountCodes.getOrderIdFk(), null, udi.getBatchNo(), null, null);
}
}
//查询单据详情,是否包含此产品
if (null == invCountOrderDetailEntity) {
return ResultVOUtils.error(ResultEnum.DATA_NOT, "当前仓库或货位不存在此产品");
}
//判断条码是否重复
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
codesRequest.setOrderIdFk(invCountCodes.getOrderIdFk());
codesRequest.setCode(invCountCodes.getCode());
List<InvCountCodesEntity> codesList = invCountCodesDao.filterList(codesRequest);
if (CollUtil.isEmpty(codesList)) {
//新增条码
invCountCodes.setProductId(invCountOrderDetailEntity.getProductId());
invCountCodes.setBatchNo(udi.getBatchNo());
invCountCodes.setCount(1);
invCountCodesDao.insert(invCountCodes);
} else {
if (StrUtil.isNotBlank(udi.getBatchNo()) && StrUtil.isNotBlank(udi.getSerialNo())) {
//条码为标准条码,批次号和序列号都存在,条码重复
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "条码重复!");
} else if ((StrUtil.isBlank(udi.getBatchNo()) && StrUtil.isBlank(udi.getSerialNo()) || (StrUtil.isNotBlank(udi.getBatchNo()) && StrUtil.isBlank(udi.getSerialNo())))) {
//批次号或序列号,其中一个字段为空,直接修改数量
InvCountCodesEntity countCodes = codesList.get(0);
countCodes.setCount(countCodes.getCount() + 1);
invCountCodesDao.updateById(countCodes);
} else {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "条码重复!");
}
}
//修改码明细
invCountOrderDetailEntity.setCountNum(invCountOrderDetailEntity.getCountNum() + getActCount(udi.getUdi()));
invCountOrderDetailDao.updateById(invCountOrderDetailEntity);
return ResultVOUtils.success();
}
public Long getCountOrderCodesNum(String orderIdFk) {
return invCountCodesDao.countByOrderId(orderIdFk);
}
public int getActCount(String nameCode) {
FilterUdiRelRequest filterUdiInfoRequest = new FilterUdiRelRequest();
filterUdiInfoRequest.setNameCode(nameCode);
List<UdiRelevanceResponse> list = udiRelevanceDao.filterUdiRelevance(filterUdiInfoRequest);
UdiRelevanceResponse udiInfoBean = list.get(0);
if (udiInfoBean != null) {
if (IntUtil.value(udiInfoBean.getIsUseDy()) && udiInfoBean.getDiType() != 2) {
if (udiInfoBean.getBhzxxsbzsl() == 0)
return udiInfoBean.getZxxsbzbhsydysl();
else
return udiInfoBean.getZxxsbzbhsydysl() * udiInfoBean.getBhzxxsbzsl();
} else {
return udiInfoBean.getBhzxxsbzsl();
}
}
return 1;
}
}

@ -0,0 +1,77 @@
package com.glxp.api.service.inv;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.dao.inv.InvCountOrderMapper;
import com.glxp.api.dao.inv.InvProductDao;
import com.glxp.api.entity.inv.InvCountOrderEntity;
import com.glxp.api.entity.inv.InvProductEntity;
import com.glxp.api.req.inv.FilterInvCountOrderDetailRequest;
import com.glxp.api.res.inv.InvCountOrderDetailResponse;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.dao.inv.InvCountOrderDetailMapper;
import com.glxp.api.entity.inv.InvCountOrderDetailEntity;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class InvCountOrderDetailService extends ServiceImpl<InvCountOrderDetailMapper, InvCountOrderDetailEntity> {
@Resource
private InvCountOrderDetailMapper invCountOrderDetailDao;
@Resource
private InvCountOrderMapper invCountOrderDao;
@Resource
private InvProductDao invProductDao;
public List<InvCountOrderDetailEntity> filterList(FilterInvCountOrderDetailRequest detailRequest) {
if (null == detailRequest) {
return Collections.emptyList();
}
if (null != detailRequest.getPage() && null != detailRequest.getLimit()) {
PageHelper.offsetPage((detailRequest.getPage() - 1) * detailRequest.getLimit(), detailRequest.getLimit());
}
return invCountOrderDetailDao.filterList(detailRequest);
}
public List<InvCountOrderDetailResponse> filterCountDetail(FilterInvCountOrderDetailRequest detailRequest) {
if (null == detailRequest) {
return Collections.emptyList();
}
if (null != detailRequest.getPage() && null != detailRequest.getLimit()) {
PageHelper.offsetPage((detailRequest.getPage() - 1) * detailRequest.getLimit(), detailRequest.getLimit());
}
return invCountOrderDetailDao.filterCountDetail(detailRequest);
}
public BaseResponse deleteOrderDetail(FilterInvCountOrderDetailRequest detailRequest) {
InvCountOrderDetailEntity invCountOrderDetail = invCountOrderDetailDao.selectById(detailRequest.getId());
if (null == invCountOrderDetail) {
return ResultVOUtils.error(ResultEnum.DATA_NOT);
}
//删除盘点单据详情
invCountOrderDetailDao.deleteById(detailRequest.getId());
//删除盘点单据详情的条码数据
invCountOrderDetailDao.deleteByOrderIdAndProductId(invCountOrderDetail.getOrderIdFk(), invCountOrderDetail.getProductId());
return ResultVOUtils.success();
}
public BaseResponse addCountOrderDetail(InvCountOrderDetailEntity invCountOrderDetail) {
//查询单据信息
InvCountOrderEntity invCountOrder = invCountOrderDao.selectByOrderId(invCountOrderDetail.getOrderIdFk());
InvProductEntity invProductEntity = invProductDao.selectProductInfo(Long.parseLong(invCountOrderDetail.getProductId()), invCountOrderDetail.getBatchNo(), null, invCountOrder.getInvStorageCode(), invCountOrder.getInvWarehouseCode());
invCountOrderDetail.setInvNum(invProductEntity.getInCount() - invProductEntity.getOutCount());
invCountOrderDetail.setCountNum(0);
invCountOrderDetailDao.insert(invCountOrderDetail);
return ResultVOUtils.success();
}
}

@ -0,0 +1,669 @@
package com.glxp.api.service.inv;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.constant.ConstantType;
import com.glxp.api.dao.basic.BasicBussinessTypeDao;
import com.glxp.api.dao.basic.BasicCorpDao;
import com.glxp.api.dao.basic.CompanyProductRelevanceDao;
import com.glxp.api.dao.basic.UdiRelevanceDao;
import com.glxp.api.dao.inout.IoCodeDao;
import com.glxp.api.dao.inout.IoCodeTempDao;
import com.glxp.api.dao.inout.IoOrderDao;
import com.glxp.api.dao.inv.*;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
import com.glxp.api.entity.basic.BasicCorpEntity;
import com.glxp.api.entity.basic.UdiEntity;
import com.glxp.api.entity.inout.IoCodeEntity;
import com.glxp.api.entity.inout.IoCodeTempEntity;
import com.glxp.api.entity.inout.IoOrderEntity;
import com.glxp.api.entity.inv.*;
import com.glxp.api.req.basic.FilterUdiRelRequest;
import com.glxp.api.req.inv.*;
import com.glxp.api.res.basic.UdiRelevanceResponse;
import com.glxp.api.res.inv.InvCountOrderResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.basic.UdiRelevanceService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.OrderNoTypeBean;
import com.glxp.api.util.udi.FilterUdiUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCountOrderEntity> {
@Resource
private InvCountOrderMapper invCountOrderDao;
@Resource
private InvCountOrderDetailMapper invCountOrderDetailDao;
@Resource
private InvCountCodesMapper invCountCodesDao;
@Resource
private GennerOrderUtils gennerOrderUtils;
@Resource
private CustomerService customerService;
@Resource
private InvProductDetailDao invProductDetailDao;
@Resource
private InvCountSettingMapper invCountSettingDao;
@Resource
private BasicBussinessTypeDao bussinessTypeDao;
@Resource
private BasicCorpDao unitMaintainDao;
@Resource
private IoOrderDao orderDao;
@Resource
private IoCodeTempDao codesTempDao;
@Resource
private InvCountCodesService invCountCodesService;
@Resource
private IoCodeDao codesDao;
@Resource
private CompanyProductRelevanceDao companyProductRelevanceDao;
@Resource
private UdiRelevanceDao udiRelevanceDao;
@Resource
private UdiRelevanceService udiRelevanceService;
@Resource
private IBasicBussinessTypeService basicBussinessTypeService;
public List<InvCountOrderResponse> filterList(FilterInvCountOrderRequest filterInvCountOrderRequest) {
if (null == filterInvCountOrderRequest) {
return Collections.emptyList();
}
if (null != filterInvCountOrderRequest.getPage() && null != filterInvCountOrderRequest.getLimit()) {
PageHelper.offsetPage((filterInvCountOrderRequest.getPage() - 1) * filterInvCountOrderRequest.getLimit(), filterInvCountOrderRequest.getLimit());
}
return invCountOrderDao.selectList(filterInvCountOrderRequest);
}
public void deleteOrder(String id) {
String orderId = invCountOrderDao.selectOrderIdById(id);
log.info("开始删除盘点单据,盘点单号: {}", orderId);
invCountOrderDao.deleteByOrderId(orderId);
if (invCountOrderDetailDao.countByOrderIdFk(orderId) > 0) {
invCountOrderDetailDao.deleteByOrderId(orderId);
}
if (invCountCodesDao.countByOrderIdFk(orderId) > 0) {
invCountCodesDao.deleteByOrderId(orderId);
}
log.info("盘点单据删除完成");
}
public BaseResponse saveCountOrder(InvCountOrderEntity invCountOrder) {
if (invCountOrder.getCountType() == 0 || invCountOrder.getCountType() == 2) {
//整库盘点
if (StrUtil.isBlank(invCountOrder.getInvStorageCode()) || StrUtil.isBlank(invCountOrder.getInvWarehouseCode())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "请选择仓库信息!");
}
} else if (invCountOrder.getCountType() == 1) {
//货位盘点
if (StrUtil.isBlank(invCountOrder.getInvStorageCode()) || StrUtil.isBlank(invCountOrder.getInvWarehouseCode()) || StrUtil.isBlank(invCountOrder.getInvSpaceCode())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "请选择仓库和货位信息!");
}
}
//封装相关数据
//未提交
invCountOrder.setStatus(0);
if (StrUtil.isBlank(invCountOrder.getOrderId())) {
//生成单据号
String orderId = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.COUNT_ORDER, "yyyyMMdd"));
//盘点单号
invCountOrder.setOrderId(orderId);
AuthAdmin user = customerService.getUserBean();
invCountOrder.setCreateUser(user.getUserName());
invCountOrder.setCreateTime(new Date());
invCountOrder.setUpdateTime(new Date());
invCountOrderDao.insert(invCountOrder);
} else {
InvCountOrderEntity oldData = invCountOrderDao.selectByOrderId(invCountOrder.getOrderId());
BeanUtil.copyProperties(invCountOrder, oldData, "id", "createTime", "createUser");
oldData.setUpdateTime(new Date());
invCountOrderDao.updateByOrderId(oldData);
}
return ResultVOUtils.success(invCountOrder);
}
public BaseResponse submitAudit(String id) {
InvCountOrderEntity invCountOrder = invCountOrderDao.selectById(id);
if (null == invCountOrder) {
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "单据不存在");
}
if (invCountOrder.getStatus() != 0) {
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "单据已提交,请勿重复提交");
}
//查询单据详情和码表是否存在,如果无单据详情和条码,不允许提交
Long detailCount = invCountOrderDetailDao.countByOrderIdFk(invCountOrder.getOrderId());
if (detailCount == 0) {
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "请先选择盘点产品");
}
Long codesCount = invCountCodesDao.countByOrderIdFk(invCountOrder.getOrderId());
if (codesCount == 0) {
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "请扫描需要盘点的产品");
}
//更新状态
invCountOrder.setStatus(1);
invCountOrder.setUpdateTime(new Date());
//查询单据详情,计算盘点盈亏状态
List<InvCountOrderDetailEntity> detailList = invCountOrderDetailDao.selectByOrderId(invCountOrder.getOrderId());
for (InvCountOrderDetailEntity invCountOrderDetail : detailList) {
int diff = invCountOrderDetail.getInvNum() - invCountOrderDetail.getCountNum();
if (diff > 0) {
invCountOrderDetail.setLossNum(Math.abs(diff));
//盘亏
invCountOrderDetail.setStatus(0);
} else if (diff < 0) {
invCountOrderDetail.setProfitNum(Math.abs(diff));
//盘盈
invCountOrderDetail.setStatus(1);
} else {
//平衡
invCountOrderDetail.setStatus(2);
}
}
//更新单据信息
invCountOrderDao.updateByOrderId(invCountOrder);
//更新单据详情
invCountOrderDetailDao.updateBatchById(detailList);
return ResultVOUtils.success();
}
public BaseResponse updateCountOrderStatus(String id, Integer status) {
InvCountOrderEntity invCountOrder = invCountOrderDao.selectById(id);
invCountOrder.setStatus(status);
invCountOrder.setAuditUser(customerService.getUserBean().getUserName());
invCountOrder.setAuditTime(new Date());
invCountOrder.setUpdateTime(new Date());
if (status == 0) {
//审核不通过
//查询盘点单据详情,清空盘盈/盘亏数值
invCountOrderDetailDao.resetCountFiledValue(invCountOrder.getOrderId());
} else {
//审核通过
//根据单据详情生成相关单据
log.info("单据审核通过后将会生成对应盘盈盘亏单是否继续?,开始生成扫码单据");
// ThreadUtil.execAsync(() -> {
//
// });
countTransferOrder(invCountOrder);
}
invCountOrderDao.updateById(invCountOrder);
return ResultVOUtils.success();
}
public BaseResponse saveCountOrderForPDA(FilterInvCountOrderSaveRequest filterInvCountOrderSaveRequest) {
InvCountOrderEntity invCountOrder = invCountOrderDao.selectByOrderId(filterInvCountOrderSaveRequest.getOrderId());
if (null == invCountOrder) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "此单据不存在");
}
if (invCountOrder.getStatus() != 0) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "此单据不可编辑");
}
//解析条码,修改单据详情,修改单据状态为待审核
invCountOrder.setStatus(1);
invCountOrder.setUpdateTime(new Date());
List<InvCountCodesEntity> countCodeList = filterInvCountOrderSaveRequest.getCountCodeList();
for (InvCountCodesEntity invCountCodes : countCodeList) {
invCountCodesService.addCode(invCountCodes);
}
submitAudit(invCountOrder.getId().toString());
return ResultVOUtils.success();
}
/**
*
*/
private void countOrderTransfer(InvCountOrderEntity invCountOrder) {
List<InvCountSettingEntity> list = invCountSettingDao.filterList(null);
if (CollUtil.isEmpty(list)) {
log.error("未配置盘点单据设置参数,无法转单");
return;
}
//出入库码明细列表
List<IoCodeTempEntity> inOrderCodes = new ArrayList<>();
List<IoCodeTempEntity> outOrderCodes = new ArrayList<>();
/**
*
* 1
* 2 / =
* 3
*
* 1
* 2 / =
* 3
*/
//构造库存详情查询参数
FilterInvProductDetailRequest invProductDetailRequest = new FilterInvProductDetailRequest();
invProductDetailRequest.setInvCode(invCountOrder.getInvStorageCode());
invProductDetailRequest.setInvSpaceCode(invCountOrder.getInvWarehouseCode());
//库存早于或等于盘点时间的库存数据,锁库存
invProductDetailRequest.setUpdateTime(invCountOrder.getCreateTime());
if (invCountOrder.getCountType() == 1) {
//按照货位盘点,查询库存详情添加货位条件
invProductDetailRequest.setInvSpaceCode(invCountOrder.getInvSpaceCode());
}
FilterInvCountOrderDetailRequest detailRequest = new FilterInvCountOrderDetailRequest();
detailRequest.setOrderIdFk(invCountOrder.getOrderId());
//查询亏损单据详情
detailRequest.setStatus(0);
List<InvCountOrderDetailEntity> lossDetailList = invCountOrderDetailDao.selectDetailList(detailRequest);
if (CollUtil.isNotEmpty(lossDetailList)) {
log.info("开始生成盘亏单据码明细");
log.info("查询盘亏产品码详情");
for (InvCountOrderDetailEntity invCountOrderDetail : lossDetailList) {
//查询库存详情
invProductDetailRequest.setRelId(invCountOrderDetail.getProductId());
invProductDetailRequest.setBatchNo(invCountOrderDetail.getBatchNo());
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.filterInvProductDetailList(invProductDetailRequest);
//查询盘点码明细
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
codesRequest.setOrderIdFk(invCountOrder.getOrderId());
codesRequest.setProductId(invCountOrderDetail.getProductId());
codesRequest.setBatchNo(invCountOrderDetail.getBatchNo());
List<String> countCodesList = invCountCodesDao.selectCodes(codesRequest);
List<String> invProductCodes = invProductDetailEntities.stream().map(InvProductDetailEntity::getCode).collect(Collectors.toList());
List<String> lossCodes = CollUtil.subtractToList(invProductCodes, countCodesList);
if (CollUtil.isNotEmpty(countCodesList) && CollUtil.isEmpty(lossCodes)) {
//盘点的码不为空,但是盘点数量和库存数量不一样,比对差集结果为空,说明是同一个条码,数量不同,直接根据盘亏数量计算生成一个扫码单据的码明细
//生成码详情
IoCodeTempEntity warehouseEntity = buildWarehouse(invCountOrder, invProductDetailEntities.get(0).getCode(), invProductDetailEntities.get(0).getRelId());
//判断此条码,是否有批次号和序列号
UdiEntity udi = FilterUdiUtils.getUdi(invProductDetailEntities.get(0).getCode());
//修改码数量
int actCount = invCountCodesService.getActCount(udi.getUdi());
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
int codeNum = invCountOrderDetail.getLossNum() / actCount;
warehouseEntity.setCount(codeNum);
warehouseEntity.setReCount(codeNum);
//设置供应商信息
setSupInfo(warehouseEntity, "loss");
outOrderCodes.add(warehouseEntity);
} else {
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
if (!countCodesList.contains(invProductDetailEntity.getCode()) && !verifyCodeExist(outOrderCodes, invProductDetailEntity.getCode())) {
//生成码详情
IoCodeTempEntity warehouseEntity = buildWarehouse(invCountOrder, invProductDetailEntity.getCode(), invProductDetailEntity.getRelId());
//判断此条码,是否有批次号和序列号
UdiEntity udi = FilterUdiUtils.getUdi(invProductDetailEntity.getCode());
if ((StrUtil.isBlank(udi.getBatchNo()) && StrUtil.isBlank(udi.getSerialNo())) || (StrUtil.isBlank(udi.getSerialNo()) && StrUtil.isNotBlank(udi.getBatchNo()))) {
//修改码数量
int actCount = invCountCodesService.getActCount(udi.getUdi());
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
int codeNum = invCountOrderDetail.getLossNum() / actCount;
warehouseEntity.setCount(codeNum);
warehouseEntity.setReCount(codeNum);
} else {
//修改实际数量
int actCount = invCountCodesService.getActCount(udi.getUdi());
warehouseEntity.setCount(actCount);
warehouseEntity.setReCount(actCount);
}
//设置供应商信息
setSupInfo(warehouseEntity, "loss");
outOrderCodes.add(warehouseEntity);
}
}
}
}
log.info("盘亏单据码明细生成完毕");
}
//生成盘盈单据的条码
//查询盘盈的单据详情
detailRequest.setStatus(1);
List<InvCountOrderDetailEntity> profitDetailList = invCountOrderDetailDao.selectDetailList(detailRequest);
if (CollUtil.isNotEmpty(profitDetailList)) {
log.info("开始生成盘盈单据码.明细");
//查询盘盈产品的库存详情
for (InvCountOrderDetailEntity invCountOrderDetail : profitDetailList) {
//查询库存详情
invProductDetailRequest.setRelId(invCountOrderDetail.getProductId());
invProductDetailRequest.setBatchNo(invCountOrderDetail.getBatchNo());
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.filterInvProductDetailList(invProductDetailRequest);
//查询盘点码明细
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
codesRequest.setOrderIdFk(invCountOrder.getOrderId());
codesRequest.setProductId(invCountOrderDetail.getProductId());
codesRequest.setBatchNo(invCountOrderDetail.getBatchNo());
List<String> countCodesList = invCountCodesDao.selectCodes(codesRequest);
List<String> invProductCodeList = invProductDetailEntities.stream().map(InvProductDetailEntity::getCode).collect(Collectors.toList());
List<String> profitCodes = CollUtil.subtractToList(countCodesList, invProductCodeList); //计算盘盈的条码
log.info("查询盘盈产品的库存详情");
if (CollUtil.isNotEmpty(invProductCodeList) && CollUtil.isEmpty(profitCodes)) {
/**
*
*
*/
String code = null;
if (CollUtil.isNotEmpty(countCodesList)) {
code = countCodesList.get(0);
} else {
code = invProductCodeList.get(0);
}
IoCodeTempEntity warehouseEntity = buildWarehouse(invCountOrder, code, Long.parseLong(invCountOrderDetail.getProductId()));
//判断此条码,是否有批次号和序列号
UdiEntity udi = FilterUdiUtils.getUdi(code);
//修改码数量
int actCount = invCountCodesService.getActCount(udi.getUdi());
//使用此盘点单据详情的盘盈数量 / 实际数量,计算得出扫码数量
int codeNum = invCountOrderDetail.getProfitNum() / actCount;
warehouseEntity.setCount(codeNum);
warehouseEntity.setReCount(codeNum);
setSupInfo(warehouseEntity, "profit");
inOrderCodes.add(warehouseEntity);
log.info("添加库存条码");
} else {
for (String code : profitCodes) {
log.info("添加盘盈入库条码");
if (!verifyCodeExist(inOrderCodes, code)) {
//生成码详情
IoCodeTempEntity warehouseEntity = buildWarehouse(invCountOrder, code, Long.parseLong(invCountOrderDetail.getProductId()));
//判断此条码,是否有批次号和序列号
UdiEntity udi = FilterUdiUtils.getUdi(code);
if ((StrUtil.isBlank(udi.getBatchNo()) && StrUtil.isBlank(udi.getSerialNo())) || (StrUtil.isBlank(udi.getSerialNo()) && StrUtil.isNotBlank(udi.getBatchNo()))) {
//修改码数量
int actCount = invCountCodesService.getActCount(udi.getUdi());
//使用此盘点单据详情的盘盈数量 / 实际数量,计算得出扫码数量
int codeNum = invCountOrderDetail.getProfitNum() / actCount;
warehouseEntity.setCount(codeNum);
warehouseEntity.setReCount(codeNum);
} else {
//修改实际数量
int actCount = invCountCodesService.getActCount(udi.getUdi());
warehouseEntity.setCount(actCount);
warehouseEntity.setReCount(actCount);
}
setSupInfo(warehouseEntity, "profit");
inOrderCodes.add(warehouseEntity);
}
}
}
}
log.info("盘盈单据码详情生成完毕");
}
InvCountSettingEntity invCountSettingEntity = list.get(0);
if (CollUtil.isNotEmpty(inOrderCodes)) {
log.info("盘点单据:{} 生成盘盈入库单据", invCountOrder.getOrderId());
IoOrderEntity order = createOrder(invCountSettingEntity, invCountOrder, ConstantType.TYPE_PUT);
log.info("盘盈入库单据号:{}", order.getBillNo());
inOrderCodes.forEach(warehouseEntity -> {
warehouseEntity.setOrderId(order.getBillNo());
warehouseEntity.setAction(order.getAction());
warehouseEntity.setCorpOrderId(order.getCorpOrderId());
});
invCountOrder.setInOrderIds(order.getBillNo());
orderDao.insert(order);
codesTempDao.insertBatch(inOrderCodes);
log.info("盘盈入库单据生成成功");
}
if (CollUtil.isNotEmpty(outOrderCodes)) {
log.info("盘点单据:{} 生成盘亏入库单据", invCountOrder.getOrderId());
IoOrderEntity order = createOrder(invCountSettingEntity, invCountOrder, ConstantType.TYPE_OUT);
log.info("盘亏入库单据号:{}", order.getBillNo());
outOrderCodes.forEach(warehouseEntity -> {
warehouseEntity.setOrderId(order.getBillNo());
warehouseEntity.setAction(order.getAction());
warehouseEntity.setCorpOrderId(order.getCorpOrderId());
String supId = codesDao.selectSupIdByCode(warehouseEntity.getCode());
warehouseEntity.setSupId(supId);
});
invCountOrder.setOutOrderIds(order.getBillNo());
orderDao.insert(order);
codesTempDao.insertBatch(outOrderCodes);
log.info("盘亏入库单据生成成功");
}
//更新盘点单据生成的扫码单据号
invCountOrderDao.updateByOrderId(invCountOrder);
}
/**
*
*/
private void countTransferOrder(InvCountOrderEntity invCountOrder) {
List<InvCountSettingEntity> list = invCountSettingDao.filterList(null);
if (CollUtil.isEmpty(list)) {
log.error("未配置盘点单据设置参数,无法转单");
return;
}
InvCountSettingEntity invCountSettingEntity = list.get(0);
List<InvCountOrderDetailEntity> orderDetailList = invCountOrderDetailDao.selectByOrderId(invCountOrder.getOrderId());
List<IoCodeTempEntity> lossCodesList = new ArrayList<>();
List<IoCodeTempEntity> profitCodesList = new ArrayList<>();
if (CollUtil.isNotEmpty(orderDetailList)) {
for (InvCountOrderDetailEntity invCountOrderDetail : orderDetailList) {
if (IntUtil.value(invCountOrderDetail.getLossNum()) > 0) {
IoCodeTempEntity warehouseEntity = buildCodeEntity(invCountOrderDetail, invCountOrder, ConstantType.TYPE_OUT);
warehouseEntity.setSupId(getSupId(warehouseEntity));
lossCodesList.add(warehouseEntity);
}
if (IntUtil.value(invCountOrderDetail.getProfitNum()) > 0) {
IoCodeTempEntity warehouseEntity = buildCodeEntity(invCountOrderDetail, invCountOrder, ConstantType.TYPE_PUT);
warehouseEntity.setSupId(getSupId(warehouseEntity));
profitCodesList.add(warehouseEntity);
}
}
}
//生成盘亏出库单
if (CollUtil.isNotEmpty(lossCodesList)) {
IoOrderEntity order = createOrder(invCountSettingEntity, invCountOrder, ConstantType.TYPE_OUT);
lossCodesList.forEach(warehouseEntity -> {
warehouseEntity.setOrderId(order.getBillNo());
warehouseEntity.setAction(order.getAction());
warehouseEntity.setCorpOrderId(order.getCorpOrderId());
});
orderDao.insert(order);
codesTempDao.insertBatch(lossCodesList);
}
//生成盘盈入库单
if (CollUtil.isNotEmpty(profitCodesList)) {
IoOrderEntity order = createOrder(invCountSettingEntity, invCountOrder, ConstantType.TYPE_PUT);
profitCodesList.forEach(warehouseEntity -> {
warehouseEntity.setOrderId(order.getBillNo());
warehouseEntity.setAction(order.getAction());
warehouseEntity.setCorpOrderId(order.getCorpOrderId());
});
orderDao.insert(order);
codesTempDao.insertBatch(profitCodesList);
}
}
private IoCodeTempEntity buildCodeEntity(InvCountOrderDetailEntity invCountOrderDetail, InvCountOrderEntity invCountOrder, String mainAction) {
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
filterUdiRelRequest.setId(Long.parseLong(invCountOrderDetail.getProductId()));
List<UdiRelevanceResponse> udiRelevanceResponses = udiRelevanceDao.filterUdiRelevance(filterUdiRelRequest);
String code = FilterUdiUtils.transGlxpNoSerStr(udiRelevanceResponses, invCountOrderDetail);
IoCodeTempEntity warehouseEntity = new IoCodeTempEntity();
warehouseEntity.setOrderId(invCountOrder.getOrderId());
warehouseEntity.setCode(code);
warehouseEntity.setRelId(Long.parseLong(invCountOrderDetail.getProductId()));
warehouseEntity.setMainAction(mainAction);
warehouseEntity.setInvCode(invCountOrder.getInvStorageCode());
warehouseEntity.setWarehouseCode(invCountOrder.getInvWarehouseCode());
UdiEntity udi = FilterUdiUtils.getUdi(code);
warehouseEntity.setBatchNo(udi.getBatchNo());
warehouseEntity.setProduceDate(udi.getProduceDate());
warehouseEntity.setExpireDate(udi.getExpireDate());
warehouseEntity.setSerialNo(udi.getSerialNo());
warehouseEntity.setNameCode(udi.getUdi());
if (mainAction.equals(ConstantType.TYPE_PUT)) {
warehouseEntity.setCount(invCountOrderDetail.getProfitNum());
warehouseEntity.setReCount(invCountOrderDetail.getProfitNum());
} else {
warehouseEntity.setCount(invCountOrderDetail.getLossNum());
warehouseEntity.setReCount(invCountOrderDetail.getLossNum());
}
return warehouseEntity;
}
/**
*
*
* @param warehouseEntity
* @param countStatus
*/
private void setSupInfo(IoCodeTempEntity warehouseEntity, String countStatus) {
/**
* 使
*
* ID
*
* 1
*/
if (countStatus.equals("loss")) {
log.info("生成盘亏单据条码供应商详情,条码信息:{}", warehouseEntity.getCode());
List<String> supIds = invProductDetailDao.selectSupIdByCode(warehouseEntity.getCode());
if (CollUtil.isNotEmpty(supIds)) {
if (supIds.size() == 1) {
//此产品只绑定了一个供应商若绑定了多个供应商则不填供应商ID字段生成单据之后会进入异常单据页面手动指定供应商
warehouseEntity.setSupId(supIds.get(0));
}
}
} else {
log.info("生成盘盈单据条码供应商详情,条码信息:{}", warehouseEntity.getCode());
List<String> unitFkList = companyProductRelevanceDao.selectUnitFkByUdiRlIdFk(warehouseEntity.getRelId() + "");
if (CollUtil.isNotEmpty(unitFkList)) {
if (unitFkList.size() == 1) {
//此产品只绑定了一个供应商若绑定了多个供应商则不填供应商ID字段生成单据之后会进入异常单据页面手动指定供应商
warehouseEntity.setSupId(unitFkList.get(0));
}
}
}
}
/**
*
*
* @param codes
* @param code
* @return
*/
private boolean verifyCodeExist(List<IoCodeTempEntity> codes, String code) {
for (IoCodeTempEntity warehouseEntity : codes) {
if (warehouseEntity.getCode().equals(code)) {
return true;
}
}
return false;
}
private static IoCodeTempEntity buildWarehouse(InvCountOrderEntity invCountOrder, String code, Long productId) {
IoCodeTempEntity warehouseEntity = new IoCodeTempEntity();
warehouseEntity.setOrderId(invCountOrder.getOrderId());
warehouseEntity.setCode(code);
warehouseEntity.setRelId(productId);
warehouseEntity.setMainAction(ConstantType.TYPE_PUT);
warehouseEntity.setInvCode(invCountOrder.getInvStorageCode());
warehouseEntity.setWarehouseCode(invCountOrder.getInvWarehouseCode());
UdiEntity udi = FilterUdiUtils.getUdi(code);
warehouseEntity.setBatchNo(udi.getBatchNo());
warehouseEntity.setProduceDate(udi.getProduceDate());
warehouseEntity.setExpireDate(udi.getExpireDate());
warehouseEntity.setSerialNo(udi.getSerialNo());
warehouseEntity.setNameCode(udi.getUdi());
warehouseEntity.setCount(1);
warehouseEntity.setReCount(1);
return warehouseEntity;
}
/**
*
*
* @param invCountSettingEntity
* @param invCountOrder
* @param type
* @return
*/
public IoOrderEntity createOrder(InvCountSettingEntity invCountSettingEntity, InvCountOrderEntity invCountOrder, String type) {
BasicBussinessTypeEntity bussinessTypeEntity;
if (ConstantType.TYPE_PUT.equals(type)) {
bussinessTypeEntity = basicBussinessTypeService.findByAction(invCountSettingEntity.getInAction());
} else {
bussinessTypeEntity = basicBussinessTypeService.findByAction(invCountSettingEntity.getOutAction());
}
//构造单据数据
IoOrderEntity orderEntity = new IoOrderEntity();
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
orderEntity.setAction(bussinessTypeEntity.getAction());
orderEntity.setCreateTime(new Date());
orderEntity.setInvCode(invCountOrder.getInvStorageCode());
//查询单据往来单位数据
BasicCorpEntity unitMaintainEntity = unitMaintainDao.selectByErpId(bussinessTypeEntity.getDefaultUnit());
orderEntity.setFromCorp(unitMaintainEntity.getErpId());
orderEntity.setCorpOrderId(CustomUtil.getId() + "x");
orderEntity.setExportStatus(0); //设置导出状态为未导出
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESS);
orderEntity.setFromType(ConstantStatus.FROM_COUNT); //单据来源设置为盘点单据转单
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trim(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
orderEntity.setBillNo(orderNo);
return orderEntity;
}
private String getSupId(IoCodeTempEntity warehouseEntity) {
List<String> supIds = companyProductRelevanceDao.selectUnitFkByUdiRlIdFk(warehouseEntity.getRelId() + "");
if (CollUtil.isNotEmpty(supIds) && supIds.size() == 1) {
return supIds.get(0);
}
return null;
}
}

@ -0,0 +1,96 @@
package com.glxp.api.service.inv;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.dao.basic.BasicBussinessTypeDao;
import com.glxp.api.req.inv.FilterInvCountSettingRequest;
import com.glxp.api.res.inv.InvCountSettingResponse;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.entity.inv.InvCountSettingEntity;
import com.glxp.api.dao.inv.InvCountSettingMapper;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Service
public class InvCountSettingService extends ServiceImpl<InvCountSettingMapper, InvCountSettingEntity> {
@Resource
private InvCountSettingMapper invCountSettingDao;
@Resource
private BasicBussinessTypeDao bussinessTypeDao;
public List<InvCountSettingResponse> filterList(FilterInvCountSettingRequest settingRequest) {
if (null == settingRequest) {
return Collections.emptyList();
}
if (null != settingRequest.getPage() && null != settingRequest.getLimit()) {
PageHelper.offsetPage((settingRequest.getPage() - 1) * settingRequest.getLimit(), settingRequest.getLimit());
}
List<InvCountSettingEntity> list = invCountSettingDao.filterList(settingRequest);
if (CollUtil.isNotEmpty(list)) {
List<InvCountSettingResponse> result = new ArrayList<>(list.size());
for (InvCountSettingEntity invCountSettingEntity : list) {
InvCountSettingResponse response = new InvCountSettingResponse();
BeanUtil.copyProperties(invCountSettingEntity, response);
//查询单据类型名称
response.setInBusTypeName(bussinessTypeDao.selectNameByAction(invCountSettingEntity.getInAction()));
response.setOutBusTypeName(bussinessTypeDao.selectNameByAction(invCountSettingEntity.getOutAction()));
result.add(response);
}
return result;
}
return Collections.emptyList();
}
public BaseResponse updateCountSetting(InvCountSettingEntity invCountSettingEntity) {
if (StrUtil.isBlank(invCountSettingEntity.getInAction()) || StrUtil.isBlank(invCountSettingEntity.getOutAction())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
invCountSettingDao.updateById(invCountSettingEntity);
return ResultVOUtils.success();
}
public BaseResponse addCountSetting(InvCountSettingEntity invCountSettingEntity) {
if (existSetting()) {
return ResultVOUtils.error(ResultEnum.DATA_REPEAT, "已存在盘点参数");
}
if (StrUtil.isBlank(invCountSettingEntity.getInAction()) || StrUtil.isBlank(invCountSettingEntity.getOutAction())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
invCountSettingDao.insert(invCountSettingEntity);
return ResultVOUtils.success();
}
public boolean verifyAdd() {
if (existSetting()) {
return false;
}
return true;
}
/**
*
*
* @return
*/
public boolean existSetting() {
Long count = invCountSettingDao.countSetting();
if (count == null || count < 1) {
//未配置设置
return false;
}
return true;
}
}

@ -2,13 +2,18 @@ package com.glxp.api.util.udi;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.entity.basic.UdiEntity;
import com.glxp.api.entity.basic.UdiProductEntity;
import com.glxp.api.entity.inv.InvCountOrderDetailEntity;
import com.glxp.api.res.basic.UdiRelevanceResponse;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.gs1.AI;
import com.glxp.api.util.gs1.AIs;
import com.glxp.api.util.gs1.Gs1128Decoder;
import com.glxp.api.util.gs1.Gs1128Engine;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -200,4 +205,33 @@ public class FilterUdiUtils {
+ "#" + Optional.ofNullable(warehouseEntity.getSerialNo()).orElse("") + "#" + "#";
return udiCode;
}
public static String transGlxpNoSerStr(List<UdiRelevanceResponse> udiRelevanceResponses, InvCountOrderDetailEntity invCountOrderDetail) {
UdiRelevanceResponse udiRelevanceResponse = getMinDi(udiRelevanceResponses);
String udiCode = "#" + udiRelevanceResponse.getNameCode() + "#" + invCountOrderDetail.getProduceDate() + "#" + invCountOrderDetail.getExpireDate() +
"#" + invCountOrderDetail.getBatchNo() + "#" + "#" + "#";
return udiCode;
}
public static UdiRelevanceResponse getMinDi(List<UdiRelevanceResponse> udiRelevanceResponses) {
if (udiRelevanceResponses.size() > 1) {
for (UdiRelevanceResponse temp : udiRelevanceResponses) {
if (IntUtil.value(temp.getIsUseDy())) {
if (temp.getDiType() == ConstantStatus.DITYPE_SYDY) {
return temp;
}
} else {
if (temp.getDiType() == ConstantStatus.DITYPE_MAIN) {
return temp;
}
}
}
}
return udiRelevanceResponses.get(0);
}
}

@ -25,15 +25,15 @@
parameterType="com.glxp.api.entity.basic.CompanyProductRelevanceEntity">
replace
INTO company_product_relevance(id, customerId, productId, enterpriseId, registrationId,
create_time, update_time, auditStatus, productUuid, udiRlIdFk, unitFk,
createTime, updateTime, auditStatus, productUuid, udiRlIdFk, unitFk,
price)
values (#{id},
#{customerId},
#{productId},
#{enterpriseId},
#{registrationId},
#{create_time},
#{update_time},
#{createTime},
#{updateTime},
#{auditStatus},
#{productUuid},
#{udiRlIdFk},
@ -96,7 +96,7 @@
basic_products.sjcpbm,
basic_products.versionNumber,
basic_products.diType,
customer_info.companyName,
basic_corp.name companyName,
basic_udirel.mainId,
basic_udirel.isAdavence,
basic_products.scbssfbhph,
@ -119,7 +119,7 @@
FROM company_product_relevance
INNER JOIN basic_udirel ON company_product_relevance.udiRlIdFk = basic_udirel.id
INNER JOIN basic_products ON basic_udirel.uuid = basic_products.uuid
INNER JOIN customer_info ON customer_info.customerId = company_product_relevance.customerId
INNER JOIN basic_corp ON basic_corp.erpId = company_product_relevance.customerId
<where>
<if test="ylqxzcrbarmc != '' and ylqxzcrbarmc != null">
AND ylqxzcrbarmc LIKE concat(#{ylqxzcrbarmc}, '%')
@ -203,7 +203,7 @@
AND basic_udirel.id = #{id}
</if>
<if test="companyName != '' and companyName != null">
AND customer_info.companyName = #{companyName}
AND basic_corp.name = #{companyName}
</if>
<if test="lockStatus != '' and lockStatus != null">
AND basic_udirel.lockStatus = #{lockStatus}
@ -223,4 +223,12 @@
</where>
ORDER BY company_product_relevance.updateTime DESC
</select>
<select id="selectUnitFkByUdiRlIdFk" resultType="java.lang.String">
select unitFk
from company_product_relevance
where udiRlIdFk = #{udiRlIdFk}
group by unitFk
</select>
</mapper>

@ -128,4 +128,12 @@
</where>
group by ic.id
</select>
<select id="selectSupIdByCode" resultType="java.lang.String">
select supId
from io_code
where code = #{code}
limit 1
</select>
</mapper>

@ -663,4 +663,5 @@
</otherwise>
</choose>
</select>
</mapper>

@ -0,0 +1,97 @@
<?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.glxp.api.dao.inv.InvCountCodesMapper">
<resultMap id="BaseResultMap" type="com.glxp.api.entity.inv.InvCountCodesEntity">
<!--@mbg.generated-->
<!--@Table inv_count_codes-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="orderIdFk" jdbcType="VARCHAR" property="orderIdFk"/>
<result column="productId" jdbcType="VARCHAR" property="productId"/>
<result column="code" jdbcType="VARCHAR" property="code"/>
<result column="status" jdbcType="BOOLEAN" property="status"/>
<result column="batchNo" jdbcType="VARCHAR" property="batchNo"/>
<result column="count" jdbcType="INTEGER" property="count"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, orderIdFk, productId, code, `status`, batchNo, `count`
</sql>
<delete id="deleteByOrderId">
delete
from inv_count_codes
where orderIdFk = #{orderId}
</delete>
<select id="filterList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from inv_count_codes
<where>
<if test="orderIdFk != null and orderIdFk != ''">
AND orderIdFk = #{orderIdFk}
</if>
<if test="productId != null and productId != ''">
AND productId = #{productId}
</if>
<if test="code != null and code != ''">
AND code like concat('%', #{code}, '%')
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
</where>
</select>
<select id="countByOrderIdFk" resultType="java.lang.Long">
select count(*)
from inv_count_codes
where orderIdFk = #{orderIdFk}
</select>
<select id="countByOrderId" resultType="java.lang.Long">
select sum(count)
from inv_count_codes
where orderIdFk = #{orderIdFk}
</select>
<select id="selectCountByCodeAndOrderId" resultType="java.lang.Long">
select count(*)
from inv_count_codes
where orderIdFk = #{orderIdFk}
and code = #{code}
</select>
<update id="resetCountFiledValue">
update inv_count_codes
set status = null
where orderIdFk = #{orderId}
</update>
<select id="selectByOrderIdAndProductId" resultMap="BaseResultMap">
select *
from inv_count_codes
where orderIdFk = #{orderIdFk}
and productId = #{productId}
</select>
<select id="selectCodes" resultType="java.lang.String">
select code
from inv_count_codes
<where>
<if test="orderIdFk != null and orderIdFk != ''">
AND orderIdFk = #{orderIdFk}
</if>
<if test="productId != null and productId != ''">
AND productId = #{productId}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
</where>
</select>
</mapper>

@ -0,0 +1,117 @@
<?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.glxp.api.dao.inv.InvCountOrderDetailMapper">
<resultMap id="BaseResultMap" type="com.glxp.api.entity.inv.InvCountOrderDetailEntity">
<!--@mbg.generated-->
<!--@Table inv_count_order_detail-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="orderIdFk" jdbcType="VARCHAR" property="orderIdFk"/>
<result column="productId" jdbcType="VARCHAR" property="productId"/>
<result column="nameCode" jdbcType="VARCHAR" property="nameCode"/>
<result column="batchNo" jdbcType="VARCHAR" property="batchNo"/>
<result column="produceDate" jdbcType="VARCHAR" property="produceDate"/>
<result column="expireDate" jdbcType="VARCHAR" property="expireDate"/>
<result column="serialNo" jdbcType="VARCHAR" property="serialNo"/>
<result column="countNum" jdbcType="INTEGER" property="countNum"/>
<result column="invNum" jdbcType="INTEGER" property="invNum"/>
<result column="profitNum" jdbcType="INTEGER" property="profitNum"/>
<result column="lossNum" jdbcType="INTEGER" property="lossNum"/>
<result column="status" jdbcType="BOOLEAN" property="status"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, orderIdFk, productId, nameCode, batchNo, produceDate, expireDate, serialNo, countNum,
invNum, profitNum, lossNum, `status`
</sql>
<delete id="deleteByOrderId">
delete
from inv_count_order_detail
where orderIdFk = #{orderId}
</delete>
<select id="filterList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from inv_count_order_detail
where orderIdFk = #{orderIdFk}
</select>
<select id="countByOrderIdFk" resultType="java.lang.Long">
select count(*)
from inv_count_order_detail
where orderIdFk = #{orderIdFk}
</select>
<select id="filterCountDetail" resultType="com.glxp.api.res.inv.InvCountOrderDetailResponse">
select od.*, ip.productsName productName, ip.ggxh, ip.ylqxzcrbarmc, ip.zczbhhzbapzbh
from inv_count_order_detail od
left join inv_count_order ico on od.orderIdFk = ico.orderId
left join inv_product ip on od.productId = ip.relIdFk
where od.orderIdFk = #{orderIdFk}
and ip.invStorageCode = ico.invStorageCode
and ip.invWarehouseCode = ico.invWarehouseCode
group by od.id
</select>
<delete id="deleteByOrderIdAndProductId">
delete
from inv_count_codes
where orderIdFk = #{orderIdFk}
and productId = #{productId}
</delete>
<select id="selectOrderDetail" resultMap="BaseResultMap">
select *
from inv_count_order_detail
<where>
<if test="productId != null and productId != ''">
AND productId = #{productId}
</if>
<if test="nameCode != null and nameCode != ''">
AND nameCode = #{nameCode}
</if>
<if test="orderIdFk != null and orderIdFk != ''">
AND orderIdFk = #{orderIdFk}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="produceDate != null and produceDate != ''">
AND produceDate = #{produceDate}
</if>
<if test="expireDate != null and expireDate != ''">
AND expireDate = #{expireDate}
</if>
</where>
</select>
<select id="selectByOrderId" resultMap="BaseResultMap">
select *
from inv_count_order_detail
where orderIdFk = #{orderId}
</select>
<update id="resetCountFiledValue">
update inv_count_order_detail
set profitNum = null,
lossNum = null,
status = null
where orderIdFk = #{orderId}
</update>
<select id="selectDetailList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from inv_count_order_detail
<where>
<if test="orderIdFk != null and orderIdFk != ''">
AND orderIdFk = #{orderIdFk}
</if>
<if test="status != null">
AND status = #{status}
</if>
</where>
</select>
</mapper>

@ -0,0 +1,120 @@
<?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.glxp.api.dao.inv.InvCountOrderMapper">
<resultMap id="BaseResultMap" type="com.glxp.api.entity.inv.InvCountOrderEntity">
<!--@mbg.generated-->
<!--@Table inv_count_order-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="orderId" jdbcType="VARCHAR" property="orderId"/>
<result column="invStorageCode" jdbcType="VARCHAR" property="invStorageCode"/>
<result column="invWarehouseCode" jdbcType="VARCHAR" property="invWarehouseCode"/>
<result column="invSpaceCode" jdbcType="VARCHAR" property="invSpaceCode"/>
<result column="createUser" jdbcType="VARCHAR" property="createUser"/>
<result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
<result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="auditUser" jdbcType="VARCHAR" property="auditUser"/>
<result column="auditTime" jdbcType="TIMESTAMP" property="auditTime"/>
<result column="status" jdbcType="BOOLEAN" property="status"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="inOrderIds" jdbcType="VARCHAR" property="inOrderIds"/>
<result column="outOrderIds" jdbcType="VARCHAR" property="outOrderIds"/>
<result column="countType" jdbcType="BOOLEAN" property="countType"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, orderId, invStorageCode, invWarehouseCode, invSpaceCode, `createUser`, createTime,
updateTime, auditUser, auditTime, `status`, remark, inOrderIds, outOrderIds, countType
</sql>
<select id="selectList" resultType="com.glxp.api.res.inv.InvCountOrderResponse">
select co.id,
co.orderId,
co.invStorageCode,
co.invWarehouseCode,
co.invSpaceCode,
co.createUser,
co.createTime,
co.updateTime,
co.auditUser,
co.auditTime,
co.status,
co.remark,
co.inOrderIds,
co.outOrderIds,
co.countType,
ws.name as invStorageName,
sp.name as invSpaceName
from inv_count_order co
left join auth_warehouse ws on co.invWarehouseCode = ws.code
left join auth_space sp on co.invSpaceCode = sp.code
<where>
<if test="invCode != null and invCode != ''">
AND co.invStorageCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND co.invSpaceCode = #{invSpaceCode}
</if>
<if test="status != null">
AND co.status = #{status}
</if>
<if test="orderId != null and orderId != ''">
AND co.orderId like concat('%', #{orderId}, '%')
</if>
</where>
group by co.orderId
order by updateTime desc
</select>
<select id="selectOrderIdById" resultType="java.lang.String">
select orderId
from inv_count_order
where id = #{id}
</select>
<select id="countBySpaceCode" resultType="java.lang.Integer">
select count(*)
from inv_count_order
<where>
<if test="invStorageCode != null and invStorageCode != ''">
AND invStorageCode = #{invStorageCode}
</if>
<if test="invWarehouseCode != null and invWarehouseCode != ''">
AND invWarehouseCode = #{invWarehouseCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND invSpaceCode = #{invSpaceCode}
</if>
</where>
</select>
<update id="updateByOrderId">
update inv_count_order
set invStorageCode = #{invStorageCode,jdbcType=VARCHAR},
invWarehouseCode = #{invWarehouseCode,jdbcType=VARCHAR},
invSpaceCode = #{invSpaceCode,jdbcType=VARCHAR},
`createUser` = #{createUser,jdbcType=VARCHAR},
createTime = #{createTime,jdbcType=TIMESTAMP},
updateTime = #{updateTime,jdbcType=TIMESTAMP},
auditUser = #{auditUser,jdbcType=VARCHAR},
auditTime = #{auditTime,jdbcType=TIMESTAMP},
`status` = #{status,jdbcType=BOOLEAN},
remark = #{remark,jdbcType=VARCHAR},
inOrderIds = #{inOrderIds,jdbcType=VARCHAR},
outOrderIds = #{outOrderIds,jdbcType=VARCHAR},
countType = #{countType,jdbcType=INTEGER}
where orderId = #{orderId}
</update>
<select id="selectByOrderId" resultMap="BaseResultMap">
select *
from inv_count_order
where orderId = #{orderId}
</select>
<delete id="deleteByOrderId">
delete
from inv_count_order
where orderId = #{orderId}
</delete>
</mapper>

@ -0,0 +1,32 @@
<?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.glxp.api.dao.inv.InvCountSettingMapper">
<resultMap id="BaseResultMap" type="com.glxp.api.entity.inv.InvCountSettingEntity">
<!--@mbg.generated-->
<!--@Table inv_count_setting-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="inAction" jdbcType="VARCHAR" property="inAction"/>
<result column="outAction" jdbcType="VARCHAR" property="outAction"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, inAction, outAction
</sql>
<select id="filterList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from inv_count_setting
<where>
<if test="id != null">
AND id = #{id}
</if>
</where>
</select>
<select id="countSetting" resultType="java.lang.Long">
select count(*)
from inv_count_setting
</select>
</mapper>
Loading…
Cancel
Save