油品盘点
This commit is contained in:
parent
39aadfc467
commit
d05c5d8efb
@ -151,8 +151,9 @@
|
|||||||
and mg.supplier_id = #{mtPurchase.supplierId}
|
and mg.supplier_id = #{mtPurchase.supplierId}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY
|
GROUP BY create_time DESC
|
||||||
mp.id
|
mp.id
|
||||||
|
ORDER BY
|
||||||
</select>
|
</select>
|
||||||
<select id="getPurcaseList" resultType="com.fuint.business.convenienceSore.vo.MtPurchaseVO">
|
<select id="getPurcaseList" resultType="com.fuint.business.convenienceSore.vo.MtPurchaseVO">
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -284,4 +285,13 @@ public class OilOrderController extends BaseController {
|
|||||||
public ResponseObject editOilOrderRemark(@RequestBody OilOrder order){
|
public ResponseObject editOilOrderRemark(@RequestBody OilOrder order){
|
||||||
return getSuccessResult(orderService.editOilOrder(order));
|
return getSuccessResult(orderService.editOilOrder(order));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间获取销售数据 销售总油量 ,销售售出价,销售总价;
|
||||||
|
*/
|
||||||
|
@GetMapping("getInfoByTime")
|
||||||
|
public ResponseObject getInfoByTime(Date time, Integer oilGunId){
|
||||||
|
return getSuccessResult(orderService.getInfoByTime(time, oilGunId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,12 @@ import com.fuint.business.marketingActivity.activeDiscount.vo.ActiveDiscountPayV
|
|||||||
import com.fuint.business.order.entity.OilOrder;
|
import com.fuint.business.order.entity.OilOrder;
|
||||||
import com.fuint.business.order.vo.Excel.OilOrderExcel;
|
import com.fuint.business.order.vo.Excel.OilOrderExcel;
|
||||||
import com.fuint.business.order.vo.OilOrderVo;
|
import com.fuint.business.order.vo.OilOrderVo;
|
||||||
|
import com.fuint.business.petrolStationManagement.entity.OilGun;
|
||||||
import com.fuint.business.petrolStationManagement.entity.OilNumber;
|
import com.fuint.business.petrolStationManagement.entity.OilNumber;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -121,4 +123,6 @@ public interface OilOrderMapper extends BaseMapper<OilOrder> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
OilOrderVo selectOilOrderDescByOrderId(@Param("orderId") Integer orderId);
|
OilOrderVo selectOilOrderDescByOrderId(@Param("orderId") Integer orderId);
|
||||||
|
|
||||||
|
OilOrderVo getInfoByTime(@Param("time") Date time,@Param("list") List<OilGun> tankIds);
|
||||||
}
|
}
|
||||||
|
@ -543,4 +543,21 @@
|
|||||||
od.id = #{orderId}
|
od.id = #{orderId}
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getInfoByTime" resultType="com.fuint.business.order.vo.OilOrderVo">
|
||||||
|
select
|
||||||
|
SUM(oil_num) oilNum,
|
||||||
|
SUM(pay_amount) + SUM(balance_amount) + SUM(oil_card_amount) payAmount
|
||||||
|
from oil_order
|
||||||
|
<where>
|
||||||
|
<if test="time != null'"><!-- 开始时间检索 -->
|
||||||
|
and date_format(update_time),'%y%m%d') >= date_format(#{time},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
<if test="list != null and list != ''">
|
||||||
|
and tank_id in
|
||||||
|
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||||
|
#{list.tankId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -187,4 +188,6 @@ public interface OilOrderService extends IService<OilOrder> {
|
|||||||
* @param isMember 是否为会员
|
* @param isMember 是否为会员
|
||||||
*/
|
*/
|
||||||
void addGoodsSaleStatistic(Integer goodsId,Integer goodsNum,Integer storeId,Boolean isMember);
|
void addGoodsSaleStatistic(Integer goodsId,Integer goodsNum,Integer storeId,Boolean isMember);
|
||||||
|
|
||||||
|
OilOrderVo getInfoByTime(Date time,Integer tankId);
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,11 @@ public class OilPurchaseOrderController extends BaseController {
|
|||||||
return getSuccessResult(this.oilPurchaseOrderService.storage(id));
|
return getSuccessResult(this.oilPurchaseOrderService.storage(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据油品id查询最近的一次进油记录
|
||||||
|
@GetMapping("getOilInletRecords")
|
||||||
|
public ResponseObject getOilInletRecords(Integer numberId) {
|
||||||
|
return getSuccessResult(this.oilPurchaseOrderService.getOilInletRecords(numberId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.fuint.business.petrolStationManagement.dto.OilPurchaseDTO;
|
import com.fuint.business.petrolStationManagement.dto.OilPurchaseDTO;
|
||||||
import com.fuint.business.petrolStationManagement.entity.OilPurchase;
|
import com.fuint.business.petrolStationManagement.entity.OilPurchase;
|
||||||
|
import com.fuint.business.petrolStationManagement.entity.OilPurchaseOrder;
|
||||||
import com.fuint.business.petrolStationManagement.entity.OilTank;
|
import com.fuint.business.petrolStationManagement.entity.OilTank;
|
||||||
import com.fuint.business.petrolStationManagement.vo.OilPurchaseVO;
|
import com.fuint.business.petrolStationManagement.vo.OilPurchaseVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
@ -113,5 +113,8 @@ public interface OilPurchaseOrderMapper {
|
|||||||
*/
|
*/
|
||||||
List<OilPurchaseOrder> getlistByTankId(Integer tankId);
|
List<OilPurchaseOrder> getlistByTankId(Integer tankId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OilPurchaseOrder getOilInletRecords(Integer tankId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,11 @@ public interface OilTankMapper {
|
|||||||
* @return 影响行数
|
* @return 影响行数
|
||||||
*/
|
*/
|
||||||
int update(OilTank oilTank);
|
int update(OilTank oilTank);
|
||||||
int addStoredQuantityByLock(@Param("tankId") Integer tankId,@Param("changeNum") Double changeNum,@Param("totalAmount") Double totalAmount, @Param("discountedPrice")Double discountedPrice);
|
int addStoredQuantityByLock(@Param("tankId") Integer tankId,
|
||||||
|
@Param("changeNum") Double changeNum,
|
||||||
|
@Param("totalAmount") Double totalAmount,
|
||||||
|
@Param("discountedPrice")Double discountedPrice,
|
||||||
|
@Param("oilDensity") Double oilDensity);
|
||||||
|
|
||||||
int subtractStoredQuantityByLock(@Param("tankId") Integer tankId,@Param("changeNum") Double changeNum);
|
int subtractStoredQuantityByLock(@Param("tankId") Integer tankId,@Param("changeNum") Double changeNum);
|
||||||
|
|
||||||
|
@ -138,7 +138,13 @@
|
|||||||
op.inventory_time inventoryTime,
|
op.inventory_time inventoryTime,
|
||||||
oi.inventory_volume inventoryVolume,
|
oi.inventory_volume inventoryVolume,
|
||||||
oi.stock_difference stockDifference,
|
oi.stock_difference stockDifference,
|
||||||
oi.profit_loss_amount profitLossAmount
|
oi.profit_loss_amount profitLossAmount,
|
||||||
|
|
||||||
|
ot.total_price totalPrice,
|
||||||
|
|
||||||
|
onn.id oilNameId,
|
||||||
|
n.number_id numberId
|
||||||
|
|
||||||
FROM
|
FROM
|
||||||
oil_inventory_order oi
|
oil_inventory_order oi
|
||||||
LEFT JOIN oil_inventory op ON oi.inventory_id = op.id
|
LEFT JOIN oil_inventory op ON oi.inventory_id = op.id
|
||||||
|
@ -295,5 +295,6 @@
|
|||||||
delete from oil_purchase where id = #{id}
|
delete from oil_purchase where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
@ -303,5 +303,13 @@
|
|||||||
AND po.tank_id = 1
|
AND po.tank_id = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getOilInletRecords"
|
||||||
|
resultMap="OilPurchaseOrderMap">
|
||||||
|
select * from oil_purchase_order opo
|
||||||
|
left join oil_purchase op on opo.purchase_id = op.id
|
||||||
|
where opo.tank_id = #{tankId} and status = 'qrts' order by opo.create_time desc limit 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@
|
|||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<update id="cleanData">
|
<update id="cleanData">
|
||||||
update oil_tank set stored_quantity = 0.00 ,total_price = 0.00, discounted_price = 0.00 where id = #{id}
|
update oil_tank set oil_density=0.00 , stored_quantity = 0.00 ,total_price = 0.00, discounted_price = 0.00 where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
@ -435,6 +435,9 @@
|
|||||||
<if test="discountedPrice != null and discountedPrice != ''">
|
<if test="discountedPrice != null and discountedPrice != ''">
|
||||||
discounted_price = #{discountedPrice},
|
discounted_price = #{discountedPrice},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="oilDensity != null and oilDensity != ''">
|
||||||
|
oil_density = #{oilDensity},
|
||||||
|
</if>
|
||||||
update_time = NOW()
|
update_time = NOW()
|
||||||
where id = #{tankId}
|
where id = #{tankId}
|
||||||
</update>
|
</update>
|
||||||
|
@ -69,7 +69,7 @@ public interface OilGunService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<OilGun> selectOilGunByNumberId(Integer numberId);
|
List<OilGun> selectOilGunByNumberId(Integer numberId);
|
||||||
|
List<OilGun> selectOilGunByTankId(Integer tankId);
|
||||||
/**
|
/**
|
||||||
* 根据油号id查询油枪列表信息
|
* 根据油号id查询油枪列表信息
|
||||||
* @return
|
* @return
|
||||||
|
@ -77,4 +77,5 @@ public interface OilPurchaseOrderService {
|
|||||||
boolean abolition(Integer id);
|
boolean abolition(Integer id);
|
||||||
boolean storage(Integer id);
|
boolean storage(Integer id);
|
||||||
|
|
||||||
|
OilPurchaseOrder getOilInletRecords(Integer tankId);
|
||||||
}
|
}
|
||||||
|
@ -90,12 +90,13 @@ public interface OilTankService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param tankId
|
* @param tankId 油罐id
|
||||||
* @param changeNum 改变的数量
|
* @param changeNum 改变的数量
|
||||||
* @param totalAmount 修改的总价格
|
* @param totalAmount 修改的总价格
|
||||||
|
* @param density 密度 (进货时使用)
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
OilTank addStoredQuantityByLock(Integer tankId, Double changeNum, Double totalAmount);
|
OilTank addStoredQuantityByLock(Integer tankId, Double changeNum, Double totalAmount, Double density);
|
||||||
|
|
||||||
// OilTank addStoredQuantityByLock(Integer tankId, Double changeNum, Double totalAmount);
|
// OilTank addStoredQuantityByLock(Integer tankId, Double changeNum, Double totalAmount);
|
||||||
OilTank subtractStoredQuantityByLock(Integer tankId, Double changeNum);
|
OilTank subtractStoredQuantityByLock(Integer tankId, Double changeNum);
|
||||||
|
@ -181,6 +181,15 @@ public class OilGunServiceImpl implements OilGunService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OilGun> selectOilGunByTankId(Integer tankId) {
|
||||||
|
QueryWrapper queryWrapper = new QueryWrapper();
|
||||||
|
queryWrapper.eq("tank_id",tankId);
|
||||||
|
queryWrapper.eq("status","启用");
|
||||||
|
List<OilGun> list = oilGunDao.selectList(queryWrapper);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OilGun> selectOilGuns() {
|
public List<OilGun> selectOilGuns() {
|
||||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package com.fuint.business.petrolStationManagement.service.impl;
|
package com.fuint.business.petrolStationManagement.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.fuint.business.member.service.ILJStaffService;
|
import com.fuint.business.member.service.ILJStaffService;
|
||||||
|
import com.fuint.business.order.entity.OilOrder;
|
||||||
|
import com.fuint.business.order.service.OilOrderService;
|
||||||
|
import com.fuint.business.order.vo.OilOrderVo;
|
||||||
import com.fuint.business.petrolStationManagement.entity.*;
|
import com.fuint.business.petrolStationManagement.entity.*;
|
||||||
import com.fuint.business.petrolStationManagement.mapper.*;
|
import com.fuint.business.petrolStationManagement.mapper.*;
|
||||||
import com.fuint.business.petrolStationManagement.service.OilInventoryOrderService;
|
import com.fuint.business.petrolStationManagement.service.OilInventoryOrderService;
|
||||||
|
import com.fuint.business.petrolStationManagement.service.OilPurchaseOrderService;
|
||||||
import com.fuint.business.petrolStationManagement.vo.OilInventoryOrderVO;
|
import com.fuint.business.petrolStationManagement.vo.OilInventoryOrderVO;
|
||||||
import com.fuint.business.petrolStationManagement.vo.OilPurchaseOrderVO;
|
import com.fuint.business.petrolStationManagement.vo.OilPurchaseOrderVO;
|
||||||
import com.fuint.common.dto.AccountInfo;
|
import com.fuint.common.dto.AccountInfo;
|
||||||
@ -16,8 +21,10 @@ 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.xml.crypto.Data;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,6 +75,20 @@ public class OilInventoryOrderServiceImpl implements OilInventoryOrderService {
|
|||||||
return oilInventoryOrderDao.queryAllByLimit(page, oilInventoryOrder);
|
return oilInventoryOrderDao.queryAllByLimit(page, oilInventoryOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进货
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private OilPurchaseOrderService oilPurchaseOrderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 销售
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private OilOrderService oilOrderService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<OilInventoryOrderVO> getListPage(@Param("page") Page page, @Param("oilInventoryOrder") OilInventoryOrder oilInventoryOrder) {
|
public IPage<OilInventoryOrderVO> getListPage(@Param("page") Page page, @Param("oilInventoryOrder") OilInventoryOrder oilInventoryOrder) {
|
||||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||||
@ -84,6 +105,22 @@ public class OilInventoryOrderServiceImpl implements OilInventoryOrderService {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Date time = new Date();
|
||||||
|
// 获取进货数据
|
||||||
|
OilPurchaseOrder oilInletRecords = oilPurchaseOrderService.getOilInletRecords(record.getTankId());
|
||||||
|
if (!ObjectUtil.isEmpty(oilInletRecords)) {
|
||||||
|
time = oilInletRecords.getUpdateTime();
|
||||||
|
record.setTheTotalPurchasePrice(oilInletRecords.getTotalAmount().toString());
|
||||||
|
record.setTheAmountOfOilPurchased(oilInletRecords.getPurchaseVolume().toString());
|
||||||
|
record.setPurchaseUnitPrice(oilInletRecords.getDiscountedPrice().toString());
|
||||||
|
}
|
||||||
|
// 获取销售信息
|
||||||
|
OilOrderVo infoByTime = oilOrderService.getInfoByTime(time, record.getTankId());
|
||||||
|
if (!ObjectUtil.isEmpty(infoByTime)) {
|
||||||
|
record.setTotalOilVolumeSold(infoByTime.getOilNum().toString());
|
||||||
|
record.setTheTotalSalePrice(infoByTime.getPayAmount().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return listPage;
|
return listPage;
|
||||||
}
|
}
|
||||||
|
@ -213,13 +213,13 @@ public class OilPurchaseOrderServiceImpl implements OilPurchaseOrderService {
|
|||||||
List<OilPurchaseOrderVO> allList = oilPurchaseOrderDao.getAllList(oilPurchase);
|
List<OilPurchaseOrderVO> allList = oilPurchaseOrderDao.getAllList(oilPurchase);
|
||||||
for (OilPurchaseOrderVO oilPurchaseOrderVO : allList) {
|
for (OilPurchaseOrderVO oilPurchaseOrderVO : allList) {
|
||||||
|
|
||||||
oilTankService.addStoredQuantityByLock(oilPurchaseOrderVO.getTankId(),oilPurchaseOrderVO.getPurchaseVolume(),oilPurchaseOrderVO.getTotalAmount());
|
oilTankService.addStoredQuantityByLock(oilPurchaseOrderVO.getTankId(),oilPurchaseOrderVO.getPurchaseVolume(),oilPurchaseOrderVO.getTotalAmount(), oilPurchaseOrderVO.getProductDensity());
|
||||||
//
|
//
|
||||||
// OilTank oilTank = new OilTank();
|
// OilTank oilTank = new OilTank();
|
||||||
// oilTank.setId(oilPurchaseOrderVO.getTankId());
|
// oilTank.setId(oilPurchaseOrderVO.getTankId());
|
||||||
// oilTank.setStoredQuantity(oilPurchaseOrderVO.getPurchaseVolume());
|
// oilTank.setStoredQuantity(oilPurchaseOrderVO.getPurchaseVolume());
|
||||||
// oilTank.setTotalPrice(oilPurchaseOrderVO.getTotalAmount());
|
// oilTank.setTotalPrice(oilPurchaseOrderVO.getTotalAmount());
|
||||||
//// oilTank.setDiscountedPrice(oilPurchaseOrderVO.getDiscountedPrice());
|
// oilTank.setDiscountedPrice(oilPurchaseOrderVO.getDiscountedPrice());
|
||||||
//
|
//
|
||||||
// // 单价计算
|
// // 单价计算
|
||||||
// OilTank oilTankSum = oilTankMapper.queryById(oilPurchaseOrderVO.getTankId());
|
// OilTank oilTankSum = oilTankMapper.queryById(oilPurchaseOrderVO.getTankId());
|
||||||
@ -262,4 +262,9 @@ public class OilPurchaseOrderServiceImpl implements OilPurchaseOrderService {
|
|||||||
int update = oilPurchaseDao.update(oilPurchase);
|
int update = oilPurchaseDao.update(oilPurchase);
|
||||||
return update>0;
|
return update>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OilPurchaseOrder getOilInletRecords(Integer tankId) {
|
||||||
|
return oilPurchaseOrderDao.getOilInletRecords(tankId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,15 +137,14 @@ public class OilTankServiceImpl implements OilTankService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public OilTank addStoredQuantityByLock(Integer tankId, Double changeNum, Double totalAmount) {
|
public OilTank addStoredQuantityByLock(Integer tankId, Double changeNum, Double totalAmount, Double density) {
|
||||||
// 根据油罐id加锁 同一时间只能
|
// 根据油罐id加锁 同一时间只能
|
||||||
String lockKey = "oilTank-"+tankId;
|
String lockKey = "oilTank-"+tankId;
|
||||||
Boolean isLock = redisLock.tryLock(lockKey,500,5000, TimeUnit.MILLISECONDS);
|
Boolean isLock = redisLock.tryLock(lockKey,500,5000, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
if (isLock) {
|
if (isLock) {
|
||||||
OilTank oilTank = oilTankDao.queryById(tankId);
|
OilTank oilTank = oilTankDao.queryById(tankId);
|
||||||
// 计算总升数(相加)
|
// 计算总升数(相加) 判断容量是否足够
|
||||||
// BigDecimal tankVolumeBigDecimal = new BigDecimal(oilTank.getTankVolume().toString());
|
|
||||||
BigDecimal changeNumBigDecimal = new BigDecimal(changeNum.toString());
|
BigDecimal changeNumBigDecimal = new BigDecimal(changeNum.toString());
|
||||||
BigDecimal storedQuantityBigDecimal = changeNumBigDecimal.add(new BigDecimal(oilTank.getStoredQuantity().toString()));
|
BigDecimal storedQuantityBigDecimal = changeNumBigDecimal.add(new BigDecimal(oilTank.getStoredQuantity().toString()));
|
||||||
|
|
||||||
@ -153,12 +152,12 @@ public class OilTankServiceImpl implements OilTankService {
|
|||||||
redisLock.unlock(lockKey);
|
redisLock.unlock(lockKey);
|
||||||
throw new RuntimeException("“"+ oilTank.getTankName() +"”油罐中容量不足,无法进行增加!");
|
throw new RuntimeException("“"+ oilTank.getTankName() +"”油罐中容量不足,无法进行增加!");
|
||||||
}
|
}
|
||||||
|
// 计算折合单价
|
||||||
Double discountedPrice = null;
|
Double discountedPrice = null;
|
||||||
if (ObjectUtil.isNotEmpty(totalAmount)) {
|
if (ObjectUtil.isNotEmpty(totalAmount)) {
|
||||||
// 计算总价格
|
// 计算总价格
|
||||||
BigDecimal totalAmountBigDecimal = new BigDecimal(totalAmount.toString());
|
BigDecimal totalAmountBigDecimal = new BigDecimal(totalAmount.toString());
|
||||||
BigDecimal totalPriceBigDecimal = totalAmountBigDecimal.subtract(new BigDecimal(oilTank.getTotalPrice().toString()));
|
BigDecimal totalPriceBigDecimal = totalAmountBigDecimal.add(new BigDecimal(oilTank.getTotalPrice().toString()));
|
||||||
// 计算单价
|
// 计算单价
|
||||||
BigDecimal discountedPriceBigDecimal = totalPriceBigDecimal.divide(storedQuantityBigDecimal,2);
|
BigDecimal discountedPriceBigDecimal = totalPriceBigDecimal.divide(storedQuantityBigDecimal,2);
|
||||||
discountedPrice = Double.valueOf(discountedPriceBigDecimal.toString());
|
discountedPrice = Double.valueOf(discountedPriceBigDecimal.toString());
|
||||||
@ -169,7 +168,27 @@ public class OilTankServiceImpl implements OilTankService {
|
|||||||
discountedPrice = multiply.doubleValue();
|
discountedPrice = multiply.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.oilTankDao.addStoredQuantityByLock(tankId, changeNum, totalAmount, discountedPrice);
|
// 传入密度的话进行计算 密度相同则不需要计算
|
||||||
|
if (ObjectUtil.isNotEmpty(density) && !density.equals(oilTank.getOilDensity()) && oilTank.getOilDensity().compareTo(0.0)>0) {
|
||||||
|
// 计算重量g
|
||||||
|
BigDecimal nowWeight = changeNumBigDecimal.multiply(new BigDecimal(density.toString())).multiply(new BigDecimal("1000"));// 传入的重量
|
||||||
|
// 原有的重量
|
||||||
|
BigDecimal resWeight = storedQuantityBigDecimal.multiply(new BigDecimal(oilTank.getOilDensity().toString())).multiply(new BigDecimal("1000"));
|
||||||
|
// 总重量
|
||||||
|
BigDecimal sumWeight = nowWeight.add(resWeight);
|
||||||
|
// 总升数
|
||||||
|
BigDecimal sumDec = changeNumBigDecimal.add(storedQuantityBigDecimal);
|
||||||
|
// 计算密度
|
||||||
|
BigDecimal sumDensity = sumWeight.divide(sumDec.multiply(new BigDecimal("1000")),2);
|
||||||
|
|
||||||
|
oilTank.setOilDensity(Double.valueOf(sumDensity.toString()));
|
||||||
|
}
|
||||||
|
if ( oilTank.getOilDensity().compareTo(0.0)<=0 ) {
|
||||||
|
oilTank.setOilDensity(density);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
this.oilTankDao.addStoredQuantityByLock(tankId, changeNum, totalAmount, discountedPrice, oilTank.getOilDensity());
|
||||||
redisLock.unlock(lockKey);
|
redisLock.unlock(lockKey);
|
||||||
}
|
}
|
||||||
return this.queryById(tankId);
|
return this.queryById(tankId);
|
||||||
@ -208,7 +227,7 @@ public class OilTankServiceImpl implements OilTankService {
|
|||||||
// 单价*油量
|
// 单价*油量
|
||||||
BigDecimal disPrice = new BigDecimal(oilTank.getDiscountedPrice().toString());
|
BigDecimal disPrice = new BigDecimal(oilTank.getDiscountedPrice().toString());
|
||||||
BigDecimal multiply = disPrice.multiply(new BigDecimal(changeNum));
|
BigDecimal multiply = disPrice.multiply(new BigDecimal(changeNum));
|
||||||
return this.oilTankDao.addStoredQuantityByLock(tankId, changeNum, Double.valueOf(multiply.toString()),null) >0 ;
|
return this.oilTankDao.addStoredQuantityByLock(tankId, changeNum, Double.valueOf(multiply.toString()),null,null) >0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,8 +8,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class OilInventoryOrderVO extends OilInventoryOrder {
|
public class OilInventoryOrderVO extends OilInventoryOrder {
|
||||||
private String tankName;
|
|
||||||
private Integer tankId;
|
|
||||||
private String numberName;
|
private String numberName;
|
||||||
/**
|
/**
|
||||||
* 盘点单号
|
* 盘点单号
|
||||||
@ -20,4 +19,35 @@ public class OilInventoryOrderVO extends OilInventoryOrder {
|
|||||||
*/
|
*/
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||||
private Date inventoryTime;
|
private Date inventoryTime;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer oilNameId; // 油品id
|
||||||
|
private Integer numberId; // 油品id
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上次采购信息
|
||||||
|
*
|
||||||
|
* 上次采购总价,采购油量,采购单价;销售总油量 ,销售售出价,销售总价;当前剩余油量,当前剩余油量总价
|
||||||
|
*/
|
||||||
|
private String theTotalPurchasePrice;
|
||||||
|
private String theAmountOfOilPurchased;
|
||||||
|
private String purchaseUnitPrice;
|
||||||
|
/**
|
||||||
|
* 销售信息
|
||||||
|
*/
|
||||||
|
private String totalOilVolumeSold;
|
||||||
|
private String saleSellSellBid;
|
||||||
|
private String theTotalSalePrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 油罐信息
|
||||||
|
*/
|
||||||
|
private String tankName;
|
||||||
|
private Integer tankId;
|
||||||
|
|
||||||
|
private String storedQuantity;
|
||||||
|
private String totalPrice;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user