瀏覽代碼

客服系统搬迁

wangzhinan 2 年之前
父節點
當前提交
87179bb4d1
共有 100 個文件被更改,包括 17228 次插入3 次删除
  1. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  2. 37 0
      business/base-service/src/mqConfig/mqdata/MS53001.json
  3. 3 0
      gateway/ag-basic/src/main/resources/application.yml
  4. 2 2
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/config/war/ServletInitializer.java
  5. 58 0
      svr/svr-manage/doc/es/平台咨讯推送记录新增索引
  6. 72 0
      svr/svr-manage/doc/es/平台咨讯操作日志新增索引
  7. 373 0
      svr/svr-manage/pom.xml
  8. 27 0
      svr/svr-manage/src/main/java/com/yihu/customer/SvrManageApplication.java
  9. 132 0
      svr/svr-manage/src/main/java/com/yihu/customer/config/ElasticFactory.java
  10. 53 0
      svr/svr-manage/src/main/java/com/yihu/customer/config/MvcConfig.java
  11. 316 0
      svr/svr-manage/src/main/java/com/yihu/customer/config/SaveModel.java
  12. 15 0
      svr/svr-manage/src/main/java/com/yihu/customer/config/SpringSecurityAuditorAware.java
  13. 48 0
      svr/svr-manage/src/main/java/com/yihu/customer/config/SwaggerDocs.java
  14. 644 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/BaseController.java
  15. 534 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/WeixinBaseController.java
  16. 87 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/common/district/DistrictController.java
  17. 48 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/common/label/SignPatientLabelController.java
  18. 100 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/export/excel/DoctorController.java
  19. 141 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/export/excel/ElasticSearchController.java
  20. 98 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/gateway/model/BaseResultModel.java
  21. 33 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/gateway/model/GcClientDetailsModel.java
  22. 51 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/gateway/model/GcTokenModel.java
  23. 39 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/gateway/model/ResultOneModel.java
  24. 47 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/AdminController.java
  25. 17 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/MainController.java
  26. 124 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/account/ShiroDbRealm.java
  27. 132 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/appeal/AppealController.java
  28. 167 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/basedata/BaseDataImportController.java
  29. 21 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/basedata/OperateExportController.java
  30. 106 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/consult/ConsultRemindController.java
  31. 125 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/consult/ConsultReplyController.java
  32. 21 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/DeviceStaticController.java
  33. 155 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/DoorController.java
  34. 156 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/HealthEduController.java
  35. 65 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/PayLogController.java
  36. 141 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/RehabilitationPatientController.java
  37. 133 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/ReplyStaticController.java
  38. 175 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/WeChatStaticController.java
  39. 243 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/DeviceHealthIndexController.java
  40. 127 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/DeviceManufacturerController.java
  41. 115 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/IotDeviceController.java
  42. 271 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/WlyyDeviceController.java
  43. 210 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/WlyyPatientDeviceController.java
  44. 312 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/dict/ManageDictController.java
  45. 192 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/dict/ManageDictEntryController.java
  46. 111 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/dict/SystemDictController.java
  47. 130 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/feedback/FeedbackController.java
  48. 223 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/ActivityController.java
  49. 161 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/HealthPlanController.java
  50. 173 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/HealthtaskController.java
  51. 111 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/TaskController.java
  52. 136 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/TaskRuleController.java
  53. 149 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthchannel/ChannelController.java
  54. 279 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthchannel/ChannelRecommendArticleController.java
  55. 140 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/hos/HlwyyHospitalController.java
  56. 324 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/hos/HosController.java
  57. 783 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/hos/HosDoctorController.java
  58. 130 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/hos/HosPharmacyController.java
  59. 430 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/integratedquery/IntegratedQueryController.java
  60. 60 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/messager/MessagerController.java
  61. 361 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/NotificationController.java
  62. 234 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/PlatformInformationController.java
  63. 195 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/WechatTemplateController.java
  64. 7 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/WlyyAuditNoticeController.java
  65. 7 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/WlyyAuditNoticeObjectController.java
  66. 8 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/WlyyAuditNoticeScopeController.java
  67. 314 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/patient/AdminPatientController.java
  68. 260 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/patient/CopdPatientController.java
  69. 246 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/pneumonia/PneumoniaController.java
  70. 47 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/refinement/RefinementController.java
  71. 226 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/satisfaction/SatisfactionController.java
  72. 452 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/sign/SignFamilyController.java
  73. 34 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/special/SpecialDiseaseController.java
  74. 158 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/specialist/HopsitalServiceItemController.java
  75. 164 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/specialist/ServiceItemController.java
  76. 77 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/QuestionnaireController.java
  77. 53 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyAdviceController.java
  78. 206 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyQuestionController.java
  79. 64 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyTemplateAdviceController.java
  80. 199 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyTemplateController.java
  81. 58 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyTemplateResultController.java
  82. 378 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/team/WlyyAdminTeamController.java
  83. 462 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageFeatureController.java
  84. 268 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageRangeController.java
  85. 235 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageRoleFeatureController.java
  86. 173 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageRoleUserController.java
  87. 255 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageRolesController.java
  88. 286 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/UserController.java
  89. 58 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/vaccin/VaccinController.java
  90. 44 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/wlyyrole/WlyyRoleController.java
  91. 59 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/wlyyrole/WlyyUserRoleController.java
  92. 242 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/yueren/YueRenController.java
  93. 151 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/statistics/CallRecordStaticsController.java
  94. 220 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/CustomerQuestionnaireController.java
  95. 48 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/CustomerScreenResultController.java
  96. 1191 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/CustomerSynergyManageController.java
  97. 307 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/KnowledgeArticleController.java
  98. 121 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/KnowledgeCategoryController.java
  99. 53 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/doctor/DoctorQuestionnaireController.java
  100. 0 0
      svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/doctor/DoctorSynergyManageController.java

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -7562,7 +7562,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            List<WlyyDoctorWorkTimeVO> timeVOs = new ArrayList<>();
            return convertToModels(times, timeVOs, WlyyDoctorWorkTimeVO.class);
        } else {
            List<WlyyDoctorWorkTimeDO> times = doctorWorkTimeDao.findDoctorWorkTimeByTime(doctor, DateUtil.stringToDate(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss"), DateUtil.stringToDate(endDate + " 23:59:59", "yyyy-MM-dd HH:mm:ss"));
            List<WlyyDoctorWorkTimeDO> times = doctorWorkTimeDao.findDoctorWorkTimeByTime(doctor, DateUtil.stringToDate(startDate, "yyyy-MM-dd HH:mm:ss"), DateUtil.stringToDate(endDate, "yyyy-MM-dd HH:mm:ss"));
            List<WlyyDoctorWorkTimeVO> timeVOs = new ArrayList<>();
            return convertToModels(times, timeVOs, WlyyDoctorWorkTimeVO.class);
        }

+ 37 - 0
business/base-service/src/mqConfig/mqdata/MS53001.json

@ -76,5 +76,42 @@
				"win_no": "6"
			}
		}
	},{
		"head": {
			"fId": "BS35014",
			"version": "2",
			"msgName": "药品字典",
			"sourceSysCode": "S01",
			"targetSysCode": "S60",
			"createTime": "20190529094914"
		},
		"body": {
			"row": {
				"action": "select",
				"charge_code": "07877 ",
				"serial": "02",
				"group_no": "71",
				"drugname": "维生素E软胶囊",
				"dosage": "01  ",
				"mini_unit": "02",
				"pack_size": "1",
				"specification": "0.1gx30粒/盒",
				"retprice": "3.562",
				"pack_retprice": "3.5619",
				"stock_amount": "275",
				"visible_flag": "0",
				"drug_flag": "1",
				"py_code": "WSSEJL",
				"pack_unit": "02",
				"manu_name": "北京萌蒂",
				"weigh_unit": "16",
				"vol_unit": [],
				"mini_unit_name": "粒",
				"pack_unit_name": "粒",
				"weigh_unit_name": "g",
				"vol_unit_name": [],
				"win_no": "6"
			}
		}
	}]
}

+ 3 - 0
gateway/ag-basic/src/main/resources/application.yml

@ -124,6 +124,9 @@ zuul:
    svr-internet-hospital-entrance:
      path: /hospitalEntrance/**
      serviceId: svr-internet-hospital-entrance
    svr-manage:
      path: /manage/**
      serviceId: svr-manage
    svr-door-service:
      path: /doorService/**
      serviceId: svr-door-service

+ 2 - 2
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/config/war/ServletInitializer.java

@ -1,6 +1,6 @@
//package com.yihu.jw.config.war;//package com.yihu.wlyy.config.war;
//package com.yihu.jw.config.war;//package com.yihu.jw.wlyy.config.war;
//
//import com.yihu.wlyy.Application;
//import com.yihu.jw.wlyy.Application;
//import org.springframework.boot.builder.SpringApplicationBuilder;
//import org.springframework.boot.web.support.SpringBootServletInitializer;
//

+ 58 - 0
svr/svr-manage/doc/es/平台咨讯推送记录新增索引

@ -0,0 +1,58 @@
创建索引
POST  http://172.19.103.68:9200/platform_information_push_record
查询索引
GET http://172.19.103.68:9200/platform_information_push_record/
设置查询长度
PUT settings http://172.19.103.68:9200/platform_information_push_record/_settings
{
  "index": {
    "max_result_window": 500000
  }
}
给索引加mapping
POST http://172.19.103.68:9200/platform_information_push_record/platform_information_push_record/_mapping
{
    "platform_information_push_record": {
        "properties": {
            "id": {
                "type": "string",
                "index": "not_analyzed"
            },
            "batchNo": {
                "type": "string",
                "index": "not_analyzed"
            },
            "type": {
                "type": "integer"
                "index": "not_analyzed"
            },
            "receiverCode": {
                "type": "string",
                "index": "not_analyzed"
            },
            "receiverName": {
                "type": "string",
                "index": "not_analyzed"
            },
            "informationId": {
                "type": "long",
                "index": "not_analyzed"
            },
            "informationTitle": {
                "type": "string",
                "index": "not_analyzed"
            },
            "informationContent": {
                "type": "string",
                "index": "not_analyzed"
            },
            "status": {
                "type": "integer"
            },
            "createTime": {
                "format": "strict_date_optional_time||epoch_millis",
                "type": "date"
            }
        }
    }
}

+ 72 - 0
svr/svr-manage/doc/es/平台咨讯操作日志新增索引

@ -0,0 +1,72 @@
创建索引
POST  http://172.19.103.68:9200/platform_information_log
查询索引
GET http://172.19.103.68:9200/platform_information_log/
设置查询长度
PUT http://172.19.103.68:9200/platform_information_log/_settings
{
  "index": {
    "max_result_window": 500000
  }
}
给索引加mapping
POST http://172.19.103.68:9200/platform_information_log/platform_information_log/_mapping
{
	"platform_information_log": {
		"properties": {
			"id": {
				"type": "string",
				"index": "not_analyzed"
			},
			"informationId": {
				"type": "long"
			},
			"informationTitle": {
				"type": "string",
				"index": "not_analyzed"
			},
			"operationType": {
				"type": "integer"
			},
			"openid": {
				"type": "string",
				"index": "not_analyzed"
			},
			"doctorCode": {
				"type": "string",
				"index": "not_analyzed"
			},
			"doctorName": {
				"type": "string",
				"index": "not_analyzed"
			},
			"type": {
				"type": "integer"
			},
			"createTime": {
				"format": "strict_date_optional_time||epoch_millis",
				"type": "date"
			},
			"patientLabels": {
				"type": "string",
				"index": "not_analyzed"
			},
			"orgName": {
				"type": "string",
				"index": "not_analyzed"
			},
			"cityName": {
				"type": "string",
				"index": "not_analyzed"
			},
			"townName": {
				"type": "string",
				"index": "not_analyzed"
			}
			"platInfoCreateTime": {
                            "format": "strict_date_optional_time||epoch_millis",
            				"type": "date"
                        }
		}
	}
}

+ 373 - 0
svr/svr-manage/pom.xml

@ -0,0 +1,373 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yihu.jw</groupId>
        <artifactId>wlyy-parent-pom</artifactId>
        <version>2.4.0</version>
        <relativePath>../../wlyy-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yihu.jw</groupId>
    <artifactId>svr-manage</artifactId>
    <packaging>jar</packaging>
    <version>${project.parent.version}</version>
    <properties>
        <springside.version>4.2.3-GA</springside.version>
        <shiro.version>1.2.3</shiro.version>
        <commons-lang3.version>3.3.2</commons-lang3.version>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>
    <dependencies>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <!--注释掉就不会读取git的配置,只会读取yml中的配置-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <!--<dependency>-->
        <!--<groupId>com.ylz.loginsdk</groupId>-->
        <!--<artifactId>ehcsdk</artifactId>-->
        <!--<version>1.0</version>-->
        <!--</dependency>-->
        <dependency>
            <groupId>com.ylz.dmrh</groupId>
            <artifactId>ehcsdk-java-sdk-base</artifactId>
            <version>1.0.3</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>wxpay-sdk</artifactId>
            <version>3.0.9</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-request-mapping</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-exception</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-web</artifactId>
        </dependency>
        <!-- 文件服务器 -->
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>fastdfs-starter</artifactId>
        </dependency>
        <!-- Jzkl Starter -->
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>swagger-starter</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>mysql-starter</artifactId>
            <version>${version.yihu-common}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>tomcat-jdbc</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <!-- <scope>runtime</scope> -->
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!--<dependency>-->
        <!--<groupId>com.yihu</groupId>-->
        <!--<artifactId>elasticsearch-starter</artifactId>-->
        <!--<version>2.0.0</version>-->
        <!--</dependency>-->
        <dependency>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup</artifactId>
            <version>1.3.2</version>
            <exclusions>
                <exclusion>
                    <artifactId>mailapi</artifactId>
                    <groupId>javax.mail</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- 发送邮件 -->
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.4.7</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <!--   poi xml导入导出工具 start-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.yihu.ehr</groupId>
                    <artifactId>commons-util</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-collections4</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
        </dependency>
        <!-- xlsx  依赖这个包 -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <!--   poi xml导入导出工具 end -->
        <!--基础业务组件-->
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>base-service</artifactId>
            <version>${version.wlyy-common}</version>
            <exclusions>
                <exclusion>
                    <groupId>xalan</groupId>
                    <artifactId>xalan</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--<dependency>-->
        <!--<groupId>com.yihu.jw</groupId>-->
        <!--<artifactId>sms-service</artifactId>-->
        <!--<version>2.0.0</version>-->
        <!--<scope>compile</scope>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-commons</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!--缩略图-->
        <dependency>
            <groupId>net.coobird</groupId>
            <artifactId>thumbnailator</artifactId>
            <version>0.4.8</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>${version.json-lib}</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>im-service</artifactId>
            <version>${version.wlyy-common}</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>sms-service</artifactId>
            <version>${version.wlyy-common}</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>es-service</artifactId>
            <version>${version.wlyy-common}</version>
        </dependency>
        <!--oracle驱动-->
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>${version.oracle}</version>
        </dependency>
        <dependency>
            <groupId>org.springside</groupId>
            <artifactId>springside-core</artifactId>
            <version>4.2.3-GA</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-spring</artifactId>
            <version>${shiro.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-ehcache</artifactId>
            <version>1.2.3</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>svr-manage</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 -->
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <!-- 是否要把第三方jar加入到类构建路径 -->
                            <addClasspath>true</addClasspath>
                            <!-- 外部依赖jar包的最终位置 -->
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.yihu.customer.SvrManageApplication</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!--拷贝依赖到jar外面的lib目录-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-lib</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <!-- 依赖包输出目录,将来不打进jar包里 -->
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <excludeTransitive>false</excludeTransitive>
                            <stripVersion>false</stripVersion>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--指定配置文件,将resources打成外部resource-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <!-- 指定配置文件目录,这样jar运行时会去找到同目录下的resources文件夹下查找 -->
                        <manifestEntries>
                            <Class-Path>resources/</Class-Path>
                        </manifestEntries>
                    </archive>
                    <!-- 打包时忽略的文件(也就是不打进jar包里的文件) -->
                    <excludes>
                        <exclude>**/*.yml</exclude>
                        <exclude>**/*.xml</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <!-- 拷贝资源文件 外面的resource目录-->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <!-- 资源文件输出目录 -->
                            <outputDirectory>${project.build.directory}/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

+ 27 - 0
svr/svr-manage/src/main/java/com/yihu/customer/SvrManageApplication.java

@ -0,0 +1,27 @@
package com.yihu.customer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
/**
 * Created by Administrator on 2016/6/18.
 */
@SpringBootApplication
@EnableJpaAuditing
public class SvrManageApplication extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(SvrManageApplication.class, args);
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SvrManageApplication.class);
    }
}

+ 132 - 0
svr/svr-manage/src/main/java/com/yihu/customer/config/ElasticFactory.java

@ -0,0 +1,132 @@
/*
package com.yihu.jw.config.es;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.config.HttpClientConfig;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
*/
/**
 * Created by chenweida on 2017/6/5.
 *//*
@Component
public class ElasticFactory {
    private static JestClientFactory factory = null;
    @Value("${es.host}")
    private String esHost;//http://59.61.92.90:9065,http://59.61.92.90:9067
    @Value("${es.tHost}")
    private String tHost;// 59.61.92.90:9066,59.61.92.90:9068
    @Value("${es.clusterName}")
    private String clusterName;
    @Value("${es.user}")
    private String user;
    @Value("${es.password}")
    private String password;
    @Value("${es.pwflag}")
    private String pwflag;
//-----------------------------------jestClient----------------------------------------
    */
/**
     * @param "http://localhost:9200"
     * @return
     *//*
    public JestClient getJestClient() {
        if (factory == null) {
            //初始化链接
            init();
        }
        return factory.getObject();
    }
    */
/**
     * 初始化链接
     * 9200
     *//*
    public synchronized void init() {
        String[] hostArray = esHost.split(",");
        // Construct a new Jest client according to configuration via factory
        factory = new JestClientFactory();
        HttpClientConfig httpClientConfig = new HttpClientConfig
                .Builder(Arrays.asList(hostArray))
                .multiThreaded(true)
                .defaultCredentials(user,password)
                .maxTotalConnection(50)// 最大链接
                .maxConnectionIdleTime(10, TimeUnit.MINUTES)//链接等待时间
                .connTimeout(60 * 1000*10)
                // .discoveryEnabled(true)
                .readTimeout(60 * 1000*10)//60秒
                .build();
        factory.setHttpClientConfig(httpClientConfig);//得到链接
    }
    //-----------------------------------TransportClient----------------------------------------
    private TransportClient transportClient;
    public Client getTransportClient() {
        try {
            initTranClient();
            return transportClient;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    */
/**
     * 9300
     *
     * @throws UnknownHostException
     *//*
    private synchronized void initTranClient() throws UnknownHostException {
        if (transportClient == null) {
            String[] hosts = tHost.split(",");
            Settings settings = null;
            //1需要加密初始化
            if("1".equals(pwflag)){
                settings = Settings.settingsBuilder()
                        // .put("client.transport.sniff", true)//开启嗅探功能
                        .put("shield.user", user+":"+password)
                        .put("cluster.name", StringUtils.isEmpty(clusterName) ? "jkzl" : clusterName)//默认集群名字是jkzl
                        .build();
                transportClient = TransportClient.builder().addPlugin(ShieldPlugin.class).settings(settings).build();
            }else{
                settings = Settings.settingsBuilder()
                        // .put("client.transport.sniff", true)//开启嗅探功能
                        .put("cluster.name", StringUtils.isEmpty(clusterName) ? "jkzl" : clusterName)//默认集群名字是jkzl
                        .build();
                transportClient = TransportClient.builder().settings(settings).build();
            }
            for (String oneHost : hosts) {
                String[] hostAndport = oneHost.split(":");
                transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostAndport[0]), Integer.valueOf(hostAndport[1])));
            }
        }
    }
}
*/

+ 53 - 0
svr/svr-manage/src/main/java/com/yihu/customer/config/MvcConfig.java

@ -0,0 +1,53 @@
/*
package com.yihu.jw.config.es;
import com.yihu.jw.interceptors.CrosXssFilter;
import com.yihu.jw.interceptors.GateWayInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
*/
/**
 * Created by chenweida on 2017/4/6.
 *//*
@Configuration
@Profile({"mlwProd"})
public class MvcConfig extends WebMvcConfigurationSupport {
    private Logger logger = LoggerFactory.getLogger(MvcConfig.class);
    @Autowired
    private GateWayInterceptor gateWayInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
//         excludePathPatterns 用户排除拦截 ,/third/juye/kit/**
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/open/gc/**").excludePathPatterns(
                "/open/gc/accesstoken",
                "/open/gc/createGcClientDetails");
        super.addInterceptors(registry);
        logger.info("init gateWayInterceptor");
    }
    @Bean
    public FilterRegistrationBean testFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new CrosXssFilter());
        registration.addUrlPatterns("/open/gc/**");
        registration.setName("CrosXssFilter");
        registration.setOrder(1);
        return registration;
    }
}
*/

+ 316 - 0
svr/svr-manage/src/main/java/com/yihu/customer/config/SaveModel.java

@ -0,0 +1,316 @@
package  com.yihu.customer.config;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.searchbox.annotations.JestId;
import org.springframework.data.annotation.CreatedDate;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/1.
 */
public class SaveModel {
    private final static String teamKey = "team";
    private final static String OrgKey = "hospital";
    private final static String townKey = "town";
    private final static String cityKey = "city";
    public final static String interval_day="1";
    public final static String interval_week="2";
    public final static String interval_month="3";
    public final static String teamLevel = "5";
    public final static String OrgLevel = "4";
    public final static String townLevel = "3";
    public final static String cityLevel = "2";
    private static final Map<String, String> fieldsSithch = new HashMap<>();
    public final static String timeLevel_ZL="1";//增量
    public final static String timeLevel_DDL="2";//到达量
    @JestId
    private String id;
    private String saasId;//saasId
    private String quotaCode;//指标code
    private Date quotaDate;//统计时间
    private String city;//城市代码 350200
    private String cityName;//
    private String town;//区代码 350206
    private String townName;//
    private String hospital;//机构code
    private String hospitalName;//
    private String team;//团队的code
    private String teamName;//
    private String slaveKey1;//从维度  1级维度
    private String slaveKey1Name;
    private String slaveKey2;//从维度  2级维度
    private String slaveKey2Name;
    private String slaveKey3;//从维度  3级维度
    private String slaveKey3Name;
    private String slaveKey4;//从维度  4级维度
    private String slaveKey4Name;
    private Double result1 = 0.0;//统计结果(如:评分总合)
    private Double result2 = 0.0;//统计结果
    private String areaLevel;// 1 省 2 市 3 区县 4 机构 5团队
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMdd'T'HHmmss.SSS'Z'")
    @CreatedDate
    private Date createTime;//创建时间
    private String timeLevel;// 1日 2年
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd ")
    public Date getQuotaDate() {
        return quotaDate;
    }
    public void setQuotaDate(Date quotaDate) {
        this.quotaDate = quotaDate;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    //@Field(type = FieldType.String, analyzer="ngram_analyzer")//使用ngram进行单字分词
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getTeam() {
        return team;
    }
    public void setTeam(String team) {
        this.team = team;
    }
    public String getSlaveKey1() {
        return slaveKey1;
    }
    public void setSlaveKey1(String slaveKey1) {
        this.slaveKey1 = slaveKey1;
    }
    public String getSlaveKey2() {
        return slaveKey2;
    }
    public void setSlaveKey2(String slaveKey2) {
        this.slaveKey2 = slaveKey2;
    }
    public String getSlaveKey3() {
        return slaveKey3;
    }
    public void setSlaveKey3(String slaveKey3) {
        this.slaveKey3 = slaveKey3;
    }
    public String getSlaveKey4() {
        return slaveKey4;
    }
    public void setSlaveKey4(String slaveKey4) {
        this.slaveKey4 = slaveKey4;
    }
    public Double getResult1() {
        return result1;
    }
    public void setResult1(Double result1) {
        this.result1 = result1;
    }
    public Double getResult2() {
        return result2;
    }
    public void setResult2(Double result2) {
        this.result2 = result2;
    }
    public String getSlaveKey1Name() {
        return slaveKey1Name;
    }
    public void setSlaveKey1Name(String slaveKey1Name) {
        this.slaveKey1Name = slaveKey1Name;
    }
    public String getSlaveKey2Name() {
        return slaveKey2Name;
    }
    public void setSlaveKey2Name(String slaveKey2Name) {
        this.slaveKey2Name = slaveKey2Name;
    }
    public String getSlaveKey3Name() {
        return slaveKey3Name;
    }
    public void setSlaveKey3Name(String slaveKey3Name) {
        this.slaveKey3Name = slaveKey3Name;
    }
    public String getSlaveKey4Name() {
        return slaveKey4Name;
    }
    public void setSlaveKey4Name(String slaveKey4Name) {
        this.slaveKey4Name = slaveKey4Name;
    }
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getTeamName() {
        return teamName;
    }
    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }
    public String getQuotaCode() {
        return quotaCode;
    }
    public void setQuotaCode(String quotaCode) {
        this.quotaCode = quotaCode;
    }
    public String getAreaLevel() {
        return areaLevel;
    }
    public void setAreaLevel(String areaLevel) {
        this.areaLevel = areaLevel;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getTimeLevel() {
        return timeLevel;
    }
    public void setTimeLevel(String timeLevel) {
        this.timeLevel = timeLevel;
    }
    /**
     * 根据级别得到key
     * 1 省 2 市 3 区县 4 机构 5团队
     *
     * @param level
     * @return
     */
    public static String getAreaLevelKey(String level) {
        switch (level) {
            case teamLevel: {
                return teamKey;
            }
            case OrgLevel: {
                return OrgKey;
            }
            case townLevel: {
                return townKey;
            }
            case cityLevel: {
                return cityKey;
            }
            default: {
                return teamKey;
            }
        }
    }
}

+ 15 - 0
svr/svr-manage/src/main/java/com/yihu/customer/config/SpringSecurityAuditorAware.java

@ -0,0 +1,15 @@
package  com.yihu.customer.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;
import java.util.Optional;
@Configuration
public class SpringSecurityAuditorAware implements AuditorAware {
    @Override
    public Optional getCurrentAuditor() {
        return Optional.empty();
    }
}

+ 48 - 0
svr/svr-manage/src/main/java/com/yihu/customer/config/SwaggerDocs.java

@ -0,0 +1,48 @@
package  com.yihu.customer.config;
import io.github.swagger2markup.GroupBy;
import io.github.swagger2markup.Language;
import io.github.swagger2markup.Swagger2MarkupConfig;
import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
import io.github.swagger2markup.markup.builder.MarkupLanguage;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
 * Created by lith on 2018/11/23
 */
@Configuration
@EnableSwagger2
public class SwaggerDocs {
    public static void main(String[] args) throws Exception {
        //1.请求 http://ip:port/swagger-resources获取group
        String group = "Default";
        //2.定义请求地址 new URL("http://ip:port/v2/api-docs?group=" + groupName)
        //项目的swagger-ui地址
        URL remoteSwaggerFile = new URL("http://127.0.0.1:10032/v2/api-docs?group=" + group);
        //3.定义文件输出路径
        String prefix = Thread.currentThread().getContextClassLoader().getResource("").getPath();
        //文档输出地址
        Path outputFile = Paths.get(prefix.substring(prefix.lastIndexOf(":") + 1, prefix.indexOf("target") - 1) + "/build/" + group);
        Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
                .withMarkupLanguage(MarkupLanguage.ASCIIDOC)
                .withOutputLanguage(Language.ZH)
                .withPathsGroupedBy(GroupBy.TAGS)
                .withGeneratedExamples()
                .withoutInlineSchema()
                //.withBasePathPrefix()
                .build();
        Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(remoteSwaggerFile)
                .withConfig(config)
                .build();
        converter.toFile(outputFile);
    }
}

+ 644 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/BaseController.java

@ -0,0 +1,644 @@
package  com.yihu.customer.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.entity.IdEntity;
import  com.yihu.customer.controller.manager.account.ShiroDbRealm;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
public class BaseController {
	private static Logger logger = LoggerFactory.getLogger(BaseController.class);
	@Autowired
	protected HttpServletRequest request;
	/**
	 * 获取排序字段名称
	 * @return
	 */
	public String getSortName() {
		return request.getParameter("sortname");
	}
	/**
	 * 获取排序方式ASC,DESC
	 * @return
	 */
	public String getSortOrder() {
		return request.getParameter("sortorder");
	}
	/**
	 * 取出Shiro中的当前用户Id.
	 */
	public Long getCurrentUserId() {
		ShiroDbRealm.ShiroUser user = (ShiroDbRealm.ShiroUser) SecurityUtils.getSubject().getPrincipal();
		return user.id;
	}
	/**
	 * 取出Shiro中的当前用户标识.
	 */
	public String getCurrentUserCode() {
		ShiroDbRealm.ShiroUser user = (ShiroDbRealm.ShiroUser) SecurityUtils.getSubject().getPrincipal();
		return user.code;
	}
	/**
	 * 獲取髮送請求用戶的uid
	 * @return
	 */
	public String getUID() {
		try {
			String userAgent = request.getHeader("userAgent");
			if (StringUtils.isEmpty(userAgent)) {
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("uid");
		} catch (Exception e) {
			return null;
		}
	}
	public String getOpenid() {
		try {
			String userAgent = request.getHeader("userAgent");
			if (StringUtils.isEmpty(userAgent)) {
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("openid");
		} catch (Exception e) {
			return null;
		}
	}
	/**
	 * 获取用户ID
	 * @return
	 */
	public long getId() {
		try {
			String userAgent = request.getHeader("userAgent");
			if (StringUtils.isEmpty(userAgent)) {
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getLong("id");
		} catch (Exception e) {
			return 0;
		}
	}
	public String getIMEI() {
		try {
			String userAgent = request.getHeader("userAgent");
			if (StringUtils.isEmpty(userAgent)) {
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("imei");
		} catch (Exception e) {
			return null;
		}
	}
	public String getToken() {
		try {
			String userAgent = request.getHeader("userAgent");
			if (StringUtils.isEmpty(userAgent)) {
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("token");
		} catch (Exception e) {
			return null;
		}
	}
	public void error(Exception e) {
		logger.error(getClass().getName() + ":", e.getMessage());
		e.printStackTrace();
	}
	public void warn(Exception e) {
		logger.warn(getClass().getName() + ":", e.getMessage());
		e.printStackTrace();
	}
	/**
	 * 返回接口处理结果
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String error(int code, String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * 接口处理成功
	 * @param msg
	 * @return
	 */
	public String success(String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", 200);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	public String write(int code, String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, List<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, list);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, JSONObject value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	
	/**
	 * 返回接口处理结果
	 *
	 *
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, com.alibaba.fastjson.JSONObject value) {
		try {
			com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toJSONString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, JSONArray value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param total 总数
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, int total, String key, JSONArray value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put("total", total);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, Object value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, Page<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			// 是否为第一页
			map.put("isFirst", list.isFirst());
			// 是否为最后一页
			map.put("isLast", list.isLast());
			// 总条数
			map.put("total", list.getTotalElements());
			// 总页数
			map.put("totalPages", list.getTotalPages());
			map.put(key, list.getContent());
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, Page<?> page, JSONArray array) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			// 是否为第一页
			json.put("isFirst", page.isFirst());
			// 是否为最后一页
			json.put("isLast", page.isLast());
			// 总条数
			json.put("total", page.getTotalElements());
			// 总页数
			json.put("totalPages", page.getTotalPages());
			json.put(key, array);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, Map<?, ?> value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			System.out.println(mapper.writeValueAsString(map));
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	* 返回接口处理结果
	*
	* @param code 结果码,成功为200
	* @param msg 结果提示信息
	* @param value 结果数据
	* @return
	*/
	public String write(int code, String msg, String key, String value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	* 返回接口处理结果
	*
	*
	* @param code 结果码,成功为200
	* @param msg 结果提示信息
	* @return
	*/
	public String write(int code, String msg, String key, IdEntity entity) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, entity);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, boolean isFirst, boolean isLast, long total, int totalPages, String key, Object values) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			// 是否为第一页
			json.put("isFirst", isFirst);
			// 是否为最后一页
			json.put("isLast", isLast);
			// 总条数
			json.put("total", total);
			// 总页数
			json.put("totalPages", totalPages);
			json.put(key, values);
			return json.toString();
		} catch (Exception e) {
			logger.error("BaseController:", e.getMessage());
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	public String trimEnd(String param, String trimChars) {
		if (param.endsWith(trimChars)) {
			param = param.substring(0, param.length() - trimChars.length());
		}
		return param;
	}
	/**
	 * 无效用户消息返回
	 * @param e
	 * @param defaultCode
	 * @param defaultMsg
	 * @return
	 */
	public String invalidUserException(Exception e, int defaultCode, String defaultMsg) {
		try {
			// if (e instanceof UndeclaredThrowableException) {
			// UndeclaredThrowableException ute = (UndeclaredThrowableException) e;
			// InvalidUserException iue = (InvalidUserException) ute.getUndeclaredThrowable();
			// if (iue != null) {
			// return error(iue.getCode(), iue.getMsg());
			// }
			// }
			return error(defaultCode, defaultMsg);
		} catch (Exception e2) {
			return null;
		}
	}
	/**
	 * 返回表格列表数据
	 * @param code 状态码:0成功,非0失败
	 * @param errorMsg 错误消息
	 * @param page 当前页码
	 * @param rows 分页大小
	 * @param list 查询的结果集
	 * @return
	 */
	public String write(int code, String errorMsg, int page, int rows, Page<?> list) {
		try {
			JSONObject object = new JSONObject();
			ObjectMapper mapper = new ObjectMapper();
			object.put("successFlg", code == 0);
			object.put("errorMsg", errorMsg);
			// 是否为第一页
			object.put("errorCode", code);
			// 是否为最后一页
			object.put("currPage", page);
			// 分页大小
			object.put("pageSize", rows);
			// 总条数
			object.put("totalCount", list.getTotalElements());
			// 总页数
			object.put("totalPage", list.getTotalPages());
			// 结果集
			object.put("detailModelList", list.getContent());
			 return object.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	
	public String write(int code, String errorMsg, int page, int rows, List<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("successFlg", code == 0);
			map.put("errorMsg", errorMsg);
			// 是否为第一页
			map.put("errorCode", code);
			// 是否为最后一页
			map.put("currPage", page);
			// 分页大小
			map.put("pageSize", rows);
			// 总条数
			map.put("totalCount", list.size());
			// 总页数
			map.put("totalPage", 1);
			// 结果集
			map.put("detailModelList", list);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	
	public String error(int code, String errorMsg, int page, int rows) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("successFlg", code == 0);
			map.put("errorMsg", errorMsg);
			// 是否为第一页
			map.put("errorCode", code);
			// 是否为最后一页
			map.put("currPage", page);
			// 分页大小
			map.put("pageSize", rows);
			// 总条数
			map.put("totalCount", 0);
			// 总页数
			map.put("totalPage", 0);
			// 结果集
			map.put("detailModelList", null);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
    //json串转集合
    public <T> Collection<T> jsonToEntities(String jsonDate, Collection<T> targets, Class<T> targetCls) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            List modelList = objectMapper.readValue(jsonDate,List.class);
            Iterator ex = modelList.iterator();
            while(ex.hasNext()) {
                Object aModelList = ex.next();
                String objJsonData = objectMapper.writeValueAsString(aModelList);
                T model = objectMapper.readValue(objJsonData, targetCls);
                targets.add(model);
            }
            return targets;
        } catch (Exception var8) {
            var8.printStackTrace();
            return null;
        }
    }
    public String write(int code, String errorMsg, int page, int rows, long total, List<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("successFlg", code == 0);
            map.put("errorMsg", errorMsg);
            // 是否为第一页
            map.put("errorCode", code);
            // 是否为最后一页
            map.put("currPage", page);
            // 分页大小
            map.put("pageSize", rows);
            // 总条数
            map.put("totalCount", total);
            // 总页数
            map.put("totalPage", Math.ceil((double)total/(rows)));
            // 结果集
            map.put("detailModelList", list);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
}

+ 534 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/WeixinBaseController.java

@ -0,0 +1,534 @@
package  com.yihu.customer.controller;
import  com.yihu.customer.entity.security.AccessToken;
import  com.yihu.customer.entity.security.JsApiTicket;
import com.yihu.customer.service.common.AccessTokenService;
import com.yihu.customer.util.HttpUtil;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.Map;
public class WeixinBaseController extends BaseController {
	@Autowired
	private AccessTokenService accessTokenService;
	@Value("${wechat.appId}")
	private String appId;
	@Value("${wechat.appSecret}")
	private String appSecret;
	@Value("${wechat.accId}")
	private String accId;
	/**
	 * 通过code获取判断openid
	 * 
	 * @param code
	 * @return
	 */
	public String getOpenidByCode(String code) {
		try {
			String token_url = "https://api.weixin.qq.com/sns/oauth2/access_token";
			String params = "appid=" + appId + "&secret=" +appSecret+ "&code=" + code + "&grant_type=authorization_code";
			String result = HttpUtil.sendGet(token_url, params);
			System.out.println("getOpenidByCode:"+result);
			JSONObject json = new JSONObject(result);
			if (json.has("openid")) {
				return json.get("openid").toString();
			} else {
				return null;
			}
		} catch (Exception e) {
			error(e);
		}
		return null;
	}
	/**
	 * 通过code获取判断openid
	 * 
	 * @param code
	 * @return
	 */
	public String getOpenid(String code) {
		try {
			String token_url = "https://api.weixin.qq.com/sns/oauth2/access_token";
			String params = "appid=" + appId + "&secret=" +appSecret + "&code=" + code + "&grant_type=authorization_code";
			String result = HttpUtil.sendGet(token_url, params);
			JSONObject json = new JSONObject(result);
			Map<Object, Object> map = new HashMap<Object, Object>();
			if (json.has("openid")) {
				String openid = json.get("openid").toString();
				map.put("openid", openid);
				return write(200, "获取成功", "data", map);
			} else {
				return error(Integer.parseInt(json.get("errcode").toString()), "操作失败:" + json.get("errmsg").toString());
			}
		} catch (Exception e) {
			error(e);
			return invalidUserException(e, -1, "操作失败!");
		}
	}
	/**
	 * 拼接地址?后的参数
	 * 
	 * @param data
	 * @param type
	 * @return
	 */
	public String getParamUrl(String data, int type) {
		try {
			JSONObject jsonData = new JSONObject(data);
			String id = jsonData.get("id").toString();
			String uid = jsonData.get("uid").toString();
			String name = jsonData.get("name").toString();
			String openid = jsonData.get("openid").toString();
			String photo = jsonData.get("photo").toString();
			String token = jsonData.get("token").toString();
			String paramUrl = "?type=" + type + "&id=" + id + "&uid=" + uid + "&name=" + name + "&openid=" + openid + "&photo=" + photo + "&token=" + token;
			return paramUrl;
		} catch (Exception e) {
			error(e);
			return "";
		}
	}
	/**
	 * 获取微信的access_token。
	 * 
	 * @return
	 */
	public String getAccessToken() {
		try {
			Iterable<AccessToken> accessTokens = accessTokenService.findAccessToken();
			if (accessTokens != null) {
				for (AccessToken accessToken : accessTokens) {
					if ((System.currentTimeMillis() - accessToken.getAdd_timestamp()) < (accessToken.getExpires_in() * 1000)) {
						return accessToken.getAccess_token();
					} else {
						accessTokenService.delAccessToken(accessToken);
						break;
					}
				}
			}
			String token_url = "https://api.weixin.qq.com/cgi-bin/token";
			String params = "grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
			String result = HttpUtil.sendGet(token_url, params);
			JSONObject json = new JSONObject(result);
			if (json.has("access_token")) {
				String token = json.get("access_token").toString();
				String expires_in = json.get("expires_in").toString();
				AccessToken newaccessToken = new AccessToken();
				newaccessToken.setAccess_token(token);
				newaccessToken.setExpires_in(Long.parseLong(expires_in));
				newaccessToken.setAcc_id(accId);
				accessTokenService.addAccessToken(newaccessToken);
				return token;
			} else {
				return null;
			}
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * 获取微信的jsapi_ticket
	 * 
	 * @return
	 */
	public String getJsapi_ticketByToken() {
		try {
			Iterable<JsApiTicket> jsapiTickets = accessTokenService.findJsapiTicket();
			if (jsapiTickets != null) {
				for (JsApiTicket jsApiTicket : jsapiTickets) {
					if ((System.currentTimeMillis() - jsApiTicket.getAdd_timestamp()) < (jsApiTicket.getExpires_in() * 1000)) {
						return jsApiTicket.getJsapi_ticket();
					} else {
						accessTokenService.delJsapiTicket(jsApiTicket);
						break;
					}
				}
			}
			String token = getAccessToken();
			if (token != null) {
				String token_url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
				String params = "access_token=" + token + "&type=jsapi";
				String result = HttpUtil.sendGet(token_url, params);
				JSONObject json = new JSONObject(result);
				if (json.has("ticket")) {
					String ticket = json.get("ticket").toString();
					String expires_in = json.get("expires_in").toString();
					JsApiTicket newJsApiTicket = new JsApiTicket();
					newJsApiTicket.setJsapi_ticket(ticket);
					newJsApiTicket.setExpires_in(Long.parseLong(expires_in));
					newJsApiTicket.setAcc_id(accId);
					accessTokenService.addJsapiTicket(newJsApiTicket);
					return ticket;
				} else {
					return null;
				}
			} else {
				return null;
			}
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * @description: SHA、SHA1加密 @parameter: str:待加密字符串 @return: 加密串
	 **/
	public String SHA1(String str) {
		try {
			MessageDigest digest = MessageDigest.getInstance("SHA-1"); // 如果是SHA加密只需要将"SHA-1"改成"SHA"即可
			digest.update(str.getBytes());
			byte messageDigest[] = digest.digest();
			// Create Hex String
			StringBuffer hexStr = new StringBuffer();
			// 字节数组转换为 十六进制 数
			for (int i = 0; i < messageDigest.length; i++) {
				String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
				if (shaHex.length() < 2) {
					hexStr.append(0);
				}
				hexStr.append(shaHex);
			}
			return hexStr.toString();
		} catch (Exception e) {
			error(e);
		}
		return null;
	}
	/**
	 * 获取微信服务器图片
	 * 
	 * @return
	 */
//	public String Images() {
//		String photos = "";
//		try {
//			String images = request.getParameter("mediaIds");
//			if (StringUtils.isEmpty(images)) {
//				return photos;
//			}
//			String[] mediaIds = images.split(",");
//			for (String mediaId : mediaIds) {
//				if (StringUtils.isEmpty(mediaId)) {
//					continue;
//				}
//				String temp = saveImageToDisk(mediaId);
//				if (StringUtils.isNotEmpty(temp)) {
//					if (photos.length() == 0) {
//						photos = temp;
//					} else {
//						photos += "," + temp;
//					}
//				}
//			}
//		} catch (Exception e) {
//			error(e);
//		}
//		return photos;
//	}
	/**
	 * 获取下载图片信息(jpg)
	 * 
	 * @param mediaId 文件的id
	 * @throws Exception
	 */
//	public String saveImageToDisk(String mediaId) throws Exception {
//		// 文件保存的临时路径
//		String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
//		// 拼接年月日路径
//		String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
//		// 重命名文件
//		String newFileName = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000) + ".png";
//		// 保存路径
//		File uploadFile = new File(tempPath + datePath + newFileName);
//
//		InputStream inputStream = null;
//		FileOutputStream fileOutputStream = null;
//		try {
//			if (!uploadFile.getParentFile().exists()) {
//				uploadFile.getParentFile().mkdirs();
//			}
//			inputStream = getInputStream(mediaId);
//			byte[] data = new byte[1024];
//			int len = 0;
//			fileOutputStream = new FileOutputStream(uploadFile);
//			while ((len = inputStream.read(data)) != -1) {
//				fileOutputStream.write(data, 0, len);
//			}
//			// 生成缩略图
//			ImageCompress.compress(uploadFile.getAbsolutePath(), uploadFile.getAbsolutePath() + "_small", 300, 300);
//			// 返回保存路径
//			return datePath + newFileName;
//		} catch (IOException e) {
//			e.printStackTrace();
//		} finally {
//			if (inputStream != null) {
//				try {
//					inputStream.close();
//				} catch (IOException e) {
//					e.printStackTrace();
//				}
//			}
//			if (fileOutputStream != null) {
//				try {
//					fileOutputStream.close();
//				} catch (IOException e) {
//					e.printStackTrace();
//				}
//			}
//		}
//		return null;
//	}
//	public String saveImageToDiskNoImageCompress(String mediaId) throws Exception {
//		// 文件保存的临时路径
//		String tempPath = imagesPath+ File.separator;
//		// 拼接年月日路径
//		String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
//		// 重命名文件
//		String newFileName = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000) + ".png";
//		// 保存路径
//		File uploadFile = new File(tempPath + datePath + newFileName);
//
//		InputStream inputStream = null;
//		FileOutputStream fileOutputStream = null;
//		try {
//			if (!uploadFile.getParentFile().exists()) {
//				uploadFile.getParentFile().mkdirs();
//			}
//			inputStream = getInputStream(mediaId);//下载微信图片
//			byte[] data = new byte[1024];
//			int len = 0;
//			fileOutputStream = new FileOutputStream(uploadFile);
//			while ((len = inputStream.read(data)) != -1) {
//				fileOutputStream.write(data, 0, len);
//			}
//			return datePath + newFileName;
//		} catch (IOException e) {
//			e.printStackTrace();
//		} finally {
//			if (inputStream != null) {
//				try {
//					inputStream.close();
//				} catch (IOException e) {
//					e.printStackTrace();
//				}
//			}
//			if (fileOutputStream != null) {
//				try {
//					fileOutputStream.close();
//				} catch (IOException e) {
//					e.printStackTrace();
//				}
//			}
//		}
//		return null;
//	}
	/**
	 * 获取微信服务器图片
	 *
	 * @return
	 */
//	public String fetchWxImages() {
//		String photos = "";
//		try {
//			String images = request.getParameter("mediaIds");
//			if (StringUtils.isEmpty(images)) {
//				return photos;
//			}
//			String[] mediaIds = images.split(",");
//			for (String mediaId : mediaIds) {
//				if (StringUtils.isEmpty(mediaId)) {
//					continue;
//				}
//				String temp = saveImageToDisk(mediaId);
//				if (StringUtils.isNotEmpty(temp)) {
//					if (photos.length() == 0) {
//						photos = temp;
//					} else {
//						photos += "," + temp;
//					}
//				}
//			}
//		} catch (Exception e) {
//			error(e);
//		}
//		return photos;
//	}
	/**
	 * 获取微信服务器语音
	 * 
	 * @return
	 */
//	public String fetchWxVoices() {
//		String voiceIds = "";
//		try {
//			String voices = request.getParameter("voices");
//			if (StringUtils.isEmpty(voices)) {
//				return voices;
//			}
//			String[] mediaIds = voices.split(",");
//			for (String mediaId : mediaIds) {
//				if (StringUtils.isEmpty(mediaId)) {
//					continue;
//				}
//				String temp = saveVoiceToDisk(mediaId);
//				if (StringUtils.isNotEmpty(temp)) {
//					if (voiceIds.length() == 0) {
//						voiceIds = temp;
//					} else {
//						voiceIds += "," + temp;
//					}
//				}
//			}
//		} catch (Exception e) {
//			error(e);
//		}
//		return voiceIds;
//	}
	/**
	 * 获取下载语音信息(jpg)
	 * 
	 * @param mediaId 文件的id
	 * @throws Exception
	 */
//	public String saveVoiceToDisk(String mediaId) throws Exception {
//		// 文件保存的临时路径
//		String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
//		// 拼接年月日路径
//		String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
//		// 重命名文件
//		String fileBase =  DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000);
//		String newFileName = fileBase+ ".amr";
//		String mp3FileName  = fileBase + ".mp3";
//		// 保存路径
//		File uploadFile = new File(tempPath + datePath + newFileName);
//
//		InputStream inputStream = null;
//		FileOutputStream fileOutputStream = null;
//		try {
//			if (!uploadFile.getParentFile().exists()) {
//				uploadFile.getParentFile().mkdirs();
//			}
//			inputStream = getInputStream(mediaId);
//			byte[] data = new byte[1024];
//			int len = 0;
//			fileOutputStream = new FileOutputStream(uploadFile);
//			while ((len = inputStream.read(data)) != -1) {
//				fileOutputStream.write(data, 0, len);
//			}
//			String amrFilePath = tempPath+datePath+newFileName;
//			String Mp3FilePath = tempPath+datePath+mp3FileName;
//			CommonUtil.changeToMp3(amrFilePath,Mp3FilePath);
//			// 返回保存路径
//			return Mp3FilePath;
//		} catch (IOException e) {
//			e.printStackTrace();
//		} finally {
//			if (inputStream != null) {
//				try {
//					inputStream.close();
//				} catch (IOException e) {
//					e.printStackTrace();
//				}
//			}
//			if (fileOutputStream != null) {
//				try {
//					fileOutputStream.close();
//				} catch (IOException e) {
//					e.printStackTrace();
//				}
//			}
//		}
//		return null;
//	}
	/**
	 * 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
	 *
	 * @return
	 */
//	public InputStream getInputStream(String mediaId) {
//		String accessToken = getAccessToken();
//		InputStream is = null;
//		String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
//		try {
//			URL urlGet = new URL(url);
//			HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
//			http.setRequestMethod("GET"); // 必须是get方式请求
//			http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
//			http.setDoOutput(true);
//			http.setDoInput(true);
//			System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒
//			System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒
//			http.connect();
//			// 获取文件转化为byte流
//			is = http.getInputStream();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return is;
//	}
	/**
	 * 获取Open
	 * @param code
	 * @return
	 * @throws Exception
     */
	public String getOpenId(String code) throws Exception {
		String token_url = "https://api.weixin.qq.com/sns/oauth2/access_token";
		String params = "appid=" + appId+ "&secret=" + appSecret + "&code=" + code + "&grant_type=authorization_code";
		String result = HttpUtil.sendGet(token_url, params);
		JSONObject json = new JSONObject(result);
		if (json.has("openid")) {
			return json.get("openid").toString();
		} else {
			return null;
		}
	}
	/**
	 * 获取subscribe
	 * @param openid
	 * @return
	 * @throws Exception
     */
	public String getIsSus(String openid) throws Exception{
		String userInfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + getAccessToken() + "&openid=" + openid + "&lang=zh_CN";
		String params = "";
		String result = HttpUtil.sendGet(userInfo_url, params);
		JSONObject json = new JSONObject(result);
		if (json.has("subscribe")) {
			return json.get("subscribe").toString();
		} else {
			return null;
		}
	}
	/**
	 * 获取Subscribe
	 * @param code
	 * @return
	 * @throws Exception
     */
	public String getSubscribeByCode(String code)throws Exception{
		return getIsSus(getOpenid(code));
	}
}

+ 87 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/common/district/DistrictController.java

@ -0,0 +1,87 @@
package  com.yihu.customer.controller.common.district;
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.service.common.district.DistrictService;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
/**
 * 省市区三级地址控制类
 *
 * @author George
 */
@Controller
@RequestMapping(value = "common",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DistrictController extends BaseController {
    @Autowired
    private DistrictService districtService;
    /**
     * 省市一二三级查询接口
     *
     * @param type 1一级目录,2二级目录,3三级目录,4街道目录
     * @param code 省或市标识
     * @return
     */
    @RequestMapping(value = "district")
    @ResponseBody
    public String district(int type, String code) {
        try {
            List<?> list = districtService.findByType(type, code);
            return write(200, "查询成功!", "list", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    /**
     * 省市一二三级查询接口(包含权限控制)
     *
     * @param type 1一级目录,2二级目录,3三级目录,4街道目录
     * @param code 省或市标识
     * @return
     */
    @RequestMapping(value = "districtAuthority")
    @ResponseBody
    public String districtAuthority(int type, String code) {
        try {
            List<Map<String, String>> roleMap = (List<Map<String, String>>) request.getSession().getAttribute("roleMap");
            List<?> list = districtService.findByType(type, code, roleMap);
            return write(200, "查询成功!", "list", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/district/importData", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(HttpServletRequest request) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = request.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            districtService.importStreet(workbook);
            return write(200, "操作成功");
        } catch (IOException | BiffException e) {
            e.printStackTrace();
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 48 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/common/label/SignPatientLabelController.java

@ -0,0 +1,48 @@
package  com.yihu.customer.controller.common.label;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.SignPatientLabel;
import com.yihu.customer.service.manager.sign.SignPatientLabelService;
import  com.yihu.customer.repository.SignPatientLabelDao;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
 * Created by yeshijie on 2017/1/22.
 */
@Controller
@RequestMapping(value = "common/label")
public class SignPatientLabelController extends BaseController {
    @Autowired
    private SignPatientLabelService signPatientLabelService;
    @Autowired
    private SignPatientLabelDao signPatientLabelDao;
    @RequestMapping(value = "signPatientLabel")
    @ResponseBody
    public String district(String labelType) {
        try {
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatus(labelType,1);
            JSONArray jsonArray = new JSONArray();
            if(list!=null&&list.size()>0){
                for (SignPatientLabel label:list){
                    JSONObject json = new JSONObject();
                    json.put("code",label.getLabelCode());
                    json.put("name",label.getLabelName());
                    jsonArray.put(json);
                }
            }
            return write(200, "查询成功!", "list", jsonArray);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}

+ 100 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/export/excel/DoctorController.java

@ -0,0 +1,100 @@
package  com.yihu.customer.controller.export.excel;
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.service.doctor.DoctorService;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by wxw on 2018/11/6.
 *
 * @author wxw.
 */
@Controller
@RequestMapping("/doctor")
public class DoctorController extends BaseController {
    @Autowired
    private DoctorService doctorService;
    @RequestMapping(value = "/outExcel", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public void outExcel(String hospital, HttpServletResponse response) {
        try {
            List<Map<String, Object>> list = doctorService.findConsultAndConcernByHospitalDept(hospital);
            List<Map<String, Object>> list2 = doctorService.findConsultAndConcernByHospitalDoctor(hospital);
            //基本设置
            response.setContentType("application/vnd.ms-excel");
            String fileName = "医院关注咨询统计";
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            Date date = new Date();
            response.setHeader("Content-Disposition", "attachment; filename="
                    + new String(fileName.getBytes("UTF-8"), "ISO8859-1") + "_" + sdf.format(date) + ".xls");
            OutputStream os = response.getOutputStream();
            //处理Excel
            WritableWorkbook book = Workbook.createWorkbook(os);
            WritableSheet sheet = book.createSheet("按科室", 0);
            sheet.addCell(new Label(0, 0, "编号"));
            sheet.addCell(new Label(1, 0, "医院名称"));
            sheet.addCell(new Label(2, 0, "科室名称"));
            sheet.addCell(new Label(3, 0, "关注人数"));
            sheet.addCell(new Label(4, 0, "咨询数"));
            List<Map<String, Object>> objList = list;
            if (null != objList && objList.size() > 0 && objList.get(0).size() > 0) {
                for(int i = 0; i< objList.size(); i ++) {
                    Map<String, Object> objMap = objList.get(i);
                    sheet.addCell(new Label(0, i + 1, String.valueOf(i + 1)));
                    sheet.addCell(new Label(1, i + 1, String.valueOf(objMap.get("hospital"))));
                    sheet.addCell(new Label(2, i + 1, String.valueOf(objMap.get("dept"))));
                    sheet.addCell(new Label(3, i + 1, String.valueOf(objMap.get("concern"))));
                    sheet.addCell(new Label(4, i + 1, String.valueOf(objMap.get("consult"))));
                }
            }
            WritableSheet sheet2 = book.createSheet("按医生", 1);
            sheet2.addCell(new Label(0, 0, "编号"));
            sheet2.addCell(new Label(1, 0, "医院名称"));
            sheet2.addCell(new Label(2, 0, "科室名称"));
            sheet2.addCell(new Label(3, 0, "医生"));
            sheet2.addCell(new Label(4, 0, "关注人数"));
            sheet2.addCell(new Label(5, 0, "咨询数"));
            List<Map<String, Object>> listMap = list2;
            if (null != listMap && listMap.size() > 0 && listMap.get(0).size() > 0) {
                for(int i = 0; i< listMap.size(); i ++) {
                    Map<String, Object> objMap = listMap.get(i);
                    sheet2.addCell(new Label(0, i + 1, String.valueOf(i + 1)));
                    sheet2.addCell(new Label(1, i + 1, String.valueOf(objMap.get("hospital"))));
                    sheet2.addCell(new Label(2, i + 1, String.valueOf(objMap.get("dept"))));
                    sheet2.addCell(new Label(3, i + 1, String.valueOf(objMap.get("name"))));
                    sheet2.addCell(new Label(4, i + 1, String.valueOf(objMap.get("concern"))));
                    sheet2.addCell(new Label(5, i + 1, String.valueOf(objMap.get("consult"))));
                }
            }
            book.write();
            book.close();
            os.flush();
            os.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (WriteException e) {
            e.printStackTrace();
        }
    }
}

+ 141 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/export/excel/ElasticSearchController.java

@ -0,0 +1,141 @@
/*
package com.yihu.jw.controller.export.excel;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.service.export.ExportService;
import jxl.write.WriteException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
*/
/**
 * Created by wxw on 2018/11/6.
 *
 * @author wxw.
 *//*
@Controller
@RequestMapping("/export")
public class ElasticSearchController extends BaseController {
    @Autowired
    private ExportService exportService;
    */
/**
     * 签约状况
     * @param start
     * @param end
     * @param response
     *//*
    @RequestMapping(value = "/healthPush", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public void healthPush(String start, String end, String city, HttpServletResponse response) {
        exportService.healthPush(start, end, city, response);
    }
    */
/**
     * 续签率统计(按城市)
     * @param start
     * @param end
     * @param city
     * @param response
     *//*
    @RequestMapping(value = "/signService")
    @ResponseBody
    public void signService(String start, String end, String city, HttpServletResponse response) {
        try {
            exportService.signService(start, end, city, response);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (WriteException e) {
            e.printStackTrace();
        }
    }
    */
/**
     * 运营数据(按机构)
     * @param start
     * @param end
     * @param hospital
     * @param response
     *//*
    @RequestMapping(value = "/teamInfo")
    @ResponseBody
    public void teamInfo(String start, String end, String hospital, HttpServletResponse response) {
        try {
            exportService.teamInfo(start, end, hospital, response);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (WriteException e) {
            e.printStackTrace();
        }
    }
    @RequestMapping(value = "/prescriptionService")
    @ResponseBody
    public void prescriptionService(String start, String end, String city, HttpServletResponse response) {
        try {
            exportService.prescriptionService(start, end, city, response);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (WriteException e) {
            e.printStackTrace();
        }
    }
    */
/**
     * 预约汇总
     * @param start
     * @param end
     * @param city
     * @param town
     * @param hospital
     * @param response
     *//*
    @RequestMapping(value = "/appointmentInfo")
    @ResponseBody
    public void appointmentInfo(String start, String end, String city,String town, String hospital, HttpServletResponse response){
        try {
            exportService.appointmentService(start, end, city, town, hospital, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    */
/**
     * 咨询汇总
     * @param start
     * @param end
     * @param city
     * @param town
     * @param hospital
     * @param response
     *//*
    @RequestMapping(value = "/consultInfo")
    @ResponseBody
    public void consultInfo(String start, String end, String city,String town, String hospital, HttpServletResponse response){
        try {
            exportService.consultService(start, end, city, town, hospital, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
*/

+ 98 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/gateway/model/BaseResultModel.java

@ -0,0 +1,98 @@
package  com.yihu.customer.controller.gateway.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel("返回实体")
public class BaseResultModel {
    @ApiModelProperty(value = "状态", required = false, access = "response")
    protected Integer status = statusEm.success.getCode();
    @ApiModelProperty(value = "信息", required = false, access = "response")
    protected String message = "成功";
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public enum statusEm {
        success(10000, "请求成功"),//请求成功
        error_Appid(40004, "appid不存在"),//appid不存在
        error_AppSecret(40001, "AppSecret不存在"),//AppSecret不存在
        token_out_effect(-9002, "无效的token"),//token无效
        token_no_power(-9003, "用户没权限"),// 没权限 包括未授权 或者uri错误
        token_out_time(-9004, "accesstoken已过期"),//token无效
        token_null(-9005, "accesstoken为空"),// 没权限 包括未授权 或者uri错误
        error_params(-10000, "请求失败 参数错误"),//请求失败 参数错误
        error_no_ip(-10010, "请求失败,获取IP失败"),//请求失败,获取IP失败
        login_system_error(-10020, "系统异常"),
        login_publickey_error(-10030, "获取公钥失败"),
        file_upload_error(-10040, "文件上传失败"),
        find_error(-10050, "查询失败"),
        opera_error(-10060, "操作失败"),
        no_openid(-30000,"用户openId为空无法发送"),
        login_account_error(-20010, "账号不存在"),
        login_password_error(-20020, "密码错误"),
        login_IMEI_error(-20030, "获取imei失败");
        ;
        statusEm(Integer code, String message) {
            this.code = code;
            this.message = message;
        }
        private Integer code;
        private String message;
        public Integer getCode() {
            return code;
        }
        public void setCode(Integer code) {
            this.code = code;
        }
        public String getMessage() {
            return message;
        }
        public void setMessage(String message) {
            this.message = message;
        }
    }
    public BaseResultModel() {
    }
    public BaseResultModel(String message) {
        this.message = message;
    }
    public BaseResultModel(Integer status, String message) {
        this.status = status;
        this.message = message;
    }
}

+ 33 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/gateway/model/GcClientDetailsModel.java

@ -0,0 +1,33 @@
package  com.yihu.customer.controller.gateway.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * GtClientDetails entity. @author MyEclipse Persistence Tools
 */
@ApiModel(description = "")
public class GcClientDetailsModel{
    // Fields
    @ApiModelProperty(value = "appId", required = false, access = "response")
    private String appId;
    @ApiModelProperty(value = "appSecret", required = false, access = "response")
    private String appSecret;
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getAppSecret() {
        return appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
}

+ 51 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/gateway/model/GcTokenModel.java

@ -0,0 +1,51 @@
package  com.yihu.customer.controller.gateway.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel(description = "")
public class GcTokenModel {
    @ApiModelProperty(value = "请求凭证", required = false, access = "response")
    private String accesstoken;
    @ApiModelProperty(value = "创建时间", required = false, access = "response")
    private Date createTime;
    @ApiModelProperty(value = "过期时间", required = false, access = "response")
    private Long outTime;
    public String getAccesstoken() {
        return accesstoken;
    }
    public void setAccesstoken(String accesstoken) {
        this.accesstoken = accesstoken;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    /*public Date getOutTime() {
        return outTime;
    }
    public void setOutTime(Date outTime) {
        this.outTime = outTime;
    }*/
    public Long getOutTime() {
        return outTime;
    }
    public void setOutTime(Long outTime) {
        this.outTime = outTime;
    }
}

+ 39 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/gateway/model/ResultOneModel.java

@ -0,0 +1,39 @@
package  com.yihu.customer.controller.gateway.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * Created by chenweida on 2017/8/17.
 * 对外放回的实体
 */
@ApiModel("返回的实体类")
public class ResultOneModel<T> extends BaseResultModel {
    @ApiModelProperty(value = "返回数据", required = false, access = "response")
    private T result;
    public T getResult() {
        return result;
    }
    public void setResult(T result) {
        this.result = result;
    }
    public ResultOneModel(T result) {
        this.result = result;
    }
    public ResultOneModel() {
    }
    public ResultOneModel(Integer code, String message) {
        super(code, message);
    }
    public ResultOneModel(Integer status, String message, T result) {
        super(status, message);
        this.result = result;
    }
}

+ 47 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/AdminController.java

@ -0,0 +1,47 @@
package  com.yihu.customer.controller.manager;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
/**
 * LoginController负责打开登录页面(GET请求)和登录出错页面(POST请求),
 * 
 * 真正登录的POST请求由Filter完成,
 * 
 * @author calvin
 */
@Controller
@RequestMapping(value = "/login")
public class AdminController {
	@RequestMapping(method = RequestMethod.GET)
	public String login(HttpServletRequest req) {
		try {
			if(req.getSession().getAttribute("errorTipNum")!=null){
				Integer errorTipNum = (Integer) req.getSession().getAttribute("errorTipNum");
				if(errorTipNum==1){
					req.getSession().setAttribute("errorTipNum",2);
				}else {
					req.getSession().setAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME, "");
					req.getSession().removeAttribute("errorTipNum");
				}
			}
		}catch (Exception e){
			e.printStackTrace();
		}
		return "login";
	}
	@RequestMapping(method = RequestMethod.POST)
	public String fail(@RequestParam(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM) String userName,  Model model) {
		model.addAttribute(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM, userName);
		return "login";
	}
}

+ 17 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/MainController.java

@ -0,0 +1,17 @@
package  com.yihu.customer.controller.manager;
import  com.yihu.customer.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value = "/admin")
public class MainController extends BaseController {
	@RequestMapping(value = "main", method = RequestMethod.GET)
	public String index() {
		return "main";
	}
}

+ 124 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/account/ShiroDbRealm.java

@ -0,0 +1,124 @@
package  com.yihu.customer.controller.manager.account;
import com.google.common.base.Objects;
import  com.yihu.customer.entity.User;
import com.yihu.customer.service.manager.account.AdminService;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;
import org.springside.modules.utils.Encodes;
import java.io.Serializable;
public class ShiroDbRealm extends AuthorizingRealm {
	protected AdminService adminService;
	/**
	 * 认证回调函数,登录时调用.
	 */
	@Override
	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException {
		UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
		User user = adminService.findUserByMobile(token.getUsername());
		if (user != null) {
			byte[] salt = Encodes.decodeHex(user.getSalt());
			return new SimpleAuthenticationInfo(new ShiroUser(user.getId(), user.getCode(), user.getMobile(), user.getName()), user.getPassword(), ByteSource.Util.bytes(salt), getName());
		} else {
			return null;
		}
	}
	/**
	 * 授权查询回调函数, 进行鉴权但缓存中无用户的授权信息时调用.
	 */
	@Override
	protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
		ShiroUser shiroUser = (ShiroUser) principals.getPrimaryPrincipal();
		User user = adminService.findUserByMobile(shiroUser.mobile);
		SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
		info.addRoles(user.getRoleList());
		return info;
	}
	/**
	 * 设定Password校验的Hash算法与迭代次数.
	 */
	/*@PostConstruct
	public void initCredentialsMatcher() {
		HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(EncodesUtil.HASH_ALGORITHM);
		matcher.setHashIterations(EncodesUtil.HASH_INTERATIONS);
		setCredentialsMatcher(matcher);
	}*/
	public void setAdminService(AdminService adminService) {
		this.adminService = adminService;
	}
	/**
	 * 自定义Authentication对象,使得Subject除了携带用户的登录名外还可以携带更多信息.
	 */
	public static class ShiroUser implements Serializable {
		private static final long serialVersionUID = -1373760761780840081L;
		public Long id;
		public String mobile;
		public String name;
		public String code;
		public ShiroUser(Long id, String code, String mobile, String name) {
			this.id = id;
			this.mobile = mobile;
			this.name = name;
			this.code = code;
		}
		public String getName() {
			return name;
		}
		/**
		 * 本函数输出将作为默认的<shiro:principal/>输出.
		 */
		@Override
		public String toString() {
			return mobile;
		}
		/**
		 * 重载hashCode,只计算loginName;
		 */
		@Override
		public int hashCode() {
			return Objects.hashCode(mobile);
		}
		/**
		 * 重载equals,只计算loginName;
		 */
		@Override
		public boolean equals(Object obj) {
			if (this == obj) {
				return true;
			}
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			ShiroUser other = (ShiroUser) obj;
			if (mobile == null) {
				if (other.mobile != null) {
					return false;
				}
			} else if (!mobile.equals(other.mobile)) {
				return false;
			}
			return true;
		}
	}
}

+ 132 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/appeal/AppealController.java

@ -0,0 +1,132 @@
package  com.yihu.customer.controller.manager.appeal;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.feedback.Appeal;
import com.yihu.customer.service.manager.feedback.AppealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
/**
 * Created by Reece on 2017/5/6.
 */
@Controller
@RequestMapping(value = "admin/appeal")
@Api(description = "管理系统账号申诉接口")
public class AppealController extends BaseController {
    @Autowired
    private AppealService appealService;
    //页面初始化数据
    @RequestMapping(value = "/initial", method = RequestMethod.GET)
    @ApiIgnore
    @ApiOperation(value = "意见反馈")
    public String initFeedback() {
        return "appeal/appeal_list";
    }
    /**
     * 初始化列表页
     * @param type 账号申诉的类别
     * @param identity 身份
     * @param status 状态
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "列表")
    public String list(
            @RequestParam(required = false,defaultValue = "-1") int type,
            @RequestParam(required = false,defaultValue = "-1") int identity,
            @RequestParam(required = false,defaultValue = "-1") int status,
            @RequestParam(value = "page",defaultValue = "1") int page,
            @RequestParam(value = "rows",defaultValue = "15") int rows) {
        try {
            Page<Appeal> appeals = appealService.findAppeal(page, rows, type, identity, status);
            return write(200, "操作成功", page, rows, appeals);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "/delAppeal")
    @ResponseBody
    @ApiOperation(value="批量删除")
    public String delAppeal(
            @RequestParam(required = true) String ids){
        try{
            appealService.delappeal(ids);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
    //跳转到意见详情页
    @RequestMapping(value = "showDetail", method = RequestMethod.GET)
    @ApiIgnore
    @ApiOperation(value = "跳转到意见详情页")
    public String infoInit(Integer id ) {
        request.setAttribute("id",id);
        return "appeal/appeal_detail";
    }
    /**
     * 根据申诉ID查询申诉详情,并更改状态
     * @param id
     * @return
     */
    @RequestMapping(value = "getAppealById")
    @ResponseBody
    public String getAppealById(@RequestParam(value = "id") Long id) {
        try {
            Map appeal = appealService.getAppealById(id);
            return write(200, "操作成功!", "data", appeal);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    ////跳转到处理页面
    //@RequestMapping(value = "dealInit", method = RequestMethod.GET)
    //@ApiIgnore
    //@ApiOperation(value = "跳转到处理页面")
    //public String dealInit(Integer id ) {
    //    request.setAttribute("id",id);
    //    return "appeal/appeal_deal";
    //}
    /**
     * 根据申诉id,回复内容result进行处理
     * @param id
     * @param result
     * @return
     */
    @RequestMapping(value="dealAppeal", method = RequestMethod.POST)
    @ResponseBody
    public String dealAppeal(@RequestParam(required = true,value="id") Long id,
                             @RequestParam(required = true,value="result") String result){
        try {
            appealService.dealAppeal(id,result);
            return write(200,"操作成功!");
        }catch (Exception e){
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 167 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/basedata/BaseDataImportController.java

@ -0,0 +1,167 @@
package  com.yihu.customer.controller.manager.basedata;
import  com.yihu.customer.controller.WeixinBaseController;
import com.yihu.customer.service.manager.basedata.BaseDataImportService;
import com.yihu.customer.service.wechat.WechatApiService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * 基础数据导入
 */
@Controller
@RequestMapping(value = "/admin/basedata",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class BaseDataImportController extends WeixinBaseController {
    @Autowired
    private BaseDataImportService dataImportService;
    @Autowired
    private WechatApiService wechatApiService;
    //页面跳转(主页面)
    @RequestMapping(value = "initial")
    public String listInit() {
        return "basedata/basedata_list";
    }
    @RequestMapping(value = "labelImport")
    public String labelImport() {
        return "basedata/basedata_label";
    }
    @RequestMapping(value = "selectLabel")
    @ResponseBody
    public String selectLabel() {
        try {
            return write(200, "操作成功", "data", dataImportService.selectLabel());
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 同步标签至微信
     * serverTypeLables 服务类型 标签列表
     * diseaseTypes 服务类型 标签列表
     * healthTypeLables 服务类型 标签列表
     * @return
     */
    @RequestMapping(value = "syncLabelToWeixin")
    @ResponseBody
    public String syncLabelToWeixin(
            @RequestParam(name = "serverTypeLables",required = false) String serverTypeLables,
            @RequestParam(name = "diseaseTypes",required = false) String diseaseTypes,
            @RequestParam(name = "healthTypeLables",required = false) String healthTypeLables,
            @RequestParam(name = "townLables",required = false) String townLables,
            @RequestParam(name = "townCode",required = false) String townCode
    ) {
        try {
            List<String> weixinOpenIdList = wechatApiService.getOpenIdList(getAccessToken());
            List<String> lableOpenIds = new ArrayList<>();
            String result = "";
            if(StringUtils.isEmpty(townCode)){
                return error(-1, "参数区县不能为空!");
            }
            if(StringUtils.isNotEmpty(serverTypeLables)){
                lableOpenIds =  dataImportService.getLabelWeixinOpenId(1, serverTypeLables, weixinOpenIdList,townCode);
                result = syscTagsToWeixin(serverTypeLables,lableOpenIds);
            }
            if(StringUtils.isNotEmpty(diseaseTypes)){
                lableOpenIds =  dataImportService.getLabelWeixinOpenId(2, diseaseTypes, weixinOpenIdList,townCode);
                result = syscTagsToWeixin(serverTypeLables,lableOpenIds);
            }
            if( StringUtils.isNotEmpty(healthTypeLables)){
                lableOpenIds =   dataImportService.getLabelWeixinOpenId(2, healthTypeLables, weixinOpenIdList,townCode);
                result =syscTagsToWeixin(serverTypeLables,lableOpenIds);
            }
            if (StringUtils.isNoneEmpty(townLables)){
                lableOpenIds =   dataImportService.getLabelWeixinOpenId(3, townLables, weixinOpenIdList,townCode);
                result =syscTagsToWeixin(townLables,lableOpenIds);
            }
            return write(200, "操作成功", "data", result);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 医生同步微信
     *
     * @param townLables
     * @return
     */
    @RequestMapping(value = "syncLabelToWeixin1")
    @ResponseBody
    public String syncLabelToWeixin1(
            @RequestParam(name = "townLables",required = false) String townLables) {
        try {
            List<String> weixinOpenIdList = wechatApiService.getOpenIdList(getAccessToken());
            List<String> lableOpenIds = new ArrayList<>();
            String result = "";
            if (StringUtils.isNoneEmpty(townLables)){
                lableOpenIds =   dataImportService.getLabelWeixinOpenId1(townLables, weixinOpenIdList);
                result =syscTagsToWeixin(townLables,lableOpenIds);
            }
            return write(200, "操作成功", "data", result);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    public String  syscTagsToWeixin(String lables,List<String> openIds) throws UnsupportedEncodingException, JSONException {
        if(openIds ==null || openIds.size() ==0){
            return "success";
        }
        String result = "";
        String tagId = "";
        Map<String,String> weixinExistTags = wechatApiService.getWeiXinTaggs(getAccessToken());
        String [] lableArr = lables.split(",");
        for(int i=0 ;i< lableArr.length ;i++) {
            String tag = lableArr[i].trim();
            if (weixinExistTags.containsKey(tag)) {
                tagId = weixinExistTags.get(tag);
            } else {
                tagId = wechatApiService.createTagging(getAccessToken(), tag);
            }
            List<String> sysOpenIds = new ArrayList<>();
            if(openIds.size() > 50){
                int m = openIds.size()/50;
                int d = openIds.size()%50;
                if(d!=0){
                    m++;
                }
                for(int k=0;k < m ;k++){
                    int to = (k+1)*50;
                    if(to > openIds.size()){
                        to = openIds.size();
                    }
                    sysOpenIds = openIds.subList(k*50,to);
                    result = wechatApiService.batchtagging(getAccessToken(), sysOpenIds, tagId);
                }
            }else {
                result = wechatApiService.batchtagging(getAccessToken(), openIds, tagId);
            }
        }
        return result;
    }
}

+ 21 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/basedata/OperateExportController.java

@ -0,0 +1,21 @@
package  com.yihu.customer.controller.manager.basedata;
import  com.yihu.customer.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
 * 周运营数据导出
 */
@Controller
@RequestMapping(value = "/admin/operateExport")
public class OperateExportController extends BaseController {
    //页面跳转(主页面)
    @RequestMapping(value = "initial")
    public String listInit() {
        return "basedata/operate_export_list";
    }
}

+ 106 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/consult/ConsultRemindController.java

@ -0,0 +1,106 @@
package  com.yihu.customer.controller.manager.consult;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.consult.WlyyConsultRemindLog;
import com.yihu.customer.service.manager.consult.WlyyConsultRemindLogService;
import com.yihu.customer.util.DateUtil;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
/**
 * Created by linz on 2017/5/15.
 */
@Controller
@RequestMapping(value = "admin/consult/remind")
@Api(description = "咨询提醒")
public class ConsultRemindController extends BaseController {
    //    咨询列表
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String listInit () {
        return "consult/consult_list";
    }
    //    医生信息
    @RequestMapping(value = "docInfo/{code}/{remind}/{reply}/{isclick}", method = RequestMethod.GET)
    public  String DocInfo (@PathVariable("code") String code, @PathVariable("remind") String remind, @PathVariable("reply") String reply, @PathVariable("isclick") String isclick) throws  Exception {
        request.setAttribute("code",code);
        request.setAttribute("remind",remind);
        request.setAttribute("reply",reply);
        request.setAttribute("isclick",isclick);
        return "consult/consult_doctor_info";
    }
    //    咨询提醒
    @RequestMapping(value = "remind/{code}",method = RequestMethod.GET)
    public String Remind (@PathVariable("code") String code) {
        request.setAttribute( "code", code);
        return "consult/consult_remind_content";
    }
    //提醒记录
    @RequestMapping(value = "relyHis",method = RequestMethod.GET)
    public String ReplyHis () {
        return "consult/consult_remind_reply_list";
    }
    @Autowired
    private WlyyConsultRemindLogService wlyyConsultRemindLogService;
    //获取咨询列表
    @RequestMapping(value = "list")
    @ResponseBody
    public String searchList(
            @RequestParam(value = "city",required = false) String city,
            @RequestParam(value = "town",required = false) String town,
            @RequestParam(value = "hospital",required = false) String hospital,
            @RequestParam(value = "teamCode",required = false) String teamCode,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "doctor",required = false) String doctor,
            @RequestParam(value = "beginDate",required = false) String beginDateString,
            @RequestParam(value = "endDate",required = false) String endDateString,
            @RequestParam(value = "remindType",required = false) String remindType,
            @RequestParam(value = "page",required = true) int page,
            @RequestParam(value = "rows",required = true) int rows){
        try {
            Date beginDate = null;
            Date endDate = null;
            if(StringUtils.isNotBlank(beginDateString)){
                beginDate = DateUtil.strToDate(beginDateString,DateUtil.YYYY_MM_DD_HH_MM_SS);
            }
            if(StringUtils.isNotBlank(endDateString)){
                endDate = DateUtil.strToDate(endDateString,DateUtil.YYYY_MM_DD_HH_MM_SS);
            }
            PageImpl<WlyyConsultRemindLog> consults = wlyyConsultRemindLogService.list(city,town,hospital,teamCode,doctorName,doctor,beginDate,endDate,remindType,page,rows);
            return write(200,"查询成功",page,rows,consults);
        }catch (Exception ex){
            error(ex);
            return error(-1, "查询失败!");
        }
    }
    //提醒医生
    @RequestMapping(value = "doctor")
    @ResponseBody
    public String remind(
            @RequestParam(value = "doctor",required = false) String doctor,
            @RequestParam(value = "remindType",required = false) Integer remindType,
            @RequestParam(value = "content",required = false) String content){
        try {
            wlyyConsultRemindLogService.remind(doctor,remindType,content);
            return write(200,"提醒成功!");
        }catch (Exception ex){
            error(ex);
            return error(-1, "提醒失败!");
        }
    }
}

+ 125 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/consult/ConsultReplyController.java

@ -0,0 +1,125 @@
package  com.yihu.customer.controller.manager.consult;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.consult.WlyyReplyConsult;
import com.yihu.customer.service.manager.consult.WlyyReplyConsultService;
import com.yihu.customer.util.DateUtil;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.DecimalFormat;
import java.util.Date;
/**
 * Created by linz on 2017/5/15.
 */
@Controller
@RequestMapping(value = "admin/consult/reply")
@Api(description = "咨询回复统计相关")
public class ConsultReplyController extends BaseController {
    @Autowired
    private WlyyReplyConsultService wlyyReplyConsultService;
    //获取咨询列表
    @RequestMapping(value = "list")
    @ResponseBody
    public String searchList(
            @RequestParam(value = "city",required = false) String city,
            @RequestParam(value = "town",required = false) String town,
            @RequestParam(value = "hospital",required = false) String hospital,
            @RequestParam(value = "teamCode",required = false) String teamCode,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "doctor",required = false) String doctor,
            @RequestParam(value = "reply",required = false) Integer reply,
            @RequestParam(value = "status",required = false) Integer status,
            @RequestParam(value = "beginDate",required = false) String beginDateString,
            @RequestParam(value = "endDate",required = false) String endDateString,
            @RequestParam(value = "page",required = true) int page,
            @RequestParam(value = "rows",required = true) int rows){
        try {
            Date beginDate = null;
            Date endDate = null;
            if(StringUtils.isNotBlank(beginDateString)){
                beginDate = DateUtil.strToDate(beginDateString,DateUtil.YYYY_MM_DD_HH_MM_SS);
            }
            if(StringUtils.isNotBlank(endDateString)){
                endDate = DateUtil.strToDate(endDateString,DateUtil.YYYY_MM_DD_HH_MM_SS);
            }
            PageImpl<WlyyReplyConsult> consults = wlyyReplyConsultService.list(city,town,hospital,teamCode,doctorName,doctor,reply,status,beginDate,endDate,page,rows);
            return write(200,"操作成功",page,rows,consults);
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    //获取咨询总数及回复率
    @RequestMapping(value = "rate")
    @ResponseBody
    public String getHandData(
            @RequestParam(value = "city",required = false) String city,
            @RequestParam(value = "town",required = false) String town,
            @RequestParam(value = "hospital",required = false) String hospital,
            @RequestParam(value = "teamCode",required = false) String teamCode,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "beginDate",required = false) String beginDateString,
            @RequestParam(value = "endDate",required = false) String endDateString){
        try {
            Date beginDate = null;
            Date endDate = null;
            if(StringUtils.isNotBlank(beginDateString)){
                beginDate = DateUtil.strToDate(beginDateString,DateUtil.YYYY_MM_DD_HH_MM_SS);
            }
            if(StringUtils.isNotBlank(endDateString)){
                endDate = DateUtil.strToDate(endDateString,DateUtil.YYYY_MM_DD_HH_MM_SS);
            }
            JSONObject result = new JSONObject();
            //未回复数量
            int countNoReply = wlyyReplyConsultService.getCountByFilter(city,town,hospital,teamCode,doctorName,null,0,0,beginDate,endDate);
            //总数
            int count = wlyyReplyConsultService.getCountByFilter(city,town,hospital,teamCode,doctorName,null,null,null,beginDate,endDate);
            result.put("count",count);
            result.put("noReply",countNoReply);
            DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
            Double rate;
            if(count!=0){
                rate = (countNoReply*100.00)/count;
                String  num = df.format(rate);//返回的是String类型的
                result.put("rate",num+"%");
            }else{
                result.put("rate","0.00%");
            }
            return write(200,"获取成功!","data",result);
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    //获取咨询未回复总数
    @RequestMapping(value = "noReply")
    @ResponseBody
    public String getHandData(
            @RequestParam(value = "doctor",required = false) String doctor){
        try {
            //未回复数量
            int countNoReply = wlyyReplyConsultService.getCountByFilter(null,null,null,null,null,doctor,0,0,null,null);
            return write(200,"获取成功!","data",countNoReply);
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
}

+ 21 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/DeviceStaticController.java

@ -0,0 +1,21 @@
package  com.yihu.customer.controller.manager.datastatic;
import  com.yihu.customer.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
 * 设备统计报表导出
 * @author huangwenjie
 * @date 2017/12/12 10:26
 */
@Controller
@RequestMapping(value = "/admin/static/device/")
public class DeviceStaticController extends BaseController {
	
	//页面跳转(主页面)
	@RequestMapping(value = "initial")
	public String listInit() {
		return "static/static_device";
	}
}

+ 155 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/DoorController.java

@ -0,0 +1,155 @@
package  com.yihu.customer.controller.manager.datastatic;
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.service.statistic.DoorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
 * Created by humingfen on 2020/12/14.
 * 康复下转
 */
@Controller
@RequestMapping(value = "admin/door", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "上门服务")
public class DoorController extends BaseController {
    @Autowired
    private DoorService doorService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initListPage() {
        return "static/door_list";
    }
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ApiOperation("上门服务列表")
    @ResponseBody
    public String searchList(
            @RequestParam(value = "number", required = false) String number,
            @RequestParam(value = "town", required = false) @ApiParam(value = "市区") String town,
            @RequestParam(value = "hospital", required = false) String hospital,
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "name", required = false) String name,
            @RequestParam(value = "idcard", required = false) String idcard,
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(value = "type", required = false) @ApiParam("上门资质人群类型,1残疾人,2肺结核患者,3计生特殊家庭,4重性精神病,5失能/半失能老人,6其他") String type,
            @RequestParam(value = "page", required = true) Integer page,
            @RequestParam(value = "rows", required = true) Integer rows) {
        try {
            Page list = doorService.searchList(number, town, hospital,name,idcard,startDate, endDate, type, page, rows);
            return write(200, "操作成功", page, rows, list);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "deleteById", method = RequestMethod.POST)
    @ApiOperation("删除上门服务记录")
    @ResponseBody
    public String deleteById(
            @RequestParam(value = "id")
            @ApiParam(value = "上门服务id") String id) {
        try {
            doorService.deleteById(id);
            return write(200, "操作成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "exportExcel", method = RequestMethod.POST)
    @ApiOperation("导出上门列表")
    @ResponseBody
    public void searchList(
            @RequestParam(value = "town", required = false) @ApiParam(value = "市区") String town,
            @RequestParam(value = "hospital", required = false) String hospital,
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(value = "name", required = false) String name,
            @RequestParam(value = "idcard", required = false) String idcard,
            @RequestParam(value = "type", required = false) @ApiParam("上门资质人群类型,1残疾人,2肺结核患者,3计生特殊家庭,4重性精神病,5失能/半失能老人,6其他") String type,
            HttpServletResponse response) {
        try {
            List<Map<String, Object>> list = doorService.exportList(town, hospital, name,idcard,startDate, endDate,type);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("doorList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os, list);
        } catch (Exception ex) {
            error(ex);
        }
    }
    private void write(OutputStream os, List<Map<String, Object>> list) throws Exception {
        WritableWorkbook wwb = Workbook.createWorkbook(os);
        try {
            WritableSheet sheet = wwb.createSheet("sheet", 1);
            String header[] = {"服务对象", "身份证号", "居民联系方式", "服务类型", "服务医生","服务社区","调度员备注", "服务次数", "工单状态"};
            int i = 0;
            for (String h : header) {
                addCell(sheet, 0, i, h);
                i++;
            }
            int j = 1;
            for (Map<String, Object> map : list) {
                addCell(sheet, j, 0, map.get("patientName") + "");
                addCell(sheet, j, 1, map.get("idcard") + "");
                addCell(sheet, j, 2, map.get("mobile") != null ? map.get("mobile").toString() : "");
                addCell(sheet, j, 3, map.get("typeValue") + "");
                addCell(sheet, j, 4, map.get("doctorName") != null ? map.get("doctorName").toString() : "");
                addCell(sheet, j, 5, map.get("hospitalName") != null ? map.get("hospitalName").toString() : "");
                addCell(sheet, j, 6, map.get("remark") != null ? map.get("remark").toString() : "");
                addCell(sheet, j, 7, map.get("count") + "");
                if (map.get("status").toString().equals("-1")) {
                    addCell(sheet, j, 8, "已取消");
                } else  if (map.get("status").toString().equals("1")) {
                    addCell(sheet, j, 8, "待派单");
                }else  if (map.get("status").toString().equals("2")){
                    addCell(sheet, j, 8, "待接单");
                }else  if (map.get("status").toString().equals("3")){
                    addCell(sheet, j, 8, "已接单");
                }else  if (map.get("status").toString().equals("4")){
                    addCell(sheet, j, 8, "待服务");
                }else  if (map.get("status").toString().equals("5")){
                    addCell(sheet, j, 8, "待评价");
                }else  if (map.get("status").toString().equals("6")){
                    addCell(sheet, j, 8, "已完成");
                }
                j++;
            }
            wwb.write();
            wwb.close();
        } catch (Exception e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
        }
    }
    private void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        ws.addCell(label);
    }
}

+ 156 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/HealthEduController.java

@ -0,0 +1,156 @@
/*
package com.yihu.jw.controller.manager.datastatic;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.entity.SignFamily;
import com.yihu.jw.entity.es.HealthEduPatientCode;
import com.yihu.jw.entity.organization.HospitalMapping;
import com.yihu.jw.repository.organization.HospitalMappingDao;
import com.yihu.jw.service.healthedu.HealthEduService;
import com.yihu.jw.service.manager.sign.FamilyContractService;
import com.yihu.jw.util.ElasticsearchUtil;
import jxl.Workbook;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
*/
/**
 * 健康教育推送报表导出
 * @author huangwenjie
 * @date 2017/12/12 20:20
 *//*
@Controller
@RequestMapping(value = "/admin/static/healthedu")
public class HealthEduController extends BaseController {
	
	@Autowired
	private HealthEduService healthEduService;
	
	@Value("${es.type.HealthEduArticlePatient}")
	private String esType;
	@Value("${es.index.HealthEduArticlePatient}")
	private String esIndex;
	@Autowired
	private ElasticsearchUtil elasticsearchUtil;
	@Autowired
	private FamilyContractService familyContractService;
	@Autowired
	private HospitalMappingDao hospitalMappingDao;
	
	//页面跳转(主页面)
	@RequestMapping(value = "initial")
	public String listInit() {
		return "static/static_healthedu";
	}
	
	//导出签约支付报表
	@RequestMapping(value="pushlistToExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
	public void signPayExport(
			@RequestParam(value = "beginDate",required = false)String beginDate,
			@RequestParam(value = "endDate",required = false)String endDate,
			HttpServletResponse response){
		try {
			
			List<SignFamily> signFamilies = new ArrayList<>();
			
			Map<String,String> orgcodemap = new HashMap<>();
			
			Set<String> patientcodesets = new HashSet<>();
			
			String sql = "SELECT patientCode FROM "+esType+" where createTime >='"+beginDate+"T00:00:00+0800' and createTime <='"+endDate+"T23:59:59+0800'  group by patientCode limit 0,1000000";
			
			List<HealthEduPatientCode> patientCodes = elasticsearchUtil.excute(sql, HealthEduPatientCode.class, esIndex, esType);
			
			for (HealthEduPatientCode es: patientCodes) {
				System.out.println(patientcodesets.size());
				if(patientcodesets.contains(es.getPatientCode())){
					continue;
				}else{
					patientcodesets.add(es.getPatientCode());
				}
				SignFamily obj = familyContractService.findSignByPatient(es.getPatientCode());
				if( obj == null){
					continue;
				}
				String jworgcode = "";
				if(orgcodemap.isEmpty() || !orgcodemap.keySet().contains(obj.getHospital())){
					HospitalMapping hospitalMapping =  hospitalMappingDao.findByCode(obj.getHospital());
					if(hospitalMapping == null){
						continue;
					}
					jworgcode = hospitalMapping.getMappingCode();
					orgcodemap.put(obj.getHospital(),jworgcode);
				}else{
					jworgcode = orgcodemap.get(obj.getHospital());
				}
				obj.setHospital(jworgcode);
				signFamilies.add(obj);
			}
			
			response.setContentType("octets/stream");
			response.setHeader("Content-Disposition", "attachment; filename="+ new String( "pushDataList.xls"));
			OutputStream os = response.getOutputStream();
			this.pushListWrite(os,signFamilies);
		}catch (Exception ex){
			error(ex);
		}
	}
	
	public void pushListWrite(OutputStream os, List ls) throws Exception{
		WritableWorkbook wwb = Workbook.createWorkbook(os);
		try {
			WritableSheet ws;
			ws = wwb.createSheet("sheet",1);
			
			String[] header = {"居民姓名","居民身份证号","居民社保卡号","签约社区", "签约社区CODE"};
			int k = 0;
			for (String h : header) {
				addCell(ws, 0, k, h);//表名,行,列,header
				k++;
			}
			
			int i = 1;
			for (SignFamily m : (List<SignFamily>) ls) {
				addCell(ws, i, 0, m.getName(),"");
				addCell(ws, i, 1, m.getIdcard(),"");
				addCell(ws, i, 2, m.getSsc(),"");
				addCell(ws, i, 3, m.getHospitalName(),"");
				addCell(ws, i, 4, m.getHospital(),"");
				i++;
			}
			wwb.write();
			wwb.close();
		} catch (IOException e) {
			e.printStackTrace();
			if (wwb != null) wwb.close();
			throw e;
		}
	}
	//添加单元格内容
	public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
		Label label = new Label(column ,row, data);
		ws.addCell(label);
	}
	//添加单元格内容
	public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
		Label label = new Label(column ,row, data);
		if(!org.springframework.util.StringUtils.isEmpty(memo)){
			WritableCellFeatures cellFeatures = new WritableCellFeatures();
			cellFeatures.setComment(memo);
			label.setCellFeatures(cellFeatures);
		}
		ws.addCell(label);
	}
}
*/

+ 65 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/PayLogController.java

@ -0,0 +1,65 @@
package  com.yihu.customer.controller.manager.datastatic;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.PayLog;
import com.yihu.customer.service.httplog.ManagePayLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * Created by humingfen on 2018/7/16.
 * 支付日志管理
 */
@Controller
@RequestMapping("admin/paylog")
public class PayLogController extends BaseController {
    @Autowired
    private ManagePayLogService managePayLogService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initListPage(){
        return "static/pay_log_list";
    }
    @RequestMapping(value = "infoInit", method = RequestMethod.GET)
    public String initInfoPage(@RequestParam(value = "id") Integer id){
        request.setAttribute("id",id);
        return "static/pay_log_modify";
    }
    @RequestMapping(value ="list",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @RequestParam(value = "params",required = false) String params,
            @RequestParam(value = "startDate",required = false) String startDate,
            @RequestParam(value = "endDate",required = false) String endDate,
            @RequestParam(value = "status",required = false) String status,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            Page<PayLog> payLogs = managePayLogService.searchList(params,startDate, endDate, status, page, pageSize);
            return write(200,"操作成功",page,pageSize,payLogs);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //根据id获取
    @RequestMapping(value = "findById")
    @ResponseBody
    public String findById(@RequestParam(value = "id") Long id) {
        try {
            PayLog payLog = managePayLogService.findById(id);
            return write(200, "操作成功!", "data", payLog);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 141 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/RehabilitationPatientController.java

@ -0,0 +1,141 @@
package  com.yihu.customer.controller.manager.datastatic;
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.service.statistic.RehabilitationPatientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
 * Created by humingfen on 2020/12/14.
 * 康复下转
 */
@Controller
@RequestMapping(value = "admin/rehabilitation", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "康复下转居民")
public class RehabilitationPatientController extends BaseController {
    @Autowired
    private RehabilitationPatientService rehabilitationPatientService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initListPage() {
        return "static/rehabilitation_patient_list";
    }
    @RequestMapping(value = "infoInit", method = RequestMethod.GET)
    public String initInfoPage(@RequestParam(value = "id") String id){
        request.setAttribute("id",id);
        return "static/rehabilitation_patient_detail";
    }
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ApiOperation("康复下转列表")
    @ResponseBody
    public String searchList(
            @RequestParam(value = "id", required = false) @ApiParam(value = "康复计划id") String id,
            @RequestParam(value = "town", required = false) @ApiParam(value = "市区") String town,
            @RequestParam(value = "hospital", required = false) String hospital,
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(value = "disease", required = false) @ApiParam("疾病类型code") String disease,
            @RequestParam(value = "isManage", required = false) @ApiParam(value = "是否管理,1是0否", name = "isManage") Integer isManage,
            @RequestParam(value = "page", required = true) Integer page,
            @RequestParam(value = "rows", required = true) Integer rows) {
        try {
            Page list = rehabilitationPatientService.searchList(id, town, hospital, startDate, endDate, disease, isManage, page, rows);
            return write(200, "操作成功", page, rows, list);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "exportExcel", method = RequestMethod.POST)
    @ApiOperation("导出康复下转居民列表")
    @ResponseBody
    public void searchList(
            @RequestParam(value = "town", required = false) @ApiParam(value = "市区") String town,
            @RequestParam(value = "hospital", required = false) String hospital,
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(value = "disease", required = false) @ApiParam("疾病类型code") String disease,
            @RequestParam(value = "isManage", required = false) @ApiParam(value = "是否管理,1是0否", name = "isManage") Integer isManage,
            HttpServletResponse response) {
        try {
            List<Map<String, Object>> list = rehabilitationPatientService.exportList(town, hospital, startDate, endDate, disease, isManage);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("rehabilitationPatientList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os, list);
        } catch (Exception ex) {
            error(ex);
        }
    }
    private void write(OutputStream os, List<Map<String, Object>> list) throws Exception {
        WritableWorkbook wwb = Workbook.createWorkbook(os);
        try {
            WritableSheet sheet = wwb.createSheet("sheet", 1);
            String header[] = {"姓名", "身份证号", "疾病类型", "专科医院", "专科医生", "签约社区", "签约医生", "是否接收","是否服务", "下转时间"};
            int i = 0;
            for (String h : header) {
                addCell(sheet, 0, i, h);
                i++;
            }
            int j = 1;
            for (Map<String, Object> map : list) {
                addCell(sheet, j, 0, map.get("name") + "");
                addCell(sheet, j, 1, map.get("idcard") + "");
                addCell(sheet, j, 2, map.get("diseaseName") + "");
                addCell(sheet, j, 3, map.get("sHospitalName") + "");
                addCell(sheet, j, 4, map.get("specialistName") + "");
                addCell(sheet, j, 5, map.get("hospitalName") + "");
                addCell(sheet, j, 6, map.get("doctorName") + "");
                if (map.get("isManage") == null || map.get("isManage").toString().equals("0")) {
                    addCell(sheet, j, 7, "否");
                } else {
                    addCell(sheet, j, 7, "是");
                }
                if (map.get("served") == null || map.get("served").toString().equals("0")) {
                    addCell(sheet, j, 8, "否");
                } else {
                    addCell(sheet, j, 8, "是");
                }
                addCell(sheet, j, 9, map.get("createTime").toString());
                j++;
            }
            wwb.write();
            wwb.close();
        } catch (Exception e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
        }
    }
    private void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        ws.addCell(label);
    }
}

+ 133 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/ReplyStaticController.java

@ -0,0 +1,133 @@
package  com.yihu.customer.controller.manager.datastatic;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.consult.WlyyConsultTeamExportVO;
import com.yihu.customer.service.manager.consult.WlyyConsultTeamService;
import jxl.Workbook;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
/**
 * Created by humingfen on 2018/8/7.
 */
@Controller
@RequestMapping("admin/static/consult")
public class ReplyStaticController extends BaseController {
    @Autowired
    private WlyyConsultTeamService consultTeamService;
    @Autowired
    ObjectMapper objectMapper;
    @RequestMapping(value = "initial")
    public String initList(){
        return "static/static_consult";
    }
    //导出报表
    @RequestMapping(value="toExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public void exportList(
            @RequestParam(value = "createTime",required = false)String createTime,
            @RequestParam(value = "town",required = false)String town,
            @RequestParam(value = "hospital",required = false)String hospital,
            HttpServletResponse response){
        try {
            List<WlyyConsultTeamExportVO> consultTeams = consultTeamService.exportReplyDelayList(town,hospital,createTime);
            /*String data = "[{" +
                    "\"symptoms\":\"李医生,我孩子赖抒明的续费,为什么无法操作?\"," +
                    "\"name\":\"易鹭燕\"," +
                    "\"create_time\":\"2018/7/4 13:09:26\"," +
                    "\"reply_time\":\"2018/7/12 20:00:02\"," +
                    "\"content\":\"没有关系,下次来社区现场缴费即可。\"," +
                    "\"team_name\":\"禾山社区团队\"," +
                    "\"doctor_name\":\"李冬彬\"," +
                    "\"doctor_health_name\":\"李冬彬\"" +
                    "}," +
                    "{" +
                    "\"symptoms\":\"小腹会有涨痛感,白天有多次放屁,晨起时也会放屁。要如何治疗?\"," +
                    "\"name\":\"杨秋梅\"," +
                    "\"create_time\":\"2018/7/5 11:15:08\"," +
                    "\"reply_time\":\"2018/7/17 18:24:54\"," +
                    "\"content\":\"不好意思,之前没看到消息,你这样应该是肠胃不好,最好是中药调理,有空过来当面看一下\"," +
                    "\"team_name\":\"岭下社区团队\"," +
                    "\"doctor_name\":\"陈余妍\"," +
                    "\"doctor_health_name\":\"张陈大添\"" +
                    "}" +
                    "]" ;
            List<WlyyConsultTeamExportVO> consultTeams = (List<WlyyConsultTeamExportVO>)JSONArray.toList(JSONArray.fromObject(data), WlyyConsultTeamExportVO.class);*/
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "ReplyDelayList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os,consultTeams);
        }catch (Exception ex){
            error(ex);
        }
    }
    public void write(OutputStream os, List ls) throws Exception{
        write(Workbook.createWorkbook(os), ls);
    }
    public void write(WritableWorkbook wwb, List ls) throws Exception {
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet",1);
            addHeader(ws);
            int i = 1;
            for (WlyyConsultTeamExportVO c : (List<WlyyConsultTeamExportVO>) ls) {
                addCell(ws, i, 0, c.getSymptoms(),"");
                addCell(ws, i, 1, c.getName(),"");
                addCell(ws, i, 2, c.getCreate_time(),"");
                addCell(ws, i, 3, c.getReply_time(),"");
                addCell(ws, i, 4, c.getContent(),"");
                addCell(ws, i, 5, c.getTeam_name(),"");
                addCell(ws, i, 6, c.getDoctor_name(),"");
                addCell(ws, i, 7, c.getDoctor_health_name(),"");
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void addHeader(WritableSheet ws) throws WriteException {
        String[] header = {"咨询内容","居民姓名","咨询时间","回复时间","回复内容","团队", "全科医生", "健管师"};
        int i = 0;
        for (String h : header) {
            addCell(ws, 0, i, h);//表名,行,列,header
            i++;
        }
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
        Label label = new Label(column ,row, data);
        ws.addCell(label);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
        Label label = new Label(column ,row, data);
        if(!org.springframework.util.StringUtils.isEmpty(memo)){
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        ws.addCell(label);
    }
}

+ 175 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/datastatic/WeChatStaticController.java

@ -0,0 +1,175 @@
package  com.yihu.customer.controller.manager.datastatic;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.wechat.WechatSignVO;
import  com.yihu.customer.entity.wechat.WechatTotalVO;
import com.yihu.customer.service.wechat.WechatService;
import jxl.Workbook;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
/**
 * 微信报表导出
 * @author huangwenjie
 * @date 2017/12/11 08:58
 */
@Controller
@RequestMapping(value = "/admin/static/wechat")
public class WeChatStaticController extends BaseController {
	
	@Autowired
	private WechatService wechatService;
	
	//页面跳转(主页面)
	@RequestMapping(value = "initial")
	public String listInit() {
		return "static/static_wechat";
	}
	
	//导出详情报表报表
	@RequestMapping(value="listToExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
	public void exportList(
			@RequestParam(value = "town",required = false)String town,
			@RequestParam(value = "hospital",required = false)String hospital,
			@RequestParam(value = "attention",required = false)String attention,
			@RequestParam(value = "signSource",required = false)String signSource,
			HttpServletResponse response){
		try {
			List<WechatSignVO> datalist = wechatService.geSignWechatDataList(hospital,attention, signSource);
			response.setContentType("octets/stream");
			response.setHeader("Content-Disposition", "attachment; filename="+ new String( "signWechatDataList.xls"));
			OutputStream os = response.getOutputStream();
			this.listWrite(os,datalist);
		}catch (Exception ex){
			error(ex);
		}
	}
	
	//导出社区报表
	@RequestMapping(value="hosipitaTotalToExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
	public void hosipitaTotalData(
			HttpServletResponse response){
		try {
			List<WechatTotalVO> datalist = wechatService.hosipitaTotalData();
			response.setContentType("octets/stream");
			response.setHeader("Content-Disposition", "attachment; filename="+ new String( "hosipitaTotalData.xls"));
			OutputStream os = response.getOutputStream();
			this.totalWrite(os,datalist);
		}catch (Exception ex){
			error(ex);
		}
	}
	
	//导出行政区报表
	@RequestMapping(value="townTotalToExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
	public void townTotalData(
			HttpServletResponse response){
		try {
			List<WechatTotalVO> datalist = wechatService.townTotalData();
			response.setContentType("octets/stream");
			response.setHeader("Content-Disposition", "attachment; filename="+ new String( "townTotalData.xls"));
			OutputStream os = response.getOutputStream();
			this.totalWrite(os,datalist);
		}catch (Exception ex){
			error(ex);
		}
	}
	
	public void totalWrite(OutputStream os, List ls) throws Exception{
		WritableWorkbook wwb = Workbook.createWorkbook(os);
		try {
			WritableSheet ws;
			ws = wwb.createSheet("sheet",1);
			
			String[] header = {"机构/行政区","关注率(关注数/签约数)","关注数","签约数"};
			int k = 0;
			for (String h : header) {
				addCell(ws, 0, k, h);//表名,行,列,header
				k++;
			}
			
			int i = 1;
			for (WechatTotalVO m : (List<WechatTotalVO>) ls) {
				addCell(ws, i, 0, m.getName(),"");
				addCell(ws, i, 1,String.valueOf(m.getAttRate()),"");
				addCell(ws, i, 2, String.valueOf(m.getAttNumber()),"");
				addCell(ws, i, 3, String.valueOf(m.getSignNumber()),"");
				i++;
			}
			wwb.write();
			wwb.close();
		} catch (IOException e) {
			e.printStackTrace();
			if (wwb != null) wwb.close();
			throw e;
		}
	}
	
	
	public void listWrite(OutputStream os, List ls) throws Exception{
		WritableWorkbook wwb = Workbook.createWorkbook(os);
		try {
			WritableSheet ws;
			ws = wwb.createSheet("sheet",1);
			
			String[] header = {"居民openid","居民姓名","手机号码","出生日期","性别","openid更新时间","医疗保险号", "身份证号","全科医生", "健管师", "社区医院", "居委会","住址","街道","openid重复数","签约来源(1线下 2线上)","签约时间"};
			int k = 0;
			for (String h : header) {
				addCell(ws, 0, k, h);//表名,行,列,header
				k++;
			}
			
			int i = 1;
			for (WechatSignVO m : (List<WechatSignVO>) ls) {
				addCell(ws, i, 0, m.getOpenid(),"");
				addCell(ws, i, 1, m.getPatientname(),"");
				addCell(ws, i, 2, m.getMobile(),"");
				addCell(ws, i, 3, m.getBirthday(),"");
				addCell(ws, i, 4, m.getSex(), "");
				addCell(ws, i, 5, m.getOpenid_time(),"");
				addCell(ws, i, 6, m.getMedicare_number(), "");
				addCell(ws, i, 7, m.getIdcard(),"");
				addCell(ws, i, 8, m.getDoctor_name(),"");
				addCell(ws, i, 9, m.getDoctor_health_name(),"");
				addCell(ws, i, 10, m.getHospital_name(),"");
				addCell(ws, i, 11, m.getSick_village_name(),"");
				addCell(ws, i, 12, m.getAddress(),"");
				addCell(ws, i, 13, m.getStreet_name(),"");
				addCell(ws, i, 14, m.getTcount(),"");
				addCell(ws, i, 15, m.getSign_source(),"");
				addCell(ws, i, 16, m.getApply_date(),"");
				i++;
			}
			wwb.write();
			wwb.close();
		} catch (IOException e) {
			e.printStackTrace();
			if (wwb != null) wwb.close();
			throw e;
		}
	}
	//添加单元格内容
	public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
		Label label = new Label(column ,row, data);
		ws.addCell(label);
	}
	//添加单元格内容
	public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
		Label label = new Label(column ,row, data);
		if(!org.springframework.util.StringUtils.isEmpty(memo)){
			WritableCellFeatures cellFeatures = new WritableCellFeatures();
			cellFeatures.setComment(memo);
			label.setCellFeatures(cellFeatures);
		}
		ws.addCell(label);
	}
}

+ 243 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/DeviceHealthIndexController.java

@ -0,0 +1,243 @@
package  com.yihu.customer.controller.manager.device;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.device.entity.DeviceHealthIndexExportVO;
import  com.yihu.customer.device.entity.DeviceHealthIndexVO;
import com.yihu.customer.service.manager.device.DeviceHealthIndexService;
import jxl.Workbook;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.List;
/**
 * Created by Administrator on 2016/12/5.
 */
@Controller
@RequestMapping("admin/healthIndex")
public class DeviceHealthIndexController extends BaseController{
    @Autowired
    private DeviceHealthIndexService healthIndexService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initList(){return "device/deviceHealthIndex_list";}
    @RequestMapping(value ="list",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "date",required = false) String date,
            @RequestParam(value = "idcard",required = false) String idcard,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "indexType",required = false) String indexType,
            @RequestParam(value = "indexTypeMin1",required = false) Double indexTypeMin1,
            @RequestParam(value = "indexTypeMax1",required = false) Double indexTypeMax1,
            @RequestParam(value = "indexTypeMin2",required = false) Double indexTypeMin2,
            @RequestParam(value = "indexTypeMax2",required = false) Double indexTypeMax2,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "hospital",required = false) String hospital,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            Page<DeviceHealthIndexVO> deviceHealthIndexes = healthIndexService.searchList(deviceSn,date, idcard, userName, indexType,page, pageSize,indexTypeMin1, indexTypeMax1, indexTypeMin2,indexTypeMax2,doctorName, hospital);
            return write(200,"操作成功",page,pageSize,deviceHealthIndexes);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    
    //导出报表
    @RequestMapping(value="toExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public void exportList(
            @RequestParam(value = "town",required = false)String town,
            @RequestParam(value = "hospital",required = false)String hospital,
            HttpServletResponse response){
        try {
            List<DeviceHealthIndexExportVO> wlyyDevices = healthIndexService.exportDeviceHealthIndexList(town,hospital);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "deviceHealthIndexDataList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os,wlyyDevices);
        }catch (Exception ex){
            error(ex);
        }
    }
    //设备体征报表导出
    @RequestMapping(value="export",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public void export(
            @RequestParam(value = "town",required = false)String town,
            @RequestParam(value = "hospital",required = false)String hospital,
            HttpServletResponse response){
        try {
            List<DeviceHealthIndexExportVO> wlyyDevices = healthIndexService.exportDeviceHealthList(town,hospital);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "deviceHealthIndexDataList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os,wlyyDevices);
        }catch (Exception ex){
            error(ex);
        }
    }
    /**
     * 按筛选条件导出居民体征数据报表
     * @param deviceSn 设备sn码
     * @param date 查询日期
     * @param idcard 居民身份证号
     * @param userName 居民姓名
     * @param indexType 体征类别
     * @param response
     * @return
     */
//    @ResponseBody
    @RequestMapping(value="getExcelByFilter",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public void exportList(
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "date",required = false) String date,
            @RequestParam(value = "idcard",required = false) String idcard,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "indexType",required = false) String indexType,
            @RequestParam(value = "indexTypeMin1",required = false) Double indexTypeMin1,
            @RequestParam(value = "indexTypeMax1",required = false) Double indexTypeMax1,
            @RequestParam(value = "indexTypeMin2",required = false) Double indexTypeMin2,
            @RequestParam(value = "indexTypeMax2",required = false) Double indexTypeMax2,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "hospital",required = false) String hospital,
            HttpServletResponse response){
        try {
            List<DeviceHealthIndexVO> deviceHealthIndexes = healthIndexService.getExcelByFilter(deviceSn,date, idcard, userName, indexType,indexTypeMin1,indexTypeMax1,indexTypeMin2,indexTypeMax2,doctorName, hospital);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "patientHealthIndexDataList.xls"));
            OutputStream os = response.getOutputStream();
            this.writePatientHealth(os,deviceHealthIndexes);
        }catch (Exception ex){
            error(ex);
        }
    }
    
    public void addHeader(WritableSheet ws) throws WriteException {
        
        String[] header = {"居民姓名","手机号","身份证","设备码","设备名称","签约医生", "地址", "记录时间", "上传次数"};
        int i = 0;
        for (String h : header) {
            addCell(ws, 0, i, h);//表名,行,列,header
            i++;
        }
    }
    public void addPatientHealthHeader(WritableSheet ws) throws WriteException {
        String[] header = {"SN码","创建日期","身份证号","姓名","数据类型","value1","value2","value3","value4","value5","value6","value7"};
        int i = 0;
        for (String h : header) {
            addCell(ws, 0, i, h);//表名,行,列,header
            i++;
        }
    }
    
    public void write(WritableWorkbook wwb, List ls) throws Exception {
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet",1);
            addHeader(ws);
            int i = 1;
            for (DeviceHealthIndexExportVO m : (List<DeviceHealthIndexExportVO>) ls) {
                addCell(ws, i, 0, m.getName(),"");
                addCell(ws, i, 1, m.getMobile(),"");
                addCell(ws, i, 2, m.getIdcard(),"");
                addCell(ws, i, 3, m.getDevice_sn(),"");
                addCell(ws, i, 4, m.getDevice_name(),"");
                addCell(ws, i, 5, m.getDoctor_name(),"");
                addCell(ws, i, 6, m.getAddress(),"");
                addCell(ws, i, 7, m.getRecord_date(),"");
                addCell(ws, i, 8, m.getAmount(),"");
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void writePatientHealth(WritableWorkbook wwb, List ls) throws Exception {
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            WritableSheet ws;
            ws = wwb.createSheet("sheet",1);
            addPatientHealthHeader(ws);
            int i = 1;
            for (DeviceHealthIndexVO m : (List<DeviceHealthIndexVO>) ls) {
                String type = "未知";
                if (m.getType()==1){
                    type = "血糖";
                }else if (m.getType()==2){
                    type = "血压";
                }else if (m.getType()==3){
                    type = "体重";
                }else if (m.getType()==4){
                    type = "腰围";
                }
                addCell(ws, i, 0, m.getDeviceSn(),"");
                addCell(ws, i, 1, format.format(m.getCzrq()),"");
                addCell(ws, i, 2, m.getIdcard(),"");
                addCell(ws, i, 3, m.getUserName(),"");
                addCell(ws, i, 4, type,"");
                addCell(ws, i, 5, m.getValue1(),"");
                addCell(ws, i, 6, m.getValue2(),"");
                addCell(ws, i, 7, m.getValue3(),"");
                addCell(ws, i, 8, m.getValue4(),"");
                addCell(ws, i, 9, m.getValue5(),"");
                addCell(ws, i, 10, m.getValue6(),"");
                addCell(ws, i, 11, m.getValue7(),"");
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void write(OutputStream os, List ls) throws Exception{
        write(Workbook.createWorkbook(os), ls);
    }
    public void writePatientHealth(OutputStream os, List ls) throws Exception{
        writePatientHealth(Workbook.createWorkbook(os), ls);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
        Label label = new Label(column ,row, data);
        ws.addCell(label);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
        Label label = new Label(column ,row, data);
        if(!org.springframework.util.StringUtils.isEmpty(memo)){
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        ws.addCell(label);
    }
}

+ 127 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/DeviceManufacturerController.java

@ -0,0 +1,127 @@
package  com.yihu.customer.controller.manager.device;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.device.entity.DeviceManufacturer;
import com.yihu.customer.service.manager.device.DeviceManufacturerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
 * Created by humingfen on 2018/6/6.
 * 设备管理
 */
@Controller
@RequestMapping("admin/manufacturer")
public class DeviceManufacturerController extends BaseController {
    @Autowired
    private DeviceManufacturerService deviceManufacturerService;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initListPage(){
        return "device/deviceManufacturer_list";
    }
    @RequestMapping(value = "infoInit")
    public String initInfoPage(@RequestParam(value = "id") Integer id,String type){
        request.setAttribute("id",id);
        request.setAttribute("type",type);
        return "device/deviceManufacturer_modify";
    }
    @RequestMapping(value ="list",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @RequestParam(value = "manufacturerName",required = false) String manufacturerName,
            @RequestParam(value = "manufacturerCode",required = false) String manufacturerCode,
            @RequestParam(value = "address",required = false) String address,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            Page<DeviceManufacturer> deviceManufacturer = deviceManufacturerService.searchList(manufacturerName,manufacturerCode, address, page, pageSize);
            return write(200,"操作成功",page,pageSize,deviceManufacturer);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "findById", method = RequestMethod.POST)
    @ResponseBody
    public String getManufacturer(@RequestParam(value = "id") Long id){
        try {
            DeviceManufacturer manufacturer = deviceManufacturerService.findById(id);
            return  write(200,"操作成功","data",manufacturer);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "create")
    @ResponseBody
    public String createManufacturer(String jsonData, String code){
        try{
            DeviceManufacturer manufacturer = objectMapper.readValue(jsonData, DeviceManufacturer.class);
            // 判断是否存在code,存在直接
            Boolean b = deviceManufacturerService.existCode(code);
            if(b){
                return error(-1,"厂商标识已存在");
            }
            deviceManufacturerService.createManufacturer(manufacturer);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "update")
    @ResponseBody
    public String updateManufacturer(String jsonData){
        try{
            DeviceManufacturer manufacturer = objectMapper.readValue(jsonData, DeviceManufacturer.class);
            deviceManufacturerService.updateManufacturer(manufacturer);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deleteDevice(Long id){
        try{
            deviceManufacturerService.deleteManufacturer(id);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "findAll")
    @ResponseBody
    public String findAll(){
        try{
            List<DeviceManufacturer> manufacturer = deviceManufacturerService.findAll();
            return write(200,"操作成功","data",manufacturer);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
}

+ 115 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/IotDeviceController.java

@ -0,0 +1,115 @@
package  com.yihu.customer.controller.manager.device;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.device.entity.DeviceHealthIndexVO;
import  com.yihu.customer.device.entity.WlyyDevice;
import  com.yihu.customer.device.entity.WlyyPatientDeviceVO;
import com.yihu.customer.service.doctor.DoctorService;
import com.yihu.customer.service.manager.device.DeviceHealthIndexService;
import com.yihu.customer.service.manager.device.WlyyDeviceService;
import com.yihu.customer.service.manager.device.WlyyPatientDeviceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * 提供物联网查询
 * @author yeshijie on 2018/5/24.
 */
@RestController
@RequestMapping(value = "/svr-iot/device/",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class IotDeviceController extends BaseController {
    @Autowired
    private WlyyDeviceService deviceService;
    @Autowired
    private DeviceHealthIndexService healthIndexService;
    @Autowired
    private WlyyPatientDeviceService patientDeviceService;
    @Autowired
    private DoctorService doctorService;
    //列表查询
    @RequestMapping(value="deviceList",method = RequestMethod.GET)
    @ApiOperation("设备管理")
    public String searchList(
            @RequestParam(value = "deviceName",required = false)String deviceName,
            @RequestParam(value = "deviceCode",required = false) String deviceCode,
            @RequestParam(value = "orgName",required = false)String orgName,
            @RequestParam(value = "linkman",required = false) String linkman,
            @RequestParam(value = "page",required = false)Integer page,
            @RequestParam(value = "pageSize",required = false)Integer pageSize){
        try {
            Page<WlyyDevice> wlyyDevices = deviceService.searchDeviceList(deviceName,deviceCode,orgName,linkman, page, pageSize);
            return write(200,"操作成功",page,pageSize,wlyyDevices);
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "findDeviceById",method = RequestMethod.GET)
    @ApiOperation("根据设备id查找设备管理")
    public String getDevice(@RequestParam(value = "id") Long id){
        try {
            WlyyDevice device = deviceService.findById(id);
            return  write(200,"操作成功","data",device);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value ="healthlist",method = RequestMethod.GET)
    @ApiOperation("体征数据查询")
    public String searchList(
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "date",required = false) String date,
            @RequestParam(value = "idcard",required = false) String idcard,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "indexType",required = false) String indexType,
            @RequestParam(value = "indexTypeMin1",required = false) Double indexTypeMin1,
            @RequestParam(value = "indexTypeMax1",required = false) Double indexTypeMax1,
            @RequestParam(value = "indexTypeMin2",required = false) Double indexTypeMin2,
            @RequestParam(value = "indexTypeMax2",required = false) Double indexTypeMax2,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "pageSize",required = false) Integer pageSize){
        try{
            Page<DeviceHealthIndexVO> deviceHealthIndexes = healthIndexService.searchList2(deviceSn,date, idcard, userName, indexType,page, pageSize,indexTypeMin1, indexTypeMax1, indexTypeMin2,indexTypeMax2,doctorName);
            return write(200,"操作成功",page,pageSize,deviceHealthIndexes);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "patientDeviceList",method = RequestMethod.GET)
    @ApiOperation("居民设备查询")
    public String searchList(
            @RequestParam(value = "deviceName",required = false) String deviceName,
            @RequestParam(value = "categoryCode",required = false) String categoryCode,
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "hospitalName",required = false) String hospitalName,
            @RequestParam(value = "page") Integer page,
            @RequestParam(value = "pageSize") Integer pageSize){
        try {
            String hospitalCode = "";
            List<WlyyPatientDeviceVO> patientDevices = patientDeviceService.searchListNew(deviceName,categoryCode, deviceSn, userName, doctorName,hospitalName,hospitalCode,page, pageSize);
            Long totalcount = patientDeviceService.getCountSearchListNew(deviceName,categoryCode, deviceSn, userName, doctorName,hospitalName,hospitalCode);
            return write(200,"操作成功",page,pageSize,totalcount,patientDevices);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 271 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/WlyyDeviceController.java

@ -0,0 +1,271 @@
package  com.yihu.customer.controller.manager.device;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.device.entity.WlyyDevice;
import  com.yihu.customer.entity.DmDevice;
import com.yihu.customer.service.manager.device.DmDeviceService;
import com.yihu.customer.service.manager.device.PatientDeviceService;
import com.yihu.customer.service.manager.device.WlyyDeviceService;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
/**
 * Created by yww on 2016/12/2.
 * 设备管理
 */
@Controller
@RequestMapping("admin/device")
public class WlyyDeviceController extends BaseController {
    @Autowired
    private WlyyDeviceService deviceService;
    @Autowired
    private DmDeviceService dmDeviceService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initListPage(){
        return "device/device_list";
    }
    @RequestMapping(value = "infoInit")
    public String initInfoPage(@RequestParam(value = "id") Integer id,String type){
        request.setAttribute("id",id);
        request.setAttribute("type",type);
        return "device/device_modify";
    }
    @RequestMapping(value = "createInit")
    public String initCreatePage(){
//        request.setAttribute("id",id);
        return  "device/device_create";
    }
    //列表查询
    @RequestMapping(value="deviceList",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @RequestParam(value = "deviceName",required = false)String deviceName,
            @RequestParam(value = "deviceCode",required = false) String deviceCode,
            @RequestParam(value = "orgName",required = false)String orgName,
            @RequestParam(value = "linkman",required = false) String linkman,
            @RequestParam(value = "page",required = false)Integer page,
            @RequestParam(value = "rows",required = false)Integer pageSize){
        try {
            Page<WlyyDevice> wlyyDevices = deviceService.searchDeviceList(deviceName,deviceCode,orgName,linkman, page, pageSize);
            return write(200,"操作成功",page,pageSize,wlyyDevices);
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    //设备型号列表
    @RequestMapping(value = "modelList",method = RequestMethod.POST)
    @ResponseBody
    public String findAll(){
        try{
            List<DmDevice> list = dmDeviceService.findAll();
            return  write(200,"操作成功","data",list);
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "device")
    @ResponseBody
    public String getDevice(@RequestParam(value = "id") Long id){
        try {
            WlyyDevice device = deviceService.findById(id);
            return  write(200,"操作成功","data",device);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "create")
    @ResponseBody
    public String createDevice(String jsonData){
        try{
            WlyyDevice device = objectMapper.readValue(jsonData, WlyyDevice.class);
            WlyyDevice deviceNew = deviceService.createDevice(device);
            return write(200,"操作成功","data",deviceNew);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "update")
    @ResponseBody
    public String updateDevice(String jsonData){
        try{
            WlyyDevice device = objectMapper.readValue(jsonData, WlyyDevice.class);
            WlyyDevice deviceNew = deviceService.updateDevice(device);
            return write(200,"操作成功","data",deviceNew);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "updateStatus")
    @ResponseBody
    public String updateStatus(String jsonData){
        try{
            WlyyDevice device = objectMapper.readValue(jsonData, WlyyDevice.class);
            WlyyDevice deviceNew = deviceService.updateDevice(device);
            return write(200,"操作成功","data",deviceNew);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deleteDevice(Long id){
        try{
            deviceService.deleteDevice(id);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "isCodeExist")
    @ResponseBody
    public String isCodeExist(String deviceCode) {
        return deviceService.existDeviceCode(deviceCode);
    }
    
    //导出设备报表
    @RequestMapping(value="toExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public void exportList(
            @RequestParam(value = "deviceName",required = false)String deviceName,
            @RequestParam(value = "deviceCode",required = false) String deviceCode,
            @RequestParam(value = "orgName",required = false)String orgName,
            @RequestParam(value = "linkman",required = false) String linkman,
            HttpServletResponse response){
        try {
            List<WlyyDevice> wlyyDevices = deviceService.exporthDeviceList(deviceName,deviceCode,orgName,linkman);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "deviceDataList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os,wlyyDevices);
        }catch (Exception ex){
            error(ex);
        }
    }
    //导入设备报表
    @RequestMapping(value = "importData", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(HttpServletRequest request) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = request.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            deviceService.importData(workbook);
            return write(200, "操作成功");
        } catch (IOException | BiffException e) {
            e.printStackTrace();
            error(e);
            return error(-1, "操作失败!");
        }
    }
    public void addHeader(WritableSheet ws) throws WriteException {
        
        String[] header = {"ID","设备名称","型号","SN码", "SIM卡号","机构名称", "联系人", "联系电话", "厂家名称"};
        int i = 0;
        for (String h : header) {
            addCell(ws, 0, i, h);//表名,行,列,header
            i++;
        }
    }
    
    public void write(WritableWorkbook wwb, List ls) throws Exception {
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet",1);
            addHeader(ws);
            int i = 1;
            for (WlyyDevice m : (List<WlyyDevice>) ls) {
                addCell(ws, i, 0, m.getId()+"","");
                addCell(ws, i, 1, m.getDeviceName(),"");
                addCell(ws, i, 2, m.getDeviceModel(),"");
                addCell(ws, i, 3, m.getDeviceCode(),"");
                addCell(ws, i, 4, m.getSim()+"","");
                addCell(ws, i, 5, m.getOrgName(),"");
                addCell(ws, i, 6, m.getLinkman(),"");
                addCell(ws, i, 7, m.getTel(),"");
                addCell(ws, i, 8, m.getManufacturer(),"");
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void write(OutputStream os, List ls) throws Exception{
        write(Workbook.createWorkbook(os), ls);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
        Label label = new Label(column ,row, data);
        ws.addCell(label);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
        Label label = new Label(column ,row, data);
        if(!org.springframework.util.StringUtils.isEmpty(memo)){
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        ws.addCell(label);
    }
    @RequestMapping(value = "register")
    @ResponseBody
    public String register(@RequestParam(value = "deviceSn") String deviceSn){
        try {
            patientDeviceService.checkDeviceSn(deviceSn);
            return  write(200,"操作成功!");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 210 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/device/WlyyPatientDeviceController.java

@ -0,0 +1,210 @@
package  com.yihu.customer.controller.manager.device;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.device.entity.PatientDeviceExportVO;
import  com.yihu.customer.device.entity.WlyyPatientDeviceVO;
import  com.yihu.customer.entity.Doctor;
import  com.yihu.customer.entity.WlyyPatientDevice;
import com.yihu.customer.service.doctor.DoctorService;
import com.yihu.customer.service.manager.device.WlyyDeviceService;
import com.yihu.customer.service.manager.device.WlyyPatientDeviceLogService;
import com.yihu.customer.service.manager.device.WlyyPatientDeviceService;
import  com.yihu.customer.repository.WlyyPatientDeviceDao;
import jxl.Workbook;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
/**
 * Created by yww on 2016/12/7.
 */
@Controller
@RequestMapping("admin/patientDevice")
public class WlyyPatientDeviceController extends BaseController {
    @Autowired
    private WlyyPatientDeviceService patientDeviceService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private WlyyDeviceService wlyyDeviceService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyyPatientDeviceLogService wlyyPatientDeviceLogService;
    @Autowired
    private WlyyPatientDeviceDao wlyyPatientDeviceDao;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String listPageInit(){
        
        return "device/patientDevice_list";
    }
    @RequestMapping(value = "list",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @RequestParam(value = "deviceName",required = false) String deviceName,
            @RequestParam(value = "categoryCode",required = false) String categoryCode,
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "hospitalName",required = false) String hospitalName,
            @RequestParam(value = "page") Integer page,
            @RequestParam(value = "rows") Integer pageSize,
            HttpServletRequest req, HttpServletResponse resp){
        try {
    
            String currentid = req.getSession().getAttribute("code").toString();
    
            System.out.println("doctorid:"+currentid);
            
            Doctor doctor = doctorService.findDoctorByCode(currentid);
    
            String hospitalCode = "";
    
            if(doctor != null){
                System.out.println("doctor-hospitalCode:"+doctor.getHospital());
                hospitalCode = doctor.getHospital();
            }
            
            List<WlyyPatientDeviceVO> patientDevices = patientDeviceService.searchListNew(deviceName,categoryCode, deviceSn, userName, doctorName,hospitalName,hospitalCode,page, pageSize);
            Long totalcount = patientDeviceService.getCountSearchListNew(deviceName,categoryCode, deviceSn, userName, doctorName,hospitalName,hospitalCode);
            return write(200,"操作成功",page,pageSize,totalcount,patientDevices);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    
    @RequestMapping(value = "listbak",method = RequestMethod.POST)
    @ResponseBody
    public String searchListbak(
            @RequestParam(value = "deviceName",required = false) String deviceName,
            @RequestParam(value = "categoryCode",required = false) String categoryCode,
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "hospital",required = false) String hospital,
            @RequestParam(value = "page") Integer page,
            @RequestParam(value = "rows") Integer pageSize){
        try {
            Page<WlyyPatientDevice> patientDevices = patientDeviceService.searchList(deviceName,categoryCode, deviceSn, userName, page, pageSize);
            return write(200,"操作成功",page,pageSize,patientDevices);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
        
    }
    //设备解绑(记录删除)
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deletePatientDevice(@RequestParam(value = "id") Integer id){
        try {
            if(id == null){
                return write(-1,"id不能为空!");
            }
            WlyyPatientDevice wlyyPatientDevice = wlyyPatientDeviceDao.findById(id).get();
            patientDeviceService.delete(id);
            String deviceSn = "";
            if (wlyyPatientDevice!=null){
                deviceSn = wlyyPatientDevice.getDeviceSn();
            }
            //全部解绑后去判断就更新设备表中是否绑定字段.
            wlyyDeviceService.unBindUpdateIsBinding(deviceSn);
            wlyyPatientDeviceLogService.savePatientDeviceLog(wlyyPatientDevice,deviceSn,3,2);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    
    //导出报表
    @RequestMapping(value="toExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public void exportList(
            @RequestParam(value = "town",required = false)String town,
            @RequestParam(value = "hospital",required = false)String hospital,
            HttpServletResponse response){
        try {
            List<PatientDeviceExportVO> wlyyDevices = patientDeviceService.exportPatientDeviceList(town,hospital);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "patientDeviceDataList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os,wlyyDevices);
        }catch (Exception ex){
            error(ex);
        }
    }
    
    
    public void addHeader(WritableSheet ws) throws WriteException {
        
        String[] header = {"居民姓名","手机号","身份证","设备码", "设备类型","签约医生", "居民住址", "openid", "是否绑定微信号"};
        int i = 0;
        for (String h : header) {
            addCell(ws, 0, i, h);//表名,行,列,header
            i++;
        }
    }
    
    public void write(WritableWorkbook wwb, List ls) throws Exception {
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet",1);
            addHeader(ws);
            int i = 1;
            for (PatientDeviceExportVO m : (List<PatientDeviceExportVO>) ls) {
                addCell(ws, i, 0, m.getName(),"");
                addCell(ws, i, 1, m.getMobile(),"");
                addCell(ws, i, 2, m.getIdcard(),"");
                addCell(ws, i, 3, m.getDevice_sn(),"");
                addCell(ws, i, 4, m.getDevice_name(),"");
                addCell(ws, i, 5, m.getDoctor_name(),"");
                addCell(ws, i, 6, m.getAddress(),"");
                addCell(ws, i, 7, m.getOpenid(),"");
                addCell(ws, i, 8, m.getIsopenid(),"");
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void write(OutputStream os, List ls) throws Exception{
        write(Workbook.createWorkbook(os), ls);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
        Label label = new Label(column ,row, data);
        ws.addCell(label);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
        Label label = new Label(column ,row, data);
        if(!org.springframework.util.StringUtils.isEmpty(memo)){
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        ws.addCell(label);
    }
}

+ 312 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/dict/ManageDictController.java

@ -0,0 +1,312 @@
package  com.yihu.customer.controller.manager.dict;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.ManageDict;
import  com.yihu.customer.entity.twoCancers.BreastCervicalAddress;
import com.yihu.customer.service.manager.dict.ManageDictService;
import com.yihu.customer.service.manager.twoCancers.TwoCancersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2017/1/24.
 */
@Controller
@RequestMapping(value = "/admin/dict")
@Api(value = "dict", description = "系统全局字典管理", tags = {"系统字典"})
public class ManageDictController extends BaseController {
    @Autowired
    ManageDictService dictService;
    @Autowired
    TwoCancersService twoCancersService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String listPageInit() {
        return "dict/manageDict";
    }
    @ApiOperation(value = "获取字典列表")
    @RequestMapping(value = "/dictList")
    @ResponseBody
    public String getDictionaries(
            @RequestParam(value = "searchNm", required = false) String searchNm,
            @RequestParam(value = "page", required = false) int page,
            @RequestParam(value = "rows", required = false) int pageSize) {
        if (page <= 0) {
            page = 1;
        }
        if (pageSize <= 0) {
            page = 15;
        }
        PageRequest pageRequest = PageRequest.of(page - 1, pageSize);
        String filters = "";
        if (!StringUtils.isEmpty(searchNm)) {
            filters = "name?" + searchNm;
        }
        try {
            List list = dictService.search("", filters, "", page, pageSize);
            long count = dictService.getCount(filters);
            PageImpl<ManageDict> manageDicts = new PageImpl<ManageDict>(list, pageRequest, count);
            return write(200, "", page, pageSize, manageDicts);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "系统错误");
        }
    }
    @ApiOperation(value = "创建字典")
    @RequestMapping(value = "/create")
    @ResponseBody
    public String createDictionary(
            @ApiParam(name = "name", value = "新增字典名称")
            @RequestParam(value = "name") String name,
            @ApiParam(name = "reference", value = "字典简介", defaultValue = "")
            @RequestParam(value = "reference", required = false) String reference) throws Exception {
        try {
            if (StringUtils.isEmpty(name)) {
                return error(-1, "新增字段名称不能为空!");
            }
            ManageDict dict = new ManageDict();
            dict.setName(name);
            dict.setPhoneticCode(name);
            dict.setReference(reference);
            dict.setAuthorId("wwcs");
            dict.setCreateDate(new Date());
            ManageDict systemDict = dictService.createDict(dict);
            return write(200, "操作成功");
        } catch (Exception ex) {
            error(ex);
            return write(-1, "操作失败!");
        }
    }
    @ApiOperation(value = "获取字典")
    @RequestMapping(value = "/dict")
    @ResponseBody
    public String getDictionary(
            @ApiParam(name = "id", value = "字典ID", defaultValue = "")
            @PathVariable(value = "id") long id) {
        ManageDict dict = dictService.retrieve(id);
        if (dict == null) {
            return write(-1, "字典不存在!");
        }
        return write(200, "操作成功", "data", dict);
    }
    @ApiOperation(value = "更新字典")
    @RequestMapping(value = "/update")
    @ResponseBody
    public String updateDictionary(
            @ApiParam(name = "dictId", value = "字典id")
            @RequestParam(value = "dictId", required = true) long dictId,
            @ApiParam(name = "name", value = "新增字典名称")
            @RequestParam(value = "name", required = true) String name,
            @ApiParam(name = "reference", value = "字典简介", defaultValue = "")
            @RequestParam(value = "reference", required = false) String reference) {
        ManageDict dict = dictService.retrieve(dictId);
        if (dict == null) {
            return error(-1, "字典不存在!");
        }
        if (StringUtils.isEmpty(name)) {
            return error(-1, "字典名称不能为空");
        }
        try {
            dict.setName(name);
            dictService.updateDict(dict);
            return write(200, "操作成功!");
        } catch (Exception ex) {
            error(ex);
            return write(-1, "操作失败!");
        }
    }
    @ApiOperation(value = "删除字典")
    @RequestMapping(value = "/delete")
    @ResponseBody
    public String deleteDictionary(
            @ApiParam(name = "dictId", value = "字典ID", defaultValue = "")
            @RequestParam(value = "dictId") long id) {
        try {
            dictService.deleteDict(id);
            return write(200, "操场成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "/isNameExist")
    @ApiOperation(value = "判断提交的字典名称是否已经存在")
    @ResponseBody
    public String isDictNameExists(
            @ApiParam(name = "name", value = "name", defaultValue = "")
            @RequestParam(value = "name") String name) {
        boolean res = dictService.isDictNameExists(name);
        if (res) {
            return error(-1, "字典名称已存在!");
        }
        return write(200, "字典名称不存在!");
    }
    @RequestMapping(value = "/syncZyReservationOrgAndDept",method = RequestMethod.GET)
    @ApiOperation(value = "数据同步-同步医生科室")
    @ResponseBody
    public String syncZyReservationOrgAndDept() {
        boolean res = dictService.syncZyReservationOrgAndDept();
        if (res) {
            return error(200, "操作成功!");
        }
        return write(-1, "操作失败!");
    }
    @RequestMapping(value = "/syncZyReservationOrgAndDept/initial",method = RequestMethod.GET)
    public String syncZyReservationOrgAndDepInitialt() {
        return "dict/zyReservationDeptAndOrg";
    }
    @RequestMapping(value = "/delTwoCancersAddress",method = RequestMethod.POST)
    @ApiOperation(value = "两癌-删除筛查地址")
    @ResponseBody
    public String delTwoCancersAddress(@RequestParam(value = "id")Integer id){
        try {
            twoCancersService.delTwoCancersAddress(id);
            return write(200,"操作成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "/saveTwoCancersAddress",method = RequestMethod.POST)
    @ApiOperation(value = "两癌-保存筛查地址")
    @ResponseBody
    public String saveTwoCancersAddress(String jsonData){
        try {
            Integer result = twoCancersService.saveTwoCancersAddress(jsonData);
            if (result>0){
               return write(200,"操作成功!");
            }else {
               return error(-2,"该机构已存在!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "/findHospitalList",method = RequestMethod.POST)
    @ApiOperation(value = "两癌-获取医院机构")
    @ResponseBody
    public String findHospitalList(){
        try {
            List<Map<String, Object>> result = twoCancersService.findHospitalList();
            return write(200,"操作成功!","data",result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "/findTwoCancersAddressList",method = RequestMethod.GET)
    @ApiOperation(value = "两癌-获取列表")
    @ResponseBody
    public String findTwoCancersAddressList(@RequestParam(value = "page",required = false)Integer page,
                      @RequestParam(value = "rows")Integer rows,
                      @RequestParam(value = "hospitalName",required = false)String hospitalName){
        try {
            Page<BreastCervicalAddress> list = twoCancersService.findTwoCancersAddressList(page,rows,hospitalName);
            return write(200, "查询成功", page, rows, list);
        } catch (Exception e) {
            e.printStackTrace();
            return  error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "/twoCancers/initial",method = RequestMethod.GET)
    public String listInit(){
        return "dict/twoCancersAddress_list";
    }
    //编辑页面
    @RequestMapping(value = "twoCancers/updateInit/{id}", method = RequestMethod.GET)
    public String update(@PathVariable("id") Long id) {
        try {
            request.setAttribute("id", id);
            request.setAttribute("type", request.getParameter("type"));
        } catch (Exception e) {
            error(e);
        }
        return "dict/twoCancersAddress_edit";
    }
    @RequestMapping(value = "twoCancers/getHospital", method = RequestMethod.GET)
    @ResponseBody
    public String getTwoCancerHospitalList(){
        try {
            return write(200,"操作成功","list",twoCancersService.getTwoCancerHospitalList());
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询机构失败");
        }
    }
    @RequestMapping(value = "twoCancers/getAddressOne", method = RequestMethod.GET)
    @ResponseBody
    public String getTwoCancerAddressOne(@RequestParam(value = "id")String id){
        try {
            List<BreastCervicalAddress> list = twoCancersService.getTwoCancerAddressOne(id);
            if (list.size()>0){
                return write(200,"操作成功","data",list.get(0));
            }else {
                return error(-1,"未获取到该条记录");
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询机构失败");
        }
    }
    @RequestMapping(value = "twoCancersCount/initial", method = RequestMethod.GET)
    public String initListPage() {
        return "static/two_cancers_count";
    }
    @RequestMapping(value = "twoCancers/findTwoCancerCouCount", method = RequestMethod.GET)
    @ResponseBody
    public String findTwoCancerCouCount(@RequestParam(value = "startTime")String startTime,
                                        @RequestParam(value = "endTime")String endTime){
        try {
            JSONObject twoCancerCouCount = twoCancersService.findTwoCancerCouCount(startTime, endTime);
            return write(200,"成功","data",twoCancerCouCount);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
}

+ 192 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/dict/ManageDictEntryController.java

@ -0,0 +1,192 @@
package  com.yihu.customer.controller.manager.dict;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.DictEntryKey;
import  com.yihu.customer.entity.ManageDictEntry;
import com.yihu.customer.service.manager.dict.ManageDictEntryService;
import com.yihu.customer.service.manager.dict.ManageDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by Administrator on 2017/1/24.
 */
@Controller
@RequestMapping(value = "/admin/dictEntry")
@Api(value = "DictEntry", description = "系统全局字典项管理", tags = {"系统字典项"})
public class ManageDictEntryController extends BaseController {
    @Autowired
    ManageDictService dictService;
    @Autowired
    ManageDictEntryService dictEntryService;
    @Autowired
    ObjectMapper objectMapper;
    @ApiOperation(value = "获取字典项列表,分页")
    @RequestMapping(value = "/entryList")
    @ResponseBody
    public String getDictEntries(
            @RequestParam(value = "dictId", required = true) long dictId,
            @RequestParam(value = "page", required = false) int page,
            @RequestParam(value = "rows", required = false) int pageSize) {
        if (page <= 0) {
            page = 1;
        }
        if (pageSize <= 0) {
            page = 15;
        }
        PageRequest pageRequest = PageRequest.of(page - 1, pageSize);
        if (dictId <= 0) {
            return error(-1, "字典Id不能为空!");
        }
        String filters = "dictId=" + dictId;
        try {
            List list = dictEntryService.search("", filters, "", page, pageSize);
            long count = dictEntryService.getCount(filters);
            PageImpl<ManageDictEntry> manageDicts = new PageImpl<ManageDictEntry>(list, pageRequest, count);
            return write(200, "", page, pageSize, manageDicts);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "系统错误");
        }
    }
    @ApiOperation(value = "获取字典项列表,不分页")
    @RequestMapping(value = "/entryListForDDL")
    @ResponseBody
    public String searchDictEntriesNoPage(
            @RequestParam(value = "dictId", required = true) long dictId) {
        String filters = "dictId=" + dictId;
        try {
            List list = dictEntryService.search(filters);
            return write(200, "", "dictList", list);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "系统错误");
        }
    }
    @ApiOperation(value = "创建字典项")
    @RequestMapping(value = "/create")
    @ResponseBody
    public String createDictEntry(
            @RequestParam(value = "dictId", required = true) Long dictId,
            @RequestParam(value = "code", required = true) String code,
            @RequestParam(value = "value") String value,
            @RequestParam(value = "sort", required = false) Integer sort,
            @RequestParam(value = "catalog", required = false) String catalog) {
        if (dictId == null) {
            return error(-1, "字典Id不能为空");
        }
        if (StringUtils.isEmpty(code)) {
            return error(-1, "字典项编码不能为空");
        }
        if (StringUtils.isEmpty(value)) {
            return error(-1, "字典项值不能为空");
        }
        ManageDictEntry dictEntryModel = new ManageDictEntry();
        dictEntryModel.setDictId(dictId);
        dictEntryModel.setCode(code);
        dictEntryModel.setValue(value);
        dictEntryModel.setSort(sort);
        dictEntryModel.setCatalog(catalog);
//            if(Boolean.parseBoolean()){
//                return error(-1,"代码在该字典中已存在,请确认。");
//            }
        try {
            ManageDictEntry save = dictEntryService.save(dictEntryModel);
            return write(200, "操作成功!");
        } catch (Exception ex) {
            error(ex);
            return write(-1, "操作失败!");
        }
    }
    @ApiOperation(value = "获取字典项")
    @RequestMapping(value = "/dictEntry")
    @ResponseBody
    public String getDictEntry(
            @ApiParam(name = "dictId", value = "字典ID", defaultValue = "")
            @RequestParam(value = "dictId") long dictId,
            @ApiParam(name = "code", value = "字典项代码", defaultValue = "")
            @PathVariable(value = "code") String code) {
        ManageDictEntry manageDictEntry = dictEntryService.getDictEntry(dictId, code);
        return write(200, "操作成功!", "data", manageDictEntry);
    }
    @ApiOperation(value = "删除字典项")
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object deleteDictEntry(
            @ApiParam(name = "dictId", value = "字典ID", defaultValue = "")
            @RequestParam(value = "dictId") long dictId,
            @ApiParam(name = "code", value = "字典ID", defaultValue = "")
            @RequestParam(value = "code") String code) throws Exception {
        try {
            dictEntryService.deleteDictEntry(dictId, code);
            return write(200, "操场成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @ApiOperation(value = "修改字典项")
    @RequestMapping(value = "/update")
    @ResponseBody
    public String updateDictEntry(
            @RequestParam(value = "dictId", required = true) Long dictId,
            @RequestParam(value = "code", required = true) String code,
            @RequestParam(value = "value") String value,
            @RequestParam(value = "sort", required = false) Integer sort,
            @RequestParam(value = "catalog", required = false) String catalog) {
        if (dictId == null) {
            return error(-1, "字典id不能为空");
        }
        if (StringUtils.isEmpty(code)) {
            return error(-1, "字典项编码code不能为空");
        }
        ManageDictEntry dictEntryModel = dictEntryService.retrieve(new DictEntryKey(code, dictId));
        if (null == dictEntryModel) {
            return error(-1, "字典项不存在!");
        }
        dictEntryModel.setValue(value);
        dictEntryModel.setSort(sort);
        dictEntryModel.setCatalog(catalog);
//        if(Boolean.parseBoolean()){
//                return error(-1,"代码在该字典中已存在,请确认。");
//            }
        try {
            dictEntryService.saveDictEntry(dictEntryModel);
            return write(200, "操作成功!");
        } catch (Exception ex) {
            error(ex);
            return write(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "/isCodeExist")
    @ApiOperation(value = "根基dictId和code判断提交的字典项名称是否已经存在")
    @ResponseBody
    public boolean isDictEntryCodeExists(
            @ApiParam(name = "dictId", value = "dictId", defaultValue = "")
            @RequestParam(value = "dictId") long dictId,
            @ApiParam(name = "code", value = "code", defaultValue = "")
            @RequestParam(value = "code") String code) {
        return dictEntryService.isDictContainEntry(dictId, code);
    }
}

+ 111 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/dict/SystemDictController.java

@ -0,0 +1,111 @@
package  com.yihu.customer.controller.manager.dict;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.SpecialDisease;
import  com.yihu.customer.entity.SystemDict;
import com.yihu.customer.service.manager.dict.SystemDictService;
import  com.yihu.customer.repository.SpecialDiseaseDao;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
 * Created by Administrator on 2016/8/13.
 */
@Controller
@RequestMapping(value = "/common")
public class SystemDictController extends BaseController {
	@Autowired
	private SystemDictService systemDictService;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private SpecialDiseaseDao specialDiseaseDao;
	@ResponseBody
	@RequestMapping(value = "/getDictByDictName")
	public String getDictByDictName(String name){
		try {
			JSONArray ja=new JSONArray();
			if("ZB_TYPE".equals(name)){
				//十大专病
				List<SpecialDisease> list = specialDiseaseDao.findDisByDel("1");
				for (SpecialDisease specialDisease:list){
					JSONObject jo=new JSONObject();
					jo.put("value",specialDisease.getCode());
					jo.put("text",specialDisease.getName());
					ja.put(jo);
				}
			}else {
				List<SystemDict> list=systemDictService.getByDictName(name);
				for (SystemDict systemDict:list){
					JSONObject jo=new JSONObject();
					jo.put("value",systemDict.getCode());
					jo.put("text",systemDict.getValue());
					ja.put(jo);
				}
			}
			return write(200,"获取成功","list",ja);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取失败");
		}
	}
	@RequestMapping("/fileUpload")
	@ApiOperation("文件上传")
	public String handleFileUpload(@RequestParam("file") MultipartFile file
			,@RequestParam("token") String token) {
		if (file.isEmpty()) {
			return "文件为空";
		}
		if(StringUtils.isBlank(token)){
			return error(-1,"非法请求");
		}
		String sql = " select code from system_dict where dict_name ='fileUpload_token'  ";
		List<String> urls = jdbcTemplate.queryForList(sql,String.class);
		if(urls.size()==0){
			return error(-1,"非法请求");
		}
		if(!token.equals(urls.get(0))){
			return error(-1,"非法请求");
		}
		// 获取文件名
		String fileName = file.getOriginalFilename();
		System.out.println("上传的文件名为:" + fileName);
		// 获取文件的后缀名
		String suffixName = fileName.substring(fileName.lastIndexOf("."));
		System.out.println("上传的后缀名为:" + suffixName);
		// 文件上传后的路径
		String filePath = "/data/";
		File dest = new File(filePath + fileName);
		// 检测是否存在目录
		if (!dest.getParentFile().exists()) {
			dest.getParentFile().mkdirs();
		}
		try {
			file.transferTo(dest);
			return "上传成功";
		} catch (IllegalStateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "上传失败";
	}
}

+ 130 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/feedback/FeedbackController.java

@ -0,0 +1,130 @@
package  com.yihu.customer.controller.manager.feedback;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.feedback.Feedback;
import com.yihu.customer.service.manager.feedback.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
/**
 * Created by Reece on 2017/5/6.
 */
@Controller
@RequestMapping(value = "admin/feedback")
@Api(description = "管理系统意见反馈接口")
public class FeedbackController extends BaseController {
    @Autowired
    private FeedbackService feedbackService;
    //页面初始化数据
    @RequestMapping(value = "/initial", method = RequestMethod.GET)
    @ApiIgnore
    @ApiOperation(value = "意见反馈")
    public String initFeedback() {
        return "feedback/feedback_list";
    }
    /**
     * 初始化列表页
     * @param type 意见反馈的类别
     * @param identity 身份
     * @param status 状态
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "列表")
    public String list(
            @RequestParam(required = false,defaultValue = "-1") int type,
            @RequestParam(required = false,defaultValue = "-1") int identity,
            @RequestParam(required = false,defaultValue = "-1") int status,
            @RequestParam(value = "page",defaultValue = "1") int page,
            @RequestParam(value = "rows",defaultValue = "15") int rows) {
        try {
            Page<Feedback> res = feedbackService.findFeedback(page,rows,type,identity,status);
            return write(200, "操作成功", page, rows, res);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "/delfeedback")
    @ResponseBody
    @ApiOperation(value="批量删除")
    public String delfeedback(
            @RequestParam(required = true) String ids){
        try{
            feedbackService.delfeedback(ids);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "/showDetail", method = RequestMethod.GET)
    @ApiOperation(value = "跳转到意见详情页,并更改状态")
    public String infoInit(@RequestParam long id) {
        try {
            Map map = feedbackService.getFeedbackById(id);
            request.setAttribute("id",id);
            return "feedback/feeback_detail";
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    /**
     * 根据反馈ID查询反馈详情,并更改状态
     * @param id
     * @return
     */
    @RequestMapping(value = "getFeedbackById")
    @ResponseBody
    public String getFeedbackById(@RequestParam(value = "id") Long id) {
        try {
            Map feedback = feedbackService.getFeedbackById(id);
            return write(200, "操作成功!", "data", feedback);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 根据反馈id,回复内容result进行处理
     * @param id
     * @param result
     * @return
     */
    @RequestMapping(value="dealFeedback", method = RequestMethod.POST)
    @ResponseBody
    public String dealAppeal(@RequestParam(required = true,value="id") Long id,
                             @RequestParam(required = true,value="result") String result){
        try {
            Feedback feedback = feedbackService.dealFeedback(id,result);
            feedbackService.sendMsg(feedback);
            return write(200,"操作成功!");
        }catch (Exception e){
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 223 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/ActivityController.java

@ -0,0 +1,223 @@
package  com.yihu.customer.controller.manager.healthbank;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.healthbank.ActivityDO;
import com.yihu.customer.service.manager.healthbank.ActivityService;
import com.yihu.customer.util.fastdfs.FastDFSUtil;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
/**
 * Created by humingfen on 2018/6/19.
 * 健康活动管理
 */
@Controller
@RequestMapping(value = "admin/activity", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class ActivityController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(ActivityController.class);
    @Autowired
    private ActivityService activityService;
    @ApiParam
    FastDFSUtil fastDFSUtil;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initListPage(){
        return "healthbank/activity_list";
    }
    @RequestMapping(value = "infoInit")
    public String initInfoPage(@RequestParam(value = "id") String id,String type){
        request.setAttribute("id",id);
        request.setAttribute("type",type);
        return "healthbank/activity_modify";
    }
    @RequestMapping(value = "init")
    public String init(String type){
        request.setAttribute("type",type);
        return "healthbank/activity_modify";
    }
    @RequestMapping(value ="list",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @RequestParam(name = "activity") String activity,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            JSONObject jsonObject = activityService.searchList(activity, page, pageSize);
            String totalCount = String.valueOf(jsonObject.get("totalCount"));
            Long total = Long.parseLong(totalCount);
            return write(200,"操作成功",page,pageSize,total,(List<ActivityDO>)jsonObject.get("detailModelList"));
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "findById")
    @ResponseBody
    public String findById(@RequestParam(value = "id") String id){
        try {
            String activity = "{\"id\":\""+ id + "\"}";
            return  write(200,"操作成功","data",activityService.searchList(activity, 1, 1));
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "update")
    @ResponseBody
    public String update(String jsonData,
                         @RequestParam(value = "value1") String value1,
                         @RequestParam(value = "value2") String value2,
                         @RequestParam(value = "value3") String value3,
                         @RequestParam(value = "registrationNumber")String registrationNumber) {
        try {
            activityService.update(jsonData,value1,value2,value3,registrationNumber);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "create")
    @ResponseBody
    public String create(@RequestParam(value = "jsonData") String jsonData,
                         @RequestParam(value = "value1") String value1,
                         @RequestParam(value = "value2") String value2,
                         @RequestParam(value = "value3") String value3,
                         @RequestParam(value = "registrationNumber")String registrationNumber) {
        try {
            activityService.create(jsonData,value1,value2,value3,registrationNumber);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "upload", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String upload(@RequestParam(value = "file") MultipartFile file, HttpServletRequest request) throws Exception {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
        String tempPaths = null;
        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
            MultipartFile mf = entity.getValue();
            InputStream inputStream  = mf.getInputStream();
            String fileName = mf.getOriginalFilename();
            //文件后缀
            String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
            //文件名称
            String newFileName = mf.getOriginalFilename().substring(0,mf.getOriginalFilename().lastIndexOf("."));
            //上传到fastdfs
            ObjectNode imgNode = fastDFSUtil.upload(inputStream, fileExt, newFileName);
            com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(imgNode.toString());
            tempPaths = json.getString("fid");
        }
        JSONObject json = new JSONObject();
        json.put("status", 200);
        json.put("msg", "上传成功");
        // 图片标识对象的HTTP链接
        json.put("urls", tempPaths);
        return json.toString();
    }
    @RequestMapping(value = "delete")
    @ResponseBody
    public String delete(@RequestParam(value = "id") String id) {
        try {
            String[] ids = {id};
            String s = JSONArray.fromObject(ids).toString();
            activityService.delete(s);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "deleteById")
    @ResponseBody
    public String deleteById(@RequestParam(value = "id") String id) {
        try {
            activityService.deleteById(id);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "editActivity")
    @ResponseBody
    public String editActivity(@RequestParam(value = "id") String id,
                               @ApiParam(name = "type",value = "操作类型:上线:0,下线:2,推荐:3")
                               @RequestParam(value = "type") String type) {
        try {
            return write(200, "操作成功","data",activityService.editActivity(id,type) );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "findActivityById")
    @ResponseBody
    public String findActivityById(@RequestParam(value = "id") String id) {
        try {
            return write(200, "操作成功" ,"data",activityService.findActivityById(id));
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value ="page",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @ApiParam(name = "status", value = "活动状态:1上线,2下线")
            @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "crowdType", value = "人群类型:1:签约居民、2平台用户")
            @RequestParam(value = "crowdType", required = false) Integer crowdType,
            @ApiParam(name = "releaseTime", value = "上线时间")
            @RequestParam(value = "releaseTime", required = false) String releaseTime,
            @ApiParam(name = "activityOfflineTime", value = "下线时间")
            @RequestParam(value = "activityOfflineTime", required = false) String activityOfflineTime,
            @ApiParam(name = "filter", value = "活动名、发布机构、面向范围名称")
            @RequestParam(value = "filter", required = false) String filter,
            @ApiParam(name = "page", value = "第几页,从1开始")
            @RequestParam(value = "page", defaultValue = "1", required = false) Integer page,
            @ApiParam(name = "size", defaultValue = "10", value = ",每页分页大小")
            @RequestParam(value = "size", required = false) Integer size){
        try{
            JSONObject jsonObject = activityService.pageActivity(status, crowdType, releaseTime,activityOfflineTime,filter,page,size);
            return write(200,"操作成功","data",jsonObject);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 161 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/HealthPlanController.java

@ -0,0 +1,161 @@
package  com.yihu.customer.controller.manager.healthbank;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.health.HealthPlan;
import com.yihu.customer.service.health.HealthPlanService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * Created by wzn54 on 2019/1/3.
 */
@Controller
@RequestMapping("admin/healthPlan")
@Api(value = "healthPlan", description = "健康计划", tags = {"健康计划"})
public class HealthPlanController extends BaseController {
    @Autowired
    private HealthPlanService planService;
    @Autowired
    private ObjectMapper objectMapper;
    /**
     * 创建计划
     * @param plan
     * @param planTask
     * @return
     */
    @RequestMapping(value ="create",method = RequestMethod.POST)
    @ResponseBody
    public String create(
            @RequestParam(name = "plan") String plan,
            @RequestParam(value = "planTask",required = true) String planTask){
        try{
            JSONArray array  = JSONArray.parseArray(planTask);
            HealthPlan healthPlan = objectMapper.readValue(plan,HealthPlan.class);
            planService.create(healthPlan,array);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    /**
     * 查询列表
     *
     * @param templateName
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value ="select",method = RequestMethod.POST)
    @ResponseBody
    public String select(
            @RequestParam(name = "templateName",required = false) String templateName,
            @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
            @RequestParam(value = "size", required = false)Integer size){
        try{
            return write(200,"查询成功","data",planService.select(templateName,page,size));
        }catch (Exception ex){
            error(ex);
            return error(-1,"查询失败!");
        }
    }
    /**
     * 删除计划任务
     *
     * @param code
     * @return
     */
    @RequestMapping(value ="deleteByCode",method = RequestMethod.POST)
    @ResponseBody
    public String deleteByCode(
            @RequestParam(name = "code",required = true) String code){
        try{
            planService.deleteByCode(code);
            return write(200,"查询成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"查询失败!");
        }
    }
    /**
     * 编辑计划状态
     *
     * @param code
     * @param status
     * @return
     */
    @RequestMapping(value ="updateStatusByCode",method = RequestMethod.POST)
    @ResponseBody
    public String updateStatusByCode(
            @RequestParam(name = "code",required = true) String code,
            @RequestParam(name = "status",required = true)Integer status){
        try{
            planService.updateStatusByCode(code,status);
            return write(200,"查询成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"查询失败!");
        }
    }
    /**
     * 编辑计划任务
     *
     * @param plan
     * @param planTask
     * @return
     */
    @RequestMapping(value ="update",method = RequestMethod.POST)
    @ResponseBody
    public String update(
            @RequestParam(name = "plan") String plan,
            @RequestParam(value = "planTask",required = true) String planTask){
        try{
            JSONArray array  = JSONArray.parseArray(planTask);
            HealthPlan healthPlan = objectMapper.readValue(plan,HealthPlan.class);
            planService.update(healthPlan,array);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    /**
     * 根据code获取计划任务详情
     *
     * @param code
     * @return
     */
    @RequestMapping(value ="selectByCode",method = RequestMethod.POST)
    @ResponseBody
    public String selectByCode(
            @RequestParam(name = "code",required = true) String code){
        try{
            return write(200,"查询成功","data",planService.selectByCode(code));
        }catch (Exception ex){
            error(ex);
            return error(-1,"查询失败!");
        }
    }
}

+ 173 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/HealthtaskController.java

@ -0,0 +1,173 @@
package  com.yihu.customer.controller.manager.healthbank;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.health.HealthTask;
import  com.yihu.customer.entity.health.HealthTaskQuestion;
import com.yihu.customer.service.health.HeathTaskService;
import io.swagger.annotations.Api;
import jxl.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.util.List;
/**
 * Created by wzn54 on 2019/1/3.
 */
@Controller
@RequestMapping("admin/healthTask")
@Api(value = "healthTask", description = "健康任务", tags = {"健康任务"})
public class HealthtaskController extends BaseController {
    @Autowired
    private HeathTaskService taskService;
    @Autowired
    private ObjectMapper objectMapper;
    /**
     * 创建健康任务
     *
     * @param task
     * @param question
     * @return
     */
    @RequestMapping(value ="create",method = RequestMethod.POST)
    @ResponseBody
    public String create(
            @RequestParam(name = "task") String task,
            @RequestParam(value = "question",required = true) String question){
        try{
            JSONArray array  = JSONArray.parseArray(question);
            HealthTask healthTask = objectMapper.readValue(task,HealthTask.class);
            taskService.create(healthTask,array);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    /**
     * 删除健康任务
     *
     * @param code
     * @return
     */
    @RequestMapping(value ="delete",method = RequestMethod.POST)
    @ResponseBody
    public String delete(@RequestParam(name = "code") String code){
        try{
            taskService.delete(code);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value ="selectByCode",method = RequestMethod.POST)
    @ResponseBody
    public String selectByCode(@RequestParam(name = "code") String code){
        try{
            return write(200,"操作成功","data",taskService.selectByCode(code));
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    /**
     * 根据code修改任务状态
     *
     * @param code
     * @return
     */
    @RequestMapping(value ="updateStatusByCode",method = RequestMethod.POST)
    @ResponseBody
    public String updateStatusByCode(@RequestParam(name = "code") String code,
                                     @RequestParam(name = "status") Integer status){
        try{
            taskService.updateStatusByCode(code,status);
            return write(200,"查询成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"查询失败!");
        }
    }
    /**
     * 获取健康任务列表
     *
     * @param name
     * @param type
     * @param status
     * @return
     */
    @RequestMapping(value ="select",method = RequestMethod.POST)
    @ResponseBody
    public String select(@RequestParam(name = "name",required = false) String name,
                         @RequestParam(name = "type",required = false) Integer type,
                         @RequestParam(name = "status",required = false) Integer status,
                         @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                         @RequestParam(value = "size", required = false)Integer size){
        try{
            return write(200,"查询成功","data",taskService.select(type,status,name,page,size));
        }catch (Exception ex){
            error(ex);
            return error(-1,"查询失败!");
        }
    }
    /**
     * 编辑健康任务
     *
     * @param task
     * @param question
     * @return
     */
    @RequestMapping(value ="update",method = RequestMethod.POST)
    @ResponseBody
    public String update(
            @RequestParam(name = "task",required = true) String task,
            @RequestParam(value = "question",required = true) String question){
        try{
            JSONArray array  = JSONArray.parseArray(question);
            HealthTask healthTask = objectMapper.readValue(task,HealthTask.class);
            taskService.update(healthTask,array);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //导入健康任务-问题
    @RequestMapping(value = "importData", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(@RequestParam(name = "file") MultipartFile file) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = file.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            List<HealthTaskQuestion> healthTaskQuestions= taskService.importData(workbook);
            return write(200, "操作成功","data",healthTaskQuestions);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 111 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/TaskController.java

@ -0,0 +1,111 @@
package  com.yihu.customer.controller.manager.healthbank;
import com.alibaba.fastjson.JSONObject;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.healthbank.TaskDO;
import com.yihu.customer.service.manager.healthbank.TaskService;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
 * Created by humingfen on 2018/6/21.
 * 健康任务管理
 */
@Controller
@RequestMapping("admin/task")
public class TaskController extends BaseController {
    @Autowired
    private TaskService taskService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initListPage(){
        return "healthbank/task_list";
    }
    @RequestMapping(value = "infoInit")
    public String initInfoPage(@RequestParam(value = "id") String id, String type){
        request.setAttribute("id",id);
        request.setAttribute("type",type);
        return "healthbank/task_modify";
    }
    @RequestMapping(value = "init")
    public String init(String type){
        request.setAttribute("type",type);
        return "healthbank/task_modify";
    }
    @RequestMapping(value ="list",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @RequestParam(name = "task") String task,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            JSONObject jsonObject = taskService.searchList(task, page, pageSize);
            String totalCount = String.valueOf(jsonObject.get("totalCount"));
            Long total = Long.parseLong(totalCount);
            return write(200,"操作成功",page,pageSize,total,(List<TaskDO>)jsonObject.get("detailModelList"));
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "findById")
    @ResponseBody
    public String findById(@RequestParam(value = "id") String id){
        try {
            String task = "{\"id\":\""+ id + "\"}";
            return  write(200,"操作成功","data",taskService.searchList(task, 1, 1));
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "update")
    @ResponseBody
    public String update(String jsonData) {
        try {
            taskService.update(jsonData);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "create")
    @ResponseBody
    public String create(String jsonData) {
        try {
            taskService.create(jsonData);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "delete")
    @ResponseBody
    public String delete(@RequestParam(value = "id") String id) {
        try {
            String[] ids = {id};
            String s = JSONArray.fromObject(ids).toString();
            taskService.delete(s);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 136 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthbank/TaskRuleController.java

@ -0,0 +1,136 @@
package  com.yihu.customer.controller.manager.healthbank;
import com.alibaba.fastjson.JSONObject;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.healthbank.TaskRuleDO;
import com.yihu.customer.service.manager.healthbank.TaskRuleService;
import net.sf.json.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
 * Created by humingfen on 2018/6/22.
 * 健康任务规则管理
 */
@Controller
@RequestMapping("admin/taskRule")
public class TaskRuleController extends BaseController {
    @Autowired
    private TaskRuleService taskRuleService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initListPage(){
        return "healthbank/taskRule_list";
    }
    @RequestMapping(value = "infoInit")
    public String initInfoPage(@RequestParam(value = "id") String id, String type){
        request.setAttribute("id",id);
        request.setAttribute("type",type);
        return "healthbank/taskRule_modify";
    }
    @RequestMapping(value = "init")
    public String init(String type){
        request.setAttribute("type",type);
        return "healthbank/taskRule_modify";
    }
    @RequestMapping(value ="list",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @RequestParam(value = "q", required = false) String name,
            @RequestParam(name = "taskRule") String taskRule,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            if(StringUtils.isNotBlank(name)){
                taskRule = taskRule.replace("}",",\"name\":"+name+"}");
            }
            JSONObject jsonObject = taskRuleService.searchList(taskRule, page, pageSize);
            String totalCount = String.valueOf(jsonObject.get("totalCount"));
            Long total = Long.parseLong(totalCount);
            return write(200,"操作成功",page,pageSize,total,(List<TaskRuleDO>)jsonObject.get("detailModelList"));
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value ="list",method = RequestMethod.GET)
    @ResponseBody
    public String list(
            @RequestParam(value = "q", required = false) String name,
            @RequestParam(name = "taskRule") String taskRule,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            taskRule = "{" + taskRule + "}";
            if(StringUtils.isNotBlank(name)){
                taskRule = taskRule.replace("}",",\"name\":"+name+"}");
            }
            JSONObject jsonObject = taskRuleService.searchList(taskRule, page, pageSize);
            return write(200,"操作成功","detailModelList",jsonObject.get("detailModelList"));
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "findById")
    @ResponseBody
    public String findById(@RequestParam(value = "id") String id){
        try {
            String taskRule = "{\"id\":\""+ id + "\"}";
            return  write(200,"操作成功","data",taskRuleService.searchList(taskRule, 1, 1));
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "update")
    @ResponseBody
    public String update(String jsonData) {
        try {
            taskRuleService.update(jsonData);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "create")
    @ResponseBody
    public String create(String jsonData) {
        try {
            taskRuleService.create(jsonData);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "delete")
    @ResponseBody
    public String delete(@RequestParam(value = "id") String id) {
        try {
            String[] ids = {id};
            String s = JSONArray.fromObject(ids).toString();
            taskRuleService.delete(s);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 149 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthchannel/ChannelController.java

@ -0,0 +1,149 @@
package  com.yihu.customer.controller.manager.healthchannel;
import  com.yihu.customer.controller.WeixinBaseController;
import  com.yihu.customer.entity.healthchannel.HealthChannelDo;
import com.yihu.customer.service.manager.healthchannel.ChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/admin/channel",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "健康频道")
public class ChannelController extends WeixinBaseController {
    @Autowired
    private ChannelService channelService;
    @RequestMapping(value = "list", method = RequestMethod.GET)
    @ApiOperation(value = "获取健康频道分类层级列表")
    @ResponseBody
    public String list(
            @ApiParam(name = "level", value = "分类层级:0频道,1推荐栏目分类,2置顶栏目分类", required = true)
            @RequestParam(value = "level", required = false) String level,
            @ApiParam(name = "classification", value = "上级分类id", required = false)
            @RequestParam(value = "classification", required = false) String classification) {
        try {
            List<Map<String,Object>> healthChannelDos = channelService.searchList(level,classification);
            return write(200, "获取成功", "data",healthChannelDos);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "create", method = RequestMethod.POST)
    @ApiOperation(value = "创建频道分类")
    @ResponseBody
    public String create(
            @ApiParam(name = "jsonData", value = "频道分类:{\"name\":\"健康专栏\",\"code\":\"health_column\",\"classification\":\"4\",\"classificationName\":\"健康专栏\",\"level\":\"1\"}", required = true)
            @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            HealthChannelDo healthChannelDo=channelService.create(jsonData, "system");
            return write(200, "创建成功","data",healthChannelDo);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "创建失败");
        }
    }
    @RequestMapping(value = "getChannelList", method = RequestMethod.GET)
    @ApiOperation(value = "获取健康频道列表")
    @ResponseBody
    public String getChannelList(@ApiParam(name = "page",value = "当前页",defaultValue = "1")
                                     @RequestParam(value = "page", required = false) Integer page,
                                 @ApiParam(name = "pageSize",value = "分页大小",defaultValue = "10")
                                     @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            Map<String,Object> healthChannelDos = channelService.getChannelList(page, pageSize);
            return write(200, "获取成功", "data",healthChannelDos);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "createChannel", method = RequestMethod.POST)
    @ApiOperation(value = "创建编辑频道")
    @ResponseBody
    public String createChannel(
            @ApiParam(name = "jsonData", value = "频道信息", required = true)
            @RequestParam(value = "jsonData", required = true) String jsonData,
            @ApiParam(name = "userCode", value = "用户code")
            @RequestParam(value = "userCode") String userCode,
            HttpServletRequest req) {
        try {
            if (StringUtils.isBlank(userCode)) {
                userCode = String.valueOf(req.getSession().getAttribute("code"));
            }
            return write(200, "创建成功", "data", channelService.createChannel(jsonData, userCode));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "创建失败");
        }
    }
    @RequestMapping(value = "updateDelFlagById", method = RequestMethod.POST)
    @ApiOperation(value = "更新生效或者失效状态")
    @ResponseBody
    public String updateDelFlagById(
            @ApiParam(name = "channelId", value = "频道id", required = true)
            @RequestParam(value = "channelId") Long channelId,
            @ApiParam(name = "delFlag", value = "是否有效:0失效,1生效", required = true)
            @RequestParam(value = "delFlag") Integer delFlag) {
        try {
            channelService.updateDelFlagById(channelId, delFlag);
            return write(200, "更新成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "更新失败");
        }
    }
    @RequestMapping(value = "getRecommendCategoryByChannelId", method = RequestMethod.GET)
    @ApiOperation(value = "根据频道获取推荐或置顶栏目及类别")
    @ResponseBody
    public String getRecommendCategory(
            @ApiParam(name = "channelId", value = "频道id", required = true)
            @RequestParam(value = "channelId") Long channelId,
            @ApiParam(name = "level", value = "分类层级:0频道,1推荐栏目,2文章置顶栏目", required = true)
            @RequestParam(value = "level") String level,
            @ApiParam(name = "code", value = "内容类型code,健康文章传health_article,精选问答是selected_questions_and_answers," +
                    "平台咨讯platform_information,健康专栏health_column")
            @RequestParam(value = "code",required = false) String code) {
        try {
            return write(200, "获取成功", "data", channelService.getCategoryByCode(channelId + "", level, code));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "getChannelById", method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取频道信息")
    @ResponseBody
    public String getChannelById(
            @ApiParam(name = "channelId", value = "频道id", required = true)
            @RequestParam(value = "channelId") Long channelId) {
        try {
            return write(200, "获取成功", "data", channelService.getChannelById(channelId));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败");
        }
    }
}

+ 279 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/healthchannel/ChannelRecommendArticleController.java

@ -0,0 +1,279 @@
/*
package com.yihu.jw.controller.manager.healthchannel;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.entity.Doctor;
import com.yihu.jw.entity.healthchannel.HealthChannelRecommendArticleDo;
import com.yihu.jw.service.doctor.DoctorService;
import com.yihu.jw.service.manager.healthchannel.ChannelRecommendArticleService;
import com.yihu.jw.service.manager.healthcolumn.PeriodicalService;
import com.yihu.jw.service.manager.platformInformation.PlatformInformationService;
import com.yihu.jw.service.refinement.RefinementService;
import com.yihu.jw.util.Constant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
*/
/**
 * Created by zdm on 2019/2/15.
 *//*
@Controller
@RequestMapping(value = "/admin/channel/channelRecommendArticle",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "健康频道-文章推荐/置顶")
public class ChannelRecommendArticleController extends BaseController {
    private static Logger logger = LoggerFactory.getLogger(ChannelRecommendArticleController.class);
    @Autowired
    private ChannelRecommendArticleService channelRecommendArticleService;
    @Autowired
    private PlatformInformationService platformInformationService;
    @Autowired
    private PeriodicalService periodicalService;
    @Autowired
    private RefinementService refinementService;
    @Autowired
    private DoctorService doctorService;
    @RequestMapping(value = "recommend/list", method = RequestMethod.GET)
    @ApiOperation(value = "获取健康频道-推荐文章列表")
    @ResponseBody
    public String list(
            @ApiParam(name = "channelId", value = "频道id", required = true)
            @RequestParam(value = "channelId", required = false) Integer channelId) {
        try {
            String filters="type=1;delFlag=1;channelId="+channelId;
            List<HealthChannelRecommendArticleDo> healthChannelRecommendArticleDos = channelRecommendArticleService.search(null,filters,"+articleType,+sort",1,20);
            Map<String,List<HealthChannelRecommendArticleDo>> map = healthChannelRecommendArticleDos.stream().collect(Collectors.groupingBy(HealthChannelRecommendArticleDo::getArticleType));
            return write(200, "获取成功", "data",map);
        } catch (Exception ex) {
            logger.error(getClass().getName() + ":"+ex.getMessage(), ex.getMessage());
            return error(-1, "获取失败!"+ex.getMessage());
        }
    }
    @RequestMapping(value = "stick/list", method = RequestMethod.GET)
    @ApiOperation(value = "获取健康频道-置顶文章列表")
    @ResponseBody
    public String list(
            @ApiParam(name = "channelId", value = "频道id", required = true)
            @RequestParam(value = "channelId", required = true) Integer channelId,
            @ApiParam(name = "title", value = "标题", required = false)
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "articleAuthor", value = "作者", required = false)
            @RequestParam(value = "articleAuthor", required = false) String articleAuthor,
            @ApiParam(name = "categoryId", value = "内容类型", required = false)
            @RequestParam(value = "categoryId", required = false) String categoryId,
            @ApiParam(name = "classification", value = "分类", required = false)
            @RequestParam(value = "classification", required = false) String classification,
            @ApiParam(name = "startTime", value = "置顶开始时间", required = false)
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "置顶结束时间", required = false)
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "delFlag", value = "状态", required = false)
            @RequestParam(value = "delFlag", required = false) String delFlag,
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize) {
        try {
            Page<HealthChannelRecommendArticleDo> healthChannelDos = channelRecommendArticleService.searchStickList(channelId,title,articleAuthor,categoryId,classification,startTime,endTime,delFlag,page,pageSize);
            return write(200, "获取成功", "data",healthChannelDos);
        } catch (Exception ex) {
            logger.error(getClass().getName() + ":"+ex.getMessage(), ex.getMessage());
            return error(-1, "获取失败!"+ex.getMessage());
        }
    }
    @RequestMapping(value = "recommend/platformInformation/list", method = RequestMethod.GET)
    @ApiOperation(value = "查询-平台资讯")
    @ResponseBody
    public String platformInformationList(
            @ApiParam(name = "title", value = "文章标题", required = false)
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "type", value = "资讯分类", required = false)
            @RequestParam(value = "type", required = false) Integer type,
            @ApiParam(name = "classify", value = "分类", required = false)
            @RequestParam(value = "classify", required = false) String classify,
            @ApiParam(name = "town", value = "行政规划(厦门市+**区)", required = false)
            @RequestParam(value = "town", required = false) String town,
            @ApiParam(name = "hospital", value = "机构编码", required = false)
            @RequestParam(value = "hospital", required = false) String hospital,
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize) {
        try {
            Page<List<Map<String, Object>>>platformInformationDOS= platformInformationService.channelSearchList(title,type,classify,town,hospital,page,pageSize);
            return write(200, "获取成功", "data",platformInformationDOS);
        } catch (Exception ex) {
            logger.error(getClass().getName() + ":"+ex.getMessage(), ex.getMessage());
            return error(-1, "获取失败!"+ex.getMessage());
        }
    }
    @RequestMapping(value = "recommend/healthColumn/list", method = RequestMethod.GET)
    @ApiOperation(value = "查询-健康专栏")
    @ResponseBody
    public String healthColumnList(
            @ApiParam(name = "title", value = "专栏名称", required = false)
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "author", value = "作者", required = false)
            @RequestParam(value = "author", required = false) String author,
            @ApiParam(name = "classify", value = "分类", required = false)
            @RequestParam(value = "classify", required = false) String classify,
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize) {
        try {
            Page<List<Map<String, Object>>> mapPage=  periodicalService.searchList(title,author,classify,page,pageSize);
            return write(200, "获取成功", "data",mapPage);
        } catch (Exception ex) {
            logger.error(getClass().getName() + ":"+ex.getMessage(), ex.getMessage());
            return error(-1, "获取失败!"+ex.getMessage());
        }
    }
    @RequestMapping(value = "recommend/healthArticle/list", method = RequestMethod.GET)
    @ApiOperation(value = "查询-精选问答/健康文章")
    @ResponseBody
    public String healthArticleList(
            @ApiParam(name = "type", value = "内容分类:selected_questions_and_answers精选问答/health_article健康文章", required = true)
            @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "title", value = "标题", required = false)
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "author", value = "作者", required = false)
            @RequestParam(value = "author", required = false) String author,
            @ApiParam(name = "firstLevelCategoryId", value = "一级分类")
            @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
            @ApiParam(name = "secondLevelCategoryId", value = "二级分类")
            @RequestParam(value = "secondLevelCategoryId", required = false) String secondLevelCategoryId,
            @ApiParam(name = "scopeOfApplication", value = "健康文章适用范围(1、全市使用,2、全区使用,3、全社区使用)")
            @RequestParam(value = "scopeOfApplication", required = false) Integer scopeOfApplication,
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize) {
        try {
            JSONObject jsonObject = null;
            if(page == null){
                page = 1;
            }
            if(pageSize == null){
                pageSize = 15;
            }
            //健康文章查询
            if (Constant.health_article.equals(type)) {
                jsonObject = channelRecommendArticleService.queryArticleList(title, author, firstLevelCategoryId, secondLevelCategoryId, scopeOfApplication, page, pageSize);
            } else if (Constant.selected_questions_and_answers.equals(type)) {
                //精选问答
                jsonObject = refinementService.getRefinnementList(title,author,firstLevelCategoryId,secondLevelCategoryId,scopeOfApplication,page,pageSize);
            }
            return write(200, "获取成功", "data", jsonObject);
        } catch (Exception ex) {
            logger.error(getClass().getName() + ":"+ex.getMessage(), ex.getMessage());
            return error(-1, "获取失败!"+ex.getMessage());
        }
    }
    @RequestMapping(value = "create", method = RequestMethod.POST)
    @ApiOperation(value = "创建推荐/置顶文章")
    @ResponseBody
    public String create(
            @ApiParam(name = "operationType", value = "操作类型:1推荐、2置顶", required = true)
            @RequestParam(value = "operationType", required = true) Integer operationType,
            @ApiParam(name = "jsonData", value = "推荐/置顶文章Json", required = true)
            @RequestParam(value = "jsonData", required = true) String jsonData, HttpServletRequest req) {
        try {
            System.out.println("code---"+String.valueOf(req.getSession().getAttribute("code")));
            System.out.println("getUid----"+getUID());
            Doctor d= doctorService.findDoctorByCode(String.valueOf(req.getSession().getAttribute("code")));
            List<HealthChannelRecommendArticleDo> healthChannelRecommendArticleDos=channelRecommendArticleService.create(operationType,jsonData,d);
            return write(200, "创建成功","data",healthChannelRecommendArticleDos);
        } catch (Exception ex) {
            logger.error(getClass().getName() + ":"+ex.getMessage(), ex.getMessage());
            return error(-1, "创建失败!"+ex.getMessage());
        }
    }
    @RequestMapping(value = "update", method = RequestMethod.POST)
    @ApiOperation(value = "编辑推荐/置顶文章")
    @ResponseBody
    public String update(
            @ApiParam(name = "operationType", value = "操作类型:1推荐、2置顶", required = true)
            @RequestParam(value = "operationType", required = true) Integer operationType,
            @ApiParam(name = "healthChannelRecommendArticleId", value = "推荐/置顶记录id", required = true)
            @RequestParam(value = "healthChannelRecommendArticleId", required = true) Long healthChannelRecommendArticleId,
            @ApiParam(name = "startTime", value = "置顶开始时间", required = false)
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "置顶结束时间", required = false)
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "sort", value = "推荐排序位置", required = false)
            @RequestParam(value = "sort", required = false) Integer sort,HttpServletRequest req) {
        try {
            HealthChannelRecommendArticleDo healthChannelRecommendArticleDo=channelRecommendArticleService.update( operationType, healthChannelRecommendArticleId, startTime, endTime, sort);
            return write(200, "编辑成功!","data",healthChannelRecommendArticleDo);
        } catch (Exception ex) {
            logger.error(getClass().getName() + ":"+ex.getMessage(), ex.getMessage());
            return error(-1, "编辑失败!"+ex.getMessage());
        }
    }
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除推荐/置顶文章")
    @ResponseBody
    public String delete(
            @ApiParam(name = "healthChannelRecommendArticleId", value = "推荐/置顶记录id,多个适用逗号隔开", required = true)
            @RequestParam(value = "healthChannelRecommendArticleId", required = true) String healthChannelRecommendArticleId) {
        try {
            channelRecommendArticleService.deleteById(healthChannelRecommendArticleId);
            return write(200, "删除成功!");
        } catch (Exception ex) {
            logger.error(getClass().getName() + ":"+ex.getMessage(), ex.getMessage());
            return error(-1, "删除失败!"+ex.getMessage());
        }
    }
    @RequestMapping(value = "getCategoryList",method = RequestMethod.GET)
    @ApiOperation("获取健康文章分类")
    @ResponseBody
    public String getCategoryList(@ApiParam(name = "categoryLevel", value = "获取类别:1、一级类别 2、二级类别")
                                      @RequestParam(value = "categoryLevel") Integer categoryLevel,
                                  @ApiParam(name = "firstlevelId", value = "一级类别Id")
                                  @RequestParam(value = "firstlevelId", required = false) String firstlevelId,
                                  @ApiParam(name = "secondLevelId", value = "二级类别Id")
                                  @RequestParam(value = "secondLevelId", required = false) String secondLevelId){
        try {
            com.alibaba.fastjson.JSONArray response = channelRecommendArticleService.getCategoryList(categoryLevel, firstlevelId, secondLevelId);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getJkeduCategoryList",method = RequestMethod.GET)
    @ApiOperation("获取健康文章全部分类")
    @ResponseBody
    public String getCategoryList(){
        try {
            com.alibaba.fastjson.JSONArray response = channelRecommendArticleService.getJkeduCategoryList();
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
}
*/

+ 140 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/hos/HlwyyHospitalController.java

@ -0,0 +1,140 @@
package  com.yihu.customer.controller.manager.hos;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.organization.HlwyyHospital;
import com.yihu.customer.service.manager.hos.HlwyyHospitalService;
import  com.yihu.customer.repository.organization.HlwyyHospitalDao;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.UUID;
/**
 * Created by yeshijie on 2023/2/1.
 */
@Controller
@RequestMapping(value = "/admin/hos/hlwyy")
public class HlwyyHospitalController extends BaseController {
    @Autowired
    private HlwyyHospitalService hlwyyHospitalService;
    @Autowired
    private HlwyyHospitalDao hlwyyHospitalDao;
    @Value("${fastDFS.fastdfs_file_url}")
    private String imgUrlDomain;
    //医院列表页面
    @RequestMapping(value = "initialHospitalList", method = RequestMethod.GET)
    public String listInit() {
        request.setAttribute("imgUrlDomain", imgUrlDomain);
        return "hos/hlwyy/hospital_list";
    }
    //编辑页面
    @RequestMapping(value = "infoInit/{id}", method = RequestMethod.GET)
    public String infoInit(@PathVariable("id") Long id, String mode) {
        if (id == 0) {
            request.setAttribute("UUID", UUID.randomUUID().toString().replace("-", ""));
        }
        request.setAttribute("imgUrlDomain", imgUrlDomain);
        request.setAttribute("id", id);
        request.setAttribute("mode", mode);
        return "hos/hlwyy/hospital_edit";
    }
    //新增 修改
    @RequestMapping(value = "createOrUpdate", method = RequestMethod.POST)
    @ResponseBody
    public String createOrUpdate(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            HlwyyHospital hospital = objectMapper.readValue(jsonData, HlwyyHospital.class);
            hospital = hlwyyHospitalService.createHospital(hospital);
            return write(200,"操作成功","data",hospital);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //修改生生效
    @RequestMapping(value = "updDel", method = RequestMethod.POST)
    @ResponseBody
    public String updDel(
            @RequestParam(name = "id") Long id,
            @RequestParam(name = "del") Integer del) {
        try {
            HlwyyHospital hospital = hlwyyHospitalService.getHospital(id);
            if(hospital!=null){
                hospital.setDel(del);
                hlwyyHospitalDao.save(hospital);
            }
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //修改推荐
    @RequestMapping(value = "updRecommond", method = RequestMethod.POST)
    @ResponseBody
    public String updRecommond(
            @RequestParam(name = "id") Long id,
            @RequestParam(name = "recommend") Integer recommend) {
        try {
            HlwyyHospital hospital = hlwyyHospitalService.getHospital(id);
            if(hospital!=null){
                hospital.setRecommend(recommend);
                hlwyyHospitalDao.save(hospital);
            }
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //根据id获取单个
    @RequestMapping(value = "getHospital", method = RequestMethod.GET)
    @ResponseBody
    public String getHospital(@RequestParam(value = "id") Long id) {
        try {
            HlwyyHospital hospital = hlwyyHospitalService.getHospital(id);
            return write(200, "操作成功!", "hos", hospital);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //获取列表(分页)
    @RequestMapping(value = "hospitalList", method = RequestMethod.GET)
    @ResponseBody
    public String hospitalList(@ApiParam(name = "name", value = "医院名称", required = false)
                                  @RequestParam(value = "name",required = false) String name,
                                  @ApiParam(name = "page", value = "第几页", required = false)
                                  @RequestParam(value = "page",required = false) Integer page,
                                  @ApiParam(name = "rows", value = "分页大小", required = false)
                                  @RequestParam(value = "rows",required = false) Integer rows) {
        try {
            if(page==null||page<=0){
                page = 1;
            }
            if(rows==null||rows<=0){
                rows = 10;
            }
            Page<HlwyyHospital> hospitals = hlwyyHospitalService.searchHospitals(name, page, rows);
            return write(200, "操作成功!", page, rows, hospitals);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 324 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/hos/HosController.java

@ -0,0 +1,324 @@
package  com.yihu.customer.controller.manager.hos;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.Doctor;
import  com.yihu.customer.entity.Hospital;
import com.yihu.customer.service.manager.hos.HosService;
import  com.yihu.customer.repository.DoctorDao;
import  com.yihu.customer.repository.HospitalDao;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * 医院信息管理
 * Created by yww on 2016/9/27.
 */
@Controller
@RequestMapping(value = "/admin/hos")
public class HosController extends BaseController {
    @Autowired
    private HosService hospitalService;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private DoctorDao doctorDao;
    @RequestMapping(value = "resetPwdInit")
    public String resetPwdInit() {
        return "hos/reset_pwd";
    }
    //页面跳转(主页面)
    @RequestMapping(value = "initial")
    public String listInit() {
        return "hos/hospital_list";
    }
    //页面跳转(详情页面)
    @RequestMapping(value = "infoInit/{id}", method = RequestMethod.GET)
    public String infoInit(@PathVariable("id") Long id, String mode) {
        if (id == 0) {
            request.setAttribute("UUID", UUID.randomUUID().toString().replace("-", ""));
        }
        request.setAttribute("id", id);
        request.setAttribute("mode", mode);
        return "hos/hospital_edit";
    }
    //新增
    @RequestMapping(value = "create")
    @ResponseBody
    public String createHospital(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Hospital hospital = objectMapper.readValue(jsonData, Hospital.class);
            hospitalService.createHospital(hospital);
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //修改
    @RequestMapping(value = "update")
    @ResponseBody
    public String updateHospital(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Hospital hospital = objectMapper.readValue(jsonData, Hospital.class);
            hospitalService.createHospital(hospital);
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //修改
    @RequestMapping(value = "updateDel")
    @ResponseBody
    public String updateHospitalStatus(
            @RequestParam(name = "id") Long id,
            @RequestParam(name = "del") String del) {
        try {
            boolean res = hospitalService.updateDel(id, del);
            return res == true ? success("操作成功!") : error(-1, "操作失败!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //根据id删除
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deleteHospital(@RequestParam(value = "id") Long id) {
        try {
            hospitalService.deleteHospital(id);
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //根据id获取单个
    @RequestMapping(value = "hospital")
    @ResponseBody
    public String getHospital(@RequestParam(value = "id") Long id) {
        try {
            Hospital hospital = hospitalService.getHospital(id);
            return write(200, "操作成功!", "hos", hospital);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //获取列表(不分页)
    @RequestMapping(value = "hospitalsNoPage")
    @ResponseBody
    public String searchHospitalNoPage(@RequestParam(value = "name", required = false) String name,
                                       @RequestParam(value = "level",required = false)String level) {
        try {
            List<Hospital> hospitals = hospitalService.searchHospitalNoPage(name,level);
            return write(200, "操作成功!", "hoss", hospitals);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //获取列表type = 1 根据城市获取  type = 2 根据区获取
    @RequestMapping(value = "hospitalsByType")
    @ResponseBody
    public String getHospitalByType(@RequestParam(value = "type", required = true) Integer type,@RequestParam(value = "code", required = true) String code) {
        try {
            List<Hospital> hospitals = hospitalService.getHospitalByType(type,code);
            return write(200, "操作成功!", "list", hospitals);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //获取列表(分页)
    @RequestMapping(value = "hospitalList")
    @ResponseBody
    public String searchHospitals(String name, String doctorName, String doctorMobile, int page, int rows) {
        try {
            Page<Hospital> hospitals = hospitalService.searchHospitals(name, doctorName, doctorMobile, page, rows);
            return write(200, "操作成功!", page, rows, hospitals);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //医院名字是否存在
    @RequestMapping(value = "isNameExist")
    @ResponseBody
    public String isNameExist(String name) {
        try {
            return hospitalService.isNameExist(name);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 按城市查找社区
     *
     * @param city
     * @return
     */
    @RequestMapping(value = "community")
    @ResponseBody
    public String community(String city) {
        try {
            List<Map<String, String>> roleMap = (List<Map<String, String>>) request.getSession().getAttribute("roleMap");
            Map<String, JSONObject> map = new HashMap<String, JSONObject>();
            if (roleMap.size() > 0) {//管理员
                List<Hospital> list = hospitalDao.findByCity(city);
                if (list != null && list.size() > 0) {
                    String areaString = "";
                    String communityString = "";
                    Boolean cityFlag = false;
                    for (Map<String, String> rmap : roleMap) {
                        String code = rmap.get("code");
                        if ("350200".equals(code)) {
                            cityFlag = true;
                            break;
                        } else if (code.length() == 6) {
                            areaString += rmap.get("areas") + ",";
                        } else {
                            communityString += rmap.get("areas") + ",";
                        }
                    }
                    for (Hospital hos : list) {
                        String town = hos.getTown() + ":" + hos.getTownName();
                        JSONArray jsonArray = null;
                        JSONObject jsonObject = null;
                        String hosCode = hos.getCode();
                        String hosName = hos.getName();
                        if (!cityFlag) {
                            if (areaString.length() > 0) {
                                if (areaString.indexOf(hos.getTown() + ",") < 0) {
                                    continue;
                                }
                            } else {
                                if (communityString.indexOf(hosCode + ",") < 0) {
                                    continue;
                                }
                            }
                        }
                        JSONObject json = new JSONObject();
                        json.put("code", hosCode);
                        json.put("name", hosName);
                        if (map.containsKey(town)) {
                            jsonObject = map.get(town);
                            jsonArray = jsonObject.getJSONArray(town);
                            jsonArray.put(json);
                        } else {
                            jsonObject = new JSONObject();
                            jsonArray = new JSONArray();
                            jsonArray.put(json);
                            jsonObject.put(town, jsonArray);
                            map.put(town, jsonObject);
                        }
                    }
                }
            } else {
                //医生
                String mobile = (String) request.getSession().getAttribute("mobile");
                Doctor doctor = doctorDao.findByMobile(mobile);
                Hospital hos = hospitalDao.findByCode(doctor.getHospital());
                String town = hos.getTown() + ":" + hos.getTownName();
                JSONArray jsonArray = new JSONArray();
                ;
                JSONObject jsonObject = new JSONObject();
                ;
                JSONObject json = new JSONObject();
                json.put("code", hos.getCode());
                json.put("name", hos.getName());
                jsonArray.put(json);
                jsonObject.put(town, jsonArray);
                map.put(town, jsonObject);
            }
            JSONArray jsonArray = new JSONArray();
            for (String key : map.keySet()) {
                JSONObject json = new JSONObject();
                json.put("town", key);
                json.put("community", map.get(key).get(key));
                jsonArray.put(json);
            }
            return write(200, "查询成功!", "list", jsonArray);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    //医院名字是否存在
    @RequestMapping(value = "isCcodeExist")
    @ResponseBody
    public String isCodeExist(String code) {
        try {
            return hospitalService.isCodeExist(code);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "importData", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(HttpServletRequest request) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = request.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            hospitalService.importData(workbook);
            return write(200, "操作成功");
        } catch (IOException | BiffException e) {
            e.printStackTrace();
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 783 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/hos/HosDoctorController.java

@ -0,0 +1,783 @@
package  com.yihu.customer.controller.manager.hos;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.Doctor;
import  com.yihu.customer.entity.twoCancers.BreastCervicalFormPermissions;
import com.yihu.customer.service.manager.dmjob.DmJobService;
import com.yihu.customer.service.manager.hos.HosDoctorService;
import com.yihu.customer.service.manager.team.ManageWlyyAdminTeamService;
import com.yihu.customer.util.IdcardValidator;
import com.yihu.customer.util.MD5;
import io.swagger.annotations.ApiOperation;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.ParseException;
import java.util.*;
/**
 * Created by yww on 2016/9/28.
 */
@Controller
@RequestMapping(value = "/admin/hos/doctor")
public class HosDoctorController extends BaseController {
    @Autowired
    private HosDoctorService doctorService;
    @Autowired
    private ManageWlyyAdminTeamService manageWlyyAdminTeamService;
    @Autowired
    private DmJobService jobService;
    //跳转到医生列表页
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String list(Model model, @RequestParam(required = true) String orgId, String doctorName, @RequestParam String orgCode, @RequestParam String orgName) {
        model.addAttribute("orgId", orgId);
        model.addAttribute("doctorName", doctorName);
        model.addAttribute("orgCode", orgCode);
        model.addAttribute("orgName", orgName);
        return "hos/doctor/doctor_list";
    }
    //进入人员添加界面
    @RequestMapping(value = "createInit", method = RequestMethod.GET)
    public String add() {
        String orgCode = request.getParameter("orgCode");
        request.setAttribute("UUID", UUID.randomUUID().toString().replace("-", ""));
        request.setAttribute("orgCode", orgCode);
        return "hos/doctor/doctor_modify";
    }
    @RequestMapping(value = "create")
    @ResponseBody
    public String createDoctor(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Doctor doctor = objectMapper.readValue(jsonData, Doctor.class);
            doctorService.saveDoctor(doctor);
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!" + e.getMessage());
        }
    }
    //进入人员查看、编辑界面
    @RequestMapping(value = "updateInit/{id}", method = RequestMethod.GET)
    public String update(@PathVariable("id") Long id) {
        try {
            request.setAttribute("doctorId", id);
            request.setAttribute("type", request.getParameter("type"));
        } catch (Exception e) {
            error(e);
        }
        return "hos/doctor/doctor_modify";
    }
    @RequestMapping(value = "update")
    @ResponseBody
    public String updateDoctor(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Doctor doctor = objectMapper.readValue(jsonData, Doctor.class);
            doctorService.updateDoctor(doctor);
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!" + e.getMessage());
        }
    }
    /**
     * 删除用户
     *
     * @param id
     * @param code
     * @return
     */
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deleteDoctor(
            @RequestParam(value = "id", required = true) Long id,
            @RequestParam(value = "code", required = true) String code) {
        try {
            doctorService.deleteDoctorByid(id, code);
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 查找用户列表
     *
     * @param page
     * @param rows
     * @param hospital 医院标识
     * @param deptName 科室标识
     * @param jobName  职称标识
     * @param status   状态
     * @param name     姓名
     * @return
     */
    @RequestMapping(value = "doctorList")
    @ResponseBody
    public String doctorList(
            @RequestParam(value = "page", required = true) int page,
            @RequestParam(value = "rows", required = true) int rows,
            @RequestParam(value = "hospital", required = true) String hospital,
            @RequestParam(value = "deptName", required = false) String deptName,
            @RequestParam(value = "jobName", required = false) String jobName,
            @RequestParam(value = "status", required = false) String status,
            @RequestParam(value = "mobile", required = false) String mobile,
            @RequestParam(value = "name", required = false) String name) {
        try {
            if (StringUtils.isEmpty(hospital)) {
                return error(-1, "所属机构编码不能为空!");
            }
            Page<Doctor> doctors = doctorService.getDoctorList(page, rows, hospital, deptName, jobName, status, mobile, name);
            return write(200, "", page, rows, doctors);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "doctorListNoPage",method = RequestMethod.POST)
    @ResponseBody
    public String doctorListNoPage(
            @RequestParam(value = "hospital", required = true) String hospital,
            @RequestParam(value = "doctorName", required = false) String doctorName
            ) {
        try {
            if (StringUtils.isEmpty(hospital)) {
                return error(-1, "所属机构编码不能为空!");
            }
            List<Doctor> doctors = doctorService.doctorListNoPage(hospital,doctorName);
            return write(200, "获取成功", "data", doctors);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "exportExcel", method = RequestMethod.POST)
    @ApiOperation("导出机构人员")
    @ResponseBody
    public void exportDoctorList(
            @RequestParam(value = "hospital", required = false) String hospital,
            @RequestParam(value = "deptName", required = false) String deptName,
            @RequestParam(value = "jobName", required = false) String jobName,
            @RequestParam(value = "status", required = false) String status,
            @RequestParam(value = "mobile", required = false) String mobile,
            @RequestParam(value = "name", required = false) String name,
            HttpServletResponse response) {
        try {
            List<Doctor> list = doctorService.exportDoctorList(hospital, deptName, jobName, status, mobile, name);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("doctorList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os, list);
        } catch (Exception ex) {
            error(ex);
        }
    }
    /**
     * 查找单个用户
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "findOneDoctor")
    @ResponseBody
    public String findOneDoctor(
            @RequestParam(value = "id", required = true) Long id) {
        try {
            Doctor doctor = doctorService.getDoctor(id);
            return write(200, "操作成功!", "doc", doctor);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 查找单个用户
     *
     * @param code
     * @return
     */
    @RequestMapping(value = "findDoctor")
    @ResponseBody
    public String findDoctor(
            @RequestParam(value = "code", required = true) String code) {
        return null;
            /* try {
       Doctor doctor = doctorService.getDoctorByCode(code);
            List<WlyyAdminTeam> wlyyAdminTeams = wlyyAdminTeamService.getTeamsByDoctor(doctor.getCode());
            com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.
            JSONObject object = new JSONObject(doctor);
            String teamName = "";
            for (WlyyAdminTeam wlyyAdminTeam : wlyyAdminTeams) {
                teamName = teamName + wlyyAdminTeam.getName() + ",";
            }
            if (teamName.lastIndexOf(",") >= 0) {
                teamName = teamName.substring(0, teamName.lastIndexOf(","));
            }
            object.put("teamName", teamName.toString());
            return write(200, "操作成功!", "doc", object);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }*/
    }
    @RequestMapping(value = "sign")
    public String sign(@RequestParam(value = "doctorIdList", required = true) String ids) {
        request.setAttribute("doctorIdList", ids);
        return "hos/doctor/sign_modify";
    }
//    @RequestMapping(value = "updateStatus",method = RequestMethod.POST)
//    @ResponseBody
//    public String updateSign(
//            @RequestParam(value = "doctorIdList", required = true) String ids,
//            @RequestParam(value = "status", required = true) String status) {
//        try {
//            doctorService.updateStatus(ids, status);
//            return write(200, "操作成功!");
//        } catch (Exception e) {
//            error(e);
//            return error(-1, "操作失败!");
//        }
//    }
    @RequestMapping(value = "updateStatus", method = RequestMethod.POST)
    @ResponseBody
    public String updateStatus(
            @RequestParam(value = "doctorId", required = true) Long doctorId,
            @RequestParam(value = "mobile", required = true) String mobile,
            @RequestParam(value = "status", required = true) Integer status) {
        try {
            if (doctorId == null) {
                return error(-1, "医生id不能为空!!");
            }
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "电话号码不能为空!");
            }
            if (status == null) {
                return error(-1, "状态不能为空!!");
            }
            //生失效前判断是否有同手机号的生效数据(有则不允许生效)
            //因为基卫导入时,手机号码为空的情况下都是设置为1,所以对该部分数据允许进行生效
            boolean existMobile = false;
            if (!mobile.equals("1")) {
                if (status == 1) {
                    existMobile = doctorService.isExistMobile(mobile);
                }
                if (existMobile) {
                    return error(-1, "同个手机号只能有一条生效医生信息!");
                }
            }
            boolean res = doctorService.updateDel(status, doctorId);
            return res == true ? write(200, "操作成功!") : error(-1, "操作失败!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //跳转上传结果页面
    @RequestMapping("/importResult")
    public String importResult() {
        return "hos/doctor/doctor_import_result";
    }
    @RequestMapping(value = "/importFromExcel", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importFromExcel(HttpServletRequest request, @RequestParam(value = "orgCode", required = true) String orgCode, @RequestParam(value = "orgName", required = true) String orgName) {
        List errorLs = new ArrayList<>();
        List correctLs = new ArrayList<>();
        IdcardValidator idcardValidator = new IdcardValidator();
        //判断表中数据是否重复
        //名字、手机号、身份证号
        Set<String> nameSet = new HashSet<>(); //存放表中名字
        Set<String> mobileSet = new HashSet<>();//存放表中手机号
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = request.getInputStream();
            Workbook rwb = Workbook.getWorkbook(inputStream);
            Sheet[] sheets = rwb.getSheets();
            int rows;
            int row;
            List<Doctor> doctorList = new ArrayList<>();
            String name = null;// 姓名
            Integer sex = null;// 性别(1男,2女)
            String birthday = null;// 生日
            String mobile = null;// 手机号
            String password = null;// 登录密码 ---默认值手机后六位
            Integer status = 1;// 状态(1正常,0禁用)
            String province = null;// 省
            String city = null;    // 市
            String town = null;// 區縣代碼
            String hospital = orgCode;// 医院标识
            String hospitalName = null;// 医院名称
            String deptName = null;// 科室名
            String jobName = null;// 职称名
            String expertise = null;// 医生专长
            String introduce = null;// 医生介绍
            Integer level = 0;// 类型:1专科医生,2全科医生,3健康管理师 11同安计生协会工作人员  默认0
            String idCard = null;//身份证号
            String isFamous = "0";//是否名医
            String shequType = null; //社区内类型
            Sheet sheet = sheets[0];    //第一张表
            rows = sheet.getRows();
            for (int j = 1; j < rows; j++) {
                if (sheet.getRow(j).length == 0) {
                    continue;
                }
                String errorMsg = "";
                Doctor doctor = new Doctor();
                Map<String, String> errorMsgMap = doctor.getErrorMsgMap();
                row = j;
                name = sheet.getCell(0, row).getContents().trim();    // 0 姓名
                idCard = sheet.getCell(1, row).getContents().trim();  //1 身份证号
                mobile = sheet.getCell(2, row).getContents().trim();   //2 手机号
                //3 人员类型(对应字段?)
                jobName = sheet.getCell(4, row).getContents().trim(); //4 临床职称
                //5 行政职称(对应字段?)
                expertise = sheet.getCell(6, row).getContents().trim();  //6 人员专长
                hospitalName = sheet.getCell(7, row).getContents().trim(); //7 机构名称
                deptName = sheet.getCell(8, row).getContents().trim(); //8 科室
                introduce = sheet.getCell(9, row).getContents().trim();//9 医生简介
                String levelName = sheet.getCell(10, row).getContents().trim();//10 三师类型
                shequType = sheet.getCell(11, row).getContents().trim();//11 社区内类型
                if (
                        StringUtils.isEmpty(name) && StringUtils.isEmpty(idCard)
                                && StringUtils.isEmpty(mobile) && StringUtils.isEmpty(jobName)
                                && StringUtils.isEmpty(expertise) && StringUtils.isEmpty(hospitalName)
                                && StringUtils.isEmpty(deptName) && StringUtils.isEmpty(introduce)
                                && StringUtils.isEmpty(levelName) && StringUtils.isEmpty(shequType)) {
                    continue;
                }
                doctor.setName(name);
                doctor.setIdCard(idCard);
                doctor.setMobile(mobile);
                doctor.setJobName(jobName);
                doctor.setExpertise(expertise);
                doctor.setHospitalName(hospitalName);
                doctor.setDeptName(deptName);
                doctor.setIntroduce(introduce);
                doctor.setLevelName(levelName);
                doctor.setShequType(shequType);
                doctor.setExpandLevel("0");//默认为0
                boolean isRepeatFlag = false;//表中姓名、手机号、身份证号是否重复(有重复保存第一个,其余返回)
                //表中的机构名不能为空,且需与机构列表传递过来的一致
                if (StringUtils.isEmpty(hospitalName)) {
                    errorMsgMap.put("hospitalName", "表中的机构名称不能为空!;");
                    errorMsg += "表中的机构名称不能为空!;";
                } else if (!StringUtils.equals(hospitalName, orgName)) {
                    errorMsgMap.put("hospitalName", "表中的机构名称与已建立的机构名称不一致!!");
                    errorMsg += "表中的机构名称与已建立的机构名称不一致!;";
                }
                //手机号不能为空、唯一性
                if (StringUtils.isEmpty(mobile)) {
                    errorMsgMap.put("mobile", "手机号码不能为空;");
                    errorMsg += "手机号码不能为空!;";
                } else {
                    //手机格式判断
                    //
                    boolean flag = doctorService.isExistMobile(mobile);
                    if (!mobile.matches("^[0-9]{11}$")) {
                        errorMsgMap.put("mobile", "手机格式不正确;");
                        errorMsg += "手机格式不正确;";
                    } else if (flag) {
                        errorMsgMap.put("mobile", "手机号已注册;");
                        errorMsg += "手机号已注册;";
                    } else if (mobileSet.contains(mobile)) {
                        errorMsgMap.put("mobile", "-表中存在重复电话号码,只导入第一条;");
                        errorMsg += "表中存在重复电话号码;";
                        isRepeatFlag = true;
                    } else {
                        mobileSet.add(mobile);
                    }
                }
                //唯一性验证
                if (StringUtils.isEmpty(name)) {
                    errorMsgMap.put("name", "医生姓名不能为空!;");
                    errorMsg += "医生姓名不能为空!;";
                } else {
                    boolean flag = doctorService.findByNameHospital(name, orgCode);
                    if (flag) {
                        errorMsgMap.put("name", "该机构下该医生姓名已存在,请确认!!");
                        errorMsg += "该机构下该医生姓名已存在,请确认,若是存在同名情况,请手工新增!;";
                    }
                    if (nameSet.contains(name)) {
                        errorMsgMap.put("name", errorMsg.indexOf("name") + "-表中存在重复人名,只导入第一条;");
                        errorMsg += "表中存在重复人名;";
                        isRepeatFlag = true;
                    } else {
                        nameSet.add(name);
                    }
                }
                //判断身份证是否为空,取相关信息
                if (!StringUtils.isEmpty(idCard)) {
                    if (!idcardValidator.isValidatedAllIdcard(idCard)) {
                        errorMsgMap.put("idCard", "身份证格式有误;");
                        errorMsg += "身份证格式有误;";
                    } else if (doctorService.isExistIdCard(idCard)) {
                        errorMsgMap.put("idCard", "医生身份证已存在,请确认!;");
                        errorMsg += "医生身份证已存在,请确认!;";
                    } else {
                        sex = doctorService.getGenderByIdCard(idCard);
                        birthday = doctorService.getBirthdayByIdCard(idCard);
                    }
                }
                //三师类型不能为空
                if (StringUtils.isEmpty(levelName)) {
                    errorMsgMap.put("levelName", "三师类型不能为空!;");
                    errorMsg += "三师类型不能为空!;";
                }
                if (StringUtils.equals(levelName, "专科医生")) {
                    level = 1;
                } else if (StringUtils.equals(levelName, "全科医生")) {
                    level = 2;
                } else if (StringUtils.equals(levelName, "健康管理师")) {
                    level = 3;
                } else if (StringUtils.equals(levelName, "管理员")) {
                    level = 10;
                } else if (StringUtils.equals(levelName, "同安计生协会工作人员")) {
                    level = 11;
                } else {
                    errorMsgMap.put("levelName", "三师类型不正确!;");
                    errorMsg += "三师类型不正确!;";
                }
                if (!StringUtils.isEmpty(errorMsg.trim())) {
                    doctor.setErrorMsg(errorMsg);
                    errorLs.add(doctor);
                    continue;
                }
                //插入数据集信息
                doctor.setCode(UUID.randomUUID().toString().replace("-", ""));
                doctor.setBirthday(StringUtils.isEmpty(birthday) == true ? null : DateUtils.parseDate(birthday, "yyyy-MM-dd"));
                doctor.setSex(sex);
                //初始密码、salt值
                String subMobile = mobile.substring(5);
                String salt = UUID.randomUUID().toString().replace("-", "");
                doctor.setSalt(salt);
                doctor.setPassword(MD5.GetMD5Code(subMobile + salt));
                doctor.setStatus(status);
                doctor.setHospital(hospital);
                doctor.setIscertified(0);
                doctor.setCzrq(new Date());
                doctor.setLevel(level);
                doctor.setShequType(shequType);
                doctor.setIsFamous(isFamous);
                doctor.setErrorMsgMap(errorMsgMap);
                doctor.setPhoto("../../../images/d-male.png");
                correctLs.add(doctor);
            }
            doctorService.saveDoctorList(correctLs);
            //包装导入结果(导入成功数量、错误对象集合)
            Map<String, Object> map = new HashMap<>();
            map.put("successNum", correctLs.size());
            map.put("failedNum", errorLs.size());
            map.put("errorData", errorLs);
            return write(200, "操作成功", "data", map);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "/importData", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(HttpServletRequest request) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = request.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            doctorService.importData(workbook);
            return write(200, "操作成功");
        } catch (IOException | BiffException | ParseException e) {
            e.printStackTrace();
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //导入失败数据生成Excel表
    @RequestMapping(value = "toExcel", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public void errorDataToExcel(@RequestParam(value = "errorData") String errorData, HttpServletResponse response) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, Doctor.class);
            List<Doctor> lst = (List<Doctor>) objectMapper.readValue(errorData, javaType);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("errorTable.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os, lst);
        } catch (Exception ex) {
            error(ex);
        }
    }
    public void addHeader(WritableSheet ws) throws WriteException {
        String[] header = {"姓名", "身份证号", "手机号", "性别", "职务", "人员专长", "机构名称", "科室", "医生简介", "用户角色", "社区内类型"};
        int i = 0;
        for (String h : header) {
            addCell(ws, 0, i, h);//表名,行,列,header
            i++;
        }
    }
    public void write(WritableWorkbook wwb, List ls) throws Exception {
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            addHeader(ws);
            int i = 1;
            for (Doctor doc : (List<Doctor>) ls) {
                Map<String, String> map = doc.getErrorMsgMap();
                addCell(ws, i, 0, doc.getName(), map.get("name"));
                addCell(ws, i, 1, doc.getIdCard(), map.get("idCard"));
                addCell(ws, i, 2, doc.getMobile(), map.get("mobile"));
                if (doc.getSex() == null || doc.getSex() == 0) {
                    addCell(ws, i, 3, "未知", "");
                } else if (doc.getSex() == 1) {
                    addCell(ws, i, 3, "男", "");
                } else if (doc.getSex() == 2) {
                    addCell(ws, i, 3, "女", "");
                }
                addCell(ws, i, 4, doc.getJobName(), map.get("jobName"));
                addCell(ws, i, 5, doc.getExpertise(), map.get("expertise"));
                addCell(ws, i, 6, doc.getHospitalName(), map.get("hospitalName"));
                addCell(ws, i, 7, doc.getDeptName(), map.get("deptName"));
                addCell(ws, i, 8, doc.getIntroduce(), map.get("introduce"));
                addCell(ws, i, 9, doc.getLevelName(), map.get("levelName"));
                addCell(ws, i, 10, doc.getShequType(), map.get("shequType"));
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void write(OutputStream os, List ls) throws Exception {
        write(Workbook.createWorkbook(os), ls);
    }
    ;
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        ws.addCell(label);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
        Label label = new Label(column, row, data);
        if (!org.springframework.util.StringUtils.isEmpty(memo)) {
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        ws.addCell(label);
    }
    //初始化密码
    @RequestMapping(value = "initPassword")
    @ResponseBody
    public String initPassword(
            @RequestParam(value = "doctorId", required = true) Long doctorId,
            @RequestParam(value = "mobile", required = true) String mobile) {
        try {
            boolean res = doctorService.initPassword(doctorId, mobile);
            return res == true ? write(200, "操作成功!") : error(-1, "操作失败!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //电话号码唯一性验证
    @RequestMapping(value = "isExistMobile")
    @ResponseBody
    public String isExistMobile(@RequestParam(value = "mobile", required = true) String mobile) {
        if (doctorService.isExistMobile(mobile)) {
            return "true";
        }
        return "false";
    }
    //身份证号唯一性验证
    @RequestMapping(value = "isExistIdCard")
    @ResponseBody
    public String isExistIdCard(@RequestParam(value = "idCard", required = true) String idCard) {
        if (doctorService.isExistIdCard(idCard)) {
            return "true";
        }
        return "false";
    }
    @RequestMapping(value = "getAllDmJobList")
    @ApiOperation("获取医生职称")
    @ResponseBody
    public String getAllDmJobList() {
        try {
            return write(200, "获取成功", "data", jobService.getAllDmJobList());
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "getDoctorExpandLevelDict",method = RequestMethod.POST)
    @ApiOperation("获取医生扩展角色")
    @ResponseBody
    public String getDoctorExpandLevel() {
        try {
            return write(200, "获取成功", "data", doctorService.getDoctorExpandLevelDict());
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "getDictByName",method = RequestMethod.GET)
    @ApiOperation("获取字典")
    @ResponseBody
    public String getDictByName(@RequestParam(value = "dictName", required = true) String dictName) {
        try {
            return write(200, "获取成功", "data", doctorService.getDictByName(dictName));
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 获取两癌筛查医生列步兵
     * @param page
     * @param rows
     * @param name     姓名
     * @return
     */
    @RequestMapping(value = "getBreastCervicalDoctorList",method = RequestMethod.GET)
    @ResponseBody
    public String getBreastCervicalDoctorList(
            @RequestParam(value = "page", required = true) int page,
            @RequestParam(value = "rows", required = true) int rows,
            @RequestParam(value = "mobile", required = false) String mobile,
            @RequestParam(value = "name", required = false) String name) {
        try {
            Page<Doctor> doctors = doctorService.getBreastCervicalDoctorList(page, rows, mobile, name);
            return write(200, "", page, rows, doctors);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 获取医生权限
     * @return
     */
    @RequestMapping(value = "findformPermissionsByDoctor",method = RequestMethod.GET)
    @ResponseBody
    public String findformPermissionsByDoctor(
            @RequestParam(value = "doctor", required = true) String doctor) {
        try {
            List<BreastCervicalFormPermissions> list = doctorService.findformPermissionsByDoctor(doctor);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 获取两癌筛查医生列表
     * @return
     */
    @RequestMapping(value = "addFormPermissions",method = RequestMethod.POST)
    @ResponseBody
    public String addFormPermissions(
            @RequestParam(value = "doctor", required = true) String doctor,
            @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            List<BreastCervicalFormPermissions> groupReservation = com.alibaba.fastjson.JSONArray.parseArray(jsonData,BreastCervicalFormPermissions.class);
            doctorService.addFormPermissions(doctor,groupReservation);
            return write(200, "操作成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //跳转到两癌筛查编辑权限列表页
    @RequestMapping(value = "breastCervicalLimits/initial", method = RequestMethod.GET)
    public String breastCervicalLimitsList(Model model) {
        return "hos/breastCervical/limits_list";
    }
    //跳转到两癌筛查编辑权限编辑页
    @RequestMapping(value = "breastCervicalLimits/edit", method = RequestMethod.GET)
    public String breastCervicalLimitsEdit() {
        String doctorCode = request.getParameter("doctor");
        try {
            Doctor doctor =  doctorService.getDoctorByCode(doctorCode);
            request.setAttribute("hospitalName", doctor.getHospitalName());
            request.setAttribute("name", doctor.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
        request.setAttribute("doctor", doctorCode);
        return "hos/breastCervical/limits_modify";
    }
}

+ 130 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/hos/HosPharmacyController.java

@ -0,0 +1,130 @@
package  com.yihu.customer.controller.manager.hos;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.WlyyOrgAddress;
import com.yihu.customer.service.manager.hos.HosPharmacyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
/**
 * 药房管理
 * Created by Bing on 2021/5/27.
 */
@Controller
@RequestMapping(value = "/admin/hos/pharmacy")
@Api(description = "社区机构药房管理")
public class HosPharmacyController extends BaseController {
    @Autowired
    private HosPharmacyService hosPharmacyService;
    //页面跳转(主页面)
    @RequestMapping(value = "initial",method = RequestMethod.GET)
    public String listInit(Model model, @RequestParam(required = true) String hospitalCode) {
        model.addAttribute("hospitalCode", hospitalCode);
        return "hos/hospital_pharmacy_list";
    }
    //机构列表药房页面
    @RequestMapping(value = "pharmacyList", method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public String pharmacyList(@RequestParam(value = "hospitalCode", required = true) String hospitalCode,
                               @RequestParam(value = "name", required = false) String name,
                               @RequestParam(value = "page", required = true) Integer page,
                               @RequestParam(value = "rows", required = true) Integer rows) {
        try {
            if (StringUtils.isBlank(hospitalCode)){
                return error(-1, "所属机构编码不能为空!");
            }
            Page<WlyyOrgAddress> list = hosPharmacyService.pharmacyList(hospitalCode,name,page,rows);
            return write(200, "查询成功", page, rows, list);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    //编辑页面
    @RequestMapping(value = "updateInit/{id}", method = RequestMethod.GET)
    public String update(@PathVariable("id") Long id) {
        try {
            request.setAttribute("id", id);
            request.setAttribute("type", request.getParameter("type"));
        } catch (Exception e) {
            error(e);
        }
        return "hos/hospital_pharmacy_edit";
    }
    @RequestMapping(value = "update",method = RequestMethod.POST)
    @ResponseBody
    public String updateOrgAddress(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            WlyyOrgAddress orgAddress = objectMapper.readValue(jsonData, WlyyOrgAddress.class);
            hosPharmacyService.updateOrgAddress(orgAddress);
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!" + e.getMessage());
        }
    }
    @RequestMapping(value = "updateStatus", method = RequestMethod.POST)
    @ResponseBody
    public String updateStatus(
            @RequestParam(value = "id", required = true) Long id,
            @RequestParam(value = "del", required = true) Integer del) {
        try {
            if (id == null) {
                return error(-1, "id不能为空!!");
            }
            if (del == null) {
                return error(-1, "状态不能为空!!");
            }
            boolean res = hosPharmacyService.updateDel(del, id);
            return res == true ? write(200, "操作成功!") : error(-1, "操作失败!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "findOne",method = RequestMethod.GET)
    @ResponseBody
    public String findOne(
            @RequestParam(value = "id", required = true) Long id) {
        try {
            WlyyOrgAddress doctor = hosPharmacyService.findOne(id);
            return write(200, "操作成功!", "pharmacy", doctor);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "getHlwDevices",method = RequestMethod.GET)
    @ApiOperation("获取社区智能药柜设备列表")
    @ResponseBody
    public String getHlwDevices(
            @RequestParam(value = "orgCode", required = true) String orgCode) {
        try {
            return write(200, "操作成功!", "list", hosPharmacyService.getHlwDevices(orgCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 430 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/integratedquery/IntegratedQueryController.java

@ -0,0 +1,430 @@
/*
package com.yihu.jw.controller.manager.integratedquery;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.service.integratedquery.IntegratedqueryService;
import com.yihu.jw.service.manager.special.SpecialDiseaseService;
import com.yihu.jw.util.ElasticsearchUtil;
import com.yihu.jw.util.WorkbookUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
*/
/**
 * Created by janseny on 2019/2/15.
 *
 * 综合查询
 *
 *//*
@Controller
@RequestMapping(value="admin/integratedQuery/",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "integratedQuery", description = "指标综合查询", tags = {"指标综合查询"})
public class IntegratedQueryController extends BaseController {
    @Autowired
    SpecialDiseaseService specialDiseaseService;
    @Value("${es.index.HealthEduArticlePatient}")
    private String esIndex_HealthEduArticlePatient;
    @Value("${es.type.HealthEduArticlePatient}")
    private String esType_HealthEduArticlePatient;
    @Value("${es.index.Statistics}")
    private String esIndex;
    @Value("${es.type.Statistics}")
    private String esType;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private IntegratedqueryService integratedqueryService;
    @RequestMapping(value = "treeList", method = RequestMethod.GET)
    @ResponseBody
    public String treeList(){
        try {
            Map<String,Map<String,String>> treeMap = new HashMap<>();
            Map<String,String> map = new HashMap<>();
            map.put("1","签约全人群");
            map.put("2","签约高血压");
            map.put("3","签约糖尿病");
            map.put("4","签约孕产妇");
            map.put("5","签约0-6岁儿童");
            map.put("6","签约65岁以上老人");
            treeMap.put("签约人数",map);
            Map<String,String> map1 = new HashMap<>();
            map1.put("7","续约全人群");
            map1.put("8","续约高血压");
            map1.put("9","续约糖尿病");
            map1.put("10","续约65岁以上老人");
            treeMap.put("续签",map1);
            Map<String,String> map2 = new HashMap<>();
            map2.put("11","推送数量");
            map2.put("12","生日居民未推送数");
            treeMap.put("家签居民生日祝福推送统计",map2);
            Map<String,String> map3 = new HashMap<>();
            map3.put("13","厦门I健康公众号绑定人数");
            map3.put("14","咨询量");
            map3.put("15","及时回复");
            map3.put("16","未回复");
            map3.put("17","线上长处方(完成数)");
            map3.put("28","计免绑定量");
            treeMap.put("厦门I健康",map3);
            Map<String,String> map4 = new HashMap<>();
            map4.put("18","发放新设备");
            map4.put("19","使用设备");
            map4.put("20","设备绑定数");
            map4.put("21","24小时干预(人数)");
            map4.put("22","24小时异常总数");
            treeMap.put("可穿戴设备",map4);
            Map<String,String> map5 = new HashMap<>();
            map5.put("24","健康文章推送人数");
            map5.put("25","健康文章触达人数");
            map5.put("26","阅读量");
            treeMap.put("健康教育",map5);
            Map<String,String> map6 = new HashMap<>();
            map6.put("27","健康指导次数");
            treeMap.put("健康管理",map6);
            return write(200, "操作成功", "data",treeMap);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    public Map<String,String> getTitleMap(){
        Map<String, String> map = new HashMap<>();
        map.put("1","quotaCode=36&签约全人群");
        map.put("2","quotaCode=36-slaveKey1=4&签约高血压");
        map.put("3","quotaCode=36-slaveKey1=5&签约糖尿病");
        map.put("4","quotaCode=36-slaveKey1=6&签约孕产妇");
        map.put("5","quotaCode=36-slaveKey1=7&签约0-6岁儿童");
        map.put("6","quotaCode=36-slaveKey1=3&签约65岁以上老人");
        map.put("7","quotaCode=51&续约全人群");
        map.put("8","quotaCode=51-slaveKey1=1&续约高血压");
        map.put("9","quotaCode=51-slaveKey1=2&续约糖尿病");
        map.put("10","quotaCode=51-slaveKey1=3&续约65岁以上老人");
        map.put("11","quotaCode=98&推送数量");
        map.put("12","quotaCode=99&生日居民未推送数");
//        map.put("12","mysql=patientBirthday&生日居民数");
        map.put("13","quotaCode=21&厦门I健康公众号绑定人数");
        map.put("14","quotaCode=25&咨询量");
        map.put("15","quotaCode=23&及时回复");
        map.put("16","quotaCode=22&未回复");
        map.put("17","mysql=xiamenIjiankang2&线上长处方(完成数)");
        map.put("18","quotaCode=85&发放新设备");
        map.put("19","quotaCode=87&使用设备");
        map.put("20","quotaCode=86&设备绑定数");
        map.put("21","quotaCode=88&24小时干预(人数)");
        map.put("22","quotaCode=97&24小时异常总数");
        map.put("24","quotaCode=103&健康文章推送人数");
        map.put("25","quotaCode=83&健康文章触达人数");
        map.put("26","elasticSearch=health_edu_article_patient-isRead=1&阅读量");
        map.put("27","quotaCode=5&健康指导次数");
        map.put("28","mysql=childFamilyImmune&计免绑定量");
        return map;
    }
    @RequestMapping(value = "teamList", method = RequestMethod.GET)
    @ResponseBody
    public String teamList(){
        try {
            String teamSql = "SELECT id ,name from wlyy_admin_team ";
            List<Map<String, Object>>  teamList = jdbcTemplate.queryForList(teamSql);
            return write(200, "操作成功", "data",teamList);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "teamListByArea", method = RequestMethod.GET)
    @ResponseBody
    public String teamListByArea(
            @ApiParam(name = "area", value = "地区")
            @RequestParam(required = false) String area) {
        try {
            String teamSql = "SELECT t.id ,t.name from wlyy_admin_team t,dm_hospital h where t.org_code=h.`code` and t.available=1 ";
            if (StringUtils.isNotBlank(area)) {
                teamSql = teamSql + " and h.town='" + area + "'";
            }
            List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
            return write(200, "操作成功", "data", teamList);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @ApiOperation(value = "获取综合统计数据")
    @ResponseBody
    @RequestMapping(value = "getStatisticDataList", method = RequestMethod.GET)
    public String getStatisticDataList(
            @ApiParam(name = "startDate", value = "开始时间", required = true)
            @RequestParam(value = "startDate",required = true)String startDate,
            @ApiParam(name = "endDate", value = "结束时间", required = true)
            @RequestParam(value = "endDate",required = true)String endDate,
            @ApiParam(name = "team", value = "团队", required = false)
            @RequestParam(required = false) String team,
            @ApiParam(name = "area", value = "地区", required = false)
            @RequestParam(required = false) String area,
            @ApiParam(name = "quotaStr", value = "指标字符串,多个用逗号隔开", required = true)
            @RequestParam(required = true) String quotaStr,
            @ApiParam(name="page",value="第几页,从1开始", defaultValue = "1")
            @RequestParam(required = false, defaultValue = "1")Integer page,
            @ApiParam(name="size",value="页码大小", defaultValue = "5")
            @RequestParam(required = false, defaultValue = "5")Integer size
    ){
        try {
            Map<String, Object> resultMap = new HashMap<>();
            List<Map<String, Object>>  teamList = new ArrayList<>();
            teamList = statisticDataList(startDate,  endDate, team,area, quotaStr);
            int count = size;//相当于pageSize
            int total = teamList.size();
            int pageCount=total/size;
            int fromIndex = count * (page - 1);
            int toIndex = fromIndex + count;
            if (toIndex >= total) {
                toIndex = total;
            }
            if(page>pageCount+1){
                fromIndex=0;
                toIndex=0;
            }
            teamList =teamList.subList(fromIndex, toIndex);
            for(Map<String, Object> teamMap : teamList){
                teamMap.remove("id");
            }
            resultMap.put("data",teamList);
            resultMap.put("total",total);
            return write(200, "操作成功", "data",resultMap);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    public List<Map<String, Object>> statisticDataList(String startDate, String endDate,String team,String area,String quotaStr){
        Map<String,String> titleMap = getTitleMap();
        String teamSql = "SELECT t.id ,t.name ,h.town,h.town_name from wlyy_admin_team t,dm_hospital h where t.org_code=h.`code` and t.available=1 ";
        if(StringUtils.isNotEmpty(team)){
            teamSql += " and t.id = " + team;
        }
        if(StringUtils.isNotEmpty(area)){
            teamSql += " and (h.city='"+area+"' or h.town='" + area+"')";
        }
        //1.5.7追加所有团队的指标统计
        Map<String, Object> totalMap=new HashMap<>();
        totalMap.put("name","所有团队");
        totalMap.put("town_name","合计");
        totalMap.put("town","");
        totalMap.put("id","totalTeam");
        List<Map<String, Object>>  teamList = jdbcTemplate.queryForList(teamSql);
        teamList.add(0,totalMap);
        String [] quotas = quotaStr.split(",");
        if(quotas.length > 0){
            for(int i=0 ;i < quotas.length; i++ ){
                String quotaId = quotas[i];
                String quota = titleMap.get(quotaId).split("&")[0];
                String quotaName = titleMap.get(quotaId).split("&")[1];
                if(quota.contains("quotaCode")){
                    String initalStr = "";
                    if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){
                        initalStr += " where quotaDate >= '" + startDate + "T00:00:00+0800'" + " and quotaDate <= '" + endDate + "T23:59:59+0800'";
                    }
                    if(StringUtils.isNotEmpty(team)){
                        initalStr += " and team = '" + team + "'";
                    }
                    if(StringUtils.isNotEmpty(area)){
                        initalStr += " and town = '" + area + "'";
                    }
                    String quotaCodeAndWhere = quota.substring(quota.indexOf("quotaCode="));
                    String filter = "";
                    String quotaCode = "";
                    if(quotaCodeAndWhere.contains("-")){
                        quotaCode = quotaCodeAndWhere.split("-")[0];
                        filter = " and " + quotaCodeAndWhere.split("-")[1];
                    }else {
                        quotaCode = quotaCodeAndWhere;
                    }
                    filter += " and " + quotaCode;
                    String sql = "select sum(result1) result from  " + esIndex + initalStr + filter + " and timeLevel = '1'  and areaLevel='5'  group by team,teamName";
                    List<Map<String, Object>> dataList = elasticsearchUtil.excuteDataModel(sql);
                    teamList = dataListIntegration(totalMap,teamList,dataList,quotaName,"team");
                }else  if(quota.contains("elasticSearch")){
                    String initalStr = "";
                    if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){
                        initalStr += " where userType =1 and createTime >= '" + startDate + "T00:00:00+0800'" + " and createTime <= '" + endDate + "T23:59:59+0800'";
                    }
                    if(StringUtils.isNotEmpty(team)){
                        initalStr += " and adminTeamCode = '" + team + "'";
                    }
                    if(StringUtils.isNotEmpty(area)){
                        initalStr += " and town = '" + area + "'";
                    }
                    String esIndexAndWhere = quota.substring(quota.indexOf("elasticSearch="));
                    String filter = "";
                    String indexStr = "";
                    if(esIndexAndWhere.contains("-")){
                        indexStr = esIndexAndWhere.split("-")[0];
                        String index =indexStr.split("=")[1].trim();
                        List<Map<String, Object>> esDataList = new ArrayList<>();
                        if(esIndexAndWhere.split("-")[1].contains("=")){
                            filter = esIndexAndWhere.split("-")[1];
                            String sql = "select count(*) result from  " + index + initalStr + " and " + filter + " group by adminTeamCode,adminTeamName";
                            esDataList = elasticsearchUtil.excuteDataModel(sql);
                        }else if(esIndexAndWhere.split("-")[1].contains("count")){
                            String sql = "select count(*) result from  " + index + initalStr + " and " + " group by adminTeamCode,adminTeamName";
                            esDataList = elasticsearchUtil.excuteDataModel(sql);
                        }else if(esIndexAndWhere.split("-")[1].contains("personCount")){
                            // 团队循环
                        }
                        teamList = dataListIntegration(totalMap,teamList,esDataList,quotaName,"adminTeamCode");
                    }
                }else  if(quota.contains("mysql")){
                    String mysqlAndWhere = quota.substring(quota.indexOf("mysql="));
                    String code = mysqlAndWhere.split("=")[1];
                    if(code.equals("xiamenIjiankang2")){
                        //线上长处方(完成数)
                        List<Map<String, Object>> prescriptionList = integratedqueryService.getTeamPrescriptionCount(startDate, endDate,team,area);
                        teamList = dataListIntegration(totalMap,teamList,prescriptionList,quotaName,"team");
                    }else if(code.equals("24Exception")){
                        //24 小时设备异常数
                        List<Map<String, Object>> exceptionList = integratedqueryService.getDevice24ExceptionCount(startDate, endDate, team,area);
                        teamList = dataListIntegration(totalMap,teamList,exceptionList,quotaName,"team");
                    }else if(code.equals("patientBirthday")) {
                        //生日人数
                        List<Map<String, Object>> birthdayList = integratedqueryService.getPatientBirthdayCount(startDate, endDate, team,area);
                        teamList = dataListIntegration(totalMap,teamList,birthdayList,quotaName,"team");
                    }else if(code.equals("childFamilyImmune")) {
                        //计免绑定量
                        List<Map<String, Object>> childFamilyImmuneList = integratedqueryService.getChildFamilyImmuneCount(startDate, endDate, team,area);
                        teamList = dataListIntegration(totalMap,teamList,childFamilyImmuneList,quotaName,"team");
                    }
                }
            }
        }
        return teamList;
    }
    public  List<Map<String, Object>> dataListIntegration( Map<String, Object> totalMap,List<Map<String, Object>>  teamList,List<Map<String, Object>>  dataList,String quotaName,String teamCloumn){
        DecimalFormat df = new DecimalFormat("###");
        Double total=0.00;
        List<Map<String, Object>>  resultList=new ArrayList<>();
        for(Map<String, Object> teamMap : teamList){
            String teamId = teamMap.get("id").toString();
            boolean exit = false;
            if(dataList != null && dataList.size() > 0){
                for(Map<String, Object> dataMap : dataList){
                    if(dataMap.get(teamCloumn)!= null && dataMap.get(teamCloumn).toString().equals(teamId)){
                        if(dataMap.get("result") != null){
                            String result = df.format(Double.valueOf(dataMap.get("result").toString()));
                            total=total+Double.valueOf(dataMap.get("result").toString());
                            teamMap.put(quotaName,result);
                            exit = true;
                            break;
                        }else if(dataMap.get("count") != null){
                            String result = df.format(Double.valueOf(dataMap.get("count").toString()));
                            total=total+Double.valueOf(dataMap.get("count").toString());
                            teamMap.put(quotaName,result);
                            exit = true;
                            break;
                        }
                    }
                }
            }
            if( !exit){
                teamMap.put(quotaName,0);
            }
            resultList.add(teamMap);
        }
        //1.5.7追加合计
        totalMap.put(quotaName,df.format(total));
        return resultList;
    }
    //报表导出
    @ApiOperation("数据文件导出")
    @RequestMapping(value="export",method = RequestMethod.GET,produces = "application/json;charset=UTF-8" )
    public void export(
            @ApiParam(name = "startDate", value = "开始时间", required = false)
            @RequestParam(value = "startDate",required = false)String startDate,
            @ApiParam(name = "endDate", value = "结束时间", required = false)
            @RequestParam(value = "endDate",required = false)String endDate,
            @ApiParam(name = "team", value = "团队", required = false)
            @RequestParam(required = false) String team,
            @ApiParam(name = "area", value = "地区", required = false)
            @RequestParam(required = false) String area,
            @ApiParam(name = "quotaStr", value = "指标字符串,多个用逗号隔开", required = true)
            @RequestParam(required = true) String quotaStr,
            HttpServletResponse response){
        try {
            String fileName = "综合指标查询";
            response.setContentType("octets/stream");
            response.setCharacterEncoding("utf-8");
            fileName = URLEncoder.encode(fileName, "utf-8");
            response.setHeader("Content-Disposition", "attachment; filename="+ fileName + new String(".xls"));
            OutputStream os = response.getOutputStream();
            Map<Integer,String> columnMap = new HashMap<>();
            WorkbookUtil workbookUtil = new WorkbookUtil();
            List<Map<String,Object>> listMap = new ArrayList<>();
            listMap = statisticDataList(startDate,  endDate, team,area, quotaStr);
            Map<String,String> titleMap = getTitleMap();
            String [] quotas = quotaStr.split(",");
            String[] header = new  String[quotas.length+1];
            header[0] = "团队";
            columnMap.put(0,"name");
            if(quotas.length > 0) {
                for (int i = 0; i < quotas.length; i++) {
                    String quotaId = quotas[i];
//                    String quota = titleMap.get(quotaId).split("&")[0];
                    String quotaName = titleMap.get(quotaId).split("&")[1];;
                    header[i+1] = quotaName;
                    columnMap.put(i+1,quotaName);
                }
            }
            workbookUtil.write(Workbook.createWorkbook(os), listMap, columnMap, header);
        }catch (Exception ex){
            error(ex);
        }
    }
}
*/

+ 60 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/messager/MessagerController.java

@ -0,0 +1,60 @@
package  com.yihu.customer.controller.manager.messager;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.consult.WlyyConsultTeamExportVO;
import com.yihu.customer.service.messager.MessagerServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/message/doctor", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "消息回复")
public class MessagerController extends BaseController {
    @Autowired
    MessagerServer messagerServer;
    @RequestMapping(value = "getMessageNoReply", method = RequestMethod.GET)
    @ApiOperation("咨询未及时回复  明细列表")
    public String getMessageNoReply(
            @ApiParam(name = "startDate", value = "开始时间", required = true)
            @RequestParam(value = "startDate", required = true) String startDate,
            @ApiParam(name = "endDate", value = "结束时间", required = true)
            @RequestParam(value = "endDate", required = true) String endDate,
            @ApiParam(name = "team", value = "团队", required = false)
            @RequestParam(required = false) String team,
            @ApiParam(name = "area", value = "地区", required = false)
            @RequestParam(required = false) String area,
            @ApiParam(name = "hospital", value = "医院", required = false)
            @RequestParam(required = false) String hospital,
            @ApiParam(name = "page", value = "第几页,从1开始", defaultValue = "1")
            @RequestParam(required = false, defaultValue = "1") Integer page,
            @ApiParam(name = "size", value = "页码大小", defaultValue = "10")
            @RequestParam(required = false, defaultValue = "10") Integer size,
            @ApiParam(name = "range", value = "数据范围(town区,hospital医院,team团队)", required = true)
            @RequestParam(required = true) String range) {
        try {
            List<WlyyConsultTeamExportVO> consultTeams = messagerServer.exportReplyDelayList(startDate, endDate, team, area, hospital, range, page, size);
            List<WlyyConsultTeamExportVO> consultTeamsSize = messagerServer.exportReplyDelayList(startDate, endDate, team, area, hospital, range, page, 0);
            JSONObject object = new JSONObject();
            object.put("consultTeams", consultTeams);
            object.put("consultTeamsSize", consultTeamsSize.size());
            return write(200, "查询成功", "data", object);
        } catch (Exception ex) {
            error(ex);
            return write(-1, "查询失败");
        }
    }
}

+ 361 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/NotificationController.java

@ -0,0 +1,361 @@
package  com.yihu.customer.controller.manager.notification;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.User;
import  com.yihu.customer.entity.WlyyAuditNotice;
import  com.yihu.customer.entity.WlyyAuditNoticeScope;
import com.yihu.customer.service.manager.notification.WlyyAuditNoticeScopeService;
import com.yihu.customer.service.manager.notification.WlyyAuditNoticeService;
import com.yihu.customer.service.manager.wlyyrole.WlyyUserRoleService;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * Created by yww on 2017/1/22.
 */
@Controller
@RequestMapping("/admin/notification")
public class NotificationController extends BaseController {
    @Autowired
    private WlyyAuditNoticeService wlyyAuditNoticeService;
    @Autowired
    private WlyyAuditNoticeScopeService wlyyAuditNoticeScopeService;
    @Autowired
    private WlyyUserRoleService wlyyUserRoleService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    @ApiIgnore
    public String notificationListInitial(Model model) {
        User currentUser = (User) request.getSession().getAttribute("current_user");
        model.addAttribute("isAuditor", wlyyAuditNoticeService.isAuditor(currentUser));
        return "notification/notification_list";
    }
    //跳转消息通知详情页
    @RequestMapping(value = "view", method = RequestMethod.GET)
    @ApiIgnore
    public String notificationView(Model model, @RequestParam(value = "id", required = true) Long id, String mode) {
        User currentUser = (User) request.getSession().getAttribute("current_user");
        WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
        WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeService.findByNoticeId(id);
        model.addAttribute("notice", notice);
        model.addAttribute("noticeId", notice.getId());
        model.addAttribute("title", notice.getTitle());
        model.addAttribute("status", notice.getStatus());
        model.addAttribute("time", notice.getSendTime());
        model.addAttribute("scope", notice.getConditionDescription());
        model.addAttribute("content", notice.getContent());
        model.addAttribute("totalCount", "总共 " + notice.getTotalCount() + " 人");
        model.addAttribute("isAuditor", wlyyAuditNoticeService.isAuditor(currentUser));
        model.addAttribute("isOwned", false);//页面判断用于显示操作按钮
        if (StringUtils.equals(notice.getApplyUserId(), currentUser.getCode())) {
            model.addAttribute("isOwned", true);
        }
        if (noticeScope != null) {
            if (!StringUtils.isEmpty(noticeScope.getServerTypeContent())) {
                model.addAttribute("serverTypeContent", noticeScope.getServerTypeContent());
            }
            if (!StringUtils.isEmpty(noticeScope.getHealthSituationContent())) {
                model.addAttribute("healthSituationContent", noticeScope.getHealthSituationContent());
            }
            if (!StringUtils.isEmpty(noticeScope.getDiseaseTypeContent())) {
                model.addAttribute("diseaseTypeContent", noticeScope.getDiseaseTypeContent());
            }
        }
        model.addAttribute("mode",mode);
        return "notification/notification_view";
    }
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    public String searchNotificationList(
            @ApiParam(name = "searchNm", value = "标题/提交人名")
            @RequestParam(value = "searchNm", required = false) String searchNm,
            @ApiParam(name = "status", value = "状态")
            @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "page")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "rows")
            @RequestParam(value = "rows") int pageSize) {
        try {
            User currentUser = (User) request.getSession().getAttribute("current_user");
            Page<WlyyAuditNotice> notices = wlyyAuditNoticeService.searchList(searchNm, status, currentUser, page, pageSize);
            return write(200, "操作成功", page, pageSize, notices);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    //页面跳转(详情页面)
    @RequestMapping(value ="infoInit/{id}",method = RequestMethod.GET)
    public String infoInit(@PathVariable("id") Long id, String mode){
        if(id==0){
            request.setAttribute("UUID", UUID.randomUUID().toString().replace("-", ""));
        }
        User currentUser = (User) request.getSession().getAttribute("current_user");
        //范围权限
        String city = "350200";
        String cityAuthority = "0";
        String areaAuthority = "0";
        String communityAuthority = "0";
        List<Map<String, String>> roleMap = (List<Map<String, String>>)request.getSession().getAttribute("roleMap");
        if(roleMap.size()>0){//管理员
            for (Map<String, String> map : roleMap){
                String code = map.get("code");
                if(city.equals(code)){
                    cityAuthority = "1";
                    areaAuthority = "1";
                    communityAuthority = "1";
                }else if(code.length()==6){
                    areaAuthority = "1";
                    communityAuthority = "1";
                }else {
                    communityAuthority = "1";
                }
            }
        }else{
            //社区医生
            communityAuthority = "2";
        }
        request.setAttribute("cityAuthority", cityAuthority);
        request.setAttribute("areaAuthority", areaAuthority);
        request.setAttribute("communityAuthority", communityAuthority);
        request.setAttribute("id", id);
        request.setAttribute("mode",mode);
        request.setAttribute("isAuditor", wlyyAuditNoticeService.isAuditor(currentUser));
        return "notification/notification_edit";
    }
    //根据id获取单个
    @RequestMapping(value = "notice")
    @ResponseBody
    public String getNotice(@RequestParam(value = "id") Long id){
        try {
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeService.findByNoticeId(id);
            JSONObject json = new JSONObject();
            json.put("noticeId",notice.getId());
            json.put("title",notice.getTitle());
            json.put("content",notice.getContent());
            json.put("sendTime",notice.getSendTime());
            json.put("sendType",notice.getSendType());
            json.put("scope",noticeScope.getScope());
            json.put("scopeId",noticeScope.getScopeId());
            json.put("condition",noticeScope.getCondition());
            json.put("diseaseTypeId",noticeScope.getDiseaseTypeId());
            json.put("healthSituationId",noticeScope.getHealthSituationId());
            json.put("serverTypeId",noticeScope.getServerTypeId());
            return write(200,"操作成功!","data",json);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 是否有有审核权限
     * @return
     */
    @RequestMapping(value = "isNoticeAuditor")
    @ResponseBody
    public String isNoticeAuditor(){
        try {
            User currentUser = (User) request.getSession().getAttribute("current_user");
            boolean flag = wlyyAuditNoticeService.isNoticeAuditor(currentUser.getCode(),String.valueOf(currentUser.getOrganizationId()));
            if(flag){
                return write(200,"有权限!","authority","1");
            }
            return write(200,"没权限!","authority","0");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //新增
    @RequestMapping(value = "create")
    @ResponseBody
    public String createNotice(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Map<String,String> map = objectMapper.readValue(jsonData, Map.class);
            User currentUser = (User) request.getSession().getAttribute("current_user");
            wlyyAuditNoticeService.create(map, currentUser);
            return success("新增成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "新增失败!");
        }
    }
    /**
     * 提交
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "submit")
    @ResponseBody
    public String submit(
            @RequestParam(value = "id", required = true) Long id) {
        try {
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            User currentUser = (User) request.getSession().getAttribute("current_user");
            //判断是否为审核者(审核者只能看到非本人的待审核通知,看不到待提交通知)
            if (!StringUtils.equals("1", notice.getStatus())) {
                return error(-1, "提交状态的消息通知才能进行提交操作!");
            }
            boolean res = wlyyAuditNoticeService.isAuditor(currentUser);
            if (res) {
                //审核者自己的消息通知,直接通过+发信息+保存发送对象信息
                wlyyAuditNoticeService.approve(id, notice, currentUser);
                return write(200, "操作成功");
            } else {
                notice.setStatus("2");
                wlyyAuditNoticeService.save(notice);
                return write(200, "操作成功");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 撤回
     * @param id
     * @return
     */
    @RequestMapping(value = "revoke")
    @ResponseBody
    public String revoke(
            @RequestParam(value = "id", required = true) Long id){
        try {
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            if("2".equals(notice.getStatus())){//待审核
                notice.setStatus("6");//撤回
                wlyyAuditNoticeService.save(notice);
            }else{
                return error(-1, "撤回失败,只有待审核才能撤回!");
            }
            return success("撤回成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "撤回失败!");
        }
    }
    //修改
    @RequestMapping(value = "update")
    @ResponseBody
    public String updateNotice(String jsonData){
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Map<String,String> map = objectMapper.readValue(jsonData, Map.class);
            User currentUser = (User) request.getSession().getAttribute("current_user");
            wlyyAuditNoticeService.updateNotice(map, currentUser);
            return success("修改成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "修改失败!");
        }
    }
    //删除
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deleteNotification(long id) {
        try {
            User currentUser = (User) request.getSession().getAttribute("current_user");
            //是本人的消息通知才能删除
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            if (notice == null) {
                return error(-1, "id有误!");
            }
            if (!StringUtils.equals(notice.getApplyUserId(), currentUser.getCode())) {
                return error(-1, "非本人的消息通知,没有权限删除!");
            }
            wlyyAuditNoticeService.deleteNotice(id);
            return write(200, "操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //审核通过
    @RequestMapping(value = "approve")
    @ResponseBody
    public String approve(long id) {
        try {
            User currentUser = (User) request.getSession().getAttribute("current_user");
            //验证消息通知为待审核
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            if (notice == null) {
                return error(-1, "提供的id有误!");
            }
            if (!StringUtils.equals("2", notice.getStatus())) {
                return error(-1, "消息状态不符,待审核状态才能进行审核操作!");
            }
            String auditorCode = currentUser.getCode();
            String noticeHospital = notice.getApplyUserHospital();
            if (StringUtils.isEmpty(noticeHospital)) {
                return error(-1, "消息通知机构信息有误,为空值!");
            }
            //审核权限验证(审核者的下辖机构有此消息通知编辑者所属机构)
            boolean res = wlyyAuditNoticeService.isNoticeAuditor(auditorCode, noticeHospital);
            wlyyAuditNoticeService.approve(id, notice, currentUser);
            return write(200, "操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "refuse")
    @ResponseBody
    public String refuse(
            @RequestParam(value = "id", required = true) Long id) {
        try {
            if (id == null) {
                return error(-1, "id不能为空!");
            }
            User currentUser = (User) request.getSession().getAttribute("current_user");
            //是本人的消息通知才能删除
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            if (notice == null) {
                return error(-1, "id有误!");
            }
            notice.setStatus("5");
            wlyyAuditNoticeService.save(notice);
            return write(200, "操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 234 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/PlatformInformationController.java

@ -0,0 +1,234 @@
/*
package com.yihu.jw.controller.manager.notification;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.controller.WeixinBaseController;
import com.yihu.jw.entity.platformInformation.PlatformInformationDO;
import com.yihu.jw.service.manager.platformInformation.PlatformInformationService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@Controller
@RequestMapping(value = "/admin/platformInfomation", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class PlatformInformationController extends WeixinBaseController {
    @Autowired
    private PlatformInformationService platformInformationService;
    @Autowired
    private ObjectMapper objectMapper;
    //图片服务地址
    @Value("${fastDFS.fastdfs_file_url}")
    private String imgUrlDomain;
    */
/**
     * 列表页面初始化数据
     *//*
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String listInitial() {
        return "platformInformation/platform_information_list";
    }
    @RequestMapping(value = "initial/{id}", method = RequestMethod.GET)
    public String listInitial2(@PathVariable(value = "id") String id) {
        return "platformInformation/platform_information_list";
    }
    @RequestMapping(value = "denizenArticle", method = RequestMethod.GET)
    public String denizenArticle() {
        request.setAttribute("imgUrlDomain", imgUrlDomain);
        return "platformInformation/denizenArticle";
    }
    @RequestMapping(value = "doctorArticle", method = RequestMethod.GET)
    public String doctorArticle() {
        request.setAttribute("imgUrlDomain", imgUrlDomain);
        return "platformInformation/doctorArticle";
    }
    @RequestMapping(value = "denizenArticle/{id}", method = RequestMethod.GET)
    public String denizenArticle2(@PathVariable(value = "id") String id) {
        request.setAttribute("imgUrlDomain", imgUrlDomain);
        return "platformInformation/denizenArticle";
    }
    @RequestMapping(value = "doctorArticle/{id}", method = RequestMethod.GET)
    public String doctorArticle2(@PathVariable(value = "id") String id) {
        request.setAttribute("imgUrlDomain", imgUrlDomain);
        return "platformInformation/doctorArticle";
    }
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ApiOperation(value = "获取平台咨讯列表")
    @ResponseBody
    public String list(
            @RequestParam(value = "sendingObjects", required = false) Integer sendingObjects,
            @RequestParam(value = "title", required = false) String title,
            @RequestParam(value = "type", required = false) Integer type,
            @RequestParam(value = "isNotice", required = false) Integer isNotice,
            @RequestParam(value = "sendType", required = false) Integer sendType,
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(value = "page") Integer page,
            @RequestParam(value = "pagesize") Integer pageSize) {
        try {
            Page<PlatformInformationDO> platformInformationDOS = platformInformationService.searchList(sendingObjects, title, type, isNotice, sendType, startDate, endDate, page, pageSize);
            return write(200, "获取成功", page, pageSize, platformInformationDOS);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "uploadImg", method = RequestMethod.POST)
    @ApiOperation(value = "上传图片")
    @ResponseBody
    public String uploadImg(HttpServletRequest request) {
        try {
            Map<String, Object> map = platformInformationService.uploadImg(request);
            return write(200, "上传成功!", "data", map);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "上传失败!");
        }
    }
    @RequestMapping(value = "create",method = RequestMethod.POST)
    @ApiOperation(value = "创建平台咨讯")
    @ResponseBody
    public String create(String jsonData, HttpServletRequest req) {
        try {
            String token = getAccessToken();
            System.out.println("token : " + token);
            platformInformationService.create(jsonData, token, String.valueOf(req.getSession().getAttribute("code")));
            return write(200, "创建成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "创建失败");
        }
    }
    @RequestMapping(value = "update",method = RequestMethod.POST)
    @ApiOperation("更新平台咨讯")
    @ResponseBody
    public String update(String jsonData, HttpServletRequest req) {
        try {
            platformInformationService.update(jsonData, String.valueOf(req.getSession().getAttribute("code")));
            return write(200, "更新成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "更新失败");
        }
    }
    @RequestMapping(value = "preview",method = RequestMethod.GET)
    @ApiOperation("预览详情")
    @ResponseBody
    public String preview(Long id) {
        try {
            Map<String, Object> map = platformInformationService.preview(id);
            return write(200, "获取成功", "data", map);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "send",method = RequestMethod.POST)
    @ApiOperation("更新平台咨讯")
    @ResponseBody
    public String send(Long id,Integer sendStatus, HttpServletRequest req) {
        try {
            platformInformationService.send(id,sendStatus, String.valueOf(req.getSession().getAttribute("code")));
            return write(200, "发送成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "发送失败");
        }
    }
    @RequestMapping(value = "findPatientLabel",method = RequestMethod.GET)
    @ApiOperation("查找居民标签")
    @ResponseBody
    public String findPatientLabel() {
        try {
            return write(200, "查找成功", "data", platformInformationService.findPatientLabel());
        } catch (Exception ex) {
            error(ex);
            return error(-1, "查找失败");
        }
    }
    @RequestMapping(value = "findInformationLabel",method = RequestMethod.GET)
    @ApiOperation("查找咨讯标签")
    @ResponseBody
    public String findInformationLabel() {
        try {
            return write(200, "查找成功", "data", platformInformationService.findInformationLabel());
        } catch (Exception ex) {
            error(ex);
            return error(-1, "查找失败");
        }
    }
    @RequestMapping(value = "findById",method = RequestMethod.GET)
    @ApiOperation("查看详情")
    @ResponseBody
    public String findById(Long id) {
        try {
            return write(200, "获取成功", "data", platformInformationService.findById(id));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "findInformationVideoClassify",method = RequestMethod.GET)
    @ApiOperation("查找咨讯视频标签")
    @ResponseBody
    public String findInformationVideoClassify(Integer type) {
        try {
            return write(200, "查找成功", "data", platformInformationService.findInformationVideoClassify(type));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "查找失败");
        }
    }
    @RequestMapping(value = "/undoArticle",method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    @ApiOperation("平台咨讯--撤销")
    @ResponseBody
    public String undoArticle(Long id, String reason, HttpServletRequest req) {
        try {
            PlatformInformationDO platformInformationDO = platformInformationService.undoOperation(id, String.valueOf(req.getSession().getAttribute("code")), reason);
            return write(200, "撤回成功", "data", platformInformationDO);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "撤回失败");
        }
    }
    @RequestMapping(value = "findPlatformInformationClassify",method = RequestMethod.GET)
    @ApiOperation("查找平台咨讯树状全部分类")
    @ResponseBody
    public String findPlatformInformationClassify() {
        try {
            return write(200, "查找成功", "data", platformInformationService.findPlatformInformationClassify());
        } catch (Exception ex) {
            error(ex);
            return error(-1, "查找失败");
        }
    }
}
*/

+ 195 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/WechatTemplateController.java

@ -0,0 +1,195 @@
package  com.yihu.customer.controller.manager.notification;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.wechat.WechatTemplateConfig;
import com.yihu.customer.service.manager.wechat.WechatTemplateService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
/**
* @Description: 微信模板管理
* @Author: WuJunjie
* @Date: Created in 2018/3/20 9:07
*/
@Controller
@RequestMapping("/admin/wechatTemplate")
public class WechatTemplateController extends BaseController {
    @Autowired
    private WechatTemplateService wechatTemplateService;
    /**
     * 列表页面初始化数据
     * @param model
     * @return
     */
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    @ApiIgnore
    public String listInitial(Model model) {
        return "wechat/wechat_list";
    }
    /**
     * 编辑、查看、新增页面初始化数据
     * @param
     * @return
     */
    @RequestMapping(value = "editInitial", method = RequestMethod.GET)
    @ApiIgnore
    public String editInitial(String templateName,String scene,String mode) {
        request.setAttribute("templateName",templateName);
        request.setAttribute("scene",scene);
        request.setAttribute("mode",mode);
        return "wechat/wechat_edit";
    }
    /**
     * 根据模板自定义名称和场景值查询模板消息
     * @param templateName
     * @param scene
     * @param page
     * @param pageSize
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    public String searchNotificationList(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = false) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = false) String scene,
            @ApiParam(name = "page")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "rows")
            @RequestParam(value = "rows") int pageSize) {
        try {
            List<WechatTemplateConfig> templetes = wechatTemplateService.searchList(templateName, scene, page, pageSize);
            int count = wechatTemplateService.getListCount(templateName, scene);
            return write(200, "操作成功", page, pageSize,count, templetes);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 根据模板自定义名称和场景值查询模板消息详情
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "getTemplate", method = RequestMethod.POST)
    @ResponseBody
    public String getTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = true) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = true) String scene) {
        try {
            List<Map<String,Object>> templete = wechatTemplateService.getTemplate(templateName, scene);
            return write(200, "操作成功", "data",templete);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 修改模板详情
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "updateTemplate", method = RequestMethod.POST)
    @ResponseBody
    public String updateTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = true) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = true) String scene,
            @ApiParam(name = "sceneDescription", value = "模板场景描述")
            @RequestParam(value = "sceneDescription", required = true) String sceneDescription,
            @ApiParam(name = "first", value = "first")
            @RequestParam(value = "first", required = false) String first,
            @ApiParam(name = "remark", value = "remark")
            @RequestParam(value = "remark", required = false) String remark,
            @ApiParam(name = "value1", value = "value1")
            @RequestParam(value = "value1", required = false) String value1,
            @ApiParam(name = "value2", value = "value2")
            @RequestParam(value = "value2", required = false) String value2,
            @ApiParam(name = "value3", value = "value3")
            @RequestParam(value = "value3", required = false) String value3,
            @ApiParam(name = "value4", value = "value4")
            @RequestParam(value = "value4", required = false) String value4,
            @ApiParam(name = "value5", value = "value5")
            @RequestParam(value = "value5", required = false) String value5,
            @ApiParam(name = "value6", value = "value6")
            @RequestParam(value = "value6", required = false) String value6,
            @ApiParam(name = "value7", value = "value7")
            @RequestParam(value = "value7", required = false) String value7) {
        try {
            wechatTemplateService.updateTemplate(templateName, scene,sceneDescription,first,remark,
                    value1,value2,value3,value4,value5,value6,value7);
            return write(200, "操作成功", "data","");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 新增模板详情
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "saveTemplate", method = RequestMethod.POST)
    @ResponseBody
    public String saveTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = true) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = true) String scene,
            @ApiParam(name = "sceneDescription", value = "模板场景描述")
            @RequestParam(value = "sceneDescription", required = true) String sceneDescription,
            @ApiParam(name = "first", value = "first")
            @RequestParam(value = "first", required = false) String first,
            @ApiParam(name = "remark", value = "remark")
            @RequestParam(value = "remark", required = false) String remark,
            @ApiParam(name = "value1", value = "value1")
            @RequestParam(value = "value1", required = false) String value1,
            @ApiParam(name = "value2", value = "value2")
            @RequestParam(value = "value2", required = false) String value2,
            @ApiParam(name = "value3", value = "value3")
            @RequestParam(value = "value3", required = false) String value3,
            @ApiParam(name = "value4", value = "value4")
            @RequestParam(value = "value4", required = false) String value4,
            @ApiParam(name = "value5", value = "value5")
            @RequestParam(value = "value5", required = false) String value5,
            @ApiParam(name = "value6", value = "value6")
            @RequestParam(value = "value6", required = false) String value6,
            @ApiParam(name = "value7", value = "value7")
            @RequestParam(value = "value7", required = false) String value7) {
        try {
            Map<String,Object> result = wechatTemplateService.saveTemplate(templateName, scene,sceneDescription,first,remark,
                    value1,value2,value3,value4,value5,value6,value7);
            int code = Integer.parseInt(result.get("code").toString());
            String msg = result.get("msg").toString();
            return write(code, msg);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
}

+ 7 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/WlyyAuditNoticeController.java

@ -0,0 +1,7 @@
package  com.yihu.customer.controller.manager.notification;
/**
 * Created by Administrator on 2017/1/22.
 */
public class WlyyAuditNoticeController {
}

+ 7 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/WlyyAuditNoticeObjectController.java

@ -0,0 +1,7 @@
package  com.yihu.customer.controller.manager.notification;
/**
 * Created by Administrator on 2017/1/22.
 */
public class WlyyAuditNoticeObjectController {
}

+ 8 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/notification/WlyyAuditNoticeScopeController.java

@ -0,0 +1,8 @@
package  com.yihu.customer.controller.manager.notification;
/**
 * Created by Administrator on 2017/1/22.
 */
public class WlyyAuditNoticeScopeController {
}

+ 314 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/patient/AdminPatientController.java

@ -0,0 +1,314 @@
package  com.yihu.customer.controller.manager.patient;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.Patient;
import com.yihu.customer.service.manager.patient.AdminPatientService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.util.UUID;
/**
 * Created by yww on 2016/10/8.
 * 后台管理 患者信息维护
 */
@Controller
@RequestMapping(value="admin/patient")
public class AdminPatientController extends BaseController {
    @Autowired
    private AdminPatientService adminPatientService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ObjectMapper objectMapper;
    //患者列表页跳转
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String listInit(){
        return "patient/patient_list";
    }
    //患者详情页跳转(uuid)
    @RequestMapping(value="infoInit/{id}",method = RequestMethod.GET)
    public String InfoInit(Model model, @PathVariable("id") Long id, String mode) throws Exception {
        model.addAttribute("patient", "{}");
        if(id==0){
            request.setAttribute("UUID", UUID.randomUUID().toString().replace("-", ""));
            model.addAttribute("UUID", UUID.randomUUID().toString().replace("-", ""));
        }
        if (id > 0) {
            Patient patient = adminPatientService.getPatient(id);
            if (patient != null)
                model.addAttribute("patient", objectMapper.writeValueAsString(patient));
        }
        request.setAttribute("mode", mode);
        request.setAttribute("id",id);
        return "patient/patient_modify";
    }
    //获取患者列表
    @RequestMapping(value = "patientList")
    @ResponseBody
    public String searchPatientList(
            String name,String idcard,String ssc,String mobile,Integer openIdStatus,String openid, int page,int rows){
        try {
            Page<Patient> patients = adminPatientService.searchPatientList(name, idcard, ssc,mobile,openIdStatus, openid, page, rows);
            return write(200,"操作成功",page,rows,patients);
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    //根据id获取
    @RequestMapping(value = "patient")
    @ResponseBody
    public String getPatient(Long id){
        try{
            Patient patient = adminPatientService.getPatient(id);
            return write(200,"操作成功","patient",patient);
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    //新增
    @RequestMapping(value = "create")
    @ResponseBody
    public String createPatient(String jsonData){
        try{
            ObjectMapper objectMapper = new ObjectMapper();
            Patient patient = objectMapper.readValue(jsonData,Patient.class);
            String msg = "";
            if(StringUtils.isEmpty(patient.getName())){
                msg += "姓名不能为空;";
            }
            if(StringUtils.isEmpty(patient.getIdcard())){
                msg += "身份证不能为空;";
            }
            if(StringUtils.isEmpty(patient.getSsc())){
                msg += "社保卡不能为空;";
            }
            if(!StringUtils.isEmpty(msg)){
                return error(-1,msg);
            }
//            String idcard = patient.getIdcard();
//            if(idcard == null){
//                return error(-1,"身份证不能为空!");
//            }
//            //姓名+身份证号+社保卡号 检验
//            SocialSecurityInfo info = adminPatientService.findSocialSecurityInfo(idcard);
//            boolean flag = true;
//            if(StringUtils.equals(info.getXming0(),patient.getName())){
//                //名字不符
//                flag = false;
//            }
//            if(StringUtils.equals(info.getCardno(),patient.getSsc()) || StringUtils.equals(info.getCard16(),patient.getSsc())){
//                //社保卡不符(两种社保卡形式)
//                flag = false;
//            }
//            if(!flag){
//                return error(-1, "姓名,身份证,社保卡信息不对应,请核对!");
//            }
            adminPatientService.createPatient(patient);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    //修改
    @RequestMapping(value = "update")
    @ResponseBody
    public String updatePatient(String jsonData){
        try{
            ObjectMapper objectMapper = new ObjectMapper();
            Patient patient = objectMapper.readValue(jsonData,Patient.class);
            String msg = "";
            if(patient.getId() ==0){
                msg += "id不能为空;";
            }
            if(StringUtils.isEmpty(patient.getName())){
                msg += "姓名不能为空;";
            }
            if(StringUtils.isEmpty(patient.getIdcard())){
                msg += "身份证不能为空;";
            }
            if(StringUtils.isEmpty(patient.getSsc())){
                msg += "社保卡不能为空;";
            }
            if(!StringUtils.isEmpty(msg)){
                return error(-1,msg);
            }
//            String idcard = patient.getIdcard();
//            if(idcard == null){
//                return error(-1,"身份证不能为空!");
//            }
//            //姓名+身份证号+社保卡号 检验
//            SocialSecurityInfo info = adminPatientService.findSocialSecurityInfo(idcard);
//            if(info == null){
//                return error(-1,"根据该身份证,没有找到相关的社保信息!");
//            }
//            boolean flag = true;//是否符合
//            if(!StringUtils.equals(info.getXming0().trim(),patient.getName().trim())){
//                //名字不符
//                flag = false;
//            }
//            if(!(StringUtils.equals(info.getCardno().trim(),patient.getSsc().trim()) || StringUtils.equals(info.getCard16().trim(),patient.getSsc().trim()))){
//                //社保卡不符(两种社保卡形式)
//                flag = false;
//            }
//            if(!flag){
//                return error(-1,"姓名,身份证,社保卡信息不对应,请核对!");
//            }
            adminPatientService.updatePatient(patient);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "updatePatientBaseInfo2")
    @ResponseBody
    public String updatePatientBaseInfo2(@RequestParam(value = "id")String id,
                                         @RequestParam(value = "name",required = false)String name,
                                         @RequestParam(value = "idcard",required = false)String idcard,
                                         @RequestParam(value = "ssc",required = false)String ssc){
        try{
            if (StringUtils.isBlank(id)){
                return error(-1,"操作失败!");
            }
            adminPatientService.updatePatientBaseInfo2(id,name,idcard,ssc);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //根据删除
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deletePatient(Long id){
        try{
            adminPatientService.deletePatient(id);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //患者死亡
    @RequestMapping(value = "death")
    @ResponseBody
    public String death(Long id){
        try{
            adminPatientService.death(id);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //手机号唯一
    @RequestMapping(value = "isMoblieExist")
    @ResponseBody
    public String isMobileExist(String mobile){
        try{
            return adminPatientService.isMobileExist(mobile);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //身份证号唯一
    @RequestMapping(value = "isIdCardExist")
    @ResponseBody
    public String isIdCardExist(String idcard){
        try{
            Patient patient = adminPatientService.findByIdcard(idcard);
            if (patient==null){
                return "false";
            }else {
                return 1==patient.getStatus()?"true":"false";
            }
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //社保卡号唯一
    @RequestMapping(value = "isSscExist")
    @ResponseBody
    public String isSscExist(String ssc){
        try{
            Patient patient = adminPatientService.findBySsc(ssc);
            if (patient==null){
                return "false";
            }else {
                return 1==patient.getStatus()?"true":"false";
            }
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //初始化密码
    @RequestMapping(value = "initPassword")
    @ResponseBody
    public String initPassword(
            @RequestParam(value = "patientId", required = true) Long patientId,
            @RequestParam(value = "idCard", required = true) String idCard) {
        try {
            boolean res = adminPatientService.initPassword(patientId, idCard);
            return res == true?write(200, "操作成功!"):error(-1, "操作失败!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "updateStatus",method = RequestMethod.POST)
    @ResponseBody
    public String updateStatus(
            @RequestParam(value = "patientId", required = true) Long patientId,
            @RequestParam(value = "status", required = true) Integer status) {
        try {
            boolean res = adminPatientService.updataStatus(status, patientId);
            return res == true?write(200, "操作成功!"):error(-1, "操作失败!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 解锁账户
     */
    @RequestMapping(value = "unlodckUser",method = RequestMethod.POST)
    @ResponseBody
    public String unlodckUser(
            @RequestParam(value = "userCode", required = true) String userCode,
            @RequestParam(value = "type", required = true) String type) {
        try {
            String sql = "delete from wlyy_user_login_log where user_code ='"+userCode+"' and login_type='"+type+"'";
            jdbcTemplate.execute(sql);
            return write(200, "操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 260 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/patient/CopdPatientController.java

@ -0,0 +1,260 @@
package  com.yihu.customer.controller.manager.patient;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.copd.CopdPatient;
import com.yihu.customer.service.manager.patient.CopdPatientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2022/1/16.
 */
@Controller
@Api(description = "慢阻肺居民")
@RequestMapping(value = "admin/copd",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class CopdPatientController extends BaseController {
    @Autowired
    private CopdPatientService copdPatientService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String listInit(){
        return "patient/copd_patient_list";
    }
    @RequestMapping(value = "addInit", method = RequestMethod.GET)
    public String addInit(){
        return "patient/copd_patient_add";
    }
    //编辑页面
    @RequestMapping(value = "updateInit/{patient}", method = RequestMethod.GET)
    public String updateInit(@PathVariable("patient") String patient,
                             @RequestParam(value = "hospital",required = false)String hospital) {
        try {
            request.setAttribute("patient", patient);
            request.setAttribute("hospitalId", hospital);
            request.setAttribute("type", request.getParameter("type"));
        } catch (Exception e) {
            error(e);
        }
        return "patient/copd_patient_modify";
    }
    @RequestMapping(value = "getPatientList", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取慢阻肺患者列表")
    public String getPatientList(@RequestParam(value = "name", required = false)String name,
                                 @RequestParam(value = "idcard", required = false)String idcard,
                                 @RequestParam(value = "mobile", required = false)String mobile,
                                 @RequestParam(value = "hospitalName", required = false)String hospitalName,
                                 @RequestParam(value = "doctorName", required = false)String doctorName,
                                 @RequestParam(value = "page", required = true) Integer page,
                                 @RequestParam(value = "rows", required = true) Integer rows) {
        try {
            Page<CopdPatient> result = copdPatientService.getPatientList(name,idcard,mobile,hospitalName,doctorName,page,rows);
            return write(200, "查询成功", page, rows, result);
        } catch (Exception e) {
            error(e);
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "updateCopdPatient", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("保存慢阻肺患者修改")
    public String updateCopdPatient(@RequestParam(value = "json", required = false)String json) {
        try {
            return write(200, "保存成功", "data",copdPatientService.updateCopdPatient(json));
        } catch (Exception e) {
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "getCopdPatientInfo", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取慢阻肺患者列表")
    public String getCopdPatientInfo(@RequestParam(value = "patient", required = false)String patient) {
        try {
            CopdPatient copdPatient = copdPatientService.getCopdPatientInfo(patient);
            if (null==copdPatient){
                return error(-1,"未获取到慢阻肺居民信息");
            }
            return write(200, "查询成功", "data",copdPatient);
        } catch (Exception e) {
            error(e);
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "initCopdPatient", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("慢阻肺居民还原(未管理状态)")
    public String initCopdPatient(@RequestParam(value = "patient", required = false)String patient) {
        try {
            return write(200, "操作成功", "data",copdPatientService.initCopdPatient(patient));
        } catch (Exception e) {
            error(e);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "initSecondScreening", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("慢阻肺居民二次排纳还原")
    public String initSecondScreening(@RequestParam(value = "patient", required = false)String patient) {
        try {
            return write(200, "操作成功", "data",copdPatientService.initSecondScreening(patient));
        } catch (Exception e) {
            error(e);
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "delCopdPatient", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("慢阻肺居民删除")
    public String delCopdPatient(@RequestParam(value = "patient", required = false)String patient) {
        try {
            return write(200, "删除成功", "data",copdPatientService.delCopdPatient(patient));
        } catch (Exception e) {
            error(e);
            return error(-1,"删除失败");
        }
    }
    @RequestMapping(value = "addCopdPatient", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("添加慢阻肺居民")
    public String delCopdPatient(@RequestParam(value = "idcard", required = false)String idcard,
                                 @RequestParam(value = "hospital", required = false)String hospital,
                                 @RequestParam(value = "doctor", required = false)String doctor) {
        try {
            return write(200, "添加成功", "data",copdPatientService.addCopdPatient(idcard,hospital,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "getFollowupList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取慢阻肺居民随访计划列表")
    public String getFollowupList(@RequestParam(value = "patient", required = false)String patient) {
        try {
            return write(200, "添加成功", "data",copdPatientService.getFollowupList(patient));
        } catch (Exception e) {
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "modifyFollow")
    @ResponseBody
    @ApiOperation("修改居民慢阻肺计划")
    public String modifyFollow(@RequestParam(value = "json", required = false)String json) {
        try {
            return write(200, "添加成功", "data",copdPatientService.modifyFollow(json));
        } catch (Exception e) {
            error(e);
            return error(-1,e.getMessage());
        }
    }
    //编辑页面
    @RequestMapping(value = "followupListInit/{patient}", method = RequestMethod.GET)
    public String followupListInit(@PathVariable("patient") String patient,
                             @RequestParam(value = "hospital",required = false)String hospital) {
        try {
            request.setAttribute("patient", patient);
            request.setAttribute("type", request.getParameter("type"));
        } catch (Exception e) {
            error(e);
        }
        return "patient/copd_followup_modify";
    }
    @RequestMapping(value = "exportExcel", method = RequestMethod.POST)
    @ApiOperation("导出慢阻肺患者列表")
    @ResponseBody
    public void exportList(
            @RequestParam(value = "name", required = false)String name,
            @RequestParam(value = "idcard", required = false)String idcard,
            @RequestParam(value = "mobile", required = false)String mobile,
            @RequestParam(value = "hospitalName", required = false)String hospitalName,
            @RequestParam(value = "doctorName", required = false)String doctorName,
            HttpServletResponse response) {
        try {
            List<Map<String, Object>> list = copdPatientService.exportList(name,idcard,mobile,hospitalName,doctorName);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("copdPatientList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os, list);
        } catch (Exception ex) {
            error(ex);
        }
    }
    private void write(OutputStream os, List<Map<String, Object>> list) throws Exception {
        WritableWorkbook wwb = Workbook.createWorkbook(os);
        try {
            WritableSheet sheet = wwb.createSheet("sheet", 1);
            String header[] = {"姓名", "性别", "身份证号", "手机号", "社保卡", "关联机构", "关联医生", "分组", "状态"};
            int i = 0;
            for (String h : header) {
                addCell(sheet, 0, i, h);
                i++;
            }
            int j = 1;
            for (Map<String, Object> map : list) {
                addCell(sheet, j, 0, map.get("name") + "");
                addCell(sheet, j, 1, null==map.get("sex_name")?"未知":"1".equals(map.get("sex_name").toString())?"男":"女");
                addCell(sheet, j, 2, map.get("idcard") + "");
                addCell(sheet, j, 3, map.get("phone") + "");
                addCell(sheet, j, 4, map.get("ssc") + "");
                addCell(sheet, j, 5, map.get("hospital_name") + "");
                addCell(sheet, j, 6, map.get("doctor_name") + "");
                addCell(sheet, j, 7, null==map.get("group_screening_status")?"未分组":"1".equals(map.get("group_screening_status").toString())?"随访观察组":"肺康复锻炼组");
                String status = map.get("status").toString();
                String statusName="";
                switch (status){
                    case "0": statusName="未管理";break;
                    case "1": statusName="已管理";break;
                    case "2": statusName="失访";break;
                    case "4": statusName="不纳入管理";break;
                    case "8": statusName="死亡";break;
                }
                addCell(sheet, j, 8, statusName);
                j++;
            }
            wwb.write();
            wwb.close();
        } catch (Exception e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
        }
    }
    private void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        ws.addCell(label);
    }
}

+ 246 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/pneumonia/PneumoniaController.java

@ -0,0 +1,246 @@
package  com.yihu.customer.controller.manager.pneumonia;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.pneumonia.PneumoniaAttackAddress;
import  com.yihu.customer.entity.pneumonia.PneumoniaAttackArea;
import  com.yihu.customer.entity.pneumonia.PneumoniaDataNew;
import com.yihu.customer.service.pneumonia.PneumoniaAttackAreaService;
import com.yihu.customer.service.pneumonia.PneumoniaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Bing on 2021/8/2.
 * 新冠肺炎相关
 */
@Controller
@RequestMapping("/admin/pneumonia")
public class PneumoniaController extends BaseController {
    @Autowired
    private PneumoniaService pneumoniaService;
    @Autowired
    private PneumoniaAttackAreaService pneumoniaAttackAreaService;
    //页面跳转(主页面)
    @RequestMapping(value = "data/initial",method = RequestMethod.GET)
    public String dataInit() {
        return "pneumonia/pneumonia_data_info";
    }
    //页面跳转(主页面)
    @RequestMapping(value = "address/initial",method = RequestMethod.GET)
    public String addressInit(Model model) {
        return "pneumonia/attack_address_list";
    }
    //页面跳转(主页面)
    @RequestMapping(value = "area/initial",method = RequestMethod.GET)
    public String areaInit(Model model) {
        return "pneumonia/attack_area_list";
    }
    //疫情数据获取
    @RequestMapping(value = "data/info",method = RequestMethod.GET)
    @ResponseBody
    public String dataInfo() {
        try {
            return write(200,"获取成功","data",pneumoniaService.dataInfo());
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"获取失败");
        }
    }
    //疫情数据修改
    @RequestMapping(value = "data/modify",method = RequestMethod.POST)
    @ResponseBody
    public String dataModify(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            PneumoniaDataNew pneumoniaDataNew = objectMapper.readValue(jsonData, PneumoniaDataNew.class);
            pneumoniaService.updateDataInfo(pneumoniaDataNew);
            return write(200,"修改成功","data","");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"修改失败");
        }
    }
    //确诊小区获取
    @RequestMapping(value = "address/list",method = RequestMethod.GET)
    @ResponseBody
    public String addressList(@RequestParam(value = "page", required = true) Integer page,
                              @RequestParam(value = "rows", required = true) Integer rows) {
        try {
            Page<PneumoniaAttackAddress> result = pneumoniaService.addressList(page,rows);
            return write(200, "查询成功", page, rows, result);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    //编辑页面
    @RequestMapping(value = "address/updateInit/{id}", method = RequestMethod.GET)
    public String update(@PathVariable("id") Long id) {
        try {
            request.setAttribute("id", id);
            request.setAttribute("type", request.getParameter("type"));
        } catch (Exception e) {
            error(e);
        }
        return "pneumonia/attack_address_edit";
    }
    //确诊小区编辑 新增
    @RequestMapping(value = "address/modify",method = RequestMethod.POST)
    @ResponseBody
    public String addressModify(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            PneumoniaAttackAddress pneumoniaDataNew = objectMapper.readValue(jsonData, PneumoniaAttackAddress.class);
            pneumoniaService.addressModify(pneumoniaDataNew);
            return write(200,"修改成功","data","");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"修改失败");
        }
    }
    //确诊小区新增
    @RequestMapping(value = "address/createInit",method = RequestMethod.GET)
    public String addressCreate() {
        request.setAttribute("id", 0);
        request.setAttribute("type", request.getParameter("type"));
        return "pneumonia/attack_address_edit";
    }
    //确诊小区删除
    @RequestMapping(value = "address/updateStatus",method = RequestMethod.POST)
    @ResponseBody
    public String updateStatus(
            @RequestParam(value = "id", required = true) Long id,
            @RequestParam(value = "del", required = true) Integer del) {
        try {
            if (id == null) {
                return error(-1, "id不能为空!!");
            }
            if (del == null) {
                return error(-1, "状态不能为空!!");
            }
            boolean res = pneumoniaService.addressUpdateDel(del, id);
            return res == true ? write(200, "操作成功!") : error(-1, "操作失败!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "address/findOne",method = RequestMethod.GET)
    @ResponseBody
    public String addressInfo(@RequestParam(value = "id", required = true) Long id) {
        try {
            PneumoniaAttackAddress result = pneumoniaService.addressFindOne(id);
            return write(200,"查询成功","pneumoniaAddress",result);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    //管控新增
    @RequestMapping(value = "area/createInit",method = RequestMethod.GET)
    public String areaCreate() {
        request.setAttribute("id", 0);
        request.setAttribute("type", request.getParameter("type"));
        return "pneumonia/attack_area_edit";
    }
    //管控区域获取
    @RequestMapping(value = "area/list",method = RequestMethod.GET)
    @ResponseBody
    public String areaList(@RequestParam(value = "page", required = true) Integer page,
                              @RequestParam(value = "rows", required = true) Integer rows) {
        try {
            Page<PneumoniaAttackArea> result = pneumoniaAttackAreaService.areaList(page,rows);
            return write(200, "查询成功", page, rows, result);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    //管控区域删除
    @RequestMapping(value = "area/updateStatus",method = RequestMethod.POST)
    @ResponseBody
    public String updateAreaStatus(
            @RequestParam(value = "id", required = true) Long id,
            @RequestParam(value = "del", required = true) Integer del) {
        try {
            if (id == null) {
                return error(-1, "id不能为空!!");
            }
            if (del == null) {
                return error(-1, "状态不能为空!!");
            }
            boolean res = pneumoniaAttackAreaService.areaUpdateDel(del, id);
            return res == true ? write(200, "操作成功!") : error(-1, "操作失败!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "area/findOne",method = RequestMethod.GET)
    @ResponseBody
    public String areaInfo(@RequestParam(value = "id", required = true) Long id) {
        try {
            PneumoniaAttackArea result = pneumoniaAttackAreaService.areaFindOne(id);
            return write(200,"查询成功","pneumoniaArea",result);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    //管控区域编辑 新增
    @RequestMapping(value = "area/modify",method = RequestMethod.POST)
    @ResponseBody
    public String areaModify(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            PneumoniaAttackArea pneumoniaAttackAreaNew = objectMapper.readValue(jsonData, PneumoniaAttackArea.class);
            pneumoniaAttackAreaService.areaModify(pneumoniaAttackAreaNew);
            return write(200,"修改成功","data","");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"修改失败");
        }
    }
    //编辑页面
    @RequestMapping(value = "area/updateInit/{id}", method = RequestMethod.GET)
    public String areaUpdate(@PathVariable("id") Long id) {
        try {
            request.setAttribute("id", id);
            request.setAttribute("model", request.getParameter("type"));
        } catch (Exception e) {
            error(e);
        }
        return "pneumonia/attack_area_edit";
    }
    //管控小区地区工具
    @RequestMapping(value = "area/map",method = RequestMethod.GET)
    public String areaMap() {
        return "getPoint";
    }
}

+ 47 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/refinement/RefinementController.java

@ -0,0 +1,47 @@
package  com.yihu.customer.controller.manager.refinement;
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.service.refinement.RefinementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * 精选问答
 * @author zhangdan
 *
 */
@Controller
@RequestMapping(value = "/admin/refinement", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "精选问答--医生端", description = "精选问答--医生端")
public class RefinementController extends BaseController {
	private static Logger logger = LoggerFactory.getLogger(RefinementController.class);
	@Autowired
	private RefinementService refinementService;
	@RequestMapping(value = "/findCategory",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation(value = "获取类别")
	public String findCategory(@ApiParam(value = "类型code") @RequestParam(value = "code") String code,
							   	@ApiParam(value = "是否取下级类别 1是 2不是") @RequestParam(value = "isChild") Integer isChild){
		try {
			return write(200,"获取成功!","data",refinementService.findCategory(code,isChild));
		}catch (Exception e){
			e.printStackTrace();
			logger.info("获取类型列表失败!----"+e.getMessage());
			return write(-1,"获取失败!");
		}
	}
}

+ 226 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/satisfaction/SatisfactionController.java

@ -0,0 +1,226 @@
package  com.yihu.customer.controller.manager.satisfaction;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.satisfaction.SatisfactionSurveyDetail;
import com.yihu.customer.service.satisfaction.SatisfactionService;
import com.yihu.customer.util.WorkbookUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 满意度调查计划和详情
 * @author xyq
 * @create 2022-07-18 10:30
 * @slogan 他化自在,我自逍遥
 */
@Controller
@RequestMapping(value = "/synergy/admin/satisfaction",produces = "application/json;charset=UTF-8")
@Api(description = "调查计划")
public class SatisfactionController extends BaseController {
    @Autowired
    private SatisfactionService satisfactionService;
    @ApiOperation("创建调查计划")
    @ResponseBody
    @RequestMapping(value = "/addPlan",method = RequestMethod.POST)
    public String addPlan(@ApiParam(value = "调查计划名字") @RequestParam String name,
                          @ApiParam(value = "调查范围,0集美区,1社区") @RequestParam Integer rangType,
                          @ApiParam(value = "调查社区code,逗号拼接") @RequestParam String rangCode,
                          @ApiParam(value = "筛选类型,0随机筛选,1按社区平均筛选,2按团队平均筛选")@RequestParam Integer filterType,
                          @ApiParam(value = "筛选数量") @RequestParam Integer filterNumber,
                          @ApiParam(value = "调查客服") @RequestParam String userCode,
                          @ApiParam(value = "调查开始时间") @RequestParam(required = false) String beginTime,
                          @ApiParam(value = "调查结束时间") @RequestParam(required = false) String endTime,
                          @ApiParam(value = "备注") @RequestParam(required = false) String remark){
        try {
            if(filterNumber <= 0){
                return error(-1,"筛选数量必须大于0");
            }
            return write(200,"创建成功","data",satisfactionService.addOrUpdatePlan(null,name, rangType, rangCode, filterType, filterNumber, userCode, beginTime, endTime, remark));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"创建失败");
        }
    }
    @ApiOperation("获取筛选总数")
    @ResponseBody
    @RequestMapping(value = "/getSearchTotal",method = RequestMethod.GET)
    public String getSearchTotal(@ApiParam(value = "调查范围,0集美区,1社区") @RequestParam Integer rangType,
                          @ApiParam(value = "调查社区code,逗号拼接") @RequestParam(required = false) String rangCode,
                          @ApiParam(value = "筛选类型,0随机筛选,1按社区平均筛选,2按团队平均筛选")@RequestParam Integer filterType,
                          @ApiParam(value = "筛选数量") @RequestParam Integer filterNumber){
        try {
            if(filterNumber <= 0){
                return error(-1,"筛选数量必须大于0");
            }
            return write(200,"创建成功","data",satisfactionService.getSearchTotal(rangType, rangCode, filterType, filterNumber));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"创建失败");
        }
    }
    @ApiOperation("修改调查计划")
    @ResponseBody
    @RequestMapping(value = "/updatePlan",method = RequestMethod.POST)
    public String updatePlan(@ApiParam(value = "计划id") @RequestParam Long id,
                             @ApiParam(value = "调查计划名字") @RequestParam String name,
                             @ApiParam(value = "调查范围,0集美区,1社区") @RequestParam Integer rangType,
                             @ApiParam(value = "调查社区code,逗号拼接") @RequestParam String rangCode,
                             @ApiParam(value = "筛选类型,0随机筛选,1按社区平均筛选,2按团队平均筛选")@RequestParam Integer filterType,
                             @ApiParam(value = "筛选数量") @RequestParam Integer filterNumber,
                             @ApiParam(value = "调查客服") @RequestParam String userCode,
                             @ApiParam(value = "调查开始时间") @RequestParam(required = false) String beginTime,
                             @ApiParam(value = "调查结束时间") @RequestParam(required = false) String endTime,
                             @ApiParam(value = "备注") @RequestParam(required = false) String remark){
        try {
            if(filterNumber <= 0){
                return error(-1,"筛选数量必须大于0");
            }
            satisfactionService.addOrUpdatePlan(id, name, rangType, rangCode, filterType, filterNumber, userCode, beginTime, endTime, remark);
            return write(200,"修改成功");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"修改失败");
        }
    }
    @ApiOperation("获取社区列表")
    @ResponseBody
    @RequestMapping(value = "/getHospitalList",method = RequestMethod.GET)
    public String getHospitalList(){
        try {
            return write(200,"查询成功","list",satisfactionService.getHospitalList());
        }catch (Exception e){
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("获取客服列表")
    @ResponseBody
    @RequestMapping(value = "/getSysUserList",method = RequestMethod.GET)
    public String getSysUserList(){
        try {
            return write(200,"查询成功","list",satisfactionService.getSysUserList());
        }catch (Exception e){
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("满意度调查计划列表")
    @ResponseBody
    @RequestMapping(value = "/getPlanList",method = RequestMethod.GET)
    public String getPlanList(@ApiParam(value = "调查计划名字查询") @RequestParam(required = false)String name,
                              @ApiParam(value = "客服名字查询") @RequestParam(required = false)String userName,
                              @ApiParam(value = "社区code查询") @RequestParam(required = false)String rangCode,
                              @ApiParam(value = "调查开始时间") @RequestParam(required = false) String beginTime,
                              @ApiParam(value = "调查结束时间") @RequestParam(required = false) String endTime,
                              @ApiParam(value = "客服code") @RequestParam(required = false) String userCode,
                              @ApiParam @RequestParam(required = false,defaultValue = "1")Integer page,
                              @ApiParam @RequestParam(required = false,defaultValue = "20")Integer pageSize){
        try {
            return write(200,"查询成功","data",satisfactionService.getPlanList(name, userName, rangCode, beginTime, endTime, page, pageSize,userCode));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("根据计划id查计划详情列表")
    @ResponseBody
    @RequestMapping(value = "/getPlanDetailListByPlanId",method = RequestMethod.GET)
    public String getPlanDetailListByPlanId(@ApiParam(value = "计划id") @RequestParam Integer planId,
                                            @ApiParam(value = "签约机构") @RequestParam(required = false) String hospital,
                                            @ApiParam(value = "手机号") @RequestParam(required = false) String mobile,
                                            @ApiParam(value = "姓名") @RequestParam(required = false) String name,
                                            @ApiParam(value = "筛选重复号码 只查询出号码重复数据1是")
                                            @RequestParam(required = false,defaultValue = "0") Integer mobileRepeat,
                                            @ApiParam(value = "页码") @RequestParam(required = false,defaultValue = "1")Integer page,
                                            @ApiParam(value = "每页大小")@RequestParam(required = false,defaultValue = "20")Integer pageSize){
        try {
            return write(200,"查询成功","data",satisfactionService.getPlanDetailListByPlanId(planId,hospital,mobile,name,mobileRepeat,page,pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("根据id编辑一条调查度调查")
    @ResponseBody
    @RequestMapping(value = "/updatePlanDetailById",method = RequestMethod.POST)
    public String updatePlanDetailById(@ApiParam(value = "详情id") @RequestParam Long id,
                                       @ApiParam(value = "电话") @RequestParam(required = false) String mobile,
                                       @ApiParam(value = "住址")@RequestParam(required = false)String address,
                                       @ApiParam(value = "接通情况。电话有通但未接、挂断、停机标记0,本人或家属接听标记1") @RequestParam(required = false) Integer isOn,
                                       @ApiParam(value = "是否知道签约的家庭医生,0不知道,1知道")@RequestParam(required = false)Integer isKnowDoctor,
                                       @ApiParam(value = "是否介绍家庭医生签约的好处,0否,1是")@RequestParam(required = false)Integer isIntroduceDoctor,
                                       @ApiParam(value = "对家签医生是否满意?1满意2不满意")@RequestParam(required = false)Integer isSatisfyDoctor,
                                       @ApiParam(value = "备注") @RequestParam(required = false) String remark){
        try{
            SatisfactionSurveyDetail one = satisfactionService.updatePlanDetailById(id, mobile, address, isOn, isKnowDoctor, isIntroduceDoctor, isSatisfyDoctor, remark);
            if(one == null){
                return error(-1,"调查记录不存在");
            }else {
                return write(200,"操作成功");
            }
        }catch (Exception e){
            return error(-1,"操作失败");
        }
    }
    @RequestMapping(value = "exportPlanDetailList",method = RequestMethod.GET)
    @ApiOperation("导出调查列表")
    public void exportPlanDetailList(@ApiParam(value = "计划id")@RequestParam Long planId, HttpServletResponse response){
        try {
            List<Map<String, Object>> list = satisfactionService.getPlanDetailListByPlanIdAndOver(planId);
                String fileName = satisfactionService.getPlanName(planId);
                response.setContentType("octets/stream");
                response.setCharacterEncoding("utf-8");
                fileName = URLEncoder.encode(fileName, "utf-8");
                response.setHeader("Content-Disposition", "attachment; filename="+ fileName + new String(".xls"));
                OutputStream os = response.getOutputStream();
                WorkbookUtil workbookUtil = new WorkbookUtil();
                //表头,第一行
                String[] header = {"居民姓名","性别","联系电话","签约机构","家庭医生","现住址","接通情况(电话有通但未接、挂断、停机标记‘0’,本人或家属接听标记‘1’)","请问您是否知道签约的家庭医生?","是否介绍家庭医生签约的好处","对家签医生是否满意?1满意2不满意","回访客服","备注"};
                //每一列对应的键
                Map<Integer,String> columnMap = new HashMap<>();
                columnMap.put(0,"patient_name");
                columnMap.put(1,"sexStr");
                columnMap.put(2,"mobile");
                columnMap.put(3,"sign_org_name");
                columnMap.put(4,"doctor_name");
                columnMap.put(5,"address");
                columnMap.put(6,"is_on");
                columnMap.put(7,"isKnowDoctorStr");
                columnMap.put(8,"isIntroduceDoctorStr");
                columnMap.put(9,"is_satisfy_doctor");
                columnMap.put(10,"return_user_name");
                columnMap.put(11,"remark");
                workbookUtil.write(Workbook.createWorkbook(os), list, columnMap, header);
                os.flush();
                os.close();
        }catch (Exception e){
           e.printStackTrace();
        }
    }
}

文件差異過大導致無法顯示
+ 452 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/sign/SignFamilyController.java


+ 34 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/special/SpecialDiseaseController.java

@ -0,0 +1,34 @@
package  com.yihu.customer.controller.manager.special;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.SpecialDisease;
import com.yihu.customer.service.manager.special.ManageSpecialDiseaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
 * Created by humingfen on 2018/7/4.
 */
@Controller
@RequestMapping(value="admin/specialDisease/")
public class SpecialDiseaseController extends BaseController {
    @Autowired
    ManageSpecialDiseaseService manageSpecialDiseaseService;
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    public String list(){
        try {
            List<SpecialDisease> specialDisease = manageSpecialDiseaseService.findAll();
            return write(200, "操作成功", "data",specialDisease);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
}

+ 158 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/specialist/HopsitalServiceItemController.java

@ -0,0 +1,158 @@
package  com.yihu.customer.controller.manager.specialist;/**
 * Created by nature of king on 2018/8/29.
 */
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.service.manager.specialist.SpecialistHospitalItemService;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
/**
 * @author wangzhinan
 * @create 2018-08-29 1:48
 * @desc 机构服务项目
 **/
@Controller
@RequestMapping(value="/admin/specialist/hospitalServiceItem")
public class HopsitalServiceItemController extends BaseController {
    @Autowired
    private SpecialistHospitalItemService specialistHospitalItemService;
    @RequestMapping(value = "initial")
    public String listInit() {
        return "desizenMan/service_project_management";
    }
    @RequestMapping(value = "initial1")
    public String listInit1() {
        return "desizenMan/new-institutional-projects";
    }
    /**
     * 添加机构服务项目
     *
     * @param hospitalServiceItem
     * @return
     */
    @RequestMapping(value = "createHospitalServiceItem", method = RequestMethod.POST)
    @ResponseBody
    public String insert(@RequestParam(name = "hospitalServiceItem") String hospitalServiceItem){
        try {
            return write(200, "操作成功", "data",specialistHospitalItemService.insert(hospitalServiceItem));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 获取机构
     * @return
     */
    @RequestMapping(value = "selectHospital", method = RequestMethod.POST)
    @ResponseBody
    public String selectHospitals(@RequestParam(name = "hospitalName",required = false) String hospitalName,
                                  @RequestParam(name = "grade",required = false) Integer grade){
        try {
            return write(200, "查询成功", "data",specialistHospitalItemService.selectHospital(hospitalName,grade));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "查询失败");
        }
    }
    /**
     *
     * @param hospital
     * @return
     */
    @RequestMapping(value = "selectByHospital", method = RequestMethod.POST)
    @ResponseBody
    public String selectByHospital(@RequestParam(name = "hospital") String hospital){
        try {
            return write(200, "查询成功", "data",specialistHospitalItemService.selectItemByHospital(hospital));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取机构服务项目
     *
     * @param serviceItemName
     * @param hospital
     * @return
     */
    @RequestMapping(value = "selectByCondition", method = RequestMethod.POST)
    @ResponseBody
    public String selectByCondition(@RequestParam(name = "serviceItemName",required = false) String serviceItemName,
                                    @RequestParam(name = "hospital",required = false) String hospital){
        try {
            return write(200, "查询成功", "data",specialistHospitalItemService.selectCondition(serviceItemName,hospital));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "查询失败");
        }
    }
    /**
     *  删除机构服务项目
     *
     * @param serviceItem 服务项目id
     * @param hospital 医院code
     * @return
     */
    @RequestMapping(value = "deleteHospitalItem", method = RequestMethod.POST)
    @ResponseBody
    public String delete(@RequestParam(name = "serviceItem",required = false) String serviceItem,
                                    @RequestParam(name = "hospital",required = false) String hospital,
                         @RequestParam(name = "id",required = false) String id){
        try {
            return write(200, "删除成功", "data",specialistHospitalItemService.delete(serviceItem,hospital,id));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "删除失败");
        }
    }
    /**
     * 机构服务项目导数据
     * @param file
     * @return
     */
    @RequestMapping(value = "importData", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(@RequestParam(name = "file") MultipartFile file) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = file.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            specialistHospitalItemService.importData(workbook);
            return write(200, "操作成功");
        } catch (IOException | BiffException e) {
            e.printStackTrace();
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 164 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/specialist/ServiceItemController.java

@ -0,0 +1,164 @@
package  com.yihu.customer.controller.manager.specialist;/**
 * Created by nature of king on 2018/8/17.
 */
import com.alibaba.fastjson.JSONObject;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.specialist.SpecialistServiceItemDO;
import com.yihu.customer.service.manager.specialist.ServiceItemService;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
 * @author wangzhinan
 * @create 2018-08-17 16:51
 * @desc 服务项目
 **/
@Controller
@RequestMapping(value="/admin/specialist/serviceItem")
public class ServiceItemController  extends BaseController {
    @Autowired
    private ServiceItemService serviceItemService;
    @RequestMapping(value = "initial")
    public String listInit() {
        return "specialty/index";
    }
    /**
     * 创建服务项目
     * @param serviceItem
     * @return
     */
    @RequestMapping(value = "createServiceItem", method = RequestMethod.POST)
    @ResponseBody
    public String createServiceItem(@RequestParam(name = "serviceItem") String serviceItem){
        try {
            return write(200, "操作成功", "data",serviceItemService.createServiceItem(serviceItem));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 更新服务项目
     *
     * @param serviceItem
     * @return
     */
    @RequestMapping(value = "updateServiceItem", method = RequestMethod.POST)
    @ResponseBody
    public String updateServiceItem(@RequestParam(name = "serviceItem") String serviceItem){
        try {
            return write(200, "操作成功", "data",serviceItemService.updateServiceItem(serviceItem));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 获取服务项目
     *
     * @param serviceItem
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "selectServiceItem", method = RequestMethod.GET)
    @ResponseBody
    public String selectServiceItem(@RequestParam(name = "serviceItem") String serviceItem,
                                    @RequestParam(name = "page",defaultValue = "1")Integer page,
                                    @RequestParam(name = "pagesize",defaultValue = "10")Integer pagesize){
        try {
            JSONObject jsonObject = serviceItemService.selectServiceItem(serviceItem,page,pagesize);
            String totalCount = String.valueOf(jsonObject.get("totalCount"));
            Long total = Long.parseLong(totalCount);
            return write(200, "操作成功", page,pagesize,total,(List< SpecialistServiceItemDO>)jsonObject.get("detailModelList"));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 删除服务项目
     *
     * @param ids
     * @return
     */
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    @ResponseBody
    public String deleteServiceItem(@RequestParam(name = "ids") String ids){
        try {
            return write(200, "操作成功", "data",serviceItemService.delete(ids));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 查询历史记录
     *
     * @param serviceItem
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "selectOperate", method = RequestMethod.POST)
    @ResponseBody
    public String selectOperate(@RequestParam(name = "serviceItem") String serviceItem,
                                    @RequestParam(name = "page",defaultValue = "1")Integer page,
                                    @RequestParam(name = "size",defaultValue = "10")Integer size){
        try {
            return write(200, "操作成功", "data",serviceItemService.selectOperate(serviceItem,page,size));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 服务项目导数据
     *
     * @param file
     * @return
     */
    @RequestMapping(value = "importData", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(@RequestParam(name = "file") MultipartFile file) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = file.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            serviceItemService.importData(workbook);
            return write(200, "操作成功");
        } catch (IOException | BiffException e) {
            e.printStackTrace();
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 77 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/QuestionnaireController.java

@ -0,0 +1,77 @@
package  com.yihu.customer.controller.manager.survey;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.survey.QuestionnaireWinning;
import com.yihu.customer.service.manager.survey.QuestionnaireService;
import io.swagger.annotations.Api;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.List;
/**
 * Created by yww on 2016/12/13.
 */
@Controller
@RequestMapping("admin/questionnaire")
@Api(description = "管理端问卷奖励管理")
public class QuestionnaireController extends BaseController {
    @Autowired
    private QuestionnaireService questionnaireService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initList(){
        return "questionnaire/prize/prize_list";
    }
    @RequestMapping(value = "list")
    @ResponseBody
    public String searchList(
            @RequestParam(value = "type",defaultValue = "1")Integer type,
            @RequestParam(value = "name",required = false)String name,
            @RequestParam(value = "idcard",required = false)String idcard,
            @RequestParam(value = "page",required = false)Integer page,
            @RequestParam(value = "rows",required = false)Integer pageSize){
        try{
            List<QuestionnaireWinning> userprizes = questionnaireService.searchList(type ,name,idcard,page, pageSize);
            List<QuestionnaireWinning> total = questionnaireService.searchListCount(type,name,idcard);
            return write(200,"操作成功",page,pageSize,total.size(),userprizes);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    /*
     * 导入奖品信息Excel表格数据
     * @param request
     * @return
    
     */
    @RequestMapping(value = "/importData", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(HttpServletRequest request) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = request.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            questionnaireService.importData(workbook);
            return write(200, "操作成功");
        } catch (IOException | BiffException | ParseException e) {
            e.printStackTrace();
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 53 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyAdviceController.java

@ -0,0 +1,53 @@
package  com.yihu.customer.controller.manager.survey;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.survey.SurveyAdvice;
import com.yihu.customer.service.manager.survey.SurveyAdviceService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
 * Created by humingfen on 2018/7/5.
 */
@Controller
@RequestMapping(value="admin/surveyAdvice/")
public class SurveyAdviceController extends BaseController {
    @Autowired
    private SurveyAdviceService surveyAdviceService;
    @RequestMapping(value = "findByDiseaseType", method = RequestMethod.POST)
    @ResponseBody
    public String findById(
            @ApiParam(name = "diseaseType",value = "疾病类型")
            @RequestParam(value = "diseaseType",required = true) Integer diseaseType,
            @ApiParam(name = "templateCode",value = "模板id")
            @RequestParam(value = "templateCode",required = true) String templateCode){
        try {
            List<SurveyAdvice> results = surveyAdviceService.findAdvice(diseaseType, templateCode);
            return write(200, "操作成功","data",results);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "saveOrUpdate", method = RequestMethod.POST)
    @ResponseBody
    public String saveResult(@ApiParam(name = "jsonData", value = "新增json",defaultValue = "")
                                 @RequestParam(value = "jsonData", required = true) String jsonData){
        try {
            SurveyAdvice advice = surveyAdviceService.saveOrUpdate(jsonData);
            return write(200,"保存成功","data",advice);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");
        }
    }
}

+ 206 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyQuestionController.java

@ -0,0 +1,206 @@
package  com.yihu.customer.controller.manager.survey;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.survey.SurveyQuestion;
import com.yihu.customer.service.manager.survey.SurveyQuestionOptionService;
import com.yihu.customer.service.manager.survey.SurveyQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Created by yeshijie on 2017/3/7.
 */
@Controller
@RequestMapping(value="admin/surveyQuestion")
//@Api(description = "问题题库数据接口")
@Api(value = "surveyQuestion", description = "问题题库数据接口", tags = {"问题题库"})
public class SurveyQuestionController extends BaseController{
    @Autowired
    private SurveyQuestionService surveyQuestionService;
    @Autowired
    private SurveyQuestionOptionService surveyQuestionOptionService;
    //---问题管理列表---
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    @ApiIgnore
    @ApiOperation(value = "问题管理列表")
    public String initQuestionList(){
        return "questionnaire/question/question_list";
    }
    //页面跳转(新增问题页面)
    @RequestMapping(value ="infoInit",method = RequestMethod.GET)
    @ApiIgnore
    @ApiOperation(value = "页面跳转(新增问题页面)")
    public String infoInit(String id,String mode){
        request.setAttribute("id",id);
        request.setAttribute("mode",mode);
        return "questionnaire/question/question_add";
    }
    //页面跳转(编辑问题页面)
    @RequestMapping(value ="editQuestion",method = RequestMethod.GET)
    @ApiIgnore
    @ApiOperation(value = "页面跳转(编辑问题页面)")
    public String editQuestion(String id,String mode){
        request.setAttribute("id",id);
        request.setAttribute("mode",mode);
        return "questionnaire/question/question_edit";
    }
    //跳转到问题查看页
    @RequestMapping(value = "seeQuestion", method = RequestMethod.GET)
    @ApiIgnore
    @ApiOperation(value = "跳转到问题查看页")
    public String seeQuestion(String id,String type) {
        request.setAttribute("id",id);
        request.setAttribute("type",type);
        return "questionnaire/question/see_question";
    }
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "问题列表数据")
    public String searchQuestionList(
            @ApiParam(name = "title", value = "标题",defaultValue = "")
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "questionType", value = "问题类型(0单选 1多选 2问答)",defaultValue = "0")
            @RequestParam(value = "questionType", required = false) Integer questionType,
            @ApiParam(name = "page",value = "第几页",defaultValue = "1")
            @RequestParam(value = "page",required = true) int page,
            @ApiParam(name = "rows",value = "页面大小",defaultValue = "2")
            @RequestParam(value = "rows",required = true) int rows) {
        try {
            Page<SurveyQuestion> res = surveyQuestionService.findQuestion(page,rows,title,questionType);
            return write(200, "操作成功", page, rows, res);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 问题新增页面
     * @param model
     * @return
     */
    @RequestMapping(value = "addQuestionInitial", method = RequestMethod.GET)
    @ApiIgnore
    @ApiOperation(value = "问题列表数据")
    public String addQuestionInitial(Model model) {
        return "survey/question/addQuestion";
    }
    @RequestMapping(value = "addQuestions", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "新增问题(可批量新增)")
    public String addQuestions(@ApiParam(name = "jsonData", value = "新增json",defaultValue = "")
                                @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            System.out.println("jsonData:"+jsonData);
            surveyQuestionService.saveOrUpdateQuestion(jsonData);
            return success("新增成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "新增失败!");
        }
    }
    @RequestMapping(value = "getQuestion", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "根据id获取单个问题")
    public String getQuestion(@ApiParam(name = "id", value = "问题id",defaultValue = "1")
                               @RequestParam(value = "id", required = true) Long id) {
        try {
            SurveyQuestion question = surveyQuestionService.findById(id);
            if(question == null){
                return error(-1, "获取问题Id不存在");
            }else if("0".equals(question.getDel())){
                return error(-1, "该问题已被删除");
            }else{
                JSONObject json = surveyQuestionService.getQuestion(question);
                return write(200,"获取成功","data",json);
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "getQuestions", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "根据id获取单个问题")
    public String getQuestion(@ApiParam(name = "id", value = "问题id",defaultValue = "1")
                              @RequestParam(value = "ids", required = true) String  ids) {
        try {
            JSONArray questions = surveyQuestionService.findByIds(ids);
             return write(200,"获取成功","data",questions);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "delQuestion", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "根据id删除单个问题")
    public String delQuestion(@ApiParam(name = "id", value = "问题id",defaultValue = "1")
                              @RequestParam(value = "id", required = true) Long id) {
        try {
            surveyQuestionService.delQuestion(id);
            return success("删除成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "删除失败!");
        }
    }
    @RequestMapping(value = "delQuestions", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "批量删除")
    public String delQuestions(@ApiParam(name = "ids", value = "问题ids",defaultValue = "1;2;3")
                              @RequestParam(value = "ids", required = true) String ids) {
        try {
            if(StringUtils.isEmpty(ids)){
                return error(-1, "删除问题ids不能为空!");
            }
            surveyQuestionService.delQuestions(ids);
            return success("删除成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "删除失败!");
        }
    }
    @RequestMapping(value = "updQuestion", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "更新问题")
    public String updQuestion(@ApiParam(name = "questionData", value = "问题json",defaultValue = "{}")
                               @RequestParam(value = "questionData", required = true) String questionData) {
        try {
            System.out.println(questionData);
            return success("更新成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "更新失败!");
        }
    }
}

+ 64 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyTemplateAdviceController.java

@ -0,0 +1,64 @@
package  com.yihu.customer.controller.manager.survey;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.survey.SurveyAdvice;
import com.yihu.customer.service.manager.survey.SurveyAdviceService;
import com.yihu.customer.service.manager.survey.SurveyTemplateAdviceService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
 * Created by humingfen on 2018/7/5.
 */
@Controller
@RequestMapping(value="admin/surveyTemplateAdvice/")
public class SurveyTemplateAdviceController extends BaseController {
    @Autowired
    private SurveyTemplateAdviceService templateAdviceService;
    @Autowired
    private SurveyAdviceService surveyAdviceService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initAdvice(Integer diseaseType, String templateCode,String mode){
        request.setAttribute("templateCode",templateCode);
        request.setAttribute("diseaseType",diseaseType);
        request.setAttribute("mode",mode);
        return "questionnaire/template/template_advice";
    }
    @RequestMapping(value = "saveOrUpdate", method = RequestMethod.POST)
    @ResponseBody
    public String saveResult(@ApiParam(name = "jsonData", value = "新增json",defaultValue = "")
                             @RequestParam(value = "jsonData", required = true) String jsonData,
                             @ApiParam(name = "templateCode", value = "新增json",defaultValue = "")
                             @RequestParam(value = "templateCode", required = true) String templateCode){
        try {
            templateAdviceService.saveOrUpdate(jsonData, templateCode);
            return write(200,"保存成功");
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");
        }
    }
    @RequestMapping(value = "adviceList", method = RequestMethod.POST)
    @ResponseBody
    public String adviceList(@ApiParam(name = "templateCode", value = "新增json",defaultValue = "")
                             @RequestParam(value = "templateCode", required = true) String templateCode){
        try {
            List<SurveyAdvice> surveyAdviceList = surveyAdviceService.findAdviceByTemplateCode(templateCode);
            return write(200,"保存成功","data",surveyAdviceList);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");
        }
    }
}

+ 199 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyTemplateController.java

@ -0,0 +1,199 @@
package  com.yihu.customer.controller.manager.survey;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.User;
import  com.yihu.customer.entity.survey.SurveyTemplate;
import com.yihu.customer.service.manager.survey.SurveyTemplateService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
/**
 * Created by yeshijie on 2017/3/7.
 */
@Controller
@RequestMapping(value="admin/surveyTemplate/")
public class SurveyTemplateController extends BaseController{
    @Autowired
    SurveyTemplateService surveyTemplateService;
    //---问卷模板管理列表---
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initTeamList(){
        return "questionnaire/template/template_list";
    }
    //跳转到问题查看页
    @RequestMapping(value = "importQuestion", method = RequestMethod.GET)
    @ApiIgnore
    @ApiOperation(value = "跳转到问题查看页")
    public String importQuestion() {
        return "questionnaire/template/import_question";
    }
    //跳转到问卷模板筛查结果列表---
    @RequestMapping(value = "initResult", method = RequestMethod.GET)
    public String initResult(String templateCode, Integer diseaseType, String mode){
        request.setAttribute("templateCode",templateCode);
        request.setAttribute("diseaseType",diseaseType);
        request.setAttribute("mode",mode);
        return "questionnaire/template/template_result";
    }
    @RequestMapping(value = "list", method = RequestMethod.GET)
    @ResponseBody
    public String list(
            @ApiParam(name = "title", value = "标题",defaultValue = "")
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "label", value = "标签信息",defaultValue = "0")
            @RequestParam(value = "label", required = false) Integer labelCode,
            @ApiParam(name = "page",value = "第几页",defaultValue = "1")
            @RequestParam(value = "page",required = true) int page,
            @ApiParam(name = "rows",value = "页面大小",defaultValue = "2")
            @RequestParam(value = "rows",required = true) int rows){
        try {
            Page<JSONObject> res = surveyTemplateService.queryList(page,rows,title,labelCode);
            return write(200, "操作成功", page, rows, res);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "list/options", method = RequestMethod.GET)
    @ResponseBody
    public String listOption(
            @ApiParam(name = "q", value = "标题",defaultValue = "")
            @RequestParam(value = "q", required = false) String title,
            @ApiParam(name = "label", value = "标签信息",defaultValue = "0")
            @RequestParam(value = "label", required = false) Integer labelCode,
            @ApiParam(name = "page",value = "第几页",defaultValue = "1")
            @RequestParam(value = "page",required = true) int page,
            @ApiParam(name = "rows",value = "页面大小",defaultValue = "2")
            @RequestParam(value = "rows",required = true) int rows){
        try {
            Page<JSONObject> res = surveyTemplateService.queryList(page,rows,title,labelCode);
            JSONArray array = new JSONArray();
            for(JSONObject p:res.getContent()){
                JSONObject optionObj = new JSONObject();
                optionObj.put("id",p.get("id"));
                optionObj.put("text",p.get("title"));
                array.put(optionObj);
            }
            return write(200,"获取成功","list",array);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    //---新增问卷模板---
    @RequestMapping(value = "addTemplate", method = RequestMethod.GET)
    public String addTemplate(String id,String mode){
        request.setAttribute("templateId",id);
        request.setAttribute("mode",mode);
        return "questionnaire/template/add_template";
    }
    //---编辑问卷模板---
    @RequestMapping(value = "editTemplate", method = RequestMethod.GET)
    public String editTemplate(String id,String mode){
        request.setAttribute("id",id);
        request.setAttribute("mode",mode);
        return "questionnaire/template/edit_template";
    }
    //---保存标签---
    @RequestMapping(value = "editLabel", method = RequestMethod.POST)
    public String editLabel(@ApiParam(name = "模板id", value = "模板id",defaultValue = "0")
                                @RequestParam(value = "templateId", required = true) long templateId,
                            @ApiParam(name = "标签JSON", value = "标签JSON",defaultValue = "")
                            @RequestParam(value = "jsonData", required = true) String jsonData){
        try {
            surveyTemplateService.saveLabel(templateId,jsonData);
            return write(200,"保存成功");
        }catch (Exception e){
            return write(-1,"保存失败");
        }
    }
    @RequestMapping(value = "save", method = RequestMethod.POST)
    @ResponseBody
    public String saveTemplate(@ApiParam(name = "jsonData", value = "新增json",defaultValue = "")
                                   @RequestParam(value = "jsonData", required = true) String jsonData,
                               HttpServletRequest request){
        User loginUser = (User) request.getSession().getAttribute("userInfo");
        try {
            SurveyTemplate surveyTemplate = surveyTemplateService.saveOrUpdate(jsonData,loginUser.getCode());
            return write(200,"保存成功","data",surveyTemplate);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");
        }
    }
    @RequestMapping(value = "template", method = RequestMethod.GET)
    @ResponseBody
    public String getTemplate(@ApiParam(name = "id", value = "模板id",defaultValue = "0")
                              @RequestParam(value = "id", required = true) long id,
                              @ApiParam(name = "question", value = "是否加载问题",defaultValue = "0")
                              @RequestParam(value = "question", required = false) long question,
                              HttpServletRequest request){
        try {
            com.alibaba.fastjson.JSONObject surveyTemplate =  surveyTemplateService.getTemplate(id,question);
            return write(200,"获取成功","data",surveyTemplate);
        }catch (Exception e){
            return write(-1,"获取失败");
        }
    }
    @RequestMapping(value = "template/title", method = RequestMethod.GET)
    @ResponseBody
    public String getTemplate(@ApiParam(name = "title", value = "模板title",defaultValue = "")
                              @RequestParam(value = "title", required = true) String  title){
        try {
            SurveyTemplate surveyTemplate =  surveyTemplateService.findByTitle(title);
            return write(200,"获取成功","data",surveyTemplate);
        }catch (Exception e){
            return write(-1,"获取失败");
        }
    }
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    @ResponseBody
    public String delete(@ApiParam(name = "模板ID", value = "模板ID",defaultValue = "0")
                              @RequestParam(value = "templateId", required = true) Long templateId){
        try {
           surveyTemplateService.deleteTemplate(templateId);
            return write(200,"删除成功");
        }catch (Exception e){
            return write(-1,"获取失败");
        }
    }
    
    @RequestMapping(value = "online", method = RequestMethod.POST)
    @ResponseBody
    public String online(@ApiParam(name = "模板ID", value = "模板ID",defaultValue = "0")
                         @RequestParam(value = "templateId", required = true) Long templateId){
        try {
            surveyTemplateService.online(templateId);
            return write(200,"操作成功");
        }catch (Exception e){
            return write(-1,"获取失败");
        }
    }
}

+ 58 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/survey/SurveyTemplateResultController.java

@ -0,0 +1,58 @@
package  com.yihu.customer.controller.manager.survey;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.User;
import  com.yihu.customer.entity.survey.SurveyTemplateResult;
import com.yihu.customer.service.manager.survey.SurveyTemplateResultService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * Created by humingfen on 2018/7/5.
 */
@Controller
@RequestMapping(value="admin/surveyTemplateResult/")
public class SurveyTemplateResultController extends BaseController {
    @Autowired
    private SurveyTemplateResultService resultService;
    @RequestMapping(value = "findByTemplateCode", method = RequestMethod.POST)
    @ResponseBody
    public String findById(
            @ApiParam(name = "templateCode",value = "模板id")
            @RequestParam(value = "templateCode",required = true) String templateCode){
        try {
            List<SurveyTemplateResult> results = resultService.findByTemplateCode(templateCode);
            return write(200, "操作成功","data",results);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "save", method = RequestMethod.POST)
    @ResponseBody
    public String saveResult(@ApiParam(name = "jsonData", value = "新增json",defaultValue = "")
                               @RequestParam(value = "jsonData", required = true) String jsonData,
                             @ApiParam(name = "templateCode",value = "模板id")
                             @RequestParam(value = "templateCode",required = true) String templateCode,
                               HttpServletRequest request){
        User loginUser = (User) request.getSession().getAttribute("userInfo");
        try {
            resultService.saveOrUpdate(jsonData,templateCode,loginUser.getCode());
            return write(200,"保存成功");
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");
        }
    }
}

+ 378 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/team/WlyyAdminTeamController.java

@ -0,0 +1,378 @@
package  com.yihu.customer.controller.manager.team;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.Doctor;
import  com.yihu.customer.entity.WlyyAdminTeam;
import  com.yihu.customer.entity.WlyyAdminTeamMember;
import com.yihu.customer.service.manager.hos.HosDoctorService;
import com.yihu.customer.service.manager.team.ManageWlyyAdminTeamMemberService;
import com.yihu.customer.service.manager.team.ManageWlyyAdminTeamService;
import com.yihu.customer.util.HttpUtil;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by yww on 2016/11/15.
 */
@Controller
@RequestMapping("admin/team")
public class WlyyAdminTeamController extends BaseController {
    @Autowired
    private ManageWlyyAdminTeamService teamService;
    @Value("${service-gateway.update-team-url}")
    private String loadTeamInfoUrl;
    //----------------------------------------团队成员列表--------------------------------
    @Autowired
    private ManageWlyyAdminTeamMemberService teamMemberService;
    @Autowired
    private HosDoctorService doctorService;
    //---医生团队查询 开始---
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initTeamList() {
        return "team/doctor/team_list";
    }
    //---专科医生团队查询 开始---
    @RequestMapping(value = "zk/initial", method = RequestMethod.GET)
    public String initZkTeamList() {
        return "team/doctor/zk_team_list";
    }
    //分页查询团队列表
    @RequestMapping(value = "teamList", method = RequestMethod.POST)
    @ResponseBody
    public String searchTeams(
            @ApiParam(name = "orgName", value = "机构名称")
            @RequestParam(value = "orgName", required = false) String orgName,
            @ApiParam(name = "teamName", value = "团队名称")
            @RequestParam(value = "teamName", required = false) String teamName,
            @ApiParam(name = "leaderName", value = "团队长")
            @RequestParam(value = "leaderName", required = false) String leaderName,
            @ApiParam(name = "memberName", value = "团队成员名")
            @RequestParam(value = "memberName", required = false) String memberName,
            @ApiParam(name = "memberMobile", value = "团队成员名电话")
            @RequestParam(value = "memberMobile", required = false) String memberMobile,
            @ApiParam(name = "page")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "rows")
            @RequestParam(value = "rows") int rows) {
        try {
            //按医生code信息外查询,
            Page<WlyyAdminTeam> wlyyTeams = teamService.searchTeams(orgName, teamName, leaderName, memberName, memberMobile, 0,page, rows);
            return writeToJson(200, "操作成功", page, rows, wlyyTeams);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    //分页查询团队列表
    @RequestMapping(value = "specialTeamList", method = RequestMethod.POST)
    @ResponseBody
    public String specialTeamList(
            @ApiParam(name = "orgName", value = "机构名称")
            @RequestParam(value = "orgName", required = false) String orgName,
            @ApiParam(name = "teamName", value = "团队名称")
            @RequestParam(value = "teamName", required = false) String teamName,
            @ApiParam(name = "leaderName", value = "团队长")
            @RequestParam(value = "leaderName", required = false) String leaderName,
            @ApiParam(name = "memberName", value = "团队成员名")
            @RequestParam(value = "memberName", required = false) String memberName,
            @ApiParam(name = "memberMobile", value = "团队成员名电话")
            @RequestParam(value = "memberMobile", required = false) String memberMobile,
            @ApiParam(name = "page")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "rows")
            @RequestParam(value = "rows") int rows) {
        try {
            //按医生code信息外查询,
            Page<WlyyAdminTeam> wlyyTeams = teamService.searchTeams(orgName, teamName, leaderName, memberName, memberMobile,1,page, rows);
            return writeToJson(200, "操作成功", page, rows, wlyyTeams);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    //获取某个机构下的所有团队
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    public String searchTeams(
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode", required = false) String orgCode) {
        try {
            //按医生code信息外查询,
            List<WlyyAdminTeam> wlyyTeams = teamService.getByOrgCode(orgCode);
            return write(200, "操作成功", "list",wlyyTeams);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    //-----居民签约团队信息查询开始(团队信息、团队成员列表)-----
    @RequestMapping(value = "signTeamInfo/{adminTeamId}", method = RequestMethod.GET)
    public String initTeamPatientList(
            @ApiParam(name = "adminTeamId", value = "居民签约行政团队id")
            @PathVariable Long adminTeamId) throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        WlyyAdminTeam team = teamService.findById(adminTeamId);
        team = teamService.searchOrgName(team);
        request.setAttribute("teamInfo", objectMapper.writeValueAsString(team));
        request.setAttribute("adminTeamId", adminTeamId);
        return "sign/sign_team_info";
    }
    @RequestMapping(value = "signTeamInfo", method = RequestMethod.POST)
    @ResponseBody
    public String signTeamInfo(
            @ApiParam(name = "teamId", value = "居民签约行政团队id")
            @RequestParam(value = "teamId", required = true) Long teamId) {
        try {
            WlyyAdminTeam signTeamInfo = teamService.getSignTeamInfo(teamId);
            return write(200, "操作成功", "data", signTeamInfo);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    //修改团队状态
    @RequestMapping(value = "updateStatus", method = RequestMethod.POST)
    @ResponseBody
    public String updateTeamStatus(
            @ApiParam(name = "id", value = "团队id")
            @RequestParam(value = "id", required = true) Long id,
            @ApiParam(name = "available", value = "修改状态值 1,0")
            @RequestParam(value = "available") String available) {
        try {
            boolean res = teamService.updateStatus(available, id);
            if (!res) {
                return error(-1, "操作失败!");
            }
            return write(200, "操作成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    //查看团队信息
    @RequestMapping(value = "teamInfo/{id}", method = RequestMethod.GET)
    public String teamInfoPage(
            @ApiParam(name = "id", value = "团队id")
            @PathVariable(value = "id") Long id) {
        request.setAttribute("id", id);
        return "team/doctor/team_info";
    }
    //查看专科团队信息
    @RequestMapping(value = "teamInfo/zk/{id}", method = RequestMethod.GET)
    public String zkTeamInfoPage(
            @ApiParam(name = "id", value = "团队id")
            @PathVariable(value = "id") Long id) {
        request.setAttribute("id", id);
        return "team/doctor/zk_team_info";
    }
    @RequestMapping(value = "teamInfo", method = RequestMethod.POST)
    @ResponseBody
    public String teamInfo(
            @ApiParam(name = "id", value = "团队id")
            @RequestParam(value = "id") Long id) {
        try {
            WlyyAdminTeam team = teamService.findById(id);
            return write(200, "操作成功", "data", team);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    //同步团队
    @RequestMapping(value = "loadTeamInfo", method = RequestMethod.POST)
    @ResponseBody
    public String loadTeamInfo() {
        try {
            String res = HttpUtil.sendPost(loadTeamInfoUrl, "");
            if (!StringUtils.isEmpty(res)) {
                return write(200, "操作成功");
            }
            return write(-1, "操作失败");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "系统异常");
        }
    }
    //团队成员列表页(不分页查询)
    @RequestMapping(value = "memberList/{teamId}", method = RequestMethod.GET)
    public String memberListPage(
            @ApiParam(name = "teamId", value = "团队Id")
            @PathVariable Long teamId) {
        request.setAttribute("teamId", teamId);
        return "team/doctor/team_member_list";
    }
    @RequestMapping(value = "memberList", method = RequestMethod.POST)
    @ResponseBody
    public String memberList(
            @ApiParam(name = "teamId", value = "团队Id")
            @RequestParam(value = "teamId") Long teamId,
            @ApiParam(name = "doctorCode", value = "医生编码")
            @RequestParam(value = "doctorCode", required = false) String doctorCode) {
        try {
            List<WlyyAdminTeamMember> members = teamMemberService.searchTeamMembers(teamId, doctorCode);
            return write(200, "操作成功", "detailModelList", members);
        } catch (Exception ex) {
            error(ex);
            return error(200, "操作失败");
        }
    }
    //团队成员信息
    @RequestMapping(value = "memberInfo/{doctorCode}", method = RequestMethod.GET)
    public String memberInfoPage(
            @ApiParam(name = "doctorCode", value = "团队医生编码")
            @PathVariable String doctorCode) {
        request.setAttribute("doctorCode", doctorCode);
        return "team/doctor/member_info";
    }
    @RequestMapping(value = "memberInfo", method = RequestMethod.POST)
    @ResponseBody
    public String memberInfo(
            @ApiParam(name = "doctorCode", value = "团队医生编码")
            @RequestParam(value = "doctorCode") String doctorCode) {
        try {
            Doctor doctor = doctorService.getDoctorByCode(doctorCode);
            return write(200, "操作成功", "data", doctor);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    public String writeToJson(int code, String errorMsg, int page, int rows, Page<WlyyAdminTeam> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("successFlg", code == 0);
            map.put("errorMsg", errorMsg);
            // 是否为第一页
            map.put("errorCode", code);
            // 是否为最后一页
            map.put("currPage", page);
            // 分页大小
            map.put("pageSize", rows);
            // 总条数
            map.put("totalCount", list.getTotalElements());
            // 总页数
            map.put("totalPage", list.getTotalPages());
            List<WlyyAdminTeam> teamList = list.getContent();
            if (teamList != null && teamList.size() > 0) {
                for (WlyyAdminTeam team : teamList) {
                    team = teamService.searchOrgName(team);
                }
            }
            // 结果集
            map.put("detailModelList", teamList);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    //获取团队成员下拉列表框(类型:专科1,全科2,健管师3
    @RequestMapping(value = "memberCodes", method = RequestMethod.POST)
    @ResponseBody
    public String searchMemberCodes(
            @RequestParam(value = "teamId", required = true) Long teamId,
            @RequestParam(value = "doctorLevel", required = true) Integer[] doctorLevel) {//逗号隔开:如 1,2,3
        try {
            if (doctorLevel.length < 0) {
                return error(-1, "医生角色类型不能为空");
            }
//            String[] level = doctorLevel.split(",");
            List<Doctor> members = teamMemberService.searchTeamMemberCodes(teamId, doctorLevel);
            return write(200, "操作成功", "detailModelList", members);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "importData", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(HttpServletRequest request) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = request.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            teamService.importData(workbook);
            return write(200, "操作成功");
        } catch (IOException | BiffException e) {
            e.printStackTrace();
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //修改团队下转信息
    @RequestMapping(value = "updateTeamAcceptInfor", method = RequestMethod.POST)
    @ResponseBody
    public String updateTeamAcceptInfor(
            @ApiParam(name = "teamId", value = "团队id")
            @RequestParam(value = "teamId") Long teamId,
            @ApiParam(name = "leaderCode", value = "团队长code")
            @RequestParam(value = "leaderCode") String leaderCode,
            @ApiParam(name = "specialCode", value = "专病code")
            @RequestParam(value = "specialCode") String specialCode,
            @ApiParam(name = "specialName", value = "专病名称")
            @RequestParam(value = "specialName") String specialName,
            @ApiParam(name = "acceptType", value = "是否下转 1接收 0拒绝 ")
            @RequestParam(value = "acceptType") Integer acceptType
    ) {
        try {
            Boolean stateType = teamService.updateTeamAcceptInfor(teamId, leaderCode, specialCode, specialName, acceptType);
            if(stateType){
                return write(200, "操作成功");
            }
            else{
                return write(-1, "该病种已有团队接受,无法重复接受");
            }
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
}

+ 462 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageFeatureController.java

@ -0,0 +1,462 @@
package  com.yihu.customer.controller.manager.user;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.ManageFeature;
import  com.yihu.customer.entity.ManageRoleFeature;
import  com.yihu.customer.filter.RoleCache;
import com.yihu.customer.service.manager.user.ManageFeatureService;
import  com.yihu.customer.model.FeatureTree;
import  com.yihu.customer.repository.ManageRoleFeatureDao;
import com.yihu.customer.util.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by yww on 2016/12/29.
 */
@Controller
@RequestMapping("admin/feature")
@Api(description = "管理系统权限")
public class ManageFeatureController extends BaseController {
    @Autowired
    RoleCache roleCache;
    @Autowired
    private ManageFeatureService featureService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    //页面跳转
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    @ApiIgnore
    public String featureListInit() {
        return "user/feature/featureGrid";
    }
    @RequestMapping(value = "/tree", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object tree() {
        try {
            List<ManageFeature> features = featureService.search("type<>3;");
            Map<Long, FeatureTree> map = new HashMap<>();
            map.put(new Long(0), new FeatureTree(0, "三师后台管理系统", -1, "0", ""));
            for (ManageFeature model : features) {
                map.put(model.getId(), new FeatureTree(
                        model.getId(), model.getName(), model.getParentId(), model.getType(), model.getIconUrl()));
            }
            FeatureTree p;
            for (FeatureTree model : map.values()) {
                if ((p = map.get(model.getParentId())) != null)
                    p.addChild(model);
            }
            List rs = new ArrayList<>();
            rs.add(map.get(new Long(0)));
            Envelop envelop = new Envelop();
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(rs);
            return objectMapper.writeValueAsString(envelop);
        } catch (Exception ex) {
            ex.printStackTrace();
            return write(-1, "系统错误!");
        }
    }
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public Object search(String fields, String filters, String sorts, int page, int rows, String extParms) {
        try {
            Map<String, Object> params = new HashMap<>();
            params.put("fields", nullToSpace(fields));
            params.put("filters", nullToSpace(filters));
            params.put("sorts", nullToSpace(sorts));
            params.put("page", page);
            params.put("size", rows);
            List<ManageFeature> features = featureService.search(nullToSpace(fields), nullToSpace(filters), nullToSpace(sorts), page, rows);
            Envelop envelop = new Envelop();
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(features);
            return objectMapper.writeValueAsString(envelop);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "系统错误!");
        }
    }
    @RequestMapping("/gotoModify")
    @ApiIgnore
    public String gotoModify(Model model, String id, String mode, String extParms) {
        try {
            if (StringUtils.isEmpty(id)) {
                return error(-1, "权限id不能为空!");
            }
            if ("new".equals(mode)) {
                model.addAttribute("model", "");
                model.addAttribute("parentId", id);
            } else {
                ManageFeature feature = featureService.retrieve(Long.parseLong(id));
                model.addAttribute("model", objectMapper.writeValueAsString(feature));
                model.addAttribute("parentId", feature.getParentId());
            }
            model.addAttribute("mode", mode);
            model.addAttribute("extParms", extParms);
            return "user/feature/featureInfoDialog";
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "系统错误");
        }
    }
    @RequestMapping("/existence")
    @ResponseBody
    public String isExistence(String filters) {
        try {
            List list = featureService.search(filters);
            if (list != null && list.size() > 0) {
                return write(200, "存在子项", "data", list.get(0));
            }
            return write(200, "不存在子项", "data", "");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "系统错误!");
        }
    }
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(String ids, String idField, String extParms, String type) {
        try {
            if (StringUtils.isEmpty(ids)) {
                return error(-1, "权限id不能为空!");
            }
            boolean res;
            if ("unique".equals(type)) {
                Long id = Long.parseLong(ids);
                res = featureService.deleteUnique(id);
                if (res) {
                    return write(200, "删除成功");
                }
                return error(-1, "删除失败");
            } else {
                return error(-1, "只允许删除单个权限!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "系统错误!");
        }
    }
    @Autowired
    private ManageRoleFeatureDao roleFeatureDao;
    @RequestMapping("/common/update1")
    @ResponseBody
    public Object update1() {
        try {
            String sql = "SELECT * from manage_feature WHERE id not in ( " +
                    "SELECT DISTINCT a.feature_id from manage_role_feature a " +
                    ")";
            List<ManageFeature> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ManageFeature.class));
            List<ManageRoleFeature> roleFeatures = new ArrayList<>();
            for (ManageFeature manageFeature:list){
                ManageRoleFeature roleFeature = new ManageRoleFeature();
                roleFeature.setFeatureId(manageFeature.getId());
                roleFeature.setRoleId(new Long(1));//system的id固定1
                roleFeatures.add(roleFeature);
            }
            roleFeatureDao.saveAll(roleFeatures);
            return write(200, "新增成功!", "obj", "feature");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping("/update")
    @ResponseBody
    public Object update(String id, String model, String modelName, String extParms) {
        try {
            ManageFeature feature = objectMapper.readValue(model, ManageFeature.class);
            String errorMsg = "";
            if (StringUtils.isEmpty(feature.getCode())) {
                errorMsg += errorMsg + "编码不能为空!;";
            }
            if (StringUtils.isEmpty(feature.getName())) {
                errorMsg += errorMsg + "名称不能为空!;";
            }
            if (StringUtils.isEmpty(feature.getType())) {
                errorMsg += errorMsg + "类型不能为空!;";
            }
            if (!StringUtils.isEmpty(errorMsg)) {
                return error(-1, errorMsg);
            }
            if (StringUtils.isEmpty(id) || "0".equals(id)) {
                boolean res = featureService.createFeature(feature);
                if (res) {
                    return write(200, "新增成功!", "obj", feature);
                }
                return error(-1, "新增失败!");
            } else {
                boolean res = featureService.updateFeature(feature);
                if (res) {
                    return write(200, "修改成功!", "obj", feature);
                }
                return error(-1, "修改失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "操作失败!");
        }
    }
    public String nullToSpace(String str) {
        if (str == null)
            return "";
        return str;
    }
    //    @Autowired
//    private ManageFeatureService featureService;
//
//    @Autowired
//    private ObjectMapper objectMapper;
//
//    //页面跳转
//    @RequestMapping(value = "list",method = RequestMethod.GET)
//    @ApiIgnore
//    public String featureListInit(){
//        return "user/feature/featureGrid";
//    }
//
//    @RequestMapping(value = "info",method = RequestMethod.GET)
//    @ApiIgnore
//    public String featureInfoInit(){
//        return "user/feature/featureInfoDialog";
//    }
//    //增删改查
//    @RequestMapping(value = "create",method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation(value = "新增权限", notes = "*")
//    public String createFeature(
//            @ApiParam(name = "dataJson",value = "权限对象Json串")
//            @RequestParam(value = "dataJson")String dataJson){
//        try{
//            ManageFeature feature = objectMapper.readValue(dataJson, ManageFeature.class);
//            //数据验证操作
//            String errorMsg = "";
//            if(StringUtils.isEmpty(feature.getCode())){
//                errorMsg += errorMsg +"权限编码不能为空!;";
//            }else {
//                if(featureService.isCodeExist(feature.getCode())){
//                    errorMsg += errorMsg+"权限编码已存在!;";
//                }
//            }
//            if(StringUtils.isEmpty(feature.getName())){
//                errorMsg += errorMsg +"权限名称不能为空!;";
//            }else {
//                if(featureService.isNameExist(feature.getName())){
//                    errorMsg += errorMsg+ "权限名称已存在!;";
//                }
//            }
//            if(!StringUtils.isEmpty(errorMsg)){
//                return error(-1, errorMsg);
//            }
//            //新增操作(新增失败抛异常)
//            Envelop envelop = featureService.createFeature(feature);
//            if(!envelop.isSuccessFlg()){
//                return error(-1,envelop.getErrorMsg());
//            }
//            return write(200,"操作成功");
//        }catch (JsonProcessingException jex){
//            error(jex);
//            return error(-1,"JSON参数有误,请核对");
//        }catch (Exception ex){
//            error(ex);
//            return error(-1,"操作失败");
//        }
//    }
//
//    @RequestMapping(value = "update",method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation(value = "修改权限", notes = "*")
//    public String updateFeature(
//            @ApiParam(name = "dataJson",value = "权限对象Json串")
//            @RequestParam(value = "dataJson")String dataJson){
//        try{
//            ManageFeature feature = objectMapper.readValue(dataJson, ManageFeature.class);
//            //数据验证操作
//            String errorMsg = "";
//            if(feature == null || feature.getId() == 0){
//                errorMsg += errorMsg+"权限id不能为空!;";
//            }
//            if(StringUtils.isEmpty(feature.getCode())){
//                errorMsg += errorMsg +"权限编码不能为空!;";
//            }else {
//                if(featureService.isCodeExist(feature.getCode())){
//                    errorMsg += errorMsg+"权限编码已存在!;";
//                }
//            }
//            if(StringUtils.isEmpty(feature.getName())){
//                errorMsg += errorMsg +"权限名称不能为空!;";
//            }else {
//                if(featureService.isNameExist(feature.getName())){
//                    errorMsg += errorMsg+ "权限名称已存在!;";
//                }
//            }
//            if(!StringUtils.isEmpty(errorMsg)){
//                return error(-1, errorMsg);
//            }
//            //新增操作(新增失败抛异常)
//            Envelop envelop = featureService.updateFeature(feature);
//            if(!envelop.isSuccessFlg()){
//                return error(-1,envelop.getErrorMsg());
//            }
//            return write(200,"操作成功");
//        }catch (JsonProcessingException jex){
//            error(jex);
//            return error(-1,"JSON参数有误,请核对");
//        }catch (Exception ex){
//            error(ex);
//            return error(-1,"操作失败");
//        }
//    }
//
//    @RequestMapping(value = "delete",method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation(value = "删除权限", notes = "")
//    public String deleteFeature(
//            @ApiParam(name = "id",value = "权限id")
//            @RequestParam(name = "id")int id,
//            @ApiParam(name = "code",value = "权限编码")
//            @RequestParam(name = "code")String code){
//        try{
//            if(id<=0){
//                return error(-1,"权限id不能为空!");
//            }
//            if(StringUtils.isEmpty(code)){
//                return error(-1,"权限编码不能为空!");
//            }
//            featureService.deleteFeature(id, code);
//            return write(200,"操作成功");
//        }catch (Exception ex){
//            return error(-1,"操作失败!");
//        }
//    }
//
//    @RequestMapping(value = "deleteNoRole",method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation(value = "删除权限", notes = "")
//    public String deleteFeatureNoUser(
//            @ApiParam(name = "id",value = "权限id")
//            @RequestParam(name = "id")int id,
//            @ApiParam(name = "code",value = "权限编码")
//            @RequestParam(name = "code") String code){
//        try{
//            if(id<=0){
//                return error(-1,"权限id不能为空!");
//            }
//            if(StringUtils.isEmpty(code)){
//                return error(-1,"权限编码不能为空!");
//            }
//            featureService.deleteFeatureNoRole(id, code);
//            return write(200,"操作成功");
//        }catch (Exception ex){
//            return error(-1,"操作失败!");
//        }
//    }
//
//    @RequestMapping(value = "role",method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation(value = "获取权限", notes = "根据id获取权限")
//    public String getFeature(
//            @ApiParam(name = "id",value = "权限id")
//            @RequestParam(name = "id")int id){
//        ManageFeature feature = featureService.getFeature(id);
//        return write(200,"操作成功","data",feature);
//    }
//
//    @RequestMapping(value = "roles")
//    @ResponseBody
//    @ApiOperation(value = "获取权限列表-分页", notes = "*")
//    public String searchFeatures(
//            @ApiParam(name = "name",value = "权限名称",defaultValue = "")
//            @RequestParam(value = "name",required = false)String name,
//            @ApiParam(name = "page",value = "页码",defaultValue = "1")
//            @RequestParam(value = "page",required = false)Integer page,
//            @ApiParam(name = "rows",value = "每页数",defaultValue = "15")
//            @RequestParam(value = "rows",required = false)Integer pageSize){
//        try{
//            Page<ManageFeature> manageFeatures = featureService.searchFeatures(name, page, pageSize);
//            return write(200,"操作成功",page,pageSize,manageFeatures);
//        }catch (Exception ex){
//            error(ex);
//            return error(-1,"操作失败!");
//        }
//
//    }
//
    @RequestMapping(value = "featuresNoPage")
    @ResponseBody
    @ApiOperation(value = "获取权限列表-不分页", notes = "*")
    public Object searchFeaturesNoPage(String searchNm) {
        try {
            return featureService.search("nam?" + searchNm + ";");
        } catch (Exception ex) {
            error(ex);
            return "[]";
        }
    }
    @RequestMapping(value = "isCodeExist", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "判断权限编码是否存在,唯一", notes = "*")
    public Object isCodeExist(
            @ApiParam(name = "code", value = "权限编码", defaultValue = "")
            @RequestParam(name = "code") String code) {
        return featureService.isCodeExist(code);
    }
    @RequestMapping(value = "isNameExist", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "判断权限名称是否存在,同一级唯一", notes = "*")
    public Object isNameExist(
            @ApiParam(name = "name", value = "权限名称", defaultValue = "")
            @RequestParam(name = "name") String name,
            @ApiParam(name = "parentId", value = "上一级权限id")
            @RequestParam(value = "parentId") long parentId) {
        return featureService.isNameExist(name, parentId);
    }
    @RequestMapping(value = "isUrlExist", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "判断权限名称是否存在,唯一", notes = "*")
    public Object isUrlExist(
            @ApiParam(name = "url", value = "权限名称", defaultValue = "")
            @RequestParam(name = "url") String url) {
        return featureService.isUrlExist(url);
    }
}

+ 268 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageRangeController.java

@ -0,0 +1,268 @@
package  com.yihu.customer.controller.manager.user;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.Doctor;
import  com.yihu.customer.entity.WlyyRole;
import com.yihu.customer.service.manager.user.ManageRangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
/**
 * Created by Reece on 2018/1/16.
 */
@Controller
@RequestMapping(value = "admin/range")
@Api(description = "管理端医生管理")
public class ManageRangeController extends BaseController {
    @Autowired
    private ManageRangeService rangeService;
    /**
     * 初始化及关键字搜索列表页
     * @return 返回列表页路径
     */
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String listPageInit(){
        return "user/range/user_role_list";
    }
    /**
     *新增时跳转到新增页面
     * @return 编辑页面路径
     */
    @RequestMapping(value = "infoInit",method = RequestMethod.GET)
    public String addPageInit(){
        return "user/range/user_role_add";
    }
    /**
     * 查看和编辑时带参页面跳转
     * @param doc 医生code
     * @param mode
     * @return
     */
    @RequestMapping(value = "editInit",method = RequestMethod.GET)
    public String editPageInit(String doc,String hospital,String mode){
        request.setAttribute("doc",doc);
        request.setAttribute("hospital",hospital);
        request.setAttribute("mode",mode);
        return "user/range/user_role_modify";
    }
    /**
     * wlyy_user_role 列表展示及页面搜索医生信息
     * @param name
     * @param idcard
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "userRoleList")
    @ResponseBody
    public String searchList(
            @RequestParam(value = "name",required = false) String name,
            @RequestParam(value = "mobile",required = false) String idcard,
            @RequestParam(value= "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
//            Page<Doctor> userRoleList = rangeService.searchList(name, idcard, page, pageSize);
            List<Doctor> userRoleList = rangeService.searchList(name, idcard, page, pageSize);
            List<Doctor> countRoleList = rangeService.searchList(name, idcard);
            return write(200,"操作成功",page,pageSize,countRoleList.size(),userRoleList);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "exportExcel", method = RequestMethod.POST)
    @ApiOperation("导出用户角色")
    @ResponseBody
    public void searchList(
            @RequestParam(value = "name",required = false) String name,
            @RequestParam(value = "idcard",required = false) String idcard,
            HttpServletResponse response) {
        try {
            List<Doctor> list = rangeService.searchList(name, idcard);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("userRoleList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os, list);
        } catch (Exception ex) {
            error(ex);
        }
    }
    private void write(OutputStream os, List<Doctor> list) throws Exception {
        WritableWorkbook wwb = Workbook.createWorkbook(os);
        try {
            WritableSheet sheet = wwb.createSheet("sheet", 1);
            String header[] = {"医生姓名", "性别", "身份证号", "手机号码",  "所属机构"};
            int i = 0;
            for (String h : header) {
                addCell(sheet, 0, i, h);
                i++;
            }
            int j = 1;
            for (Doctor d: list) {
                addCell(sheet, j, 0, d.getName());
                if(d.getSex() == null || d.getSex() == 0) {
                    addCell(sheet, j, 1, "未知");
                }else if(d.getSex() == 1){
                    addCell(sheet, j, 1, "男");
                }else if(d.getSex() == 2){
                    addCell(sheet, j, 1, "女");
                }
                addCell(sheet, j, 2, d.getIdCard());
                addCell(sheet, j, 3, d.getMobile());
                addCell(sheet, j, 4, d.getHospitalName());
                j++;
            }
            wwb.write();
            wwb.close();
        } catch (Exception e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
        }
    }
    private void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        ws.addCell(label);
    }
    /**
     * 搜索新增的医生信息
     * @return
     */
    @RequestMapping(value = "doctorList")
    @ResponseBody
    public String getDoctorList(
            @RequestParam(value = "name",required = false) String name,
            @RequestParam(value = "mobile",required = false) String idcard,
            @RequestParam(value= "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            Page<Doctor> doctorList = rangeService.getDoctorList(name, idcard,page,pageSize);
            return write(200,"操作成功",page,pageSize,doctorList);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    /**
     * 查询所有的医院信息
     * @return
     */
    @RequestMapping(value = "hostpitalList")
    @ResponseBody
    public String getHostpitalList( ){
        try{
            List<WlyyRole> roles = rangeService.getHostpitalList();
            return write(200,"操作成功","data",roles);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    /**
     * 列表页根据医生code查询医生详情
     * @param doc 医生code
     * @param hospital 医院code
     * @return
     */
    @RequestMapping(value = "userRoleDetail")
    @ResponseBody
    public String getUserRole(
            @ApiParam(name = "doc", defaultValue = "2")
            @RequestParam(name = "doc", required = true) String doc,
            @ApiParam(name = "hospital", defaultValue = "350001")
            @RequestParam(name = "hospital", required = true) String hospital) {
        try{
            List<Doctor> doctor = rangeService.getUser(doc,hospital);
            return write(200,"操作成功","data",doctor);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //删除医生在wlyy_user_role表的信息
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deleteUserRole(String doc,String hospital){
        try{
            if (StringUtils.isEmpty(doc) || StringUtils.isEmpty(hospital)){
                return error(-1,"参数错误!");
            }
            rangeService.deleteUserRole(doc,hospital);
            return write(200,"操作成功!");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    /**
     * 新增医生信息到wlyy_user_role
     * @param info 新增医生及医院 信息 {["doc": "新增医生code(批量添加逗号分隔)","hospital" : "新增医生权限code(批量添加逗号分隔)"],[]}
     * @return
     */
    @RequestMapping(value = "create")
    @ResponseBody
    public String createUserRole(String info){
        try{
            String result = rangeService.saveUserRole(info);
            return write(200,result);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    /**
     * 编辑医生相关信息
     * @param doc 编辑医生code(批量添加逗号分隔)
     * @param oldHospital 修改前的医生权限code
     * @param hospital 修改后的医生权限code
     * @return
     */
    @RequestMapping(value = "update")
    @ResponseBody
    public String updateUserRole(String doc,String oldHospital,String hospital){
        try{
            //先删除原信息在
            rangeService.updateUserRole(doc,oldHospital,hospital);
            return write(200,"操作成功!");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 235 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageRoleFeatureController.java

@ -0,0 +1,235 @@
package  com.yihu.customer.controller.manager.user;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.ManageFeature;
import  com.yihu.customer.entity.ManageRoleFeature;
import com.yihu.customer.service.manager.user.ManageFeatureService;
import com.yihu.customer.service.manager.user.ManageRoleFeatureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by yww on 2016/12/29.
 */
@Controller
@RequestMapping("admin/roleFeature")
@Api(description = "管理系统角色-权限关系")
public class ManageRoleFeatureController extends BaseController {
    @Autowired
    private ManageRoleFeatureService roleFeatureService;
    @Autowired
    private ManageFeatureService featureService;
    @RequestMapping(value = "initial")
    public String initial(Model model, String obj) {
        model.addAttribute("obj", obj);
        return "user/roles/rolesFeature";
    }
    /**
     * 角色组权限列表查询接口(左侧查询出所有权限,不分页,页面检索)(右侧查询角色组已配置的权限,不分页)
     *
     * @param treeType(查询列表类型:所有权限;角色组已配置权限)
     * @param roleId
     * @return
     * @throws Exception
     */
    @RequestMapping("/searchFeatureTree")
    @ResponseBody
    public Object searchFeatureTree(String treeType, long roleId) throws Exception {
        if (treeType.equals("configFeature")) {
            return featureService.findByRoleId(roleId);
        } else {
            List<ManageFeature> features = featureService.search("");
            if (features.size() > 0) {
                for (ManageFeature m : features) {
                    ManageRoleFeature relation = roleFeatureService.findRelation(m.getId(), roleId);
                    m.setIschecked(false);
                    if (relation != null) {
                        m.setIschecked(true);
                    }
                }
            }
            return features;
        }
    }
    @RequestMapping(value = "updateFeatureConfig")
    @ApiOperation(value = "根据角色组、应用权限id批量修改,一对多")
    @ResponseBody
    public String batchUpdateRoleFeatureRelation(
            @ApiParam(name = "roleId", value = "角色组Id")
            @RequestParam(value = "roleId") long roleId,
            @ApiParam(name = "featureIds", value = "选择的应用权限ids", defaultValue = "")
            @RequestParam(name = "featureIds", required = false) String featureIds) throws Exception {
        boolean bo = false;
        //根据传入的参数获取新增、删除ids
        if (StringUtils.isEmpty(featureIds)) {
            //删除角色组下配置的所有应用权限
            bo = roleFeatureService.deleteRoleFeatureRelationByRoleId(roleId);
            if (bo)
                return write(200, "操作成功!");
            return error(-1, "操作成功!");
        }
        //获取新增和删除ids
        String[] featureIdsStr = featureIds.split(",");
        List<Long> newFeatureIds = new ArrayList<>();
        for (int i = 0; i < featureIdsStr.length; i++) {
            newFeatureIds.add(Long.parseLong(featureIdsStr[i]));
        }
        Collection<ManageRoleFeature> roleFeatures = roleFeatureService.findByField("roleId", roleId);
        if (roleFeatures == null || roleFeatures.size() == 0) {
            //原角色组不存在配置权限则直接新增
            Long[] ids = new Long[newFeatureIds.size()];
            bo = roleFeatureService.batchUpdateRoleFeatureRelation(roleId, newFeatureIds.toArray(ids), "");
            if (bo)
                return write(200, "操作成功!");
            return error(-1, "操作成功!");
        }
        String deleteFeatureIds = "";
        StringBuffer deleteBuffer = new StringBuffer();
        for (ManageRoleFeature m : roleFeatures) {
            Long featureId = m.getFeatureId();
            if (newFeatureIds.contains(featureId)) {
                newFeatureIds.remove(featureId);
                continue;
            }
            deleteBuffer.append(featureId);
            deleteBuffer.append(",");
        }
        if (deleteBuffer.length() > 0) {
            deleteFeatureIds = deleteBuffer.substring(0, deleteBuffer.length() - 1);
        }
        Long[] addFeatureIds = newFeatureIds.toArray(new Long[newFeatureIds.size()]);
        bo = roleFeatureService.batchUpdateRoleFeatureRelation(roleId, addFeatureIds, deleteFeatureIds);
        if (bo)
            return write(200, "操作成功!");
        return error(-1, "操作成功!");
    }
//    @RequestMapping(value = "create",method = RequestMethod.POST)
//    @ApiOperation(value = "为角色组配置功能权限,单个")
//    @ResponseBody
//    public String createRoleFeature(String roleId,String featureId){
//        if(StringUtils.isEmpty(featureId)){
//            return error(-1, "权限不能为空!");
//        }
//        if(StringUtils.isEmpty(roleId)){
//            return error(-1,"角色组id不能为空!");
//        }
//        try{
//            ManageRoleFeature model = new ManageRoleFeature();
//            model.setRoleId(Long.parseLong(roleId));
//            model.setFeatureId(Long.parseLong(featureId));
//            ManageRoleFeature roleFeatureRelationNew = roleFeatureService.save(model);
//            return write(200, "操作成功");
//        }catch (Exception ex){
//            return error(-1,"操作失败!");
//        }
//    }
//    @RequestMapping(value = "delete",method = RequestMethod.POST)
//    @ApiOperation(value = "根据角色组id,权限Id删除角色组-功能权限关系")
//    @ResponseBody
//    public boolean deleteRoleFeature(
//            @ApiParam(name = "featureId",value = "功能权限id")
//            @RequestParam(value = "featureId") String featureId,
//            @ApiParam(name = "roleId",value = "角色组id")
//            @RequestParam(value = "roleId") String roleId){
//        ManageRoleFeature relation = roleFeatureService.findRelation(Long.parseLong(featureId), Long.parseLong(roleId));
//        if(null != relation){
//            roleFeatureService.delete(relation.getId());
//        }
//        return true;
//    }
//
//    @RequestMapping(value = "delete/byRoleId",method = RequestMethod.POST)
//    @ApiOperation(value = "根据角色组id删除所配置的应用权限")
//    @ResponseBody
//    public boolean deleteRoleFeatureRelationByRoleId(
//            @ApiParam(name = "roleId",value = "角色组id")
//            @RequestParam(value = "roleId") Long roleId){
//        return  roleFeatureService.deleteRoleFeatureRelationByRoleId(roleId);
//    }
//
//    @RequestMapping(value = "update/batch",method = RequestMethod.POST)
//    @ApiOperation(value = "批量修改角色组-应用权限关系,一对多")
//    @ResponseBody
//    public boolean batchUpdateRoleFeatureRelation(
//            @ApiParam(name = "roleId",value = "角色组Id")
//            @RequestParam(value = "roleId") Long roleId,
//            @ApiParam(name = "addFeatureIds",value = "要新增的featureIds",defaultValue = "")
//            @RequestParam(name = "addFeatureIds",required = false) Long[] addFeatureIds,
//            @ApiParam(name = "deleteFeatureIds",value = "要删除的featureIds",defaultValue = "")
//            @RequestParam(value = "deleteFeatureIds",required = false) String deleteFeatureIds) throws Exception{
//        roleFeatureService.batchUpdateRoleFeatureRelation(roleId,addFeatureIds,deleteFeatureIds);
//        return true;
//    }
//
//    @RequestMapping(value = "roleFeatures",method = RequestMethod.GET)
//    @ApiOperation(value = "查询角色组-功能权限关系列表---分页")
//    @ResponseBody
//    public String searchRoleFeature(
//            @ApiParam(name = "roleId", value = "角色id", defaultValue = "1")
//            @RequestParam(value = "size", required = true) long roleId,
//            @ApiParam(name = "page", value = "页码", defaultValue = "1")
//            @RequestParam(value = "page", required = false) int page,
//            @ApiParam(name = "rows", value = "分页大小", defaultValue = "15")
//            @RequestParam(value = "rows", required = false) int pageSize){
//
//        try{
//            String filters = "roleId="+roleId+";";
//            if(page<=0){
//                page = 1;
//            }
//            if (pageSize<=0){
//                pageSize = 15;
//            }
//            List list = roleFeatureService.search("", filters, "", page, pageSize);
//            long total = roleFeatureService.getCount(filters);
//            return write(200,"操作成功",page,pageSize,total,list);
//        }catch (Exception ex){
//            error(ex);
//            return error(-1,"操作失败!");
//        }
//    }
//    @RequestMapping(value = "roleFeaturesNoPage",method = RequestMethod.GET)
//    @ApiOperation(value = "查询角色组-功能权限关系列表---不分页")
//    @ResponseBody
//    public String searchRoleFeatureNoPaging(
//            @ApiParam(name = "roleId", value = "", defaultValue = "1")
//            @RequestParam(value = "roleId", required = true) String roleId) {
//        try {
//            String filters = "roleId=" + roleId + ";";
//            List list = roleFeatureService.search(filters);
//            return write(200, "操作成功", "data", list);
//        } catch (Exception ex) {
//            error(ex);
//            return error(-1, "操作失败!");
//        }
//    }
//
//    @RequestMapping(value = "isExist", method = RequestMethod.GET)
//    @ApiOperation(value = "通用根据过滤条件,判断是否存在")
//    @ResponseBody
//    public boolean getAppFeaturesFilter(
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters) throws Exception {
//        Long count = roleFeatureService.getCount(filters);
//        return count>0?true:false;
//    }
}

+ 173 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageRoleUserController.java

@ -0,0 +1,173 @@
package  com.yihu.customer.controller.manager.user;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.ManageRoleUser;
import com.yihu.customer.service.manager.user.ManageRoleUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by yww on 2016/12/29.
 */
@Controller
@RequestMapping("admin/roleUser")
@Api(description = "管理系统角色组人员配置")
public class ManageRoleUserController extends BaseController {
    @Autowired
    private ManageRoleUserService roleUserService;
    @RequestMapping("/initial")
    public String initial(Model model, String obj) {
        model.addAttribute("obj", obj);
        return "user/roles/rolesUsers";
    }
    @RequestMapping(value = "update", method = RequestMethod.POST)
    @ApiOperation(value = "单个角色组人员的增删")
    @ResponseBody
    public boolean updateRoleUser(
            @ApiParam(name = "userCode", value = "人员编码")
            @RequestParam(value = "userCode") String userCode,
            @ApiParam(name = "roleId", value = "角色组id")
            @RequestParam(value = "roleId") long roleId,
            @ApiParam(name = "mode", value = "增/删,create/delete")
            @RequestParam(value = "mode") String mode) {
        if (StringUtils.equals("create", mode)) {
            return roleUserService.create(userCode, roleId);
        }
        if (StringUtils.equals("delete", mode)) {
            ManageRoleUser roleUser = roleUserService.findRelation(userCode, roleId);
            if (null != roleUser) {
                roleUserService.delete(roleUser.getId());
            }
        }
        return true;
    }
    @RequestMapping(value = "create", method = RequestMethod.POST)
    @ApiOperation(value = "为角色组配置人员,单个")
    @ResponseBody
    public boolean createRoleUser(
            @ApiParam(name = "userCode", value = "人员编码")
            @RequestParam(value = "userCode") String userCode,
            @ApiParam(name = "roleId", value = "角色组id")
            @RequestParam(value = "roleId") long roleId) {
        return roleUserService.create(userCode, roleId);
    }
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    @ApiOperation(value = "根据角色组编码,人员Id删除角色组人员,单个")
    @ResponseBody
    public boolean deleteRoleUser(
            @ApiParam(name = "userCode", value = "人员编码")
            @RequestParam(value = "userCode") String userCode,
            @ApiParam(name = "roleId", value = "角色组id")
            @RequestParam(value = "roleId") String roleId) {
        ManageRoleUser roleUser = roleUserService.findRelation(userCode, Long.parseLong(roleId));
        if (null != roleUser) {
            roleUserService.delete(roleUser.getId());
        }
        return true;
    }
    @RequestMapping(value = "delete/roleUsers", method = RequestMethod.POST)
    @ApiOperation(value = "根据人员编码,删除其与所有角色组关系")
    @ResponseBody
    public boolean deleteRoleUserBuUserId(
            @ApiParam(name = "userCode", value = "人员编码")
            @RequestParam(value = "userCode") String userCode) throws Exception {
        Collection<ManageRoleUser> roleUsers = roleUserService.search("userCode=" + userCode);
        List<Long> ids = new ArrayList<>();
        for (ManageRoleUser roleUser : roleUsers) {
            ids.add(roleUser.getId());
        }
        roleUserService.delete(ids);
        return true;
    }
//    @RequestMapping(value = "deleteBatch/roleUsers",method = RequestMethod.POST)
//    @ApiOperation(value = "人员id,角色组ids,批量删除人员-角色组关系")
//    @ResponseBody
//    public boolean batchDeleteRoleUserRelation(
//            @ApiParam(name = "userCode",value = "人员编码")
//            @RequestParam(value = "userCode") String userCode,
//            @ApiParam(name = "roleIds",value = "角色组ids")
//            @RequestParam(value = "roleIds") String roleIds) throws Exception{
//        return roleUserService.batchDeleteRoleUserRelation(userCode, roleIds);
//    }
//    @RequestMapping(value = "create/roleUsers",method = RequestMethod.POST)
//    @ApiOperation(value = "批量新增人员所属角色组,一对多")
//    @ResponseBody
//    public boolean batchCreateRolUsersRelation(
//            @ApiParam(name = "userCode",value = "人员编码")
//            @RequestParam(value = "userCode") String userCode,
//            @ApiParam(name = "roleIds",value = "角色组ids,多个用逗号隔开")
//            @RequestParam(value = "roleIds") String roleIds) throws Exception{
//        roleUserService.batchCreateRoleUsersRelation(userCode,roleIds);
//        return true;
//    }
//    @RequestMapping(value = "update/roleUsers",method = RequestMethod.POST)
//    @ApiOperation(value = "批量修改人员所属角色组关系,一对多")
//    @ResponseBody
//    public boolean batchUpdateRoleUsersRelation(
//            @ApiParam(name = "userCode",value = "人员编码")
//            @RequestParam(value = "userCode") String userCode,
//            @ApiParam(name = "roleIds",value = "角色组ids,多个用逗号隔开")
//            @RequestParam(value = "roleIds") String roleIds) throws Exception{
//        roleUserService.batchUpdateRoleUsersRelation(userCode,roleIds);
//        return true;
//    }
    @RequestMapping(value = "roleUsers", method = RequestMethod.POST)
    @ApiOperation(value = "查询角色组人员关系列表---分页")
    @ResponseBody
    public String searchRoleUser(
            @ApiParam(name = "roleId", value = "", defaultValue = "1")
            @RequestParam(value = "roleId", required = true) String roleId,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "rows", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "rows", required = false) int pageSize) {
        try {
            Page<ManageRoleUser> manageRoleUsers = roleUserService.searchRoleUser(roleId, page, pageSize);
            return write(200, "操作成功", page, pageSize, manageRoleUsers);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "roleUsersNoPage", method = RequestMethod.POST)
    @ApiOperation(value = "查询角色组人员关系列表---不分页")
    @ResponseBody
    public String searchRoleUserNoPaging(
            @ApiParam(name = "roleId", value = "", defaultValue = "1")
            @RequestParam(value = "roleId", required = true) String roleId) {
        try {
            String filters = "roleId=" + roleId + ";";
            List list = roleUserService.search(filters);
            return write(200, "操作成功", "detailModelList", list);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
}

+ 255 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/ManageRolesController.java

@ -0,0 +1,255 @@
package  com.yihu.customer.controller.manager.user;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.ManageRoles;
import com.yihu.customer.service.manager.user.ManageRoleUserService;
import com.yihu.customer.service.manager.user.ManageRolesService;
import com.yihu.customer.util.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
 * Created by yww on 2016/12/29.
 */
@Controller
@RequestMapping("admin/roles")
@Api(description = "管理系统用户角色")
public class ManageRolesController extends BaseController {
    @Autowired
    private ManageRolesService rolesService;
    @Autowired
    private ManageRoleUserService roleUserService;
    @Autowired
    private ObjectMapper objectMapper;
    //页面跳转
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    @ApiIgnore
    public String rolesListInit() {
        return "user/roles/roles";
    }
    @RequestMapping(value = "info")
    @ApiIgnore
    public String roleInfoInit(Model model, @RequestParam(value = "id", required = false) long id, String mode) throws Exception {
        model.addAttribute("mode", mode);
        if (id > 0 && (StringUtils.equals("modify", mode) || StringUtils.equals("view", mode))) {
            model.addAttribute("obj", objectMapper.writeValueAsString(rolesService.retrieve(id)));
        } else {
            model.addAttribute("obj", "{}");
        }
        return "user/roles/rolesInfoDialog";
    }
    @RequestMapping(value = "create", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "创建角色", notes = "*")
    public String createRole(
            @ApiParam(name = "dataJson", value = "角色对象Json串")
            @RequestParam(value = "dataJson") String dataJson) {
        try {
            ManageRoles role = objectMapper.readValue(dataJson, ManageRoles.class);
            //数据验证操作
            String errorMsg = "";
            if (StringUtils.isEmpty(role.getCode())) {
                errorMsg += errorMsg + "角色编码不能为空!;";
            } else {
                if (rolesService.isCodeExist(role.getCode())) {
                    errorMsg += errorMsg + "角色编码已存在!;";
                }
            }
            if (StringUtils.isEmpty(role.getName())) {
                errorMsg += errorMsg + "角色名称不能为空!;";
            } else {
                if (rolesService.isNameExist(role.getName())) {
                    errorMsg += errorMsg + "角色名称已存在!;";
                }
            }
            if (!StringUtils.isEmpty(errorMsg)) {
                return error(-1, errorMsg);
            }
            //新增操作(新增失败抛异常)
            Envelop envelop = rolesService.createRole(role);
            if (!envelop.isSuccessFlg()) {
                return error(-1, envelop.getErrorMsg());
            }
            return write(200, "操作成功");
        } catch (JsonProcessingException jex) {
            error(jex);
            return error(-1, "JSON参数有误,请核对");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "update", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "修改角色", notes = "*")
    public String updateRole(
            @ApiParam(name = "dataJson", value = "角色对象Json串")
            @RequestParam(value = "dataJson") String dataJson) {
        try {
            ManageRoles role = objectMapper.readValue(dataJson, ManageRoles.class);
            //数据验证操作
            String errorMsg = "";
            if (role == null || role.getId() == 0) {
                errorMsg += errorMsg + "角色id不能为空!;";
            }
            //manage角色不允许修改
            if (role.getId() == 1 || StringUtils.equals(role.getCode(), "systemManager")) {
                return error(-1, "系统管理员角色不允许修改!");
            }
            ManageRoles old = rolesService.retrieve(role.getId());
            if (StringUtils.isEmpty(role.getCode())) {
                errorMsg += errorMsg + "角色编码不能为空!;";
            } else {
                if (rolesService.isCodeExist(role.getCode()) && !StringUtils.equals(role.getCode(), old.getCode())) {
                    errorMsg += errorMsg + "角色编码已存在!;";
                }
            }
            if (StringUtils.isEmpty(role.getName())) {
                errorMsg += errorMsg + "角色名称不能为空!;";
            } else {
                if (rolesService.isNameExist(role.getName()) && !StringUtils.equals(role.getName(), old.getName())) {
                    errorMsg += errorMsg + "角色名称已存在!;";
                }
            }
            if (!StringUtils.isEmpty(errorMsg)) {
                return error(-1, errorMsg);
            }
            //新增操作(新增失败抛异常)
            Envelop envelop = rolesService.updateRole(role);
            if (!envelop.isSuccessFlg()) {
                return error(-1, envelop.getErrorMsg());
            }
            return write(200, "操作成功");
        } catch (JsonProcessingException jex) {
            error(jex);
            return error(-1, "JSON参数有误,请核对");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除角色", notes = "删除未配置人员角色,并删除角色权限关系")
    public String deleteRoleNoUser(
            @ApiParam(name = "id", value = "角色id")
            @RequestParam(name = "id") long id,
            @ApiParam(name = "code", value = "角色编码")
            @RequestParam(name = "code") String code) {
        try {
            if (id <= 0) {
                return error(-1, "角色id不能为空!");
            }
            if (id == 1 || StringUtils.equals(code, "systemManager")) {
                return error(-1, "系统管理员角色不允许删除!");
            }
            if (StringUtils.isEmpty(code)) {
                return error(-1, "角色编码不能为空!");
            }
            //判断角色组是否有配置人员,有配置则不能删除
            boolean bo = roleUserService.isRoleExistUser(id);
            if (bo) {
                return error(-1, "角色存在人员配置,请先删除!");
            }
            rolesService.deleteRoleNoUser(id, code);
            return write(200, "操作成功");
        } catch (Exception ex) {
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "role", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取角色", notes = "根据id获取角色")
    public String getRole(
            @ApiParam(name = "id", value = "角色id")
            @RequestParam(name = "id") int id) {
        ManageRoles role = rolesService.getRole(id);
        return write(200, "操作成功", "data", role);
    }
    @RequestMapping(value = "rolesList")
    @ResponseBody
    @ApiOperation(value = "获取角色列表-分页", notes = "*")
    public String searchRoles(
            @ApiParam(name = "searchNm", value = "角色编码或名称", defaultValue = "")
            @RequestParam(value = "searchNm", required = false) String searchNm,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "rows", value = "每页数", defaultValue = "15")
            @RequestParam(value = "rows", required = false) Integer pageSize) {
        try {
            Page<ManageRoles> manageRoles = rolesService.searchRoles(searchNm, page, pageSize);
            return write(200, "操作成功", page, pageSize, manageRoles);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "rolesNoPage", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取角色列表-不分页", notes = "*")
    public String searchRolesNoPage(
            @ApiParam(name = "name", value = "角色名称", defaultValue = "")
            @RequestParam(name = "name", required = false) String name) {
        try {
            List<ManageRoles> manageRoles = rolesService.searchRolesNoPage(name);
            return write(200, "操作成功", "data", manageRoles);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "isCodeExist", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "判断角色编码是否存在", notes = "*")
    public boolean isCodeExist(
            @ApiParam(name = "code", value = "角色编码", defaultValue = "")
            @RequestParam(name = "code") String code) {
        return rolesService.isCodeExist(code.trim());
    }
    @RequestMapping(value = "isNameExist", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "判断角色名称是否存在", notes = "*")
    public boolean isNameExist(
            @ApiParam(name = "name", value = "角色名称", defaultValue = "")
            @RequestParam(name = "name") String name) {
        return rolesService.isNameExist(name.trim());
    }
    @RequestMapping(value = "isRoleExistUser", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "判断角色是否配置人员", notes = "*")
    public boolean isRoleExistUser(
            @ApiParam(name = "id", value = "角色id", defaultValue = "")
            @RequestParam(value = "id") long id) {
        return roleUserService.isRoleExistUser(id);
    }
}

+ 286 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/user/UserController.java

@ -0,0 +1,286 @@
package  com.yihu.customer.controller.manager.user;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.User;
import com.yihu.customer.service.manager.user.UserService;
import com.yihu.customer.util.MD5;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * Created by yww on 2016/12/6.
 */
@Controller
@RequestMapping(value = "admin/user")
public class UserController extends BaseController {
    @Autowired
    private UserService userService;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String listPageInit(){
        return "user/user_list";
    }
    @RequestMapping(value = "infoInit",method = RequestMethod.GET)
    public String infoPageInit(Long id,String mode){
        request.setAttribute("id",id);
        request.setAttribute("mode",mode);
        return "user/user_modify";
    }
    @RequestMapping(value = "userList")
    @ResponseBody
    public String searchList(
            @RequestParam(value = "code",required = false) String code,
            @RequestParam(value = "name",required = false) String name,
            @RequestParam(value = "mobile",required = false) String mobile,
            @RequestParam(value= "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            Page<User> userPage = userService.searchList(code, name, mobile, page, pageSize);
            return write(200,"操作成功",page,pageSize,userPage);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "user")
    @ResponseBody
    public String getUser(
            @ApiParam(name = "id", defaultValue = "2")
            @RequestParam(name = "id", required = true) Long id) {
        try{
            User user = userService.retrieve(id);
            return write(200,"操作成功","data",user);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "isCodeExist")
    @ResponseBody
    public String isCodeExist(String code){
        List<User> users = userService.findByField("code", code);
        if(users != null && users.size()>0){
            return "true";
        }
        return "false";
    }
    @RequestMapping(value = "isMobileExist")
    @ResponseBody
    public String isMobileExist(String mobile){
        List<User> users = userService.findByField("mobile", mobile);
        if(users != null && users.size()>0){
            return "true";
        }
        return "false";
    }
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deleteUser(Long id){
        try{
            if (id == null) {
                return error(-1, "id不能为空!");
            }
            User user = userService.retrieve(id);
            if (StringUtils.equals(user.getCode(), "admin")) {
                return error(-1, "超级管理员admin不允许删除!");
            }
            userService.deleteUser(id);
            return write(200,"操作成功!");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "create")
    @ResponseBody
    public String createUser(String jsonData){
        try{
            User user = objectMapper.readValue(jsonData, User.class);
            String mobile = user.getMobile();
            if(mobile == null){
                return write(-1,"手机号不能为空");
            }
            user.setCzrq(new Date());
            String password=user.getMobile().substring(5);
            String salt= UUID.randomUUID().toString().replace("-", "");
            password = MD5.GetMD5Code("a"+password+"*"+salt);
            user.setPassword(password);
            user.setSalt(salt);
            User userNew = userService.save(user);
            return write(200,"操作成功!");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "update")
    @ResponseBody
    public String updateUser(String jsonData){
        try{
    
            JSONObject data = JSONObject.parseObject(jsonData);
            
            String oldpsw = data.getString("oldpsw");
            
            User user = objectMapper.readValue(jsonData, User.class);
            String mobile = user.getMobile();
            if(mobile == null){
                return write(-1,"手机号不能为空");
            }
            User userNew = userService.retrieve(user.getId());
            userNew.setCode(user.getCode());
            userNew.setName(user.getName());
            userNew.setType(user.getType());
            userNew.setMobile(user.getMobile());
            userNew.setOrganizationId(user.getOrganizationId());
            userNew.setRoles(user.getRoles());
    
            String password=user.getPassword();
            
            //如果新密码不为空,则进入修改密码的分支
            if(StringUtils.isNotBlank(password)){
                
                if(StringUtils.isBlank(oldpsw)){
                    return error(-1,"旧密码不能为空");
                }
    
                oldpsw =  MD5.GetMD5Code(oldpsw+userNew.getSalt());
    
                if(!oldpsw.equals(userNew.getPassword())){
                    return error(-1,"旧密码错误,无法修改");
                }
                if(!userService.testPwd(password)){
                    return error(-1,"密码必须是包含大小写字母、数字、特殊符号的8位以上组合!");
                }
    
                String salt= UUID.randomUUID().toString().replace("-", "");
                password = MD5.GetMD5Code(password+salt);
                userNew.setPassword(password);
                userNew.setSalt(salt);
            }
//            //修改手机号对应初始化密码(因暂未提供修改密码操作)-手机号后六位
//            if(userNew.getMobile() != user.getMobile()){
//                String password=mobile.substring(5);
//                String salt= UUID.randomUUID().toString().replace("-", "");
//                password = MD5.GetMD5Code(password+salt);
//                userNew.setPassword(password);
//                userNew.setSalt(salt);
//            }
            userNew = userService.save(userNew);
            return write(200,"操作成功!");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //初始化密码
    @RequestMapping(value = "initPwd")
    @ResponseBody
    public String initPwd(
            @RequestParam(value = "mobile",required = true)String mobile){
        try{
            boolean res = userService.initPwd(mobile);
            if(!res){
                return error(-1,"操作失败!");
            }
            return write(200,"操作成功!");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    //修改密码
    @RequestMapping(value = "changePwd",method = RequestMethod.POST)
    @ResponseBody
    public String changePwd(
            @RequestParam(value = "id")Long id,
            @RequestParam(value = "oldPwd")String oldPwd,
            @RequestParam(value = "newPwd1")String newPwd1,
            @RequestParam(value = "newPwd2")String newPwd2,
            HttpServletRequest req){
        try {
            User curUser = userService.retrieve(id);
            if(curUser==null){
                return error(-1,"用户不存在");
            }
            if(StringUtils.isBlank(oldPwd)){
                return error(-1,"旧密码不能为空");
            }
            if(StringUtils.isBlank(newPwd1)){
                return error(-1,"新密码不能为空");
            }
            if(!newPwd1.equals(newPwd2)){
                return error(-1,"两次输入的新密码不一致");
            }
            if(!userService.testPwd(newPwd1)){
                return error(-1,"密码必须是包含大小写字母、数字、特殊符号的8位以上组合");
            }
            oldPwd =  MD5.GetMD5Code(oldPwd+curUser.getSalt());
            if(!oldPwd.equals(curUser.getPassword())){
                return error(-1,"旧密码错误,无法修改");
            }
            newPwd1 = MD5.GetMD5Code(newPwd1+curUser.getSalt());
            curUser.setPassword(newPwd1);
            userService.save(curUser);
            //更新缓存
            req.getSession().setAttribute("authPw",userService.saveUserPwlimitDate(curUser.getCode()));
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    //根据姓名获取所有有效用户列表(用于分页下拉框)
    @RequestMapping("/searchUsers")
    @ResponseBody
    public Object searchUsers(String searchNm, int page, int rows) {
        try {
            Page<User> users = userService.searchUsers(searchNm, page, rows);
            return write(200, "操作成功", page, rows, users);
        } catch (Exception ex) {
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 58 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/vaccin/VaccinController.java

@ -0,0 +1,58 @@
package  com.yihu.customer.controller.manager.vaccin;
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.vaccin.VaccinService;
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.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * Created by wxw on 2019/1/14.
 *
 * @author wxw.
 */
@Controller
@RequestMapping(value = "/admin/vaccin", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "国家疫苗信息")
public class VaccinController extends BaseController {
    @Autowired
    private VaccinService vaccinService;
    @RequestMapping(value = "/initial",method = RequestMethod.GET)
    public String ReplyHis () {
        return "vaccin/vaccin_list";
    }
    @RequestMapping(value = "/searchPageList", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "获取文章列表")
    @ResponseBody
    public String searchPageList(
            @ApiParam(name = "discriminateCode", value = "识别码")
            @RequestParam(value = "discriminateCode", required = false) String discriminateCode,
            @ApiParam(name = "name", value = "疫苗名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "subtitle", value = "副标题")
            @RequestParam(value = "subtitle", required = false) String subtitle,
            @ApiParam(name = "type", value = "1一类 2二类")
            @RequestParam(value = "type", required = false) String type,
            @ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
            @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
            @ApiParam(name = "rows", value = "每页分页大小", required = true, defaultValue = "10")
            @RequestParam(value = "rows", required = true,defaultValue = "10")Integer rows) {
        try {
            Page result = vaccinService.searchPageList(discriminateCode, name, subtitle, type, page, rows);
            return write(200,"获取成功", page, rows, result.getTotalElements(), result.getContent());
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
}

+ 44 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/wlyyrole/WlyyRoleController.java

@ -0,0 +1,44 @@
package  com.yihu.customer.controller.manager.wlyyrole;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.WlyyRole;
import com.yihu.customer.service.manager.wlyyrole.WlyyRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * Created by yww on 2016/12/13.
 */
@Controller
@RequestMapping("/admin/wlyyRole")
public class WlyyRoleController extends BaseController {
    @Autowired
    private WlyyRoleService wlyyRoleService;
    @RequestMapping(value = "list",method = RequestMethod.GET)
    public String listPageInit(){
        return "wlyyrole/wlyy_role_list";
    }
    @RequestMapping(value = "list",method = RequestMethod.POST)
    @ResponseBody
    public String searchList(
            @RequestParam(value = "name",required = false)String name,
            @RequestParam(value = "page",required = false)Integer page,
            @RequestParam(value = "rows",required = false)Integer pageSize){
        try{
            Page<WlyyRole> wlyyRoles = wlyyRoleService.searchList(name, page, pageSize);
            return write(200,"操作成功",page,pageSize,wlyyRoles);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 59 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/wlyyrole/WlyyUserRoleController.java

@ -0,0 +1,59 @@
package  com.yihu.customer.controller.manager.wlyyrole;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.WlyyUserRole;
import com.yihu.customer.service.manager.wlyyrole.WlyyUserRoleService;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
/**
 * Created by yww on 2016/12/13.
 */
@Controller
@RequestMapping("/admin/wlyyUserRole")
public class WlyyUserRoleController extends BaseController {
    @Autowired
    private WlyyUserRoleService wlyyUserRoleService;
    @RequestMapping(value = "list")
    @ResponseBody
    public String searchList(
            @RequestParam(value = "page",required = false)Integer page,
            @RequestParam(value = "rows",required = false)Integer pageSize){
        try{
            Page<WlyyUserRole> wlyyUserRoles = wlyyUserRoleService.searchList("",page, pageSize);
            return write(200,"操作成功",page,pageSize,wlyyUserRoles);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "/importData", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String importData(HttpServletRequest request) {
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = request.getInputStream();
            Workbook workbook = Workbook.getWorkbook(inputStream);
            wlyyUserRoleService.importData(workbook);
            return write(200, "操作成功");
        } catch (IOException | BiffException | ParseException e) {
            e.printStackTrace();
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 242 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/manager/yueren/YueRenController.java

@ -0,0 +1,242 @@
package  com.yihu.customer.controller.manager.yueren;
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.service.manager.medicine.WlyyMedicineKeyService;
import com.yihu.customer.util.HttpManageClientUtil;
import io.swagger.annotations.Api;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.stereotype.Controller;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
/**
 * Created by Administrator on 2017/8/14.
 */
@Controller
@RequestMapping("/yueren")
@Api(description = "调用越人接口")
public class YueRenController extends BaseController {
    @Value("${yueren.api}")
    private String api;
    @Autowired
    private WlyyMedicineKeyService wlyyMedicineKeyService;
    //--预约模块 begin
    /**
     * 获取每个接口需要传递的key值
     * @return
     */
    @RequestMapping(value = "/phonekey", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String getPhoneKey() throws JSONException {
        String key =wlyyMedicineKeyService.getKey();
        return  write(200,"查询成功","key",key);
    }
    /**
     * 新增客户咨询预约单,如果是新客人,同时新增客户信息
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "insertslip", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String insertSlip(@RequestBody String jsonString) throws JSONException {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/insertslip", params);
        return postStr;
    }
    //--预约模块 end
    //--四诊模块 begin
    /**
     * 上传图片音频等附件
     * @param file
     * @return
     */
    @RequestMapping(value = "/uploadattachment", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String uploadAttachment(@RequestParam MultipartFile file) {
        MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
        String fileName = file.getOriginalFilename();
        String filePath =this.getClass().getResource("/").getPath() + "temp/" + System.currentTimeMillis() + fileName;
        File dest = new File(filePath);
        if (!dest.getParentFile().exists()) {
            dest.getParentFile().mkdirs();
        }
        try {
            file.transferTo(dest);
            RestTemplate rest = new RestTemplate();
            FileSystemResource resource = new FileSystemResource(filePath);
            param.add("file", resource);
            String postStr = rest.postForObject(api + "/yueren/uploadattachment", param, String.class);
            if (dest.exists() && dest.isFile()) {
                dest.delete();
            }
            return postStr;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "{\"status\":500,\"exception\":\"上传文件出错\"}";
    }
    /**
     * 处理头像舌苔声音
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "dillphoneimgdata", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String inserTemp(@RequestBody String jsonString) throws JSONException {
        String key = wlyyMedicineKeyService.getKey();
        JSONObject params = new JSONObject(jsonString);
        params.put("key",key);
        String answer = params.get("answer").toString();
        params.put("answer","/attach/{{key}}/"+answer);
        String postStr = remoteCall("/yueren/dillphoneimgdata", params);
        return postStr;
    }
    //--四诊模块 end
    //--答题模块 begin
    /**
     * 查找试卷
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "findtest", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String findTest(@RequestBody String jsonString) throws JSONException {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/findtest", params);
        return postStr;
    }
    /**
     * 查找试卷题目
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "giveproblem", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String giveproblem(@RequestBody String jsonString) throws JSONException {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/giveproblem", params);
        return postStr;
    }
    /**
     * 将用户提交的试卷题目的答案进行保存
     * @param jsonString
     * @return 将用户提交的试卷题目的答案进行保存
     */
    @RequestMapping(value = "handleproblem", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String handleproblem(@RequestBody String jsonString) throws JSONException {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/handleproblem", params);
        return postStr;
    }
    /**
     * 将用户提交的试卷题目的答案进行处理
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "centralizedproblem", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String centralizedproblem(@RequestBody String jsonString) throws JSONException {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/centralizedproblem", params);
        return postStr;
    }
    /**
     * 在生成报告单之前,必须调用这个接口,将风险预警中的因素中的所有病处理到影响中
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "conclusionfactor", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String conclusionFactor(@RequestBody String jsonString) throws JSONException {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/conclusionfactor", params);
        return postStr;
    }
    //--答题模块 end
    //--报告单模块 begin
    /**
     * 生成报告单
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "insertconconhealth", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String insertConsultConclusionHealth(@RequestBody String jsonString) throws JSONException {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/insertconconhealth", params);
        return postStr;
    }
    /**
     * 查找报告单结论
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "findconconhealth", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String insertConsultConclusion(@RequestBody String jsonString) throws JSONException {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/findconconhealth", params);
        return postStr;
    }
    /**
     * 查找状态要素结论积分图及个人信息
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "findintegral", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String findIntegral(@RequestBody String jsonString) throws JSONException {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/findintegral", params);
        return postStr;
    }
    private String remoteCall(String url, JSONObject jsonDate) {
        try {
            String result = HttpManageClientUtil.postBody(api + url, jsonDate);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return "{\"status\":500,\"exception\":\"连接出错\"}";
        }
    }
    public void saveKey(String key) {
        wlyyMedicineKeyService.saveKey(key);
    }
}

+ 151 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/statistics/CallRecordStaticsController.java

@ -0,0 +1,151 @@
/*
package com.yihu.jw.controller.statistics;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.service.statistic.CallRecordStatisticsService;
import com.yihu.jw.util.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
*/
/**
 * Created by wangzhinan on 2019/9/18.
 *//*
@RestController
@RequestMapping(value = "/callRecordStatics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "通话记录统计")
public class CallRecordStaticsController extends BaseController {
    @Autowired
    private CallRecordStatisticsService callRecordStatisticsService;
    @RequestMapping(value = "total", method = RequestMethod.POST)
    @ApiOperation(value = "通话记录统计")
    public String getIndexTotal(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = false) String type) {
        try {
            return write(200, "查询成功", "data",callRecordStatisticsService.getCallRecordList(area,level,type,startDate,endDate) );
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/callrecordOutExcel", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public void outExcel(HttpServletResponse response,
                         @RequestParam(required = true) String startDate,
                         @RequestParam(required = true) String endDate,
                         @RequestParam(required = true) String area,
                         @RequestParam(required = true) int level,
                         @RequestParam(required = false) String type) {
        try {
            Map<String,Object> map = callRecordStatisticsService.getCallRecordList(area,level,type,startDate,endDate);
            String callInTotal = null;
            String callOutTotal = null;
            JSONArray array = new JSONArray();
            if (map!=null){
                JSONObject object  = new JSONObject();
                object = JSONObject.parseObject(map.get("allTotal").toString());
                callInTotal = object.getString("callIn");
                callOutTotal = object.getString("callOut");
                array = JSONArray.parseArray(map.get("hospitalTotal").toString());
            }
            //基本设置
            response.setContentType("application/vnd.ms-excel");
            String fileName = "通话记录统计导出";
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            Date date = new Date();
            response.setHeader("Content-Disposition", "attachment; filename="
                    + new String(fileName.getBytes("UTF-8"), "ISO8859-1") + "_" + sdf.format(date) + ".xls");
            OutputStream os = response.getOutputStream();
            //处理Excel
            WritableWorkbook book = Workbook.createWorkbook(os);
            WritableSheet sheet = book.createSheet("通话记录统计", 0);
            sheet.addCell(new Label(0, 0, "社区名称"));
            if (type==null||type.equalsIgnoreCase("1")||type==""){
                sheet.addCell(new Label(1, 0, "呼入数量"));
                sheet.addCell(new Label(2, 0, "呼入服务名称"));
                sheet.addCell(new Label(3, 0, "数量"));
            }
            if (type==null||type==""){
                sheet.addCell(new Label(4, 0, "呼出数量"));
                sheet.addCell(new Label(4, 1, callOutTotal));
            }if (type.equalsIgnoreCase("2")){
                sheet.addCell(new Label(1, 0, "呼出数量"));
                sheet.addCell(new Label(1, 1, callOutTotal));
            }
            sheet.addCell(new Label(0, 1, "合计"));
            sheet.addCell(new Label(1, 1, callInTotal));
            sheet.addCell(new Label(2, 1, ""));
            sheet.addCell(new Label(3, 1, ""));
            int row =2;
            int row1 = 2;
            if (null != array && array.size() > 0) {
                for(int i = 0; i< array.size(); i ++) {
                    JSONObject object = array.getJSONObject(i);
                    JSONArray jsonArray = object.getJSONArray("serverTypeTotal");
                    sheet.addCell(new Label(0,row1,object.getString("hospitalName")));
                    if (jsonArray!=null&&jsonArray.size()!=0){
                        sheet.addCell(new Label(1,row1,object.getString("callIn")));
                        sheet.addCell(new Label(4,row1,object.getString("callOut")));
                        for (int j=0;j<jsonArray.size();j++){
                            JSONObject jsonObject = jsonArray.getJSONObject(j);
                            sheet.addCell(new Label(2,j+row,jsonObject.getString("slaveKey2Name")));
                            sheet.addCell(new Label(3,j+row,jsonObject.getString("result")));
                        }
                        sheet.mergeCells(0,row1,0,row1+jsonArray.size()-1);
                        sheet.mergeCells(1,row1,1,row1+jsonArray.size()-1);
                        sheet.mergeCells(4,row1,4,row1+jsonArray.size()-1);
                        row+=jsonArray.size();
                        row1+=jsonArray.size();
                    }else {
                        sheet.addCell(new Label(1,row1,object.getString("callOut")));
                        row1+=1;
                    }
                }
            }
            book.write();
            book.close();
            os.flush();
            os.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (WriteException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
*/

+ 220 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/CustomerQuestionnaireController.java

@ -0,0 +1,220 @@
package  com.yihu.customer.controller.synergy.customer;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.service.synergy.QuestionnaireManageService;
import com.yihu.customer.service.synergy.SynergyManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 客服端问卷调查
 * Created by Humingfen on 2018/9/29.
 */
@RestController
@RequestMapping(value = "/customer/question", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "客服端-调查问卷协同服务")
public class CustomerQuestionnaireController extends BaseController {
    @Autowired
    private QuestionnaireManageService questionnaireService;
    @Autowired
    private SynergyManageService synergyManageService;
    @RequestMapping(value = "saveAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "保存用户答案")
    public String saveAnswer( @ApiParam(value = "问卷题目及选项")@RequestParam String jsonData,
                              @ApiParam(value = "客服code")@RequestParam(value = "customerCode", required = true)String customerCode,
                              @ApiParam(value = "居民code")@RequestParam(value = "patientCode", required = true)String patientCode,
                              @ApiParam(value = "问卷标签(疾病筛查问卷要传5,调查问卷传4)")@RequestParam(value = "labelType", required = false)Integer labelType,
                              @ApiParam(value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source", required = false, defaultValue = "1")Integer source,
                              @ApiParam(value = "协同工单服务对象表code", required = true)@RequestParam(value = "serviceCode", required = true)String serviceCode) {
        try {
            return  write(200, "保存成功!", "data", questionnaireService.saveResultAndAnswer(patientCode, labelType, customerCode, source,jsonData, serviceCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
    @RequestMapping(value = "getAnswers", method = RequestMethod.GET)
    @ApiOperation(value = "查看调查统计结果")
    public String getAnswers(@ApiParam(value = "问卷code", required = true) @RequestParam String surveyCode) {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getAnswers(surveyCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "getResult", method = RequestMethod.GET)
    @ApiOperation(value = "查看客服对居民调查问卷结果")
    public String getResult(@ApiParam(value = "调查结果code") @RequestParam String questionResultCode) {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getReuslt(questionResultCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "getQuestionnaireDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查看调查问卷内容")
    public String getQuestionnaireDetail(@ApiParam(value = "调查问卷code") @RequestParam String surveyCode) {
        try {
            com.alibaba.fastjson.JSONObject jsonObject = questionnaireService.getQuestionnaireDetail(surveyCode);
            return write(200, "查询成功!", "data", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "getOptionsComment", method = RequestMethod.GET)
    @ApiOperation(value = "获取调查结果")
    public String getOptionsComment(@RequestParam int pageNo,
                                    @RequestParam int pageSize,
                                    @ApiParam(value = "问卷code")
                                        @RequestParam String surveyCode,
                                    @ApiParam(value = "题目code")
                                        @RequestParam String questionCode,
                                    @ApiParam(value = "选项code")
                                        @RequestParam(required = false) String optionCode) {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getOptionsComment(surveyCode, questionCode, optionCode, pageNo, pageSize));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "isNotException", method = RequestMethod.POST)
    @ApiOperation(value = "判断是否异常通话")
    public String isNotException(@ApiParam(value = "协同服务工单code") @RequestParam String workorderCode,
                                 @ApiParam(value = "客服code") @RequestParam String customerCode) {
        try {
            return write(200, "查询成功!", "data", synergyManageService.isNotException(workorderCode, customerCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "loadingInfo", method = RequestMethod.GET)
    @ApiOperation(value = "载入异常通话居民信息")
    public String loadingInfo(@ApiParam(value = "协同服务对象code") @RequestParam String workorderServiceCode) {
        try {
            return write(200, "查询成功!", "data", synergyManageService.loadingInfo(workorderServiceCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "statics", method = RequestMethod.GET)
    @ApiOperation(value = "问卷")
    public String statics(@ApiParam(value = "问卷code") @RequestParam String code) {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getQuestionOption(code));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/surveyOutExcel", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public void outExcel(HttpServletResponse response,
                         @RequestParam(required = true) String code) {
        try {
            Map<String,Object> map = questionnaireService.getQuestionOption(code);
            JSONArray array = new JSONArray();
            JSONArray jsonArray = new JSONArray();
            if (map!=null&&map.size()!=0){
                array = JSONArray.parseArray(map.get("title").toString());
                jsonArray = JSONArray.parseArray(map.get("jsonArray").toString());
            }
            //基本设置
            response.setContentType("application/vnd.ms-excel");
            String fileName = "问卷调查明细表导出";
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            Date date = new Date();
            response.setHeader("Content-Disposition", "attachment; filename="
                    + new String(fileName.getBytes("UTF-8"), "ISO8859-1") + "_" + sdf.format(date) + ".xls");
            OutputStream os = response.getOutputStream();
            //处理Excel
            WritableWorkbook book = Workbook.createWorkbook(os);
            WritableSheet sheet = book.createSheet("问卷调查明细表", 0);
            sheet.addCell(new Label(0, 0, "居民姓名"));
            sheet.addCell(new Label(1, 0, "性别"));
            sheet.addCell(new Label(2, 0, "电话"));
            sheet.addCell(new Label(3, 0, "签约机构"));
            sheet.addCell(new Label(4, 0, "签约医生"));
            sheet.addCell(new Label(5, 0, "服务类型"));
            List<Map<String,Object>> maps = new ArrayList<>();
            for (int i=0;i<array.size();i++){
                JSONObject object = array.getJSONObject(i);
                sheet.addCell(new Label(6+i, 0, object.getString("title")));
                Map<String,Object> map1 = new HashedMap();
                map1.put("sort",6+i);
                map1.put("code",object.getString("code"));
                maps.add(map1);
            }
            if (null != jsonArray && jsonArray.size() > 0) {
                for(int i = 0; i< jsonArray.size(); i ++) {
                    JSONObject object = jsonArray.getJSONObject(i);
                    sheet.addCell(new Label(0, i+1, object.getString("name")));
                    sheet.addCell(new Label(1, i+1, object.getString("sex")));
                    sheet.addCell(new Label(2, i+1, object.getString("mobile")));
                    sheet.addCell(new Label(3, i+1, object.getString("hospitalName")));
                    sheet.addCell(new Label(4, i+1, object.getString("doctorName")));
                    sheet.addCell(new Label(5, i+1, object.getString("serverType")));
                    JSONArray array1 = object.getJSONArray("questions");
                    for (int j=0;j<array1.size();j++){
                        JSONObject object1 = array1.getJSONObject(j);
                        for (Map<String,Object> map1:maps){
                            if (object1.getString("questionCode").equals(map1.get("code").toString())){
                                sheet.addCell(new Label(Integer.parseInt(map1.get("sort").toString()), i+1, object1.getString("sort")));
                            }
                        }
                    }
                }
            }
            maps.clear();
            book.write();
            book.close();
            os.flush();
            os.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (WriteException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 48 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/CustomerScreenResultController.java

@ -0,0 +1,48 @@
package  com.yihu.customer.controller.synergy.customer;
import  com.yihu.customer.controller.BaseController;
import com.yihu.customer.service.synergy.ScreenResultManageService;
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.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * 客服端疾病筛查
 * Created by Humingfen on 2018/9/29.
 */
@RestController
@RequestMapping(value = "/customer/screen", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "客服端-疾病筛查协同服务")
public class CustomerScreenResultController extends BaseController {
    @Autowired
    private ScreenResultManageService screenResultService;
    @RequestMapping(value = "getScreenResultDetail", method = RequestMethod.GET)
    @ApiOperation(value = "获取筛查结果记录详情")
    public String getScreenResultDetail(@ApiParam(value = "筛查结果唯一code")@RequestParam(value = "code") String code) {
        try {
            return write(200, "获取成功!", "data", screenResultService.getScreenResultDetail(code));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "getQuestions", method = RequestMethod.GET)
    @ApiOperation(value = "获取筛查问卷详情")
    public String getScreenDetail(@ApiParam(value = "筛查问卷code")@RequestParam(value = "code") String templateCode) {
        try {
            return write(200, "获取成功!", "data", screenResultService.getScreenDetail(templateCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
}

+ 1191 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/CustomerSynergyManageController.java

@ -0,0 +1,1191 @@
package  com.yihu.customer.controller.synergy.customer;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.Hospital;
import  com.yihu.customer.entity.User;
import  com.yihu.customer.entity.WlyyAdminTeam;
import  com.yihu.customer.entity.call.CallRecord;
import  com.yihu.customer.entity.synergy.ManageSynergyWorkorderServicerLogDO;
import  com.yihu.customer.entity.synergy.ManageSynergyAccessoryDO;
import  com.yihu.customer.entity.synergy.ManageSynergyWorkorderTestInstructionsDo;
import  com.yihu.customer.repository.call.CallRecordDao;
import com.yihu.customer.service.manager.hos.HosService;
import com.yihu.customer.service.manager.team.ManageWlyyAdminTeamService;
import com.yihu.customer.service.manager.user.UserService;
import com.yihu.customer.service.synergy.SynergyManageService;
import com.yihu.customer.service.synergy.SynergyWorkorderServicerLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by 刘文彬 on 2018/9/27.
 */
@Controller
@RequestMapping(value = "/synergy/customer", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "集美客服系统")
public class CustomerSynergyManageController extends BaseController {
    public static final String CALL_LABEL="CALL_LABEL";
    @Autowired
    private SynergyManageService synergyManageService;
    @Autowired
    private SynergyWorkorderServicerLogService synergyWorkorderServicerLogService;
    @Autowired
    private UserService userService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private CallRecordDao callRecordDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private HosService hospitalService;
    @Autowired
    private ManageWlyyAdminTeamService teamService;
    @RequestMapping(value = "/getWorkOrderInfo", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "获取协同服务工单信息")
    @ResponseBody
    public String getWorkOrderInfo(@ApiParam(name="workorderCode",value="协同服务工单code")
                                @RequestParam(required = true)String workorderCode,
                                @ApiParam(name="patient",value="居民code")
                                @RequestParam(required = false)String patient,
                                @ApiParam(name="role",value="1医生,2普通客服,3客服管理员")
                                @RequestParam(required = true)Integer role,
                                @ApiParam(name="reminderCode",value="催单code")
                                @RequestParam(required = false)String reminderCode){
        try {
            return write(200,"查询成功","data", synergyManageService.getWorkOrderInfo(workorderCode, patient, role,reminderCode));
        }catch (Exception e){
            e.printStackTrace();
            error(e);
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/dealWorkOrder",method = RequestMethod.POST)
    @ApiOperation(value = "处理协同服务")
    @ResponseBody
    public String dealWorkOrder(@ApiParam(name="code",value="协同服务工单code")
                                @RequestParam(required = true)String code,
                                @ApiParam(name="jsonData",value="接收负责人或者退回理由")
                                @RequestParam(required = true)String jsonData,
                                @ApiParam(name="receiverCode",value="处理者code")
                                @RequestParam(required = true)String receiverCode,
                                @ApiParam(name="status",value="2、接收,4、退回)")
                                @RequestParam(required = true)Integer status){
        try {
            User user = userService.getUserByCode(receiverCode);
            synergyManageService.dealWorkOrder(code, user, jsonData, status);
            return write(200,"保存成功");
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
    /**
     * 批量处理协同服务
     * @param code
     * @param jsonData
     * @param receiverCode
     * @param status
     * @return
     */
    @RequestMapping(value = "/batchDealWorkOrder",method = RequestMethod.POST)
    @ApiOperation(value = "批量处理协同服务")
    @ResponseBody
    public String batchDealWorkOrder(@ApiParam(name="code",value="协同服务工单code")
                                @RequestParam(required = true)String code,
                                @ApiParam(name="jsonData",value="接收负责人或者退回理由")
                                @RequestParam(required = true)String jsonData,
                                @ApiParam(name="receiverCode",value="处理者code")
                                @RequestParam(required = true)String receiverCode,
                                @ApiParam(name="status",value="2、接收,4、退回)")
                                @RequestParam(required = true)Integer status){
        try {
            User user = userService.getUserByCode(receiverCode);
            synergyManageService.batchDealWorkOrder(code, user, jsonData, status);
            return write(200,"保存成功");
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
    @RequestMapping(value = "/selectByWorkorder",method = RequestMethod.GET)
    @ApiOperation(value = "获取上一次分配的信息")
    @ResponseBody
    public String selectByWorkorder(@ApiParam(name="code",value="协同服务工单code")
                                @RequestParam(required = true)String code){
        try {
            return write(200,"保存成功","data",synergyManageService.selectByWorkorder(code));
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
    @RequestMapping(value = "/getCustomers", method = RequestMethod.GET)
    @ApiOperation(value = "获取客服列表")
    @ResponseBody
    public String getCustomers(){
        try {
            List<User> list = synergyManageService.getCustomers();
            return write(200,"查询成功", "data", list);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/labels", method = RequestMethod.GET)
    @ApiOperation("根据分组类型查找标签")
    @ResponseBody
    public String labels(
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true)
            @RequestParam(value = "labelType", required = true) String labelType) {
        try {
            return write(200,"查询成功", "data", synergyManageService.getLabels(labelType));
        } catch (Exception e) {
            error(e);
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/unitLabels", method = RequestMethod.GET)
    @ApiOperation("根据地区查找卫计委下属单位标签")
    @ResponseBody
    public String unitLabels(@ApiParam(name = "currentRoleCode", value = "地点对应的code")
                             @RequestParam(value = "currentRoleCode", required = true) String currentRoleCode,
                             @ApiParam(name = "currentRoleLevel", value = "1省2城市3区县", required = false)
                             @RequestParam(value = "currentRoleLevel", required = true) String currentRoleLevel) {
        try {
            return write(200,"查询成功", "data", synergyManageService.getUnitLabels(currentRoleCode, currentRoleLevel));
        } catch (Exception e) {
            error(e);
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "workorderList", method = RequestMethod.GET)
    @ApiOperation("客服系统-协同服务列表")
    @ResponseBody
    public String workorderList(@ApiParam(name = "userCode", value = "客服code", required = false)
                                @RequestParam(value = "userCode", required = false)String userCode,
                                @ApiParam(name = "keywords", value = "输入医生姓名、姓名、社保卡、身份证号码", required = false)
                                @RequestParam(value = "keywords", required = false)String keywords,
                                @ApiParam(name = "workorderType", value = "服务类型(0、咨询,1、健康教育,2、预约,3、随访,4、问卷调查,5、疾病筛查)", required = false)
                                @RequestParam(value = "workorderType", required = false)Integer workorderType,
                                @ApiParam(name = "isMyTask", value = "是否由我负责,1、我负责,null全部", required = false)
                                @RequestParam(value = "isMyTask", required = false)Integer isMyTask,
                                @ApiParam(name = "status", value = "工单状态(0、草稿,1、未接受,2、处理中,3、处理完成,4、退回)", required = false)
                                @RequestParam(value = "status", required = false)Integer status,
                                @ApiParam(name = "priority", value = "工单优先级(0、普通,1、加急)", required = false)
                                @RequestParam(value = "priority", required = false)Integer priority,
                                @ApiParam(name = "timeout", value = "是否超时1、超时,2、否超时,null全部", required = false)
                                @RequestParam(value = "timeout", required = false)Integer timeout,
                                @ApiParam(name = "workorderCode", value = "服务编号", required = false)
                                @RequestParam(value = "workorderCode", required = false)String workorderCode,
                                @ApiParam(name = "principal", value = "负责人", required = false)
                                @RequestParam(value = "principal", required = false)String principal,
                                @ApiParam(name = "serviceStartTime", value = "服务开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                @RequestParam(value = "serviceStartTime", required = false)String serviceStartTime,
                                @ApiParam(name = "serviceEndTime", value = "服务结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                @RequestParam(value = "serviceEndTime", required = false)String serviceEndTime,
                                @ApiParam(name = "patientName", value = "服务对象名称", required = false)
                                @RequestParam(value = "patientName", required = false)String patientName,
                                @ApiParam(name = "ssc", value = "社保卡号", required = false)
                                @RequestParam(value = "ssc", required = false)String ssc,
                                @ApiParam(name = "idcard", value = "身份证号", required = false)
                                @RequestParam(value = "idcard", required = false)String idcard,
                                @ApiParam(name = "userType", value = "2、客服,3、客服管理员", required = true)
                                @RequestParam(value = "userType", required = true)Integer userType,
                                @ApiParam(name = "isAcceptTask", value = "1、我接收到的任务,2、我派发的任务,3、待接收(客服管理员),4、已接收(客服管理员)", required = true)
                                @RequestParam(value = "isAcceptTask", required = true)Integer isAcceptTask,
                                @ApiParam(name = "userName", value = "需求方", required = false)
                                @RequestParam(value = "userName", required = false)String userName,
                                @ApiParam(name = "hospitalName", value = "所属机构", required = false)
                                @RequestParam(value = "hospitalName", required = false)String hospitalName,
                                @ApiParam(name = "page", value = "第几页,从1开始", required = true)
                                @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
                                @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
                                @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize,
                                @ApiParam(name = "isRead", value = "1、已读,0、未读", required = false)
                                @RequestParam(value = "isRead", required = false)Integer isRead,
                                @ApiParam(name = "isOne", value = "1、自己,0、全部", required = false)
                                @RequestParam(value = "isOne", required = false)Integer isOne,
                                @ApiParam(name = "customerCode", value = "客服code", required = false)
                                @RequestParam(value = "customerCode", required = false)String customerCode){
        try {
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            Map<String,Object> result = synergyManageService.workorderList(userCode,keywords,workorderType,isMyTask,status,priority,timeout,workorderCode,
                    principal,serviceStartTime,serviceEndTime,patientName,ssc,idcard,userType,isAcceptTask,userName,hospitalName,page,pageSize,isRead,isOne,customerCode);
            return write(200, "获取成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "workorderListTotal", method = RequestMethod.GET)
    @ApiOperation("客服系统-协同服务列表")
    @ResponseBody
    public String workorderListTotal(@ApiParam(name = "userCode", value = "客服code", required = false)
                                @RequestParam(value = "userCode", required = false)String userCode,
                                @ApiParam(name = "userType", value = "2、客服,3、客服管理员", required = true)
                                @RequestParam(value = "userType", required = true)Integer userType){
        try {
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            Map<String,Object> result = synergyManageService.workorderListTotal(userCode,userType);
            return write(200, "获取成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/takeWorkorderNum", method = RequestMethod.GET)
    @ApiOperation(value = "获取协同服务取号信息")
    @ResponseBody
    public String takeWorkorderNum(@ApiParam(name="workorderCode",value="协同服务工单code",required = false)
                                @RequestParam(required = true)String workorderCode,
                                @ApiParam(name="townCode",value="所属区县",required = false)
                                @RequestParam(required = false)String townCode,
                                @ApiParam(name="hospitalCode",value="所属社区",required = false)
                                @RequestParam(required = false)String hospitalCode,
                                @ApiParam(name="diseaseCode",value="疾病类型",required = false)
                                @RequestParam(required = false)String diseaseCode,
                                @ApiParam(name="healthCode",value="健康情况",required = false)
                                @RequestParam(required = false)String healthCode,
                                @ApiParam(name="serveCode",value="服务类型",required = false)
                                @RequestParam(required = false)String serveCode,
                                @ApiParam(name="isFollow",value="是否待跟进(1是,0否)",required = false)
                                @RequestParam(required = false)Integer isFollow){
        try {
            Map<String,Object> resultMap = synergyManageService.takeWorkorderNum(workorderCode,townCode,hospitalCode,
                    diseaseCode,healthCode,serveCode,isFollow);
            return write(200,"取号成功","data", resultMap);
        }catch (Exception e){
            error(e);
            return error(-1,"取号失败");
        }
    }
    /**
     * 获取协同服务取号列表
     *
     * @param workorderCode
     * @param townCode
     * @param hospitalCode
     * @param diseaseCode
     * @param healthCode
     * @param serveCode
     * @param isFollow
     * @return
     */
    @RequestMapping(value = "/getWorkorderNum", method = RequestMethod.GET)
    @ApiOperation(value = "获取协同服务取号列表")
    @ResponseBody
    public String getWorkorderNum(@ApiParam(name="workorderCode",value="协同服务工单code",required = false)
                                   @RequestParam(required = true)String workorderCode,
                                   @ApiParam(name="townCode",value="所属区县",required = false)
                                   @RequestParam(required = false)String townCode,
                                   @ApiParam(name="hospitalCode",value="所属社区",required = false)
                                   @RequestParam(required = false)String hospitalCode,
                                   @ApiParam(name="diseaseCode",value="疾病类型",required = false)
                                   @RequestParam(required = false)String diseaseCode,
                                   @ApiParam(name="healthCode",value="健康情况",required = false)
                                   @RequestParam(required = false)String healthCode,
                                   @ApiParam(name="serveCode",value="服务类型",required = false)
                                   @RequestParam(required = false)String serveCode,
                                   @ApiParam(name="isFollow",value="是否待跟进(1是,0否)",required = false)
                                   @RequestParam(required = false)Integer isFollow,
                                   @ApiParam(name = "page", value = "第几页,从1开始", required = true)
                                   @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
                                   @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
                                   @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize){
        try {
            JSONObject resultMap = synergyManageService.getWorkorderNum(workorderCode,townCode,hospitalCode,
                    diseaseCode,healthCode,serveCode,isFollow,page,pageSize);
            return write(200,"取号成功","data", resultMap);
        }catch (Exception e){
            error(e);
            return error(-1,"取号失败");
        }
    }
    @RequestMapping(value = "/reminderList", method = RequestMethod.GET)
    @ApiOperation(value = "获取催单列表")
    @ResponseBody
    public String reminderList(@ApiParam(name="userCode",value="客服code",required = false)
                               @RequestParam(required = false)String userCode,
                               @ApiParam(name="receiveType",value="客服角色(1、客服,2、客服管理员)",required = false)
                               @RequestParam(required = false)Integer receiveType,
                               @ApiParam(name="sortType",value="排序(1、升序,2、降序)",required = false,defaultValue = "1")
                               @RequestParam(required = false,defaultValue = "1")Integer sortType,
                               @ApiParam(name = "page", value = "第几页,从1开始", required = true)
                               @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
                               @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
                               @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize){
        try{
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            Map<String,Object> resultList = synergyManageService.reminderList(userCode,receiveType,sortType,page,pageSize);
            return write(200,"获取成功","data", resultList);
        }catch (Exception e){
            error(e);
            return error(-1,"获取失败");
        }
    }
    @RequestMapping(value = "/workorderRate", method = RequestMethod.GET)
    @ApiOperation(value = "任务进度")
    @ResponseBody
    public String workorderRate(@ApiParam(name="userCode",value="客服code",required = false)
                                @RequestParam(required = false)String userCode,
                                @ApiParam(name="workorderCode",value="协同服务工单code",required = true)
                                @RequestParam(required = true)String workorderCode){
        try{
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            Map<String,Object> resultMap = synergyManageService.workorderRate(workorderCode,userCode);
            return write(200,"获取成功","data", resultMap);
        }catch (Exception e){
            error(e);
            return error(-1,"获取失败");
        }
    }
    @RequestMapping(value = "getCallLabelList",method = RequestMethod.GET)
    @ApiOperation(value = "显示所有通话标签")
    @ResponseBody
    public String getCallLabelList(){
        try{
            String sql ="SELECT `code`,`value`,sort FROM system_dict WHERE dict_name='"+CALL_LABEL+"'";
            return write(200,"查询成功!","data",jdbcTemplate.queryForList(sql));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "saveCallLabel",method = RequestMethod.POST)
    @ApiOperation(value = "保存所有通话标签")
    @ResponseBody
    public String saveCallLabel(@ApiParam(name="callCode",value="通话记录code")@RequestParam(value = "callCode")String callCode,
                                @ApiParam(name="callLabels",value="通话标签,多个用逗号隔开")@RequestParam(value = "callLabels",required = false)String callLabels){
        try{
            int result = synergyManageService.saveCallLabel(callLabels,callCode);
            if (result>0){
                return write(200,"保存成功!");
            }else {
                return write(-1,"保存失败!");
            }
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败!");
        }
    }
    @RequestMapping(value = "getCallInfo",method = RequestMethod.GET)
    @ApiOperation(value = "获取通话的详情")
    @ResponseBody
    public String getCallTypeAndContent(@ApiParam(name="callCode",value="通话记录code")@RequestParam(value ="callCode")String callCode){
        try{
            CallRecord callRecord = callRecordDao.findByCode(callCode);
            return write(200,"查询成功!","data",callCode);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "saveCallInfo",method = RequestMethod.POST)
    @ApiOperation(value = "保存通话记录详情")
    @ResponseBody
    public String saveCallInfo(@ApiParam(name="callCode",value="通话记录code")@RequestParam(value ="callCode")String callCode,
                                @ApiParam(name="serviceType",value="服务类型,多个用逗号隔开")@RequestParam(value = "serviceType",required = false)String serviceType,
                               @ApiParam(name="serviceContent",value="服务记录")@RequestParam(value = "serviceContent",required = false)String serviceContent,
                               @ApiParam(name="patientName",value="居民姓名")@RequestParam(value = "patientName",required = false)String patientName,
                               @ApiParam(name="followUp",value="是否跟进")@RequestParam(value = "followUp",required = false)Integer followUp){
        try{
            int result = synergyManageService.saveCallInfo(serviceType,serviceContent,callCode,patientName,followUp);
            if (result>0){
                return write(200,"保存成功!");
            }else {
                return write(-1,"保存失败!");
            }
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败!");
        }
    }
    @RequestMapping(value = "/taskSubmit", method = RequestMethod.POST)
    @ApiOperation(value = "协同任务提交")
    @ResponseBody
    public String taskSubmit(@ApiParam(name="userCode",value="客服code",required = false)
                             @RequestParam(required = false)String userCode,
                             @ApiParam(name="workorderCode",value="协同服务工单code",required = true)
                             @RequestParam(required = true)String workorderCode,
                             @ApiParam(name="dealResultRemark",value="说明",required = false)
                             @RequestParam(required = false)String dealResultRemark,
                             @ApiParam(name="accessoryJson",value="附件的json",required = true)
                             @RequestParam(required = true)String accessoryJson){
        try{
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            synergyManageService.taskSubmit(userCode,workorderCode,dealResultRemark,accessoryJson);
            return write(200,"提交成功");
        }catch (Exception e){
            error(e);
            return error(-1,"提交失败");
        }
    }
    @RequestMapping(value = "/createServicerLog",method = RequestMethod.POST)
    @ApiOperation(value = "添加协同服务日志")
    @ResponseBody
    public String dealWorkOrder(@ApiParam(name="servicerLogDO",value="协同服务日志")
                                @RequestParam(name = "servicerLogDO",required = true)String servicerLogDO){
        try {
            ManageSynergyWorkorderServicerLogDO synergyWorkorderServicerLogDO = objectMapper.readValue(servicerLogDO,ManageSynergyWorkorderServicerLogDO.class);
            synergyWorkorderServicerLogService.create(synergyWorkorderServicerLogDO,getUID());
            return write(200,"保存成功");
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
    @RequestMapping(value = "getDealList",method = RequestMethod.GET)
    @ApiOperation(value = "通话详情获取待办事项")
    @ResponseBody
    public String getDealList(@ApiParam(name="idcard",value="居民身份证")@RequestParam(value ="idcard")String idcard){
        try{
            return write(200,"获取成功!","data",synergyManageService.getDealList(idcard));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @ApiOperation("查询体征数据")
    @RequestMapping(value = "/findByPatient", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String findByPatient(@ApiParam(name="patient",value="随访记录ID",defaultValue = "")
                                @RequestParam(value="patient",required = true) String patient)
    {
        try {
            return write(200, "查询成功","data",synergyManageService.findByPatient(patient));
        } catch (Exception e) {
            return invalidUserException(e, -1, "查询失败"+e.getMessage());
        }
    }
    @ApiOperation("获取随访数据")
    @RequestMapping(value = "/getFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                         @RequestParam(value = "id", required = true) String id,
                                         @ApiParam(name = "followupProject", value = "随访项目", defaultValue = "2")
                                         @RequestParam(value = "followupProject", required = true) String followupProject) {
        try {
            return write(200, "获取随访项目数据成功!", "data", synergyManageService.getFollowupProjectData(id,followupProject));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取随访项目数据失败!" + e.getMessage());
        }
    }
    /**
     * 药品列表
     * @param name
     * @param isinsulin
     * @return
     */
    @RequestMapping(value = "/findDictByName", method = RequestMethod.GET)
    @ApiOperation(value = "药品列表")
    @ResponseBody
    public String findDictByName(@ApiParam(name = "name", value = "药品名称(中文或拼音首字母查询)", defaultValue = "胰岛素")
                                 @RequestParam(value = "name", required = false) String name,
                                 @ApiParam(name = "isinsulin", value = "是否过滤胰岛素:1非胰岛素,2胰岛素", defaultValue = "")
                                 @RequestParam(value = "isinsulin", required = false) String isinsulin,
                                 @ApiParam(name = "doctor", value = "医生code", defaultValue = "")
                                     @RequestParam(value = "doctor", required = false) String doctor) {
        try {
//            return write(200, "操作成功!", "data",zyDictService.findDictByDoctorAndName("e3b3bfb3644011e69616fa163e424525",name,isinsulin));
            return write(200, "操作成功!", "data",synergyManageService.findDictByName(name,isinsulin,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @ApiOperation("保存面访用药数据")
    @RequestMapping(value = "/saveFollowupDrugs", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String saveFollowupDrugs(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
                                    @RequestParam(value="id",required = true) String id,
                                    @ApiParam(name="drugsData",value="面访用药数据",defaultValue = "[]")
                                    @RequestParam(value="drugsData",required = true) String drugsData)
    {
        try {
            synergyManageService.saveFollowupDrugs(id,drugsData);
            return write(200, "保存面访用药数据成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "保存面访用药数据失败!"+e.getMessage());
        }
    }
    /***************************************获取随访信息*****************************************/
    @ApiOperation("获取随访信息")
    @RequestMapping(value = "/getFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String getFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                              @RequestParam(value = "id", required = true) String id) {
        try {
            com.alibaba.fastjson.JSONObject response = synergyManageService.getFollowup(id);
            return write(200, "获取随访信息成功!", "data", response);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取随访信息失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取上次随访")
    @RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getLastFollowup(@ApiParam(name = "doctor", value = "医生code")
                                      @RequestParam(value = "doctor", required = true) String doctor,
                                  @ApiParam(name = "patient", value = "患者代码", defaultValue = "P20161008001")
                                  @RequestParam(value = "patient", required = true) String patient,
                                  @ApiParam(name = "followClass", value = "随访类别", defaultValue = "1")
                                  @RequestParam(value = "followClass", required = true) String followClass) {
        try {
            com.alibaba.fastjson.JSONObject response = synergyManageService.getLastFollowup(doctor, patient, followClass);
            return write(200, "获取上次随访成功!", "data", response);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取上次随访失败!" + e.getMessage());
        }
    }
    @ApiOperation("复制上次随访数据")
    @RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String copyFollowup(@ApiParam(name = "id", value = "本地随访ID", defaultValue = "")
                               @RequestParam(value = "id", required = true) Long id,
                               @ApiParam(name = "fromId", value = "拷贝随访记录ID", defaultValue = "")
                               @RequestParam(value = "fromId", required = true) Long fromId) {
        try {
            synergyManageService.copyFollowup(id, fromId);
            return write(200, "复制上次随访成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "复制上次随访失败!" + e.getMessage());
        }
    }
    @ApiOperation("新增临时随访记录(返回ID)")
    @RequestMapping(value = "/addFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String addFollowup(@ApiParam(name = "doctor", value = "医生code")
                              @RequestParam(value = "doctor", required = true) String doctor,
                              @ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                              @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "date", value = "下次随访时间", defaultValue = "2016-12-15 20:00:00")
                              @RequestParam(value = "date", required = true) String date,
                              @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                              @RequestParam(value = "followupType", required = true) String followupType,
                              @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病 3高糖】", defaultValue = "1")
                              @RequestParam(value = "followupClass", required = true) String followupClass,
                              @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                              @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus,
                              @ApiParam(name = "plandate", value = "下次随访时间", defaultValue = "2016-12-14 20:00:00")
                              @RequestParam(value = "plandate", required = false) String plandate) {
        try {
            String response = synergyManageService.addFollowup(doctor, patient, date, followupType, followupClass, followupManagerStatus,plandate);
            return write(200, "新增临时随访记录成功!", "data", response);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "新增临时随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("保存随访项目数据")
    @RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String saveFollowupProjectData(@ApiParam(name = "id", value = "随访记录id")
                                              @RequestParam(value = "id", required = true)String id,
                                          @ApiParam(name = "followup", value = "随访项目对象")
                                          @RequestParam(value = "followup", required = true)String followup ) {
        try {
            synergyManageService.saveFollowupProjectData(id,followup);
            return write(200, "保存随访项目数据成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "保存随访项目数据失败!" + e.getMessage());
        }
    }
    @RequestMapping(value = "customerIndex",method = RequestMethod.GET)
    @ApiOperation(value = "客服首页")
    @ResponseBody
    public String customerIndex(@ApiParam(name="userCode",value="客服code")@RequestParam(value ="userCode")String userCode){
        try{
            return write(200,"获取成功!","data",synergyManageService.customerIndex(userCode));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "exportWorkorder", method = RequestMethod.GET)
    @ApiOperation("客服系统-协同服务列表")
    public void exportWorkorder(@ApiParam(name = "userCode", value = "客服code", required = false)
                                @RequestParam(value = "userCode", required = false)String userCode,
                                @ApiParam(name = "keywords", value = "输入医生姓名、姓名、社保卡、身份证号码", required = false)
                                @RequestParam(value = "keywords", required = false)String keywords,
                                @ApiParam(name = "workorderType", value = "服务类型(0、咨询,1、健康教育,2、预约,3、随访,4、问卷调查,5、疾病筛查)", required = false)
                                @RequestParam(value = "workorderType", required = false)Integer workorderType,
                                @ApiParam(name = "isMyTask", value = "是否由我负责,1、我负责,null全部", required = false)
                                @RequestParam(value = "isMyTask", required = false)Integer isMyTask,
                                @ApiParam(name = "status", value = "工单状态(0、草稿,1、未接受,2、处理中,3、处理完成,4、退回)", required = false)
                                @RequestParam(value = "status", required = false)Integer status,
                                @ApiParam(name = "priority", value = "工单优先级(0、普通,1、加急)", required = false)
                                @RequestParam(value = "priority", required = false)Integer priority,
                                @ApiParam(name = "timeout", value = "是否超时1、超时,2、否超时,null全部", required = false)
                                @RequestParam(value = "timeout", required = false)Integer timeout,
                                @ApiParam(name = "workorderCode", value = "服务编号", required = false)
                                @RequestParam(value = "workorderCode", required = false)String workorderCode,
                                @ApiParam(name = "principal", value = "负责人", required = false)
                                @RequestParam(value = "principal", required = false)String principal,
                                @ApiParam(name = "serviceStartTime", value = "服务开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                @RequestParam(value = "serviceStartTime", required = false)String serviceStartTime,
                                @ApiParam(name = "serviceEndTime", value = "服务结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                @RequestParam(value = "serviceEndTime", required = false)String serviceEndTime,
                                @ApiParam(name = "patientName", value = "服务对象名称", required = false)
                                @RequestParam(value = "patientName", required = false)String patientName,
                                @ApiParam(name = "ssc", value = "社保卡号", required = false)
                                @RequestParam(value = "ssc", required = false)String ssc,
                                @ApiParam(name = "idcard", value = "身份证号", required = false)
                                @RequestParam(value = "idcard", required = false)String idcard,
                                @ApiParam(name = "userType", value = "2、客服,3、客服管理员", required = true)
                                @RequestParam(value = "userType", required = true)Integer userType,
                                @ApiParam(name = "isAcceptTask", value = "1、我接收到的任务,2、我派发的任务,3、待接收(客服管理员),4、已接收(客服管理员)", required = true)
                                @RequestParam(value = "isAcceptTask", required = true)Integer isAcceptTask,
                                @ApiParam(name = "userName", value = "需求方", required = false)
                                @RequestParam(value = "userName", required = false)String userName,
                                @ApiParam(name = "hospitalName", value = "所属机构", required = false)
                                @RequestParam(value = "hospitalName", required = false)String hospitalName,
                                @ApiParam(name = "isRead", value = "是否未读", required = false)
                                    @RequestParam(value = "isRead", required = false)Integer isRead,
                                HttpServletResponse response){
        try {
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            synergyManageService.exportWorkorder(userCode,keywords,workorderType,
                    isMyTask,status,priority,timeout,workorderCode,principal,serviceStartTime,serviceEndTime,
                    patientName,ssc,idcard,userType,isAcceptTask,userName,hospitalName,isRead,response);
        } catch (Exception e) {
            error(e);
        }
    }
    @RequestMapping(value = "/addWorkorderCustomerLog", method = RequestMethod.POST)
    @ApiOperation(value = "添加客户操作记录")
    @ResponseBody
    public String addWorkorderCustomerLog(@ApiParam(name="workorderCode",value="协同服务工单code",required = true)
                             @RequestParam(required = true)String workorderCode,
                             @ApiParam(name="workorderServiceCode",value="协同服务工单的服务对象code",required = true)
                             @RequestParam(required = true)String workorderServiceCode,
                             @ApiParam(name="userCode",value="客服code",required = false)
                             @RequestParam(required = false)String userCode,
                             @ApiParam(name="callCode",value="通话记录code",required = true)
                             @RequestParam(required = true)String callCode,
                             @ApiParam(name="status",value="状态(0、未完成,1、处理完成)",required = true)
                             @RequestParam(required = true)Integer status){
        try{
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            synergyManageService.addWorkorderCustomerLog(workorderCode,workorderServiceCode,userCode,callCode,status);
            return write(200,"保存成功");
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
    @RequestMapping(value = "adminIndex",method = RequestMethod.GET)
    @ApiOperation(value = "管理员首页.")
    @ResponseBody
    public String adminIndex(){
        try{
            return write(200,"获取成功!","data",synergyManageService.adminIndex());
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "intervalOnLine",method = RequestMethod.GET)
    @ApiOperation(value = "管理员首页-今日在线服务趋势")
    @ResponseBody
    public String intervalOnLine(){
        try{
            return write(200,"获取成功!","data",synergyManageService.intervalOnLine());
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "TodayCustomerActivy",method = RequestMethod.GET)
    @ApiOperation(value = "管理员首页-客服今日活动")
    @ResponseBody
    public String TodayCustomerActivy(){
        try{
            return write(200,"获取成功!","data",synergyManageService.TodayCustomerActivy());
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "uploadAccessory",method = RequestMethod.POST)
    @ApiOperation(value = "上传附件")
    @ResponseBody
    public String uploadAccessory(HttpServletRequest request){
        try{
            Map<String,Object> map = synergyManageService.uploadAccessory(request);
            return write(200,"获取成功!","data",map);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "accessoryList",method = RequestMethod.GET)
    @ApiOperation(value = "获取附件")
    @ResponseBody
    public String accessoryList(@ApiParam(name="workorderCode",value="协同服务code",required = true)
                                 @RequestParam(required = true)String workorderCode){
        try{
            List<ManageSynergyAccessoryDO> resultList = synergyManageService.accessoryList(workorderCode);
            return write(200,"获取成功!","date",resultList);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "deleteFile",method = RequestMethod.POST)
    @ApiOperation(value = "删除附件")
    @ResponseBody
    public String deleteFile(@ApiParam(name="storagePath",value="文件的全部路径 如:group1/M00/00/00/wKgRsVjtwpSAXGwkAAAweEAzRjw471.jpg",required = true)
                             @RequestParam(required = true)String storagePath){
        try{
            synergyManageService.deleteFile(storagePath);
            return write(200,"删除成功!");
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"删除失败!");
        }
    }
    @RequestMapping(value = "getArticalById",method = RequestMethod.GET)
    @ApiOperation(value = "获取健康文章详情")
    @ResponseBody
    public String getArticalById(@ApiParam(name="articalId",value="文章id",required = true)
                             @RequestParam(required = true)String articalId){
        try{
            JSONObject jsonObject = synergyManageService.getArticalById(articalId);
            return write(200,"获取成功!","data",jsonObject);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "deleteWorkorder",method = RequestMethod.POST)
    @ApiOperation(value = "删除工单")
    @ResponseBody
    public String deleteWorkorder(@ApiParam(name="workorderCode",value="工单code",required = true)
                                 @RequestParam(required = true)String workorderCode){
        try{
            synergyManageService.deleteWorkorder(workorderCode);
            return write(200,"删除成功!");
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"删除失败!");
        }
    }
    @RequestMapping(value = "/getTaskByIdcard", method = RequestMethod.GET)
    @ApiOperation(value = "根据身份证号获取协同服务居民信息")
    @ResponseBody
    public String takeWorkorderNum(@ApiParam(name="workorderCode",value="协同服务工单code",required = true)
                                   @RequestParam(required = true)String workorderCode,
                                   @ApiParam(name="idcard",value="身份证号",required = true)
                                   @RequestParam(required = true)String idcard){
        try {
            Map<String,Object> resultMap = synergyManageService.getTaskByIdcard(workorderCode,idcard);
            return write(200,"获取成功","data", resultMap);
        }catch (Exception e){
            error(e);
            return error(-1,"获取失败");
        }
    }
    @RequestMapping(value = "/create/ManageSynergyWorkorderTestInstructions", method = RequestMethod.GET)
    @ApiOperation(value = "协同服务-新增体检说明")
    @ResponseBody
    public String createManageSynergyWorkorderTestInstructions(
            @ApiParam(name = "orgCode", value = "机构编码", required = true)
            @RequestParam(required = true) String orgCode,
            @ApiParam(name = "orgName", value = "机构名称", required = false)
            @RequestParam(required = false) String orgName,
            @ApiParam(name = "testCrowd", value = "体检人群", required = false)
            @RequestParam(required = false) String testCrowd,
            @ApiParam(name = "testPrepare", value = "体检前准备", required = false)
            @RequestParam(required = false) String testPrepare,
            @ApiParam(name = "testMaterial", value = "提供证件、材料", required = false)
            @RequestParam(required = false) String testMaterial,
            @ApiParam(name = "testContent", value = "体检内容", required = false)
            @RequestParam(required = false) String testContent,
            @ApiParam(name = "testRelatedServices", value = "家庭医生相关服务", required = false)
            @RequestParam(required = false) String testRelatedServices,
            @ApiParam(name = "testAreaTime", value = "地点、时间", required = false)
            @RequestParam(required = false) String testAreaTime) {
        try {
            ManageSynergyWorkorderTestInstructionsDo mswtiDo = synergyManageService.createManageSynergyWorkorderTestInstructions( orgCode, orgName, testCrowd, testPrepare, testMaterial, testContent, testRelatedServices,  testAreaTime);
            return write(200,"创建成功","data", mswtiDo);
        }catch (Exception e){
            error(e);
            return error(-1,"获取失败");
        }
    }
    @RequestMapping(value = "findManageSynergyWorkorderArticleById",method = RequestMethod.GET)
    @ApiOperation(value = "集美客服-健康教育文章(医生编写)id")
    @ResponseBody
    public String findManageSynergyWorkorderArticleById(
            @ApiParam(name="articalId",value="集美客服-健康教育文章id",required = true)
            @RequestParam(required = true)Long articalId){
        try{
            JSONObject jsonObject = synergyManageService.findManageSynergyWorkorderArticleById(articalId);
            return write(200,"获取成功!","data",jsonObject);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "findTestInstructionsByOrgCode",method = RequestMethod.GET)
    @ApiOperation(value = "集美客服-根据机构code获取体检说明")
    @ResponseBody
    public String findTestInstructionsByOrgCode(
            @ApiParam(name="orgCode",value="协同服务医生机构编码",required = true)
            @RequestParam(required = true)String orgCode){
        try{
            ManageSynergyWorkorderTestInstructionsDo jsonObject = synergyManageService.findByorgCode(orgCode);
            return write(200,"获取成功!","data",jsonObject);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    /**
     * 根据患者标志获取健康指标
     * @param patient 患者指标
     * @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
     * @return 操作结果
     */
    @RequestMapping(value = "healthIndexList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("根据患者标志获取健康指标")
    public String getHealthIndexByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "P20160901001")
                                          @RequestParam(value="patient",required = true) String patient,
                                          @ApiParam(name="type",value="指标类型",defaultValue = "1")
                                          @RequestParam(value="type",required = true) int type,
                                          @ApiParam(name="begin",value="开始时间",defaultValue = "2016-07-23 00:00:00")
                                          @RequestParam(value="begin",required = true) String begin,
                                          @ApiParam(name="end",value="开始时间",defaultValue = "2016-08-23 00:00:00")
                                          @RequestParam(value="end",required = true) String end,
                                          @ApiParam(name="page",value="第几页",defaultValue = "1")
                                          @RequestParam(value="page",required = true) int page,
                                          @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
                                          @RequestParam(value="pagesize",required = true) int pagesize) {
        try {
            JSONArray jsonArray = synergyManageService.findIndexByPatient(patient, type, begin, end, page, pagesize);
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
//    @RequestMapping(value = "fileListener",method = RequestMethod.GET)
//    @ApiOperation(value = "录音监控")
//    @ResponseBody
//    public String fileListener(){
//        try{
//            File directory = new File("D:\\testFile");
//            // 轮询间隔 5 秒
//            long interval = TimeUnit.SECONDS.toMillis(5);
//            // 创建一个文件观察器用于处理文件的格式
//            FileAlterationObserver observer = new FileAlterationObserver(directory, FileFilterUtils.and(
//                    FileFilterUtils.fileFileFilter(),FileFilterUtils.suffixFileFilter(".mp3")));
//            //设置文件变化监听器
//            observer.addListener(new FileListener());
//            FileAlterationMonitor monitor = new FileAlterationMonitor(interval,observer);
//            monitor.start();
//            return write(200, "启动成功");
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1, "启动失败!");
//        }
//    }
    @RequestMapping(value = "standard",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("患者健康指标预警值查询")
    public String standard(@ApiParam(name="patient",value="患者代码",defaultValue = "P20160901001")
                                          @RequestParam(value="patient",required = true) String patient) {
        try {
            JSONObject jsonObject = synergyManageService.standard(patient);
            return write(200, "查询成功", "list", jsonObject);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    
    
    @RequestMapping(value = "/callrecordOutExcel", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public void outExcel(String startTime,String endTime,HttpServletResponse response) {
        
        try {
            List<Map<String, Object>> list = synergyManageService.findAllCallRecord(startTime,endTime);
            
            //基本设置
            response.setContentType("application/vnd.ms-excel");
            String fileName = "通话记录导出";
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            Date date = new Date();
            response.setHeader("Content-Disposition", "attachment; filename="
                    + new String(fileName.getBytes("UTF-8"), "ISO8859-1") + "_" + sdf.format(date) + ".xls");
            OutputStream os = response.getOutputStream();
            //处理Excel
            WritableWorkbook book = Workbook.createWorkbook(os);
            WritableSheet sheet = book.createSheet("通话记录", 0);
            sheet.addCell(new Label(0, 0, "序号"));
            sheet.addCell(new Label(1, 0, "日期"));
            sheet.addCell(new Label(2, 0, "呼入号码"));
            sheet.addCell(new Label(3, 0, "回电号码"));
            sheet.addCell(new Label(4, 0, "居民姓名"));
            sheet.addCell(new Label(5, 0, "居民电话"));
            sheet.addCell(new Label(6, 0, "所属社区"));
            sheet.addCell(new Label(7, 0, "家庭医生"));
            sheet.addCell(new Label(8, 0, "医生电话"));
            sheet.addCell(new Label(9, 0, "服务类型"));
            sheet.addCell(new Label(10,0,"是否跟进"));
            sheet.addCell(new Label(11, 0, "状态"));
            sheet.addCell(new Label(12, 0, "工单内容"));
            sheet.addCell(new Label(13, 0, "受理客服"));
            sheet.addCell(new Label(14, 0, "工单状态"));
            List<Map<String, Object>> objList = list;
            if (null != objList && objList.size() > 0 && objList.get(0).size() > 0) {
                for(int i = 0; i< objList.size(); i ++) {
                    Map<String, Object> objMap = objList.get(i);
                    String followup = null;
                    if (objMap.get("follow_up")!= null){
                        if (objMap.get("follow_up").toString().equalsIgnoreCase("0")){
                            followup="无需跟进";
                        }else if (objMap.get("follow_up").toString().equalsIgnoreCase("1")){
                            followup="需跟进";
                        }else if (objMap.get("follow_up").toString().equalsIgnoreCase("2")){
                            followup="已跟进";
                        }
                    }
                    StringBuffer buffer = new StringBuffer();
                    if (objMap.get("server_type_name")!=null){
                        String str[]=objMap.get("server_type_name").toString().split(",");
                        for (int k=0;k<str.length;k++){
                            if (objMap.get("server_type_name").toString().contains("0")){
                                buffer.append("咨询"+",");
                            }else if (str[k].equalsIgnoreCase("1")){
                                buffer.append("健康文章"+",");
                            }else if (str[k].equalsIgnoreCase("2")){
                                buffer.append("预约"+",");
                            }else if (str[k].equalsIgnoreCase("3")){
                                buffer.append("随访"+",");
                            }else if (str[k].equalsIgnoreCase("4")){
                                buffer.append("问卷调查"+",");
                            }else if (str[k].equalsIgnoreCase("5")){
                                buffer.append("疾病筛查"+",");
                            }else if (str[k].equalsIgnoreCase("6")){
                                buffer.append("健康教育"+",");
                            }else if (str[k].equalsIgnoreCase("7")){
                                buffer.append("体检提醒"+",");
                            }else if (str[k].equalsIgnoreCase("8")){
                                buffer.append("体征测量"+",");
                            }else if (str[k].equalsIgnoreCase("9")){
                                buffer.append("咨询医生"+",");
                            }else if (str[k].equalsIgnoreCase("10")){
                                buffer.append("咨询客服"+",");
                            }else if (str[k].equalsIgnoreCase("11")){
                                buffer.append("医生代预约"+",");
                            }else if (str[k].equalsIgnoreCase("12")){
                                buffer.append("客服预约"+",");
                            }else if (str[k].equalsIgnoreCase("13")){
                                buffer.append("急救"+",");
                            }
                        }
                        if (buffer!=null&&buffer.length()>0){
                            buffer.deleteCharAt(buffer.length()-1);
                        }
                    }
                    sheet.addCell(new Label(0, i + 1, String.valueOf(i + 1)));
                    sheet.addCell(new Label(1, i + 1, String.valueOf(objMap.get("create_time") != null ? objMap.get("create_time") : "")));
                    sheet.addCell(new Label(2, i + 1, String.valueOf(objMap.get("caller_number")!= null ? objMap.get("caller_number") : "")));
                    sheet.addCell(new Label(3, i + 1, String.valueOf(objMap.get("recipient_number")!= null ? objMap.get("recipient_number") : "")));
                    sheet.addCell(new Label(4, i + 1, String.valueOf(objMap.get("patient_name")!= null ? objMap.get("patient_name") : "")));
                    sheet.addCell(new Label(5, i + 1, String.valueOf(objMap.get("mobile")!= null ? objMap.get("mobile") : "")));
                    sheet.addCell(new Label(6, i + 1, String.valueOf(objMap.get("hospital_name")!= null ? objMap.get("hospital_name") : "")));
                    sheet.addCell(new Label(7, i + 1, String.valueOf(objMap.get("doctor_name")!= null ? objMap.get("doctor_name") : "")));
                    sheet.addCell(new Label(8, i + 1, String.valueOf(objMap.get("doctorMobile")!= null ? objMap.get("doctorMobile") : "")));
                    sheet.addCell(new Label(9, i + 1, String.valueOf(buffer!= null ? buffer : "")));
                    sheet.addCell(new Label(10, i + 1, String.valueOf(followup!= null ? followup : "")));
                    sheet.addCell(new Label(11, i + 1, String.valueOf(objMap.get("answer_status_name")!= null ? objMap.get("answer_status_name") : "")));
                    sheet.addCell(new Label(12, i + 1, String.valueOf(objMap.get("service_content")!= null ? objMap.get("service_content") : "")));
                    sheet.addCell(new Label(13, i + 1, String.valueOf(objMap.get("user_name")!= null ? objMap.get("user_name") : "")));
                    sheet.addCell(new Label(14, i + 1, String.valueOf(objMap.get("transfer_state_name")!= null ? objMap.get("transfer_state_name") : "")));
                }
            }
            
            book.write();
            book.close();
            os.flush();
            os.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (WriteException e) {
            e.printStackTrace();
        }
        
    }
    /**
     * 关闭工单
     * @param workorderCode
     * @param reason
     * @return
     */
    @RequestMapping(value = "/closeWorkorder", method = RequestMethod.GET)
    @ApiOperation(value = "关闭工单")
    @ResponseBody
    public String closeWorkorder(@ApiParam(name="workorderCode",value="协同服务工单code",required = true)
                                   @RequestParam(required = true)String workorderCode,
                                   @ApiParam(name="reason",value="关闭说明",required = true)
                                   @RequestParam(required = true)String reason,
                                 @ApiParam(name = "userCode",value = "客服code")
                                 @RequestParam(required = true)String userCode){
        try {
            synergyManageService.closeWorkorder(workorderCode,reason,userCode);
            return write(200,"关闭成功");
        }catch (Exception e){
            error(e);
            return error(-1,"关闭失败");
        }
    }
    @RequestMapping(value = "hospitalsByType",method = RequestMethod.GET)
    @ResponseBody
    public String getHospitalByType(@RequestParam(value = "type", required = true) Integer type,@RequestParam(value = "code", required = true) String code) {
        try {
            List<Hospital> hospitals = hospitalService.getHospitalByType(type,code);
            return write(200, "操作成功!", "list", hospitals);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //获取某个机构下的所有团队
    @RequestMapping(value = "teamList", method = RequestMethod.GET)
    @ResponseBody
    public String searchTeams(
            @ApiParam(name = "town", required = false,value = "区编码")
            @RequestParam(value = "town", required = false) String town,
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode", required = false) String orgCode) {
        try {
            //按医生code信息外查询,
            List<WlyyAdminTeam> wlyyTeams = teamService.getByOrgCode(orgCode,town);
            return write(200, "操作成功", "list",wlyyTeams);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
}

+ 307 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/KnowledgeArticleController.java

@ -0,0 +1,307 @@
package  com.yihu.customer.controller.synergy.customer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.Hospital;
import  com.yihu.customer.entity.User;
import  com.yihu.customer.entity.synergy.KnowledgeArticleDO;
import  com.yihu.customer.entity.synergy.KnowledgeCategoryDO;
import com.yihu.customer.service.common.district.DistrictService;
import com.yihu.customer.service.manager.hos.HosService;
import com.yihu.customer.service.synergy.KnowledgeArticleService;
import com.yihu.customer.service.synergy.KnowledgeCategoryService;
import  com.yihu.customer.repository.UserDao;
import com.yihu.customer.util.DateTimeUtil;
import com.yihu.customer.util.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created by wxw on 2018/12/26.
 *
 * @author wxw.
 */
@RestController
@RequestMapping(value = "/customer/article", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "知识库-文章管理")
public class KnowledgeArticleController extends BaseController {
    @Autowired
    private KnowledgeArticleService articleService;
    @Autowired
    private DistrictService districtService;
    @Autowired
    private HosService hosService;
    @Autowired
    private KnowledgeCategoryService categoryService;
    @Autowired
    private UserDao userDao;
    @RequestMapping(value = "/searchPageList", method = RequestMethod.GET)
    @ApiOperation(value = "获取文章列表")
    public String searchPageList(
            @ApiParam(name = "category", value = "分类编码")
            @RequestParam(value = "category", required = false) String category,
            @ApiParam(name = "keyword", value = "分类编码")
            @RequestParam(value = "keyword", required = false) String keyword,
            @ApiParam(name = "start", value = "开始时间")
            @RequestParam(value = "start", required = false) String start,
            @ApiParam(name = "end", value = "结束时间")
            @RequestParam(value = "end", required = false) String end,
            @ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
            @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
            @ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
            @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize) {
        try {
            StringBuffer sb = new StringBuffer();
            sb.append("del=1;");
            if (StringUtils.isNotEmpty(category)) {
                sb.append("category=").append(category).append(";");
            }
            if (StringUtils.isNotEmpty(keyword)) {
                sb.append("title?").append(keyword).append(" g1;").append("content?").append(keyword).append(" g1;");
            }
            if (StringUtils.isNotEmpty(start)) {
                Date startDate = DateUtil.strToDate(start, DateUtil.YYYY_MM_DD);
                sb.append("czrq>=").append(DateTimeUtil.utcDateTimeFormat(startDate)).append(";");
            }
            if (StringUtils.isNotEmpty(end)) {
                Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD);
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(endDate);
                calendar.add(Calendar.DATE, 1);
                endDate = calendar.getTime();
                sb.append("czrq<").append(DateTimeUtil.utcDateTimeFormat(endDate)).append(";");
            }
            PageRequest pageRequest = PageRequest.of(page - 1, pageSize);
            List search = articleService.search("", sb.toString(), "-czrq", page, pageSize);
            List search1 = new ArrayList();
            for (int i=0;i<search.size();i++){
                Object object = search.get(i);
                JSONObject jsonObject = (JSONObject) JSON.toJSON(object);
                User user = userDao.findByCode(jsonObject.getString("patient"));
                jsonObject.put("name",user.getName());
                search1.add(jsonObject);
            }
            List searchCount = articleService.search(sb.toString());
            Page result = new PageImpl(search1, pageRequest, null != searchCount && searchCount.size() > 0 ? searchCount.size() : 0);
            return  write(200, "获取成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/searchKnowledgePageList", method = RequestMethod.GET)
    @ApiOperation(value = "获取文章列表")
    public String searchKnowledgePageList(
            @ApiParam(name = "keyword", value = "分类编码")
            @RequestParam(value = "keyword", required = false) String keyword,
            @ApiParam(name = "applyOrg", value = "适用社区")
            @RequestParam(value = "applyOrg", required = false) String applyOrg,
            @ApiParam(name = "patient", value = "用户code", required = true)
            @RequestParam(value = "patient", required = true, defaultValue = "xx") String patient,
            @ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
            @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
            @ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
            @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize) {
        try {
            StringBuffer sb = new StringBuffer();
            StringBuffer category = new StringBuffer();
            sb.append("del=1;");
            category.append("del=1;");
            if (StringUtils.isNotEmpty(keyword)) {
                List<String> list = Arrays.asList(keyword.split(","));
                for (String key : list) {
                    sb.append("title?").append(key).append(" g1;").append("content?").append(key).append(" g1;");
                    category.append("name?").append(key).append(" g1;");
                }
                List<KnowledgeCategoryDO> categoryList = categoryService.search(category.toString());
                Set<String> codes = categoryList.stream().map(KnowledgeCategoryDO::getCode).collect(Collectors.toSet());
                if (null != codes && codes.size() > 0) {
                    String join = StringUtils.join(codes, ",");
                    sb.append("category=").append(join).append(" g1;");
                }
            }
            if (StringUtils.isNotEmpty(applyOrg)) {
                sb.append("applyOrg?").append(applyOrg).append(";");
            }
            PageRequest pageRequest = PageRequest.of(page - 1, pageSize);
            List search = articleService.search("", sb.toString(), "-czrq", page, pageSize);
            List search1 = new ArrayList();
            for (int i=0;i<search.size();i++){
                Object object = search.get(i);
                JSONObject jsonObject = (JSONObject) JSON.toJSON(object);
                User user = userDao.findByCode(jsonObject.getString("patient"));
                jsonObject.put("name",user.getName());
                search1.add(jsonObject);
            }
            List searchCount = articleService.search(sb.toString());
            Page result = new PageImpl(search1, pageRequest, null != searchCount && searchCount.size() > 0 ? searchCount.size() : 0);
            return  write(200, "获取成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/searchMyPageList", method = RequestMethod.GET)
    @ApiOperation(value = "获取我的文章列表")
    public String searchMyPageList(
            @ApiParam(name = "category", value = "分类编码")
            @RequestParam(value = "category") String category,
            @ApiParam(name = "keyword", value = "分类编码")
            @RequestParam(value = "keyword") String keyword,
            @ApiParam(name = "start", value = "开始时间")
            @RequestParam(value = "start") String start,
            @ApiParam(name = "end", value = "结束时间")
            @RequestParam(value = "end") String end,
            @ApiParam(name = "applyOrg", value = "适用社区")
            @RequestParam(value = "applyOrg", required = false) String applyOrg,
            @ApiParam(name = "patient", value = "用户code", required = true)
            @RequestParam(value = "patient", required = true, defaultValue = "xx") String patient,
            @ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
            @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
            @ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
            @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize) {
        try {
            StringBuffer sb = new StringBuffer();
            sb.append("del=1;");
            if (StringUtils.isNotEmpty(category)) {
                sb.append("category=").append(category).append(";");
            }
            if (StringUtils.isNotEmpty(keyword)) {
                sb.append("title?").append(keyword).append(" g1;").append("content?").append(keyword).append(" g1;");
            }
            if (StringUtils.isNotEmpty(start)) {
                Date startDate = DateUtil.strToDate(start, DateUtil.YYYY_MM_DD);
                sb.append("czrq>=").append(DateTimeUtil.utcDateTimeFormat(startDate)).append(";");
            }
            if (StringUtils.isNotEmpty(end)) {
                Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD);
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(endDate);
                calendar.add(Calendar.DATE, 1);
                endDate = calendar.getTime();
                sb.append("czrq<").append(DateTimeUtil.utcDateTimeFormat(endDate)).append(";");
            }
            if (StringUtils.isNotEmpty(applyOrg)) {
                sb.append("applyOrg?").append(applyOrg).append(";");
            }
            if (StringUtils.isEmpty(patient)) {
                sb.append("patient=-1;");
            } else {
                sb.append("patient=").append(patient).append(";");
            }
            PageRequest pageRequest = PageRequest.of(page - 1, pageSize);
            List search = articleService.search("", sb.toString(), "-czrq", page, pageSize);
            List searchCount = articleService.search(sb.toString());
            Page result = new PageImpl(search, pageRequest, null != searchCount && searchCount.size() > 0 ? searchCount.size() : 0);
            return  write(200, "获取成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/queryById", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询文章")
    public String queryByCode(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id", required = true)Long id) {
        try {
            KnowledgeArticleDO articleDO = articleService.findById(id);
            return  write(200, "获取成功!", "data", articleDO);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/queryOneById", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询文章详情")
    public String queryOneById(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id", required = true)Long id) {
        try {
            KnowledgeArticleDO articleDO = articleService.queryOneById(id);
            return  write(200, "获取成功!", "data", articleDO);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/deleteById", method = RequestMethod.GET)
    @ApiOperation(value = "根据id删除文章")
    public String DeleteById(
            @ApiParam(name = "id", value = "id,多个使用英文逗号分隔", required = true)
            @RequestParam(value = "id", required = true)String id) {
        try {
            articleService.delArticle(id);
            return  write(200, "删除成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "删除失败!");
        }
    }
    @RequestMapping(value = "/updateArticle",method = RequestMethod.POST)
    @ApiOperation("更新客服文章")
    public String updateArticle(String json) {
        try {
            articleService.updateArticle(json);
            return write(200, "更新成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "更新失败");
        }
    }
    @RequestMapping(value = "/hospitalsTree", method = RequestMethod.GET)
    @ApiOperation("查询机构树接口")
    public String hospitalsTree() {
        try {
            List<Map<String, Object>> list = articleService.hospitalsTree("");
            return write(200, "获取成功","data", list);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/hospitalsByCity", method = RequestMethod.GET)
    @ApiOperation("根据区域查询机构")
    public String hospitalsByCity(@RequestParam(value = "code", required = true) String code) {
        try {
            List<Hospital> hospitalList = hosService.getHospitalByType(1, code);
            return write(200, "获取成功","data", hospitalList);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getHospitalList", method = RequestMethod.GET)
    @ApiOperation("模糊查询机构")
    public String getHospitalList(@RequestParam(value = "name", required = false) String name) {
        try {
            List<Hospital> hospitals = hosService.searchHospitalNoPage(name,null);
            return write(200, "获取成功","data", hospitals);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "获取失败");
        }
    }
}

+ 121 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/customer/KnowledgeCategoryController.java

@ -0,0 +1,121 @@
package  com.yihu.customer.controller.synergy.customer;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.synergy.KnowledgeCategoryDO;
import com.yihu.customer.service.synergy.KnowledgeCategoryService;
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.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by wxw on 2018/12/26.
 *
 * @author wxw.
 */
@RestController
@RequestMapping(value = "/customer/category", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "知识库-分类管理")
public class KnowledgeCategoryController extends BaseController {
    @Autowired
    private KnowledgeCategoryService service;
    @RequestMapping(value = "/saveCategory", method = RequestMethod.POST)
    @ApiOperation(value = "新增、修改分类")
    public String saveCategory(String json) {
        try {
            KnowledgeCategoryDO knowledgeCategoryDO = service.saveCategory(json);
            return  write(200, "保存成功!", "data", knowledgeCategoryDO);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
    @RequestMapping(value = "/searchCategoryPageList", method = RequestMethod.GET)
    @ApiOperation(value = "获取分类列表")
    public String searchCategoryPageList(
            @ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
            @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
            @ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
            @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize) {
        try {
            Map<String, Object> map = new HashMap<>();
            String filters = "del=1";
            PageRequest pageRequest = PageRequest.of(page - 1, pageSize);
            List search = service.search("", filters, "", page, pageSize);
            List searchCount = service.search(filters);
            Page result = new PageImpl(search, pageRequest, null != searchCount && searchCount.size() > 0 ? searchCount.size() : 0);
            return  write(200, "获取成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/hasExistCode", method = RequestMethod.GET)
    @ApiOperation(value = "是否存在分类code")
    public String hasExistCode(
            @ApiParam(name = "code", value = "code", required = true)
            @RequestParam(value = "code", required = true)String code) {
        try {
            Boolean flag = service.hasExistCode(code);
            return  write(200, "获取成功!", "data", flag);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/updateDel", method = RequestMethod.GET)
    @ApiOperation(value = "根据分类code删除分类")
    public String updateDel(
            @ApiParam(name = "code", value = "code", required = true)
            @RequestParam(value = "code", required = true)String code) {
        try {
            Boolean flag = service.updateDel(code);
            if (!flag) {
                return write(205, "该分类下有文章,请先删除文章!");
            }
            return write(200, "删除成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "删除失败!");
        }
    }
    @RequestMapping(value = "/queryByCode", method = RequestMethod.GET)
    @ApiOperation(value = "根据code查询分类")
    public String queryByCode(
            @ApiParam(name = "code", value = "code", required = true)
            @RequestParam(value = "code", required = true)String code) {
        try {
            KnowledgeCategoryDO knowledgeCategoryDO = service.queryByCode(code);
            return  write(200, "获取成功!", "data", knowledgeCategoryDO);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/searchCategoryList", method = RequestMethod.GET)
    @ApiOperation(value = "获取分类列表")
    public String searchCategoryList() {
        try {
            List search = service.search("del=1;pid=0;");
            return  write(200, "获取成功!", "data", search);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
}

+ 53 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/doctor/DoctorQuestionnaireController.java

@ -0,0 +1,53 @@
package  com.yihu.customer.controller.synergy.doctor;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.yihu.customer.controller.BaseController;
import  com.yihu.customer.entity.synergy.ManageSynergyWorkorderDO;
import  com.yihu.customer.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.customer.service.synergy.QuestionnaireManageService;
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.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.List;
/**
 * 管理端问卷调查
 * Created by humingfen on 2018/9/27.
 */
@RestController
@RequestMapping(value = "/synergy/questionnaire", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-派发协同服务")
public class DoctorQuestionnaireController extends BaseController {
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    private QuestionnaireManageService questionnaireService;
    @RequestMapping(value = "/createWorkOrder", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "派发协同服务")
    public String addCallRecord(@ApiParam(name="jsonData",value="协同服务json字符串")
                                    @RequestParam(required = true)String jsonData,
                                @ApiParam(name="patientInfo",value="居民信息json字符串")
                                    @RequestParam(required = true)String patientInfo){
        try {
            ObjectMapper object = new ObjectMapper();
            object.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm"));
            ManageSynergyWorkorderDO manageSynergyWorkorderDO = object.readValue(jsonData, ManageSynergyWorkorderDO.class);
            List<ManageSynergyWorkorderServicerDO>  manageSynergyWorkorderServicerDOS = object.readValue(patientInfo, new TypeReference<List<ManageSynergyWorkorderServicerDO>>(){});
            return write(200,"保存成功","data",questionnaireService.createWorkOrder(manageSynergyWorkorderDO, manageSynergyWorkorderServicerDOS));
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
}

+ 0 - 0
svr/svr-manage/src/main/java/com/yihu/customer/controller/synergy/doctor/DoctorSynergyManageController.java


部分文件因文件數量過多而無法顯示