生成盘点单

main
judy 1 year ago
parent 49e49ced1b
commit eb58395b79
  1. 28
      shkj-wms/src/main/java/com/shkj/wms/bo/BusinStockInvAddBo.java
  2. 6
      shkj-wms/src/main/java/com/shkj/wms/controller/business/BusinStockInvController.java
  3. 2
      shkj-wms/src/main/java/com/shkj/wms/service/IBusinStockInvService.java
  4. 65
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinStockInvServiceImpl.java
  5. 55
      shkj-wms/src/main/java/com/shkj/wms/utils/IntIdUtil.java
  6. 5
      shkj-wms/src/main/java/com/shkj/wms/vo/StockLocationInvVo.java
  7. 4
      shkj-wms/src/main/resources/mapper/wms/BusinStockInvMapper.xml

@ -24,32 +24,24 @@ public class BusinStockInvAddBo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 盘点类型
* 巷道
*/
@NotBlank(message = "盘点类型不得为空")
@Dict(type = "inv_type_dict", message = "盘点类型与数据字典值不匹配")
private String invType;
private String tunnel;
/**
* 盘点方式 明盘 open 盲盘 close
*
*/
@NotBlank(message = "盘点方式不得为空")
private String invWay;
private String locationRow;
/**
* 库存id集合
*
*/
@NotEmpty(message = "库存id集合不得为空")
private List<Long> stockIds;
// /**
// * 货位分组
// */
// @NotEmpty(message = "货位分组不得为空")
// private List<String> locationGroups;
private String locationColumn;
/**
* 货位分组
*
*/
private List<String> locationGroups;
private String layer;
}

@ -36,11 +36,11 @@ public class BusinStockInvController extends BaseController {
private final IBusinStockInvService iBusinStockInvService;
/**
* 新增盘点计划
* 生成盘点计划
*/
@Log(title = "新增盘点计划", businessType = BusinessType.INSERT)
@Log(title = "生成盘点计划", businessType = BusinessType.INSERT)
@PostMapping("/add")
public Result<Boolean> add(@Valid @RequestBody BusinStockInvAddBo bo) {
public Result<Boolean> add(@Valid @RequestBody BusinStockInvLocQueryBo bo) {
return iBusinStockInvService.generateInventoryPlan(bo);
}

@ -42,7 +42,7 @@ List<BusinStockInvVo> queryList(BusinStockInvQueryBo bo);
* @param bo 盘点计划新增业务对象
* @return
*/
Result<Boolean> generateInventoryPlan(BusinStockInvAddBo bo);
Result<Boolean> generateInventoryPlan(BusinStockInvLocQueryBo bo);
/**

@ -18,6 +18,7 @@ import com.shkj.wms.enums.InvStatusEnum;
import com.shkj.wms.enums.TaskStatusEnum;
import com.shkj.wms.mapper.BusinStockInvMapper;
import com.shkj.wms.service.*;
import com.shkj.wms.utils.IntIdUtil;
import com.shkj.wms.vo.BusinStockInvExeVo;
import com.shkj.wms.vo.BusinStockInvVo;
import com.shkj.wms.vo.StockLocationInvVo;
@ -87,48 +88,42 @@ public class BusinStockInvServiceImpl extends ServiceImpl<BusinStockInvMapper, B
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Boolean> generateInventoryPlan(BusinStockInvAddBo bo) {
Long branchId = SecurityUtils.getCurrentBranchId();
String username = SecurityUtils.getUsername();
Map<String, List<String>> locationGroupStockDic = new HashMap<>();
Map<String, String> orderNosDic = new HashMap<>();
for (Long stockId : bo.getStockIds()) {
LambdaQueryWrapper<BusinStockInv> wrapper = new LambdaQueryWrapper<BusinStockInv>().ne(BusinStockInv::getInvStatus, InvStatusEnum.end).ne(BusinStockInv::getInvStatus, InvStatusEnum.cancel);
BusinStockInv businStockInvOne = iBusinStockInvService.getOne(wrapper);
if (businStockInvOne != null) {
LambdaQueryWrapper<BaseLocation> locationWrapper = new LambdaQueryWrapper<BaseLocation>().eq(BaseLocation::getId, businStockInvOne.getLocationId());
BaseLocation locationOne = iBaseLocationService.getOne(locationWrapper);
return Result.err().msg("货位" + locationOne.getLocationName() + "存在没有结束的盘点单" + businStockInvOne.getInvOrderNo() + ",不允许再次生成!");
}
public Result<Boolean> generateInventoryPlan(BusinStockInvLocQueryBo bo) {
/**
* 1.查询需要盘点的货位
*/
List<StockLocationInvVo> stockLocationInvVos = this.queryLocatonStocklist(bo);
List<Long> locIdList = new ArrayList<>();
for (StockLocationInvVo stockLocationInvVo : stockLocationInvVos) {
locIdList.add(stockLocationInvVo.getLocationId());
}
if (locIdList.size()>0){
LambdaQueryWrapper<BusinStockInv> wrapper = new LambdaQueryWrapper<BusinStockInv>().in(BusinStockInv::getLocationId,locIdList).ne(BusinStockInv::getInvStatus, InvStatusEnum.end).ne(BusinStockInv::getInvStatus, InvStatusEnum.cancel);
List<BusinStockInv> list = iBusinStockInvService.list(wrapper);
for (BusinStockInv businStockInv : list) {
businStockInv.setInvStatus(InvStatusEnum.end.getValue());
businStockInv.setRemark("下一轮盘点把上次未完成的进行完成");
}
iBusinStockInvService.updateBatchById(list);
}
List<BusinStockInv> businStockInvs = new ArrayList<>();
Long lineId =0L;
for (StockLocationInvVo stockLocationInvVo : stockLocationInvVos) {
lineId++;
BusinStockInv inv = new BusinStockInv();
/* inv.setInvOrderNo(orderNosDic.get(locationGroup));
inv.setConsignorId(stockLot.getConsignorId());
inv.setLocationId(stockLot.getLocationId());
inv.setGoodId(stockLot.getGoodId());
inv.setBatchId(stockLot.getBatchId());
inv.setQuantity(stockLot.getQuantity());
inv.setInvOrderNo(IntIdUtil.generateIntId()+"");
inv.setLocationId(stockLocationInvVo.getLocationId());
inv.setInvQty(BigDecimal.ZERO);
inv.setInvCase(BigDecimal.ZERO);
inv.setInvPiece(BigDecimal.ZERO);
inv.setOrderUser(username);
inv.setOrderUser(SecurityUtils.getUsername());
inv.setInvStatus(InvStatusEnum.init.getValue());
inv.setInvType(bo.getInvType());
inv.setInvWay(bo.getInvWay());
inv.setStatus(stockLot.getStatus());
inv.setBranchId(stockLot.getBranchId());
inv.setContainerId(stockLot.getContainerId());
inv.setOrderType(OrderTypeEnum.PD.getValue());
if (locationGroupStockDic.containsKey(locationGroup)) {
inv.setLineId(Long.valueOf(locationGroupStockDic.get(locationGroup).size()));
} else {
inv.setLineId(0L);
}*/
this.save(inv);
inv.setBranchId(SecurityUtils.getCurrentBranchId());
inv.setLineId(lineId);
businStockInvs.add(inv);
}
return Result.ok();
return iBusinStockInvService.saveBatch(businStockInvs)?Result.ok().msg("生成盘点单成功"):Result.err().msg("生成盘点单失败");
}
/**

@ -0,0 +1,55 @@
package com.shkj.wms.utils;
import com.shkj.common.core.redis.RedisCache;
import com.shkj.common.core.text.Convert;
import com.shkj.common.utils.spring.SpringUtils;
import java.time.LocalDate;
import java.util.Date;
/**
* @author lch
*/
public class IntIdUtil {
private static Date date = new Date();
private static StringBuilder buf = new StringBuilder();
// private static int seq = 0;
private static final int ROTATION = 99999;
public static synchronized String next() {
Integer seq = Convert.toInt(SpringUtils.getBean(RedisCache.class).getCacheObject("seq"), 0);
if (seq > ROTATION) {
seq = 0;
}
// buf.delete(0, buf.length());
// date.setTime(System.currentTimeMillis());
String str = String.format("%1$05d", seq++);
SpringUtils.getBean(RedisCache.class).setCacheObject("seq", seq);
System.out.println("redis的值为"+seq);
return str;
}
public static Long generateIntId() {
//生成规则 年份后两位-10【2位】 + 1年内第几天【3位】 + 随机数【5位】
LocalDate now = LocalDate.now();
// 因为int的最大数是2147483647 所以前2位=当前年-10
String yearStr = now.getYear() - 10 + "";
yearStr = yearStr.substring(2);
StringBuilder id = new StringBuilder(yearStr + String.format("%1$03d", now.getDayOfYear() )+ next());
return Long.parseLong(id.toString());
}
public static void main(String[] args) {
for (int i = 0; i < 10000; i++) {
Long aLong = IntIdUtil.generateIntId();
System.out.println(aLong + "==>" + Long.parseLong(aLong.intValue() + ""));
}
}
}

@ -15,6 +15,11 @@ import java.io.Serializable;
public class StockLocationInvVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 货位ID
*/
private Long locationId;
/**
* 货位编号
*/

@ -257,7 +257,7 @@
<select id="queryLocatonStocklist" resultType="com.shkj.wms.vo.StockLocationInvVo"
parameterType="com.shkj.wms.bo.BusinStockInvLocQueryBo">
select loc.location_code,goods.vehiche_model,goods.color,loc.location_status,count(stock.id) goodQty
select loc.id as locationId, loc.location_code,goods.vehiche_model,goods.color,loc.location_status,count(stock.id) goodQty
from base_location loc
left join sys_stock_detail stock on loc.id =stock.location_id
left join base_goods_data goods on stock.goods_no=goods.goods_no
@ -277,7 +277,7 @@
</if>
</where>
GROUP BY loc.location_code,goods.vehiche_model,goods.color,loc.location_status
GROUP BY loc.id, loc.location_code,goods.vehiche_model,goods.color,loc.location_status
order by route
</select>

Loading…
Cancel
Save