|
@@ -0,0 +1,204 @@
|
|
|
+package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
+import com.baomidou.mybatisplus.plugins.Page;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.yh.saas.common.support.util.IdGenerator;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.SpeedExpenseInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.SpeedGoodsInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.SpeedPositionInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.SpeedWarehouseInOutInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.mapper.SpeedWarehouseInOutInfoMapper;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.*;
|
|
|
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 记录极速版出入库信息 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author Gdc
|
|
|
+ * @since 2023-03-27
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehouseInOutInfoMapper, SpeedWarehouseInOutInfo> implements ISpeedWarehouseInOutInfoService {
|
|
|
+ @Autowired
|
|
|
+ private ISpeedPositionInfoService speedPositionInfoService;
|
|
|
+ @Autowired
|
|
|
+ private ISpeedGoodsInfoService speedGoodsInfoService;
|
|
|
+ @Override
|
|
|
+ public Page<SpeedWarehouseInOutInfo> selectInfo(SpeedWarehouseInOutInfo speedWarehouseInOutInfo) {
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
+ pageView.put("startRecord", (speedWarehouseInOutInfo.getCurrentPage() - 1)
|
|
|
+ * speedWarehouseInOutInfo.getPageSize());
|
|
|
+ //公司id
|
|
|
+ pageView.put("compId", speedWarehouseInOutInfo.getCompId());
|
|
|
+ pageView.put("searchKeyWord", speedWarehouseInOutInfo.getSearchKeyWord());
|
|
|
+ pageView.put("searchType", speedWarehouseInOutInfo.getSearchType());
|
|
|
+ pageView.put("status", speedWarehouseInOutInfo.getStatus());
|
|
|
+ pageView.put("startDate", speedWarehouseInOutInfo.getStartDate());
|
|
|
+ pageView.put("endDate", speedWarehouseInOutInfo.getEndDate());
|
|
|
+ pageView.put("pageSize", speedWarehouseInOutInfo.getPageSize());
|
|
|
+ pageView.put("currentPage", speedWarehouseInOutInfo.getCurrentPage());
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
+ List<SpeedWarehouseInOutInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
|
+ Page<SpeedWarehouseInOutInfo> page = new Page<>();
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
+ page.setCurrent(speedWarehouseInOutInfo.getCurrentPage());
|
|
|
+ page.setSize(speedWarehouseInOutInfo.getPageSize());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String addInfo(SpeedWarehouseInOutInfo speedWarehouseInOutInfo) {
|
|
|
+ // 根据传参id判断是否是新增
|
|
|
+ // 空是新增
|
|
|
+ if (StringUtils.isEmpty(speedWarehouseInOutInfo.getId())) {
|
|
|
+ speedWarehouseInOutInfo.setId(IdGenerator.generateUUID());
|
|
|
+ //出库
|
|
|
+ if ("1".equals(speedWarehouseInOutInfo.getInOutFlag())) {
|
|
|
+ //默认未收
|
|
|
+ speedWarehouseInOutInfo.setStatusFlag(StatusEnum.UNCOLLECTED.getFlag());
|
|
|
+ speedWarehouseInOutInfo.setStatus(StatusEnum.UNCOLLECTED.getName());
|
|
|
+ //净重不为空,操作库存
|
|
|
+ if (speedWarehouseInOutInfo.getNetWeight()!=null){
|
|
|
+ SpeedPositionInfo speedPositionInfo=speedPositionInfoService.selectById(speedWarehouseInOutInfo.getPositionId());
|
|
|
+ if (speedPositionInfo!=null){
|
|
|
+ speedPositionInfo.setStorage(speedPositionInfo.getStorage()-speedWarehouseInOutInfo.getNetWeight());
|
|
|
+ speedPositionInfoService.updateById(speedPositionInfo);
|
|
|
+ }
|
|
|
+ SpeedGoodsInfo speedGoodsInfo=speedGoodsInfoService.selectOne(new EntityWrapper<SpeedGoodsInfo>()
|
|
|
+ .eq("comp_id",speedWarehouseInOutInfo.getCompId())
|
|
|
+ .eq("goods_name",speedWarehouseInOutInfo.getGoodsName()));
|
|
|
+ if (speedGoodsInfo!=null){
|
|
|
+ speedGoodsInfo.setStorage(speedGoodsInfo.getStorage()-speedWarehouseInOutInfo.getNetWeight());
|
|
|
+ speedGoodsInfoService.updateById(speedGoodsInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //入库
|
|
|
+ else {
|
|
|
+ //默认未付
|
|
|
+ speedWarehouseInOutInfo.setStatusFlag(StatusEnum.PAY_WAIT.getFlag());
|
|
|
+ speedWarehouseInOutInfo.setStatus(StatusEnum.PAY_WAIT.getName());
|
|
|
+ //净重不为空,操作库存
|
|
|
+ if (speedWarehouseInOutInfo.getNetWeight()!=null){
|
|
|
+ SpeedPositionInfo speedPositionInfo=speedPositionInfoService.selectById(speedWarehouseInOutInfo.getPositionId());
|
|
|
+ if (speedPositionInfo!=null){
|
|
|
+ speedPositionInfo.setStorage(speedPositionInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight());
|
|
|
+ speedPositionInfoService.updateById(speedPositionInfo);
|
|
|
+ }
|
|
|
+ SpeedGoodsInfo speedGoodsInfo=speedGoodsInfoService.selectOne(new EntityWrapper<SpeedGoodsInfo>()
|
|
|
+ .eq("comp_id",speedWarehouseInOutInfo.getCompId())
|
|
|
+ .eq("goods_name",speedWarehouseInOutInfo.getGoodsName()));
|
|
|
+ if (speedGoodsInfo!=null){
|
|
|
+ speedGoodsInfo.setStorage(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight());
|
|
|
+ speedGoodsInfoService.updateById(speedGoodsInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.insert(speedWarehouseInOutInfo);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //出库
|
|
|
+ if ("1".equals(speedWarehouseInOutInfo.getInOutFlag())) {
|
|
|
+ //净重不为空,操作库存
|
|
|
+ if (speedWarehouseInOutInfo.getNetWeight()!=null){
|
|
|
+ //取原净重
|
|
|
+ SpeedWarehouseInOutInfo speedWarehouseInOutInfo1=this.selectById(speedWarehouseInOutInfo.getId());
|
|
|
+ SpeedPositionInfo speedPositionInfo=speedPositionInfoService.selectById(speedWarehouseInOutInfo.getPositionId());
|
|
|
+ if (speedPositionInfo!=null){
|
|
|
+ //加上原净重再减去新净重
|
|
|
+ speedPositionInfo.setStorage(speedPositionInfo.getStorage()+speedWarehouseInOutInfo1.getNetWeight()-speedWarehouseInOutInfo.getNetWeight());
|
|
|
+ speedPositionInfoService.updateById(speedPositionInfo);
|
|
|
+ }
|
|
|
+ SpeedGoodsInfo speedGoodsInfo=speedGoodsInfoService.selectOne(new EntityWrapper<SpeedGoodsInfo>()
|
|
|
+ .eq("comp_id",speedWarehouseInOutInfo.getCompId())
|
|
|
+ .eq("goods_name",speedWarehouseInOutInfo.getGoodsName()));
|
|
|
+ if (speedGoodsInfo!=null){
|
|
|
+ //加上原净重再减去新净重
|
|
|
+ speedGoodsInfo.setStorage(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo1.getNetWeight()-speedWarehouseInOutInfo.getNetWeight());
|
|
|
+ speedGoodsInfoService.updateById(speedGoodsInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //入库
|
|
|
+ else {
|
|
|
+ //净重不为空,操作库存
|
|
|
+ if (speedWarehouseInOutInfo.getNetWeight()!=null){
|
|
|
+ //取原净重
|
|
|
+ SpeedWarehouseInOutInfo speedWarehouseInOutInfo1=this.selectById(speedWarehouseInOutInfo.getId());
|
|
|
+ SpeedPositionInfo speedPositionInfo=speedPositionInfoService.selectById(speedWarehouseInOutInfo.getPositionId());
|
|
|
+ if (speedPositionInfo!=null){
|
|
|
+ //减去原净重再加上新净重
|
|
|
+ speedPositionInfo.setStorage(speedPositionInfo.getStorage()-speedWarehouseInOutInfo1.getNetWeight()+speedWarehouseInOutInfo.getNetWeight());
|
|
|
+ speedPositionInfoService.updateById(speedPositionInfo);
|
|
|
+ }
|
|
|
+ SpeedGoodsInfo speedGoodsInfo=speedGoodsInfoService.selectOne(new EntityWrapper<SpeedGoodsInfo>()
|
|
|
+ .eq("comp_id",speedWarehouseInOutInfo.getCompId())
|
|
|
+ .eq("goods_name",speedWarehouseInOutInfo.getGoodsName()));
|
|
|
+ if (speedGoodsInfo!=null){
|
|
|
+ //减去原净重再加上新净重
|
|
|
+ speedGoodsInfo.setStorage(speedGoodsInfo.getStorage()-speedWarehouseInOutInfo1.getNetWeight()+speedWarehouseInOutInfo.getNetWeight());
|
|
|
+ speedGoodsInfoService.updateById(speedGoodsInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deleteInfo(String id) {
|
|
|
+ SpeedWarehouseInOutInfo speedWarehouseInOutInfo = this.selectById(id);
|
|
|
+ this.deleteById(speedWarehouseInOutInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String editInfo(SpeedWarehouseInOutInfo speedWarehouseInOutInfo) {
|
|
|
+ //付款
|
|
|
+ if ("1".equals(speedWarehouseInOutInfo.getFlag())){
|
|
|
+ speedWarehouseInOutInfo.setStatusFlag(StatusEnum.PAYED.getFlag());
|
|
|
+ speedWarehouseInOutInfo.setStatus(StatusEnum.PAYED.getName());
|
|
|
+ }
|
|
|
+ //收款
|
|
|
+ else if ("2".equals(speedWarehouseInOutInfo.getFlag())){
|
|
|
+ speedWarehouseInOutInfo.setStatusFlag(StatusEnum.COLLECTED.getFlag());
|
|
|
+ speedWarehouseInOutInfo.setStatus(StatusEnum.COLLECTED.getName());
|
|
|
+ }
|
|
|
+ //批量付款
|
|
|
+ else if ("3".equals(speedWarehouseInOutInfo.getFlag())){
|
|
|
+ List<SpeedWarehouseInOutInfo> speedWarehouseInOutInfoList=speedWarehouseInOutInfo.getSpeedWarehouseInOutInfoList();
|
|
|
+ if (!CollectionUtils.isEmpty(speedWarehouseInOutInfoList)){
|
|
|
+ for (SpeedWarehouseInOutInfo speedWarehouseInOutInfo1:speedWarehouseInOutInfoList){
|
|
|
+ speedWarehouseInOutInfo.setStatusFlag(StatusEnum.PAYED.getFlag());
|
|
|
+ speedWarehouseInOutInfo.setStatus(StatusEnum.PAYED.getName());
|
|
|
+ this.updateById(speedWarehouseInOutInfo1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //批量收款
|
|
|
+ else if ("4".equals(speedWarehouseInOutInfo.getFlag())){
|
|
|
+ List<SpeedWarehouseInOutInfo> speedWarehouseInOutInfoList=speedWarehouseInOutInfo.getSpeedWarehouseInOutInfoList();
|
|
|
+ if (!CollectionUtils.isEmpty(speedWarehouseInOutInfoList)){
|
|
|
+ for (SpeedWarehouseInOutInfo speedWarehouseInOutInfo1:speedWarehouseInOutInfoList){
|
|
|
+ speedWarehouseInOutInfo.setStatusFlag(StatusEnum.COLLECTED.getFlag());
|
|
|
+ speedWarehouseInOutInfo.setStatus(StatusEnum.COLLECTED.getName());
|
|
|
+ this.updateById(speedWarehouseInOutInfo1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.updateById(speedWarehouseInOutInfo);
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+}
|