|
@@ -0,0 +1,442 @@
|
|
|
+package com.rongwei.sfcommon.sys.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.rongwe.scentity.domian.ApsSpecialInspectionTaskDo;
|
|
|
+import com.rongwe.scentity.domian.ApsSpecialInspectionTaskZibiaoDo;
|
|
|
+import com.rongwe.scentity.domian.ApsSpecialInspectionTaskZibiaoSocreDo;
|
|
|
+import com.rongwe.scentity.domian.AspCheckDiscoveryItemDo;
|
|
|
+import com.rongwe.scentity.vo.AspCheckDiscoveryItemVo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
+import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
+import com.rongwei.sfcommon.sys.service.*;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.AsyncAddress.*;
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.AsyncStatus.FAILURESYNC;
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.AsyncStatus.SUCCESSSYNC;
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.DatePattern.DATE_PATTERN_YMD;
|
|
|
+
|
|
|
+
|
|
|
+@Service
|
|
|
+public class SpecialInspectionSynchronizationServiceImpl implements SpecialInspectionSynchronizationService {
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(SpecialInspectionSynchronizationServiceImpl.class);
|
|
|
+
|
|
|
+ private static final String TENANTID="1510085864884137986";
|
|
|
+ private static final SimpleDateFormat FORMATYMD= new SimpleDateFormat("yyyyMMdd");
|
|
|
+ private static final SimpleDateFormat FORMAT_YMD = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ private static final SimpleDateFormat FORMAT_YMDHMS = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+
|
|
|
+ private static final String ip="127.0.0.1";
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ApsSpecialInspectionTaskService apsSpecialInspectionTaskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ApsSpecialInspectionTaskZibiaoService apsSpecialInspectionTaskZibiaoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreService apsSpecialInspectionTaskZibiaoSocreService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AspCheckDiscoveryItemService aspCheckDiscoveryItemService;
|
|
|
+ /**
|
|
|
+ * 下发专项检查
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R issueBaseCheckTask() {
|
|
|
+ //1.组装参数调用接口...
|
|
|
+ String json = "{}";
|
|
|
+ String retStr = this.callPai(json,TBBASECHECKTASKURL);
|
|
|
+ //2.处理数据
|
|
|
+ if("200".equals(JSONUtil.parseObj(retStr).get("status"))) {
|
|
|
+ cn.hutool.json.JSONObject apiReturnJson = JSONUtil.parseObj(retStr);
|
|
|
+ JSONArray message = apiReturnJson.getJSONArray("message");
|
|
|
+ if (!message.isEmpty()){
|
|
|
+ fillTaskData(message);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return R.error("调用接口数据失败");
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下发专项检查项目
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R issueBaseCheckItem(HashMap<String, String> map) {
|
|
|
+ //1.组装参数调用接口...
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
|
|
|
+ jsonObject.put("task_id",map.get("task_id"));
|
|
|
+ String json = jsonObject.toString();
|
|
|
+ //调用接口
|
|
|
+ String retStr = this.callPai(json,TBBASECHECKITEMURL);
|
|
|
+ //2.处理数据
|
|
|
+ if("200".equals(JSONUtil.parseObj(retStr).get("status"))) {
|
|
|
+ cn.hutool.json.JSONObject apiReturnJson = JSONUtil.parseObj(retStr);
|
|
|
+ JSONArray message = apiReturnJson.getJSONArray("message");
|
|
|
+ if (!message.isEmpty()){
|
|
|
+ fillItemData(message);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return R.error("调用接口数据失败");
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下发检查项评分细则
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R issueBaseCheckScore(HashMap<String, String> map) {
|
|
|
+ //1.组装参数调用接口...
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
|
|
|
+ jsonObject.put("task_id",map.get("task_id"));
|
|
|
+ String json = jsonObject.toString();
|
|
|
+ String retStr = this.callPai(json,TBBASECHECKSCOREURL);
|
|
|
+ //2.处理数据
|
|
|
+ if("200".equals(JSONUtil.parseObj(retStr).get("status"))) {
|
|
|
+ cn.hutool.json.JSONObject apiReturnJson = JSONUtil.parseObj(retStr);
|
|
|
+ JSONArray message = apiReturnJson.getJSONArray("message");
|
|
|
+ if (!message.isEmpty()){
|
|
|
+ fillScoreData(message);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return R.error("调用接口数据失败");
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *上报专项检查情况
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R reportBaseCheckRecord(List<String> ids) throws Exception {
|
|
|
+ if (ids.size() > 50) {
|
|
|
+ throw new CustomException("单次上报最大数据量:50条!");
|
|
|
+ }
|
|
|
+ //1.查询数据
|
|
|
+ List<ApsSpecialInspectionTaskDo> apsSpecialInspectionTaskDos = (List<ApsSpecialInspectionTaskDo>) apsSpecialInspectionTaskService.listByIds(ids);
|
|
|
+ //2.检查数据
|
|
|
+ String json = convertListToJsonCheck(apsSpecialInspectionTaskDos);
|
|
|
+ //调用接口
|
|
|
+ String retStr = this.callPai(json,TBBASECHECKRECORDURL);
|
|
|
+ //2.处理数据
|
|
|
+ cn.hutool.json.JSONObject apiReturnJson = JSONUtil.parseObj(retStr);
|
|
|
+ LambdaUpdateWrapper<ApsSpecialInspectionTaskDo> lambdaUpdateWrapper = new LambdaUpdateWrapper<ApsSpecialInspectionTaskDo>()
|
|
|
+ .in(ApsSpecialInspectionTaskDo::getId, ids)
|
|
|
+ .set(ApsSpecialInspectionTaskDo::getSynclog,apiReturnJson.getStr("message"))
|
|
|
+ .set(ApsSpecialInspectionTaskDo::getSynctime, new Date());
|
|
|
+
|
|
|
+ if("200".equals(JSONUtil.parseObj(retStr).get("status"))) {
|
|
|
+ lambdaUpdateWrapper.set(ApsSpecialInspectionTaskDo::getSyncstatus, SUCCESSSYNC);
|
|
|
+ }else {
|
|
|
+ lambdaUpdateWrapper.set(ApsSpecialInspectionTaskDo::getSyncstatus, FAILURESYNC);
|
|
|
+ }
|
|
|
+
|
|
|
+ apsSpecialInspectionTaskService.update(lambdaUpdateWrapper);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上报专项检查隐患信息
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R reportBaseCheckDanger(List<String> ids) throws Exception {
|
|
|
+ if (ids.size() > 50) {
|
|
|
+ throw new CustomException("单次上报最大数据量:50条!");
|
|
|
+ }
|
|
|
+ //1.查询数据
|
|
|
+ List<AspCheckDiscoveryItemVo> aspCheckDiscoveryItemDos = aspCheckDiscoveryItemService.getDangerData(ids);
|
|
|
+ //2.检查数据
|
|
|
+
|
|
|
+ String json = convertListToJsonDanger(aspCheckDiscoveryItemDos);
|
|
|
+ //调用接口
|
|
|
+ String retStr = this.callPai(json,TBBASECHECKDANGERURL);
|
|
|
+ //2.处理数据
|
|
|
+ cn.hutool.json.JSONObject apiReturnJson = JSONUtil.parseObj(retStr);
|
|
|
+ LambdaUpdateWrapper<AspCheckDiscoveryItemDo> lambdaUpdateWrapper = new LambdaUpdateWrapper<AspCheckDiscoveryItemDo>()
|
|
|
+ .in(AspCheckDiscoveryItemDo::getId, ids)
|
|
|
+ .set(AspCheckDiscoveryItemDo::getSynclog,apiReturnJson.getStr("message"))
|
|
|
+ .set(AspCheckDiscoveryItemDo::getSynctime, new Date());
|
|
|
+
|
|
|
+ if("200".equals(JSONUtil.parseObj(retStr).get("status"))) {
|
|
|
+ lambdaUpdateWrapper.set(AspCheckDiscoveryItemDo::getSyncstatus, SUCCESSSYNC);
|
|
|
+ }else {
|
|
|
+ lambdaUpdateWrapper.set(AspCheckDiscoveryItemDo::getSyncstatus, FAILURESYNC);
|
|
|
+ }
|
|
|
+
|
|
|
+ aspCheckDiscoveryItemService.update(lambdaUpdateWrapper);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验整理数据
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String convertListToJsonDanger(List<AspCheckDiscoveryItemVo> list) throws Exception {
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ JSONObject jsonObject;
|
|
|
+
|
|
|
+ for (AspCheckDiscoveryItemVo item : list) {
|
|
|
+ jsonObject =new JSONObject();
|
|
|
+ validateAndAppendDanger(item, jsonObject);
|
|
|
+ jsonArray.put(jsonObject);
|
|
|
+ }
|
|
|
+ return jsonArray.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void validateAndAppendDanger(AspCheckDiscoveryItemVo item, JSONObject jsonObject) throws Exception {
|
|
|
+ validateStringValue(item.getCompanycode(), "company_code", jsonObject, "企业编码不能为空");
|
|
|
+ validateStringValue(item.getThemecheckitemid(), "task_id", jsonObject, "任务 ID不能为空");
|
|
|
+ validateStringValue(item.getChecktype(), "check_type", jsonObject, "检查类型为空");
|
|
|
+ validateStringValue(item.getCheckitemid(), "check_item_id", jsonObject, "检查项为空");
|
|
|
+ validateStringValue(item.getChecksourceid(), "check_score_id", jsonObject, "检查项评分细则为空");
|
|
|
+ validateDateValue(item.getCheckdate(), "check_date", FORMATYMD, jsonObject, "检查日期为空");
|
|
|
+ validateStringValue(item.getDeleted(), "deleted", jsonObject, "删除标志为空");
|
|
|
+ validateStringValue(item.getCreateusername(), "create_by", jsonObject, "创建人为空");
|
|
|
+ validateStringValue(item.getModifyusername(), "update_by", jsonObject, "最后修改人为空");
|
|
|
+ validateDateValue(item.getCreatedate(), "create_date", FORMAT_YMDHMS, jsonObject, "创建时间为空");
|
|
|
+ validateDateValue(item.getModifydate(), "update_date", FORMAT_YMDHMS, jsonObject, "最后修改时间为空");
|
|
|
+
|
|
|
+ if(item.getChecktype().contains("危险化学品重大危险源企业安全专项检查督导")){
|
|
|
+ validateStringValue(item.getHarmtype(), "harm_type", jsonObject, "检查项评分细则为空");
|
|
|
+ }else {
|
|
|
+ jsonObject.put("harm_type", item.getHarmtype());
|
|
|
+ }
|
|
|
+ jsonObject.put("id", SecurityUtil.getUUID());
|
|
|
+ jsonObject.put("danger_id",item.getId());
|
|
|
+ jsonObject.put("check_pay", item.getCheckpay());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验整理数据
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String convertListToJsonCheck(List<ApsSpecialInspectionTaskDo> list) throws Exception {
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ JSONObject jsonObject;
|
|
|
+
|
|
|
+ for (ApsSpecialInspectionTaskDo item : list) {
|
|
|
+ jsonObject =new JSONObject();
|
|
|
+ validateAndAppend(item, jsonObject);
|
|
|
+ jsonArray.put(jsonObject);
|
|
|
+ }
|
|
|
+ return jsonArray.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void validateAndAppend(ApsSpecialInspectionTaskDo item, JSONObject jsonObject) throws Exception {
|
|
|
+ validateStringValue(item.getCompanycode(), "company_code", jsonObject, "企业编码不能为空");
|
|
|
+ validateStringValue(item.getDeleted(), "deleted", jsonObject, "删除标志为空");
|
|
|
+ validateStringValue(item.getChecktype(), "check_type", jsonObject, "检查类型为空");
|
|
|
+ validateStringValue(item.getCreateusername(), "create_by", jsonObject, "创建人为空");
|
|
|
+ validateStringValue(item.getModifyusername(), "update_by", jsonObject, "最后修改人为空");
|
|
|
+ validateDateValue(item.getCheckdate(), "check_date", FORMAT_YMD, jsonObject, "检查日期为空");
|
|
|
+ validateDateValue(item.getCreatedate(), "create_date", FORMAT_YMDHMS, jsonObject, "创建时间为空");
|
|
|
+ validateDateValue(item.getModifydate(), "update_date", FORMAT_YMDHMS, jsonObject, "最后修改时间为空");
|
|
|
+ jsonObject.put("task_id", item.getId());
|
|
|
+ jsonObject.put("result_status", item.getResultstatus());
|
|
|
+ jsonObject.put("hazard_code", item.getHazardcode());
|
|
|
+ jsonObject.put("id", SecurityUtil.getUUID());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void validateDateValue(Date value, String key, SimpleDateFormat dateFormat, JSONObject jsonObject, String errorMsg) throws Exception {
|
|
|
+ if (value==null){
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
|
+ }else {
|
|
|
+ jsonObject.put(key,dateFormat.format(value));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void validateStringValue(String value, String key, JSONObject jsonObject, String errorMsg) throws Exception {
|
|
|
+ if (StringUtils.isNotBlank(value)){
|
|
|
+ jsonObject.put(key,value);
|
|
|
+ }else {
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 专项检查项目 数据填充
|
|
|
+ * aps_special_inspection_task_zibiao
|
|
|
+ * @param data
|
|
|
+ */
|
|
|
+ private void fillItemData(JSONArray data) {
|
|
|
+ List<ApsSpecialInspectionTaskZibiaoDo> saveList =new ArrayList<>();
|
|
|
+ ApsSpecialInspectionTaskZibiaoDo apsSpecialInspectionTaskZibiaoDo =null;
|
|
|
+ JSONObject jsonObject =null;
|
|
|
+ //时间格式转换
|
|
|
+ SimpleDateFormat formatCreate = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ //循环接受数据
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ apsSpecialInspectionTaskZibiaoDo= new ApsSpecialInspectionTaskZibiaoDo();
|
|
|
+ jsonObject = (JSONObject) data.get(i);
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setId(jsonObject.getString("id"));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setTenantid(TENANTID);
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setMadinid(jsonObject.getString("task_id"));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setCheckname(jsonObject.getString("check_name"));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setCheckcontent( jsonObject.getString("check_content"));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setCheckway(jsonObject.getString("check_way"));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setCheckbasis(jsonObject.getString("check_basis"));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setApplicableplace(jsonObject.getString("applicable_place"));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setDeleted(jsonObject.getString("deleted"));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setCreateusername(jsonObject.getString("create_by"));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setCreatedate(StringToData( jsonObject.getString("create_date"),formatCreate));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setModifydate(StringToData( jsonObject.getString("update_date"),formatCreate));
|
|
|
+ apsSpecialInspectionTaskZibiaoDo.setModifyusername(jsonObject.getString("update_by"));
|
|
|
+ saveList.add(apsSpecialInspectionTaskZibiaoDo);
|
|
|
+ };
|
|
|
+ //存储数据
|
|
|
+ if(!saveList.isEmpty()){
|
|
|
+ apsSpecialInspectionTaskZibiaoService.saveOrUpdateBatch(saveList,50);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下发检查项评分细则 数据填充
|
|
|
+ * @param data
|
|
|
+ */
|
|
|
+ private void fillScoreData(JSONArray data) {
|
|
|
+ List<ApsSpecialInspectionTaskZibiaoSocreDo> updateList =new ArrayList<>();
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo ApsSpecialInspectionTaskZibiaoSocreDo =null;
|
|
|
+ JSONObject jsonObject =null;
|
|
|
+ //时间格式转换
|
|
|
+ SimpleDateFormat formatCreate = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ //循环接受数据
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo= new ApsSpecialInspectionTaskZibiaoSocreDo();
|
|
|
+ jsonObject = (JSONObject) data.get(i);
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setCheckitemid(jsonObject.getString("check_item_id"));
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setId(jsonObject.getString("id"));
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setTenantid(TENANTID);
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setIsreject(jsonObject.getString("is_reject"));
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setDeductpoint(new BigDecimal(jsonObject.getString("deduct_point")));
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setDeductillustrate(jsonObject.getString("deduct_illustrate"));
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setDeleted(jsonObject.getString("deleted"));
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setCreateusername(jsonObject.getString("create_by"));
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setCreatedate(StringToData( jsonObject.getString("create_date"),formatCreate));
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setModifydate(StringToData( jsonObject.getString("update_date"),formatCreate));
|
|
|
+ ApsSpecialInspectionTaskZibiaoSocreDo.setModifyusername(jsonObject.getString("update_by"));
|
|
|
+ updateList.add(ApsSpecialInspectionTaskZibiaoSocreDo);
|
|
|
+ };
|
|
|
+ //存储数据
|
|
|
+ if(!updateList.isEmpty()){
|
|
|
+ apsSpecialInspectionTaskZibiaoSocreService.saveOrUpdateBatch(updateList,50);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 专项检查任务记录 数据填充
|
|
|
+ * aps_special_inspection_task
|
|
|
+ * @param data
|
|
|
+ */
|
|
|
+ private void fillTaskData(JSONArray data) {
|
|
|
+ List<ApsSpecialInspectionTaskDo> saveList =new ArrayList<>();
|
|
|
+ ApsSpecialInspectionTaskDo apsSpecialInspectionTaskDo =null;
|
|
|
+ JSONObject jsonObject =null;
|
|
|
+ //时间格式转换
|
|
|
+ SimpleDateFormat formatStart = new SimpleDateFormat(DATE_PATTERN_YMD);
|
|
|
+ SimpleDateFormat formatEnd = new SimpleDateFormat("yyyyMMdd");
|
|
|
+ SimpleDateFormat formatCreate = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ //循环接受数据
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ apsSpecialInspectionTaskDo=new ApsSpecialInspectionTaskDo();
|
|
|
+ jsonObject = (JSONObject) data.get(i);
|
|
|
+ apsSpecialInspectionTaskDo.setId(jsonObject.getString("id"));
|
|
|
+ apsSpecialInspectionTaskDo.setTenantid(TENANTID);
|
|
|
+ apsSpecialInspectionTaskDo.setTaskname(jsonObject.getString("task_name"));
|
|
|
+ apsSpecialInspectionTaskDo.setTaskstarttime(StringToData( jsonObject.getString("task_start_time"),formatStart));
|
|
|
+ apsSpecialInspectionTaskDo.setTaskendtime(StringToData( jsonObject.getString("task_end_time"),formatEnd));
|
|
|
+ apsSpecialInspectionTaskDo.setTasktypename( jsonObject.getString("task_type_name"));
|
|
|
+ apsSpecialInspectionTaskDo.setTaskcontent(jsonObject.getString("task_content"));
|
|
|
+ apsSpecialInspectionTaskDo.setDeleted(jsonObject.getString("deleted"));
|
|
|
+ apsSpecialInspectionTaskDo.setCreateusername(jsonObject.getString("create_by"));
|
|
|
+ apsSpecialInspectionTaskDo.setCreatedate(StringToData( jsonObject.getString("create_date"),formatCreate));
|
|
|
+ apsSpecialInspectionTaskDo.setModifydate(StringToData( jsonObject.getString("update_date"),formatCreate));
|
|
|
+ apsSpecialInspectionTaskDo.setModifyusername(jsonObject.getString("update_by"));
|
|
|
+ saveList.add(apsSpecialInspectionTaskDo);
|
|
|
+ };
|
|
|
+ //存储数据
|
|
|
+ if(!saveList.isEmpty()){
|
|
|
+ apsSpecialInspectionTaskService.saveOrUpdateBatch(saveList,50);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 时间字符串转换
|
|
|
+ * @param timeStr
|
|
|
+ * @param format
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Date StringToData(String timeStr, SimpleDateFormat format) {
|
|
|
+ if (StringUtils.isNotBlank(timeStr)){
|
|
|
+ try {
|
|
|
+ return format.parse(timeStr);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ logger.error("时间转换异常{}",timeStr);
|
|
|
+ // throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String callPai( String json, String url) {
|
|
|
+ logger.info("入参:" +json);
|
|
|
+ String apiUrl = this.ip + url;
|
|
|
+ logger.info("api地址:" + apiUrl);
|
|
|
+ //获取token
|
|
|
+ String token = this.getToken();
|
|
|
+ logger.info("token:"+token);
|
|
|
+ String apiReturnStr = HttpRequest.post(apiUrl)
|
|
|
+ .header("Content-Type","application/json")
|
|
|
+ .header("token",token)
|
|
|
+ .body(json).execute().body();
|
|
|
+ logger.info("返回报文:{}",apiReturnStr);
|
|
|
+ return apiReturnStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getToken() {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+}
|