package com.jtgh.qlyg.sync; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Component; import com.jtgh.qlyg.service.InfApplyProcessService; import com.jtgh.qlyg.service.InfApplyResultService; import com.jtgh.qlyg.service.InfApplyService; import com.jtgh.yjpt.common.Constants; import com.jtgh.yjpt.common.GlobalData; import com.jtgh.yjpt.common.PredicateModel; import com.jtgh.yjpt.common.PredicateModel.Operator; import com.jtgh.yjpt.common.SpecificationCreater; import com.jtgh.yjpt.controller.BaseController; import com.jtgh.yjpt.entity.BaseEntity; import com.jtgh.yjpt.entity.qlyg.ApplyEntity; import com.jtgh.yjpt.entity.qlyg.ApplyProcessEntity; import com.jtgh.yjpt.entity.qlyg.ApplyResultEntity; import com.jtgh.yjpt.service.qlyg.ApplyProcessService; import com.jtgh.yjpt.service.qlyg.ApplyResultService; import com.jtgh.yjpt.service.qlyg.ApplyService; /** * 同步办件信息 * * @author masn * */ @Component public class QlygSyncApply extends BaseController { /** 日志记录 */ private Logger logger = Logger.getLogger(getClass()); @Autowired private ApplyService applyService; @Autowired private ApplyProcessService applyProcessService; @Autowired private ApplyResultService applyResultService; @Autowired private InfApplyService infApplyService; @Autowired private InfApplyProcessService infApplyProcessService; @Autowired private InfApplyResultService infApplyResultService; /** * 执行前一天办件情况 */ public void execute() { if (Constants.NO.equals(GlobalData.QLYG_SYNC)) return; logger.info(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") .format(new Date()) + "执行QlygSyncApply"); // Calendar c = Calendar.getInstance(); // c.set(Calendar.HOUR_OF_DAY, 0); // c.set(Calendar.MINUTE, 0); // c.set(Calendar.SECOND, 0); // c.set(Calendar.MILLISECOND, 0); // Date stopTime = c.getTime(); // c.add(Calendar.DAY_OF_MONTH, -1); // Date startTime = c.getTime(); // 同步办件基础信息 List filterListApply = new ArrayList(); addNotEmptyModel(filterListApply, "recordStatus", BaseEntity.RECORD_STATE_DELETE, Operator.NEQ); // addNotEmptyModel(filterListApply, "createDate", startTime, // Operator.GTE); // addNotEmptyModel(filterListApply, "createDate", stopTime, // Operator.LT); addNotEmptyModel(filterListApply, "byzd5", GlobalData.QLYG_RES, Operator.NEQ); Specification specApply = SpecificationCreater .searchByPredicateModels(filterListApply); List listApply = applyService.findAll(specApply); if (listApply != null && listApply.size() > 0) { for (ApplyEntity apply : listApply) { // 保存办件基本信息 infApplyService.save(apply); } } // 同步办件过程信息 List filterListApplyProcess = new ArrayList(); addNotEmptyModel(filterListApplyProcess, "recordStatus", BaseEntity.RECORD_STATE_COMPLETED, Operator.EQ); // addNotEmptyModel(filterListApplyProcess, "createDate", startTime, // Operator.GTE); // addNotEmptyModel(filterListApplyProcess, "createDate", stopTime, // Operator.LT); addNotEmptyModel(filterListApply, "byzd5", GlobalData.QLYG_RES, Operator.NEQ); Specification specApplyProcess = SpecificationCreater .searchByPredicateModels(filterListApplyProcess); List listApplyProcess = applyProcessService .findAll(specApplyProcess); if (listApplyProcess != null && listApplyProcess.size() > 0) { for (ApplyProcessEntity applyProcess : listApplyProcess) { // 保存办件过程 保存到权力阳光库 infApplyProcessService.save(applyProcess); } } // 同步办件过程信息 List filterListApplyResult = new ArrayList(); addNotEmptyModel(filterListApplyResult, "recordStatus", BaseEntity.RECORD_STATE_DELETE, Operator.NEQ); // addNotEmptyModel(filterListApplyResult, "createDate", startTime, // Operator.GTE); // addNotEmptyModel(filterListApplyResult, "createDate", stopTime, // Operator.LT); addNotEmptyModel(filterListApply, "byzd5", GlobalData.QLYG_RES, Operator.NEQ); Specification specApplyResult = SpecificationCreater .searchByPredicateModels(filterListApplyResult); List listApplyResult = applyResultService .findAll(specApplyResult); if (listApplyResult != null && listApplyResult.size() > 0) { for (ApplyResultEntity applyResult : listApplyResult) { // 保存办件过程 infApplyResultService.save(applyResult); } } } }