|
|
@ -3,6 +3,8 @@ package com.os.ems.info.service.impl;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import com.os.common.exception.ServiceException;
|
|
|
|
|
|
|
|
import com.os.common.utils.StringUtils;
|
|
|
|
import com.os.ems.info.mapper.PowerEnergySparePartsRegistrationMapper;
|
|
|
|
import com.os.ems.info.mapper.PowerEnergySparePartsRegistrationMapper;
|
|
|
|
import com.os.ems.info.domain.PowerEnergySparePartsRegistration;
|
|
|
|
import com.os.ems.info.domain.PowerEnergySparePartsRegistration;
|
|
|
|
import com.os.ems.info.service.IPowerEnergySparePartsRegistrationService;
|
|
|
|
import com.os.ems.info.service.IPowerEnergySparePartsRegistrationService;
|
|
|
@ -90,4 +92,83 @@ public class PowerEnergySparePartsRegistrationServiceImpl implements IPowerEnerg
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return powerEnergySparePartsRegistrationMapper.deletePowerEnergySparePartsRegistrationByObjid(objid);
|
|
|
|
return powerEnergySparePartsRegistrationMapper.deletePowerEnergySparePartsRegistrationByObjid(objid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 导入动力能源部行输科废旧备件登记数据
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param recordList 记录数据列表
|
|
|
|
|
|
|
|
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
|
|
|
|
|
|
|
* @param operName 操作用户
|
|
|
|
|
|
|
|
* @return 结果
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String importPowerEnergySparePartsRegistration(List<PowerEnergySparePartsRegistration> recordList, Boolean isUpdateSupport, String operName)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (StringUtils.isNull(recordList) || recordList.size() == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new ServiceException("导入数据不能为空!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int successNum = 0;
|
|
|
|
|
|
|
|
int failureNum = 0;
|
|
|
|
|
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
|
|
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
|
|
|
|
|
for (PowerEnergySparePartsRegistration record : recordList)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// 设置操作人
|
|
|
|
|
|
|
|
record.setCreateBy(operName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 验证是否存在这个记录
|
|
|
|
|
|
|
|
PowerEnergySparePartsRegistration existRecord = null;
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(record.getType()) && StringUtils.isNotEmpty(record.getReferenceLocation()))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PowerEnergySparePartsRegistration queryRecord = new PowerEnergySparePartsRegistration();
|
|
|
|
|
|
|
|
queryRecord.setType(record.getType());
|
|
|
|
|
|
|
|
queryRecord.setReferenceLocation(record.getReferenceLocation());
|
|
|
|
|
|
|
|
List<PowerEnergySparePartsRegistration> existRecords = powerEnergySparePartsRegistrationMapper.selectPowerEnergySparePartsRegistrationList(queryRecord);
|
|
|
|
|
|
|
|
if (existRecords.size() > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
existRecord = existRecords.get(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNull(existRecord))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.insertPowerEnergySparePartsRegistration(record);
|
|
|
|
|
|
|
|
successNum++;
|
|
|
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、废旧备件登记 " + record.getType() + " 导入成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (isUpdateSupport)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
record.setObjid(existRecord.getObjid());
|
|
|
|
|
|
|
|
record.setUpdateBy(operName);
|
|
|
|
|
|
|
|
this.updatePowerEnergySparePartsRegistration(record);
|
|
|
|
|
|
|
|
successNum++;
|
|
|
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、废旧备件登记 " + record.getType() + " 更新成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
failureNum++;
|
|
|
|
|
|
|
|
failureMsg.append("<br/>" + failureNum + "、废旧备件登记 " + record.getType() + " 已存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
failureNum++;
|
|
|
|
|
|
|
|
String msg = "<br/>" + failureNum + "、废旧备件登记 " + record.getType() + " 导入失败:";
|
|
|
|
|
|
|
|
failureMsg.append(msg + e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (failureNum > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
|
|
|
|
|
throw new ServiceException(failureMsg.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return successMsg.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|