package com.aps.core.service.impl;
|
|
import java.util.List;
|
|
import com.aps.common.core.utils.DateUtils;
|
import com.aps.common.core.utils.uuid.IdUtils;
|
import com.aps.core.domain.ApsPartPlanTemp;
|
import com.aps.core.mapper.ApsPartPlanTempMapper;
|
import org.checkerframework.checker.units.qual.A;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import com.aps.core.mapper.ApsPartPlanMapper;
|
import com.aps.core.domain.ApsPartPlan;
|
import com.aps.core.service.IApsPartPlanService;
|
import org.springframework.transaction.annotation.Transactional;
|
|
/**
|
* 零件计划管理Service业务层处理
|
*
|
* @author wwj
|
* @date 2025-04-08
|
*/
|
@Service
|
public class ApsPartPlanServiceImpl implements IApsPartPlanService
|
{
|
@Autowired
|
private ApsPartPlanMapper apsPartPlanMapper;
|
@Autowired
|
private ApsPartPlanTempMapper apsPartPlanTempMapper;
|
|
/**
|
* 查询零件计划管理
|
*
|
* @param id 零件计划管理主键
|
* @return 零件计划管理
|
*/
|
@Override
|
public ApsPartPlan selectApsPartPlanById(String id)
|
{
|
return apsPartPlanMapper.selectApsPartPlanById(id);
|
}
|
|
/**
|
* 查询零件计划管理列表
|
*
|
* @param apsPartPlan 零件计划管理
|
* @return 零件计划管理
|
*/
|
@Override
|
public List<ApsPartPlan> selectApsPartPlanList(ApsPartPlan apsPartPlan)
|
{
|
return apsPartPlanMapper.selectApsPartPlanList(apsPartPlan);
|
}
|
|
/**
|
* 新增零件计划管理
|
*
|
* @param apsPartPlan 零件计划管理
|
* @return 结果
|
*/
|
@Override
|
public int insertApsPartPlan(ApsPartPlan apsPartPlan)
|
{
|
apsPartPlan.setId(IdUtils.fastUUID());
|
apsPartPlan.setCreateTime(DateUtils.getNowDate());
|
return apsPartPlanMapper.insertApsPartPlan(apsPartPlan);
|
}
|
|
/**
|
* 修改零件计划管理
|
*
|
* @param apsPartPlan 零件计划管理
|
* @return 结果
|
*/
|
@Override
|
public int updateApsPartPlan(ApsPartPlan apsPartPlan)
|
{
|
return apsPartPlanMapper.updateApsPartPlan(apsPartPlan);
|
}
|
|
/**
|
* 批量删除零件计划管理
|
*
|
* @param ids 需要删除的零件计划管理主键
|
* @return 结果
|
*/
|
@Override
|
public int deleteApsPartPlanByIds(String[] ids)
|
{
|
return apsPartPlanMapper.deleteApsPartPlanByIds(ids);
|
}
|
|
/**
|
* 删除零件计划管理信息
|
*
|
* @param id 零件计划管理主键
|
* @return 结果
|
*/
|
@Override
|
public int deleteApsPartPlanById(String id)
|
{
|
return apsPartPlanMapper.deleteApsPartPlanById(id);
|
}
|
|
@Transactional
|
@Override
|
public int confirmPart(ApsPartPlanTemp apsPartPlanTemp) {
|
|
apsPartPlanMapper.removeAllPartPlans();
|
//查询临时表数据
|
List<ApsPartPlanTemp> apsPartPlanTemps=apsPartPlanTempMapper.selectApsPartPlanTempList(apsPartPlanTemp);
|
int count=0;
|
List<String> aids=apsPartPlanTemps.stream().map(ApsPartPlanTemp::getId).toList();
|
String[] ids=aids.toArray(new String[0]);
|
// for (int i = 0; i <apsPartPlanTemps.size() ; i++) {
|
// //记录临时表id
|
// ids[i]=apsPartPlanTemps.get(i).getId();
|
// ApsPartPlan apsPartPlan=new ApsPartPlan();
|
// BeanUtils.copyProperties(apsPartPlanTemps.get(i), apsPartPlan);
|
// apsPartPlan.setId(IdUtils.fastUUID());
|
// //插入正式表,并记录
|
// apsPartPlanMapper.insertApsPartPlan(apsPartPlan);
|
// count++;
|
// }
|
count =apsPartPlanMapper.insertBatch(apsPartPlanTemps);
|
//插入数量与临时表查询一直则删除临时表数据
|
if (count==apsPartPlanTemps.size()) {
|
apsPartPlanTempMapper.deleteApsPartPlanTempByIds(ids);
|
}
|
return 1;
|
}
|
}
|