Commit c732a3a6 by 李小惠

出入库记录

parent df79006a
package com.junmp.jyzb.api.bean.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class InOutRecordsDto implements Serializable {
//序号
private String Id;
//操作人员
private String userName;
// 存储名称
private String locationName;
//出入库时间
private Date useTime;
// 出入库状态
private String outInState;
}
package com.junmp.jyzb.api.bean.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
......@@ -11,50 +8,93 @@ import java.util.Date;
@Data
public class LogDetailDto implements Serializable {
/**
* 出入库明细ID
*/
private Integer id;
/**
* 物资id
*/
@ApiModelProperty(value = "物资id")
private String inventoryId;
/**
* 出入库汇总ID
*/
private Integer summaryId;
/**
* 单据ID
*/
@ApiModelProperty(value = "单据ID")
private String orderMainId;
/**
* EPC信息
*/
@ApiModelProperty(value = "EPC信息")
private String epc;
/**
* 装备名称
*/
@ApiModelProperty(value = "装备名称")
private String equipmentName;
/**
* 装备号型
*/
@ApiModelProperty(value = "装备号型")
private String equipmentSize;
/**
* 供应商
*/
@ApiModelProperty(value = "供应商")
private String equipmentSupplier;
/**
* 装备类型:0单件/1装备包
*/
@ApiModelProperty(value = "装备类型:0单件/1装备包")
private Integer equipmentType;
/**
* 状态,0正常/1异常
*/
@ApiModelProperty(value = "状态,0正常/1异常")
private Integer errorState;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人员
*/
private String updateUser;
/**
* 创建人员
*/
private String createUser;
/**
* 照片信息
*/
private String picture;
/**
* 作业设备:0手持机 1单警柜 2通道)
*/
private Integer deviceType;
/**
* 存储ID
*/
private String locationId;
/**
* 存储名称:XX仓库,XX单警柜
*/
private String locationName;
}
package com.junmp.jyzb.api.bean.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
......@@ -13,87 +9,97 @@ import java.util.List;
public class LogSummaryDto implements Serializable {
/**
* 出入库汇总ID
*/
private Integer id;
/**
* 组织机构ID
*/
@ApiModelProperty(value = "组织机构ID")
private String orgId;
private Long orgId;
/**
* 组织机构名称
*/
@ApiModelProperty(value = "组织机构名称")
private String orgName;
/**
* 单据id
*/
@ApiModelProperty(value = "单据id")
private String orderMainId;
/**
* 存储ID
*/
@ApiModelProperty(value = "存储ID")
private String locationId;
/**
* 存储名称:XX仓库,XX单警柜
*/
@ApiModelProperty(value = "存储名称")
private String locationName;
/**
* 设备标识
*/
@ApiModelProperty(value = "设备标识")
private String device;
/**
* 出入设备:0手持机/1单警柜/2通道
*/
@ApiModelProperty(value = "出入设备:0手持机/1单警柜/2通道")
private Integer deviceType;
/**
* 操作时间
*/
@ApiModelProperty(value = "操作时间")
private Date useTime;
/**
* 业务类型
*/
@ApiModelProperty(value = "业务类型")
private String bussinessType;
/**
* 操作人员姓名
*/
@ApiModelProperty(value = "操作人员姓名")
private String userName;
/**
* 出入库类型:0出库/1入库
*/
@ApiModelProperty(value = "出入库类型:0出库/1入库")
private Integer outInState;
/**
* 照片信息
*/
@ApiModelProperty(value = "照片信息")
private String picture;
/**
* 装备记录集合,警棍、盾牌
*/
@ApiModelProperty(value = "装备记录集合")
private String equipments;
private String equipmentList;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人员
*/
private String updateUser;
/**
* 创建人员
*/
private String createUser;
/**
* 装备详细信息
*/
@ApiModelProperty(value = "装备详细信息")
private List<LogDetailDto> equipmentList;
private List<LogDetailDto> logList;
}
......@@ -27,6 +27,8 @@ public class OrderDetailDto implements Serializable {
private String warehouseId;
private String warehouseName;
/**
* 计划数量
*/
......
......@@ -32,6 +32,10 @@ public class InventoryReq extends BaseRequest {
*/
private String typeId;
/**
* 装备类型名称
*/
private String typeName;
/**
* 装备号型ID
*/
private String sizeId;
......
package com.junmp.jyzb.api.bean.query;
import lombok.Data;
import java.util.Date;
@Data
public class LogDetailReq {
/**
* 出入库明细ID
*/
private Integer id;
/**
* 物资id
*/
private String inventoryId;
/**
* 出入库汇总ID
*/
private Integer summaryId;
/**
* 单据ID
*/
private String orderMainId;
/**
* EPC信息
*/
private String epc;
/**
* 装备名称
*/
private String equipmentName;
/**
* 装备号型
*/
private String equipmentSize;
/**
* 供应商
*/
private String equipmentSupplier;
/**
* 装备类型:0单件/1装备包
*/
private Integer equipmentType;
/**
* 状态,0正常/1异常
*/
private Integer errorState;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人员
*/
private String updateUser;
/**
* 创建人员
*/
private String createUser;
/**
* 照片信息
*/
private String picture;
/**
* 作业设备:0手持机 1单警柜 2通道)
*/
private Integer deviceType;
/**
* 存储ID
*/
private String locationId;
/**
* 存储名称:XX仓库,XX单警柜
*/
private String locationName;
}
package com.junmp.jyzb.api.bean.query;
import com.baomidou.mybatisplus.annotation.TableField;
import com.junmp.jyzb.api.bean.dto.LogDetailDto;
import com.junmp.v2.common.bean.request.BaseRequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
public class LogSummaryReq extends BaseRequest {
/**
* 出入库汇总ID
*/
private Integer id;
/**
* 组织机构ID
*/
@NotNull(message = "组织机构id不能为空",groups = {detail.class})
private Long orgId;
/**
* 组织机构名称
*/
private String orgName;
/**
* 单据id
*/
private String orderMainId;
/**
* 存储ID
*/
private String locationId;
/**
* 存储名称:XX仓库,XX单警柜
*/
private String locationName;
/**
* 设备标识
*/
private String device;
/**
* 出入设备:0手持机/1单警柜/2通道
*/
private Integer deviceType;
/**
* 操作时间
*/
private Date useTime;
/**
* 业务类型
*/
private String bussinessType;
/**
* 操作人员姓名
*/
private String userName;
/**
* 出入库类型:0出库/1入库
*/
private Integer outInState;
/**
* 照片信息
*/
private String picture;
/**
* 装备记录集合,警棍、盾牌
*/
private String equipmentList;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人员
*/
private String updateUser;
/**
* 创建人员
*/
private String createUser;
/**
* 装备详细信息
*/
private List<LogDetailReq> logList;
}
......@@ -50,6 +50,8 @@ public class OrderDetailReq extends BaseRequest {
private String warehouseId;
private String warehouseName;
/**
* 修改后数量
*/
......
package com.junmp.jyzb.api.bean.req;
import lombok.Data;
@Data
public class CabinetInOutRecordsReq {
private String id;
private Long orgId;
private String orgName;
//表示装备
private String device;
//出入设备:0手持机/1单警柜/2通道
private Integer deviceType;
/**
* 装备包ID
*/
private String packageId;
/**
* 装备类型ID
*/
private String typeId;
/**
* 装备类型名称
*/
private String typeName;
/**
* 装备号型ID
*/
private String sizeId;
/**
* 装备号型
*/
private String sizeName;
/**
* 供应商
*/
private String supplierName;
/**
* 供应商ID
*/
private String supplierId;
//出入类型:0出库/1入库
private Integer outInState;
private String locationId;
private String locationName;
private String epc;
}
......@@ -46,6 +46,8 @@ public class UpdateOrderDetailReq implements Serializable {
private String warehouseId;
private String warehouseName;
private String orderId;
private Integer actualNum;
......
......@@ -4,8 +4,11 @@ import com.junmp.jyzb.api.bean.dto.*;
import com.junmp.jyzb.api.bean.query.*;
import com.junmp.jyzb.api.bean.req.BatchEditingInvsReq;
import com.junmp.jyzb.api.bean.req.EquipmentBindReq;
import com.junmp.jyzb.api.bean.req.RabbitMqOrderReq;
import com.junmp.jyzb.entity.Inventory;
import com.junmp.jyzb.entity.InventorySummary;
import com.junmp.jyzb.entity.LogDetail;
import com.junmp.jyzb.entity.LogSummary;
import com.junmp.jyzb.service.*;
import com.junmp.v2.common.bean.request.ValidationApi;
import com.junmp.v2.common.bean.response.ApiRes;
......@@ -221,10 +224,23 @@ public class InventoryController {
return ApiRes.success(inventoryService.BatchEditingInvsInfo(req));
}
//装备出入库记录(通过装备id)-----------------------需要修改成page
@PostMapping("/GetInOutRecords")
@ApiOperation("装备出入库记录查询展示")
public ApiRes<List<InOutRecordsDto>> getInOutRecords(@RequestBody @Validated(ValidationApi.detail.class) InventoryReq req){
//装备出入库记录(通过装备id)
@PostMapping("/ShowInOutRecordsPage")
@ApiOperation("出入库单据记录查询展示")
public ApiRes<PageResult<LogSummary>> ShowInOutRecordsPage(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){
return ApiRes.success(inventoryService.ShowInOutRecordsPage(req));
}
//通过装备id查询某一件装备的出入库记录
@PostMapping("/GetInOutRecordsByEqs")
@ApiOperation("出入库单据记录查询展示")
public ApiRes<PageResult<LogDetail>> getInOutRecords(@RequestBody @Validated(ValidationApi.detail.class) InventoryReq req){
return ApiRes.success(inventoryService.getInOutRecords(req));
}
// @PostMapping("/test")
// public ApiRes<Boolean> test(@RequestBody RabbitMqOrderReq req){
// return ApiRes.success(inventoryService.test(req));
// }
}
......@@ -65,7 +65,7 @@ public class WarehouseController {
@PostMapping("/ShowWarehouse")
@ApiOperation("查询仓库列表")
public ApiRes<List<WarehouseDto>> getAllWarehouse(@RequestBody @Validated(ValidationApi.edit.class) WarehouseReq req){
return ApiRes.success(warehouseService.getAllWarehouse(req));
return ApiRes.success(warehouseService.getAllWarehouse(req.getOrgId()));
}
//通过仓库id查询列表
......
......@@ -33,17 +33,26 @@ public class Inventory implements Serializable {
*/
@TableField("type_id")
private String typeId;
@TableField(exist = false)
private String typeName;
/**
* 装备类型ID
*/
@TableField("size_id")
private String sizeId;
@TableField(exist = false)
private String sizeName;
/**
* 供应商ID
*/
@TableField("supplier_id")
private String supplierId;
@TableField(exist = false)
private String supplierName;
/**
* 部门ID
*/
......
......@@ -54,17 +54,37 @@ public class LogDetail implements Serializable {
/**
* 装备名称
*/
@ApiModelProperty(value = "装备名称id")
@TableField("type_id")
private String typeId;
/**
* 装备名称
*/
@ApiModelProperty(value = "装备名称")
@TableField("equipment_name")
private String equipmentName;
@TableField("type_name")
private String typeName;
/**
* 装备号型id
*/
@ApiModelProperty(value = "装备号型id")
@TableField("size_id")
private String sizeId;
/**
* 装备号型
*/
@ApiModelProperty(value = "装备号型")
@TableField("equipment_size")
private String equipmentSize;
/**
* 供应商id
*/
@ApiModelProperty(value = "供应商")
@TableField("supplier_id")
private String supplierId;
/**
* 供应商
*/
......@@ -124,5 +144,17 @@ public class LogDetail implements Serializable {
@TableField("device_type")
private Integer deviceType;
/**
* 存储ID
*/
@ApiModelProperty(value = "存储ID")
private String locationId;
/**
* 存储名称:XX仓库,XX单警柜
*/
@ApiModelProperty(value = "存储名称")
private String locationName;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -7,6 +7,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -28,7 +30,7 @@ public class LogSummary implements Serializable {
*/
@ApiModelProperty(value = "组织机构ID")
@TableField("org_id")
private String orgId;
private Long orgId;
/**
* 组织机构名称
......@@ -135,5 +137,8 @@ public class LogSummary implements Serializable {
@TableField(value = "create_user", fill = FieldFill.UPDATE)
private String createUser;
@TableField(exist = false)
private List<LogDetail> logDetailList;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -46,6 +46,9 @@ import java.util.Date;
@TableField("warehouse_id")
private String warehouseId;
@TableField("warehouse_name")
private String warehouseName;
@TableField("plan_num")
private Integer planNum;
......
......@@ -12,7 +12,7 @@ import java.util.Map;
@Mapper
public interface CabinetMapper extends BaseMapper<Cabinet> {
List<Cabinet> getAllCabinetByOrgList(List<Long> allOrgId);
List<Cabinet> getAllCabinetByOrgList(@Param("list") List<Long> allOrgId);
boolean SetInventoryInfo(String id);
......
......@@ -2,6 +2,7 @@ package com.junmp.jyzb.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.junmp.jyzb.api.bean.dto.InventorySumDto;
import com.junmp.jyzb.api.bean.dto.WarehouseDto;
import com.junmp.jyzb.api.bean.query.InventorySumReq;
import com.junmp.jyzb.entity.InventorySummary;
import org.apache.ibatis.annotations.Mapper;
......@@ -12,5 +13,16 @@ import java.util.List;
@Mapper
public interface InventorySummaryMapper extends BaseMapper<InventorySummary> {
//用于出库单中的装备选择
List<InventorySumDto> GetInventorySumInfo(@Param("req") InventorySumReq req);
//根据仓库id删除装备汇总信息
boolean deleteByWarehouse(@Param("list") List<WarehouseDto> allWarehouse);
boolean getSumByWarehouse(@Param("list") List<WarehouseDto> allWarehouse);
//根据单警柜删除装备汇总信息
boolean deleteByCabinet(@Param("cabinetId") String cabinetId);
boolean getSumByCabinet(@Param("cabinetId") String cabinetId);
}
\ No newline at end of file
package com.junmp.jyzb.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.junmp.jyzb.api.bean.dto.LogSummaryDto;
import com.junmp.jyzb.api.bean.query.LogSummaryReq;
import com.junmp.jyzb.entity.LogSummary;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface LogSummaryMapper extends BaseMapper<LogSummary> {
IPage<LogSummary> ShowInOutRecordsPage(Page<LogSummary> page,@Param("req") LogSummaryReq req);
}
\ No newline at end of file
package com.junmp.jyzb.rabbitmq;
import com.junmp.jyzb.api.bean.req.CabinetInOutRecordsReq;
import com.junmp.jyzb.api.bean.req.RabbitMqOrderReq;
import com.junmp.jyzb.service.InventorySummaryService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
@Component
public class CabinetLogReceiver {
@Resource
private InventorySummaryService inventorySummaryService;
@RabbitListener(queues = "cabinetInOutLog")//监听队列名
private void a(CabinetInOutRecordsReq req, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag){
try {
System.out.println("req = " + req);
//将消息进行消费
Boolean result = inventorySummaryService.cabinetInOutRecords(req);
if (result){
// 手动确认消息
channel.basicAck(deliveryTag, false);
}else {
channel.basicNack(deliveryTag, false, true);
}
} catch (Exception e) {
// 处理消息过程中发生异常,拒绝消息并将其重新放回队列
try {
channel.basicNack(deliveryTag, false, true);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}
}
......@@ -25,8 +25,8 @@ public class OrderMQReceiver {
private void a(RabbitMqOrderReq req, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag){
try {
//将消息进行消费
System.out.println("req = " + req);
//将消息进行消费
Boolean result = inventorySummaryService.processInventoryRecords(req);
if (result){
// 手动确认消息
......
......@@ -6,8 +6,11 @@ import com.junmp.jyzb.api.bean.query.*;
import com.junmp.jyzb.api.bean.req.BatchEditingInvsReq;
import com.junmp.jyzb.api.bean.req.EquipmentBindReq;
import com.junmp.jyzb.api.bean.req.RabbitMqOrderReq;
import com.junmp.jyzb.entity.Inventory;
import com.junmp.jyzb.entity.InventorySummary;
import com.junmp.jyzb.entity.LogDetail;
import com.junmp.jyzb.entity.LogSummary;
import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.v2.db.api.page.PageResult;
......@@ -71,8 +74,6 @@ public interface InventoryService extends IService<Inventory> {
//通过组织机构id对该组织机构下的装备进行导出
void ExportInventoryExcel(InventoryReq req);
//获取装备的出入库记录
List<InOutRecordsDto> getInOutRecords(InventoryReq req);
//通过条件查询装备数量报表
List<EqsSumDto> GetListEquipment(InventoryReq req);
......@@ -85,4 +86,13 @@ public interface InventoryService extends IService<Inventory> {
//批量信息修改
boolean BatchEditingInvsInfo(BatchEditingInvsReq req);
//获取装备的出入库记录(根据装备id获取某件装备的出入库记录信息)
PageResult<LogDetail> getInOutRecords(InventoryReq req);
//根据单据获取出入库记录
PageResult<LogSummary> ShowInOutRecordsPage(LogSummaryReq req);
boolean test(RabbitMqOrderReq req);
}
......@@ -3,6 +3,7 @@ package com.junmp.jyzb.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.api.bean.dto.InventorySumDto;
import com.junmp.jyzb.api.bean.query.InventorySumReq;
import com.junmp.jyzb.api.bean.req.CabinetInOutRecordsReq;
import com.junmp.jyzb.api.bean.req.RabbitMqOrderReq;
import com.junmp.jyzb.entity.InventorySummary;
import com.junmp.v2.db.api.page.PageResult;
......@@ -20,4 +21,7 @@ public interface InventorySummaryService extends IService<InventorySummary> {
//处理本地主机返回单据结果
Boolean processInventoryRecords(RabbitMqOrderReq req);
//处理单警柜返回单据结果
Boolean cabinetInOutRecords(CabinetInOutRecordsReq req);
}
package com.junmp.jyzb.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.api.bean.dto.LogSummaryDto;
import com.junmp.jyzb.entity.LogSummary;
import java.util.List;
public interface LogSummaryService extends IService<LogSummary> {
//上传出入日志
List<LogSummaryDto> getLogs();
}
......@@ -40,7 +40,7 @@ public interface WarehouseService extends IService<Warehouse> {
boolean changeWarehouseState(WarehouseReq req);
List<WarehouseDto> getAllWarehouse(WarehouseReq orgId);
List<WarehouseDto> getAllWarehouse(Long orgId);
//通过仓库id 判断仓库是否存在
......
......@@ -68,6 +68,7 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl
String ProcessInstanceId= FlowInstanceService.startProcessInstanceById(startProcessInstanceDTO);
busForm.setProcessId(ProcessInstanceId);
}
updateById(busForm);
return busForm.getId();
}
......@@ -106,7 +107,7 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl
//单据类型
.eq(ObjectUtil.isNotNull(req.getBussinessType()), BusForm::getBussinessType, req.getBussinessType())
//审核状态
.eq(ObjectUtil.isNotNull(req.getExamineState()), BusForm::getExamineState, req.getExamineState())
.eq(ObjectUtil.isNotNull(req.getExamineState()) && !req.getExamineState().trim().isEmpty(), BusForm::getExamineState, req.getExamineState())
//
.eq(ObjectUtil.isNotNull(req.getWarehouseId()), BusForm::getWarehouseId, req.getWarehouseId())
.eq(ObjectUtil.isNotNull(req.getOrgId()),BusForm::getOrgId,req.getOrgId())
......
......@@ -11,12 +11,14 @@ import com.junmp.jyzb.api.bean.dto.*;
import com.junmp.jyzb.api.bean.query.*;
import com.junmp.jyzb.api.bean.req.BatchEditingInvsReq;
import com.junmp.jyzb.api.bean.req.EquipmentBindReq;
import com.junmp.jyzb.api.bean.req.RabbitMqOrderReq;
import com.junmp.jyzb.api.bean.vo.InventoryVo;
import com.junmp.jyzb.api.exception.enums.CabinetBoxExceptionEnum;
import com.junmp.jyzb.api.exception.enums.CabinetExceptionEnum;
import com.junmp.jyzb.api.exception.enums.InventoryExceptionEnum;
import com.junmp.jyzb.entity.*;
import com.junmp.jyzb.mapper.LogSummaryMapper;
import com.junmp.jyzb.service.*;
import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil;
......@@ -27,6 +29,12 @@ import com.junmp.v2.db.api.page.PageResult;
import com.junmp.v2.office.api.OfficeExcelApi;
import com.junmp.v2.office.api.bean.ExcelExportParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
......@@ -82,6 +90,14 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
@Resource
private InventorySummaryService inventorySummaryService;
@Resource
private LogSummaryMapper logSummaryMapper;
@Resource
private RabbitTemplate rabbitTemplate;
@Resource
private RabbitAdmin rabbitAdmin;
//根据装备id查询出装备的详细信息
@Override
......@@ -396,6 +412,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
}
//修改库存信息汇总
@Transactional(rollbackFor = Exception.class)
public boolean setInventorySummary(BatchEditingInvsReq req){
//先将其删除再全部重新添加计算
List<InventorySummary> list = inventorySummaryService.list(new LambdaQueryWrapper<InventorySummary>()
......@@ -553,22 +570,23 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
officeExcelApi.easyExportDownload(param);
}
//获取装备的出入库信息
//获取装备的出入库信息(根据装备id获取该装备的出入库记录)
@Override
public List<InOutRecordsDto> getInOutRecords(InventoryReq req) {
public PageResult<LogDetail> getInOutRecords(InventoryReq req) {
//通过装备id获取出入库记录(判断id是否存在)
InventoryExist(req.getId());
List<LogDetail> list = logDetailService.list(new LambdaQueryWrapper<LogDetail>()
.eq(LogDetail::getInventoryId, req.getId()));
List<InOutRecordsDto> inOutRecordsDtoList=new ArrayList<>();
for (LogDetail logDetail: list) {
//获取
LogSummary logSummary = logSummaryService.getById(logDetail.getSummaryId());
InOutRecordsDto inOutRecordsDto = new InOutRecordsDto();
BeanPlusUtil.copyProperties(logSummary,inOutRecordsDto);
inOutRecordsDtoList.add(inOutRecordsDto);
LambdaQueryWrapper<LogDetail> eq = new LambdaQueryWrapper<LogDetail>().eq(LogDetail::getInventoryId,req.getId());
Page<LogDetail> page = logDetailService.page(PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()), eq);
return PageResultFactory.createPageResult(page);
}
return inOutRecordsDtoList;
//根据单据查询出入库记录
@Override
public PageResult<LogSummary> ShowInOutRecordsPage(LogSummaryReq req) {
Page<LogSummary> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
IPage<LogSummary> ipage=logSummaryMapper.ShowInOutRecordsPage(page,req);
page.setRecords(ipage.getRecords());
return PageResultFactory.createPageResult(page);
}
//查询装备数量报表
......@@ -622,4 +640,28 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
return wrapper;
}
@Override
public boolean test(RabbitMqOrderReq req) {
String exchangeName="hahaha";
//需要判断是入库单还是出库单,入库单传收物单位id,出库单传发物单位id
if(req.getOrderMainReq().getOrderType().equals("in")){
org.springframework.amqp.core.Queue queue=new org.springframework.amqp.core.Queue( "11111",true,false,false);
Exchange exchange = new DirectExchange(exchangeName, true, false);
rabbitAdmin.declareQueue(queue);
rabbitAdmin.declareExchange(exchange);
rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange).with(req.getOrderMainReq().getEndOrgId().toString()).noargs());
rabbitTemplate.convertAndSend(exchangeName, req.getOrderMainReq().getEndOrgId().toString(), req);
}else {
org.springframework.amqp.core.Queue queue = new Queue("11111", true, false, false);
Exchange exchange = new DirectExchange(exchangeName, true, false);
rabbitAdmin.declareQueue(queue);
rabbitAdmin.declareExchange(exchange);
rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange).with(req.getOrderMainReq().getStartOrgId().toString()).noargs());
rabbitTemplate.convertAndSend(exchangeName, req.getOrderMainReq().getStartOrgId().toString(), req);
}
return true;
}
}
\ No newline at end of file
......@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.dto.InventorySumDto;
import com.junmp.jyzb.api.bean.dto.WarehouseDto;
import com.junmp.jyzb.api.bean.query.InventorySumReq;
import com.junmp.jyzb.api.bean.req.CabinetInOutRecordsReq;
import com.junmp.jyzb.api.bean.req.RabbitMqOrderReq;
import com.junmp.jyzb.entity.*;
import com.junmp.jyzb.service.*;
......@@ -15,10 +17,13 @@ import com.junmp.v2.db.api.factory.PageResultFactory;
import com.junmp.v2.db.api.page.PageResult;
import org.springframework.stereotype.Service;
import com.junmp.jyzb.mapper.InventorySummaryMapper;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Service
......@@ -39,6 +44,22 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
@Resource
private EquipmentSizeService equipmentSizeService;
@Resource
private OrderDetailService orderDetailService;
@Resource
private WarehouseService warehouseService;
@Resource
private LogSummaryService logSummaryService;
@Resource
private LogDetailService logDetailService;
@Resource
private CabinetBoxService cabinetBoxService;
//根据条件查询库存汇总信息
@Override
public PageResult<InventorySummary> getEquipmentInfo(InventorySumReq req) {
......@@ -81,16 +102,155 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
//处理本地主机返回单据结果
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean processInventoryRecords(RabbitMqOrderReq req) {
//将主单据信息复制进行更新
OrderMain orderMain = new OrderMain();
BeanPlusUtil.copyProperties(req.getOrderMainReq(),orderMain);
orderMainService.updateById(orderMain);
//将子单据信息复制进行更新
OrderDetail orderDetail = new OrderDetail();
BeanPlusUtil.copyProperties(req.getOrderDetailReq(),orderDetail);
orderDetailService.updateById(orderDetail);
////对装备表进行更新或者插入
//新增列表
List<Inventory> addList = new ArrayList<>();
//更新列表
List<Inventory> updateList = new ArrayList<>();
String bussinessState=orderMain.getOrderState();
//组织机构
Long orgId;
if (bussinessState.equals("in")){
orgId=orderMain.getEndOrgId();
}else {
orgId=orderMain.getStartOrgId();
}
//将具体Epc进行处理(判断装备是否具有id,如果没有id表示新增一条数据在数据库中--采购)
req.getInventoryReqList().forEach(inventoryReq -> {
Inventory inventory = new Inventory();
BeanPlusUtil.copyProperties(inventoryReq,inventory);
inventory.setOrgId(orgId);
if (ObjectUtil.isNotNull(inventoryReq.getId())){
//修改状态
inventory.setId(UUID.randomUUID().toString());
inventory.setLocationState(orderMain.getOrderType());
inventory.setBussinessState("normal");
addList.add(inventory);
}else {
//修改状态
inventory.setLocationState(orderMain.getOrderType());
//修改业务状态
if (bussinessState.equals("in")){
inventory.setBussinessState("normal");
}else {
inventory.setBussinessState(orderMain.getBussinessType());
}
updateList.add(inventory);
}
});
if (ObjectUtil.isNotNull(addList) && addList.size()>0){
inventoryService.saveBatch(addList);
}
if (ObjectUtil.isNotNull(updateList) && updateList.size()>0){
inventoryService.updateBatchById(updateList);
}
//对装备进行记录,存入log表形成出入库记录
Boolean c = insertLog(orderMain,addList,updateList);
//对summary表中数据进行重新计算装备信息汇总
Boolean d = updateSummaryInsByOrder(orgId);
return (c && d);
}
//对装备进行记录,存入log表形成出入库记录
@Transactional(rollbackFor = Exception.class)
public Boolean insertLog(OrderMain orderMain,List<Inventory> addList,List<Inventory> updateList ){
//插入log_summary
LogSummary logSummary = new LogSummary();
if (orderMain.getOrderType().equals("in")){
logSummary.setOutInState(1);
logSummary.setOrgId(orderMain.getEndOrgId());
logSummary.setOrgName(orderMain.getEndOrgName());
}else {
logSummary.setOutInState(0);
logSummary.setOrgId(orderMain.getStartOrgId());
logSummary.setOrgName(orderMain.getStartOrgName());
}
logSummary.setOrderMainId(orderMain.getId());
logSummary.setBussinessType(orderMain.getBussinessType());
boolean a = logSummaryService.save(logSummary);
//存入log_detail表中
List<LogDetail> logDetailList=new ArrayList<>();
//判断是哪个列表不为空,进行出入库记录
if (addList.size()!=0 && ObjectUtil.isNotNull(addList)){
for (Inventory inventory:addList) {
LogDetail logDetail = new LogDetail();
BeanPlusUtil.copyProperties(inventory,logDetail);
logDetail.setSummaryId(logSummary.getId());
logDetail.setOrderMainId(orderMain.getId());
logDetailList.add(logDetail);
}
}
if (updateList.size()!=0 && ObjectUtil.isNotNull(updateList)){
for (Inventory inventory:addList) {
LogDetail logDetail = new LogDetail();
BeanPlusUtil.copyProperties(inventory,logDetail);
logDetail.setSummaryId(logSummary.getId());
logDetail.setOrderMainId(orderMain.getId());
logDetailList.add(logDetail);
}
}
boolean b = logDetailService.saveBatch(logDetailList);
return (a && b);
}
//对summary表中数据进行重新计算装备信息汇总
public Boolean updateSummaryInsByOrder(Long orgId){
//查询出组织机构下的所有仓库信息,并且将表中的仓库信息数据进行删除
List<WarehouseDto> allWarehouse = warehouseService.getAllWarehouse(orgId);
boolean a = inventorySummaryMapper.deleteByWarehouse(allWarehouse);
//根据仓库id重新计算汇总信息
boolean b = inventorySummaryMapper.getSumByWarehouse(allWarehouse);
return (a && b);
}
//单警柜返回数据
@Override
public Boolean cabinetInOutRecords(CabinetInOutRecordsReq req) {
//修改inventory表中数据
Inventory inventory = new Inventory();
BeanPlusUtil.copyProperties(req,inventory);
boolean a = inventoryService.updateById(inventory);
//修改summary表中数据
boolean b = updateSummaryInsByCabinet(req.getLocationId());
//添加日志记录、
Boolean c = insertCabinetLog(req);
return (a && b && c);
}
public boolean updateSummaryInsByCabinet(String locationId){
//根据箱门id查询出单警柜信息
CabinetBox cabinetBox = cabinetBoxService.getById(locationId);
//删除inventorysummary表中该单警柜数据
boolean a = inventorySummaryMapper.deleteByCabinet(cabinetBox.getCabinetId());
//重新计算该单警柜下面的装备信息
boolean b = inventorySummaryMapper.getSumByCabinet(cabinetBox.getCabinetId());
return (a && b);
}
return null;
//添加单警柜出入库记录日志
public Boolean insertCabinetLog(CabinetInOutRecordsReq req){
LogSummary logSummary = new LogSummary();
BeanPlusUtil.copyProperties(req,logSummary);
boolean a = logSummaryService.save(logSummary);
LogDetail logDetail = new LogDetail();
BeanPlusUtil.copyProperties(req,logDetail);
logDetail.setSummaryId(logSummary.getId());
boolean b = logDetailService.save(logDetail);
return (a && b);
}
private LambdaQueryWrapper<InventorySummary> createWrapper(InventorySumReq req) {
......
package com.junmp.jyzb.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.dto.LogDetailDto;
import com.junmp.jyzb.api.bean.dto.LogSummaryDto;
import com.junmp.jyzb.entity.LogDetail;
import com.junmp.jyzb.entity.LogSummary;
import com.junmp.jyzb.mapper.LogSummaryMapper;
import com.junmp.jyzb.service.LogDetailService;
import com.junmp.jyzb.service.LogSummaryService;
import com.junmp.v2.common.util.BeanPlusUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSummary> implements LogSummaryService {
@Resource
private LogDetailService logDetailService;
@Override
public List<LogSummaryDto> getLogs() {
List<LogSummary> list = list(new LambdaQueryWrapper<LogSummary>().orderByDesc(LogSummary::getCreateTime));
List<LogSummaryDto> logSummaryDtoList=new ArrayList<>();
List<LogDetailDto> logDetailDtoList=new ArrayList<>();
for (LogSummary logSummary:list) {
LogSummaryDto logSummaryDto = new LogSummaryDto();
BeanPlusUtil.copyProperties(logSummary,logSummaryDto);
List<LogDetail> list1 = logDetailService.list(new LambdaQueryWrapper<LogDetail>()
.eq(LogDetail::getSummaryId, logSummary.getId()));
for (LogDetail logDetail:list1) {
LogDetailDto logDetailDto = new LogDetailDto();
BeanPlusUtil.copyProperties(logDetail,logDetailDto);
logDetailDtoList.add(logDetailDto);
}
logSummaryDto.setEquipmentList(logDetailDtoList);
logSummaryDtoList.add(logSummaryDto);
}
return logSummaryDtoList;
}
}
......@@ -88,15 +88,15 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse>
@Override
public List<WarehouseDto> getAllWarehouse(WarehouseReq msg) {
public List<WarehouseDto> getAllWarehouse(Long orgId) {
List<WarehouseDto> warehouseDtoList=new ArrayList<>();
//判断组织机构是否存在
PubOrg pubOrg = pubOrgService.PubOrgExist(msg.getOrgId());
PubOrg pubOrg = pubOrgService.PubOrgExist(orgId);
//根据组织机构id查询组织机构名称
String orgName = pubOrg.getOrgName();
List<Warehouse> list = list(new LambdaQueryWrapper<Warehouse>()
.eq(Warehouse::getOrgId, msg.getOrgId()));
.eq(Warehouse::getOrgId, orgId));
for (Warehouse warehouse:list) {
WarehouseDto warehouseDto = new WarehouseDto();
BeanPlusUtil.copyProperties(warehouse,warehouseDto);
......
......@@ -31,6 +31,7 @@
destruction_number, expire_number, create_time, update_time,threshold
</sql>
<select id="GetInventorySumInfo" resultType="com.junmp.jyzb.api.bean.dto.InventorySumDto"
parameterType="com.junmp.jyzb.api.bean.query.InventorySumReq">
select max(bis.org_id_int) as orgId,max(bis.org_name) as orgName,bis.location_id,max(bis.location_name) as location_name
......@@ -67,7 +68,92 @@
</if>
</select>
<insert id="getSumByCabinet">
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,unit_price,price,stock_number, outbound_number,destruction_number,expire_number,location_type,create_time,update_time)
select
MAX(t.id) as id,t.orgId,t.orgName,t.type_id,t.typeName,t.size_id,t.sizeName,t.locationId,t.locationName,sum(t.number) as number,t.unitPrice,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,sum(t.destructionNumber)as destructionNumber,sum(t.expireNumber)as expireNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
bi.org_id_int as orgId,
po.org_name as orgName,
bcb.cabinet_id as locationId,
bi.location_id as locationBoxId,
bc.name as locationName,
bi.type_id,
t.name as typeName,
bi.size_id,
s.name as sizeName,
count(*) as number,
bi.price as unitPrice,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH)<NOW() then 1 else 0 end )as expireNumber,
bi.location_type
FROM base_inventory bi
join base_cabinet_box bcb on bi.location_id = bcb.id
join base_cabinet bc on bcb.cabinet_id = bc.id
join base_equipment_type t on t.id = bi.type_id
join base_equipment_size s on s.id = bi.size_id
join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 1 and bcb.cabinet_id=#{cabinetId}
GROUP BY location_id, type_id,size_id,bi.org_id_int,bi.price ) as t
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
</insert>
<delete id="deleteByWarehouse"
parameterType="com.junmp.jyzb.api.bean.dto.WarehouseDto">
delete from base_inventory_summary_type2
where location_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</delete>
<delete id="deleteByCabinet" parameterType="java.lang.String">
delete from base_inventory_summary_type2 where locationId = #{cabinetId}
</delete>
<insert id="getSumByWarehouse">
INSERT INTO base_inventory_summary_type2 (id,org_id_int,org_name,location_id,location_name,type_id, type_name,size_id,size_name,number,unit_price,price, stock_number, outbound_number,destruction_number,expire_number,location_type,create_time,update_time)
select
MAX(t.id) as id,t.orgId,t.orgName,t.locationId,MAX(t.locationName),t.type_id,t.typeName,t.size_id,t.sizeName,sum(t.number) as number,t.unitPrice,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,sum(t.destructionNumber)as destructionNumber,sum(t.destructionNumber) as expireNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
bi.org_id_int as orgId,
po.org_name as orgName,
MAX(bi.location_id) as locationId,
MAX(bw.name) as locationName,
bi.type_id,
t.name as typeName,
bi.size_id,
s.name as sizeName,
count(*) as number,
Max(bi.price) as unitPrice,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &lt; NOW() then 1
else 0 end )as expireNumber,
bi.location_type
FROM base_inventory bi
join base_warehouse bw on bi.location_id = bw.id
join base_equipment_type t on t.id = bi.type_id
join base_equipment_size s on s.id = bi.size_id
join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 0
and bi.location_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
GROUP BY type_id,size_id,bi.org_id_int,location_id,bi.price) as t
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
</insert>
</mapper>
\ No newline at end of file
......@@ -7,18 +7,30 @@
<id column="id" jdbcType="INTEGER" property="id" />
<result column="org_id" jdbcType="VARCHAR" property="orgId" />
<result column="org_name" jdbcType="VARCHAR" property="orgName" />
<result column="warehouse_id" jdbcType="VARCHAR" property="warehouseId" />
<result column="warehouse_name" jdbcType="VARCHAR" property="warehouseName" />
<result column="device" jdbcType="VARCHAR" property="device" />
<result column="device_type" jdbcType="INTEGER" property="deviceType" />
<result column="use_time" jdbcType="TIMESTAMP" property="useTime" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="out_in_state" jdbcType="INTEGER" property="outInState" />
<result column="picture" jdbcType="VARCHAR" property="picture" />
<collection property="logDetailList" ofType="com.junmp.jyzb.entity.LogDetail">
<id column="id" property="id"/>
<result column="inventory_id" property="inventoryId"></result>
<result column="order_main_id" property="orderMainId"></result>
</collection>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, org_id, org_name, warehouse_id, warehouse_name, device, device_type, use_time,
user_name, out_in_state, picture
</sql>
<select id="ShowInOutRecordsPage" resultType="com.junmp.jyzb.entity.LogSummary">
select * from base_log_summary ls
left join base_log_detail ld on ls.id=ld.summary_id
where ls.org_id = #{req.orgId}
<if test="req.bussinessType != null and req.bussinessType !=''">
and ls.bussiness_type=#{req.bussinessType}
</if>
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论