Commit 6b269a33 by 赵剑炜

盘点上报接口微调

parent 7a67f435
...@@ -83,4 +83,11 @@ public class BussinessInventoryController { ...@@ -83,4 +83,11 @@ public class BussinessInventoryController {
//判断是否有工作流id,如果有则将状态进行修改 //判断是否有工作流id,如果有则将状态进行修改
return ApiRes.success(BussinessInventoryService.UploadStock(req)); return ApiRes.success(BussinessInventoryService.UploadStock(req));
} }
//盘库申请
@PostMapping("/UseOrFinished")
@ApiOperation("确认结果/结束盘点")
public ApiRes<Boolean> UseOrFinished (@RequestBody UploadInventoryReq req){
//判断是否有工作流id,如果有则将状态进行修改
return ApiRes.success(BussinessInventoryService.UploadStock(req));
}
} }
...@@ -11,6 +11,7 @@ import lombok.NoArgsConstructor; ...@@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
...@@ -61,7 +62,16 @@ public class BussinessDetail implements Serializable { ...@@ -61,7 +62,16 @@ public class BussinessDetail implements Serializable {
*/ */
@TableField(value = "stock_number") @TableField(value = "stock_number")
private Integer stockNumber; private Integer stockNumber;
/**
* 月
*/
@TableField(value = "stock_price")
private BigDecimal stockPrice;
/**
* 月
*/
@TableField(value = "fix_price")
private BigDecimal fixPrice;
/** /**
* 申请时间 * 申请时间
*/ */
......
...@@ -121,6 +121,7 @@ public class InventorySummary implements Serializable { ...@@ -121,6 +121,7 @@ public class InventorySummary implements Serializable {
@ApiModelProperty(value = "在库数") @ApiModelProperty(value = "在库数")
@TableField("stock_number") @TableField("stock_number")
private Integer stockNumber; private Integer stockNumber;
@TableField(exist = false) @TableField(exist = false)
private BigDecimal stockNumberPrice; private BigDecimal stockNumberPrice;
/** /**
......
...@@ -72,7 +72,7 @@ public class WarehouseInventory implements Serializable { ...@@ -72,7 +72,7 @@ public class WarehouseInventory implements Serializable {
/** /**
* 更新时间 * 更新时间
*/ */
@TableField(value = "org_id") @TableField(value = "update_time")
private Date updateTime; private Date updateTime;
/** /**
......
...@@ -31,4 +31,5 @@ public interface BussinessInventoryService extends IService<BussinessInventory> ...@@ -31,4 +31,5 @@ public interface BussinessInventoryService extends IService<BussinessInventory>
BussinessInventoryDto GetDetailById(BussinessInventoryReq req); BussinessInventoryDto GetDetailById(BussinessInventoryReq req);
Boolean UploadStock(UploadInventoryReq req); Boolean UploadStock(UploadInventoryReq req);
Boolean UseOrFinished(UploadInventoryReq req);
} }
...@@ -45,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -45,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.beans.Transient; import java.beans.Transient;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -60,6 +61,8 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor ...@@ -60,6 +61,8 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor
@Resource @Resource
private IFlowInstanceService FlowInstanceService; private IFlowInstanceService FlowInstanceService;
@Resource @Resource
private InventorySummaryService inventorySummaryService;
@Resource
private SysDictItemService sysDictItemService; private SysDictItemService sysDictItemService;
@Resource @Resource
private SysDictService sysDictService; private SysDictService sysDictService;
...@@ -72,8 +75,6 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor ...@@ -72,8 +75,6 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor
@Resource @Resource
private WarehouseInventoryService warehouseInventoryService; private WarehouseInventoryService warehouseInventoryService;
@Resource @Resource
private InventorySummaryService inventorySummaryService;
@Resource
private OrderNumService orderNumService; private OrderNumService orderNumService;
@Autowired @Autowired
private RabbitMQSendMsg MQ; private RabbitMQSendMsg MQ;
...@@ -205,6 +206,7 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor ...@@ -205,6 +206,7 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor
InventorySumReq sumreq=new InventorySumReq(); InventorySumReq sumreq=new InventorySumReq();
sumreq.setLocationType("0"); sumreq.setLocationType("0");
sumreq.setLocationId(warehouseId); sumreq.setLocationId(warehouseId);
BussinessInventoryDto BIDto=new BussinessInventoryDto(); BussinessInventoryDto BIDto=new BussinessInventoryDto();
if (ObjectUtil.isEmpty(type) || ObjectUtil.isNull(type)) { if (ObjectUtil.isEmpty(type) || ObjectUtil.isNull(type)) {
} }
...@@ -244,49 +246,8 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor ...@@ -244,49 +246,8 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor
if (bi!=null) if (bi!=null)
{ {
BussinessInventory inventory= this.getById(orderId);
String type=inventory.getInventoryType().toString();//获取盘点类型
String warehouseId=inventory.getWarehouseId();
InventorySumReq sumreq=new InventorySumReq();
sumreq.setLocationType("0");
sumreq.setLocationId(warehouseId);
BussinessInventoryDto BIDto=new BussinessInventoryDto();
List<BussinessDetail> detailList=new ArrayList<>();
if (type.equals("1"))//按装备类型盘点
{
List<String> typeIds = Arrays.asList(req.getTypeList().split(","));
sumreq.setTypeIds(typeIds);
} else if (type.equals("2"))//按装备号型盘点
{
List<String> sizeIds = Arrays.asList(req.getTypeList().split(","));
sumreq.setSizeIds(sizeIds);
}
List<EquipmentListDto> eqList=new ArrayList<>();
Integer totalNumber=0;
List<InventorySummary> SumResult = inventorySummaryService.getEquipmentInfoList(sumreq);
for (InventorySummary summary : SumResult) {
BussinessDetail detail=new BussinessDetail();
EquipmentListDto eq=new EquipmentListDto();
BeanPlusUtil.copyProperties(summary,eq);
eq.setPlanNum(String.valueOf(summary.getStockNumber()));
totalNumber+=summary.getStockNumber();
eqList.add(eq);
}
BIDto.setTotalNum(String.valueOf(totalNumber));
BIDto.setEquipmentList(eqList);
// List<BussinessDetail> details = bussinessInventoryDetailService.list(
// new LambdaQueryWrapper<BussinessDetail>().eq(BussinessDetail::getInventoryId, bi.getId())
// );
// bi.setDetailList(details);
Warehouse warehouseSet= warehouseService.getById(bi.getWarehouseId());//先锁库,再下发盘点
warehouseSet.setIsLocked(true);
bi.setInventoryState("running"); bi.setInventoryState("running");
warehouseService.updateById(warehouseSet); this.save(bi);
MQ.SendMsg("BussinessInv",warehouseSet.getOrgId().toString(),bi);
} }
else else
{ {
...@@ -373,12 +334,109 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor ...@@ -373,12 +334,109 @@ public class BussinessInventoryServiceImpl extends ServiceImpl<BussinessInventor
Bussinessdetails.add(eqDto); Bussinessdetails.add(eqDto);
} }
BI.setResult(req.getState()); BI.setResult(req.getState());
BI.setInventoryState("running"); BI.setInventoryState("finished");
this.updateById(BI); this.updateById(BI);
bussinessInventoryDetailService.saveBatch(Bussinessdetails); bussinessInventoryDetailService.saveBatch(Bussinessdetails);
return true; return true;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean UseOrFinished(UploadInventoryReq req) {
//更新之前先把库存表的epc备份
BussinessInventory BI= this.getById(req.getOrderId());
List<BussinessDetail> details;
List<WarehouseInventory> DeleteList;
List<WarehouseInventory> UpdateList;
List<BussinessDetail> BusinessDetail = bussinessInventoryDetailService.list(
new LambdaQueryWrapper<BussinessDetail>().eq(BussinessDetail::getInventoryId, req.getOrderId())
);
InventorySumReq sumreq=new InventorySumReq();
sumreq.setLocationType("0");
sumreq.setLocationId(BI.getWarehouseId());
if (BI.getInventoryType().equals("1"))//按装备类型盘点
{
List<String> typeIds = Arrays.asList(BI.getRules().split(","));
sumreq.setTypeIds(typeIds);
} else if (BI.getInventoryType().equals("2"))//按装备号型盘点
{
List<String> sizeIds = Arrays.asList(BI.getRules().split(","));
sumreq.setSizeIds(sizeIds);
}
List<InventorySummary> SumResult = inventorySummaryService.getEquipmentInfoList(sumreq);
for (InventorySummary summary : SumResult) {
for (BussinessDetail businessDetail : BusinessDetail) {
if (summary.getTypeId().equals(businessDetail.getTypeId()) && summary.getSizeId().equals(businessDetail.getSizeId())) {
summary.setStockNumber(businessDetail.getFixNumber());
summary.setOutboundNumber(0);
summary.setNumber(businessDetail.getFixNumber());
if (businessDetail.getState().equals(1))//盈余状态需要增加金额和数量
{
summary.setPrice( summary.getPrice().add(businessDetail.getFixPrice()));
businessDetail.setStockPrice(summary.getStockNumberPrice());
}
else if (businessDetail.getState().equals(2))//亏损状态需要减少金额和数量
{
BigDecimal fixPriceNew=summary.getPrice().subtract(businessDetail.getFixPrice());
int i = fixPriceNew.compareTo(BigDecimal.ZERO);
if (i == -1) {
summary.setPrice(BigDecimal.ZERO);
} else if (i == 1||i == 0) {
summary.setPrice( fixPriceNew);
}
}
}
}
}
// if (req.getState().equals("0"))//确认结果
// {
List<String> DeleteInventorys = Arrays.asList(BI.getEpcBack().split(","));
DeleteList = warehouseInventoryService.list(//找出所有
new LambdaQueryWrapper<WarehouseInventory>()
.and(qw -> DeleteInventorys.forEach(epc -> qw.or().eq(WarehouseInventory::getEpc, epc)))
);
List<String> UpdateInventorys = Arrays.asList(BI.getEpc_update().split(","));
UpdateList = warehouseInventoryService.list(//找出所有
new LambdaQueryWrapper<WarehouseInventory>()
.and(qw -> UpdateInventorys.forEach(epc -> qw.or().eq(WarehouseInventory::getEpc, epc)))
);
warehouseInventoryService.removeBatchByIds(DeleteList);
warehouseInventoryService.saveBatch(UpdateList);
BI.setInventoryState("close");
BI.setUpdateTime(DateTimeUtil.getCurrentDateTime());
this.updateById(BI);
inventorySummaryService.updateBatchById(SumResult);
// }
// else if (req.getState().equals("1"))//回滚结果
// {
// List<String> DeleteInventorys = Arrays.asList(BI.getEpcBack().split(","));
// UpdateList= warehouseInventoryService.list(//找出所有
// new LambdaQueryWrapper<WarehouseInventory>()
// .and(qw -> DeleteInventorys.forEach(epc -> qw.or().eq(WarehouseInventory::getEpc, epc)))
// );
// List<String> UpdateInventorys = Arrays.asList(BI.getEpc_update().split(","));
// DeleteList = warehouseInventoryService.list(//找出所有
// new LambdaQueryWrapper<WarehouseInventory>()
// .and(qw -> UpdateInventorys.forEach(epc -> qw.or().eq(WarehouseInventory::getEpc, epc)))
// );
// warehouseInventoryService.removeBatchByIds(DeleteList);
// warehouseInventoryService.saveBatch(UpdateList);
// BI.setInventoryState("close");
// BI.setUpdateTime(DateTimeUtil.getCurrentDateTime());
// this.updateById(BI);
// }
return true;
}
@Override @Override
public PageResult<BussinessInventory> GetPage(BussinessInventoryReq req) { public PageResult<BussinessInventory> GetPage(BussinessInventoryReq req) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论