Commit 2b6eb37f authored by ZWT's avatar ZWT

feat(吉林演示): 松原

1.开发间开优化结果统计功能,创建间开优化效果统计表,生成对应代码;
2.修改15天,10天,3天,1天间开优化功能,修改代码结构;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent e92ede97
package pps.core.common.bean;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* Spring Context 工具类
*
* @author lixueyan
*/
@Component
public class SpringContextUtils implements ApplicationContextAware {
public static ApplicationContext applicationContext;
public static Object getBean(String name) {
return applicationContext.getBean(name);
}
public static <T> T getBean(Class<T> requiredType) {
return applicationContext.getBean(requiredType);
}
public static <T> T getBean(String name, Class<T> requiredType) {
return applicationContext.getBean(name, requiredType);
}
public static boolean containsBean(String name) {
return applicationContext.containsBean(name);
}
public static boolean isSingleton(String name) {
return applicationContext.isSingleton(name);
}
public static Class<? extends Object> getType(String name) {
return applicationContext.getType(name);
}
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
SpringContextUtils.applicationContext = applicationContext;
}
}
\ No newline at end of file
...@@ -5,7 +5,6 @@ import org.springframework.stereotype.Repository; ...@@ -5,7 +5,6 @@ import org.springframework.stereotype.Repository;
import pps.core.system.entity.CurrentSysUserView; import pps.core.system.entity.CurrentSysUserView;
import pps.core.system.entity.SysUserTradeView; import pps.core.system.entity.SysUserTradeView;
import pps.core.system.entity.SysUserView; import pps.core.system.entity.SysUserView;
import pps.core.system.service.data.sys_user.GetSysUserListByOuInput;
import java.util.List; import java.util.List;
...@@ -26,9 +25,5 @@ public interface SysUserViewMapper { ...@@ -26,9 +25,5 @@ public interface SysUserViewMapper {
List<SysUserTradeView> selectUserByTrade(SysUserView record); List<SysUserTradeView> selectUserByTrade(SysUserView record);
List<SysUserView> getSysUserListByOuIds(GetSysUserListByOuInput record);
List<SysUserView> getSysUserListByOuIdOrUserName(GetSysUserListByOuInput record);
CurrentSysUserView getSysUserAndOuByUserId(@Param("userId") String userId); CurrentSysUserView getSysUserAndOuByUserId(@Param("userId") String userId);
} }
...@@ -172,15 +172,13 @@ public class LoginService { ...@@ -172,15 +172,13 @@ public class LoginService {
); );
if (ObjectUtil.isNull(sysUserEnt)) { if (ObjectUtil.isNull(sysUserEnt)) {
insertError(context, loginName); insertError(context, loginName);
Long count = getErrorTimes(context, loginName, sysUserEnt); throw new XServiceException(1000, "用户名或密码错误,还剩" + (5 - getErrorTimes(context, loginName, sysUserEnt)) + "次机会");
throw new XServiceException(1000, "用户名或密码错误,还剩" + (5 - count) + "次机会");
} }
if (CharSequenceUtil.isNotBlank(password)) { if (CharSequenceUtil.isNotBlank(password)) {
String decrypt = sysUserEnt.getPassword(); String decrypt = sysUserEnt.getPassword();
if (!CharSequenceUtil.equals(password, decrypt)) { if (!CharSequenceUtil.equals(password, decrypt)) {
insertError(context, loginName); insertError(context, loginName);
Long count = getErrorTimes(context, loginName, sysUserEnt); throw new XServiceException(1000, "用户名或密码错误,还剩" + (5 - getErrorTimes(context, loginName, sysUserEnt)) + "次机会");
throw new XServiceException(1000, "用户名或密码错误,还剩" + (5 - count) + "次机会");
} }
} }
return XSingleResult.success(sysUserEnt); return XSingleResult.success(sysUserEnt);
......
...@@ -1156,8 +1156,7 @@ public class SysOrganizationService { ...@@ -1156,8 +1156,7 @@ public class SysOrganizationService {
list.add(propertyEnt); list.add(propertyEnt);
} }
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
SysOrganizationPropertyMapper propertyMapper = context.getBean(SysOrganizationPropertyMapper.class); list.forEach(context.getBean(SysOrganizationPropertyMapper.class)::insert);
list.forEach(propertyMapper::insert);
} }
} }
......
package pps.core.system.service.data.sys_user;
import xstartup.annotation.XText;
import java.util.List;
public class GetSysUserListByOuInput {
@XText("组织机构id")
private List<String> ouIds;
@XText("用户名称")
private String userName;
@XText("ouId")
private String ouId;
public String userName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getOuId() {
return ouId;
}
public void setOuId(String ouId) {
this.ouId = ouId;
}
public List<String> getOuIds() {
return ouIds;
}
public void setOuIds(List<String> ouIds) {
this.ouIds = ouIds;
}
}
package pps.core.system.service.data.sys_user;
import xstartup.annotation.XText;
import xstartup.base.data.XPageInput;
import java.util.List;
public class QuerySysUserListByOuIdorNameInput extends XPageInput {
@XText("组织机构id")
private List<String> ouIds;
@XText("用户名称")
private String userName;
@XText("ouId")
private String ouId;
public String userName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getOuId() {
return ouId;
}
public void setOuId(String ouId) {
this.ouId = ouId;
}
public List<String> getOuIds() {
return ouIds;
}
public void setOuIds(List<String> ouIds) {
this.ouIds = ouIds;
}
}
...@@ -262,26 +262,6 @@ ...@@ -262,26 +262,6 @@
</where> </where>
</select> </select>
<select id="getSysUserListByOuIdOrUserName" parameterType="pps.core.system.entity.SysUserView"
resultMap="BaseResultMap">
select distinct
su.id,
su.user_name,
su.duty,
su.phone
from sys_user su
left join sys_user_organization_rel suor on suor.user_id=su.id
<where>
<if test="ouId != null and ouId !=''">
and su.phone is not null and suor.ou_id =#{ouId}
</if>
<if test="userName != null and userName!= ''">
and su.user_name like concat('%',#{userName},'%')
</if>
</where>
</select>
<select id="selectUserByTrade" parameterType="pps.core.system.entity.SysUserView" resultMap="TradeResultMap"> <select id="selectUserByTrade" parameterType="pps.core.system.entity.SysUserView" resultMap="TradeResultMap">
select a.user_name, a.login_name, c.ou_name select a.user_name, a.login_name, c.ou_name
from sys_user a, from sys_user a,
......
package pps.core.base.excel;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import pps.core.base.entity.ThirdWindPowerGenerationEnt;
import pps.core.base.entity.WindPredictionFutureView;
import pps.core.base.entity.WindPredictionHistoryView;
import pps.core.base.mapper.ThirdWindPowerGenerationMapper;
import pps.core.base.mapper.WindPredictionFutureViewMapper;
import pps.core.base.mapper.WindPredictionHistoryViewMapper;
import pps.core.base.service.data.third_weather_data.ThirdApiWeatherExcelData;
import pps.core.common.utils.BaseUtils;
import xstartup.base.XContext;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 天气数据监听器(测试用)
*
* @author ZWT
* @date 2024/04/30 11:04
*/
public class ThirdApiWeatherDataListener2 implements ReadListener<ThirdApiWeatherExcelData> {
private XContext context;
/**
* 缓存的数据
*/
private List<ThirdApiWeatherExcelData> cachedDataList = new ArrayList<>(4096);
public ThirdApiWeatherDataListener2(XContext context) {
this.context = context;
}
@Override
public void invoke(ThirdApiWeatherExcelData thirdApiWeatherData, AnalysisContext analysisContext) {
cachedDataList.add(thirdApiWeatherData);
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
this.saveHistory(context, cachedDataList);
}
private void saveHistory(XContext context, List<ThirdApiWeatherExcelData> cachedDataList) {
if (CollUtil.isNotEmpty(cachedDataList)) {
String stationId = "f4816d9e4e134aaba0dbd483775e36b2";
String stationName = "吉林油田模拟电站";
ThirdApiWeatherExcelData first = CollUtil.getFirst(cachedDataList);
ThirdApiWeatherExcelData last = CollUtil.getLast(cachedDataList);
//每个csv只要第一天
DateTime beginTime = DateUtil.parseDateTime(first.getTime());
DateTime endTime = DateUtil.endOfDay(beginTime);
//查实际信息
ThirdWindPowerGenerationMapper mapper = context.getBean(ThirdWindPowerGenerationMapper.class);
List<ThirdWindPowerGenerationEnt> list = mapper.selectList(new LambdaQueryWrapper<ThirdWindPowerGenerationEnt>()
.eq(ThirdWindPowerGenerationEnt::getStationId, stationId)
.between(ThirdWindPowerGenerationEnt::getCollectTime, beginTime, endTime)
.orderByAsc(ThirdWindPowerGenerationEnt::getCollectTime)
);
Map<Date, ThirdWindPowerGenerationEnt> collect = list.stream()
.collect(Collectors.toMap(ThirdWindPowerGenerationEnt::getCollectTime, Function.identity()));
//封装数据
List<WindPredictionFutureView> futureList = new ArrayList<>(96);
List<WindPredictionHistoryView> historyList = new ArrayList<>(96);
DateTime dateTime;
ThirdWindPowerGenerationEnt generationEnt;
for (ThirdApiWeatherExcelData data : cachedDataList) {
dateTime = DateUtil.parseDateTime(data.getTime());
if (endTime.compareTo(dateTime) <= 0) {
break;
}
WindPredictionHistoryView historyView = new WindPredictionHistoryView();
historyView.setStationId(stationId);
historyView.setDataTime(dateTime);
historyView.setWindDirection(data.getWnd());
historyView.setWindSpeed(data.getGust());
historyView.setAirTemperature(data.getTem());
historyView.setHumidity(data.getRhu());
historyView.setPressure(data.getPrsQfe());
historyView.setWnd100m(data.getWnd100m());
historyView.setWns100m(data.getWns100m());
historyView.setWnsGrd100m(data.getWnsGrd100m());
WindPredictionFutureView futureView = new WindPredictionFutureView();
futureView.setStationId(stationId);
futureView.setDataTime(dateTime);
futureView.setWindDirection(data.getWnd());
futureView.setWindSpeed(data.getGust());
futureView.setAirTemperature(data.getTem());
futureView.setHumidity(data.getRhu());
futureView.setPressure(data.getPrsQfe());
futureView.setActualPower(BigDecimal.ZERO);
//匹配实际
if (collect.containsKey(dateTime)) {
generationEnt = collect.get(dateTime);
futureView.setActualWindSpeed(generationEnt.getActualWindSpeed());
historyView.setActualWindSpeed(generationEnt.getActualWindSpeed());
historyView.setActualPower(generationEnt.getActualPower());
historyView.setActualWindDirection(generationEnt.getAccurateWindDirection());
} else {
futureView.setActualWindSpeed(BigDecimal.ZERO);
historyView.setActualWindSpeed(BigDecimal.ZERO);
historyView.setActualPower(BigDecimal.ZERO);
}
futureList.add(futureView);
historyList.add(historyView);
}
//入库
if (CollUtil.isNotEmpty(futureList)) {
WindPredictionFutureViewMapper futureMapper = context.getBean(WindPredictionFutureViewMapper.class);
if (futureList.size() > BaseUtils.BATCH_SIZE) {
List<List<WindPredictionFutureView>> subList = BaseUtils.getSubList(futureList);
subList.forEach(futureMapper::insertBatch);
} else {
futureMapper.insertBatch(futureList);
}
}
if (CollUtil.isNotEmpty(historyList)) {
WindPredictionHistoryViewMapper historyMapper = context.getBean(WindPredictionHistoryViewMapper.class);
if (historyList.size() > BaseUtils.BATCH_SIZE) {
List<List<WindPredictionHistoryView>> subList = BaseUtils.getSubList(historyList);
subList.forEach(historyMapper::batchInsert);
} else {
historyMapper.batchInsert(historyList);
}
}
}
}
}
\ No newline at end of file
...@@ -62,17 +62,15 @@ public class BasePowerLineService { ...@@ -62,17 +62,15 @@ public class BasePowerLineService {
@XApiPost @XApiPost
@XText("输电线路配置--新增") @XText("输电线路配置--新增")
public XServiceResult createBasePowerLine(XContext context, CreateBasePowerLineInput input) { public XServiceResult createBasePowerLine(XContext context, CreateBasePowerLineInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
BasePowerLineMapper mapper = context.getBean(BasePowerLineMapper.class); BasePowerLineMapper mapper = context.getBean(BasePowerLineMapper.class);
BasePowerLineEnt entity = XCopyUtils.copyNewObject(input, BasePowerLineEnt.class); BasePowerLineEnt entity = XCopyUtils.copyNewObject(input, BasePowerLineEnt.class);
//新增输电线路 //新增输电线路
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session); BaseUtils.setBaseModelDefault(entity, session);
mapper.insert(entity); mapper.insert(entity);
String lineId = entity.getId();
String ouId = entity.getOuId();
//新增关联信息 //新增关联信息
this.saveLineRelation(context, lineId, ouId, session, input.getWellheadInputs(), input.getPlantInputs(), input.getStorageInputs(), input.getDieselInputs()); this.saveLineRelation(context, entity.getId(), entity.getOuId(), session, input.getWellheadInputs(), input.getPlantInputs(), input.getStorageInputs(), input.getDieselInputs());
return XServiceResult.OK; return XServiceResult.OK;
}); });
} }
...@@ -87,10 +85,8 @@ public class BasePowerLineService { ...@@ -87,10 +85,8 @@ public class BasePowerLineService {
@XApiPost @XApiPost
@XText("输电线路配置--修改") @XText("输电线路配置--修改")
public XServiceResult updateBasePowerLine(XContext context, UpdateBasePowerLineInput input) { public XServiceResult updateBasePowerLine(XContext context, UpdateBasePowerLineInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
String lineId = input.getId();
String ouId = input.getOuId();
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
String lineId = input.getId();
BasePowerLineMapper mapper = context.getBean(BasePowerLineMapper.class); BasePowerLineMapper mapper = context.getBean(BasePowerLineMapper.class);
BasePowerLineEnt entity = this.selectOneByLineId(lineId, mapper); BasePowerLineEnt entity = this.selectOneByLineId(lineId, mapper);
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
...@@ -116,8 +112,9 @@ public class BasePowerLineService { ...@@ -116,8 +112,9 @@ public class BasePowerLineService {
dieselMapper.delete(new LambdaQueryWrapper<BasePowerLineDieselEnt>() dieselMapper.delete(new LambdaQueryWrapper<BasePowerLineDieselEnt>()
.eq(BasePowerLineDieselEnt::getLineId, lineId) .eq(BasePowerLineDieselEnt::getLineId, lineId)
); );
PpsUserSession session = context.getSession(PpsUserSession.class);
//新增关联信息 //新增关联信息
this.saveLineRelation(context, lineId, ouId, session, input.getWellheadInputs(), input.getPlantInputs(), input.getStorageInputs(), input.getDieselInputs()); this.saveLineRelation(context, lineId, input.getOuId(), session, input.getWellheadInputs(), input.getPlantInputs(), input.getStorageInputs(), input.getDieselInputs());
XCopyUtils.copyObject(input, entity); XCopyUtils.copyObject(input, entity);
BaseUtils.setBaseModelDefault(entity, session); BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity); mapper.updateById(entity);
......
...@@ -59,17 +59,15 @@ public class BasePriceStrategyService { ...@@ -59,17 +59,15 @@ public class BasePriceStrategyService {
@XApiPost @XApiPost
@XText("市电峰谷策略--新增") @XText("市电峰谷策略--新增")
public XServiceResult createBasePriceStrategy(XContext context, CreateBasePriceStrategyInput input) { public XServiceResult createBasePriceStrategy(XContext context, CreateBasePriceStrategyInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
BasePriceStrategyMapper mapper = context.getBean(BasePriceStrategyMapper.class); BasePriceStrategyMapper mapper = context.getBean(BasePriceStrategyMapper.class);
BasePriceStrategyEnt entity = XCopyUtils.copyNewObject(input, BasePriceStrategyEnt.class); BasePriceStrategyEnt entity = XCopyUtils.copyNewObject(input, BasePriceStrategyEnt.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session); BaseUtils.setBaseModelDefault(entity, session);
mapper.insert(entity); mapper.insert(entity);
String strategyId = entity.getId();
List<CreateBasePriceStrategyMonthInput> inputMonths = input.getMonths(); List<CreateBasePriceStrategyMonthInput> inputMonths = input.getMonths();
if (CollUtil.isNotEmpty(inputMonths)) { if (CollUtil.isNotEmpty(inputMonths)) {
List<BasePriceStrategyMonthView> monthList = XCopyUtils.copyNewList(inputMonths, BasePriceStrategyMonthView.class); this.saveStrategyMonthDetail(context, XCopyUtils.copyNewList(inputMonths, BasePriceStrategyMonthView.class), entity.getId(), session);
this.saveStrategyMonthDetail(context, monthList, strategyId, session);
} }
return XServiceResult.OK; return XServiceResult.OK;
}); });
...@@ -85,16 +83,15 @@ public class BasePriceStrategyService { ...@@ -85,16 +83,15 @@ public class BasePriceStrategyService {
@XApiPost @XApiPost
@XText("市电峰谷策略--修改") @XText("市电峰谷策略--修改")
public XServiceResult updateBasePriceStrategy(XContext context, UpdateBasePriceStrategyInput input) { public XServiceResult updateBasePriceStrategy(XContext context, UpdateBasePriceStrategyInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
String strategyId = input.getId();
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
BasePriceStrategyMapper mapper = context.getBean(BasePriceStrategyMapper.class); BasePriceStrategyMapper mapper = context.getBean(BasePriceStrategyMapper.class);
BasePriceStrategyEnt entity = mapper.selectOne(new LambdaQueryWrapper<BasePriceStrategyEnt>() BasePriceStrategyEnt entity = mapper.selectOne(new LambdaQueryWrapper<BasePriceStrategyEnt>()
.eq(BaseModel::getId, strategyId)); .eq(BaseModel::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
} }
List<UpdateBasePriceStrategyMonthInput> inputMonths = input.getMonths(); List<UpdateBasePriceStrategyMonthInput> inputMonths = input.getMonths();
PpsUserSession session = context.getSession(PpsUserSession.class);
if (CollUtil.isNotEmpty(inputMonths)) { if (CollUtil.isNotEmpty(inputMonths)) {
List<BasePriceStrategyMonthView> monthList = XCopyUtils.copyNewList(inputMonths, BasePriceStrategyMonthView.class); List<BasePriceStrategyMonthView> monthList = XCopyUtils.copyNewList(inputMonths, BasePriceStrategyMonthView.class);
List<String> collect = monthList.stream() List<String> collect = monthList.stream()
...@@ -103,16 +100,16 @@ public class BasePriceStrategyService { ...@@ -103,16 +100,16 @@ public class BasePriceStrategyService {
BasePriceStrategyMonthMapper monthMapper = context.getBean(BasePriceStrategyMonthMapper.class); BasePriceStrategyMonthMapper monthMapper = context.getBean(BasePriceStrategyMonthMapper.class);
//删除月信息 //删除月信息
monthMapper.delete(new LambdaQueryWrapper<BasePriceStrategyMonthEnt>() monthMapper.delete(new LambdaQueryWrapper<BasePriceStrategyMonthEnt>()
.eq(BasePriceStrategyMonthEnt::getStrategyId, strategyId) .eq(BasePriceStrategyMonthEnt::getStrategyId, input.getId())
.in(BasePriceStrategyMonthEnt::getStrategyMonth, collect) .in(BasePriceStrategyMonthEnt::getStrategyMonth, collect)
); );
BasePriceStrategyDetailMapper detailMapper = context.getBean(BasePriceStrategyDetailMapper.class); BasePriceStrategyDetailMapper detailMapper = context.getBean(BasePriceStrategyDetailMapper.class);
//删除详情 //删除详情
detailMapper.delete(new LambdaQueryWrapper<BasePriceStrategyDetailEnt>() detailMapper.delete(new LambdaQueryWrapper<BasePriceStrategyDetailEnt>()
.eq(BasePriceStrategyDetailEnt::getStrategyId, strategyId) .eq(BasePriceStrategyDetailEnt::getStrategyId, input.getId())
.in(BasePriceStrategyDetailEnt::getStrategyMonth, collect) .in(BasePriceStrategyDetailEnt::getStrategyMonth, collect)
); );
this.saveStrategyMonthDetail(context, monthList, strategyId, session); this.saveStrategyMonthDetail(context, monthList, input.getId(), session);
} }
XCopyUtils.copyObject(input, entity); XCopyUtils.copyObject(input, entity);
BaseUtils.setBaseModelDefault(entity, session); BaseUtils.setBaseModelDefault(entity, session);
......
...@@ -62,7 +62,6 @@ public class SpaceCalibrationService { ...@@ -62,7 +62,6 @@ public class SpaceCalibrationService {
@XApiPost @XApiPost
@XText("校准周期--新增") @XText("校准周期--新增")
public XServiceResult createSpaceCalibrationPeriod(XContext context, CreateSpaceCalibrationPeriodInput input) { public XServiceResult createSpaceCalibrationPeriod(XContext context, CreateSpaceCalibrationPeriodInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
SpaceCalibrationPeriodMapper mapper = context.getBean(SpaceCalibrationPeriodMapper.class); SpaceCalibrationPeriodMapper mapper = context.getBean(SpaceCalibrationPeriodMapper.class);
SpaceCalibrationPeriodEnt periodEnt = this.getPeriodEntByParam(mapper, input.getLineId(), input.getOuId()); SpaceCalibrationPeriodEnt periodEnt = this.getPeriodEntByParam(mapper, input.getLineId(), input.getOuId());
if (ObjectUtil.isNotNull(periodEnt)) { if (ObjectUtil.isNotNull(periodEnt)) {
...@@ -90,6 +89,7 @@ public class SpaceCalibrationService { ...@@ -90,6 +89,7 @@ public class SpaceCalibrationService {
} }
} }
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session); BaseUtils.setBaseModelDefault(entity, session);
mapper.insert(entity); mapper.insert(entity);
SpaceCalibrationHistoryViewMapper historyViewMapper = context.getBean(SpaceCalibrationHistoryViewMapper.class); SpaceCalibrationHistoryViewMapper historyViewMapper = context.getBean(SpaceCalibrationHistoryViewMapper.class);
...@@ -110,7 +110,6 @@ public class SpaceCalibrationService { ...@@ -110,7 +110,6 @@ public class SpaceCalibrationService {
@XApiPost @XApiPost
@XText("校准周期--修改") @XText("校准周期--修改")
public XServiceResult updateSpaceCalibrationPeriod(XContext context, UpdateSpaceCalibrationPeriodInput input) { public XServiceResult updateSpaceCalibrationPeriod(XContext context, UpdateSpaceCalibrationPeriodInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
SpaceCalibrationPeriodMapper mapper = context.getBean(SpaceCalibrationPeriodMapper.class); SpaceCalibrationPeriodMapper mapper = context.getBean(SpaceCalibrationPeriodMapper.class);
SpaceCalibrationPeriodEnt entity = mapper.selectOne( SpaceCalibrationPeriodEnt entity = mapper.selectOne(
...@@ -121,6 +120,7 @@ public class SpaceCalibrationService { ...@@ -121,6 +120,7 @@ public class SpaceCalibrationService {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
} }
XCopyUtils.copyObject(input, entity); XCopyUtils.copyObject(input, entity);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session); BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity); mapper.updateById(entity);
return XServiceResult.OK; return XServiceResult.OK;
......
...@@ -118,10 +118,9 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService { ...@@ -118,10 +118,9 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
@XApiPost @XApiPost
@XText("基础间开配置--删除") @XText("基础间开配置--删除")
public XServiceResult deleteSpaceInstitutionDetail(XContext context, DeleteSpaceInstitutionDetailInput input) { public XServiceResult deleteSpaceInstitutionDetail(XContext context, DeleteSpaceInstitutionDetailInput input) {
String institutionId = input.getId();
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
SpaceInstitutionDetailMapper mapper = context.getBean(SpaceInstitutionDetailMapper.class); SpaceInstitutionDetailMapper mapper = context.getBean(SpaceInstitutionDetailMapper.class);
SpaceInstitutionDetailEnt entity = this.getInstitutionDetail(mapper, institutionId); SpaceInstitutionDetailEnt entity = this.getInstitutionDetail(mapper, input.getId());
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
} }
...@@ -132,7 +131,7 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService { ...@@ -132,7 +131,7 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
PpsUserSession session = context.getSession(PpsUserSession.class); PpsUserSession session = context.getSession(PpsUserSession.class);
SpaceInstitutionDurationMapper durationMapper = context.getBean(SpaceInstitutionDurationMapper.class); SpaceInstitutionDurationMapper durationMapper = context.getBean(SpaceInstitutionDurationMapper.class);
durationMapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDurationEnt>() durationMapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDurationEnt>()
.eq(SpaceInstitutionDurationEnt::getInstitutionId, institutionId) .eq(SpaceInstitutionDurationEnt::getInstitutionId, input.getId())
.set(BaseModel::getIsDeleted, BusinessConstant.ZERO) .set(BaseModel::getIsDeleted, BusinessConstant.ZERO)
.set(SpaceInstitutionDurationEnt::getModifyById, session.getId()) .set(SpaceInstitutionDurationEnt::getModifyById, session.getId())
.set(SpaceInstitutionDurationEnt::getModifyByName, session.getUserName()) .set(SpaceInstitutionDurationEnt::getModifyByName, session.getUserName())
...@@ -140,14 +139,14 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService { ...@@ -140,14 +139,14 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
); );
SpaceInstitutionWellheadMapper wellheadMapper = context.getBean(SpaceInstitutionWellheadMapper.class); SpaceInstitutionWellheadMapper wellheadMapper = context.getBean(SpaceInstitutionWellheadMapper.class);
wellheadMapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionWellheadEnt>() wellheadMapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionWellheadEnt>()
.eq(SpaceInstitutionWellheadEnt::getInstitutionId, institutionId) .eq(SpaceInstitutionWellheadEnt::getInstitutionId, input.getId())
.set(BaseModel::getIsDeleted, BusinessConstant.ZERO) .set(BaseModel::getIsDeleted, BusinessConstant.ZERO)
.set(SpaceInstitutionWellheadEnt::getModifyById, session.getId()) .set(SpaceInstitutionWellheadEnt::getModifyById, session.getId())
.set(SpaceInstitutionWellheadEnt::getModifyByName, session.getUserName()) .set(SpaceInstitutionWellheadEnt::getModifyByName, session.getUserName())
.set(SpaceInstitutionWellheadEnt::getModifyTime, new Date()) .set(SpaceInstitutionWellheadEnt::getModifyTime, new Date())
); );
mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>() mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>()
.eq(BaseModel::getId, institutionId) .eq(BaseModel::getId, input.getId())
.set(BaseModel::getIsDeleted, BusinessConstant.ZERO) .set(BaseModel::getIsDeleted, BusinessConstant.ZERO)
.set(SpaceInstitutionDetailEnt::getModifyById, session.getId()) .set(SpaceInstitutionDetailEnt::getModifyById, session.getId())
.set(SpaceInstitutionDetailEnt::getModifyByName, session.getUserName()) .set(SpaceInstitutionDetailEnt::getModifyByName, session.getUserName())
...@@ -277,10 +276,9 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService { ...@@ -277,10 +276,9 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
if (ObjectUtil.isNull(detail)) { if (ObjectUtil.isNull(detail)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
} }
PpsUserSession session = context.getSession(PpsUserSession.class);
Integer isCurrentBasic = input.getIsCurrentBasic();
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
if (isCurrentBasic.equals(0)) { PpsUserSession session = context.getSession(PpsUserSession.class);
if (input.getIsCurrentBasic().equals(0)) {
//关闭其他基础制度 //关闭其他基础制度
mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>() mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>()
.eq(SpaceInstitutionDetailEnt::getLineId, detail.getLineId()) .eq(SpaceInstitutionDetailEnt::getLineId, detail.getLineId())
...@@ -294,7 +292,7 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService { ...@@ -294,7 +292,7 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
//修改基础制度 //修改基础制度
mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>() mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>()
.eq(BaseModel::getId, institutionId) .eq(BaseModel::getId, institutionId)
.set(SpaceInstitutionDetailEnt::getIsCurrentBasic, isCurrentBasic) .set(SpaceInstitutionDetailEnt::getIsCurrentBasic, input.getIsCurrentBasic())
.set(BaseModel::getModifyById, session.getId()) .set(BaseModel::getModifyById, session.getId())
.set(BaseModel::getModifyByName, session.getUserName()) .set(BaseModel::getModifyByName, session.getUserName())
.set(BaseModel::getModifyTime, DateUtil.date()) .set(BaseModel::getModifyTime, DateUtil.date())
...@@ -313,11 +311,8 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService { ...@@ -313,11 +311,8 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
@XApiPost @XApiPost
@XText("基础间开配置--设为基础制度") @XText("基础间开配置--设为基础制度")
public XServiceResult updateBasicInstitution(XContext context, UpdateSpaceInstitutionDetailInput input) { public XServiceResult updateBasicInstitution(XContext context, UpdateSpaceInstitutionDetailInput input) {
String ouId = input.getOuId();
String lineId = input.getLineId();
String institutionId = input.getId();
SpaceInstitutionDetailMapper mapper = context.getBean(SpaceInstitutionDetailMapper.class); SpaceInstitutionDetailMapper mapper = context.getBean(SpaceInstitutionDetailMapper.class);
SpaceInstitutionDetailEnt detail = this.getInstitutionDetail(mapper, institutionId); SpaceInstitutionDetailEnt detail = this.getInstitutionDetail(mapper, input.getId());
if (ObjectUtil.isNull(detail)) { if (ObjectUtil.isNull(detail)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
} }
...@@ -325,12 +320,12 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService { ...@@ -325,12 +320,12 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
if (isCurrentBasic.equals(BusinessConstant.ZERO)) { if (isCurrentBasic.equals(BusinessConstant.ZERO)) {
return XServiceResult.error(context, BusinessError.RepeatSetting); return XServiceResult.error(context, BusinessError.RepeatSetting);
} }
PpsUserSession session = context.getSession(PpsUserSession.class);
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
PpsUserSession session = context.getSession(PpsUserSession.class);
//关闭当前基础制度 //关闭当前基础制度
mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>() mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>()
.eq(SpaceInstitutionDetailEnt::getOuId, ouId) .eq(SpaceInstitutionDetailEnt::getOuId, input.getOuId())
.eq(SpaceInstitutionDetailEnt::getLineId, lineId) .eq(SpaceInstitutionDetailEnt::getLineId, input.getLineId())
.eq(SpaceInstitutionDetailEnt::getIsCurrentBasic, BusinessConstant.ZERO) .eq(SpaceInstitutionDetailEnt::getIsCurrentBasic, BusinessConstant.ZERO)
.set(SpaceInstitutionDetailEnt::getIsCurrentBasic, BusinessConstant.ONE) .set(SpaceInstitutionDetailEnt::getIsCurrentBasic, BusinessConstant.ONE)
.set(BaseModel::getModifyById, session.getId()) .set(BaseModel::getModifyById, session.getId())
...@@ -339,7 +334,7 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService { ...@@ -339,7 +334,7 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
); );
//设定当前制度为基础制度 //设定当前制度为基础制度
mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>() mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>()
.eq(BaseModel::getId, institutionId) .eq(BaseModel::getId, input.getId())
.set(SpaceInstitutionDetailEnt::getIsCurrentBasic, BusinessConstant.ZERO) .set(SpaceInstitutionDetailEnt::getIsCurrentBasic, BusinessConstant.ZERO)
.set(BaseModel::getModifyById, session.getId()) .set(BaseModel::getModifyById, session.getId())
.set(BaseModel::getModifyByName, session.getUserName()) .set(BaseModel::getModifyByName, session.getUserName())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment