package com.zy.asrs.service.impl;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.core.common.Cools;
|
import com.core.common.R;
|
import com.core.exception.CoolException;
|
import com.zy.asrs.entity.BasAreas;
|
import com.zy.asrs.entity.BasWhsType;
|
import com.zy.asrs.entity.LocMast;
|
import com.zy.asrs.entity.param.LocMastInitParam;
|
import com.zy.asrs.mapper.LocCacheMapper;
|
import com.zy.asrs.entity.LocCache;
|
import com.zy.asrs.service.BasAreasService;
|
import com.zy.asrs.service.BasWhsTypeService;
|
import com.zy.asrs.service.LocCacheService;
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.zy.common.model.Shelves;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
@Slf4j
|
@Service("locCacheService")
|
public class LocCacheServiceImpl extends ServiceImpl<LocCacheMapper, LocCache> implements LocCacheService {
|
|
|
@Autowired
|
private BasAreasService basAreasService;
|
|
/**
|
* @author Ryan
|
* @date 2025/9/18
|
* @description: 初始化库区库位信息
|
* @version 1.0
|
*/
|
@Override
|
public R initLocCache(LocMastInitParam param, Long userId) {
|
try {
|
List<LocCache> list = new ArrayList<>();
|
BasAreas areas = basAreasService.selectById(param.getIdentifying());
|
if (Cools.isEmpty(areas)) {
|
return R.error("库区不存在!!!");
|
}
|
for (int r = param.getStartRow(); r <= param.getEndRow(); r++) {
|
for (int b = param.getStartBay(); b <= param.getEndBay(); b++) {
|
for (int l = param.getStartLev(); l <= param.getEndLev(); l++) {
|
// 获取库位号
|
String locNo = String.format("CA") + String.format("%02d", r) + String.format("%03d", b) + String.format("%02d", l);
|
Date now = new Date();
|
LocCache locMast = new LocCache();
|
locMast.setLocNo(locNo);
|
locMast.setLocSts("O");
|
locMast.setRow1(r); // 排
|
locMast.setBay1(b); // 列
|
locMast.setLev1(l); // 层
|
locMast.setId(null);
|
locMast.setLocType1(!Cools.isEmpty(param.getLocType1()) ? param.getLocType1() : 1);
|
locMast.setLocType2(param.getLocType2());
|
locMast.setLocType3(param.getLocType3());
|
locMast.setAppeUser(userId);
|
locMast.setAppeTime(now);
|
locMast.setModiUser(userId);
|
locMast.setModiTime(now);
|
locMast.setAreaId(areas.getId());
|
locMast.setAreaName(areas.getName());
|
list.add(locMast);
|
}
|
}
|
}
|
if (!Cools.isEmpty(param.getEnable()) && param.getEnable() == 1) {
|
if (!this.delete(new EntityWrapper<>())) {
|
throw new CoolException("删除失败!!");
|
}
|
}
|
|
if (!this.insertBatch(list)) {
|
throw new CoolException("添加失败!!");
|
}
|
return R.ok("初始化成功");
|
} catch (Exception e) {
|
return R.error("初始化失败===>" + e.getMessage());
|
}
|
}
|
}
|