package cn.com.goldenwater.dcproj.service.impl.swhs; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.dao.BisInspLogDao; import cn.com.goldenwater.dcproj.dao.BisInspSwhsRgstrMeasuresDao; import cn.com.goldenwater.dcproj.model.BisInspLog; import cn.com.goldenwater.dcproj.model.BisInspSwhsRgstrMeasures; import cn.com.goldenwater.dcproj.param.BisInspLogParam; import cn.com.goldenwater.dcproj.param.BisInspSwhsRgstrMeasuresParam; import cn.com.goldenwater.dcproj.service.BisInspSwhsRgstrMeasuresService; import net.sf.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.sql.Date; import java.util.List; /** * @author lune * @date 2019-8-7 */ @Service @Transactional public class BisInspSwhsRgstrMeasuresServiceImpl extends AbstractCrudService implements BisInspSwhsRgstrMeasuresService { @Autowired private BisInspSwhsRgstrMeasuresDao bisInspSwhsRgstrMeasuresDao; @Autowired private BisInspLogDao bisInspLogDao; public BisInspSwhsRgstrMeasuresServiceImpl(BisInspSwhsRgstrMeasuresDao bisInspSwhsRgstrMeasuresDao) { super(bisInspSwhsRgstrMeasuresDao); this.bisInspSwhsRgstrMeasuresDao = bisInspSwhsRgstrMeasuresDao; } @Override public boolean reData() { boolean bol = true; BisInspLogParam bisInspLogParam = new BisInspLogParam(); bisInspLogParam.setPath("http://sv.goldenwater.com.cn/bis/insp/swhs/rgstr/measures"); List bisInspLogList = bisInspLogDao.findLogList(bisInspLogParam); for (BisInspLog inspLog : bisInspLogList) { String resp = inspLog.getResponseBody(); net.sf.json.JSONObject jsonobject = JSONObject.fromObject(resp); JSONObject data = jsonobject.getJSONObject("data"); String id = data.getString("id"); String rgstrId = data.getString("rgstrId"); String annInflow = data.getString("annInflow"); String annInflowDry = data.getString("annInflowDry"); String isAmwqiadtfad = data.getString("isAmwqiadtfad"); String isEcgbacws = data.getString("isEcgbacws"); String isEowqoms = data.getString("isEowqoms"); String isHasIwba = data.getString("isHasIwba"); String isHasProject = data.getString("isHasProject"); String isPzfdwsad = data.getString("isPzfdwsad"); String isSwqiowstswrmisar = data.getString("isSwqiowstswrmisar"); String isTcowqmWtmiafmtr = data.getString("isTcowqmWtmiafmtr"); String recPersId = data.getString("recPersId"); String inTm = data.getString("inTm"); Long inTmL = Long.parseLong(inTm); String upTm = data.getString("upTm"); Long upTmL = Long.parseLong(upTm); BisInspSwhsRgstrMeasures inspSwhsRgstrMeasures = new BisInspSwhsRgstrMeasures(); inspSwhsRgstrMeasures.setId(id); inspSwhsRgstrMeasures.setRgstrId(rgstrId); inspSwhsRgstrMeasures.setAnnInflow(annInflow); inspSwhsRgstrMeasures.setAnnInflowDry(annInflowDry); inspSwhsRgstrMeasures.setIsAmwqiadtfad(isAmwqiadtfad); inspSwhsRgstrMeasures.setIsEcgbacws(isEcgbacws); inspSwhsRgstrMeasures.setIsEowqoms(isEowqoms); inspSwhsRgstrMeasures.setIsHasIwba(isHasIwba); inspSwhsRgstrMeasures.setIsHasProject(isHasProject); inspSwhsRgstrMeasures.setIsPzfdwsad(isPzfdwsad); inspSwhsRgstrMeasures.setIsSwqiowstswrmisar(isSwqiowstswrmisar); inspSwhsRgstrMeasures.setIsTcowqmWtmiafmtr(isTcowqmWtmiafmtr); inspSwhsRgstrMeasures.setRecPersId(recPersId); inspSwhsRgstrMeasures.setInTm(new Date(inTmL)); inspSwhsRgstrMeasures.setUpTm(new Date(upTmL)); BisInspSwhsRgstrMeasures swhsRgstrMeasures = bisInspSwhsRgstrMeasuresDao.get(id); if (swhsRgstrMeasures != null) { bisInspSwhsRgstrMeasuresDao.update(inspSwhsRgstrMeasures); } else { bisInspSwhsRgstrMeasuresDao.insert(inspSwhsRgstrMeasures); } } return bol; } }