Prechádzať zdrojové kódy

Merge branch 'main' of suhaiwen/wlyy2.0 into dev

叶仕杰 4 rokov pred
rodič
commit
a388614c9d

+ 51 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/sync/BaseSyncDataDO.java

@ -0,0 +1,51 @@
package com.yihu.jw.entity.base.sync;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/25
 */
@Entity
@Table(name = "wlyy_data_sync")
public class BaseSyncDataDO extends UuidIdentityEntityWithOperator implements java.io.Serializable {
    @Column(name = "style")
    private String style;//同步方式 1:手动同步 2:自动同步
    @Column(name = "complete_time")
    private Date completeTime; //完成时间
    @Column(name = "sync_result")
    private String syncResult;//同步结果
    public String getStyle() {
        return style;
    }
    public void setStyle(String style) {
        this.style = style;
    }
    public Date getCompleteTime() {
        return completeTime;
    }
    public void setCompleteTime(Date completeTime) {
        this.completeTime = completeTime;
    }
    public String getSyncResult() {
        return syncResult;
    }
    public void setSyncResult(String syncResult) {
        this.syncResult = syncResult;
    }
}

+ 8 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -679,6 +679,14 @@ public class BaseRequestMapping {
    public static class BaseMessage extends Basic {
        public static final String PREFIX  = "/baseMessage";
    }
    /**
     * 基础消息
     */
    public static class SyncData extends Basic {
        public static final String PREFIX  = "/syncData";
        public static final String findAllSyncData  = "/findAllSyncData";
        public static final String findDataByTime  = "/findDataByTime";
    }
    /**
     * 基础消息类型

+ 14 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/sync/BaseSyncDataDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.base.dao.sync;
import com.yihu.jw.entity.base.message.BaseMessageDO;
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/25
 */
public interface BaseSyncDataDao extends PagingAndSortingRepository<BaseSyncDataDO, String>, JpaSpecificationExecutor<BaseSyncDataDO> {
}

+ 72 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/sync/BaseSyncDataEndpoint.java

@ -0,0 +1,72 @@
package com.yihu.jw.base.endpoint.sync;
import com.yihu.jw.base.service.sync.BaseSyncDataService;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/25
 */
@RestController
@RequestMapping(value = BaseRequestMapping.SyncData.PREFIX)
@Api(value = "数据同步", description = "数据同步", tags = {"wlyy基础服务 - 数据同步接口"})
public class BaseSyncDataEndpoint  extends EnvelopRestEndpoint {
    @Autowired
    private BaseSyncDataService baseSyncDataService;
    @GetMapping(value = BaseRequestMapping.SyncData.findAllSyncData)
    @ApiOperation(value = "获取同步数据列表")
    public PageEnvelop findAllSyncData( @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "")
                                            @RequestParam(value = "page") Integer page,
                                        @ApiParam(name = "size", value = "页码", required = true, defaultValue = "")
                                            @RequestParam(value = "size") Integer size){
        try {
            if(page == null|| page < 0){
                page = 1;
            }
            if(size == null){
                size = 10;
            }
            return   baseSyncDataService.findAll(page,size);
        }catch (Exception e){
            return PageEnvelop.getError(e.getMessage(),-1);
        }
    }
    @GetMapping(value = BaseRequestMapping.SyncData.findDataByTime)
    @ApiOperation(value = "获取同步数据列表")
    public PageEnvelop findDataByTime( @ApiParam(name = "startTime", value = "开始时间", required = true, defaultValue = "")
                                        @RequestParam(value = "startTime") String startTime,
                                        @ApiParam(name = "endTime", value = "结束时间", required = true, defaultValue = "")
                                        @RequestParam(value = "endTime") String endTime,
                                       @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "")
                                           @RequestParam(value = "page") Integer page,
                                       @ApiParam(name = "size", value = "页码", required = true, defaultValue = "")
                                           @RequestParam(value = "size") Integer size){
        try {
            return   baseSyncDataService.findDataByTime(startTime,endTime,page,size);
        }catch (Exception e){
            return PageEnvelop.getError(e.getMessage(),-1);
        }
    }
}

+ 88 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/sync/BaseSyncDataService.java

@ -0,0 +1,88 @@
package com.yihu.jw.base.service.sync;
import com.yihu.jw.base.dao.sync.BaseSyncDataDao;
import com.yihu.jw.base.useragent.UserAgent;
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/25
 */
@Service
public class BaseSyncDataService extends BaseJpaService<BaseSyncDataDO, BaseSyncDataDao> {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private UserAgent userAgent;
    public PageEnvelop findAll(Integer page, Integer size){
        StringBuffer sql= new StringBuffer("SELECT * FROM wlyy_data_sync ");
        sql.append(" ORDER BY complete_time LIMIT ").append((page-1)*size).append(",").append(size);
        List<BaseSyncDataDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(BaseSyncDataDO.class));
        long count =list.size();
        return PageEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find,list,page,size,count);
    }
    /**
     * 根据时间查询
     * @param startTime
     * @param endTime
     * @return
     */
    public PageEnvelop findDataByTime(String startTime, String endTime,Integer page,Integer size) {
        StringBuffer sql= new StringBuffer("SELECT c.* FROM wlyy_data_sync c WHERE 1=1 ");
        if (StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            sql.append(" and c.complete_time BETWEEN ").append("'").append(startTime).append("'").append(" AND ").append("'").append(endTime).append("'");
        }
        sql.append(" ORDER BY c.complete_time DESC LIMIT ").append((page-1)*size).append(",").append(size);
        List<BaseSyncDataDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(BaseSyncDataDO.class));
        long count =list.size();
        return PageEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find,list,page,size,count);
    }
    /**
     * 完成同步
     * @return
     */
    public void complete () {
        try {
            xzzxEntranceService.getDoctorInfo("");
            xzzxEntranceService.randomString(1);
            xzzxEntranceService.getJobTitle();
            xzzxEntranceService.getChargeDict();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}