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::getIsEnable, 1)
);
if (projectBimface == null) {
throw new OpenAlertException("未启用模型");
}
BimfaceClient bimfaceClient = this.getBimfaceClientByProjectSn(projectSn);
Long fileId = projectBimface.getFileId();
String status = this.getFileStatus(bimfaceClient, fileId);

View File

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

View File

@ -141,7 +141,7 @@ public class GouliPkpmModelController {
@ApiOperation(value = "设置成主模型", notes = "设置成主模型", httpMethod = "POST")
@ApiImplicitParams({
@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")
public Result setEnableMainModel(@RequestBody @ApiIgnore GouliPkpmModel gouliPkpmModel) {

View File

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

View File

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

View File

@ -32,18 +32,24 @@ public class SmartBeamFieldBeamToSaveBeamPedestal implements Serializable {
@Excel(name = "智慧梁场-存梁台座id", width = 15)
@ApiModelProperty(value = "智慧梁场-存梁台座id")
private java.lang.Long smartBeamFieldSaveBeamPedestalId;
/**智慧梁场-梁id*/
@Excel(name = "智慧梁场-梁id", width = 15)
@ApiModelProperty(value="智慧梁场-梁id")
private java.lang.Long smartBeamFieldBeamId ;
/**现在是否存梁*/
@Excel(name = "现在是否存梁", width = 15)
@ApiModelProperty(value="现在是否存梁")
private java.lang.Integer isSaveBeam ;
/**项目sn*/
@Excel(name = "项目sn", width = 15)
@ApiModelProperty(value="项目sn")
private java.lang.String projectSn ;
/**
* 智慧梁场-梁id
*/
@Excel(name = "智慧梁场-梁id", width = 15)
@ApiModelProperty(value = "智慧梁场-梁id")
private java.lang.Long smartBeamFieldBeamId;
/**
* 现在是否存梁
*/
@Excel(name = "现在是否存梁", width = 15)
@ApiModelProperty(value = "现在是否存梁")
private java.lang.Boolean isSaveBeam;
/**
* 项目sn
*/
@Excel(name = "项目sn", width = 15)
@ApiModelProperty(value = "项目sn")
private java.lang.String projectSn;
/**创建时间 yyyy-MM-dd HH:mm:ss*/
@Excel(name = "创建时间 yyyy-MM-dd HH:mm:ss", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

View File

@ -11,7 +11,8 @@
</select>
<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
join smart_beam_field_make_beam_pedestal_to_process mbptp on mbptp.smart_beam_field_make_beam_pedestal_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.extension.plugins.pagination.Page;
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.system.query.QueryGenerator;
import com.zhgd.xmgl.modules.smartbeamfield.entity.SmartBeamFieldBeam;
@ -97,6 +98,14 @@ public class SmartBeamFieldBeamServiceImpl extends ServiceImpl<SmartBeamFieldBea
public void edit(SmartBeamFieldBeam 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);
}
@ -132,7 +141,9 @@ public class SmartBeamFieldBeamServiceImpl extends ServiceImpl<SmartBeamFieldBea
smartBeamFieldBeam.setSmartBeamFieldProductionLineId(smartBeamFieldProductionLineId);
baseMapper.updateById(smartBeamFieldBeam);
//插入梁和工序中间表
//删除和插入梁和工序中间表
smartBeamFieldBeamToProcessMapper.delete(new LambdaQueryWrapper<SmartBeamFieldBeamToProcess>()
.eq(SmartBeamFieldBeamToProcess::getSmartBeamFieldBeamId, smartBeamFieldBeamId));
List<SmartBeamFieldProcess> smartBeamFieldProcessList = smartBeamFieldProcessMapper.getProcessAndMakeBeamPedestalByLineId(smartBeamFieldProductionLineId);
for (SmartBeamFieldProcess process : smartBeamFieldProcessList) {
SmartBeamFieldBeamToProcess beamProcess = new SmartBeamFieldBeamToProcess();
@ -176,9 +187,14 @@ public class SmartBeamFieldBeamServiceImpl extends ServiceImpl<SmartBeamFieldBea
SmartBeamFieldBeamToSaveBeamPedestal saveBeamPedestalBeam = new SmartBeamFieldBeamToSaveBeamPedestal();
saveBeamPedestalBeam.setSmartBeamFieldSaveBeamPedestalId(smartBeamFieldSaveBeamPedestalId);
saveBeamPedestalBeam.setSmartBeamFieldBeamId(smartBeamFieldBeamId);
saveBeamPedestalBeam.setIsSaveBeam(1);
saveBeamPedestalBeam.setIsSaveBeam(true);
saveBeamPedestalBeam.setProjectSn(beam.getProjectSn());
smartBeamFieldBeamToSaveBeamPedestalMapper.insert(saveBeamPedestalBeam);
//释放生产线
smartBeamFieldBeamMapper.update(null, new LambdaUpdateWrapper<SmartBeamFieldBeam>()
.set(SmartBeamFieldBeam::getUseProductionLine, 0)
.eq(SmartBeamFieldBeam::getId, smartBeamFieldBeamId));
}
@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.extension.plugins.pagination.Page;
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.xmgl.modules.smartbeamfield.entity.SmartBeamFieldBeam;
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.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description: 智慧梁场-梁和工序中间表
@ -75,15 +75,19 @@ public class SmartBeamFieldBeamToProcessServiceImpl extends ServiceImpl<SmartBea
private void setBeamStatus(SmartBeamFieldBeamToProcess smartBeamFieldBeamToProcess) {
//判断梁是否完成
Long smartBeamFieldBeamId = smartBeamFieldBeamToProcess.getSmartBeamFieldBeamId();
List<SmartBeamFieldBeamToProcess> smartBeamFieldBeamToProcesses = smartBeamFieldBeamToProcessMapper.selectList(new LambdaQueryWrapper<SmartBeamFieldBeamToProcess>()
List<SmartBeamFieldBeamToProcess> allList = smartBeamFieldBeamToProcessMapper.selectList(new LambdaQueryWrapper<SmartBeamFieldBeamToProcess>()
.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;
if (CollUtil.isEmpty(smartBeamFieldBeamToProcesses)) {
status = 3;
} else {
} else if (CollUtil.isNotEmpty(pes)) {
status = 2;
} else {
status = 1;
}
smartBeamFieldBeamMapper.update(null, new LambdaUpdateWrapper<SmartBeamFieldBeam>().set(SmartBeamFieldBeam::getBeamMakeStatus, status)
.eq(SmartBeamFieldBeam::getId, smartBeamFieldBeamId));

View File

@ -73,27 +73,12 @@ public class SmartBeamFieldSaveBeamDistrictServiceImpl extends ServiceImpl<Smart
@Override
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);
baseMapper.insert(smartBeamFieldSaveBeamDistrict);
}
@Override
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);
}

View File

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

View File

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

View File

@ -191,8 +191,7 @@ public class StableWaterMixStationData implements Serializable {
@Excel(name = "删除标识 Y已删除N未删除", width = 15)
@ApiModelProperty(value = "删除标识 Y已删除N未删除")
private java.lang.String scbz;
@ApiModelProperty(value = "删除标识名称")
private java.lang.String scbzName;
/**
* 生产时间 / 发料时间
@ -238,4 +237,8 @@ public class StableWaterMixStationData implements Serializable {
@TableField(exist = false)
@ApiModelProperty(value = "设备名称")
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));
}
@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;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.data.HmacRestAuthInfo;
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.NoAuthenticateException;
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.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.util.ThirdPartRequestUtil;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.core.SchedulerLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
@ -37,28 +45,42 @@ public class StableWaterMixStationTask {
@Autowired
IStableWaterMixStationDataService stableWaterMixStationDataService;
@Autowired
StableWaterMixStationDataMapper stableWaterMixStationDataMapper;
@Autowired
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)
@GetMapping("1204") // to do
@GetMapping("s/1205")
public void executeTask() {
log.info("定时拉取广联达的搅拌站数据任务开始");
List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>()
.isNotNull(Project::getGldProjectId)
.ne(Project::getGldProjectId, "")
.isNotNull(Project::getGldLicPath)
.ne(Project::getGldLicPath, "")
);
//for (Project project : projects) {
sendHttp(null);
//}
for (Project project : projects) {
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 {
log.info("定时拉取广联达的搅拌站数据任务开始:项目名称:{} 项目sn{} timestamp{}", project.getProjectName(), project.getProjectSn(), timestamp);
/**----------------准备 -------------------*/
//第1步下载授权文件
//第2步获取SDK
@ -70,8 +92,7 @@ public class StableWaterMixStationTask {
//4.1构建认证信息
HmacRestAuthInfo restAuthInfo = new HmacRestAuthInfo();
//4.2设置授权文件路径
restAuthInfo.setLicPath("C:\\Users\\Administrator\\Desktop\\t\\auth.lic");
//restAuthInfo.setLicPath(project.getGldLicPath());
restAuthInfo.setLicPath(project.getGldLicPath());
//4.3权限认证
serviceClient.authenticate(restAuthInfo);
@ -79,9 +100,7 @@ public class StableWaterMixStationTask {
//第5步获取授权文件关联的GYS系统地址hostAddress
String hostAddress = serviceClient.getRestRootAddress();
//第6步设置请求接口的URI地址apiURI(以获取集成项目列表信息为例)
String apiURI = "/api/inspection/v1.0/project/getTenantHasCodeProject";
//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());
String apiURI = String.format("/api/mix/v1.0/mix/product/getMachineProductList?beginTimestamp=%s", timestamp);
//第7步拼装完整的请求网址
String fullURL = hostAddress + apiURI;
//第8步请求数据准备本例中为从GYS系统获取数据无需进行请求数据的准备
@ -96,11 +115,23 @@ public class StableWaterMixStationTask {
if (restResponseInfo.isSuccess()) {
//请求成功
//第10步处理请求结果第三方系统自行处理
System.out.println(restResponseInfo.getStringContent());
save(restResponseInfo.getStringContent(), project);
String stringContent = restResponseInfo.getStringContent();
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 {
//请求失败:
//第11步根据返回结果排查失败原因数据原因第三方系统自行处理
log.error("失败未知原因2");
}
} catch (AuthenticateException e) {
e.printStackTrace();
@ -111,37 +142,37 @@ public class StableWaterMixStationTask {
}
}
private void save(String stringContent, Project project) {
//String projectId = "672804614860800";
//String url = String.format("/api/mix/v1.0/mix/product/getMachineProductList?projectId=%s&beginTimestamp=20170710101010000", projectId);
//String rs = thirdPartRequestUtil.get(url);
//JSONObject jo = JSON.parseObject(rs);
//if (Objects.equals(jo.getBoolean("success"), true)) {
// JSONObject dataJson = jo.getJSONObject("data");
// JSONArray bills = dataJson.getJSONArray("Bills");
// for (Object bill : bills) {
// StableWaterMixStationData data = new StableWaterMixStationData();
// List<StableWaterMixStationSetData> setDataList = new ArrayList<>();
// data.setSetDataList(setDataList);
// BeanUtil.copyProperties(bill, data, true);
// JSONArray pcList = ((JSONObject) bill).getJSONArray("PCList");
// for (Object pc : pcList) {
// StableWaterMixStationSetData setData = new StableWaterMixStationSetData();
// BeanUtil.copyProperties(pc, setData, true);
// setDataList.add(setData);
// List<StableWaterMixStationRawMaterialData> rawMaterialDataList = new ArrayList<>();
// setData.setRawMaterialDataList(rawMaterialDataList);
// JSONArray ycList = ((JSONObject) pc).getJSONArray("YCList");
// for (Object yc : ycList) {
// StableWaterMixStationRawMaterialData rawMaterialData = new StableWaterMixStationRawMaterialData();
// BeanUtil.copyProperties(yc, rawMaterialData, true);
// rawMaterialDataList.add(rawMaterialData);
// }
// }
// stableWaterMixStationDataService.add(data);
// }
//}
private void saveData(JSONObject dataJo, Project project) {
//保存拌合站设备一个项目级别的授权文件对应我们的一个项目他们的一个项目有多个拌合站属性是projectId和我们设备对应一个拌合站有多个机组我们不体现
//保存拌合站数据
JSONArray bills = dataJo.getJSONArray("Bills");
for (Object bill : bills) {
StableWaterMixStationData data = new StableWaterMixStationData();
List<StableWaterMixStationSetData> setDataList = new ArrayList<>();
data.setSetDataList(setDataList);
BeanUtil.copyProperties(bill, data, true);
data.setDevSn(((JSONObject) bill).getString("projectId"));
JSONArray pcList = ((JSONObject) bill).getJSONArray("PCList");
for (Object pc : pcList) {
StableWaterMixStationSetData setData = new StableWaterMixStationSetData();
BeanUtil.copyProperties(pc, setData, true);
setDataList.add(setData);
List<StableWaterMixStationRawMaterialData> rawMaterialDataList = new ArrayList<>();
setData.setRawMaterialDataList(rawMaterialDataList);
JSONArray ycList = ((JSONObject) pc).getJSONArray("YCList");
for (Object yc : ycList) {
StableWaterMixStationRawMaterialData rawMaterialData = new StableWaterMixStationRawMaterialData();
BeanUtil.copyProperties(yc, rawMaterialData, true);
rawMaterialDataList.add(rawMaterialData);
}
}
try {
stableWaterMixStationDataService.add(data);
} catch (Exception e) {
e.printStackTrace();
log.info("新增出错:{},编号:{}", e.getMessage(), data.getDevSn());
}
}
}
}