Commit a30195b9 by 李小惠

出入库,记账,调试bug

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