bug修复 每5分钟拉取广联达的搅拌站数据

This commit is contained in:
guo 2023-12-12 18:06:05 +08:00
parent e1980f0dd6
commit 512097514f
15 changed files with 150 additions and 94 deletions

View File

@ -188,6 +188,9 @@ public class ProjectBimfaceServiceImpl extends ServiceImpl<ProjectBimfaceMapper,
.eq(ProjectBimface::getProjectSn, projectSn) .eq(ProjectBimface::getProjectSn, projectSn)
.eq(ProjectBimface::getIsEnable, 1) .eq(ProjectBimface::getIsEnable, 1)
); );
if (projectBimface == null) {
throw new OpenAlertException("未启用模型");
}
BimfaceClient bimfaceClient = this.getBimfaceClientByProjectSn(projectSn); BimfaceClient bimfaceClient = this.getBimfaceClientByProjectSn(projectSn);
Long fileId = projectBimface.getFileId(); Long fileId = projectBimface.getFileId();
String status = this.getFileStatus(bimfaceClient, fileId); String status = this.getFileStatus(bimfaceClient, fileId);

View File

@ -22,6 +22,7 @@ import java.util.List;
/** /**
* @Title: Controller * @Title: Controller
* @Description: 构力pkpm-配置信息表 * @Description: 构力pkpm-配置信息表
* BIMBASE
* @author pds * @author pds
* @date 2023-12-08 * @date 2023-12-08
* @version V1.0 * @version V1.0

View File

@ -141,7 +141,7 @@ public class GouliPkpmModelController {
@ApiOperation(value = "设置成主模型", notes = "设置成主模型", httpMethod = "POST") @ApiOperation(value = "设置成主模型", notes = "设置成主模型", httpMethod = "POST")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"), @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "urn", value = "文件标识", paramType = "body", required = true, dataType = "String"), @ApiImplicitParam(name = "id", value = "id", paramType = "body", required = true, dataType = "String"),
}) })
@PostMapping(value = "/setEnableMainModel") @PostMapping(value = "/setEnableMainModel")
public Result setEnableMainModel(@RequestBody @ApiIgnore GouliPkpmModel gouliPkpmModel) { public Result setEnableMainModel(@RequestBody @ApiIgnore GouliPkpmModel gouliPkpmModel) {

View File

@ -94,13 +94,16 @@ public class GouliPkpmModelServiceImpl extends ServiceImpl<GouliPkpmModelMapper,
@Override @Override
public void setEnableMainModel(GouliPkpmModel gouliPkpmModel) { public void setEnableMainModel(GouliPkpmModel gouliPkpmModel) {
GouliPkpmModel m = gouliPkpmModelMapper.selectById(gouliPkpmModel.getId());
if (m == null) {
throw new OpenAlertException("无数据");
}
gouliPkpmModelMapper.update(null, new LambdaUpdateWrapper<GouliPkpmModel>() gouliPkpmModelMapper.update(null, new LambdaUpdateWrapper<GouliPkpmModel>()
.set(GouliPkpmModel::getIsEnable, 0) .set(GouliPkpmModel::getIsEnable, 0)
.eq(GouliPkpmModel::getProjectSn, gouliPkpmModel.getProjectSn())); .eq(GouliPkpmModel::getProjectSn, gouliPkpmModel.getProjectSn()));
gouliPkpmModelMapper.update(null, new LambdaUpdateWrapper<GouliPkpmModel>() gouliPkpmModelMapper.update(null, new LambdaUpdateWrapper<GouliPkpmModel>()
.set(GouliPkpmModel::getIsEnable, 1) .set(GouliPkpmModel::getIsEnable, 1)
.eq(GouliPkpmModel::getProjectSn, gouliPkpmModel.getProjectSn()) .eq(GouliPkpmModel::getId, m.getId())
.eq(GouliPkpmModel::getUrn, gouliPkpmModel.getUrn())
); );
} }
} }

View File

@ -275,8 +275,6 @@ public class Project implements Serializable {
private String xiwonAppSecret; private String xiwonAppSecret;
@ApiModelProperty(value = "bim的Url") @ApiModelProperty(value = "bim的Url")
private String bimUrl; private String bimUrl;
@ApiModelProperty(value = "广联达项目id")
private String gldProjectId;
@ApiModelProperty(value = "广联达授权文件路径") @ApiModelProperty(value = "广联达授权文件路径")
private String gldLicPath; private String gldLicPath;
@ApiModelProperty(value = "新大屏地址(没有填则跳旧大屏)") @ApiModelProperty(value = "新大屏地址(没有填则跳旧大屏)")

View File

@ -32,15 +32,21 @@ public class SmartBeamFieldBeamToSaveBeamPedestal implements Serializable {
@Excel(name = "智慧梁场-存梁台座id", width = 15) @Excel(name = "智慧梁场-存梁台座id", width = 15)
@ApiModelProperty(value = "智慧梁场-存梁台座id") @ApiModelProperty(value = "智慧梁场-存梁台座id")
private java.lang.Long smartBeamFieldSaveBeamPedestalId; private java.lang.Long smartBeamFieldSaveBeamPedestalId;
/**智慧梁场-梁id*/ /**
* 智慧梁场-梁id
*/
@Excel(name = "智慧梁场-梁id", width = 15) @Excel(name = "智慧梁场-梁id", width = 15)
@ApiModelProperty(value = "智慧梁场-梁id") @ApiModelProperty(value = "智慧梁场-梁id")
private java.lang.Long smartBeamFieldBeamId; private java.lang.Long smartBeamFieldBeamId;
/**现在是否存梁*/ /**
* 现在是否存梁
*/
@Excel(name = "现在是否存梁", width = 15) @Excel(name = "现在是否存梁", width = 15)
@ApiModelProperty(value = "现在是否存梁") @ApiModelProperty(value = "现在是否存梁")
private java.lang.Integer isSaveBeam ; private java.lang.Boolean isSaveBeam;
/**项目sn*/ /**
* 项目sn
*/
@Excel(name = "项目sn", width = 15) @Excel(name = "项目sn", width = 15)
@ApiModelProperty(value = "项目sn") @ApiModelProperty(value = "项目sn")
private java.lang.String projectSn; private java.lang.String projectSn;

View File

@ -11,7 +11,8 @@
</select> </select>
<select id="queryList" resultType="com.zhgd.xmgl.modules.smartbeamfield.entity.SmartBeamFieldMakeBeamPedestal"> <select id="queryList" resultType="com.zhgd.xmgl.modules.smartbeamfield.entity.SmartBeamFieldMakeBeamPedestal">
select mbp.*, group_concat(p.process_name) pedestalProcess,if(sbfpltmbp.id is null,0,1) bindByProductionLine select mbp.*, group_concat(p.process_name ORDER BY mbptp.id) pedestalProcess,if(sbfpltmbp.id is null,0,1)
bindByProductionLine
from smart_beam_field_make_beam_pedestal mbp from smart_beam_field_make_beam_pedestal mbp
join smart_beam_field_make_beam_pedestal_to_process mbptp on mbptp.smart_beam_field_make_beam_pedestal_id = join smart_beam_field_make_beam_pedestal_to_process mbptp on mbptp.smart_beam_field_make_beam_pedestal_id =
mbp.id mbp.id

View File

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Objects;
import com.zhgd.jeecg.common.execption.OpenAlertException; import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.jeecg.common.system.query.QueryGenerator; import com.zhgd.jeecg.common.system.query.QueryGenerator;
import com.zhgd.xmgl.modules.smartbeamfield.entity.SmartBeamFieldBeam; import com.zhgd.xmgl.modules.smartbeamfield.entity.SmartBeamFieldBeam;
@ -97,6 +98,14 @@ public class SmartBeamFieldBeamServiceImpl extends ServiceImpl<SmartBeamFieldBea
public void edit(SmartBeamFieldBeam smartBeamFieldBeam) { public void edit(SmartBeamFieldBeam smartBeamFieldBeam) {
//架梁状态 //架梁状态
smartBeamFieldBeam.setBeamErectionStatus(getStatus(smartBeamFieldBeam)); smartBeamFieldBeam.setBeamErectionStatus(getStatus(smartBeamFieldBeam));
//已架梁则释放存梁台座
if (Objects.equal(3, smartBeamFieldBeam.getBeamErectionStatus())) {
smartBeamFieldBeamToSaveBeamPedestalMapper.update(null, new LambdaUpdateWrapper<SmartBeamFieldBeamToSaveBeamPedestal>()
.set(SmartBeamFieldBeamToSaveBeamPedestal::getIsSaveBeam, 0)
.eq(SmartBeamFieldBeamToSaveBeamPedestal::getSmartBeamFieldBeamId, smartBeamFieldBeam.getId())
);
}
baseMapper.updateById(smartBeamFieldBeam); baseMapper.updateById(smartBeamFieldBeam);
} }
@ -132,7 +141,9 @@ public class SmartBeamFieldBeamServiceImpl extends ServiceImpl<SmartBeamFieldBea
smartBeamFieldBeam.setSmartBeamFieldProductionLineId(smartBeamFieldProductionLineId); smartBeamFieldBeam.setSmartBeamFieldProductionLineId(smartBeamFieldProductionLineId);
baseMapper.updateById(smartBeamFieldBeam); baseMapper.updateById(smartBeamFieldBeam);
//插入梁和工序中间表 //删除和插入梁和工序中间表
smartBeamFieldBeamToProcessMapper.delete(new LambdaQueryWrapper<SmartBeamFieldBeamToProcess>()
.eq(SmartBeamFieldBeamToProcess::getSmartBeamFieldBeamId, smartBeamFieldBeamId));
List<SmartBeamFieldProcess> smartBeamFieldProcessList = smartBeamFieldProcessMapper.getProcessAndMakeBeamPedestalByLineId(smartBeamFieldProductionLineId); List<SmartBeamFieldProcess> smartBeamFieldProcessList = smartBeamFieldProcessMapper.getProcessAndMakeBeamPedestalByLineId(smartBeamFieldProductionLineId);
for (SmartBeamFieldProcess process : smartBeamFieldProcessList) { for (SmartBeamFieldProcess process : smartBeamFieldProcessList) {
SmartBeamFieldBeamToProcess beamProcess = new SmartBeamFieldBeamToProcess(); SmartBeamFieldBeamToProcess beamProcess = new SmartBeamFieldBeamToProcess();
@ -176,9 +187,14 @@ public class SmartBeamFieldBeamServiceImpl extends ServiceImpl<SmartBeamFieldBea
SmartBeamFieldBeamToSaveBeamPedestal saveBeamPedestalBeam = new SmartBeamFieldBeamToSaveBeamPedestal(); SmartBeamFieldBeamToSaveBeamPedestal saveBeamPedestalBeam = new SmartBeamFieldBeamToSaveBeamPedestal();
saveBeamPedestalBeam.setSmartBeamFieldSaveBeamPedestalId(smartBeamFieldSaveBeamPedestalId); saveBeamPedestalBeam.setSmartBeamFieldSaveBeamPedestalId(smartBeamFieldSaveBeamPedestalId);
saveBeamPedestalBeam.setSmartBeamFieldBeamId(smartBeamFieldBeamId); saveBeamPedestalBeam.setSmartBeamFieldBeamId(smartBeamFieldBeamId);
saveBeamPedestalBeam.setIsSaveBeam(1); saveBeamPedestalBeam.setIsSaveBeam(true);
saveBeamPedestalBeam.setProjectSn(beam.getProjectSn()); saveBeamPedestalBeam.setProjectSn(beam.getProjectSn());
smartBeamFieldBeamToSaveBeamPedestalMapper.insert(saveBeamPedestalBeam); smartBeamFieldBeamToSaveBeamPedestalMapper.insert(saveBeamPedestalBeam);
//释放生产线
smartBeamFieldBeamMapper.update(null, new LambdaUpdateWrapper<SmartBeamFieldBeam>()
.set(SmartBeamFieldBeam::getUseProductionLine, 0)
.eq(SmartBeamFieldBeam::getId, smartBeamFieldBeamId));
} }
@Override @Override

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Objects;
import com.zhgd.jeecg.common.system.query.QueryGenerator; import com.zhgd.jeecg.common.system.query.QueryGenerator;
import com.zhgd.xmgl.modules.smartbeamfield.entity.SmartBeamFieldBeam; import com.zhgd.xmgl.modules.smartbeamfield.entity.SmartBeamFieldBeam;
import com.zhgd.xmgl.modules.smartbeamfield.entity.SmartBeamFieldBeamToProcess; import com.zhgd.xmgl.modules.smartbeamfield.entity.SmartBeamFieldBeamToProcess;
@ -23,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @Description: 智慧梁场-梁和工序中间表 * @Description: 智慧梁场-梁和工序中间表
@ -75,15 +75,19 @@ public class SmartBeamFieldBeamToProcessServiceImpl extends ServiceImpl<SmartBea
private void setBeamStatus(SmartBeamFieldBeamToProcess smartBeamFieldBeamToProcess) { private void setBeamStatus(SmartBeamFieldBeamToProcess smartBeamFieldBeamToProcess) {
//判断梁是否完成 //判断梁是否完成
Long smartBeamFieldBeamId = smartBeamFieldBeamToProcess.getSmartBeamFieldBeamId(); Long smartBeamFieldBeamId = smartBeamFieldBeamToProcess.getSmartBeamFieldBeamId();
List<SmartBeamFieldBeamToProcess> smartBeamFieldBeamToProcesses = smartBeamFieldBeamToProcessMapper.selectList(new LambdaQueryWrapper<SmartBeamFieldBeamToProcess>() List<SmartBeamFieldBeamToProcess> allList = smartBeamFieldBeamToProcessMapper.selectList(new LambdaQueryWrapper<SmartBeamFieldBeamToProcess>()
.eq(SmartBeamFieldBeamToProcess::getSmartBeamFieldBeamId, smartBeamFieldBeamId) .eq(SmartBeamFieldBeamToProcess::getSmartBeamFieldBeamId, smartBeamFieldBeamId)
.in(SmartBeamFieldBeamToProcess::getStatus, Stream.of(1, 2).collect(Collectors.toList()))
); );
List<SmartBeamFieldBeamToProcess> smartBeamFieldBeamToProcesses = allList.stream().filter(p -> Objects.equal(p.getStatus(), 1) || Objects.equal(p.getStatus(), 2)).collect(Collectors.toList());
List<SmartBeamFieldBeamToProcess> pes = allList.stream().filter(p -> Objects.equal(2, p.getStatus()) || Objects.equal(3, p.getStatus())).collect(Collectors.toList());
int status; int status;
if (CollUtil.isEmpty(smartBeamFieldBeamToProcesses)) { if (CollUtil.isEmpty(smartBeamFieldBeamToProcesses)) {
status = 3; status = 3;
} else { } else if (CollUtil.isNotEmpty(pes)) {
status = 2; status = 2;
} else {
status = 1;
} }
smartBeamFieldBeamMapper.update(null, new LambdaUpdateWrapper<SmartBeamFieldBeam>().set(SmartBeamFieldBeam::getBeamMakeStatus, status) smartBeamFieldBeamMapper.update(null, new LambdaUpdateWrapper<SmartBeamFieldBeam>().set(SmartBeamFieldBeam::getBeamMakeStatus, status)
.eq(SmartBeamFieldBeam::getId, smartBeamFieldBeamId)); .eq(SmartBeamFieldBeam::getId, smartBeamFieldBeamId));

View File

@ -73,27 +73,12 @@ public class SmartBeamFieldSaveBeamDistrictServiceImpl extends ServiceImpl<Smart
@Override @Override
public void add(SmartBeamFieldSaveBeamDistrict smartBeamFieldSaveBeamDistrict) { public void add(SmartBeamFieldSaveBeamDistrict smartBeamFieldSaveBeamDistrict) {
SmartBeamFieldSaveBeamDistrict d = smartBeamFieldSaveBeamDistrictMapper.selectOne(new LambdaQueryWrapper<SmartBeamFieldSaveBeamDistrict>()
.eq(SmartBeamFieldSaveBeamDistrict::getProjectSn, smartBeamFieldSaveBeamDistrict.getProjectSn())
.eq(SmartBeamFieldSaveBeamDistrict::getSaveBeamDistrictName, smartBeamFieldSaveBeamDistrict.getSaveBeamDistrictName())
);
if (d != null) {
throw new OpenAlertException("存梁区名称已存在");
}
smartBeamFieldSaveBeamDistrict.setId(null); smartBeamFieldSaveBeamDistrict.setId(null);
baseMapper.insert(smartBeamFieldSaveBeamDistrict); baseMapper.insert(smartBeamFieldSaveBeamDistrict);
} }
@Override @Override
public void edit(SmartBeamFieldSaveBeamDistrict smartBeamFieldSaveBeamDistrict) { public void edit(SmartBeamFieldSaveBeamDistrict smartBeamFieldSaveBeamDistrict) {
SmartBeamFieldSaveBeamDistrict d = smartBeamFieldSaveBeamDistrictMapper.selectOne(new LambdaQueryWrapper<SmartBeamFieldSaveBeamDistrict>()
.eq(SmartBeamFieldSaveBeamDistrict::getProjectSn, smartBeamFieldSaveBeamDistrict.getProjectSn())
.eq(SmartBeamFieldSaveBeamDistrict::getSaveBeamDistrictName, smartBeamFieldSaveBeamDistrict.getSaveBeamDistrictName())
.ne(SmartBeamFieldSaveBeamDistrict::getId, smartBeamFieldSaveBeamDistrict.getId())
);
if (d != null) {
throw new OpenAlertException("存梁区名称已存在");
}
baseMapper.updateById(smartBeamFieldSaveBeamDistrict); baseMapper.updateById(smartBeamFieldSaveBeamDistrict);
} }

View File

@ -157,7 +157,7 @@ public class SmartBeamFieldSaveBeamPedestalServiceImpl extends ServiceImpl<Smart
throw new OpenAlertException("beamList[i].id智慧梁场-梁id不能为空"); throw new OpenAlertException("beamList[i].id智慧梁场-梁id不能为空");
} }
smartBeamFieldBeamToSaveBeamPedestal.setSmartBeamFieldBeamId(id1); smartBeamFieldBeamToSaveBeamPedestal.setSmartBeamFieldBeamId(id1);
smartBeamFieldBeamToSaveBeamPedestal.setIsSaveBeam(1); smartBeamFieldBeamToSaveBeamPedestal.setIsSaveBeam(true);
smartBeamFieldBeamToSaveBeamPedestal.setProjectSn(projectSn); smartBeamFieldBeamToSaveBeamPedestal.setProjectSn(projectSn);
smartBeamFieldBeamToSaveBeamPedestalMapper.insert(smartBeamFieldBeamToSaveBeamPedestal); smartBeamFieldBeamToSaveBeamPedestalMapper.insert(smartBeamFieldBeamToSaveBeamPedestal);
} }

View File

@ -173,9 +173,9 @@ public class SmartGroutSteelBeamData implements Serializable {
public static class GroutCurve { public static class GroutCurve {
@ApiModelProperty(value = "x轴的值") @ApiModelProperty(value = "x轴的值")
private String xAxis; private String xAxis;
@ApiModelProperty(value = "进浆的值") @ApiModelProperty(value = "进浆压力的值")
private Double inputGrout; private Double inputGrout;
@ApiModelProperty(value = "出浆的值") @ApiModelProperty(value = "出浆压力的值")
private Double dischargeGrout; private Double dischargeGrout;
@ApiModelProperty(value = "进浆量的值") @ApiModelProperty(value = "进浆量的值")
private Double inputGroutAmount; private Double inputGroutAmount;

View File

@ -191,8 +191,7 @@ public class StableWaterMixStationData implements Serializable {
@Excel(name = "删除标识 Y已删除N未删除", width = 15) @Excel(name = "删除标识 Y已删除N未删除", width = 15)
@ApiModelProperty(value = "删除标识 Y已删除N未删除") @ApiModelProperty(value = "删除标识 Y已删除N未删除")
private java.lang.String scbz; private java.lang.String scbz;
@ApiModelProperty(value = "删除标识名称")
private java.lang.String scbzName;
/** /**
* 生产时间 / 发料时间 * 生产时间 / 发料时间
@ -238,4 +237,8 @@ public class StableWaterMixStationData implements Serializable {
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "设备名称") @ApiModelProperty(value = "设备名称")
private java.lang.String devName; private java.lang.String devName;
@TableField(exist = false)
@ApiModelProperty(value = "删除标识名称")
private java.lang.String scbzName;
} }

View File

@ -259,5 +259,10 @@ public class TaskProgressController {
return Result.success(taskProgressService.countMppStatus(paramMap)); return Result.success(taskProgressService.countMppStatus(paramMap));
} }
@ApiOperation(value = "编辑任务进度的bim构件", notes = "编辑任务进度的bim构件", httpMethod = "POST")
@PostMapping(value = "/editBimComponent")
public Result<TaskProgress> editBimComponent(@RequestBody TaskProgress taskProgress) {
taskProgressService.updateById(taskProgress);
return Result.ok();
}
} }

View File

@ -1,7 +1,10 @@
package com.zhgd.xmgl.task; package com.zhgd.xmgl.task;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gexin.fastjson.JSON; import com.gexin.fastjson.JSON;
import com.gexin.fastjson.JSONArray;
import com.gexin.fastjson.JSONObject;
import com.glodon.cloudt.rest.client.RestServiceClient; import com.glodon.cloudt.rest.client.RestServiceClient;
import com.glodon.cloudt.rest.client.data.HmacRestAuthInfo; import com.glodon.cloudt.rest.client.data.HmacRestAuthInfo;
import com.glodon.cloudt.rest.client.data.RestResponseInfo; import com.glodon.cloudt.rest.client.data.RestResponseInfo;
@ -9,20 +12,25 @@ import com.glodon.cloudt.rest.client.exception.AuthenticateException;
import com.glodon.cloudt.rest.client.exception.InvalidUriException; import com.glodon.cloudt.rest.client.exception.InvalidUriException;
import com.glodon.cloudt.rest.client.exception.NoAuthenticateException; import com.glodon.cloudt.rest.client.exception.NoAuthenticateException;
import com.glodon.cloudt.rest.client.impl.HmacRestServiceClient; import com.glodon.cloudt.rest.client.impl.HmacRestServiceClient;
import com.google.common.base.Objects;
import com.zhgd.xmgl.modules.project.entity.Project; import com.zhgd.xmgl.modules.project.entity.Project;
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper; import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationData;
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationRawMaterialData;
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationSetData;
import com.zhgd.xmgl.modules.stablewater.mapper.StableWaterMixStationDataMapper;
import com.zhgd.xmgl.modules.stablewater.service.IStableWaterMixStationDataService; import com.zhgd.xmgl.modules.stablewater.service.IStableWaterMixStationDataService;
import com.zhgd.xmgl.util.ThirdPartRequestUtil; import com.zhgd.xmgl.util.ThirdPartRequestUtil;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.core.SchedulerLock; import net.javacrumbs.shedlock.core.SchedulerLock;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -37,28 +45,42 @@ public class StableWaterMixStationTask {
@Autowired @Autowired
IStableWaterMixStationDataService stableWaterMixStationDataService; IStableWaterMixStationDataService stableWaterMixStationDataService;
@Autowired @Autowired
StableWaterMixStationDataMapper stableWaterMixStationDataMapper;
@Autowired
ProjectMapper projectMapper; ProjectMapper projectMapper;
/** /**
* 定时拉取广联达的搅拌站数据https://xmgl.glodon.com/wl/docs/third_help/part2/openapi/pull/mixTotal.html * 每5分钟拉取广联达的搅拌站数据https://xmgl.glodon.com/wl/docs/third_help/part2/openapi/pull/mixTotal.html
*/ */
@Scheduled(cron = "0 2 0 * * ?") @Scheduled(cron = "0 0/5 * * * ?")
@SchedulerLock(name = "executeStableWaterMixStationTask", lockAtMostFor = 1000 * 60 * 2, lockAtLeastFor = 1000 * 60 * 1) @SchedulerLock(name = "executeStableWaterMixStationTask", lockAtMostFor = 1000 * 60 * 2, lockAtLeastFor = 1000 * 60 * 1)
@GetMapping("1204") // to do @GetMapping("s/1205")
public void executeTask() { public void executeTask() {
log.info("定时拉取广联达的搅拌站数据任务开始"); log.info("定时拉取广联达的搅拌站数据任务开始");
List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>() List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>()
.isNotNull(Project::getGldProjectId) .isNotNull(Project::getGldLicPath)
.ne(Project::getGldProjectId, "") .ne(Project::getGldLicPath, "")
); );
//for (Project project : projects) { for (Project project : projects) {
sendHttp(null); StableWaterMixStationData data = stableWaterMixStationDataMapper.selectOne(new LambdaQueryWrapper<StableWaterMixStationData>()
//} .eq(StableWaterMixStationData::getProjectSn, project.getProjectSn())
.orderByDesc(StableWaterMixStationData::getTimestamp)
.last("limit 1")
);
String timestamp;
if (data != null) {
timestamp = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(data.getTimestamp());
} else {
timestamp = "20230101141314082";
}
sendHttp(project, timestamp);
}
} }
private void sendHttp(Project project) { private void sendHttp(Project project, String timestamp) {
try { try {
log.info("定时拉取广联达的搅拌站数据任务开始:项目名称:{} 项目sn{} timestamp{}", project.getProjectName(), project.getProjectSn(), timestamp);
/**----------------准备 -------------------*/ /**----------------准备 -------------------*/
//第1步下载授权文件 //第1步下载授权文件
//第2步获取SDK //第2步获取SDK
@ -70,8 +92,7 @@ public class StableWaterMixStationTask {
//4.1构建认证信息 //4.1构建认证信息
HmacRestAuthInfo restAuthInfo = new HmacRestAuthInfo(); HmacRestAuthInfo restAuthInfo = new HmacRestAuthInfo();
//4.2设置授权文件路径 //4.2设置授权文件路径
restAuthInfo.setLicPath("C:\\Users\\Administrator\\Desktop\\t\\auth.lic"); restAuthInfo.setLicPath(project.getGldLicPath());
//restAuthInfo.setLicPath(project.getGldLicPath());
//4.3权限认证 //4.3权限认证
serviceClient.authenticate(restAuthInfo); serviceClient.authenticate(restAuthInfo);
@ -79,9 +100,7 @@ public class StableWaterMixStationTask {
//第5步获取授权文件关联的GYS系统地址hostAddress //第5步获取授权文件关联的GYS系统地址hostAddress
String hostAddress = serviceClient.getRestRootAddress(); String hostAddress = serviceClient.getRestRootAddress();
//第6步设置请求接口的URI地址apiURI(以获取集成项目列表信息为例) //第6步设置请求接口的URI地址apiURI(以获取集成项目列表信息为例)
String apiURI = "/api/inspection/v1.0/project/getTenantHasCodeProject"; String apiURI = String.format("/api/mix/v1.0/mix/product/getMachineProductList?beginTimestamp=%s", timestamp);
//String apiURI = String.format("/api/mix/v1.0/mix/product/getMachineProductList?projectId=%s&beginTimestamp=20170710101010000", "672804614860800");
//String apiURI = String.format("/api/mix/v1.0/mix/product/getMachineProductList?projectId=%s&beginTimestamp=20170710101010000", project.getGldProjectId());
//第7步拼装完整的请求网址 //第7步拼装完整的请求网址
String fullURL = hostAddress + apiURI; String fullURL = hostAddress + apiURI;
//第8步请求数据准备本例中为从GYS系统获取数据无需进行请求数据的准备 //第8步请求数据准备本例中为从GYS系统获取数据无需进行请求数据的准备
@ -96,11 +115,23 @@ public class StableWaterMixStationTask {
if (restResponseInfo.isSuccess()) { if (restResponseInfo.isSuccess()) {
//请求成功 //请求成功
//第10步处理请求结果第三方系统自行处理 //第10步处理请求结果第三方系统自行处理
System.out.println(restResponseInfo.getStringContent()); String stringContent = restResponseInfo.getStringContent();
save(restResponseInfo.getStringContent(), project); System.out.println(stringContent);
JSONObject scjo = JSON.parseObject(stringContent);
if (scjo.getBoolean("success")) {
saveData(scjo.getJSONObject("data"), project);
JSONObject dataJo = scjo.getJSONObject("data");
//继续发送http查询未保存的数据
if (!Objects.equal(dataJo.getInteger("PageSize"), 0)) {
sendHttp(project, dataJo.getString("MaxTimestamp"));
}
} else {
log.error("失败未知原因1");
}
} else { } else {
//请求失败: //请求失败:
//第11步根据返回结果排查失败原因数据原因第三方系统自行处理 //第11步根据返回结果排查失败原因数据原因第三方系统自行处理
log.error("失败未知原因2");
} }
} catch (AuthenticateException e) { } catch (AuthenticateException e) {
e.printStackTrace(); e.printStackTrace();
@ -111,37 +142,37 @@ public class StableWaterMixStationTask {
} }
} }
private void save(String stringContent, Project project) { private void saveData(JSONObject dataJo, Project project) {
//String projectId = "672804614860800"; //保存拌合站设备一个项目级别的授权文件对应我们的一个项目他们的一个项目有多个拌合站属性是projectId和我们设备对应一个拌合站有多个机组我们不体现
//String url = String.format("/api/mix/v1.0/mix/product/getMachineProductList?projectId=%s&beginTimestamp=20170710101010000", projectId); //保存拌合站数据
//String rs = thirdPartRequestUtil.get(url); JSONArray bills = dataJo.getJSONArray("Bills");
//JSONObject jo = JSON.parseObject(rs); for (Object bill : bills) {
//if (Objects.equals(jo.getBoolean("success"), true)) { StableWaterMixStationData data = new StableWaterMixStationData();
// JSONObject dataJson = jo.getJSONObject("data"); List<StableWaterMixStationSetData> setDataList = new ArrayList<>();
// JSONArray bills = dataJson.getJSONArray("Bills"); data.setSetDataList(setDataList);
// for (Object bill : bills) { BeanUtil.copyProperties(bill, data, true);
// StableWaterMixStationData data = new StableWaterMixStationData(); data.setDevSn(((JSONObject) bill).getString("projectId"));
// List<StableWaterMixStationSetData> setDataList = new ArrayList<>(); JSONArray pcList = ((JSONObject) bill).getJSONArray("PCList");
// data.setSetDataList(setDataList); for (Object pc : pcList) {
// BeanUtil.copyProperties(bill, data, true); StableWaterMixStationSetData setData = new StableWaterMixStationSetData();
// JSONArray pcList = ((JSONObject) bill).getJSONArray("PCList"); BeanUtil.copyProperties(pc, setData, true);
// for (Object pc : pcList) { setDataList.add(setData);
// StableWaterMixStationSetData setData = new StableWaterMixStationSetData(); List<StableWaterMixStationRawMaterialData> rawMaterialDataList = new ArrayList<>();
// BeanUtil.copyProperties(pc, setData, true); setData.setRawMaterialDataList(rawMaterialDataList);
// setDataList.add(setData); JSONArray ycList = ((JSONObject) pc).getJSONArray("YCList");
// List<StableWaterMixStationRawMaterialData> rawMaterialDataList = new ArrayList<>(); for (Object yc : ycList) {
// setData.setRawMaterialDataList(rawMaterialDataList); StableWaterMixStationRawMaterialData rawMaterialData = new StableWaterMixStationRawMaterialData();
// JSONArray ycList = ((JSONObject) pc).getJSONArray("YCList"); BeanUtil.copyProperties(yc, rawMaterialData, true);
// for (Object yc : ycList) { rawMaterialDataList.add(rawMaterialData);
// StableWaterMixStationRawMaterialData rawMaterialData = new StableWaterMixStationRawMaterialData(); }
// BeanUtil.copyProperties(yc, rawMaterialData, true); }
// rawMaterialDataList.add(rawMaterialData); try {
// } stableWaterMixStationDataService.add(data);
// } } catch (Exception e) {
// stableWaterMixStationDataService.add(data); e.printStackTrace();
// } log.info("新增出错:{},编号:{}", e.getMessage(), data.getDevSn());
//} }
}
} }
} }