From fbaf417de9040ff0ef6ec36861295aecfd8654bf Mon Sep 17 00:00:00 2001 From: bai <1643359946@qq.com> Date: Thu, 13 Jun 2024 13:56:24 +0800 Subject: [PATCH] =?UTF-8?q?2024=E5=B9=B46=E6=9C=8813=E6=97=A5=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...erSelfGoodsEntryExitRecordsController.java | 33 -------- .../BlArtificerSelfGoodsEntryExitRecords.java | 6 +- ...ficerSelfGoodsEntryExitRecordsService.java | 8 +- .../service/BlArtificerSelfGoodsService.java | 48 ++++++++--- ...rSelfGoodsEntryExitRecordsServiceImpl.java | 20 ++--- .../impl/BlArtificerSelfGoodsServiceImpl.java | 81 ++++++++++++------- 6 files changed, 106 insertions(+), 90 deletions(-) diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsEntryExitRecordsController.java b/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsEntryExitRecordsController.java index 38da838..c6f4311 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsEntryExitRecordsController.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsEntryExitRecordsController.java @@ -48,43 +48,10 @@ public class BlArtificerSelfGoodsEntryExitRecordsController { return Result.success().put("data",pageList); } - @PostMapping(value = "/add") - @ApiOperation("新增") - public Result add(@RequestBody BlArtificerSelfGoodsEntryExitRecords entity){ - entity.setCreateTime(DateUtil.now()); - entity.setUpdateTime(DateUtil.now()); - return Result.success().put("data",service.save(entity)); - } - - @PostMapping(value = "/update") - @ApiOperation("修改") - public Result update(@RequestBody BlArtificerSelfGoodsEntryExitRecords entity){ - entity.setUpdateTime(DateUtil.now()); - return Result.success().put("data",service.updateById(entity)); - } - @RequestMapping("/info/{id}") public Result info(@PathVariable("id") Long id){ BlArtificerSelfGoodsEntryExitRecords data = service.getById(id); return Result.success().put("data", data); } - @DeleteMapping(value = "/deleteById") - @ApiOperation("删除") - public Result deleteById(Long id){ - service.removeById(id); - return Result.success(); - } - - @DeleteMapping(value = "/deleteByIds") - @ApiOperation("批量删除") - public Result deleteByIds(String id){ - if(StringUtils.isNotBlank(id)){ - String[] ids = StringUtils.split(id,","); - service.removeByIds(Arrays.asList(ids)); - } - return Result.success(); - } - - } \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/entity/BlArtificerSelfGoodsEntryExitRecords.java b/src/main/java/com/sqx/modules/artificerselfgoods/entity/BlArtificerSelfGoodsEntryExitRecords.java index c521529..5308f0e 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/entity/BlArtificerSelfGoodsEntryExitRecords.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/entity/BlArtificerSelfGoodsEntryExitRecords.java @@ -61,17 +61,17 @@ public class BlArtificerSelfGoodsEntryExitRecords implements Serializable { /** * 变更后库存量 */ - private Integer num; + private Integer afterTheChangeNum; /** * 变更前库存量 */ - private Integer lastTimeNum; + private Integer beforeTheChangeNum; /** * 本次变更量 */ - private Integer lastTimeChangeNum; + private Integer changeNum; /** * 操作类型(1:入库,2:出库,3:修改库) diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsEntryExitRecordsService.java b/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsEntryExitRecordsService.java index 0379b5e..075a150 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsEntryExitRecordsService.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsEntryExitRecordsService.java @@ -8,12 +8,12 @@ import java.math.BigDecimal; public interface BlArtificerSelfGoodsEntryExitRecordsService extends IService { - boolean addLog(BlArtificerSelfGoods e,Integer operationType, String createAt, Integer changeEndNum, Integer allNum, Integer num, BigDecimal purchasePrice, String userId, String remark); + boolean addLog(BlArtificerSelfGoods e,Integer operationType, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, BigDecimal purchasePrice, String userId, String remark); - boolean addInLog(BlArtificerSelfGoods e, String createAt, Integer changeEndNum, Integer allNum, Integer num, BigDecimal purchasePrice); + boolean addInLog(BlArtificerSelfGoods e, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, BigDecimal purchasePrice); - boolean addOutLog(BlArtificerSelfGoods e, String createAt, Integer changeEndNum, Integer allNum, Integer num, String userId); + boolean addOutLog(BlArtificerSelfGoods e, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, String userId); - boolean editLog(BlArtificerSelfGoods e, String createAt, Integer changeEndNum, Integer allNum, Integer num, String remark); + boolean editLog(BlArtificerSelfGoods e, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, String remark); } diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsService.java b/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsService.java index 99cac3a..239fa50 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsService.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsService.java @@ -31,54 +31,78 @@ public interface BlArtificerSelfGoodsService extends IService artificerSelfGoodsList); + + /** + * 新增库 + * @param artificerSelfGoods + * @return + */ boolean addWarehouse(BlArtificerSelfGoods artificerSelfGoods); + /** + * 批量新增库 + * @param artificerSelfGoodsList + * @return + */ boolean addWarehouse(List artificerSelfGoodsList); /** * 入库 * @param artificerSelfGoodsId - * @param num + * @param changeNum * @return */ - boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int num); + boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int changeNum); /** * 批量入库 - * @param artificerSelfGoods + * @param artificerSelfGoodsList * @return */ - boolean inWarehouse(List artificerSelfGoods); + boolean inWarehouse(List artificerSelfGoodsList); /** * 出库 * @param artificerSelfGoodsId - * @param num + * @param changeNum * @return */ - boolean outWarehouse(Long artificerSelfGoodsId, int num, String userId); + boolean outWarehouse(Long artificerSelfGoodsId, int changeNum, String userId); /** * 批量出库 - * @param artificerSelfGoods + * @param artificerSelfGoodsList * @return */ - boolean outWarehouse(List artificerSelfGoods); + boolean outWarehouse(List artificerSelfGoodsList); /** * 修改库 * @param artificerSelfGoodsId - * @param num + * @param changeNum * @return */ - boolean editWarehouse(Long artificerSelfGoodsId, int num, String remark); + boolean editWarehouse(Long artificerSelfGoodsId, int changeNum, String remark); /** * 批量修改库 - * @param artificerSelfGoods + * @param artificerSelfGoodsList * @return */ - boolean editWarehouse(List artificerSelfGoods); + boolean editWarehouse(List artificerSelfGoodsList); } diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsEntryExitRecordsServiceImpl.java b/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsEntryExitRecordsServiceImpl.java index 6f9499c..876017d 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsEntryExitRecordsServiceImpl.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsEntryExitRecordsServiceImpl.java @@ -18,7 +18,7 @@ import java.math.BigDecimal; public class BlArtificerSelfGoodsEntryExitRecordsServiceImpl extends ServiceImpl implements BlArtificerSelfGoodsEntryExitRecordsService { @Override - public boolean addLog(BlArtificerSelfGoods e,Integer operationType, String createAt, Integer changeEndNum, Integer allNum, Integer num, BigDecimal purchasePrice, String userId, String remark) { + public boolean addLog(BlArtificerSelfGoods e,Integer operationType, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, BigDecimal purchasePrice, String userId, String remark) { BlArtificerSelfGoodsEntryExitRecords log = new BlArtificerSelfGoodsEntryExitRecords(); log.setCreateTime(DateUtil.now()); log.setCreateAt(createAt); @@ -27,9 +27,9 @@ public class BlArtificerSelfGoodsEntryExitRecordsServiceImpl extends ServiceImpl log.setSelfGoodsTypeId(e.getSelfGoodsTypeId()); log.setSelfGoodsTypeParentId(e.getSelfGoodsTypeParentId()); log.setArtificerId(e.getArtificerId()); - log.setNum(changeEndNum); - log.setLastTimeNum(allNum); - log.setLastTimeChangeNum(num); + log.setAfterTheChangeNum(afterTheChangeNum); + log.setBeforeTheChangeNum(beforeTheChangeNum); + log.setChangeNum(changeNum); log.setOperationType(operationType); log.setPurchasePrice(purchasePrice); log.setUserId(userId); @@ -40,20 +40,20 @@ public class BlArtificerSelfGoodsEntryExitRecordsServiceImpl extends ServiceImpl } @Override - public boolean addInLog(BlArtificerSelfGoods e, String createAt, Integer changeEndNum, Integer allNum, Integer num, BigDecimal purchasePrice) { - addLog(e, ArtificerSelfGoodsEnum.OperationType.IN.getValue(), createAt, changeEndNum, allNum, num, purchasePrice, null, null); + public boolean addInLog(BlArtificerSelfGoods e, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, BigDecimal purchasePrice) { + addLog(e, ArtificerSelfGoodsEnum.OperationType.IN.getValue(), createAt, afterTheChangeNum, beforeTheChangeNum, changeNum, purchasePrice, null, null); return true; } @Override - public boolean addOutLog(BlArtificerSelfGoods e, String createAt, Integer changeEndNum, Integer allNum, Integer num, String userId) { - addLog(e, ArtificerSelfGoodsEnum.OperationType.OUT.getValue(), createAt, changeEndNum, allNum, num, null, userId, null); + public boolean addOutLog(BlArtificerSelfGoods e, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, String userId) { + addLog(e, ArtificerSelfGoodsEnum.OperationType.OUT.getValue(), createAt, afterTheChangeNum, beforeTheChangeNum, changeNum, null, userId, null); return true; } @Override - public boolean editLog(BlArtificerSelfGoods e, String createAt, Integer changeEndNum, Integer allNum, Integer num, String remark) { - addLog(e, ArtificerSelfGoodsEnum.OperationType.EDIT.getValue(), createAt, changeEndNum, allNum, num, null, null, remark); + public boolean editLog(BlArtificerSelfGoods e, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, String remark) { + addLog(e, ArtificerSelfGoodsEnum.OperationType.EDIT.getValue(), createAt, afterTheChangeNum, beforeTheChangeNum, changeNum, null, null, remark); return true; } } diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsServiceImpl.java b/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsServiceImpl.java index ea78848..563cf36 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsServiceImpl.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsServiceImpl.java @@ -1,15 +1,15 @@ package com.sqx.modules.artificerselfgoods.service.impl; -import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.sqx.modules.artificerselfgoods.dao.BlArtificerSelfGoodsDao; import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoods; -import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoodsEntryExitRecords; -import com.sqx.modules.artificerselfgoods.enums.ArtificerSelfGoodsEnum; import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsEntryExitRecordsService; import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService; +import com.sqx.modules.sys.entity.SysUserEntity; +import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import java.math.BigDecimal; @@ -21,9 +21,17 @@ import java.util.List; @Service public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl implements BlArtificerSelfGoodsService { + @Lazy + @Autowired + private BlArtificerSelfGoodsService artificerSelfGoodsService; + @Autowired private BlArtificerSelfGoodsEntryExitRecordsService artificerSelfGoodsEntryExitRecordsService; + private SysUserEntity getUser() { + return ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()); + } + @Override public List findArtificerSelfGoodsByArtificerId(String artificerId) { QueryWrapper qw = new QueryWrapper<>(); @@ -48,6 +56,23 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl artificerSelfGoodsList) { + artificerSelfGoodsList.forEach(this::addOrInWarehouse); + return true; + } + + @Override public boolean addWarehouse(BlArtificerSelfGoods artificerSelfGoods) { save(artificerSelfGoods); @@ -56,70 +81,70 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl artificerSelfGoodsList) { - saveBatch(artificerSelfGoodsList); + artificerSelfGoodsService.saveBatch(artificerSelfGoodsList); return true; } @Override - public boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int num) { + public boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int changeNum) { BlArtificerSelfGoods e = getById(artificerSelfGoodsId); if(e == null) return false; - Integer allNum = e.getNum(); - e.setLastTimeChangeNum(num); + Integer afterTheChangeNum = e.getNum(); + e.setLastTimeChangeNum(changeNum); e.setLastTimeNum(e.getNum()); - Integer changeEndNum = allNum - num; - e.setNum(changeEndNum); + Integer beforeTheChangeNum = afterTheChangeNum - changeNum; + e.setNum(beforeTheChangeNum); updateById(e); //记录日志 - artificerSelfGoodsEntryExitRecordsService.addInLog(e, null, changeEndNum, allNum, num, purchasePrice); + artificerSelfGoodsEntryExitRecordsService.addInLog(e, null, afterTheChangeNum, beforeTheChangeNum, changeNum, purchasePrice); return true; } @Override - public boolean inWarehouse(List artificerSelfGoods) { - artificerSelfGoods.forEach(x -> inWarehouse(x.getId(), x.getPurchasePrice(), x.getChangeNum())); + public boolean inWarehouse(List artificerSelfGoodsList) { + artificerSelfGoodsList.forEach(x -> inWarehouse(x.getId(), x.getPurchasePrice(), x.getChangeNum())); return true; } @Override - public boolean outWarehouse(Long artificerSelfGoodsId, int num, String userId) { + public boolean outWarehouse(Long artificerSelfGoodsId, int changeNum, String userId) { BlArtificerSelfGoods e = getById(artificerSelfGoodsId); if(e == null) return false; - Integer allNum = e.getNum(); - e.setLastTimeChangeNum(num); + Integer afterTheChangeNum = e.getNum(); + e.setLastTimeChangeNum(changeNum); e.setLastTimeNum(e.getNum()); - Integer changeEndNum = allNum - num; - e.setNum(changeEndNum); + Integer beforeTheChangeNum = afterTheChangeNum - changeNum; + e.setNum(beforeTheChangeNum); updateById(e); //记录日志 - artificerSelfGoodsEntryExitRecordsService.addOutLog(e, null, changeEndNum, allNum, num, userId); + artificerSelfGoodsEntryExitRecordsService.addOutLog(e, null, afterTheChangeNum, beforeTheChangeNum, changeNum, userId); return true; } @Override - public boolean outWarehouse(List artificerSelfGoods) { - artificerSelfGoods.forEach(x -> outWarehouse(x.getId(), x.getChangeNum(), x.getUserId())); + public boolean outWarehouse(List artificerSelfGoodsList) { + artificerSelfGoodsList.forEach(x -> outWarehouse(x.getId(), x.getChangeNum(), x.getUserId())); return true; } @Override - public boolean editWarehouse(Long artificerSelfGoodsId, int num, String remark) { + public boolean editWarehouse(Long artificerSelfGoodsId, int changeNum, String remark) { BlArtificerSelfGoods e = getById(artificerSelfGoodsId); if(e == null) return false; - Integer allNum = e.getNum(); - e.setLastTimeChangeNum(num); + Integer afterTheChangeNum = e.getNum(); + e.setLastTimeChangeNum(changeNum); e.setLastTimeNum(e.getNum()); - Integer changeEndNum = allNum - num; - e.setNum(changeEndNum); + Integer beforeTheChangeNum = afterTheChangeNum - changeNum; + e.setNum(beforeTheChangeNum); updateById(e); //记录日志 - artificerSelfGoodsEntryExitRecordsService.editLog(e, null, changeEndNum, allNum, num, remark); + artificerSelfGoodsEntryExitRecordsService.editLog(e, null, afterTheChangeNum, beforeTheChangeNum, changeNum, remark); return true; } @Override - public boolean editWarehouse(List artificerSelfGoods) { - artificerSelfGoods.forEach(x -> editWarehouse(x.getId(), x.getChangeNum(), x.getRemark())); + public boolean editWarehouse(List artificerSelfGoodsList) { + artificerSelfGoodsList.forEach(x -> editWarehouse(x.getId(), x.getChangeNum(), x.getRemark())); return true; } }