2024年6月13日 修复问题

This commit is contained in:
bai 2024-06-13 13:56:24 +08:00
parent 1fb4bdeb4f
commit fbaf417de9
6 changed files with 106 additions and 90 deletions

View File

@ -48,43 +48,10 @@ public class BlArtificerSelfGoodsEntryExitRecordsController {
return Result.success().put("data",pageList); 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}") @RequestMapping("/info/{id}")
public Result info(@PathVariable("id") Long id){ public Result info(@PathVariable("id") Long id){
BlArtificerSelfGoodsEntryExitRecords data = service.getById(id); BlArtificerSelfGoodsEntryExitRecords data = service.getById(id);
return Result.success().put("data", data); 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();
}
} }

View File

@ -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:修改库) * 操作类型(1:入库,2:出库,3:修改库)

View File

@ -8,12 +8,12 @@ import java.math.BigDecimal;
public interface BlArtificerSelfGoodsEntryExitRecordsService extends IService<BlArtificerSelfGoodsEntryExitRecords> { public interface BlArtificerSelfGoodsEntryExitRecordsService extends IService<BlArtificerSelfGoodsEntryExitRecords> {
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);
} }

View File

@ -31,54 +31,78 @@ public interface BlArtificerSelfGoodsService extends IService<BlArtificerSelfGoo
*/ */
BlArtificerSelfGoods findArtificerSelfGoodsByArtificerIdAndGoodsId(String artificerId, String goodsId); BlArtificerSelfGoods findArtificerSelfGoodsByArtificerIdAndGoodsId(String artificerId, String goodsId);
/**
* 新增或入库
* @param artificerSelfGoods
* @return
*/
boolean addOrInWarehouse(BlArtificerSelfGoods artificerSelfGoods);
/**
* 批量新增或入库
* @param artificerSelfGoodsList
* @return
*/
boolean addOrInWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList);
/**
* 新增库
* @param artificerSelfGoods
* @return
*/
boolean addWarehouse(BlArtificerSelfGoods artificerSelfGoods); boolean addWarehouse(BlArtificerSelfGoods artificerSelfGoods);
/**
* 批量新增库
* @param artificerSelfGoodsList
* @return
*/
boolean addWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList); boolean addWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList);
/** /**
* 入库 * 入库
* @param artificerSelfGoodsId * @param artificerSelfGoodsId
* @param num * @param changeNum
* @return * @return
*/ */
boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int num); boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int changeNum);
/** /**
* 批量入库 * 批量入库
* @param artificerSelfGoods * @param artificerSelfGoodsList
* @return * @return
*/ */
boolean inWarehouse(List<BlArtificerSelfGoods> artificerSelfGoods); boolean inWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList);
/** /**
* 出库 * 出库
* @param artificerSelfGoodsId * @param artificerSelfGoodsId
* @param num * @param changeNum
* @return * @return
*/ */
boolean outWarehouse(Long artificerSelfGoodsId, int num, String userId); boolean outWarehouse(Long artificerSelfGoodsId, int changeNum, String userId);
/** /**
* 批量出库 * 批量出库
* @param artificerSelfGoods * @param artificerSelfGoodsList
* @return * @return
*/ */
boolean outWarehouse(List<BlArtificerSelfGoods> artificerSelfGoods); boolean outWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList);
/** /**
* 修改库 * 修改库
* @param artificerSelfGoodsId * @param artificerSelfGoodsId
* @param num * @param changeNum
* @return * @return
*/ */
boolean editWarehouse(Long artificerSelfGoodsId, int num, String remark); boolean editWarehouse(Long artificerSelfGoodsId, int changeNum, String remark);
/** /**
* 批量修改库 * 批量修改库
* @param artificerSelfGoods * @param artificerSelfGoodsList
* @return * @return
*/ */
boolean editWarehouse(List<BlArtificerSelfGoods> artificerSelfGoods); boolean editWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList);
} }

View File

@ -18,7 +18,7 @@ import java.math.BigDecimal;
public class BlArtificerSelfGoodsEntryExitRecordsServiceImpl extends ServiceImpl<BlArtificerSelfGoodsEntryExitRecordsDao, BlArtificerSelfGoodsEntryExitRecords> implements BlArtificerSelfGoodsEntryExitRecordsService { public class BlArtificerSelfGoodsEntryExitRecordsServiceImpl extends ServiceImpl<BlArtificerSelfGoodsEntryExitRecordsDao, BlArtificerSelfGoodsEntryExitRecords> implements BlArtificerSelfGoodsEntryExitRecordsService {
@Override @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(); BlArtificerSelfGoodsEntryExitRecords log = new BlArtificerSelfGoodsEntryExitRecords();
log.setCreateTime(DateUtil.now()); log.setCreateTime(DateUtil.now());
log.setCreateAt(createAt); log.setCreateAt(createAt);
@ -27,9 +27,9 @@ public class BlArtificerSelfGoodsEntryExitRecordsServiceImpl extends ServiceImpl
log.setSelfGoodsTypeId(e.getSelfGoodsTypeId()); log.setSelfGoodsTypeId(e.getSelfGoodsTypeId());
log.setSelfGoodsTypeParentId(e.getSelfGoodsTypeParentId()); log.setSelfGoodsTypeParentId(e.getSelfGoodsTypeParentId());
log.setArtificerId(e.getArtificerId()); log.setArtificerId(e.getArtificerId());
log.setNum(changeEndNum); log.setAfterTheChangeNum(afterTheChangeNum);
log.setLastTimeNum(allNum); log.setBeforeTheChangeNum(beforeTheChangeNum);
log.setLastTimeChangeNum(num); log.setChangeNum(changeNum);
log.setOperationType(operationType); log.setOperationType(operationType);
log.setPurchasePrice(purchasePrice); log.setPurchasePrice(purchasePrice);
log.setUserId(userId); log.setUserId(userId);
@ -40,20 +40,20 @@ public class BlArtificerSelfGoodsEntryExitRecordsServiceImpl extends ServiceImpl
} }
@Override @Override
public boolean addInLog(BlArtificerSelfGoods e, String createAt, Integer changeEndNum, Integer allNum, Integer num, BigDecimal purchasePrice) { public boolean addInLog(BlArtificerSelfGoods e, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, BigDecimal purchasePrice) {
addLog(e, ArtificerSelfGoodsEnum.OperationType.IN.getValue(), createAt, changeEndNum, allNum, num, purchasePrice, null, null); addLog(e, ArtificerSelfGoodsEnum.OperationType.IN.getValue(), createAt, afterTheChangeNum, beforeTheChangeNum, changeNum, purchasePrice, null, null);
return true; return true;
} }
@Override @Override
public boolean addOutLog(BlArtificerSelfGoods e, String createAt, Integer changeEndNum, Integer allNum, Integer num, String userId) { public boolean addOutLog(BlArtificerSelfGoods e, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, String userId) {
addLog(e, ArtificerSelfGoodsEnum.OperationType.OUT.getValue(), createAt, changeEndNum, allNum, num, null, userId, null); addLog(e, ArtificerSelfGoodsEnum.OperationType.OUT.getValue(), createAt, afterTheChangeNum, beforeTheChangeNum, changeNum, null, userId, null);
return true; return true;
} }
@Override @Override
public boolean editLog(BlArtificerSelfGoods e, String createAt, Integer changeEndNum, Integer allNum, Integer num, String remark) { public boolean editLog(BlArtificerSelfGoods e, String createAt, Integer afterTheChangeNum, Integer beforeTheChangeNum, Integer changeNum, String remark) {
addLog(e, ArtificerSelfGoodsEnum.OperationType.EDIT.getValue(), createAt, changeEndNum, allNum, num, null, null, remark); addLog(e, ArtificerSelfGoodsEnum.OperationType.EDIT.getValue(), createAt, afterTheChangeNum, beforeTheChangeNum, changeNum, null, null, remark);
return true; return true;
} }
} }

View File

@ -1,15 +1,15 @@
package com.sqx.modules.artificerselfgoods.service.impl; 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.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.modules.artificerselfgoods.dao.BlArtificerSelfGoodsDao; import com.sqx.modules.artificerselfgoods.dao.BlArtificerSelfGoodsDao;
import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoods; 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.BlArtificerSelfGoodsEntryExitRecordsService;
import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService; 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.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -21,9 +21,17 @@ import java.util.List;
@Service @Service
public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelfGoodsDao, BlArtificerSelfGoods> implements BlArtificerSelfGoodsService { public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelfGoodsDao, BlArtificerSelfGoods> implements BlArtificerSelfGoodsService {
@Lazy
@Autowired
private BlArtificerSelfGoodsService artificerSelfGoodsService;
@Autowired @Autowired
private BlArtificerSelfGoodsEntryExitRecordsService artificerSelfGoodsEntryExitRecordsService; private BlArtificerSelfGoodsEntryExitRecordsService artificerSelfGoodsEntryExitRecordsService;
private SysUserEntity getUser() {
return ((SysUserEntity) SecurityUtils.getSubject().getPrincipal());
}
@Override @Override
public List<BlArtificerSelfGoods> findArtificerSelfGoodsByArtificerId(String artificerId) { public List<BlArtificerSelfGoods> findArtificerSelfGoodsByArtificerId(String artificerId) {
QueryWrapper<BlArtificerSelfGoods> qw = new QueryWrapper<>(); QueryWrapper<BlArtificerSelfGoods> qw = new QueryWrapper<>();
@ -48,6 +56,23 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelf
return getOne(qw); return getOne(qw);
} }
@Override
public boolean addOrInWarehouse(BlArtificerSelfGoods artificerSelfGoods) {
if(artificerSelfGoods.getId() == null){
addWarehouse(artificerSelfGoods);
} else {
inWarehouse(artificerSelfGoods.getId(),artificerSelfGoods.getPurchasePrice(), artificerSelfGoods.getChangeNum());
}
return true;
}
@Override
public boolean addOrInWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
artificerSelfGoodsList.forEach(this::addOrInWarehouse);
return true;
}
@Override @Override
public boolean addWarehouse(BlArtificerSelfGoods artificerSelfGoods) { public boolean addWarehouse(BlArtificerSelfGoods artificerSelfGoods) {
save(artificerSelfGoods); save(artificerSelfGoods);
@ -56,70 +81,70 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelf
@Override @Override
public boolean addWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) { public boolean addWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
saveBatch(artificerSelfGoodsList); artificerSelfGoodsService.saveBatch(artificerSelfGoodsList);
return true; return true;
} }
@Override @Override
public boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int num) { public boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int changeNum) {
BlArtificerSelfGoods e = getById(artificerSelfGoodsId); BlArtificerSelfGoods e = getById(artificerSelfGoodsId);
if(e == null) return false; if(e == null) return false;
Integer allNum = e.getNum(); Integer afterTheChangeNum = e.getNum();
e.setLastTimeChangeNum(num); e.setLastTimeChangeNum(changeNum);
e.setLastTimeNum(e.getNum()); e.setLastTimeNum(e.getNum());
Integer changeEndNum = allNum - num; Integer beforeTheChangeNum = afterTheChangeNum - changeNum;
e.setNum(changeEndNum); e.setNum(beforeTheChangeNum);
updateById(e); updateById(e);
//记录日志 //记录日志
artificerSelfGoodsEntryExitRecordsService.addInLog(e, null, changeEndNum, allNum, num, purchasePrice); artificerSelfGoodsEntryExitRecordsService.addInLog(e, null, afterTheChangeNum, beforeTheChangeNum, changeNum, purchasePrice);
return true; return true;
} }
@Override @Override
public boolean inWarehouse(List<BlArtificerSelfGoods> artificerSelfGoods) { public boolean inWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
artificerSelfGoods.forEach(x -> inWarehouse(x.getId(), x.getPurchasePrice(), x.getChangeNum())); artificerSelfGoodsList.forEach(x -> inWarehouse(x.getId(), x.getPurchasePrice(), x.getChangeNum()));
return true; return true;
} }
@Override @Override
public boolean outWarehouse(Long artificerSelfGoodsId, int num, String userId) { public boolean outWarehouse(Long artificerSelfGoodsId, int changeNum, String userId) {
BlArtificerSelfGoods e = getById(artificerSelfGoodsId); BlArtificerSelfGoods e = getById(artificerSelfGoodsId);
if(e == null) return false; if(e == null) return false;
Integer allNum = e.getNum(); Integer afterTheChangeNum = e.getNum();
e.setLastTimeChangeNum(num); e.setLastTimeChangeNum(changeNum);
e.setLastTimeNum(e.getNum()); e.setLastTimeNum(e.getNum());
Integer changeEndNum = allNum - num; Integer beforeTheChangeNum = afterTheChangeNum - changeNum;
e.setNum(changeEndNum); e.setNum(beforeTheChangeNum);
updateById(e); updateById(e);
//记录日志 //记录日志
artificerSelfGoodsEntryExitRecordsService.addOutLog(e, null, changeEndNum, allNum, num, userId); artificerSelfGoodsEntryExitRecordsService.addOutLog(e, null, afterTheChangeNum, beforeTheChangeNum, changeNum, userId);
return true; return true;
} }
@Override @Override
public boolean outWarehouse(List<BlArtificerSelfGoods> artificerSelfGoods) { public boolean outWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
artificerSelfGoods.forEach(x -> outWarehouse(x.getId(), x.getChangeNum(), x.getUserId())); artificerSelfGoodsList.forEach(x -> outWarehouse(x.getId(), x.getChangeNum(), x.getUserId()));
return true; return true;
} }
@Override @Override
public boolean editWarehouse(Long artificerSelfGoodsId, int num, String remark) { public boolean editWarehouse(Long artificerSelfGoodsId, int changeNum, String remark) {
BlArtificerSelfGoods e = getById(artificerSelfGoodsId); BlArtificerSelfGoods e = getById(artificerSelfGoodsId);
if(e == null) return false; if(e == null) return false;
Integer allNum = e.getNum(); Integer afterTheChangeNum = e.getNum();
e.setLastTimeChangeNum(num); e.setLastTimeChangeNum(changeNum);
e.setLastTimeNum(e.getNum()); e.setLastTimeNum(e.getNum());
Integer changeEndNum = allNum - num; Integer beforeTheChangeNum = afterTheChangeNum - changeNum;
e.setNum(changeEndNum); e.setNum(beforeTheChangeNum);
updateById(e); updateById(e);
//记录日志 //记录日志
artificerSelfGoodsEntryExitRecordsService.editLog(e, null, changeEndNum, allNum, num, remark); artificerSelfGoodsEntryExitRecordsService.editLog(e, null, afterTheChangeNum, beforeTheChangeNum, changeNum, remark);
return true; return true;
} }
@Override @Override
public boolean editWarehouse(List<BlArtificerSelfGoods> artificerSelfGoods) { public boolean editWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
artificerSelfGoods.forEach(x -> editWarehouse(x.getId(), x.getChangeNum(), x.getRemark())); artificerSelfGoodsList.forEach(x -> editWarehouse(x.getId(), x.getChangeNum(), x.getRemark()));
return true; return true;
} }
} }