Jelajahi Sumber

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

Sand 8 tahun lalu
induk
melakukan
045a529938

+ 26 - 23
src/main/java/com/yihu/wlyy/entity/demographic/DemographicInfo.java

@ -91,30 +91,33 @@ public class DemographicInfo implements java.io.Serializable {
	private String mothercode;//
	private String familyhtype;//
	public DemographicInfo() {
	}
	public DemographicInfo(String persontype, String name, String oldname,
                           String aliasname, String sex, Timestamp birth, Timestamp doorbirth,
                           String cardid, String nation, String edudegree, String work,
                           String party, String doorprop, String farmer, String aviso,
                           String publicize, String hortation, String checktype,
                           String single, Integer workid, String dooraddress,
                           String dooraddressinfo, String nowaddress, String nowaddressinfo,
                           String doortel, String marrytype, Timestamp marrychangedate,
                           Integer mateid, String matename, String matecardid,
                           Timestamp matebrith, Integer fatherid, String fathername,
                           Integer materid, String matername, Integer girlcount,
                           Integer boycount, Integer operatorid, String checkunit,
                           Timestamp checkdate, Integer uoperatorid, String updateunit,
                           Timestamp updatedate, Timestamp indate, Integer cancel,
                           String memo, String persontel, Timestamp arrivedate,
                           Timestamp leavedate, String conclass, String munitid, String state,
                           String health, String relaparents, String matebwork,
                           String workaddress, String mateaddtel, Integer nowchilden,
                           Timestamp schildbirth, Timestamp singlenodate, String isviolate,
                           String ismatefarmer, String workaddressid, String workname,
                           Timestamp condate, String contramemo, String matedooradd,
                           String matedooraddinfo, Timestamp fmarrydate, String unitname,
                           String addtype, String zjlxdm, String qtzjhm, String fathercode,
                           String gjdm, Timestamp dbdate, String mothercode, String familyhtype) {
						   String aliasname, String sex, Timestamp birth, Timestamp doorbirth,
						   String cardid, String nation, String edudegree, String work,
						   String party, String doorprop, String farmer, String aviso,
						   String publicize, String hortation, String checktype,
						   String single, Integer workid, String dooraddress,
						   String dooraddressinfo, String nowaddress, String nowaddressinfo,
						   String doortel, String marrytype, Timestamp marrychangedate,
						   Integer mateid, String matename, String matecardid,
						   Timestamp matebrith, Integer fatherid, String fathername,
						   Integer materid, String matername, Integer girlcount,
						   Integer boycount, Integer operatorid, String checkunit,
						   Timestamp checkdate, Integer uoperatorid, String updateunit,
						   Timestamp updatedate, Timestamp indate, Integer cancel,
						   String memo, String persontel, Timestamp arrivedate,
						   Timestamp leavedate, String conclass, String munitid, String state,
						   String health, String relaparents, String matebwork,
						   String workaddress, String mateaddtel, Integer nowchilden,
						   Timestamp schildbirth, Timestamp singlenodate, String isviolate,
						   String ismatefarmer, String workaddressid, String workname,
						   Timestamp condate, String contramemo, String matedooradd,
						   String matedooraddinfo, Timestamp fmarrydate, String unitname,
						   String addtype, String zjlxdm, String qtzjhm, String fathercode,
						   String gjdm, Timestamp dbdate, String mothercode, String familyhtype) {
		this.persontype = persontype;
		this.name = name;
		this.oldname = oldname;

+ 11 - 8
src/main/java/com/yihu/wlyy/entity/demographic/ResidenceInfo.java

@ -41,15 +41,18 @@ public class ResidenceInfo implements java.io.Serializable {
	private Integer cancelid;//出户ID对应tblreg_move或tblreg_cancel表
	private String canceltype;//出户类型(03对应死亡,04对应迁出)
	public ResidenceInfo() {
	}
	public ResidenceInfo(Integer familystateid, Integer personid,
                         String property, String relaholder, String personstate,
                         Integer operatorid, String checkunit, Timestamp checkdate,
                         String leavecau, Timestamp canceldate, String memo,
                         Integer familyinfoid, Timestamp indate, String state, String sn,
                         String team, String familyno, String doornumb, String addno,
                         String persontype, String munittype, Integer manid,
                         Timestamp startdate, Timestamp enddate, Integer jionid,
                         String jiontype, Integer cancelid, String canceltype) {
						 String property, String relaholder, String personstate,
						 Integer operatorid, String checkunit, Timestamp checkdate,
						 String leavecau, Timestamp canceldate, String memo,
						 Integer familyinfoid, Timestamp indate, String state, String sn,
						 String team, String familyno, String doornumb, String addno,
						 String persontype, String munittype, Integer manid,
						 Timestamp startdate, Timestamp enddate, Integer jionid,
						 String jiontype, Integer cancelid, String canceltype) {
		this.familystateid = familystateid;
		this.personid = personid;
		this.property = property;

+ 1 - 1
src/main/java/com/yihu/wlyy/repository/doctor/DoctorDao.java

@ -120,7 +120,7 @@ public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, Jpa
    List<Doctor> findByIsFamous(Integer isFamous);
    @Query("select p from Doctor p ,DoctorFamousConsultTimesRemain w where p.code=w.doctor and w.consultDate = ?1 and p.name like name order by w.timesRemain desc")
    @Query("select p from Doctor p ,DoctorFamousConsultTimesRemain w where p.code=w.doctor and w.consultDate = ?1 and p.name like ?2 order by w.timesRemain desc")
    Page<Doctor> famousDoctorList(String date, String name, Pageable pageRequest);
    @Query("select p from Doctor p ,DoctorFamousConsultTimesRemain w where p.code=w.doctor and w.consultDate = ?1 order by w.timesRemain desc")

+ 7 - 2
src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -577,7 +577,7 @@ public class DoctorInfoService extends BaseService {
        doctor.setIsFamous(status);
    }
    public Page<Doctor> findDoctorByDept(String dept, String key, int page, int pageSize) {
    public Page<Doctor> findDoctorByDept(String dept,String hosptial, String key, int page, int pageSize) {
        if (pageSize <= 0) {
            pageSize = 10;
        }
@ -593,7 +593,12 @@ public class DoctorInfoService extends BaseService {
        if (StringUtils.isNotEmpty(key)) {
            filters.put("name", new SearchFilter("name", SearchFilter.Operator.LIKE, key));
        }
        filters.put("dept", new SearchFilter("dept", SearchFilter.Operator.EQ, dept));
        if (StringUtils.isNotEmpty(dept)) {
            filters.put("dept", new SearchFilter("dept", SearchFilter.Operator.EQ, dept));
        }
        if (StringUtils.isNotEmpty(hosptial)) {
            filters.put("hosptial", new SearchFilter("hosptial", SearchFilter.Operator.EQ, hosptial));
        }
        Specification<Doctor> spec = DynamicSpecifications.bySearchFilter(filters.values(), Doctor.class);
        return doctorDao.findAll(spec, pageRequest);

+ 1 - 1
src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -1383,7 +1383,7 @@ public class FamilyContractService extends BaseService {
    public SignFamily findByJiatingPatient(String code) {
        return signFamilyDao.findFamilySignByPatient(code);
        return signFamilyDao.findByjiatingPatientYes(code);
    }
    /**

+ 74 - 29
src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -14,6 +14,7 @@ import com.yihu.wlyy.util.DateUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.keyvalue.core.IterableConverter;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -63,6 +64,21 @@ public class StatisticsService extends BaseService {
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 缓存人口数据到redis
     *
     * @return
     */
    public boolean peopleNumToRedis() {
        Iterable<PopulationBase> peopleNums = peopleNumDao.findAll();
        for (PopulationBase peopleNum : peopleNums) {
            redisTemplate.opsForValue().set("people:num:" + peopleNum.getCode(), new JSONObject(peopleNum).toString());
        }
        return true;
    }
    /**
     * 查询截止某个日期累计量
     *
@ -126,19 +142,22 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public JSONObject getSignRate(String endDate, String area, int level) throws Exception {
        JSONObject json =  new JSONObject();
        JSONObject json = new JSONObject();
        long signAmount = getTotalAmount(endDate, area, level, SIGN);
        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
        DecimalFormat df = new DecimalFormat("0.0000");
        if (peopleNum != null && peopleNum.getNum() > 0) {
            json.put("rate",df.format((signAmount * 1.0000) / peopleNum.getNum() * 100));
            json.put("sign",signAmount);
            json.put("rate", df.format((signAmount * 1.0000) / peopleNum.getNum() * 100));
            json.put("sign", signAmount);
            json.put("people", peopleNum.getNum());
            return json;
        } else {
            throw new Exception("户籍任务人口数为0");
            json.put("rate", "0.0000");
            json.put("sign", signAmount);
            json.put("people", 0);
        }
        return json;
    }
    /**
@ -150,19 +169,22 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public JSONObject getSignTaskRate(String endDate, String area, int level) throws Exception {
        JSONObject json =  new JSONObject();
        JSONObject json = new JSONObject();
        long signAmount = getTotalAmount(endDate, area, level, SIGN);
        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
        DecimalFormat df = new DecimalFormat("0.0000");
        if (peopleNum != null && peopleNum.getTaskNum() > 0) {
            json.put("rate",df.format((signAmount * 1.0000) / peopleNum.getTaskNum() * 100));
            json.put("sign",signAmount);
            json.put("rate", df.format((signAmount * 1.0000) / peopleNum.getTaskNum() * 100));
            json.put("sign", signAmount);
            json.put("people", peopleNum.getTaskNum());
            return json;
        } else {
            throw new Exception("户籍人口任务数为0");
            json.put("rate", "0.0000");
            json.put("sign", signAmount);
            json.put("people", 0);
        }
        return json;
    }
    /**
@ -409,11 +431,13 @@ public class StatisticsService extends BaseService {
            }
        }
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
        // 查询语句
        String sql = " select " +
                "     ifnull(" + lowLevelField + ",'') code " +
                "     ,ifnull(" + lowLevelName + ",'') 'name' " +
                "     ,ifnull(sum(result),0) amount" +
                "     ,ifnull(sum(result),0.0) amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
@ -429,11 +453,11 @@ public class StatisticsService extends BaseService {
            sql += " order by amount asc ";
        }
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{(StringUtils.isEmpty(lowLevel)?(level - 1):lowLevel), endDate, area});
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, endDate, area});
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
            resultList = new ArrayList<>();
            if (level == 4) {
            if (low_level.equals("3")) {
                List<Town> towns = townDao.findByCityCode(area);
                if (towns != null) {
                    for (Town town : towns) {
@ -441,9 +465,10 @@ public class StatisticsService extends BaseService {
                        obj.put("code", town.getCode());
                        obj.put("name", town.getName());
                        obj.put("amount", Double.valueOf("0.0"));
                        obj.put("rate", Double.valueOf("0.0000"));
                    }
                }
            } else if (level == 3) {
            } else if (low_level.equals("2")) {
                List<Hospital> hospitals = hospitalDao.findByTownCode(area);
                if (hospitals != null) {
                    for (Hospital hos : hospitals) {
@ -451,9 +476,10 @@ public class StatisticsService extends BaseService {
                        obj.put("code", hos.getCode());
                        obj.put("name", hos.getName());
                        obj.put("amount", Double.valueOf("0.0"));
                        obj.put("rate", Double.valueOf("0.0000"));
                    }
                }
            } else if (level == 2) {
            } else if (low_level.equals("1")) {
                List<Doctor> doctors = doctorDao.findDoctorByLevelAndHospital(area, 2);
                if (doctors != null) {
                    for (Doctor doc : doctors) {
@ -467,18 +493,35 @@ public class StatisticsService extends BaseService {
        }
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.0000");
            for (Map<String, Object> map : resultList) {
                map.put("amount", map.get("amount") != null ? Math.round((double) map.get("amount")) : 0);
                // 截止日期包含当天,则从redis查询当天统计数据
                if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + (StringUtils.isEmpty(lowLevel)?(level - 1):lowLevel) + ":" + code);
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code);
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num") && valJson.getInt("num") > 0) {
                            map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
                        }
                    }
                    if (!low_level.equals("1")) {
                        String redisNum = redisTemplate.opsForValue().get("people:num:" + map.get("code").toString());
                        if (StringUtils.isEmpty(redisNum)) {
                            PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                            if (peopleNum != null) {
                                map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                            }
                        } else {
                            JSONObject peopleNum = new JSONObject(redisNum);
                            if (peopleNum != null) {
                                map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getInt("num") * 100));
                            }
                        }
                    }
                }
            }
@ -513,7 +556,7 @@ public class StatisticsService extends BaseService {
     * @param index     指标
     * @return
     */
    public JSONArray getLowLevelIncrementDetail(String startDate, String endDate, String area, int level, String index, int sort,String lowLevel) throws Exception {
    public JSONArray getLowLevelIncrementDetail(String startDate, String endDate, String area, int level, String index, int sort, String lowLevel) throws Exception {
        String areaField = "";
        String lowLevelField = "";
        String lowLevelName = "";
@ -552,11 +595,13 @@ public class StatisticsService extends BaseService {
            }
        }
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
        // 查询语句
        String sql = " select " +
                "     ifnull(" + lowLevelField + ",'') code " +
                "     ,ifnull(" + lowLevelName + ",'') 'name' " +
                "     ,ifnull(sum(result),0) amount" +
                "     ,ifnull(sum(result),0.0) amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
@ -573,12 +618,12 @@ public class StatisticsService extends BaseService {
            sql += " order by amount asc ";
        }
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{(StringUtils.isEmpty(lowLevel)?(level - 1):lowLevel), startDate, endDate, area});
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, startDate, endDate, area});
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
            resultList = new ArrayList<>();
            if (level == 4) {
            if (low_level.equals("3")) {
                List<Town> towns = townDao.findByCityCode(area);
                if (towns != null) {
                    for (Town town : towns) {
@ -589,7 +634,7 @@ public class StatisticsService extends BaseService {
                        resultList.add(obj);
                    }
                }
            } else if (level == 3) {
            } else if (low_level.equals("2")) {
                List<Hospital> hospitals = hospitalDao.findByTownCode(area);
                if (hospitals != null) {
                    for (Hospital hos : hospitals) {
@ -600,7 +645,7 @@ public class StatisticsService extends BaseService {
                        resultList.add(obj);
                    }
                }
            } else if (level == 2) {
            } else if (low_level.equals("1")) {
                List<Doctor> doctors = doctorDao.findDoctorByLevelAndHospital(area, 2);
                if (doctors != null) {
                    for (Doctor doc : doctors) {
@ -620,7 +665,7 @@ public class StatisticsService extends BaseService {
                // 截止日期包含当天,则从redis查询当天统计数据
                if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + (StringUtils.isEmpty(lowLevel)?(level - 1):lowLevel) + ":" + code);
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code);
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num") && valJson.getInt("num") > 0) {
@ -760,7 +805,7 @@ public class StatisticsService extends BaseService {
        sql = " select " +
                "     ifnull(quota_date,'') as 'range' " +
                "     ,ifnull(sum(result),0) amount " +
                "     ,ifnull(sum(result),0.0) amount " +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
@ -927,7 +972,7 @@ public class StatisticsService extends BaseService {
        // 查询时间范围内所有记录
        sql = " select " +
                "     ifnull(quota_date,'') as 'range' " +
                "     ,ifnull(sum(result),0) amount " +
                "     ,ifnull(sum(result),0.0) amount " +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
@ -1123,7 +1168,7 @@ public class StatisticsService extends BaseService {
        // 查询时间范围内所有记录
        sql = " select " +
                "     ifnull(quota_date,'') as 'range' " +
                "     ,ifnull(sum(result),0) amount " +
                "     ,ifnull(sum(result),0.0) amount " +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
@ -1225,7 +1270,7 @@ public class StatisticsService extends BaseService {
        String sql = " select " +
                "     ifnull(level2_type,'') code " +
                "     ,ifnull(level2_type_name,'') 'name' " +
                "     ,ifnull(sum(result),0) amount" +
                "     ,ifnull(sum(result),0.0) amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
@ -1457,7 +1502,7 @@ public class StatisticsService extends BaseService {
        String sql = " select " +
                "     ifnull(level3_type,'') code " +
                "     ,ifnull(level3_type_name,'') 'name' " +
                "     ,ifnull(sum(result),0) amount" +
                "     ,ifnull(sum(result),0.0) amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
@ -1571,7 +1616,7 @@ public class StatisticsService extends BaseService {
        // 查询语句
        String sql = " select " +
                "     ifnull(sum(result),0) amount" +
                "     ifnull(sum(result),0.0) amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +

+ 66 - 29
src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -4,6 +4,7 @@ import com.yihu.wlyy.job.QuartzHelper;
import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,7 +23,7 @@ import java.util.HashMap;
@RestController
@RequestMapping(value = "/manage_util")
@Api(description = "管理工具及后台任务控制")
public class ManagerUtilController extends BaseController{
public class ManagerUtilController extends BaseController {
    @Autowired
    PatientDiseaseService diseaseService;
@ -32,19 +33,22 @@ public class ManagerUtilController extends BaseController{
    QuartzHelper quartzHelper;
    @Autowired
    DoctorWorkTimeService workTimeService;
    @Autowired
    StatisticsService statisticsService;
    /*********************************************患者疾病相关******************************************/
    /**
     * 更新到redis
     *
     * @return
     */
    @RequestMapping(value = "/disease/to_redis")
    public String updateToRedid(){
        try{
    public String updateToRedid() {
        try {
            diseaseService.updateToRedis();
            return write(200,"更新成功");
        }catch (Exception e){
            return error(-1,"更新失败");
            return write(200, "更新成功");
        } catch (Exception e) {
            return error(-1, "更新失败");
        }
    }
@ -54,49 +58,82 @@ public class ManagerUtilController extends BaseController{
     * @return
     */
    @RequestMapping(value = "/disease/to_disease")
    public String updateToDisease(){
        try{
    public String updateToDisease() {
        try {
            diseaseService.updateToDisease();
            return write(200,"更新成功");
        }catch (Exception e){
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"更新失败");
            return error(-1, "更新失败");
        }
    }
    /**
     * 查询患者redis疾病
     *
     * @param patient
     * @return
     */
    @RequestMapping(value = "/disease/patient")
    public String getDiseaseFromRedis(String patient){
        try{
            return write(200,"查询成功","data",redisTemplate.opsForValue().get("disease:" + patient));
        }catch (Exception e){
    public String getDiseaseFromRedis(String patient) {
        try {
            return write(200, "查询成功", "data", redisTemplate.opsForValue().get("disease:" + patient));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
            return error(-1, "查询失败");
        }
    }
    /***********************************************名医咨询相关****************************************/
    /**
     * 开始名医咨询剩余次数统计任务
     *
     * @return
     */
    @RequestMapping(value = "/famous_doctor/start_job")
    public String startConsultTimesJob(){
        try{
            if(!quartzHelper.isExistJob("famous-doctor-times")) {
    public String startConsultTimesJob() {
        try {
            if (!quartzHelper.isExistJob("famous-doctor-times")) {
                quartzHelper.addJob(FamousConsultTimesJob.class, "0 0 0 * * ?", "famous-doctor-times", new HashMap<String, Object>());
                return write(200,"启动成功");
            }else{
                return write(200,"任务已存在");
                return write(200, "启动成功");
            } else {
                return write(200, "任务已存在");
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"启动失败");
            return error(-1, "启动失败");
        }
    }
    /**
     * 名医咨询剩余次数手动更新
     *
     * @return
     */
    @RequestMapping(value = "/famous_doctor/times_update")
    public String famousConsultTimeUpdate(){
        try{
    public String famousConsultTimeUpdate() {
        try {
            workTimeService.consultTimesRemain(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
            return write(200,"更新成功");
        }catch (Exception e){
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
    /*********************************************统计相关*******************************************/
    /**
     * 更新人口数据到redis
     *
     * @return
     */
    public String peopleNumToRedis() {
        try {
            statisticsService.peopleNumToRedis();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"更新失败");
            return error(-1, "更新失败");
        }
    }
}

+ 3 - 2
src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -281,13 +281,14 @@ public class DoctorController extends BaseController {
    @RequestMapping(value = "findDoctorByDept")
    @ResponseBody
    public String findDoctorByDept(
            String dept,
            @RequestParam(required = false)String dept,
            @RequestParam(required = false)String hosptial,
            @RequestParam(required = false) String key,
            int page,
            int pagesize) {
        try {
            JSONArray array = new JSONArray();
            Page<Doctor> list = doctorInfoService.findDoctorByDept(dept, key, page, pagesize);
            Page<Doctor> list = doctorInfoService.findDoctorByDept(dept,hosptial, key, page, pagesize);
            if (list != null) {
                for (Doctor doctor : list) {
                    JSONObject json = new JSONObject();

+ 82 - 40
src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -155,7 +155,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
     * @param group      患者组 1是健康人群组 2是慢病  3是65岁以上人群
     * @param emerMobile 应急人手机号
     * @param images     图片URL,多图以逗号分隔
     * @param expenses     签约费用
     * @param expenses   签约费用
     * @return
     */
    @RequestMapping(value = "agent")
@ -163,7 +163,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    public String agent(
            String name,
            String idcard,
            @RequestParam(required = false)String ssc,
            @RequestParam(required = false) String ssc,
            String mobile,
            @RequestParam(required = false, defaultValue = "") String disease,
            @RequestParam(required = false) String emerMobile,
@ -172,7 +172,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            String healthDoctor,
            String healthDoctorName,
            String images,
            @RequestParam(required = false,defaultValue = "0") String expenses,
            @RequestParam(required = false, defaultValue = "0") String expenses,
            String doctor,//全科医生code
            String doctorName,//全科医生名字
            String signDoctorCode,//簽約人code
@ -216,7 +216,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            if (StringUtils.isEmpty(idcard)) {
                return error(-1, "身份证号不允许为空!");
            }
            if(StringUtils.isEmpty(ssc)){
            if (StringUtils.isEmpty(ssc)) {
                return error(-1, "社保卡号不允许为空!");
            }
            if (StringUtils.isEmpty(mobile)) {
@ -236,7 +236,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            Doctor cDoctor = doctorService.findDoctorByCode(getUID());
            SignFamily sf = familyContractService.agent(getAccessToken(), name, doctor, doctorName,
                    healthDoctor, healthDoctorName, majorDoctor, majorDoctorName, cDoctor.getHospital(), cDoctor.getHosptialName(),
                    idcard, ssc, mobile, emerMobile, images, disease,expenses,signDoctorCode,signDoctorName,signDoctorLevel,group);
                    idcard, ssc, mobile, emerMobile, images, disease, expenses, signDoctorCode, signDoctorName, signDoctorLevel, group);
            if (sf == null) {
                return error(-1, "代理签约失败!");
@ -257,7 +257,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
     * @param healthDoctorName 健康管理师姓名
     * @param majorDoctor      专科医生标识
     * @param disease          疾病code
     * @param majorhDoctorName 专科医生姓名
     * @param msgid            消息id
     * @param patientIDcard    患者身份证
     * @param type             处理类型:1同意,2拒绝
@ -275,10 +274,10 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            @RequestParam(required = false) String majorDoctorName,
            long msgid,
            String patientIDcard,
            int type,String group,
            @RequestParam(required = false,defaultValue = "0") String expenses) {
            int type, String group,
            @RequestParam(required = false, defaultValue = "0") String expenses) {
        try {
            int res = familyContractService.handleSign(signType, getAccessToken(), healthDoctor, healthDoctorName, msgid, patientIDcard, type, disease, majorDoctor, majorDoctorName,group,expenses);
            int res = familyContractService.handleSign(signType, getAccessToken(), healthDoctor, healthDoctorName, msgid, patientIDcard, type, disease, majorDoctor, majorDoctorName, group, expenses);
            if (res == -1) {
                return error(-1, "未知的处理类型!");
            } else if (res == 0) {
@ -454,17 +453,17 @@ public class DoctorFamilyContractController extends WeixinBaseController {
     */
    @RequestMapping(value = "patient_sanshi_signinfo")
    @ResponseBody
    public String getPatientSanshiSignByIdCard(String idCard){
        try{
            if(StringUtils.isEmpty(idCard)){
                return error(-1,"请输入身份证号!");
    public String getPatientSanshiSignByIdCard(String idCard) {
        try {
            if (StringUtils.isEmpty(idCard)) {
                return error(-1, "请输入身份证号!");
            }
            JSONObject result = familyContractService.getSanshiSingInfoByPatientIdCard(idCard);
            return write(200,"查询成功!","data",result);
        }catch (Exception e){
            return error(-1,"查询失败!");
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败!");
        }
    }
@ -472,28 +471,38 @@ public class DoctorFamilyContractController extends WeixinBaseController {
     * 更新患者签约补贴类型
     *
     * @param expensesType 补贴类型
     * @param patient 患者
     * @param patient      患者
     * @return
     */
    @RequestMapping(value = "/expenses_type_update")
    @ResponseBody
    public String updateExpensesType(String expensesType,String patient){
        try{
            if(StringUtils.isEmpty(expensesType)){
                return error(-1,"补贴类型不能为空");
    public String updateExpensesType(String expensesType, String patient) {
        try {
            if (StringUtils.isEmpty(expensesType)) {
                return error(-1, "补贴类型不能为空");
            }
            if(StringUtils.isEmpty(patient)){
                return error(-1,"患者不能为空");
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");
            }
            if(familyContractService.updateExpensesType(expensesType,patient)){
                return write(200,"更新成功");
            }else{
                return write(-1,"不存在该患者签约");
            SignFamily familySign = familyContractService.findByPatient(patient);
            if (familySign == null) {
                return error(-1, "居民家庭签约不存在");
            } else {
                if (StringUtils.isNotEmpty(familySign.getMedicalInsuranceNum())) {
                    return error(-1, "数据已上传社保,不能修改补贴类型");
                }
            }
            if (familyContractService.updateExpensesType(expensesType, patient)) {
                return write(200, "更新成功");
            } else {
                return write(-1, "不存在该患者签约");
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"更新失败");
            return error(-1, "更新失败");
        }
    }
@ -505,8 +514,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
     */
    @RequestMapping(value = "/patient_signing")
    @ResponseBody
    public String getSigningPatientInfo(String patient){
        try{
    public String getSigningPatientInfo(String patient) {
        try {
            Patient temp = patientInfoService.findByCode(patient);
            if (temp != null) {
                JSONObject json = new JSONObject();
@ -541,20 +550,20 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                json.put("ssc", temp.getSsc());
                String diseases = redisTemplate.opsForValue().get("disease:" + patient);
                if(!StringUtils.isEmpty(diseases)){
                    json.put("diseases",new JSONArray(diseases));
                }else{
                    json.put("diseases","");
                if (!StringUtils.isEmpty(diseases)) {
                    json.put("diseases", new JSONArray(diseases));
                } else {
                    json.put("diseases", "");
                }
                SignFamily jtSign = familyContractService.findSigningByPatient(patient);
                // 家庭签约
                if(jtSign != null){
                if (jtSign != null) {
                    json.put("applySurrDate", jtSign.getPatientApplyUnsignDate());
                    json.put("applyDate", jtSign.getPatientApplyDate());
                    json.put("jtSign",new JSONObject(jtSign));
                }else{
                    json.put("jtSign", new JSONObject(jtSign));
                } else {
                    throw new Exception("未找到患者待家庭签约的数据");
                }
@ -562,9 +571,42 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            } else {
                return error(-1, "患者信息查询失败!");
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "患者信息查询失败");
        }
    }
    /**
     * 获取家庭签约社保流水号
     *
     * @param patient
     * @return
     */
    @RequestMapping(value = "/medical_insurance_num")
    @ResponseBody
    public String getMedicalInsuranceNum(String patient) {
        try {
            JSONObject json = new JSONObject();
            SignFamily familySign = familyContractService.findByPatient(patient);
            if (familySign != null) {
                if (StringUtils.isNotEmpty(familySign.getMedicalInsuranceNum())) {
                    json.put("status", 1); // 已上传社保
                    json.put("medicalInsuranceNum", familySign.getMedicalInsuranceNum());
                } else {
                    json.put("status", 0);
                    json.put("medicalInsuranceNum", "");
                }
            } else {
                json.put("status", -1); // 没有家庭签约
                json.put("medicalInsuranceNum", "");
            }
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"患者信息查询失败");
            return error(-1, "查询失败");
        }
    }
}

+ 19 - 0
src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -1,11 +1,13 @@
package com.yihu.wlyy.web.statistic;
import com.yihu.wlyy.entity.statistics.PopulationBase;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@ -21,6 +23,23 @@ public class StatisticsController extends BaseController {
    @Autowired
    StatisticsService statisticsService;
    /**
     * 缓存人口数据到redis
     *
     * @return
     */
    @RequestMapping(value = "/people_num_to_redis")
    @ResponseBody
    public String peopleNumToRedis(){
        try{
            statisticsService.peopleNumToRedis();
            return write(200,"更新成功");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"更新失败");
        }
    }
    /**
     * 指标按间隔统计
     *