Commit c2925832 by 李小惠

修改出入库记录

parent 9c83538f
package com.junmp.jyzb.api.bean.dto;
import lombok.Data;
import java.util.List;
@Data
public class A {
private List<Object[]> a;
}
......@@ -177,4 +177,5 @@ public class BusFormDto {
* 销毁、报废单位名称
*/
private String destoryName;
}
......@@ -2,10 +2,15 @@ package com.junmp.jyzb.api.bean.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class GeneratePurchaseQuicklyDto {
//采购单号
private String orderId;
//是否成功
private boolean isSuccess;
private String sizeId;
private String sizeName;
private String typeId;
private String typeName;
private Integer number;
}
......@@ -3,6 +3,7 @@ package com.junmp.jyzb.api.bean.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
......@@ -10,7 +11,7 @@ public class LogDetailDto implements Serializable {
/**
* 出入库明细ID
*/
private Integer id;
private Long id;
/**
* 物资id
......@@ -20,7 +21,7 @@ public class LogDetailDto implements Serializable {
/**
* 出入库汇总ID
*/
private Integer summaryId;
private Long summaryId;
/**
* 单据ID
......@@ -97,4 +98,6 @@ public class LogDetailDto implements Serializable {
* 存储名称:XX仓库,XX单警柜
*/
private String locationName;
private BigDecimal price;
}
......@@ -11,7 +11,7 @@ public class LogSummaryDto implements Serializable {
/**
* 出入库汇总ID
*/
private Integer id;
private Long id;
/**
* 组织机构ID
......@@ -67,6 +67,8 @@ public class LogSummaryDto implements Serializable {
*/
private Integer outInState;
private Integer number;
/**
* 照片信息
*/
......@@ -96,10 +98,6 @@ public class LogSummaryDto implements Serializable {
* 创建人员
*/
private String createUser;
/**
* 装备详细信息
*/
private List<LogDetailDto> logList;
}
package com.junmp.jyzb.api.bean.dto;
import lombok.Data;
import java.math.BigDecimal;
//日常出入库输出类,用于更新计算库存汇总表中的数据
@Data
public class NormalInOutDto {
/**
*orgId 组织机构id
*/
private Long orgId;
/**
*orgName 组织机构名称
*/
private String orgName;
/**
*typeId 装备类型id
*/
private String typeId;
/**
*typeName 装备类型名称
*/
private String typeName;
/**
*sizeId 装备型号id
*/
private String sizeId;
/**
*sizeName 装备型号名称
*/
private String sizeName;
/**
* 位置信息id
*/
private String locationId;
/**
* 位置名称
*/
private String locationName;
/**
* 单价
*/
private BigDecimal price;
/**
*number 库存数量
*/
private Integer number;
//出入库状态
private String OutInState;
}
......@@ -37,6 +37,8 @@ public class OrderDetailDto implements Serializable {
* 实际数量
*/
private Integer actualNum;
//记账数量
private Integer modifyQuantity;
private BigDecimal price;
......
......@@ -76,9 +76,9 @@ public class OrderDto implements Serializable {
private String invList;
/**
* 生产厂商id
* 生产厂商
*/
private String manufacturerId;
private String manufacturerName;
/**
* 明细列表
*/
......@@ -87,5 +87,9 @@ public class OrderDto implements Serializable {
private Date useDate;
private String createUser;
private Integer allocateType;
private String repairName;
private String destoryName;
}
package com.junmp.jyzb.api.bean.query.InAndOutRecordReq;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class DetailLogReq {
private Integer summaryId;
private String inventoryId;
private String bussinessType;
private String epc;
private String sizeId;
private String typeId;
private String typeName;
private String sizeName;
private String supplierId;
private String supplierName;
private Integer errorState;
private BigDecimal price;
private Integer equipmentType;
}
package com.junmp.jyzb.api.bean.query.InAndOutRecordReq;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class DetailOrderReq {
private String id;
private String orderType;
private BigDecimal price;
private Integer actualNum;
}
package com.junmp.jyzb.api.bean.query.InAndOutRecordReq;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class OrderReq {
private String id;
private BigDecimal price;
private Integer actualQuantity;
private Integer orderState;
private List<DetailOrderReq> orderDetail;
private List<PurchaseEqsReq> purchaseList;
}
package com.junmp.jyzb.api.bean.query.InAndOutRecordReq;
import lombok.Data;
import java.util.List;
@Data
public class OutInLogsReq {
//组织机构id
private Long orgId;
//组织机构名称
private String orgName;
//设备标识
private String device;
//出入设备
private Integer deviceType;
//业务类型
private String bussinessType;
//出入状态
private String outInState;
//所属位置(0仓库1单警柜)
private Integer locationType;
private OrderReq orderMain;
private List<SummaryLogReq> logSummaryList;
}
package com.junmp.jyzb.api.bean.query.InAndOutRecordReq;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class PurchaseEqsReq {
private String epc;
private String typeId;
private String typeName;
private String sizeId;
private String sizeName;
private Date productionDate;
private Integer warranyPeriod;
private Integer maintenancePeriod;
private String supplierId;
private String supplierName;
//装备类型0单件,1装备包
private Integer equipmentType;
private BigDecimal price;
}
package com.junmp.jyzb.api.bean.query.InAndOutRecordReq;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class SummaryLogReq {
private String orderMainId;
private String orderCode;
private String locationId;
private String locationName;
private String userName;
private Date useTime;
private String picture;
private String equipmentList;
private Integer number;
private List<DetailLogReq> logDetailList;
}
......@@ -139,6 +139,7 @@ public class InventoryReq extends BaseRequest {
* 位置ID
*/
private String locationId ;
private String locationName;
/**
* 是否遗失
*/
......
package com.junmp.jyzb.api.bean.query;
import com.baomidou.mybatisplus.annotation.TableField;
import com.junmp.v2.common.bean.request.ValidationApi;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Data
......@@ -10,7 +14,7 @@ public class LogDetailReq {
/**
* 出入库明细ID
*/
private Integer id;
private Long id;
/**
* 物资id
......@@ -20,12 +24,9 @@ public class LogDetailReq {
/**
* 出入库汇总ID
*/
private Integer summaryId;
@NotNull(message = "出入库记录汇总id不能为空",groups = {ValidationApi.detail.class})
private Long summaryId;
/**
* 单据ID
*/
private String orderMainId;
/**
* EPC信息
......@@ -88,13 +89,4 @@ public class LogDetailReq {
*/
private Integer deviceType;
/**
* 存储ID
*/
private String locationId;
/**
* 存储名称:XX仓库,XX单警柜
*/
private String locationName;
}
......@@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
......@@ -17,12 +18,12 @@ public class LogSummaryReq extends BaseRequest {
/**
* 出入库汇总ID
*/
private Integer id;
private Long id;
/**
* 组织机构ID
*/
@NotNull(message = "组织机构id不能为空",groups = {detail.class})
@NotNull(message = "组织机构id不能为空",groups = {page.class})
private Long orgId;
/**
......@@ -33,6 +34,7 @@ public class LogSummaryReq extends BaseRequest {
/**
* 单据id
*/
@NotBlank(message = "单据id不能为空",groups = {detail.class})
private String orderMainId;
/**
......@@ -40,10 +42,6 @@ public class LogSummaryReq extends BaseRequest {
*/
private String locationId;
/**
* 箱门id
*/
private String cabinetboxId;
/**
* 存储名称:XX仓库,XX单警柜
......@@ -53,6 +51,7 @@ public class LogSummaryReq extends BaseRequest {
/**
* 0仓库,1单警柜
*/
@NotNull(message = "位置不能为空",groups = {page.class})
private Integer locationType;
/**
......@@ -80,9 +79,11 @@ public class LogSummaryReq extends BaseRequest {
private String userName;
/**
* 出入库类型:0出库/1入库
* 出入库类型
*/
private Integer outInState;
private String outInState;
private Integer number;
/**
* 照片信息
......@@ -120,4 +121,9 @@ public class LogSummaryReq extends BaseRequest {
private String typeId;
private String column;
private String order;
private Date startTime;
private Date endTime;
}
......@@ -36,6 +36,7 @@ public class OrderDetailReq extends BaseRequest {
private Integer actualNum;
private BigDecimal price;
private String orderType;
......@@ -53,7 +54,7 @@ public class OrderDetailReq extends BaseRequest {
private String warehouseName;
/**
* 修改后数量
* 修改后数量(记账数量)
*/
private Integer modifyQuantity;
......
......@@ -19,6 +19,8 @@ public class OrderMainReq extends BaseRequest {
@NotBlank(message = "业务类型不能为空",groups = {edit.class})
private String orderType;
private String processInstanceId;
private String processId;
private String bussinessType;
......@@ -92,12 +94,12 @@ public class OrderMainReq extends BaseRequest {
/**
* 生产厂商id
*/
private String manufacturerId;
private String manufacturerName;
/**
* 调拨类型(2支拨,1价拨),调拨出入库才有
*/
private Integer transferType;
private Integer allocateType;
/**
* 归还人,归还入库特有
......
package com.junmp.jyzb.api.bean.query;
import com.junmp.v2.common.bean.request.BaseRequest;
import lombok.Data;
@Data
public class ProcessOrderReq extends BaseRequest {
//单据类型
private String orderType;
//流程id
private String processInstanceId;
}
......@@ -6,7 +6,10 @@ import java.util.List;
@Data
public class GeneratePurchaseQuicklyReq {
//业务单
private List<UpdateBusFormReq> busFormList;
//组织机构id
private Long orgId;
//业务类型
private String bussinessType;
}
......@@ -38,7 +38,7 @@ public class UpdateBusFormReq extends BaseRequest {
/**
* 组织机构id
*/
@NotNull(message = "组织机构id不能为空",groups = {add.class})
// @NotNull(message = "组织机构id不能为空",groups = {add.class})
private Long orgId;
/**
......
......@@ -133,9 +133,9 @@ public class UpdateOrderReq extends BaseRequest implements Serializable {
private List<UpdateOrderDetailReq> detailList;
/**
* 生产厂商id
* 生产厂商
*/
private String manufacturerId;
private String manufacturerName;
/**
* 调拨类型(2支拨,1价拨),调拨出入库才有
......
......@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* 业务单据管理模块(只针对业务单据,不包含任何出入库单据)
......@@ -65,7 +66,7 @@ public class BussinessController {
//根据调拨单,一键生成采购单
@PostMapping("/GeneratePurchaseQuickly")
@ApiOperation("快速生成采购单")
public ApiRes<GeneratePurchaseQuicklyDto> GeneratePurchaseQuickly(@RequestBody GeneratePurchaseQuicklyReq req){
public ApiRes<List<GeneratePurchaseQuicklyDto>> GeneratePurchaseQuickly(@RequestBody GeneratePurchaseQuicklyReq req){
return ApiRes.success(busFormService.GeneratePurchaseQuickly(req));
}
......
......@@ -222,27 +222,6 @@ public class InventoryController {
return ApiRes.success(inventoryService.BatchEditingInvsInfo(req));
}
//装备出入库记录(根据单据id)
@PostMapping("/ShowInOutRecordsByOrder")
@ApiOperation("出入库单据查询展示")
public ApiRes<PageResult<LogSummary>> ShowInOutRecordsByOrder(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){
return ApiRes.success(inventoryService.ShowInOutRecordsByOrder(req));
}
//装备出入库记录(根据条件查询)
@PostMapping("/ShowInOutRecordsByItems")
@ApiOperation("出入库记录条件查询展示")
public ApiRes<PageResult<LogSummary>> ShowInOutRecordsByItems(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){
return ApiRes.success(inventoryService.ShowInOutRecordsByItems(req));
}
//通过装备id查询某一件装备的出入库记录
@PostMapping("/ShowInOutRecordsByEqs")
@ApiOperation("出入库记录装备id查询展示")
public ApiRes<PageResult<LogDetail>> getInOutRecords(@RequestBody @Validated(ValidationApi.detail.class) InventoryReq req){
return ApiRes.success(inventoryService.getInOutRecords(req));
}
//首页上的装备统计数量
@PostMapping("/EquipmentStatistics")
......
......@@ -6,7 +6,6 @@ import com.junmp.jyzb.api.bean.dto.OrderMainDto;
import com.junmp.jyzb.api.bean.dto.ProcessOrderDto;
import com.junmp.jyzb.api.bean.query.OrderMainReq;
import com.junmp.jyzb.api.bean.query.OrderUploadReq;
import com.junmp.jyzb.api.bean.query.ProcessOrderReq;
import com.junmp.jyzb.api.bean.req.BaseOrderReq;
import com.junmp.jyzb.api.bean.query.QueryOrderLogReq;
import com.junmp.jyzb.api.bean.req.UpdateOrderReq;
......@@ -150,7 +149,7 @@ public class OrderController {
//根据流程id获取单据的装备信息
@PostMapping("/GetByProcessId")
@ApiOperation("根据流程id获取单据装备信息")
public ApiRes<ProcessOrderDto> GetByProcessId(@RequestBody ProcessOrderReq req){
public ApiRes<ProcessOrderDto> GetByProcessId(@RequestBody OrderMainReq req){
return ApiRes.success(orderMainService.GetByProcessId(req));
}
}
package com.junmp.jyzb.controller;
import com.junmp.jyzb.api.bean.dto.LogDetailDto;
import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.OutInLogsReq;
import com.junmp.jyzb.api.bean.query.InventoryReq;
import com.junmp.jyzb.api.bean.req.FormEqsReq;
import com.junmp.jyzb.service.PoliceEquipmentService;
import com.junmp.jyzb.api.bean.query.LogDetailReq;
import com.junmp.jyzb.api.bean.query.LogSummaryReq;
import com.junmp.jyzb.api.bean.req.RabbitMqOrderReq;
import com.junmp.jyzb.entity.LogDetail;
import com.junmp.jyzb.entity.LogSummary;
import com.junmp.jyzb.service.InventorySummaryService;
import com.junmp.jyzb.service.LogDetailService;
import com.junmp.jyzb.service.LogSummaryService;
import com.junmp.v2.common.bean.request.ValidationApi;
import com.junmp.v2.common.bean.response.ApiRes;
import com.junmp.v2.db.api.page.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
@Slf4j
@RequestMapping("/OutAndInbound")
@RequestMapping("/OutAndInRecords")
@Api(tags = "出入库模块")
public class OutAndInboundController {
@Resource
private PoliceEquipmentService policeEquipmentService;
//装备入库,添加入库记录
@ApiOperation("添加装备入库记录")
@PostMapping("/AddInRecords")
public ApiRes<Boolean> AddInRecords(InventoryReq req){
return ApiRes.success();
public LogSummaryService logSummaryService;
@Resource
private InventorySummaryService inventorySummaryService;
@Resource
private LogDetailService logDetailService;
@ApiOperation("/查看出入库详情")
@PostMapping("/GetDetailByLogSumId")
public ApiRes<List<LogDetailDto>> GetDetailByLogSumId(@RequestBody @Validated(ValidationApi.detail.class) LogDetailReq req){
return ApiRes.success(logDetailService.GetDetailByLogSumId(req));
}
//装备出入库记录(根据单据id)
@PostMapping("/ShowInOutRecordsByOrder")
@ApiOperation("出入库单据查询展示")
public ApiRes<List<LogDetailDto>> ShowInOutRecordsByOrder(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){
return ApiRes.success(logDetailService.ShowInOutRecordsByOrder(req));
}
//装备出入库记录(根据条件查询)
@PostMapping("/ShowInOutRecordsByItems")
@ApiOperation("出入库记录条件查询展示")
public ApiRes<PageResult<LogSummary>> ShowInOutRecordsByItems(@RequestBody @Validated(ValidationApi.page.class) LogSummaryReq req){
return ApiRes.success(logSummaryService.ShowInOutRecordsByItems(req));
}
//通过装备id查询某一件装备的出入库记录
@PostMapping("/ShowInOutRecordsByEqs")
@ApiOperation("出入库记录装备id查询展示")
public ApiRes<PageResult<LogDetail>> getInOutRecords(@RequestBody @Validated(ValidationApi.detail.class) InventoryReq req){
return ApiRes.success(logDetailService.getInOutRecords(req));
}
@PostMapping("/OutInRecords")
public ApiRes<Boolean> OutInRecords(@RequestBody RabbitMqOrderReq req){
return ApiRes.success(inventorySummaryService.processInventoryRecords(req));
}
}
package com.junmp.jyzb.controller;
import com.junmp.jyzb.api.bean.dto.A;
import com.junmp.jyzb.api.bean.query.TestReq;
import com.junmp.jyzb.api.bean.req.RabbitMqOrderReq;
import com.junmp.jyzb.entity.InventorySummary;
import com.junmp.jyzb.service.InventorySummaryService;
import com.junmp.jyzb.service.TestService;
import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.v2.common.bean.response.ApiRes;
......@@ -15,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
@Slf4j
......@@ -23,6 +27,8 @@ public class TestController {
@Resource
private TestService testService;
@Resource
private InventorySummaryService inventorySummaryService;
@Resource
private RabbitAdmin rabbitAdmin;
......@@ -31,9 +37,14 @@ public class TestController {
return new ResponseResult(10000,"操作成功","hello");
}
// @PostMapping("/test")
// public ApiRes<Boolean> test(@RequestBody RabbitMqOrderReq req){
// return ApiRes.success(testService.test(req));
// }
@PostMapping("/test")
public ApiRes<Boolean> test(@RequestBody RabbitMqOrderReq req){
return ApiRes.success(testService.test(req));
return ApiRes.success(inventorySummaryService.processInventoryRecords(req));
}
@PostMapping("/hasConsumers")
......@@ -43,4 +54,8 @@ public class TestController {
return ApiRes.success(execute>0L);
}
@PostMapping("/selectByItem")
public ApiRes<List<InventorySummary>> selectByItem(@RequestBody A a){
return ApiRes.success(inventorySummaryService.selectByItems(a.getA()));
}
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
......@@ -18,7 +19,7 @@ public class LogDetail implements Serializable {
* 出入库明细ID
*/
private Long id;
private Long detailId;
/**
* 出入库汇总id
*/
......@@ -30,17 +31,6 @@ public class LogDetail implements Serializable {
@TableField(value = "inventory_id")
private String inventoryId;
/**
* 单据ID
*/
@TableField(value = "order_main_id")
private String orderMainId;
/**
* 单据编号
*/
@TableField(value = "order_code")
private String orderCode;
/**
* 业务类型
......@@ -96,17 +86,7 @@ public class LogDetail implements Serializable {
@TableField(value = "equipment_type")
private Integer equipmentType;
/**
* 位置id(存放单警柜id或者是仓库id)
*/
@TableField(value = "location_id")
private String locationId;
/**
* 位置名称(单警柜,仓库)
*/
@TableField(value = "location_name")
private String locationName;
/**
* 箱门id
......@@ -156,11 +136,10 @@ public class LogDetail implements Serializable {
@TableField(value = "picture")
private String picture;
/**
* 出入设备:0手持机/1单警柜/2通道
*/
@TableField(value = "device_type")
private Integer deviceType;
@TableField(value = "price")
private BigDecimal price;
private static final long serialVersionUID = 1L;
......
......@@ -58,17 +58,17 @@ public class LogSummary implements Serializable {
private Integer deviceType;
/**
* 所属位置(0仓库1单警柜
* 位置id(存放单警柜id或者是仓库id
*/
@TableField(value = "location_id")
private String locationId;
/**
* 所属位置(0仓库1单警柜
* 位置名称(单警柜,仓库
*/
@TableField(value = "location_name")
private String locationName;
/**
* 所属位置(0仓库1单警柜)
*/
......@@ -129,8 +129,6 @@ public class LogSummary implements Serializable {
@TableField(value = "create_user")
private String createUser;
@TableField(exist = false)
private List<LogDetail> logDetailList;
/**
* 出入状态
......@@ -138,6 +136,9 @@ public class LogSummary implements Serializable {
@TableField(value = "out_in_state")
private String outInState;
@TableField(value = "number")
private Integer number;
private static final long serialVersionUID = 1L;
......
......@@ -56,6 +56,9 @@ import java.util.Date;
@TableField("actual_num")
private Integer actualNum;
@TableField("modify_quantity")
private Integer modifyQuantity;
@TableField("price")
private BigDecimal price;
......
......@@ -117,19 +117,24 @@ public class OrderMain implements Serializable {
/**
* 生产厂商id
*/
@TableField("manufacturer_id")
private String manufacturerId;
@TableField("manufacturer_name")
private String manufacturerName;
/**
* 调拨类型(2支拨,1价拨)
*/
@TableField("transfer_type")
private Integer transferType;
@TableField("allocate_type")
private Integer allocateType;
/**
* 归还人,归还入库特有
*/
@TableField("return_user_id")
private String returnUserId;
@TableField("repair_name")
private String repairName;
@TableField("destory_name")
private String destoryName;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -25,13 +25,13 @@ import org.springframework.data.elasticsearch.annotations.Document;
public class PubOrg implements Serializable {
//此项作为id,不会写到_source里边。
@Id
private String id;
// @Id
// private String id;
/**
* 主键
*/
@TableId(type = IdType.AUTO, value = "org_id")
@Id
private Long orgId;
/**
* 主键
......
......@@ -2,11 +2,13 @@ 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.NormalInOutDto;
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;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
......@@ -31,4 +33,14 @@ public interface InventorySummaryMapper extends BaseMapper<InventorySummary> {
InventorySummary EquipmentStatistics(@Param("req") InventorySumReq req);
List<InventorySummary> selectByEqs(@Param("orgId") Long orgId);
// @Select({
// "<script>",
// "<foreach collection='list' item='item' open='(' separator=',' close=')'>",
// "select * from base_inventory_summary",
// "where org_id_int=#{item[0]} and location_id=#{item[1]} and size_id=#{item[2]} and type_id=#{item[3]} and unit_price=#{item[4]}}}",
// "</foreach>",
// "</script>"
// })
List<InventorySummary> selectByItems(@Param("list") List<Object[]> list);
}
\ No newline at end of file
package com.junmp.jyzb.mapper;
import com.junmp.jyzb.api.bean.dto.LogDetailDto;
import com.junmp.jyzb.entity.LogDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author lxh专属坐骑
......@@ -11,6 +15,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface LogDetailMapper extends BaseMapper<LogDetail> {
List<LogDetailDto> GetDetailByLogSumId(@Param("summaryId") Long summaryId);
List<LogDetailDto> ShowInOutRecordsByOrder(@Param("orderMainId") String orderMainId);
}
......
......@@ -14,11 +14,7 @@ import org.apache.ibatis.annotations.Param;
* @Entity com.junmp.jyzb.entity.LogSummary
*/
public interface LogSummaryMapper extends BaseMapper<LogSummary> {
IPage<LogSummary> ShowInOutRecordsByOrder(Page<LogSummary> page, @Param("req") LogSummaryReq req);
IPage<LogSummary> ShowInOutRecordsByWarehouse(Page<LogSummary> page,@Param("req") LogSummaryReq req);
IPage<LogSummary> ShowInOutRecordsByCabinet(Page<LogSummary> page,@Param("req") LogSummaryReq req);
// IPage<LogSummary> ShowInOutRecordsPage(Page<LogSummary> page,@Param("req") LogSummaryReq req);
// IPage<LogSummary> ShowInOutRecordsByItems(Page<LogSummary> page,@Param("req") LogSummaryReq req);
}
......
package com.junmp.jyzb.rabbitmq;
import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.OutInLogsReq;
import com.junmp.jyzb.service.LogSummaryService;
import com.junmp.jyzb.service.OrderMainService;
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 OutInLogsReceiver {
@Resource
private LogSummaryService logSummaryService;
@RabbitListener(queues = "11111")//监听队列名
private void a(OutInLogsReq req, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag){
try {
System.out.println("req = " + req);
//将消息进行消费
Boolean result = logSummaryService.processInventoryRecords(req);
if (result){
// 手动确认消息
channel.basicAck(deliveryTag, false);
}else {
channel.basicNack(deliveryTag, false, true);
}
// 手动确认消息
// channel.basicAck(deliveryTag, false);
} catch (Exception e) {
// 处理消息过程中发生异常,拒绝消息并将其重新放回队列
try {
channel.basicNack(deliveryTag, false, true);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}
}
......@@ -9,6 +9,8 @@ import com.junmp.jyzb.entity.BusForm;
import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.v2.db.api.page.PageResult;
import java.util.List;
/**
* @author lxh专属坐骑
* @description 针对表【base_bus_form】的数据库操作Service
......@@ -33,5 +35,5 @@ public interface BusFormService extends IService<BusForm> {
PageResult<BusFormDto> showBussinessOrder(QueryBusFormReq req);
//根据调拨单,一键生成采购单
GeneratePurchaseQuicklyDto GeneratePurchaseQuickly(GeneratePurchaseQuicklyReq req);
List<GeneratePurchaseQuicklyDto> GeneratePurchaseQuickly(GeneratePurchaseQuicklyReq req);
}
......@@ -80,12 +80,4 @@ public interface InventoryService extends IService<Inventory> {
boolean BatchEditingInvsInfo(BatchEditingInvsReq req);
//获取装备的出入库记录(根据装备id获取某件装备的出入库记录信息)
PageResult<LogDetail> getInOutRecords(InventoryReq req);
//根据单据获取出入库记录
PageResult<LogSummary> ShowInOutRecordsByOrder(LogSummaryReq req);
PageResult<LogSummary> ShowInOutRecordsByItems(LogSummaryReq req);
}
......@@ -2,6 +2,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.dto.NormalInOutDto;
import com.junmp.jyzb.api.bean.query.InventorySumReq;
import com.junmp.jyzb.api.bean.req.CabinetInOutRecordsReq;
import com.junmp.jyzb.api.bean.req.RabbitMqOrderReq;
......@@ -36,5 +37,5 @@ public interface InventorySummaryService extends IService<InventorySummary> {
List<InventorySummary> EquipmentStatistics(InventorySumReq req);
List<InventorySummary> selectByItems(List<Object[]> searchCriteria);
}
package com.junmp.jyzb.service;
import com.junmp.jyzb.api.bean.dto.LogDetailDto;
import com.junmp.jyzb.api.bean.query.InventoryReq;
import com.junmp.jyzb.api.bean.query.LogDetailReq;
import com.junmp.jyzb.api.bean.query.LogSummaryReq;
import com.junmp.jyzb.entity.LogDetail;
import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.v2.db.api.page.PageResult;
import java.util.List;
/**
* @author lxh专属坐骑
......@@ -10,4 +17,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface LogDetailService extends IService<LogDetail> {
//根据logSumId查询详情
List<LogDetailDto> GetDetailByLogSumId(LogDetailReq req);
//根据单据获取出入库记录
List<LogDetailDto> ShowInOutRecordsByOrder(LogSummaryReq req);
//获取装备的出入库记录(根据装备id获取某件装备的出入库记录信息)
PageResult<LogDetail> getInOutRecords(InventoryReq req);
}
package com.junmp.jyzb.service;
import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.OutInLogsReq;
import com.junmp.jyzb.api.bean.query.LogSummaryReq;
import com.junmp.jyzb.entity.LogSummary;
import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.v2.db.api.page.PageResult;
/**
* @author lxh专属坐骑
......@@ -10,4 +13,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface LogSummaryService extends IService<LogSummary> {
PageResult<LogSummary> ShowInOutRecordsByItems(LogSummaryReq req);
//本地主机返回出入库结果
Boolean processInventoryRecords(OutInLogsReq req);
}
......@@ -4,9 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.api.bean.dto.OrderDto;
import com.junmp.jyzb.api.bean.dto.OrderMainDto;
import com.junmp.jyzb.api.bean.dto.ProcessOrderDto;
import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.OutInLogsReq;
import com.junmp.jyzb.api.bean.query.OrderMainReq;
import com.junmp.jyzb.api.bean.query.OrderUploadReq;
import com.junmp.jyzb.api.bean.query.ProcessOrderReq;
import com.junmp.jyzb.api.bean.query.QueryOrderLogReq;
import com.junmp.jyzb.api.bean.req.UpdateOrderReq;
import com.junmp.jyzb.entity.OrderLog;
......@@ -48,5 +48,6 @@ public interface OrderMainService extends IService<OrderMain> {
void OutOrderExport(OrderMainReq req);
ProcessOrderDto GetByProcessId(ProcessOrderReq req);
ProcessOrderDto GetByProcessId(OrderMainReq req);
}
......@@ -175,23 +175,77 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl
//根据调拨单,一键生成采购单
@Override
public GeneratePurchaseQuicklyDto GeneratePurchaseQuickly(GeneratePurchaseQuicklyReq req) {
public List<GeneratePurchaseQuicklyDto> GeneratePurchaseQuickly(GeneratePurchaseQuicklyReq req) {
//先把所有发物单位是自己的业务单全部查询出来,然后一一进行比较到底那个是前端传递的数据
// List<BusForm> list = list(new LambdaQueryWrapper<BusForm>()
// .eq(BusForm::getOrgId, req.getOrgId())
// .eq(BusForm::getBussinessType, req.getBussinessType()));
//将所有调拨单中的装备添加到totalList,之后进行去重并且相应数量相加
List<BussinessOrderDetialReq> totalList=new ArrayList<>();
//将所有调拨单获取
List<UpdateBusFormReq> busFormList = req.getBusFormList();
for (UpdateBusFormReq updateBusFormReq:busFormList) {
String detailList = updateBusFormReq.getDetailList();
List<BussinessOrderDetialReq> list = JSONObject.parseArray(detailList, BussinessOrderDetialReq.class);
totalList.addAll(list);
}
//查询库存数量
//newList用来去重,把相同size和type的数量进行相加
List<BussinessOrderDetialReq> newList=new ArrayList<>();
for (BussinessOrderDetialReq item :totalList) {
boolean found=false;
if (newList.size()==0){
newList.add(item);
continue;
}
for (BussinessOrderDetialReq listItem:newList) {
if (listItem.getSizeId().equals(item.getSizeId()) && listItem.getTypeId().equals(item.getTypeId())) {
// 如果存在匹配的元素,则更新 num 值
listItem.setPlanNum(listItem.getPlanNum() + item.getPlanNum());
found = true;
break;
}
}
if (!found){
newList.add(item);
}
}
//创建list,返回给前端(只返回库存不足的装备和数量)
List<GeneratePurchaseQuicklyDto> returnList=new ArrayList<>();
//查询库存数量(将该组织机构下面的所有类型和号型的数量查询出来)
List<InventorySummary> sumList = inventorySummaryMapper.selectByEqs(req.getOrgId());
for (BussinessOrderDetialReq bussinessOrderDetial:newList) {
boolean flag=false;
for (InventorySummary inventorySummary:sumList) {
if (bussinessOrderDetial.getSizeId().equals(inventorySummary.getSizeId())
&& bussinessOrderDetial.getTypeId().equals(inventorySummary.getSizeId())){
//判断两个数量谁打谁小
if (bussinessOrderDetial.getPlanNum()-inventorySummary.getStockNumber()>0){
GeneratePurchaseQuicklyDto generatePurchaseQuicklyDto = new GeneratePurchaseQuicklyDto();
generatePurchaseQuicklyDto.setNumber(bussinessOrderDetial.getPlanNum()-inventorySummary.getStockNumber());
generatePurchaseQuicklyDto.setSizeId(bussinessOrderDetial.getSizeId());
generatePurchaseQuicklyDto.setSizeName(bussinessOrderDetial.getSizeName());
generatePurchaseQuicklyDto.setTypeId(bussinessOrderDetial.getTypeId());
generatePurchaseQuicklyDto.setTypeName(bussinessOrderDetial.getTypeName());
returnList.add(generatePurchaseQuicklyDto);
}
flag=true;
break;
}
}
if (!flag){
GeneratePurchaseQuicklyDto generatePurchaseQuicklyDto = new GeneratePurchaseQuicklyDto();
generatePurchaseQuicklyDto.setNumber(bussinessOrderDetial.getPlanNum());
generatePurchaseQuicklyDto.setSizeId(bussinessOrderDetial.getSizeId());
generatePurchaseQuicklyDto.setSizeName(bussinessOrderDetial.getSizeName());
generatePurchaseQuicklyDto.setTypeId(bussinessOrderDetial.getTypeId());
generatePurchaseQuicklyDto.setTypeName(bussinessOrderDetial.getTypeName());
returnList.add(generatePurchaseQuicklyDto);
}
}
return null;
return returnList;
}
}
......
......@@ -544,54 +544,6 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
}
//根据单据查询出入库记录
@Override
public PageResult<LogSummary> ShowInOutRecordsByOrder(LogSummaryReq req) {
Page<LogSummary> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
IPage<LogSummary> ipage=logSummaryMapper.ShowInOutRecordsByOrder(page,req);
List<LogSummary> logSummaryList=new ArrayList<>();
ipage.getRecords().forEach(logSummary -> {
List<LogDetail> list = logDetailService.list(new LambdaQueryWrapper<LogDetail>()
.eq(LogDetail::getSummaryId, logSummary.getId()));
logSummary.setLogDetailList(list);
logSummaryList.add(logSummary);
});
page.setRecords(logSummaryList);
return PageResultFactory.createPageResult(page);
}
//根据条件查询出入库记录
@Override
public PageResult<LogSummary> ShowInOutRecordsByItems(LogSummaryReq req) {
Page<LogSummary> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
List<LogSummary> logSummaryList=new ArrayList<>();
IPage<LogSummary> ipage;
if (req.getLocationType()==0){
ipage = logSummaryMapper.ShowInOutRecordsByWarehouse(page, req);
}else {
ipage=logSummaryMapper.ShowInOutRecordsByCabinet(page,req);
}
ipage.getRecords().forEach(logSummary -> {
List<LogDetail> list = logDetailService.list(new LambdaQueryWrapper<LogDetail>()
.eq(LogDetail::getSummaryId, logSummary.getId()));
logSummary.setLogDetailList(list);
logSummaryList.add(logSummary);
});
page.setRecords(logSummaryList);
return PageResultFactory.createPageResult(page);
}
//获取装备的出入库信息(根据装备id获取该装备的出入库记录)
@Override
public PageResult<LogDetail> getInOutRecords(InventoryReq req) {
//通过装备id获取出入库记录(判断id是否存在)
InventoryExist(req.getId());
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);
}
//查询装备数量报表
@Override
public List<EqsSumDto> GetListEquipment(InventoryReq req) {
......
......@@ -5,6 +5,7 @@ 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.NormalInOutDto;
import com.junmp.jyzb.api.bean.dto.WarehouseDto;
import com.junmp.jyzb.api.bean.query.InventoryReq;
import com.junmp.jyzb.api.bean.query.InventorySumReq;
......@@ -130,7 +131,13 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean processInventoryRecords(RabbitMqOrderReq req) {
//新增列表
List<Inventory> addList = new ArrayList<>();
//更新列表
List<Inventory> updateList = new ArrayList<>();
boolean c;
//将主单据信息复制进行更新
if (ObjectUtil.isNotNull(req.getOrderMain()) && ObjectUtil.isNotNull(req.getOrderDetail())){
OrderMain orderMain = new OrderMain();
BeanPlusUtil.copyProperties(req.getOrderMain(),orderMain);
orderMainService.updateById(orderMain);
......@@ -140,11 +147,6 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
BeanPlusUtil.copyProperties(req.getOrderDetail(),orderDetail);
orderDetailService.updateById(orderDetail);
////对装备表进行更新或者添加
//新增列表
List<Inventory> addList = new ArrayList<>();
//更新列表
List<Inventory> updateList = new ArrayList<>();
//出库out,入库in
String orderType=orderMain.getOrderType();
//组织机构
......@@ -160,12 +162,13 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
BeanPlusUtil.copyProperties(inventoryReq,inventory);
inventory.setOrgId(orgId);
//新增装备
if (ObjectUtil.isNull(inventory.getId())){
if (ObjectUtil.isNull(inventory.getId() ) || inventory.getId().trim().isEmpty()){
//修改状态
inventory.setId(UUID.randomUUID().toString());
inventory.setLocationState(orderMain.getOrderType());
inventory.setBussinessState("normal");
inventory.setState("normal");
inventory.setLostFlag(0);
addList.add(inventory);
}else {
//修改状态
......@@ -187,6 +190,32 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
updateList.add(inventory);
}
});
c = insertLog(req,orderMain,addList,updateList);
}else {
////对装备表进行更新或者添加
String outInState =req.getInventoryReqList().get(0).getLocationState();
Long orgId=req.getInventoryReqList().get(0).getOrgId();
//将具体Epc进行处理(判断装备是否具有id,如果没有id表示新增一条数据在数据库中--采购)
req.getInventoryReqList().forEach(inventoryReq -> {
Inventory inventory = new Inventory();
BeanPlusUtil.copyProperties(inventoryReq,inventory);
//新增装备
if (ObjectUtil.isNull(inventory.getId() ) || inventory.getId().trim().isEmpty()){
//修改状态
inventory.setId(UUID.randomUUID().toString());
inventory.setBussinessState("normal");
inventory.setState("normal");
inventory.setLostFlag(0);
addList.add(inventory);
}else {
updateList.add(inventory);
}
});
//对装备进行记录,存入log表形成出入库记录
c = insertLogWithOutOrder(req,addList,updateList,orgId,outInState);
}
boolean b=false;
if (ObjectUtil.isNotNull(addList) && addList.size()>0){
b = inventoryService.saveBatch(addList);
......@@ -194,9 +223,7 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
if (ObjectUtil.isNotNull(updateList) && updateList.size()>0){
b = inventoryService.updateBatchById(updateList);
}
//对装备进行记录,存入log表形成出入库记录
Boolean c = insertLog(req,orderMain,addList,updateList);
// Boolean d = updateSummaryInsByOrder(orgId);
return (b && c );
}
......@@ -211,8 +238,6 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
logSummary.setLocationType(0);
logSummary.setUserName(req.getUserName());
logSummary.setUseTime(req.getUseTime());
// logSummary.setLocationId();
// logSummary.setLocationName();
if (orderMain.getOrderType().equals("in")){
logSummary.setOutInState("in");
logSummary.setOrgId(orderMain.getEndOrgId());
......@@ -228,31 +253,152 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
boolean a = logSummaryService.save(logSummary);
//存入log_detail表中
List<LogDetail> logDetailList=new ArrayList<>();
List<String> eqsList=new ArrayList<>();
//判断是哪个列表不为空,进行出入库记录
if (addList.size()!=0 && ObjectUtil.isNotNull(addList)){
for (Inventory inventory:addList) {
LogDetail logDetail = new LogDetail();
BeanPlusUtil.copyProperties(inventory,logDetail);
logDetail.setEquipmentType(0);
logDetail.setInventoryId(inventory.getId());
logDetail.setBussinessType(orderMain.getBussinessType());
logDetail.setOutInState(orderMain.getOrderType());
logDetail.setOrderCode(orderMain.getOrderCode());
logDetail.setSummaryId(logSummary.getId());
logDetail.setOrderMainId(orderMain.getId());
logDetail.setErrorState(0);
logDetailList.add(logDetail);
//创建一个列表用于存入装备list
if (eqsList.size()==0){
eqsList.add(inventory.getTypeName());
}
boolean flag=false;
for (String eqsName:eqsList ) {
if (eqsName.equals(inventory.getTypeName())){
flag=true;
break;
}
}
if (!flag){
eqsList.add(inventory.getTypeName());
}
logSummary.setCreateTime(inventory.getCreateTime());
}
}
if (updateList.size()!=0 && ObjectUtil.isNotNull(updateList)){
for (Inventory inventory:updateList) {
LogDetail logDetail = new LogDetail();
BeanPlusUtil.copyProperties(inventory,logDetail);
logDetail.setEquipmentType(0);
logDetail.setInventoryId(inventory.getId());
logDetail.setBussinessType(orderMain.getBussinessType());
logDetail.setOutInState(orderMain.getOrderType());
logDetail.setSummaryId(logSummary.getId());
logDetail.setOrderMainId(orderMain.getId());
logDetail.setErrorState(0);
logDetailList.add(logDetail);
if (eqsList.size()==0){
eqsList.add(inventory.getTypeName());
}
boolean flag=false;
for (String eqsName:eqsList ) {
if (eqsName.equals(inventory.getTypeName())){
flag=true;
break;
}
}
if (!flag){
eqsList.add(inventory.getTypeName());
}
logSummary.setCreateTime(inventory.getCreateTime());
}
}
String equipmentList = String.join("/", eqsList);
logSummary.setEquipmentList(equipmentList);
logSummaryService.updateById(logSummary);
boolean b = logDetailService.saveBatch(logDetailList);
return (a && b);
}
@Transactional(rollbackFor = Exception.class)
public Boolean insertLogWithOutOrder(RabbitMqOrderReq req,List<Inventory> addList,List<Inventory> updateList,Long orgId ,String outInState){
//插入log_summary
LogSummary logSummary = new LogSummary();
logSummary.setDevice(req.getDevice());
logSummary.setDeviceType(req.getDeviceType());
logSummary.setLocationType(0);
logSummary.setOrgId(orgId);
logSummary.setUserName(req.getUserName());
logSummary.setUseTime(req.getUseTime());
logSummary.setOutInState(outInState);
logSummary.setBussinessType("normal");
boolean a = logSummaryService.save(logSummary);
//存入log_detail表中
List<LogDetail> logDetailList=new ArrayList<>();
List<String> eqsList=new ArrayList<>();
//判断是哪个列表不为空,进行出入库记录
if (addList.size()!=0 && ObjectUtil.isNotNull(addList)){
for (Inventory inventory:addList) {
LogDetail logDetail = new LogDetail();
BeanPlusUtil.copyProperties(inventory,logDetail);
logDetail.setEquipmentType(0);
logDetail.setInventoryId(inventory.getId());
logDetail.setBussinessType("normal");
logDetail.setOutInState(inventory.getLocationState());
logDetail.setSummaryId(logSummary.getId());
logDetail.setErrorState(0);
logDetailList.add(logDetail);
//创建一个列表用于存入装备list
if (eqsList.size()==0){
eqsList.add(inventory.getTypeName());
}
boolean flag=false;
for (String eqsName:eqsList ) {
if (eqsName.equals(inventory.getTypeName())){
flag=true;
break;
}
}
if (!flag){
eqsList.add(inventory.getTypeName());
}
logSummary.setCreateTime(inventory.getCreateTime());
}
}
if (updateList.size()!=0 && ObjectUtil.isNotNull(updateList)){
for (Inventory inventory:updateList) {
LogDetail logDetail = new LogDetail();
BeanPlusUtil.copyProperties(inventory,logDetail);
logDetail.setEquipmentType(0);
logDetail.setInventoryId(inventory.getId());
logDetail.setBussinessType("normal");
logDetail.setOutInState(inventory.getLocationState());
logDetail.setSummaryId(logSummary.getId());
logDetail.setErrorState(0);
logDetailList.add(logDetail);
//创建一个列表用于存入装备list
if (eqsList.size()==0){
eqsList.add(inventory.getTypeName());
}
boolean flag=false;
for (String eqsName:eqsList ) {
if (eqsName.equals(inventory.getTypeName())){
flag=true;
break;
}
}
if (!flag){
eqsList.add(inventory.getTypeName());
}
logSummary.setCreateTime(inventory.getCreateTime());
}
}
String equipmentList = String.join("/", eqsList);
logSummary.setEquipmentList(equipmentList);
logSummaryService.updateById(logSummary);
boolean b = logDetailService.saveBatch(logDetailList);
return (a && b);
}
......@@ -367,6 +513,10 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
return inventorySummaryList;
}
@Override
public List<InventorySummary> selectByItems(List<Object[]> searchCriteria) {
return inventorySummaryMapper.selectByItems(searchCriteria);
}
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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.dto.LogDetailDto;
import com.junmp.jyzb.api.bean.query.InventoryReq;
import com.junmp.jyzb.api.bean.query.LogDetailReq;
import com.junmp.jyzb.api.bean.query.LogSummaryReq;
import com.junmp.jyzb.entity.LogDetail;
import com.junmp.jyzb.service.InventoryService;
import com.junmp.jyzb.service.LogDetailService;
import com.junmp.jyzb.mapper.LogDetailMapper;
import com.junmp.v2.db.api.factory.PageFactory;
import com.junmp.v2.db.api.factory.PageResultFactory;
import com.junmp.v2.db.api.page.PageResult;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author lxh专属坐骑
* @description 针对表【base_log_detail】的数据库操作Service实现
......@@ -15,6 +28,40 @@ import org.springframework.stereotype.Service;
public class LogDetailServiceImpl extends ServiceImpl<LogDetailMapper, LogDetail>
implements LogDetailService{
@Resource
private LogDetailService logDetailService;
@Resource
private InventoryService inventoryService;
@Resource
private LogDetailMapper logDetailMapper;
//根据logSumId查询详情
@Override
public List<LogDetailDto> GetDetailByLogSumId(LogDetailReq req) {
List<LogDetailDto> list = logDetailMapper.GetDetailByLogSumId(req.getSummaryId());
return list;
}
//根据单据查询出入库记录
@Override
public List<LogDetailDto> ShowInOutRecordsByOrder(LogSummaryReq req) {
List<LogDetailDto> list = logDetailMapper.ShowInOutRecordsByOrder(req.getOrderMainId());
return list;
}
//获取装备的出入库信息(根据装备id获取该装备的出入库记录)
@Override
public PageResult<LogDetail> getInOutRecords(InventoryReq req) {
//通过装备id获取出入库记录(判断id是否存在)
inventoryService.InventoryExist(req.getId());
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);
}
}
......
package com.junmp.jyzb.service.impl;
import cn.hutool.core.util.ObjectUtil;
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.entity.LogSummary;
import com.junmp.jyzb.service.LogSummaryService;
import com.junmp.jyzb.api.bean.dto.InventorySumDto;
import com.junmp.jyzb.api.bean.dto.NormalInOutDto;
import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.*;
import com.junmp.jyzb.api.bean.query.LogSummaryReq;
import com.junmp.jyzb.entity.*;
import com.junmp.jyzb.mapper.InventorySummaryMapper;
import com.junmp.jyzb.service.*;
import com.junmp.jyzb.mapper.LogSummaryMapper;
import com.junmp.jyzb.utils.DateTimeUtil;
import com.junmp.v2.common.util.BeanPlusUtil;
import com.junmp.v2.db.api.factory.PageFactory;
import com.junmp.v2.db.api.factory.PageResultFactory;
import com.junmp.v2.db.api.page.PageResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author lxh专属坐骑
......@@ -15,6 +34,198 @@ import org.springframework.stereotype.Service;
public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSummary>
implements LogSummaryService{
@Resource
private LogSummaryService logSummaryService;
@Resource
private InventoryService inventoryService;
@Resource
private OrderMainService orderMainService;
@Resource
private OrderDetailService orderDetailService;
@Resource
private LogDetailService logDetailService;
@Resource
private InventorySummaryService inventorySummaryService;
@Resource
private InventorySummaryMapper inventorySummaryMapper;
//根据条件查询出入库记录
@Override
public PageResult<LogSummary> ShowInOutRecordsByItems(LogSummaryReq req) {
//(如果传其他不是数据库字段参数或者排序规则不是deac或者asc可能会出现错误)
if (ObjectUtil.isNotNull(req.getColumn()) && !req.getColumn().trim().isEmpty() &&
(req.getOrder().equalsIgnoreCase("asc")|| req.getOrder().equalsIgnoreCase("desc")) &&
ObjectUtil.isNotNull(req.getOrder()) && !req.getOrder().trim().isEmpty()) {
//修改字段,和数据库字段进行统一
req.setColumn(req.getColumn().replaceAll("[A-Z]", "_$0").toLowerCase());
req.setOrder(req.getOrder().toLowerCase());
}
LambdaQueryWrapper<LogSummary> eq = new LambdaQueryWrapper<LogSummary>()
.eq(LogSummary::getOrgId,req.getOrgId())
.eq(LogSummary::getLocationType,req.getLocationType())
.eq(ObjectUtil.isNotNull(req.getBussinessType()) && !req.getBussinessType().trim().isEmpty(),LogSummary::getBussinessType,req.getBussinessType())
.eq(ObjectUtil.isNotNull(req.getOutInState()) && !req.getOutInState().trim().isEmpty(),LogSummary::getOutInState,req.getOutInState())
.eq(ObjectUtil.isNotNull(req.getLocationId()),LogSummary::getLocationId,req.getLocationId())
.eq(ObjectUtil.isNotNull(req.getUserName()),LogSummary::getUserName,req.getUserName())
.ge(ObjectUtil.isNotNull(req.getStartTime()),LogSummary::getUseTime,req.getStartTime())
.le(ObjectUtil.isNotNull(req.getEndTime()),LogSummary::getUseTime,req.getEndTime())
.like(ObjectUtil.isNotNull(req.getEquipmentList()),LogSummary::getEquipmentList,req.getEquipmentList())
.last("order by " + req.getColumn() + " " + req.getOrder());
Page<LogSummary> page = logSummaryService.page(PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()), eq);
return PageResultFactory.createPageResult(page);
}
//本地主机返回出入库结果
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean processInventoryRecords(OutInLogsReq req) {
//1.判断业务类型,如果是采购,更新装备库存表
if (req.getBussinessType().equals("purchase")){
List<PurchaseEqsReq> purchaseList = req.getOrderMain().getPurchaseList();
List<Inventory> collect = purchaseList.stream().map(purchaseEqsReq -> {
Inventory inventory = new Inventory();
BeanPlusUtil.copyProperties(purchaseEqsReq, inventory);
return inventory;
}).collect(Collectors.toList());
inventoryService.saveBatch(collect);
}
//2.如果有单据,更新单据
if (ObjectUtil.isNotNull(req.getOrderMain())){
OrderReq orderMain = req.getOrderMain();
List<DetailOrderReq> orderDetailList = orderMain.getOrderDetail();
OrderMain one = orderMainService.getOne(new LambdaQueryWrapper<OrderMain>()
.eq(OrderMain::getId, orderMain.getId()));
one.setPrice(orderMain.getPrice());
one.setActualQuantity(orderMain.getActualQuantity());
one.setOrderState(one.getOrderState());
orderMainService.updateById(one);
List<OrderDetail> collect = orderDetailList.stream().map(detailOrderReq -> {
OrderDetail orderDetail = new OrderDetail();
BeanPlusUtil.copyProperties(detailOrderReq, orderDetail);
return orderDetail;
}).collect(Collectors.toList());
orderDetailService.updateBatchById(collect);
}
//3.对出入库记录进行存储
List<NormalInOutDto> inventorySumDtos = saveInOutRecords(req);
//4.如果没有单据,当作日常出入库,需要对库存汇总表进行更新
if (req.getBussinessType().equals("normal")){
//获取到组织机构和仓库,将出入库的装备进行分组统计,并且对inventorysummary进行更新操作
updateNumToSum(inventorySumDtos,req.getOutInState());
}
return false;
}
//对库存汇总表进行更新(只限于日常出入库)
private void updateNumToSum(List<NormalInOutDto> inventorySumDtos,String OutInState) {
List<NormalInOutDto> groupedResult = inventorySumDtos.stream()
.collect(Collectors.groupingBy(dto -> dto.getOrgId() + "_" + dto.getLocationId() + "_" +
dto.getSizeId() + "_" + dto.getTypeId() + "_" + dto.getPrice(),
Collectors.collectingAndThen(Collectors.toList(), group -> {
NormalInOutDto result = new NormalInOutDto();
result.setOrgId(group.get(0).getOrgId());
result.setLocationId(group.get(0).getLocationId());
result.setSizeId(group.get(0).getSizeId());
result.setTypeId(group.get(0).getTypeId());
result.setPrice(group.get(0).getPrice());
result.setNumber(group.stream().mapToInt(NormalInOutDto::getNumber).sum());
return result;
})))
.values().stream()
.collect(Collectors.toList());
List<Object[]> searchCriteria = new ArrayList<>();
for (NormalInOutDto groupedDto : groupedResult) {
Object[] criteria = new Object[]{groupedDto.getOrgId(), groupedDto.getLocationId(),
groupedDto.getSizeId(), groupedDto.getTypeId(), groupedDto.getPrice()};
searchCriteria.add(criteria);
}
inventorySummaryMapper.selectByItems(searchCriteria);
}
//对出入库记录进行存储
@Transactional(rollbackFor = Exception.class)
public List<NormalInOutDto> saveInOutRecords(OutInLogsReq req) {
//返回结果,用于日常出入库时计算更新库存汇总表
List<NormalInOutDto> returnList=new ArrayList<>();
List<LogDetail> logDetailList=new ArrayList<>();
List<SummaryLogReq> logSummaryList = req.getLogSummaryList();
//如果是日常出入库,那么将这些出入库数据进行计算,最终更新库存汇总表中的数据
if (req.getBussinessType().equals("normal")){
for (SummaryLogReq summaryLogReq:logSummaryList) {
LogSummary logSummary = new LogSummary();
BeanPlusUtil.copyProperties(summaryLogReq,logSummary);
logSummary.setOutInState(req.getOutInState());
logSummary.setCreateTime(DateTimeUtil.getCurrentDateTime());
logSummary.setUpdateTime(DateTimeUtil.getCurrentDateTime());
logSummary.setBussinessType(req.getBussinessType());
logSummary.setOrgId(req.getOrgId());
logSummary.setOrgName(req.getOrgName());
logSummaryService.save(logSummary);
List<DetailLogReq> logList = summaryLogReq.getLogDetailList();
//出入库list
List<LogDetail> collect=new ArrayList<>();
//用于装备汇总list
List<NormalInOutDto> list=new ArrayList<>();
for (DetailLogReq detailLogReq: logList) {
//将所有装备信息进行存放(为后面计算汇总信息)
NormalInOutDto normalInOutDto = new NormalInOutDto();
BeanPlusUtil.copyProperties(detailLogReq,normalInOutDto);
normalInOutDto.setLocationId(logSummary.getLocationId());
normalInOutDto.setLocationName(logSummary.getLocationName());
normalInOutDto.setOrgId(logSummary.getOrgId());
normalInOutDto.setOrgName(logSummary.getOrgName());
normalInOutDto.setNumber(1);
list.add(normalInOutDto);
//存放logdetail信息
LogDetail logDetail = new LogDetail();
BeanPlusUtil.copyProperties(detailLogReq, logDetail);
logDetail.setSummaryId(logSummary.getId());
collect.add(logDetail);
}
logDetailList.addAll(collect);
returnList.addAll(list);
}
logDetailService.saveBatch(logDetailList);
return returnList;
}else {
//外层的logSummary只能逐个进行插入,logDetail可以批量进行插入
for (SummaryLogReq summaryLogReq:logSummaryList) {
LogSummary logSummary = new LogSummary();
BeanPlusUtil.copyProperties(summaryLogReq,logSummary);
logSummary.setOutInState(req.getOutInState());
logSummary.setCreateTime(DateTimeUtil.getCurrentDateTime());
logSummary.setUpdateTime(DateTimeUtil.getCurrentDateTime());
logSummary.setBussinessType(req.getBussinessType());
logSummary.setOrgId(req.getOrgId());
logSummary.setOrgName(req.getOrgName());
logSummaryService.save(logSummary);
List<LogDetail> collect = summaryLogReq.getLogDetailList().stream().map(detailLogReq -> {
LogDetail logDetail = new LogDetail();
NormalInOutDto inventorySumDto = new NormalInOutDto();
BeanPlusUtil.copyProperties(detailLogReq,inventorySumDto);
BeanPlusUtil.copyProperties(detailLogReq, logDetail);
logDetail.setSummaryId(logSummary.getId());
return logDetail;
}).collect(Collectors.toList());
logDetailList.addAll(collect);
}
logDetailService.saveBatch(logDetailList);
return returnList;
}
}
}
......
......@@ -10,6 +10,7 @@ import com.junmp.junmpProcess.dto.StartProcessInstanceDTO;
import com.junmp.junmpProcess.service.IFlowInstanceService;
import com.junmp.jyzb.api.bean.dto.*;
import com.junmp.jyzb.api.bean.query.*;
import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.OutInLogsReq;
import com.junmp.jyzb.api.bean.req.UpdateOrderDetailReq;
import com.junmp.jyzb.api.bean.req.UpdateOrderReq;
import com.junmp.jyzb.api.bean.vo.InOrderInfo;
......@@ -823,13 +824,21 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
* @return
*/
@Override
public ProcessOrderDto GetByProcessId(ProcessOrderReq req) {
public ProcessOrderDto GetByProcessId(OrderMainReq req) {
ProcessOrderDto processOrderDto = new ProcessOrderDto();
System.out.println("req = " + req.getOrderType());
if (req.getOrderType().equals("null")|| ObjectUtil.isNull(req.getOrderType())) {
return processOrderDto;
}
if (req.getOrderType().equals("workOrder")){
OrderDto orderDto = new OrderDto();
OrderMain one = getOne(new LambdaQueryWrapper<OrderMain>()
.eq(OrderMain::getProcessId, req.getProcessInstanceId()));
if (ObjectUtil.isNull(one)){
return processOrderDto;
}
BeanPlusUtil.copyProperties(one,orderDto);
List<OrderDetailDto> collect = orderDetailService.list(new LambdaQueryWrapper<OrderDetail>()
.eq(OrderDetail::getOrderId, one.getId())).stream().map(orderDetail -> {
OrderDetailDto orderDetailDto = new OrderDetailDto();
......@@ -861,4 +870,5 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
}
}
......@@ -482,7 +482,7 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
//根据组织机构id查询出组织机构是否存在
@Override
public PubOrg PubOrgExist(Long id) {
PubOrg puborg = getById(id);
PubOrg puborg = getOne(new LambdaQueryWrapper<PubOrg>().eq(PubOrg::getOrgId, id));
if (ObjectUtil.isEmpty(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
......
......@@ -261,7 +261,17 @@
MAX(type_name) as typeName,org_id_int as orgId,MAX(org_name) as orgName
FROM base_inventory_summary where org_id_int=#{orgId}
GROUP BY size_id,type_id
HAVING stockNumber>0
</select>
<select id="selectByItems" resultType="com.junmp.jyzb.entity.InventorySummary">
<foreach collection="list" item="item" open="(" separator="," close=")">
select * from base_inventory_summary where
org_id_int = #{item[0]} AND location_id = #{item[1]}
AND size_id = #{item[2]} AND type_id = #{item[3]}
AND unit_price = #{item[4]}
</foreach>
</select>
<delete id="deleteByWarehouse"
parameterType="com.junmp.jyzb.api.bean.dto.WarehouseDto">
delete from base_inventory_summary
......
......@@ -7,7 +7,6 @@
<resultMap id="BaseResultMap" type="com.junmp.jyzb.entity.LogDetail">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="inventoryId" column="inventory_id" jdbcType="VARCHAR"/>
<result property="orderMainId" column="order_main_id" jdbcType="VARCHAR"/>
<result property="bussinessType" column="bussiness_type" jdbcType="VARCHAR"/>
<result property="epc" column="epc" jdbcType="VARCHAR"/>
<result property="typeId" column="type_id" jdbcType="VARCHAR"/>
......@@ -24,7 +23,6 @@
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
<result property="createUser" column="create_user" jdbcType="VARCHAR"/>
<result property="picture" column="picture" jdbcType="VARCHAR"/>
<result property="deviceType" column="device_type" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -36,4 +34,12 @@
update_time,update_user,create_user,
picture,device_type
</sql>
<select id="GetDetailByLogSumId" resultType="com.junmp.jyzb.api.bean.dto.LogDetailDto">
SELECT ld.*,ls.location_name FROM base_log_detail ld
join base_log_summary ls on ld.summary_id=ls.id and ld.summary_id=#{summaryId}
</select>
<select id="ShowInOutRecordsByOrder" resultType="com.junmp.jyzb.api.bean.dto.LogDetailDto">
SELECT ls.location_name,ls.order_main_id,ld.* FROM base_log_summary ls
join base_log_detail ld on ld.summary_id=ls.id and ls.order_main_id=#{orderMainId}
</select>
</mapper>
......@@ -4,6 +4,8 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.junmp.jyzb.mapper.LogSummaryMapper">
<resultMap id="BaseResultMap" type="com.junmp.jyzb.entity.LogSummary">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="orgId" column="org_id" jdbcType="BIGINT"/>
......@@ -11,8 +13,6 @@
<result property="orderMainId" column="order_main_id" jdbcType="VARCHAR"/>
<result property="device" column="device" jdbcType="VARCHAR"/>
<result property="deviceType" column="device_type" jdbcType="INTEGER"/>
<result property="locationId" column="location_id" jdbcType="VARCHAR"/>
<result property="locationName" column="location_name" jdbcType="VARCHAR"/>
<result property="locationType" column="location_type" jdbcType="INTEGER"/>
<result property="useTime" column="use_time" jdbcType="TIMESTAMP"/>
<result property="bussinessType" column="bussiness_type" jdbcType="VARCHAR"/>
......@@ -24,7 +24,6 @@
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
<result property="createUser" column="create_user" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,org_id,org_name,
order_main_id,device,device_type,
......@@ -33,37 +32,6 @@
picture,equipment_List,create_time,
update_time,update_user,create_user
</sql>
<select id="ShowInOutRecordsByOrder" resultType="com.junmp.jyzb.entity.LogSummary">
select * from base_log_summary ls
where ls.org_id = #{req.orgId} and ls.order_main_id=#{req.orderMainId}
</select>
<select id="ShowInOutRecordsByWarehouse" 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} and ls.location_type=0
<if test="req.bussinessType != null and req.bussinessType !=''">
and ls.bussiness_type=#{req.bussinessType}
</if>
<if test="req.locationId != null and req.locationId !=''">
and ls.location_id=#{locationId}
</if>
<if test="req.typeId != null and req.typeId !=''">
and ld.type_id=#{req.typeId}
</if>
</select>
<select id="ShowInOutRecordsByCabinet" 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} and ls.location_type=1
<if test="req.locationId != null and req.locationId !=''">
and ls.location_id=#{req.locationId}
<if test="req.cabinetboxId != null and req.cabinetboxId !=''">
and ld.cabinetbox_id in (select id from base_cabinet_box cb where cb.cabinet_id=#{req.locationId})
</if>
</if>
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论