Merge remote-tracking branch 'origin/main'

main
liutao 11 hours ago
commit 860424e71b

@ -26,6 +26,7 @@ import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutApproveRecord
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemPalletDO;
import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockOutItemMapper;
import cn.iocoder.yudao.module.erp.enums.ErpStockOutStatusEnum;
import cn.iocoder.yudao.module.erp.service.mold.MoldBrandService;
import cn.iocoder.yudao.module.erp.service.mold.MoldService;
@ -81,6 +82,8 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
@Validated
public class ErpStockOutController {
private static final List<Integer> LOCKED_STOCK_OUT_STATUSES = java.util.Arrays.asList(10, 0, 1);
@Resource
private ErpStockOutService stockOutService;
@Resource
@ -97,6 +100,8 @@ public class ErpStockOutController {
private ErpPalletService palletService;
@Resource
private AdminUserApi adminUserApi;
@Resource
private ErpStockOutItemMapper stockOutItemMapper;
@PostMapping("/create")
@Operation(summary = "创建其它出库单")
@ -177,9 +182,11 @@ public class ErpStockOutController {
if (stockOut == null) {
return success(null);
}
return success(buildStockOutRespVO(stockOut,
ErpStockOutRespVO stockOutVO = buildStockOutRespVO(stockOut,
stockOutService.getStockOutItemListByOutId(id),
stockOutService.getStockOutApproveRecordList(id)));
stockOutService.getStockOutApproveRecordList(id));
fillLockedStockCount(stockOutVO.getItems());
return success(stockOutVO);
}
@GetMapping("/page")
@ -424,6 +431,22 @@ public class ErpStockOutController {
return value != null ? value : BigDecimal.ZERO;
}
private void fillLockedStockCount(List<ErpStockOutRespVO.Item> items) {
if (CollUtil.isEmpty(items)) {
return;
}
items.forEach(item -> item.setLockedStockCount(getLockedStockCount(item)));
}
private BigDecimal getLockedStockCount(ErpStockOutRespVO.Item item) {
if (item.getProductId() == null) {
return BigDecimal.ZERO;
}
BigDecimal lockedStockCount = stockOutItemMapper.selectLockedStockCount(
item.getProductId(), item.getWarehouseId(), item.getAreaId(), LOCKED_STOCK_OUT_STATUSES);
return lockedStockCount != null ? lockedStockCount : BigDecimal.ZERO;
}
private String buildStockKey(Long productId, Long warehouseId, Long areaId) {
return String.valueOf(productId) + "_" + String.valueOf(warehouseId) + "_" + String.valueOf(areaId);
}

@ -259,6 +259,9 @@ public class ErpStockOutRespVO {
@Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
private BigDecimal stockCount;
@Schema(description = "锁定库存数量", example = "10.00")
private BigDecimal lockedStockCount;
@Schema(description = "托盘列表")
private List<PalletItem> pallets;

@ -422,7 +422,7 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
item -> copyStockOutItem(sourceItem, warehouseId, areaId));
BigDecimal palletCount = resolvePalletCount(pallet, sourceItem);
if (palletCount.compareTo(BigDecimal.ZERO) <= 0) {
throw exception(STOCK_OUT_PRODUCT_PALLET_COUNT_EMPTY, pallet.getPalletId());
throw exception(STOCK_OUT_PRODUCT_PALLET_COUNT_EMPTY, getPalletCodeOrId(pallet.getPalletId()));
}
palletTotalCount = palletTotalCount.add(palletCount);
targetItem.setCount(defaultZero(targetItem.getCount()).add(palletCount));
@ -440,6 +440,14 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
reqVO.setItems(normalizedItems);
}
private Object getPalletCodeOrId(Long palletId) {
if (palletId == null) {
return null;
}
ErpPalletDO pallet = palletMapper.selectById(palletId);
return pallet != null && pallet.getCode() != null ? pallet.getCode() : palletId;
}
private ErpStockOutSaveReqVOItem copyStockOutItem(ErpStockOutSaveReqVOItem sourceItem, Long warehouseId, Long areaId) {
ErpStockOutSaveReqVOItem targetItem = BeanUtils.toBean(sourceItem, ErpStockOutSaveReqVOItem.class);
targetItem.setId(null);

@ -153,8 +153,9 @@ public class DeviceLineController {
@PreAuthorize("@ss.hasPermission('iot:device:query')")
public CommonResult<List<LineAnalysisTreeDTO.LineNode>> deviceParameterAnalysis(
@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "showDevices") Integer showDevices) {
return success(deviceLineService.deviceParameterAnalysis(keyword, showDevices));
@RequestParam(value = "showDevices") Integer showDevices,
@RequestParam(value = "filterNoDeviceLine", required = false) Integer filterNoDeviceLine) {
return success(deviceLineService.deviceParameterAnalysis(keyword, showDevices, filterNoDeviceLine));
}
@GetMapping("/children")

@ -12,7 +12,7 @@ public enum PlanStatusEnum {
(2),
(3),
//旧完工-
//旧完工-
// 完工(4),
(5),
(6),

@ -255,6 +255,9 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
updateObj.setComponentId(updateObj.getComponentId()==null?"":updateObj.getComponentId());
updateObj.setBeijianId(updateObj.getBeijianId()==null?"":updateObj.getBeijianId());
deviceLedgerMapper.updateById(updateObj);
deviceLedgerMapper.update(null, Wrappers.<DeviceLedgerDO>lambdaUpdate()
.eq(DeviceLedgerDO::getId, updateObj.getId())
.set(DeviceLedgerDO::getDvId, updateReqVO.getDvId()));
deviceLedgerComponentRelService.replaceByDeviceLedgerId(updateObj.getId(), updateReqVO.getComponentId());
deviceLedgerSpareRelService.replaceByDeviceLedgerId(updateObj.getId(), updateReqVO.getBeijianId());
}

@ -36,7 +36,7 @@ public interface DeviceLineService {
List<DeviceLineDO> getAncestorDeviceLines(Long id);
List<LineAnalysisTreeDTO.LineNode> deviceParameterAnalysis(String keyword, Integer showDevices);
List<LineAnalysisTreeDTO.LineNode> deviceParameterAnalysis(String keyword, Integer showDevices, Integer filterNoDeviceLine);
void regenerateCode(Long id, String code) throws UnsupportedEncodingException;

@ -229,11 +229,12 @@ public class DeviceLineServiceImpl implements DeviceLineService {
}
@Override
public List<LineAnalysisTreeDTO.LineNode> deviceParameterAnalysis(String keyword, Integer showDevices) {
public List<LineAnalysisTreeDTO.LineNode> deviceParameterAnalysis(String keyword, Integer showDevices, Integer filterNoDeviceLine) {
if (showDevices == null || (showDevices != 1 && showDevices != 2)) {
showDevices = 1;
}
boolean needShowDevices = showDevices == 1;
boolean needFilterNoDeviceLine = filterNoDeviceLine != null && filterNoDeviceLine == 1;
boolean hasKeyword = StringUtils.isNotBlank(keyword);
String lowerKeyword = hasKeyword ? keyword.toLowerCase() : null;
@ -274,10 +275,21 @@ public class DeviceLineServiceImpl implements DeviceLineService {
.filter(item -> item.getDeviceLine() != null)
.collect(Collectors.groupingBy(item -> item.getDeviceLine().longValue()));
Set<Long> validDeviceIds = deviceMap.keySet();
Set<Long> lineIdsWithDevice = ledgers.stream()
.filter(item -> item.getDeviceLine() != null)
.filter(item -> validDeviceIds.contains(item.getDvId()))
.map(item -> item.getDeviceLine().longValue())
.collect(Collectors.toSet());
Map<Long, List<DeviceLineDO>> childrenByParentId = deviceLines.stream()
.filter(item -> item.getParentId() != null && item.getParentId() != 0L)
.collect(Collectors.groupingBy(DeviceLineDO::getParentId));
Map<Long, DeviceLineDO> deviceLineMap = deviceLines.stream()
.collect(Collectors.toMap(DeviceLineDO::getId, Function.identity(), (a, b) -> a));
Set<Long> lineIdsWithDeviceOrAncestor = buildLineIdsWithDeviceOrAncestor(lineIdsWithDevice, deviceLineMap);
Set<Long> matchedNodeIds = new HashSet<>();
if (hasKeyword) {
for (DeviceLineDO line : deviceLines) {
@ -294,8 +306,27 @@ public class DeviceLineServiceImpl implements DeviceLineService {
matchedNodeIds.addAll(deviceLines.stream().map(DeviceLineDO::getId).collect(Collectors.toSet()));
}
return buildDeviceLineAnalysisTree(deviceLines, matchedNodeIds, ledgersByLineId, deviceMap,
paramsByDeviceId, needShowDevices, hasKeyword, lowerKeyword);
return buildDeviceLineAnalysisTree(deviceLines, matchedNodeIds, lineIdsWithDeviceOrAncestor, ledgersByLineId, deviceMap,
paramsByDeviceId, needShowDevices, needFilterNoDeviceLine, hasKeyword, lowerKeyword);
}
private Set<Long> buildLineIdsWithDeviceOrAncestor(Set<Long> lineIdsWithDevice,
Map<Long, DeviceLineDO> deviceLineMap) {
Set<Long> result = new HashSet<>(lineIdsWithDevice);
for (Long lineId : lineIdsWithDevice) {
DeviceLineDO current = deviceLineMap.get(lineId);
Long parentId = current == null ? null : current.getParentId();
Set<Long> visitedParentIds = new HashSet<>();
while (parentId != null && parentId > 0 && visitedParentIds.add(parentId)) {
result.add(parentId);
DeviceLineDO parent = deviceLineMap.get(parentId);
if (parent == null) {
break;
}
parentId = parent.getParentId();
}
}
return result;
}
private boolean isDeviceLineAnalysisMatched(DeviceLineDO line,
@ -365,10 +396,12 @@ public class DeviceLineServiceImpl implements DeviceLineService {
private List<LineAnalysisTreeDTO.LineNode> buildDeviceLineAnalysisTree(
List<DeviceLineDO> deviceLines,
Set<Long> matchedNodeIds,
Set<Long> lineIdsWithDeviceOrAncestor,
Map<Long, List<DeviceLedgerDO>> ledgersByLineId,
Map<Long, DeviceDO> deviceMap,
Map<Long, List<DeviceContactModelDO>> paramsByDeviceId,
boolean needShowDevices,
boolean needFilterNoDeviceLine,
boolean hasKeyword,
String lowerKeyword) {
@ -377,6 +410,9 @@ public class DeviceLineServiceImpl implements DeviceLineService {
if (!matchedNodeIds.contains(line.getId())) {
continue;
}
if (needFilterNoDeviceLine && !lineIdsWithDeviceOrAncestor.contains(line.getId())) {
continue;
}
nodeMap.put(line.getId(), LineAnalysisTreeDTO.LineNode.builder()
.id(line.getId())
.name(line.getName())

@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
import cn.iocoder.yudao.module.iot.controller.admin.device.enums.JavaToTdengineTypeEnum;
import cn.iocoder.yudao.module.mes.controller.admin.energydevice.vo.HourEnergyValueVO;
import cn.iocoder.yudao.module.iot.dal.dataobject.devicecontactmodel.DeviceContactModelDO;
@ -15,7 +16,6 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.energydevice.EnergyDeviceCheck
import cn.iocoder.yudao.module.mes.dal.dataobject.energydevice.EnergyDeviceDO;
import cn.iocoder.yudao.module.mes.dal.mysql.energydevice.EnergyDeviceCheckRecordMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.energydevice.EnergyDeviceMapper;
import cn.iocoder.yudao.module.mes.dal.redis.no.MesNoRedisDAO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -58,7 +58,7 @@ public class EnergyDeviceServiceImpl implements EnergyDeviceService {
@Resource
private EnergyDeviceCheckRecordMapper energyDeviceCheckRecordMapper;
@Resource
private MesNoRedisDAO noRedisDAO;
private AutoCodeUtil autoCodeUtil;
@Resource
private TDengineService tDengineService;
@Resource
@ -68,15 +68,12 @@ public class EnergyDeviceServiceImpl implements EnergyDeviceService {
public Long createEnergyDevice(EnergyDeviceSaveReqVO createReqVO) {
// 插入
EnergyDeviceDO energyDevice = BeanUtils.toBean(createReqVO, EnergyDeviceDO.class);
if (StringUtils.isEmpty(energyDevice.getCode())) {
// 1.4 生成编号
String no = noRedisDAO.generate2(MesNoRedisDAO.ENERGY_NO_PREFIX);
energyDevice.setCode(no);
}
// 校验编码是否唯一
if (StringUtils.isNotEmpty(energyDevice.getCode())) {
// 验证是否唯一编码;未填写时自动生成
if (StringUtils.isBlank(createReqVO.getCode())) {
energyDevice.setCode(autoCodeUtil.genSerialCode("ENERGY_CONSUMPTION_CODE", null));
} else {
List<EnergyDeviceDO> existingDevice = energyDeviceMapper.selectList(
Wrappers.<EnergyDeviceDO>lambdaQuery().eq(EnergyDeviceDO::getCode,createReqVO.getCode()));
Wrappers.<EnergyDeviceDO>lambdaQuery().eq(EnergyDeviceDO::getCode, createReqVO.getCode()));
if (!existingDevice.isEmpty()) {
throw exception(ENERGY_DEVICE_CODE_DUPLICATE);
}

Loading…
Cancel
Save