Commit a30195b9 by 李小惠

出入库,记账,调试bug

parent 3a5ec6bd
...@@ -39,4 +39,9 @@ public class OrderDetailDto implements Serializable { ...@@ -39,4 +39,9 @@ public class OrderDetailDto implements Serializable {
private Integer actualNum; private Integer actualNum;
private BigDecimal price; private BigDecimal price;
/**
* 在库数
*/
private Integer stockNumber;
} }
...@@ -42,5 +42,5 @@ public class PolicemanDto { ...@@ -42,5 +42,5 @@ public class PolicemanDto {
private List<PoliceFingerDto> fingersList; private List<PoliceFingerDto> fingersList;
private String fileContent; private String fileContent;
private String userId; private Long userId;
} }
\ No newline at end of file
...@@ -25,6 +25,11 @@ public class InventorySumReq extends BaseRequest { ...@@ -25,6 +25,11 @@ public class InventorySumReq extends BaseRequest {
* 位置信息 * 位置信息
*/ */
private String locationName; private String locationName;
/**
* 位置类型(0仓库,1单警柜)
*/
private String locationType;
/** /**
* 类型ID * 类型ID
*/ */
...@@ -42,4 +47,15 @@ public class InventorySumReq extends BaseRequest { ...@@ -42,4 +47,15 @@ public class InventorySumReq extends BaseRequest {
*/ */
private String sizeName; private String sizeName;
/**
* 排序规则
*/
private String order;
/**
* 排序列
*/
private String column;
} }
...@@ -118,4 +118,6 @@ public class LogSummaryReq extends BaseRequest { ...@@ -118,4 +118,6 @@ public class LogSummaryReq extends BaseRequest {
*/ */
private List<LogDetailReq> logList; private List<LogDetailReq> logList;
private String typeId;
} }
...@@ -91,6 +91,13 @@ public class InventoryController { ...@@ -91,6 +91,13 @@ public class InventoryController {
return ApiRes.success(inventorySummaryService.getEquipmentInfo(req)); return ApiRes.success(inventorySummaryService.getEquipmentInfo(req));
} }
//根据组织机构id/单警柜id/仓库id查询出库存汇总数量以及金额
@PostMapping("/getTotalNumberAndPrice")
@ApiOperation("查询总金额以及各个汇总数量")
public ApiRes<List<InventorySummary>> getTotalNumberAndPrice(@RequestBody InventorySumReq req){
return ApiRes.success(inventorySummaryService.getTotalNumberAndPrice(req));
}
//根据组织机构/单警柜id/仓库id查询每件装备细信的详息(返回结果是List) //根据组织机构/单警柜id/仓库id查询每件装备细信的详息(返回结果是List)
@PostMapping("/") @PostMapping("/")
...@@ -195,9 +202,9 @@ public class InventoryController { ...@@ -195,9 +202,9 @@ public class InventoryController {
return ApiRes.success(inventoryService.GetListEquipment(req)); return ApiRes.success(inventoryService.GetListEquipment(req));
} }
//根据条件查询仓库下的所有装备信息(业务状态,在库状态,仓库id,超期状态) //根据条件查询仓库/单警柜下的所有装备信息(业务状态,在库状态,仓库id,超期状态)
@PostMapping("/GetDetailByTerms") @PostMapping("/GetDetailByTerms")
@ApiOperation("根据条件查询仓库下的所有装备信息") @ApiOperation("根据条件查询仓库/单警柜下的所有装备信息")
public ApiRes<PageResult<InventoryDto>> GetDetailByTerms(@RequestBody @Validated(ValidationApi.export.class) InventoryReq req){ public ApiRes<PageResult<InventoryDto>> GetDetailByTerms(@RequestBody @Validated(ValidationApi.export.class) InventoryReq req){
return ApiRes.success(inventoryService.GetDetailByTerms(req)); return ApiRes.success(inventoryService.GetDetailByTerms(req));
} }
...@@ -225,8 +232,8 @@ public class InventoryController { ...@@ -225,8 +232,8 @@ public class InventoryController {
//装备出入库记录(根据单据id) //装备出入库记录(根据单据id)
@PostMapping("/ShowInOutRecordsByOrder") @PostMapping("/ShowInOutRecordsByOrder")
@ApiOperation("出入库单据查询展示") @ApiOperation("出入库单据查询展示")
public ApiRes<PageResult<LogSummary>> ShowInOutRecordsPage(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){ public ApiRes<PageResult<LogSummary>> ShowInOutRecordsByOrder(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){
return ApiRes.success(inventoryService.ShowInOutRecordsPage(req)); return ApiRes.success(inventoryService.ShowInOutRecordsByOrder(req));
} }
...@@ -234,7 +241,7 @@ public class InventoryController { ...@@ -234,7 +241,7 @@ public class InventoryController {
@PostMapping("/ShowInOutRecordsByItems") @PostMapping("/ShowInOutRecordsByItems")
@ApiOperation("出入库记录条件查询展示") @ApiOperation("出入库记录条件查询展示")
public ApiRes<PageResult<LogSummary>> ShowInOutRecordsByItems(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){ public ApiRes<PageResult<LogSummary>> ShowInOutRecordsByItems(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){
return ApiRes.success(inventoryService.ShowInOutRecordsPage(req)); return ApiRes.success(inventoryService.ShowInOutRecordsByItems(req));
} }
//通过装备id查询某一件装备的出入库记录 //通过装备id查询某一件装备的出入库记录
...@@ -244,9 +251,20 @@ public class InventoryController { ...@@ -244,9 +251,20 @@ public class InventoryController {
return ApiRes.success(inventoryService.getInOutRecords(req)); return ApiRes.success(inventoryService.getInOutRecords(req));
} }
// @PostMapping("/test") @PostMapping("/test")
// public ApiRes<Boolean> test(@RequestBody RabbitMqOrderReq req){ public ApiRes<Boolean> test(@RequestBody InventorySumReq req){
// return ApiRes.success(inventoryService.test(req)); System.out.println("req = " + req);
// } return ApiRes.success(true);
}
@PostMapping("/EquipmentStatistics")
@ApiOperation("装备数量数据统计")
public ApiRes<List<InventorySummary>> EquipmentStatistics(@RequestBody InventorySumReq req){
return ApiRes.success(inventorySummaryService.EquipmentStatistics(req));
}
} }
...@@ -146,6 +146,12 @@ public class Inventory implements Serializable { ...@@ -146,6 +146,12 @@ public class Inventory implements Serializable {
private String locationId ; private String locationId ;
/** /**
* 位置名称
*/
@TableField(exist = false)
private String locationName ;
/**
* 是否遗失 * 是否遗失
*/ */
@TableField(value = "lost_flag") @TableField(value = "lost_flag")
......
...@@ -134,6 +134,27 @@ public class InventorySummary implements Serializable { ...@@ -134,6 +134,27 @@ public class InventorySummary implements Serializable {
private Integer expireNumber; private Integer expireNumber;
/** /**
* 报废数量
*/
@ApiModelProperty(value = "报废数量")
@TableField("broken_number")
private Integer brokenNumber;
/**
* 临近报废数量
*/
@ApiModelProperty(value = "临近报废数量")
@TableField("near_broken_number")
private Integer nearBrokenNumber;
/**
* 使用中数量(领用和借用)
*/
@ApiModelProperty(value = "使用中数量(领用和借用)")
@TableField("use_number")
private Integer useNumber;
/**
* 创建时间 * 创建时间
*/ */
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
......
package com.junmp.jyzb.entity; package com.junmp.jyzb.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -16,6 +17,7 @@ public class LogDetail implements Serializable { ...@@ -16,6 +17,7 @@ public class LogDetail implements Serializable {
/** /**
* 出入库明细ID * 出入库明细ID
*/ */
private Long id; private Long id;
/** /**
* 出入库汇总id * 出入库汇总id
...@@ -35,6 +37,12 @@ public class LogDetail implements Serializable { ...@@ -35,6 +37,12 @@ public class LogDetail implements Serializable {
private String orderMainId; private String orderMainId;
/** /**
* 单据编号
*/
@TableField(value = "order_code")
private String orderCode;
/**
* 业务类型 * 业务类型
*/ */
@TableField(value = "bussiness_type") @TableField(value = "bussiness_type")
...@@ -89,6 +97,18 @@ public class LogDetail implements Serializable { ...@@ -89,6 +97,18 @@ public class LogDetail implements Serializable {
private Integer equipmentType; private Integer equipmentType;
/** /**
* 位置id(存放单警柜id或者是仓库id)
*/
@TableField(value = "location_id")
private String locationId;
/**
* 位置名称(单警柜,仓库)
*/
@TableField(value = "location_name")
private String locationName;
/**
* 箱门id * 箱门id
*/ */
@TableField(value = "cabinetbox_id") @TableField(value = "cabinetbox_id")
......
...@@ -39,6 +39,11 @@ public class LogSummary implements Serializable { ...@@ -39,6 +39,11 @@ public class LogSummary implements Serializable {
*/ */
@TableField(value = "order_main_id") @TableField(value = "order_main_id")
private String orderMainId; private String orderMainId;
/**
* 单据编号
*/
@TableField(value = "order_code")
private String orderCode;
/** /**
* 设备标识 * 设备标识
...@@ -52,17 +57,7 @@ public class LogSummary implements Serializable { ...@@ -52,17 +57,7 @@ public class LogSummary implements Serializable {
@TableField(value = "device_type") @TableField(value = "device_type")
private Integer deviceType; private Integer deviceType;
/**
* 位置id(存放单警柜id或者是仓库id)
*/
@TableField(value = "location_id")
private String locationId;
/**
* 位置名称(单警柜,仓库)
*/
@TableField(value = "location_name")
private String locationName;
/** /**
* 所属位置(0仓库1单警柜) * 所属位置(0仓库1单警柜)
...@@ -127,6 +122,12 @@ public class LogSummary implements Serializable { ...@@ -127,6 +122,12 @@ public class LogSummary implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private List<LogDetail> logDetailList; private List<LogDetail> logDetailList;
/**
* 出入状态
*/
@TableField(value = "out_in_state")
private String outInState;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -76,7 +76,7 @@ public class Policeman implements Serializable { ...@@ -76,7 +76,7 @@ public class Policeman implements Serializable {
private Integer state; private Integer state;
@TableField(value = "user_id",updateStrategy = FieldStrategy.IGNORED) @TableField(value = "user_id",updateStrategy = FieldStrategy.IGNORED)
private Long UserId; private Long userId;
/** /**
* 0表示警员,1表示辅警 * 0表示警员,1表示辅警
......
...@@ -26,10 +26,10 @@ public interface InventoryMapper extends BaseMapper<Inventory> { ...@@ -26,10 +26,10 @@ public interface InventoryMapper extends BaseMapper<Inventory> {
boolean deleteAllMsg(); boolean deleteAllMsg();
//根据单警柜统计装备信息 //根据单警柜统计装备信息
boolean SetCabinetInventory(); boolean SetCabinetInventory(@Param("brokenNumberDays") Integer brokenNumberDays);
//根据仓库统计装备信息 //根据仓库统计装备信息
boolean SetWarehouseInventory(); boolean SetWarehouseInventory(@Param("brokenNumberDays") Integer brokenNumberDays);
List<InventoryDto> EqsBySearchType(InventoryReq req); List<InventoryDto> EqsBySearchType(InventoryReq req);
...@@ -60,5 +60,5 @@ public interface InventoryMapper extends BaseMapper<Inventory> { ...@@ -60,5 +60,5 @@ public interface InventoryMapper extends BaseMapper<Inventory> {
IPage<InventorySummary> EqsByCabinetBoxIdPage(Page<InventorySummary> page, String id); IPage<InventorySummary> EqsByCabinetBoxIdPage(Page<InventorySummary> page, String id);
boolean insertInventorySummary(@Param("req") BatchEditingInvsReq req); boolean insertInventorySummary(@Param("req") BatchEditingInvsReq req,@Param("brokenNumberDays")Integer brokenNumberDays);
} }
\ No newline at end of file
...@@ -19,10 +19,14 @@ public interface InventorySummaryMapper extends BaseMapper<InventorySummary> { ...@@ -19,10 +19,14 @@ public interface InventorySummaryMapper extends BaseMapper<InventorySummary> {
//根据仓库id删除装备汇总信息 //根据仓库id删除装备汇总信息
boolean deleteByWarehouse(@Param("list") List<WarehouseDto> allWarehouse); boolean deleteByWarehouse(@Param("list") List<WarehouseDto> allWarehouse);
boolean getSumByWarehouse(@Param("list") List<WarehouseDto> allWarehouse); boolean getSumByWarehouse(@Param("list") List<WarehouseDto> allWarehouse,@Param("brokenNumberDays")Integer brokenNumberDays);
//根据单警柜删除装备汇总信息 //根据单警柜删除装备汇总信息
boolean deleteByCabinet(@Param("cabinetId") String cabinetId); boolean deleteByCabinet(@Param("cabinetId") String cabinetId);
boolean getSumByCabinet(@Param("cabinetId") String cabinetId); boolean getSumByCabinet(@Param("cabinetId") String cabinetId,@Param("brokenNumberDays")Integer brokenNumberDays);
InventorySummary getTotalNumberAndPrice(@Param("req") InventorySumReq req);
InventorySummary EquipmentStatistics(@Param("req") InventorySumReq req);
} }
\ No newline at end of file
...@@ -14,7 +14,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -14,7 +14,7 @@ import org.apache.ibatis.annotations.Param;
* @Entity com.junmp.jyzb.entity.LogSummary * @Entity com.junmp.jyzb.entity.LogSummary
*/ */
public interface LogSummaryMapper extends BaseMapper<LogSummary> { public interface LogSummaryMapper extends BaseMapper<LogSummary> {
IPage<LogSummary> ShowInOutRecordsPage(Page<LogSummary> page, @Param("req") LogSummaryReq req); IPage<LogSummary> ShowInOutRecordsByOrder(Page<LogSummary> page, @Param("req") LogSummaryReq req);
IPage<LogSummary> ShowInOutRecordsByWarehouse(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> ShowInOutRecordsByCabinet(Page<LogSummary> page,@Param("req") LogSummaryReq req);
// IPage<LogSummary> ShowInOutRecordsPage(Page<LogSummary> page,@Param("req") LogSummaryReq req); // IPage<LogSummary> ShowInOutRecordsPage(Page<LogSummary> page,@Param("req") LogSummaryReq req);
......
...@@ -21,15 +21,22 @@ public class OrderMQReceiver { ...@@ -21,15 +21,22 @@ public class OrderMQReceiver {
@Resource @Resource
private InventorySummaryService inventorySummaryService; private InventorySummaryService inventorySummaryService;
@RabbitListener(queues = "11111")//监听队列名 @RabbitListener(queues = "orderResult")//监听队列名
private void a(RabbitMqOrderReq req, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag){ private void a(RabbitMqOrderReq req, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag){
try { try {
System.out.println("req = " + req); System.out.println("req = " + req);
//将消息进行消费 //将消息进行消费
Boolean result = inventorySummaryService.processInventoryRecords(req); Boolean result = inventorySummaryService.processInventoryRecords(req);
Long ordId;
if (req.getOrderMainReq().getOrderType().equals("in")){
ordId=req.getOrderMainReq().getEndOrgId();
}else {
ordId=req.getOrderMainReq().getStartOrgId();
}
Boolean aBoolean = inventorySummaryService.updateSummaryInsByOrder(ordId);
System.out.println("result = " + result); System.out.println("result = " + result);
if (result){ if (result && aBoolean){
// 手动确认消息 // 手动确认消息
channel.basicAck(deliveryTag, false); channel.basicAck(deliveryTag, false);
}else { }else {
......
...@@ -88,8 +88,10 @@ public interface InventoryService extends IService<Inventory> { ...@@ -88,8 +88,10 @@ public interface InventoryService extends IService<Inventory> {
PageResult<LogDetail> getInOutRecords(InventoryReq req); PageResult<LogDetail> getInOutRecords(InventoryReq req);
//根据单据获取出入库记录 //根据单据获取出入库记录
PageResult<LogSummary> ShowInOutRecordsPage(LogSummaryReq req); PageResult<LogSummary> ShowInOutRecordsByOrder(LogSummaryReq req);
PageResult<LogSummary> ShowInOutRecordsByItems(LogSummaryReq req); PageResult<LogSummary> ShowInOutRecordsByItems(LogSummaryReq req);
boolean test(RabbitMqOrderReq req); boolean test(RabbitMqOrderReq req);
} }
...@@ -21,7 +21,15 @@ public interface InventorySummaryService extends IService<InventorySummary> { ...@@ -21,7 +21,15 @@ public interface InventorySummaryService extends IService<InventorySummary> {
//处理本地主机返回单据结果 //处理本地主机返回单据结果
Boolean processInventoryRecords(RabbitMqOrderReq req); Boolean processInventoryRecords(RabbitMqOrderReq req);
//对summary表中数据进行重新计算装备信息汇总
Boolean updateSummaryInsByOrder(Long orgId);
//处理单警柜返回单据结果 //处理单警柜返回单据结果
Boolean cabinetInOutRecords(CabinetInOutRecordsReq req); Boolean cabinetInOutRecords(CabinetInOutRecordsReq req);
//根据组织机构id/单警柜id/仓库id查询出库存汇总数量以及金额
List<InventorySummary> getTotalNumberAndPrice(InventorySumReq req);
//计算装备总数(装备数量数据统计)
List<InventorySummary> EquipmentStatistics(InventorySumReq req);
} }
...@@ -52,13 +52,20 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl ...@@ -52,13 +52,20 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl
public String AddBussinessOrder(UpdateBusFormReq req) { public String AddBussinessOrder(UpdateBusFormReq req) {
BusForm busForm = new BusForm(); BusForm busForm = new BusForm();
BeanUtil.copyProperties(req,busForm); BeanUtil.copyProperties(req,busForm);
if (ObjectUtil.isNull(req.getId())){
String id= UUID.randomUUID().toString();
busForm.setId(id);
//设置单据号
OrderNum orderNum = stocktakeService.setOrderCode(req.getBussinessType(), req.getOrgId()); OrderNum orderNum = stocktakeService.setOrderCode(req.getBussinessType(), req.getOrgId());
String codeValue=String.format("%04d",orderNum.getNum()); String codeValue=String.format("%04d",orderNum.getNum());
busForm.setBussinessCode(orderNum.getBussinessType()+"-"+orderNum.getYear()+"-"+ busForm.setBussinessCode(orderNum.getBussinessType()+orderNum.getYear()+
LocalDateTime.now().getMonth().getValue()+"-"+LocalDateTime.now().getDayOfMonth()+"-"+codeValue); String.format("%02d",LocalDateTime.now().getMonth().getValue())+
String.format("%02d",LocalDateTime.now().getDayOfMonth())+codeValue);
}
busForm.setCreateTime(DateTimeUtil.getCurrentDateTime()); busForm.setCreateTime(DateTimeUtil.getCurrentDateTime());
String id= UUID.randomUUID().toString();
busForm.setId(id);
//执行工作流 //执行工作流
if (req.getExamineState().equals("working")) if (req.getExamineState().equals("working"))
{ {
...@@ -69,9 +76,9 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl ...@@ -69,9 +76,9 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl
startProcessInstanceDTO.setUserId(req.getUserId()); startProcessInstanceDTO.setUserId(req.getUserId());
String ProcessInstanceId= FlowInstanceService.startProcessInstanceById(startProcessInstanceDTO); String ProcessInstanceId= FlowInstanceService.startProcessInstanceById(startProcessInstanceDTO);
busForm.setProcessId(ProcessInstanceId); busForm.setProcessId(ProcessInstanceId);
this.save(busForm);
} }
if (req.getExamineState().equals("none")){//如果是草稿
if(ObjectUtil.isNotNull(req.getId())){ if(ObjectUtil.isNotNull(req.getId())){
//已经是一个草稿,在点击提交的时候只需要更新即可,因为数据库中已经存在该单据 //已经是一个草稿,在点击提交的时候只需要更新即可,因为数据库中已经存在该单据
updateById(busForm); updateById(busForm);
...@@ -79,7 +86,6 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl ...@@ -79,7 +86,6 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl
//保存 //保存
this.save(busForm); this.save(busForm);
} }
}
return busForm.getId(); return busForm.getId();
} }
...@@ -119,7 +125,7 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl ...@@ -119,7 +125,7 @@ public class BusFormServiceImpl extends ServiceImpl<BusFormMapper, BusForm> impl
.eq(ObjectUtil.isNotNull(req.getBussinessType()), BusForm::getBussinessType, req.getBussinessType()) .eq(ObjectUtil.isNotNull(req.getBussinessType()), BusForm::getBussinessType, req.getBussinessType())
//审核状态 //审核状态
.eq(ObjectUtil.isNotNull(req.getExamineState()) && !req.getExamineState().trim().isEmpty(), BusForm::getExamineState, req.getExamineState()) .eq(ObjectUtil.isNotNull(req.getExamineState()) && !req.getExamineState().trim().isEmpty(), BusForm::getExamineState, req.getExamineState())
// //仓库id
.eq(ObjectUtil.isNotNull(req.getWarehouseId()), BusForm::getWarehouseId, req.getWarehouseId()) .eq(ObjectUtil.isNotNull(req.getWarehouseId()), BusForm::getWarehouseId, req.getWarehouseId())
.eq(ObjectUtil.isNotNull(req.getOrgId()),BusForm::getOrgId,req.getOrgId()) .eq(ObjectUtil.isNotNull(req.getOrgId()),BusForm::getOrgId,req.getOrgId())
.ge(ObjectUtil.isNotNull(req.getStartTime()), BusForm::getCreateTime, req.getStartTime()) .ge(ObjectUtil.isNotNull(req.getStartTime()), BusForm::getCreateTime, req.getStartTime())
......
...@@ -18,6 +18,7 @@ import com.junmp.jyzb.api.exception.enums.CabinetExceptionEnum; ...@@ -18,6 +18,7 @@ import com.junmp.jyzb.api.exception.enums.CabinetExceptionEnum;
import com.junmp.jyzb.api.exception.enums.InventoryExceptionEnum; import com.junmp.jyzb.api.exception.enums.InventoryExceptionEnum;
import com.junmp.jyzb.entity.*; import com.junmp.jyzb.entity.*;
import com.junmp.jyzb.mapper.InventorySummaryMapper;
import com.junmp.jyzb.mapper.LogSummaryMapper; import com.junmp.jyzb.mapper.LogSummaryMapper;
import com.junmp.jyzb.service.*; import com.junmp.jyzb.service.*;
import com.junmp.v2.common.exception.base.ServiceException; import com.junmp.v2.common.exception.base.ServiceException;
...@@ -26,6 +27,8 @@ import com.junmp.v2.common.util.HttpServletUtil; ...@@ -26,6 +27,8 @@ import com.junmp.v2.common.util.HttpServletUtil;
import com.junmp.v2.db.api.factory.PageFactory; import com.junmp.v2.db.api.factory.PageFactory;
import com.junmp.v2.db.api.factory.PageResultFactory; import com.junmp.v2.db.api.factory.PageResultFactory;
import com.junmp.v2.db.api.page.PageResult; import com.junmp.v2.db.api.page.PageResult;
import com.junmp.v2.dict.entity.SysDictItem;
import com.junmp.v2.dict.service.SysDictItemService;
import com.junmp.v2.office.api.OfficeExcelApi; import com.junmp.v2.office.api.OfficeExcelApi;
import com.junmp.v2.office.api.bean.ExcelExportParam; import com.junmp.v2.office.api.bean.ExcelExportParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -98,6 +101,12 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -98,6 +101,12 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
@Resource @Resource
private RabbitAdmin rabbitAdmin; private RabbitAdmin rabbitAdmin;
@Resource
private SysDictItemService sysDictItemService;
@Resource
private InventorySummaryMapper inventorySummaryMapper;
//根据装备id查询出装备的详细信息 //根据装备id查询出装备的详细信息
@Override @Override
...@@ -119,35 +128,41 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -119,35 +128,41 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean setInventoryMsg(){ public boolean setInventoryMsg(){
//查询字典表中的临近报废天数
SysDictItem sysDictItem = sysDictItemService.getOne(new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getItemText, "brokenNumber"));
//如果配置找不到,那就默认设置为15天为临近报废(如果装备的质保期小于15天了,就是为临近报废)
Integer brokenNumberDays;
if (ObjectUtil.isNotNull(sysDictItem)){
brokenNumberDays=15;
}else {
brokenNumberDays=Integer.parseInt(sysDictItem.getItemValue());
}
//先查询inventory_summary表中的物资阈值字段是否为空,如果为空则默认他是默认值,如果不是默认值,将其存储,再重新统计后进行赋值 //先查询inventory_summary表中的物资阈值字段是否为空,如果为空则默认他是默认值,如果不是默认值,将其存储,再重新统计后进行赋值
List<InventorySummary> list = inventorySummaryService.list(new LambdaQueryWrapper<InventorySummary>() // List<InventorySummary> list = inventorySummaryService.list(new LambdaQueryWrapper<InventorySummary>()
.isNotNull(InventorySummary::getThreshold) // .isNotNull(InventorySummary::getThreshold)
.eq(InventorySummary::getLocationType,0)); // .eq(InventorySummary::getLocationType,0));
//清空数据库中已存在的信息 //清空数据库中已存在的信息
inventoryMapper.deleteAllMsg(); inventoryMapper.deleteAllMsg();
//放入单警柜信息汇总 //放入单警柜信息汇总
boolean b = inventoryMapper.SetCabinetInventory(); boolean b = inventoryMapper.SetCabinetInventory(brokenNumberDays);
//放入仓库区域信息汇总 //放入仓库区域信息汇总
boolean b1 = inventoryMapper.SetWarehouseInventory(); boolean b1 = inventoryMapper.SetWarehouseInventory(brokenNumberDays);
boolean b2=true; // boolean b2=true;
if (list.size()>0){ // if (list.size()>0){
for (InventorySummary inventorySummary:list) { // for (InventorySummary inventorySummary:list) {
InventorySummary one = inventorySummaryService.getOne(new LambdaQueryWrapper<InventorySummary>() // InventorySummary one = inventorySummaryService.getOne(new LambdaQueryWrapper<InventorySummary>()
.eq(InventorySummary::getLocationId, inventorySummary.getLocationId()) // .eq(InventorySummary::getLocationId, inventorySummary.getLocationId())
.eq(InventorySummary::getLocationType, 0) // .eq(InventorySummary::getLocationType, 0)
.eq(InventorySummary::getSizeId, inventorySummary.getSizeId()) // .eq(InventorySummary::getSizeId, inventorySummary.getSizeId())
.eq(InventorySummary::getTypeId, inventorySummary.getTypeId()) // .eq(InventorySummary::getTypeId, inventorySummary.getTypeId())
.eq(InventorySummary::getOrgId, inventorySummary.getOrgId())); // .eq(InventorySummary::getOrgId, inventorySummary.getOrgId()));
one.setThreshold(inventorySummary.getThreshold()); // one.setThreshold(inventorySummary.getThreshold());
b2 = inventorySummaryService.updateById(one); // b2 = inventorySummaryService.updateById(one);
} // }
} // }
if (b && b1 && b2){ return (b && b1);
return true;
}else{
return false;
}
} }
...@@ -323,7 +338,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -323,7 +338,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
return PageResultFactory.createPageResult(page1); return PageResultFactory.createPageResult(page1);
} }
//根据条件查询仓库下的所有装备信息 //根据条件查询仓库/单警柜下的所有装备信息
@Override @Override
public PageResult<InventoryDto> GetDetailByTerms(InventoryReq req) { public PageResult<InventoryDto> GetDetailByTerms(InventoryReq req) {
//判断组织机构是否存在 //判断组织机构是否存在
...@@ -331,15 +346,20 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -331,15 +346,20 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
//根据条件查询仓库下的所有装备 //根据条件查询仓库下的所有装备
LambdaQueryWrapper<Inventory> eq = new LambdaQueryWrapper<Inventory>() LambdaQueryWrapper<Inventory> eq = new LambdaQueryWrapper<Inventory>()
.eq(Inventory::getOrgId, req.getOrgId()) .eq(Inventory::getOrgId, req.getOrgId())
.eq(Inventory::getLocationType, 0) .eq(ObjectUtil.isNotNull(req.getLocationType()),Inventory::getLocationType, req.getLocationType())
.eq(ObjectUtil.isNotNull(req.getLocationId()) && !req.getLocationId().trim().isEmpty(), Inventory::getLocationId, req.getLocationId())
.eq(ObjectUtil.isNotNull(req.getLocationState()) && !req.getLocationState().trim().isEmpty(), Inventory::getLocationState, req.getLocationState()) .eq(ObjectUtil.isNotNull(req.getLocationState()) && !req.getLocationState().trim().isEmpty(), Inventory::getLocationState, req.getLocationState())
.eq(ObjectUtil.isNotNull(req.getBussinessState()) && !req.getBussinessState().trim().isEmpty(), Inventory::getBussinessState, req.getBussinessState()) .eq(ObjectUtil.isNotNull(req.getBussinessState()) && !req.getBussinessState().trim().isEmpty(), Inventory::getBussinessState, req.getBussinessState())
.eq(ObjectUtil.isNotNull(req.getTermState()), Inventory::getTermState, req.getTermState()) .eq(ObjectUtil.isNotNull(req.getTermState()), Inventory::getTermState, req.getTermState())
.eq(ObjectUtil.isNotNull(req.getSizeId()) && !req.getSizeId().trim().isEmpty(),Inventory::getSizeId,req.getSizeId()) .eq(ObjectUtil.isNotNull(req.getSizeId()) && !req.getSizeId().trim().isEmpty(),Inventory::getSizeId,req.getSizeId())
.eq(ObjectUtil.isNotNull(req.getTypeId()) && !req.getTypeId().trim().isEmpty(),Inventory::getTypeId,req.getTypeId()) .eq(ObjectUtil.isNotNull(req.getTypeId()) && !req.getTypeId().trim().isEmpty(),Inventory::getTypeId,req.getTypeId())
.eq(ObjectUtil.isNotNull(req.getPrice()),Inventory::getPrice,req.getPrice()); .eq(ObjectUtil.isNotNull(req.getPrice()),Inventory::getPrice,req.getPrice());
if (req.getLocationType().equals("0")){
eq.eq(ObjectUtil.isNotNull(req.getLocationId()) && !req.getLocationId().trim().isEmpty(), Inventory::getLocationId, req.getLocationId());
}else {
List<CabinetBox> list = cabinetBoxService.list(new LambdaQueryWrapper<CabinetBox>().eq(CabinetBox::getCabinetId, req.getLocationId()));
Set<String> cabinetList=list.stream().map(CabinetBox::getId).collect(Collectors.toSet());
eq.in(Inventory::getLocationId,cabinetList);
}
long size = list(eq).size(); long size = list(eq).size();
Page<Inventory> page = page(PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()), eq); Page<Inventory> page = page(PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()), eq);
List<Inventory> records = page.getRecords(); List<Inventory> records = page.getRecords();
...@@ -414,6 +434,16 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -414,6 +434,16 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
//修改库存信息汇总 //修改库存信息汇总
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean setInventorySummary(BatchEditingInvsReq req){ public boolean setInventorySummary(BatchEditingInvsReq req){
//查询字典表中的临近报废天数
SysDictItem sysDictItem = sysDictItemService.getOne(new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getItemText, "brokenNumber"));
//如果配置找不到,那就默认设置为15天为临近报废(如果装备的质保期小于15天了,就是为临近报废)
Integer brokenNumberDays;
if (ObjectUtil.isNotNull(sysDictItem)){
brokenNumberDays=15;
}else {
brokenNumberDays=Integer.parseInt(sysDictItem.getItemValue());
}
//先将其删除再全部重新添加计算 //先将其删除再全部重新添加计算
List<InventorySummary> list = inventorySummaryService.list(new LambdaQueryWrapper<InventorySummary>() List<InventorySummary> list = inventorySummaryService.list(new LambdaQueryWrapper<InventorySummary>()
.eq(ObjectUtil.isNotNull(req.getOrgId()),InventorySummary::getOrgId,req.getOrgId()) .eq(ObjectUtil.isNotNull(req.getOrgId()),InventorySummary::getOrgId,req.getOrgId())
...@@ -421,7 +451,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -421,7 +451,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
.eq(ObjectUtil.isNotNull(req.getSizeId()),InventorySummary::getSizeId,req.getSizeId()) .eq(ObjectUtil.isNotNull(req.getSizeId()),InventorySummary::getSizeId,req.getSizeId())
.eq(ObjectUtil.isNotNull(req.getTypeId()),InventorySummary::getTypeId,req.getTypeId())); .eq(ObjectUtil.isNotNull(req.getTypeId()),InventorySummary::getTypeId,req.getTypeId()));
boolean b = inventorySummaryService.removeBatchByIds(list); boolean b = inventorySummaryService.removeBatchByIds(list);
boolean a = inventoryMapper.insertInventorySummary(req); boolean a = inventoryMapper.insertInventorySummary(req,brokenNumberDays);
return (a && b); return (a && b);
} }
...@@ -573,9 +603,9 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -573,9 +603,9 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
//根据单据查询出入库记录 //根据单据查询出入库记录
@Override @Override
public PageResult<LogSummary> ShowInOutRecordsPage(LogSummaryReq req) { public PageResult<LogSummary> ShowInOutRecordsByOrder(LogSummaryReq req) {
Page<LogSummary> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()); Page<LogSummary> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
IPage<LogSummary> ipage=logSummaryMapper.ShowInOutRecordsPage(page,req); IPage<LogSummary> ipage=logSummaryMapper.ShowInOutRecordsByOrder(page,req);
List<LogSummary> logSummaryList=new ArrayList<>(); List<LogSummary> logSummaryList=new ArrayList<>();
ipage.getRecords().forEach(logSummary -> { ipage.getRecords().forEach(logSummary -> {
List<LogDetail> list = logDetailService.list(new LambdaQueryWrapper<LogDetail>() List<LogDetail> list = logDetailService.list(new LambdaQueryWrapper<LogDetail>()
...@@ -593,7 +623,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -593,7 +623,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
Page<LogSummary> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()); Page<LogSummary> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
List<LogSummary> logSummaryList=new ArrayList<>(); List<LogSummary> logSummaryList=new ArrayList<>();
IPage<LogSummary> ipage; IPage<LogSummary> ipage;
if (req.getLocationType()==1){ if (req.getLocationType()==0){
ipage = logSummaryMapper.ShowInOutRecordsByWarehouse(page, req); ipage = logSummaryMapper.ShowInOutRecordsByWarehouse(page, req);
}else { }else {
......
...@@ -16,6 +16,8 @@ import com.junmp.v2.common.util.BeanPlusUtil; ...@@ -16,6 +16,8 @@ import com.junmp.v2.common.util.BeanPlusUtil;
import com.junmp.v2.db.api.factory.PageFactory; import com.junmp.v2.db.api.factory.PageFactory;
import com.junmp.v2.db.api.factory.PageResultFactory; import com.junmp.v2.db.api.factory.PageResultFactory;
import com.junmp.v2.db.api.page.PageResult; import com.junmp.v2.db.api.page.PageResult;
import com.junmp.v2.dict.entity.SysDictItem;
import com.junmp.v2.dict.service.SysDictItemService;
import liquibase.pro.packaged.L; import liquibase.pro.packaged.L;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.junmp.jyzb.mapper.InventorySummaryMapper; import com.junmp.jyzb.mapper.InventorySummaryMapper;
...@@ -61,6 +63,9 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -61,6 +63,9 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
@Resource @Resource
private CabinetBoxService cabinetBoxService; private CabinetBoxService cabinetBoxService;
@Resource
private SysDictItemService sysDictItemService;
//根据条件查询库存汇总信息 //根据条件查询库存汇总信息
@Override @Override
...@@ -70,6 +75,14 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -70,6 +75,14 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
if (ObjectUtil.isNotNull(req.getOrgId())){ if (ObjectUtil.isNotNull(req.getOrgId())){
pubOrgService.PubOrgExist(req.getOrgId()); pubOrgService.PubOrgExist(req.getOrgId());
} }
//(如果传其他不是数据库字段参数或者排序规则不是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<InventorySummary> wp = createWrapper(req);//取出仓库中总数并计算 LambdaQueryWrapper<InventorySummary> wp = createWrapper(req);//取出仓库中总数并计算
long size = list(wp).size(); long size = list(wp).size();
Page<InventorySummary> sumList= this.page(PageFactory.getDefaultPage(req.getPageNo(),req.getPageSize()),wp); Page<InventorySummary> sumList= this.page(PageFactory.getDefaultPage(req.getPageNo(),req.getPageSize()),wp);
...@@ -141,6 +154,7 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -141,6 +154,7 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
inventory.setId(UUID.randomUUID().toString()); inventory.setId(UUID.randomUUID().toString());
inventory.setLocationState(orderMain.getOrderType()); inventory.setLocationState(orderMain.getOrderType());
inventory.setBussinessState("normal"); inventory.setBussinessState("normal");
inventory.setState("normal");
addList.add(inventory); addList.add(inventory);
}else { }else {
//修改状态 //修改状态
...@@ -148,25 +162,30 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -148,25 +162,30 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
//修改业务状态 //修改业务状态
if (orderType.equals("in")){ if (orderType.equals("in")){
inventory.setBussinessState("normal"); inventory.setBussinessState("normal");
inventory.setState("normal");
}else if (orderType.equals("out") && orderMain.getBussinessType().equals("repair")){
inventory.setBussinessState(orderMain.getBussinessType());
inventory.setState("fix");
}else if (orderType.equals("out") && orderMain.getBussinessType().equals("remove")){
inventory.setBussinessState(orderMain.getBussinessType());
inventory.setState("destory");
}else { }else {
inventory.setBussinessState(orderMain.getBussinessType()); inventory.setBussinessState(orderMain.getBussinessType());
inventory.setState("normal");
} }
updateList.add(inventory); updateList.add(inventory);
} }
}); });
boolean b=false;
if (ObjectUtil.isNotNull(addList) && addList.size()>0){ if (ObjectUtil.isNotNull(addList) && addList.size()>0){
boolean b = inventoryService.saveBatch(addList); b = inventoryService.saveBatch(addList);
System.out.println("b = " + b);
} }
if (ObjectUtil.isNotNull(updateList) && updateList.size()>0){ if (ObjectUtil.isNotNull(updateList) && updateList.size()>0){
inventoryService.updateBatchById(updateList); b = inventoryService.updateBatchById(updateList);
} }
//对装备进行记录,存入log表形成出入库记录 //对装备进行记录,存入log表形成出入库记录
Boolean c = insertLog(req,orderMain,addList,updateList); Boolean c = insertLog(req,orderMain,addList,updateList);
//对summary表中数据进行重新计算装备信息汇总 return (b && c );
Boolean d = updateSummaryInsByOrder(orgId);
return (c && d);
} }
...@@ -177,14 +196,18 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -177,14 +196,18 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
LogSummary logSummary = new LogSummary(); LogSummary logSummary = new LogSummary();
logSummary.setDevice(req.getDevice()); logSummary.setDevice(req.getDevice());
logSummary.setDeviceType(req.getDeviceType()); logSummary.setDeviceType(req.getDeviceType());
logSummary.setLocationType(0);
if (orderMain.getOrderType().equals("in")){ if (orderMain.getOrderType().equals("in")){
logSummary.setOutInState("in");
logSummary.setOrgId(orderMain.getEndOrgId()); logSummary.setOrgId(orderMain.getEndOrgId());
logSummary.setOrgName(orderMain.getEndOrgName()); logSummary.setOrgName(orderMain.getEndOrgName());
}else { }else {
logSummary.setOutInState("out");
logSummary.setOrgId(orderMain.getStartOrgId()); logSummary.setOrgId(orderMain.getStartOrgId());
logSummary.setOrgName(orderMain.getStartOrgName()); logSummary.setOrgName(orderMain.getStartOrgName());
} }
logSummary.setOrderMainId(orderMain.getId()); logSummary.setOrderMainId(orderMain.getId());
logSummary.setOrderCode(orderMain.getOrderCode());
logSummary.setBussinessType(orderMain.getBussinessType()); logSummary.setBussinessType(orderMain.getBussinessType());
boolean a = logSummaryService.save(logSummary); boolean a = logSummaryService.save(logSummary);
//存入log_detail表中 //存入log_detail表中
...@@ -194,9 +217,13 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -194,9 +217,13 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
for (Inventory inventory:addList) { for (Inventory inventory:addList) {
LogDetail logDetail = new LogDetail(); LogDetail logDetail = new LogDetail();
BeanPlusUtil.copyProperties(inventory,logDetail); BeanPlusUtil.copyProperties(inventory,logDetail);
logDetail.setInventoryId(inventory.getId());
logDetail.setBussinessType(orderMain.getBussinessType());
logDetail.setOutInState(orderMain.getOrderType()); logDetail.setOutInState(orderMain.getOrderType());
logDetail.setOrderCode(orderMain.getOrderCode());
logDetail.setSummaryId(logSummary.getId()); logDetail.setSummaryId(logSummary.getId());
logDetail.setOrderMainId(orderMain.getId()); logDetail.setOrderMainId(orderMain.getId());
logDetail.setErrorState(0);
logDetailList.add(logDetail); logDetailList.add(logDetail);
} }
} }
...@@ -216,12 +243,23 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -216,12 +243,23 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
//对summary表中数据进行重新计算装备信息汇总 //对summary表中数据进行重新计算装备信息汇总
public Boolean updateSummaryInsByOrder(Long orgId){ public Boolean updateSummaryInsByOrder(Long orgId){
//查询字典表中的临近报废天数
SysDictItem sysDictItem = sysDictItemService.getOne(new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getItemText, "brokenNumber"));
//如果配置找不到,那就默认设置为15天为临近报废(如果装备的质保期小于15天了,就是为临近报废)
Integer brokenNumberDays;
if (ObjectUtil.isNotNull(sysDictItem)){
brokenNumberDays=15;
}else {
brokenNumberDays=Integer.parseInt(sysDictItem.getItemValue());
}
//查询出组织机构下的所有仓库信息,并且将表中的仓库信息数据进行删除 //查询出组织机构下的所有仓库信息,并且将表中的仓库信息数据进行删除
List<WarehouseDto> allWarehouse = warehouseService.getAllWarehouse(orgId); List<WarehouseDto> allWarehouse = warehouseService.getAllWarehouse(orgId);
boolean a = inventorySummaryMapper.deleteByWarehouse(allWarehouse); boolean a = inventorySummaryMapper.deleteByWarehouse(allWarehouse);
//根据仓库id重新计算汇总信息 //根据仓库id重新计算汇总信息
boolean b = inventorySummaryMapper.getSumByWarehouse(allWarehouse); boolean sumByWarehouse = inventorySummaryMapper.getSumByWarehouse(allWarehouse, brokenNumberDays);
return (a && b); System.out.println("sumByWarehouse = " + sumByWarehouse);
return (a && sumByWarehouse);
} }
//单警柜返回数据 //单警柜返回数据
...@@ -246,13 +284,25 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -246,13 +284,25 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
Boolean c = insertCabinetLog(req); Boolean c = insertCabinetLog(req);
return (a && b && c); return (a && b && c);
} }
public boolean updateSummaryInsByCabinet(String locationId){ public boolean updateSummaryInsByCabinet(String locationId){
//查询字典表中的临近报废天数
SysDictItem sysDictItem = sysDictItemService.getOne(new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getItemText, "brokenNumber"));
//如果配置找不到,那就默认设置为15天为临近报废(如果装备的质保期小于15天了,就是为临近报废)
Integer brokenNumberDays;
if (ObjectUtil.isNotNull(sysDictItem)){
brokenNumberDays=15;
}else {
brokenNumberDays=Integer.parseInt(sysDictItem.getItemValue());
}
//根据箱门id查询出单警柜信息 //根据箱门id查询出单警柜信息
CabinetBox cabinetBox = cabinetBoxService.getById(locationId); CabinetBox cabinetBox = cabinetBoxService.getById(locationId);
//删除inventorysummary表中该单警柜数据 //删除inventorysummary表中该单警柜数据
boolean a = inventorySummaryMapper.deleteByCabinet(cabinetBox.getCabinetId()); boolean a = inventorySummaryMapper.deleteByCabinet(cabinetBox.getCabinetId());
//重新计算该单警柜下面的装备信息 //重新计算该单警柜下面的装备信息
boolean b = inventorySummaryMapper.getSumByCabinet(cabinetBox.getCabinetId()); boolean b = inventorySummaryMapper.getSumByCabinet(cabinetBox.getCabinetId(),brokenNumberDays);
return (a && b); return (a && b);
} }
...@@ -276,6 +326,29 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -276,6 +326,29 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
return (a && b); return (a && b);
} }
//根据组织机构id/单警柜id/仓库id查询出库存汇总数量以及金额
@Override
public List<InventorySummary> getTotalNumberAndPrice(InventorySumReq req) {
List<InventorySummary> list=new ArrayList<>();
InventorySummary totalNumberAndPrice = inventorySummaryMapper.getTotalNumberAndPrice(req);
if (ObjectUtil.isNotNull(totalNumberAndPrice)){
list.add(totalNumberAndPrice);
}
return list;
}
//计算装备总数(装备数量数据统计)
@Override
public List<InventorySummary> EquipmentStatistics(InventorySumReq req) {
List<InventorySummary> inventorySummaryList=new ArrayList<>();
InventorySummary inventorySummary = inventorySummaryMapper.EquipmentStatistics(req);
if (ObjectUtil.isNotNull(inventorySummary)){
inventorySummaryList.add(inventorySummary);
}
return inventorySummaryList;
}
private LambdaQueryWrapper<InventorySummary> createWrapper(InventorySumReq req) { private LambdaQueryWrapper<InventorySummary> createWrapper(InventorySumReq req) {
LambdaQueryWrapper<InventorySummary> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InventorySummary> wrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isEmpty(req)) { if (ObjectUtil.isEmpty(req)) {
...@@ -287,6 +360,8 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -287,6 +360,8 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
wrapper.like(ObjectUtil.isNotEmpty(req.getOrgName()), InventorySummary::getOrgName, req.getOrgName()); wrapper.like(ObjectUtil.isNotEmpty(req.getOrgName()), InventorySummary::getOrgName, req.getOrgName());
//位置id(单警柜/仓库) //位置id(单警柜/仓库)
wrapper.eq(ObjectUtil.isNotEmpty(req.getLocationId()), InventorySummary::getLocationId, req.getLocationId()); wrapper.eq(ObjectUtil.isNotEmpty(req.getLocationId()), InventorySummary::getLocationId, req.getLocationId());
//位置类型
wrapper.eq(ObjectUtil.isNotEmpty(req.getLocationType()),InventorySummary::getLocationType,req.getLocationType());
//位置信息 //位置信息
wrapper.like(ObjectUtil.isNotEmpty(req.getLocationName()), InventorySummary::getLocationName, req.getLocationName()); wrapper.like(ObjectUtil.isNotEmpty(req.getLocationName()), InventorySummary::getLocationName, req.getLocationName());
//装备类别名称 //装备类别名称
...@@ -297,8 +372,7 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa ...@@ -297,8 +372,7 @@ public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMa
wrapper.like(ObjectUtil.isNotEmpty(req.getSizeName()), InventorySummary::getSizeName, req.getSizeName()); wrapper.like(ObjectUtil.isNotEmpty(req.getSizeName()), InventorySummary::getSizeName, req.getSizeName());
//号型 //号型
wrapper.eq(ObjectUtil.isNotEmpty(req.getSizeId()), InventorySummary::getSizeId, req.getSizeId()); wrapper.eq(ObjectUtil.isNotEmpty(req.getSizeId()), InventorySummary::getSizeId, req.getSizeId());
wrapper.orderByDesc(InventorySummary::getTypeId); wrapper.last("order by " + req.getColumn() + " " + req.getOrder());
wrapper.orderByDesc(InventorySummary::getSizeId);
return wrapper; return wrapper;
} }
......
...@@ -43,6 +43,7 @@ import org.springframework.stereotype.Service; ...@@ -43,6 +43,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.management.remote.rmi._RMIConnection_Stub;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -87,22 +88,103 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -87,22 +88,103 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
//新增任务单 //新增任务单
// @Transactional(rollbackFor = Exception.class)
// @Override
// public List<String> AddOrder(UpdateOrderReq req) {
// //先判断该单据是否存在,如果存在,进行更新操作即可
//
// List<String> list=new ArrayList<>();
// OrderMain order = new OrderMain();
// BeanPlusUtil.copyProperties(req, order);
// //设置单据单号
// if (ObjectUtil.isNull(order.getOrderCode())){
// OrderNum orderNum = setOrderCode(req);
// String codeValue=String.format("%04d",orderNum.getNum());
// order.setOrderCode(orderNum.getBussinessType()+orderNum.getYear()+
// String.format("%02d",LocalDateTime.now().getMonth().getValue())+String.format("%02d",LocalDateTime.now().getDayOfMonth())+codeValue);
// }
// //设置总价格和应出入库数量
// //设置id
// String id=UUID.randomUUID().toString();
// order.setId(id);
// Integer sumNum=0;
// BigDecimal priceTotal=new BigDecimal(0);
// List<OrderDetail> detailList = new ArrayList<>();
// //通过遍历批量保存详细信息
// for (UpdateOrderDetailReq listReq:req.getDetailList()) {
// OrderDetail detail=new OrderDetail();
// BeanPlusUtil.copyProperties(listReq, detail);
// detail.setOrderId(order.getId());
// //设置单据类型
// detail.setType(order.getOrderType());
// //将数量和价格进行累加
// sumNum += detail.getPlanNum();
// priceTotal = priceTotal.add(BigDecimal.valueOf(detail.getPlanNum()).multiply(detail.getPrice())) ;
// detail.setCreateTime(DateTimeUtil.getCurrentDateTime());
// detailList.add(detail);
// }
// if (ObjectUtil.isNotNull(req.getId())){
// //删除子单据
// orderDetailService.remove(new LambdaQueryWrapper<OrderDetail>()
// .eq(ObjectUtil.isNotNull(req.getId()),OrderDetail::getOrderId,req.getId()));
// }
// orderDetailService.saveBatch(detailList);
// //设置总价格和总数量
// order.setPrice(priceTotal);
// order.setInventoryQuantity(sumNum);
// order.setCreateTime(DateTimeUtil.getCurrentDateTime());
// //执行工作流
//
// if (req.getExamineState().equals("working"))
// {
// StartProcessInstanceDTO startProcessInstanceDTO=new StartProcessInstanceDTO();
// startProcessInstanceDTO.setProcessDefinitionId(req.getProcessDefinitionId());
// startProcessInstanceDTO.setOrderId(id);
// startProcessInstanceDTO.setOrderType("workOrder");
// startProcessInstanceDTO.setUserId(req.getUserId());
// String ProcessInstanceId= FlowInstanceService.startProcessInstanceById(startProcessInstanceDTO);
// order.setProcessId(ProcessInstanceId);
// //保存
// this.save(order);
// }
// if (req.getExamineState().equals("none")){//如果是草稿
// if(ObjectUtil.isNotNull(req.getId())){
// //已经是一个草稿,在点击提交的时候只需要更新即可,因为数据库中已经存在该单据
// updateById(order);
// }else {
// //保存
// this.save(order);
// }
// }
// list.add(order.getId());
// for (OrderDetail orderDetail:detailList) {
// list.add(Long.toString(orderDetail.getId()));
// }
// return list;
// }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public List<String> AddOrder(UpdateOrderReq req) { public List<String> AddOrder(UpdateOrderReq req) {
List<String> list=new ArrayList<>();
OrderMain order = new OrderMain(); OrderMain order = new OrderMain();
BeanPlusUtil.copyProperties(req, order); BeanPlusUtil.copyProperties(req, order);
//先判断该单据id是否存在,如果存在,进行更新操作即可
if (ObjectUtil.isNotNull(req.getId())){
//删除子单据
orderDetailService.remove(new LambdaQueryWrapper<OrderDetail>()
.eq(ObjectUtil.isNotNull(req.getId()),OrderDetail::getOrderId,req.getId()));
}else {
//设置id
String id=UUID.randomUUID().toString();
order.setId(id);
//设置单据单号 //设置单据单号
OrderNum orderNum = setOrderCode(req); OrderNum orderNum = setOrderCode(req);
String codeValue=String.format("%04d",orderNum.getNum()); String codeValue=String.format("%04d",orderNum.getNum());
order.setOrderCode(orderNum.getBussinessType()+"-"+orderNum.getYear()+"-"+ order.setOrderCode(orderNum.getBussinessType()+orderNum.getYear()+
LocalDateTime.now().getMonth().getValue()+"-"+LocalDateTime.now().getDayOfMonth()+"-"+codeValue); String.format("%02d",LocalDateTime.now().getMonth().getValue())+
String.format("%02d",LocalDateTime.now().getDayOfMonth())+codeValue);
}
//设置总价格和应出入库数量 //设置总价格和应出入库数量
//设置id
String id=UUID.randomUUID().toString();
order.setId(id);
Integer sumNum=0; Integer sumNum=0;
BigDecimal priceTotal=new BigDecimal(0); BigDecimal priceTotal=new BigDecimal(0);
List<OrderDetail> detailList = new ArrayList<>(); List<OrderDetail> detailList = new ArrayList<>();
...@@ -125,28 +207,25 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -125,28 +207,25 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
order.setInventoryQuantity(sumNum); order.setInventoryQuantity(sumNum);
order.setCreateTime(DateTimeUtil.getCurrentDateTime()); order.setCreateTime(DateTimeUtil.getCurrentDateTime());
//执行工作流 //执行工作流
if (req.getExamineState().equals("working")) if (req.getExamineState().equals("working"))
{ {
StartProcessInstanceDTO startProcessInstanceDTO=new StartProcessInstanceDTO(); StartProcessInstanceDTO startProcessInstanceDTO=new StartProcessInstanceDTO();
startProcessInstanceDTO.setProcessDefinitionId(req.getProcessDefinitionId()); startProcessInstanceDTO.setProcessDefinitionId(req.getProcessDefinitionId());
startProcessInstanceDTO.setOrderId(id); startProcessInstanceDTO.setOrderId(order.getId());
startProcessInstanceDTO.setOrderType("workOrder"); startProcessInstanceDTO.setOrderType("workOrder");
startProcessInstanceDTO.setUserId(req.getUserId()); startProcessInstanceDTO.setUserId(req.getUserId());
String ProcessInstanceId= FlowInstanceService.startProcessInstanceById(startProcessInstanceDTO); String ProcessInstanceId= FlowInstanceService.startProcessInstanceById(startProcessInstanceDTO);
order.setProcessId(ProcessInstanceId); order.setProcessId(ProcessInstanceId);
//保存
this.save(order);
} }
if (req.getExamineState().equals("none")){//如果是草稿 if (ObjectUtil.isNotNull(req.getId())){
if(ObjectUtil.isNotNull(req.getId())){
//已经是一个草稿,在点击提交的时候只需要更新即可,因为数据库中已经存在该单据
updateById(order); updateById(order);
}else { }else {
//保存 //保存
this.save(order); this.save(order);
} }
} //list返回数据
List<String> list=new ArrayList<>();
list.add(order.getId()); list.add(order.getId());
for (OrderDetail orderDetail:detailList) { for (OrderDetail orderDetail:detailList) {
list.add(Long.toString(orderDetail.getId())); list.add(Long.toString(orderDetail.getId()));
...@@ -206,7 +285,6 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -206,7 +285,6 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
//添加到数据库中 //添加到数据库中
List<String> strings = AddOrder(req); List<String> strings = AddOrder(req);
System.out.println("strings = " + strings);
req.setId(strings.get(0)); req.setId(strings.get(0));
List<UpdateOrderDetailReq> detailList = req.getDetailList(); List<UpdateOrderDetailReq> detailList = req.getDetailList();
//将子单据id传递 //将子单据id传递
...@@ -251,72 +329,7 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -251,72 +329,7 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
{ {
throw new ServiceException(OrderExceptionEnum.ORDER_CAN_NOT_UPDATE); throw new ServiceException(OrderExceptionEnum.ORDER_CAN_NOT_UPDATE);
} }
//方法1(分为两步进行操作)-------------------------------------------------- //(直接删除并重新插入数据)----------------------------------------------
// List<OrderDetail> list= orderDetailService.QueryList(req.getId());
//idSet中存放的是存在数据库中的任务单中的orderDetail中的id(原始的工作单中的数据id)
// Set<Long> idSet =new HashSet<>();
// for (OrderDetail orderDetail:list){
// idSet.add(orderDetail.getId());
// }
// //将该任务单的所有id转换为String,并添加到updateList中,用来判断删除或者修改新增的是否存在
// //判断删除列表是否为空,如果不为空则进行批量删除
// if (ObjectUtil.isNotNull(req.getDeleteList())&& ObjectUtil.isNotEmpty(req.getDeleteList())) {
// //判断传递的list Id是否存在,如果不存在则抛出异常
// for (Long s:req.getDeleteList()){
// if (idSet.contains(s)){
// //将要删除的装备价格和数据进行查询出来,并别对任务单的总数量和总价格进行更改
// OrderDetail one = orderDetailService.getOne(new LambdaQueryWrapper<OrderDetail>()
// .eq(OrderDetail::getOrderId, s));
// order.setPrice(order.getPrice().subtract(one.getPrice().multiply(BigDecimal.valueOf(one.getPlanNum()))));
// order.setInventoryQuantity(order.getInventoryQuantity() - one.getPlanNum());
//
// }else {
// throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR);
// }
// }
// orderDetailService.removeBatchByIds(req.getDeleteList());
// }
//对detaillist进行处理
// List<OrderDetail> addList = new ArrayList<>();//新增的
// List<OrderDetail> updateList = new ArrayList<>();//更新
// for (UpdateOrderDetailReq updateOrderDetailReq :req.getDetailList()) {
// //判断是否存在,存在则进行修改
// if (idSet.contains(updateOrderDetailReq.getId())){
// OrderDetail one = orderDetailService.getOne(new LambdaQueryWrapper<OrderDetail>()
// .eq(OrderDetail::getId, updateOrderDetailReq.getId()));
// BeanPlusUtil.copyProperties(updateOrderDetailReq,one);
// one.setType(req.getOrderType());
// //判断数量和价格是否有变动,如果有变动,则将order的总价和总数量进行更新操作,否则不变
// if (one.getPlanNum().equals(updateOrderDetailReq.getPlanNum()) && one.getPrice().compareTo(updateOrderDetailReq.getPrice())!=0){
// order.setPrice(order.getPrice().subtract(one.getPrice().multiply(BigDecimal.valueOf(one.getPlanNum())))
// .add(updateOrderDetailReq.getPrice().multiply(BigDecimal.valueOf(updateOrderDetailReq.getPlanNum()))));
// order.setInventoryQuantity(order.getInventoryQuantity() - one.getPlanNum()+ updateOrderDetailReq.getPlanNum());
// }
// one.setUpdateTime(DateTimeUtil.getCurrentDateTime());
// updateList.add(one);
// }else {
// //否则判断id是否为空或者错误,如果为空则添加,不为空则抛出异常
// if (ObjectUtil.isNull(updateOrderDetailReq.getId()) || ObjectUtil.isEmpty(updateOrderDetailReq.getId())){
// OrderDetail detail=new OrderDetail();
// BeanPlusUtil.copyProperties(updateOrderDetailReq, detail);
// detail.setOrderId(req.getId());
// detail.setType(req.getOrderType());
// //将数量和价格进行相加处理
// order.setPrice(order.getPrice().add(updateOrderDetailReq.getPrice().multiply(BigDecimal.valueOf(updateOrderDetailReq.getPlanNum()))));
// order.setInventoryQuantity(order.getInventoryQuantity() + updateOrderDetailReq.getPlanNum());
// detail.setUpdateTime(DateTimeUtil.getCurrentDateTime());
// addList.add(detail);
// }else {
// throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR);
// }
//
// }
// }
// orderDetailService.updateBatchById(updateList);
// orderDetailService.saveBatch(addList);
// BeanPlusUtil.copyProperties(req,order);
// 方法2(直接删除并重新插入数据)----------------------------------------------
orderDetailService.remove(new LambdaQueryWrapper<OrderDetail>().eq(OrderDetail::getOrderId, req.getId())); orderDetailService.remove(new LambdaQueryWrapper<OrderDetail>().eq(OrderDetail::getOrderId, req.getId()));
Integer sumNum=0; Integer sumNum=0;
BigDecimal priceTotal=new BigDecimal(0); BigDecimal priceTotal=new BigDecimal(0);
...@@ -417,6 +430,14 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -417,6 +430,14 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
for (OrderDetail orderDetail:list) { for (OrderDetail orderDetail:list) {
OrderDetailDto orderDetailDto = new OrderDetailDto(); OrderDetailDto orderDetailDto = new OrderDetailDto();
BeanPlusUtil.copyProperties(orderDetail,orderDetailDto); BeanPlusUtil.copyProperties(orderDetail,orderDetailDto);
if (orderMain.getOrderType().equals("out")){
InventorySummary one = inventorySummaryService.getOne(new LambdaQueryWrapper<InventorySummary>()
.eq(InventorySummary::getLocationId, orderDetail.getWarehouseId())
.eq(InventorySummary::getSizeId, orderDetail.getSizeId())
.eq(InventorySummary::getTypeId, orderDetail.getTypeId())
.eq(InventorySummary::getUnitPrice, orderDetail.getPrice()));
orderDetailDto.setStockNumber(one.getStockNumber());
}
orderDetailDtoList.add(orderDetailDto); orderDetailDtoList.add(orderDetailDto);
} }
orderDto.setDetailList(orderDetailDtoList); orderDto.setDetailList(orderDetailDtoList);
...@@ -528,16 +549,18 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -528,16 +549,18 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
updateSummaryInfo(req,orderDetailReqList,orgId); updateSummaryInfo(req,orderDetailReqList,orgId);
//修改仓库表中的数量汇总信息(warehouse) //修改仓库表中的数量汇总信息(warehouse)
updateWarehouseInfo(req,orderDetailReqList,orgId); // updateWarehouseInfo(req,orderDetailReqList,orgId);
//更新主单据的数量和价格 //更新主单据的数量和价格
//记账直接将单子结束
//修改记账状态,0未记账,1已记账 //修改记账状态,0未记账,1已记账
orderMain.setActualQuantity(updateQuantity); orderMain.setActualQuantity(updateQuantity);
orderMain.setPrice(priceTotal); orderMain.setPrice(priceTotal);
orderMain.setOrderState("finished"); orderMain.setOrderState("finished");
orderMain.setManualState(1); orderMain.setManualState(1);
orderMain.setUpdateTime(DateTimeUtil.getCurrentDateTime()); orderMain.setUpdateTime(DateTimeUtil.getCurrentDateTime());
//如果是领用出库,那记账结束以后将装备挂到警员名下(存储到policemanEquipment表中)
//更新主单据 //更新主单据
return updateById(orderMain); return updateById(orderMain);
} }
...@@ -641,7 +664,6 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -641,7 +664,6 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
@Override @Override
public void InOrderExport(OrderMainReq req) { public void InOrderExport(OrderMainReq req) {
LambdaQueryWrapper<OrderMain> wrapper = createWrapper(req); LambdaQueryWrapper<OrderMain> wrapper = createWrapper(req);
System.out.println("list(wrapper).size() = " + list(wrapper).size());
List<InOrderInfo> collect = list(wrapper).stream().map(orderMain -> { List<InOrderInfo> collect = list(wrapper).stream().map(orderMain -> {
InOrderInfo inOrderInfo = new InOrderInfo(); InOrderInfo inOrderInfo = new InOrderInfo();
BeanPlusUtil.copyProperties(orderMain, inOrderInfo); BeanPlusUtil.copyProperties(orderMain, inOrderInfo);
...@@ -665,8 +687,6 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -665,8 +687,6 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
for (int i = 1; i <= collect.size() ; i++) { for (int i = 1; i <= collect.size() ; i++) {
collect.get(i-1).setNumId(i); collect.get(i-1).setNumId(i);
} }
System.out.println("collect.size() = " + collect.size());
System.out.println("collect = " + collect);
HttpServletResponse response = HttpServletUtil.getResponse(); HttpServletResponse response = HttpServletUtil.getResponse();
ExcelExportParam param = new ExcelExportParam(); ExcelExportParam param = new ExcelExportParam();
param.setDataList(collect); param.setDataList(collect);
......
...@@ -55,13 +55,16 @@ public class StocktakeServiceImpl extends ServiceImpl<StocktakeMapper, Stocktake ...@@ -55,13 +55,16 @@ public class StocktakeServiceImpl extends ServiceImpl<StocktakeMapper, Stocktake
Stocktake stocktake = new Stocktake(); Stocktake stocktake = new Stocktake();
BeanPlusUtil.copyProperties(req,stocktake); BeanPlusUtil.copyProperties(req,stocktake);
//设置单号 //设置单号
if (ObjectUtil.isNull(stocktake.getOrderCode())){
OrderNum orderNum = setOrderCode(req.getBussinessType(),req.getOrgId()); OrderNum orderNum = setOrderCode(req.getBussinessType(),req.getOrgId());
String codeValue=String.format("%04d",orderNum.getNum()); String codeValue=String.format("%04d",orderNum.getNum());
stocktake.setOrderCode(orderNum.getBussinessType()+"-"+orderNum.getYear()+"-"+ stocktake.setOrderCode(orderNum.getBussinessType()+orderNum.getYear()+
LocalDateTime.now().getMonth().getValue()+"-"+LocalDateTime.now().getDayOfMonth()+"-"+codeValue); String.format("%02d",LocalDateTime.now().getMonth().getValue())+
String.format("%02d",LocalDateTime.now().getDayOfMonth())+codeValue);
}
stocktake.setCreateTime(DateTimeUtil.getCurrentDateTime()); stocktake.setCreateTime(DateTimeUtil.getCurrentDateTime());
stocktake.setApplyTime(DateTimeUtil.getCurrentDateTime()); stocktake.setApplyTime(DateTimeUtil.getCurrentDateTime());
this.save(stocktake);
//执行工作流 //执行工作流
if (req.getExamineState().equals("working")) if (req.getExamineState().equals("working"))
{ {
...@@ -73,6 +76,7 @@ public class StocktakeServiceImpl extends ServiceImpl<StocktakeMapper, Stocktake ...@@ -73,6 +76,7 @@ public class StocktakeServiceImpl extends ServiceImpl<StocktakeMapper, Stocktake
String ProcessInstanceId= FlowInstanceService.startProcessInstanceById(startProcessInstanceDTO); String ProcessInstanceId= FlowInstanceService.startProcessInstanceById(startProcessInstanceDTO);
stocktake.setProcessId(ProcessInstanceId); stocktake.setProcessId(ProcessInstanceId);
} }
this.save(stocktake);
return stocktake.getId(); return stocktake.getId();
} }
......
...@@ -77,28 +77,37 @@ delete from base_inventory_summary ...@@ -77,28 +77,37 @@ delete from base_inventory_summary
<insert id="SetCabinetInventory"> <insert id="SetCabinetInventory">
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) 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,
broken_number,use_number,near_broken_number,location_type,create_time,update_time)
select 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() 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,sum(t.brokenNumber)as brokenNumber,
sum(t.useNumber)as useNumber,sum(t.nearBrokenNumber)as nearBrokenNumber,t.location_type,NOW(),NOW()
FROM FROM
(SELECT (SELECT
UUID() as id, UUID() as id,
bi.org_id_int as orgId, bi.org_id_int as orgId,
po.org_name as orgName, po.org_name as orgName,
bcb.cabinet_id as locationId, bcb.cabinet_id as locationId,
bi.location_id as locationBoxId,
bc.name as locationName, bc.name as locationName,
bi.type_id, bi.type_id,
t.name as typeName, t.name as typeName,
bi.size_id, bi.size_id,
s.name as sizeName, s.name as sizeName,
count(*) as number, SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
Max(bi.price) as unitPrice, bi.price as unitPrice,
sum(bi.price) as price, sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber, 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 location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber, 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, sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &gt; NOW() then 1 else 0 end )as expireNumber,
sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &lt; NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) &lt; #{brokenNumberDays} then 1 else 0 end)as nearBrokenNumber,
bi.location_type bi.location_type
FROM base_inventory bi FROM base_inventory bi
join base_cabinet_box bcb on bi.location_id = bcb.id join base_cabinet_box bcb on bi.location_id = bcb.id
...@@ -107,33 +116,43 @@ delete from base_inventory_summary ...@@ -107,33 +116,43 @@ delete from base_inventory_summary
join base_equipment_size s on s.id = bi.size_id join base_equipment_size s on s.id = bi.size_id
join pub_org po on bi.org_id_int = po.org_id join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 1 WHERE location_type = 1
GROUP BY location_id, type_id,size_id,bi.org_id_int,bi.price ) as t GROUP BY bi.org_id_int, bcb.cabinet_id, type_id,size_id,bi.price
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice order by po.org_name,bc.name ) as t
GROUP BY t.orgName,t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
</insert> </insert>
<insert id="SetWarehouseInventory"> <insert id="SetWarehouseInventory">
INSERT INTO base_inventory_summary (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) INSERT INTO base_inventory_summary (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,broken_number,use_number,near_broken_number,location_type,create_time,update_time)
select 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() 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,sum(t.brokenNumber)as brokenNumber,sum(t.useNumber)as useNumber,
sum(t.nearBrokenNumber)as nearBrokenNumber,t.location_type,NOW(),NOW()
FROM FROM
(SELECT (SELECT
UUID() as id, UUID() as id,
bi.org_id_int as orgId, bi.org_id_int as orgId,
po.org_name as orgName, po.org_name as orgName,
MAX(bi.location_id) as locationId, bi.location_id as locationId,
MAX(bw.name) as locationName, bw.name as locationName,
bi.type_id, bi.type_id,
t.name as typeName, t.name as typeName,
bi.size_id, bi.size_id,
s.name as sizeName, s.name as sizeName,
count(*) as number, SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
Max(bi.price) as unitPrice, bi.price as unitPrice,
sum(bi.price) as price, sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber, 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 location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber, 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 sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &gt; NOW() then 1 else 0 end )as expireNumber,
else 0 end )as expireNumber, sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &lt; NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) &lt; #{brokenNumberDays} then 1 else 0 end)as nearBrokenNumber,
bi.location_type bi.location_type
FROM base_inventory bi FROM base_inventory bi
join base_warehouse bw on bi.location_id = bw.id join base_warehouse bw on bi.location_id = bw.id
...@@ -141,13 +160,19 @@ delete from base_inventory_summary ...@@ -141,13 +160,19 @@ delete from base_inventory_summary
join base_equipment_size s on s.id = bi.size_id join base_equipment_size s on s.id = bi.size_id
join pub_org po on bi.org_id_int = po.org_id join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 0 WHERE location_type = 0
GROUP BY type_id,size_id,bi.org_id_int,location_id,bi.price) as t GROUP BY type_id,size_id,bi.org_id_int,location_id,bi.price
order by po.org_name,bw.name) as t
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
</insert> </insert>
<insert id="insertInventorySummary"> <insert id="insertInventorySummary">
INSERT INTO base_inventory_summary (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) INSERT INTO base_inventory_summary (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,use_number,near_broken_number,create_time,update_time)
select 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() 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,sum(t.useNumber)as useNumber,
sum(t.nearBrokenNumber)as nearBrokenNumber,t.location_type,NOW(),NOW()
FROM FROM
(SELECT (SELECT
UUID() as id, UUID() as id,
...@@ -165,8 +190,12 @@ delete from base_inventory_summary ...@@ -165,8 +190,12 @@ delete from base_inventory_summary
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber, 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, 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.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 sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &gt; NOW() then 1
else 0 end )as expireNumber, else 0 end )as expireNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &lt; NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) &lt; #{brokenNumberDays} then 1 else 0 end)as nearBrokenNumber,
bi.location_type bi.location_type
FROM base_inventory bi FROM base_inventory bi
join base_warehouse bw on bi.location_id = bw.id join base_warehouse bw on bi.location_id = bw.id
...@@ -246,7 +275,8 @@ delete from base_inventory_summary ...@@ -246,7 +275,8 @@ delete from base_inventory_summary
</select> </select>
<select id="getSumByShelf" resultType="com.junmp.jyzb.entity.InventorySummary" <select id="getSumByShelf" resultType="com.junmp.jyzb.entity.InventorySummary"
parameterType="java.lang.String"> parameterType="java.lang.String">
select t.id,t.orgId,t.orgName,t.locationId,t.locationName,t.shelf_id,t.type_id,t.typeName,t.size_id,t.sizeName,t.number,t.price,t.stockNumber,t.outboundNumber,t.location_type select t.id,t.orgId,t.orgName,t.locationId,t.locationName,t.shelf_id,t.type_id,t.typeName,t.size_id,t.sizeName,
t.number,t.price,t.stockNumber,t.outboundNumber,t.location_type
FROM FROM
(SELECT (SELECT
UUID() as id, UUID() as id,
......
...@@ -68,10 +68,21 @@ ...@@ -68,10 +68,21 @@
</if> </if>
</select> </select>
<delete id="deleteByCabinet" parameterType="java.lang.String">
delete from base_inventory_summary where locationId = #{cabinetId}
</delete>
<insert id="getSumByCabinet"> <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) 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,
broken_number,use_number,near_broken_number,location_type,create_time,update_time)
select 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() 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,sum(t.brokenNumber)as brokenNumber,
sum(t.useNumber)as useNumber,sum(t.nearBrokenNumber)as nearBrokenNumber,t.location_type,NOW(),NOW()
FROM FROM
(SELECT (SELECT
UUID() as id, UUID() as id,
...@@ -84,13 +95,18 @@ ...@@ -84,13 +95,18 @@
t.name as typeName, t.name as typeName,
bi.size_id, bi.size_id,
s.name as sizeName, s.name as sizeName,
count(*) as number, SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
bi.price as unitPrice, bi.price as unitPrice,
sum(bi.price) as price, sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber, 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 location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber, 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, sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &gt; NOW() then 1 else 0 end )as expireNumber,
sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &lt; NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) &lt; #{brokenNumberDays} then 1 else 0 end)as nearBrokenNumber,
bi.location_type bi.location_type
FROM base_inventory bi FROM base_inventory bi
join base_cabinet_box bcb on bi.location_id = bcb.id join base_cabinet_box bcb on bi.location_id = bcb.id
...@@ -105,22 +121,55 @@ ...@@ -105,22 +121,55 @@
</insert> </insert>
<select id="getTotalNumberAndPrice" resultType="com.junmp.jyzb.entity.InventorySummary">
select sum(number) as number,sum(price)as price,sum(stock_number)as stockNumber,
sum(outbound_number)as outboundNumber,sum(destruction_number)as destructionNumber,
sum(expire_number)as expireNumber,sum(broken_number)as brokenNumber,max(location_type)
FROM base_inventory_summary where 1=1
<if test="req.orgId != null and req.orgId != ''">
and org_id_int=#{req.orgId}
</if>
<if test="req.locationId !=null and req.locationId != ''">
and location_id=#{req.locationId}
</if>
<if test="req.sizeId != null and req.sizeId != ''">
and size_id=#{req.sizeId}
</if>
<if test="req.TypeId != null and req.typeId != ''">
and type_id=#{req.typeId}
</if>
<if test="req.locationType != null and req.locationType != ''">
and location_type=#{req.locationType}
</if>
</select>
<select id="EquipmentStatistics" resultType="com.junmp.jyzb.entity.InventorySummary"
parameterType="com.junmp.jyzb.api.bean.query.InventorySumReq">
select sum(number) as number,sum(price)as price,sum(stock_number)as stockNumber,
sum(outbound_number)as outboundNumber,sum(destruction_number)as destructionNumber,
sum(expire_number)as expireNumber,sum(broken_number)as brokenNumber,
sum(near_broken_number)as nearBrokenNumber,sum(use_number)as useNumber
FROM base_inventory_summary where org_id_int=#{req.orgId}
</select>
<delete id="deleteByWarehouse" <delete id="deleteByWarehouse"
parameterType="com.junmp.jyzb.api.bean.dto.WarehouseDto"> parameterType="com.junmp.jyzb.api.bean.dto.WarehouseDto">
delete from base_inventory_summary_type2 delete from base_inventory_summary
where location_id in where location_id in
<foreach collection="list" item="item" open="(" separator="," close=")"> <foreach collection="list" item="item" open="(" separator="," close=")">
#{item.id} #{item.id}
</foreach> </foreach>
</delete> </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) <insert id="getSumByWarehouse" >
INSERT INTO base_inventory_summary (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,broken_number,use_number,near_broken_number,location_type,create_time,update_time)
select 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() 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,sum(t.brokenNumber) as brokenNumber,
sum(t.useNumber)as useNumber,sum(t.nearBrokenNumber)as nearBrokenNumber,t.location_type,NOW(),NOW()
FROM FROM
(SELECT (SELECT
UUID() as id, UUID() as id,
...@@ -132,14 +181,18 @@ ...@@ -132,14 +181,18 @@
t.name as typeName, t.name as typeName,
bi.size_id, bi.size_id,
s.name as sizeName, s.name as sizeName,
count(*) as number, SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
Max(bi.price) as unitPrice, bi.price as unitPrice,
sum(bi.price) as price, sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber, 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 location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber, 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 sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &gt; NOW() then 1 else 0 end )as expireNumber,
else 0 end )as expireNumber, sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &lt; NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) &lt; #{brokenNumberDays} then 1 else 0 end)as nearBrokenNumber,
bi.location_type bi.location_type
FROM base_inventory bi FROM base_inventory bi
join base_warehouse bw on bi.location_id = bw.id join base_warehouse bw on bi.location_id = bw.id
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
picture,equipment_List,create_time, picture,equipment_List,create_time,
update_time,update_user,create_user update_time,update_user,create_user
</sql> </sql>
<select id="ShowInOutRecordsPage" resultType="com.junmp.jyzb.entity.LogSummary"> <select id="ShowInOutRecordsByOrder" resultType="com.junmp.jyzb.entity.LogSummary">
select * from base_log_summary ls select * from base_log_summary ls
where ls.org_id = #{req.orgId} and ls.order_main_id=#{req.orderMainId} where ls.org_id = #{req.orgId} and ls.order_main_id=#{req.orderMainId}
</select> </select>
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
select * FROM bussiness_order_main WHERE order_type=#{req.orderType} select * FROM bussiness_order_main WHERE order_type=#{req.orderType}
<if test="req.typeId != null and req.typeId != ''"> <if test="req.typeId != null and req.typeId != ''">
and id in( and id in(
SELECT order_id FROM bussiness_order_detail WHERE equipment_type = #{req.typeId}) SELECT order_id FROM bussiness_order_detail WHERE type_id = #{req.typeId})
</if> </if>
<if test="null != req.bussinessType and '' != req.bussinessType "> <if test="null != req.bussinessType and '' != req.bussinessType ">
and bussiness_type = #{req.bussinessType} and bussiness_type = #{req.bussinessType}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论