package com.by4cloud.platformx.device.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.by4cloud.platformx.common.security.util.SecurityUtils;
|
import com.by4cloud.platformx.device.constant.CommonStatusContant;
|
import com.by4cloud.platformx.device.constant.MaxSizeContant;
|
import com.by4cloud.platformx.device.dto.DevicePurchasePlanQueryDTO;
|
import com.by4cloud.platformx.device.entity.DevicePurchasePlan;
|
import com.by4cloud.platformx.device.entity.DevicePurchasePlanItem;
|
import com.by4cloud.platformx.device.mapper.DevicePurchasePlanItemMapper;
|
import com.by4cloud.platformx.device.mapper.DevicePurchasePlanMapper;
|
import com.by4cloud.platformx.device.service.DevicePurchasePlanService;
|
import com.by4cloud.platformx.device.service.JcMaxSizeService;
|
import lombok.AllArgsConstructor;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 设备采购计划
|
*
|
* @author syt
|
* @date 2025-04-21 14:43:13
|
*/
|
@Service
|
@AllArgsConstructor
|
public class DevicePurchasePlanServiceImpl extends ServiceImpl<DevicePurchasePlanMapper, DevicePurchasePlan> implements DevicePurchasePlanService {
|
|
private final JcMaxSizeService maxSizeService;
|
|
private final DevicePurchasePlanItemMapper itemMapper;
|
|
@Override
|
public boolean saveNew(DevicePurchasePlan devicePurchasePlan) {
|
devicePurchasePlan.setPlanCode(maxSizeService.nextNo(MaxSizeContant.DEVICE_PURCHASE_CODE));
|
devicePurchasePlan.setReleaseCompId(SecurityUtils.getUser().getCompId());
|
devicePurchasePlan.setReleaseId(SecurityUtils.getUser().getId());
|
devicePurchasePlan.setReleaseTime(new Date());
|
devicePurchasePlan.setStatus(CommonStatusContant.DEVICE_PURCHASE_STATUS_PANDING_APPROVAL);
|
baseMapper.insert(devicePurchasePlan);
|
if (devicePurchasePlan.getPlanItemList() != null&&devicePurchasePlan.getPlanItemList().size()>0) {
|
devicePurchasePlan.getPlanItemList().forEach(item->{
|
item.setPlanId(devicePurchasePlan.getId());
|
itemMapper.insert(item);
|
});
|
}
|
return true;
|
}
|
|
@Override
|
public IPage pageNew(Page page, DevicePurchasePlanQueryDTO queryDTO) {
|
return baseMapper.page(page,queryDTO);
|
}
|
|
@Override
|
public boolean approved(Long id) {
|
DevicePurchasePlan plan = baseMapper.selectById(id);
|
plan.setStatus(CommonStatusContant.DEVICE_PURCHASE_STATUS_APPROVED);
|
baseMapper.updateById(plan);
|
return true;
|
}
|
|
@Override
|
public DevicePurchasePlan getByIdNew(Long id) {
|
DevicePurchasePlan plan = baseMapper.selectById(id);
|
QueryWrapper<DevicePurchasePlanItem> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("plan_id",id);
|
List<DevicePurchasePlanItem> planItemList = itemMapper.selectList(queryWrapper);
|
plan.setPlanItemList(planItemList);
|
return plan;
|
}
|
|
@Override
|
public boolean updateByIdNew(DevicePurchasePlan devicePurchasePlan) {
|
baseMapper.updateById(devicePurchasePlan);
|
if (devicePurchasePlan.getPlanItemList() != null&&devicePurchasePlan.getPlanItemList().size()>0) {
|
devicePurchasePlan.getPlanItemList().forEach(item->{
|
item.setPlanId(devicePurchasePlan.getId());
|
if (item.getId()==null) {
|
itemMapper.insert(item);
|
}else {
|
itemMapper.updateById(item);
|
}
|
});
|
}
|
return true;
|
}
|
}
|