Browse Source

患者广告接口开发

chenyongxing 7 years ago
parent
commit
6cb0416d28
31 changed files with 1107 additions and 143 deletions
  1. 33 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/patient/WlyyPatientContants.java
  2. 5 0
      svr-lib-parent-pom/pom.xml
  3. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/SaasService.java
  4. 4 0
      svr/svr-wlyy/pom.xml
  5. 214 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/util/AddressUtils.java
  6. 17 17
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/controller/WlyyAgreementController.java
  7. 17 17
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/controller/WlyyAgreementKpiController.java
  8. 13 13
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/controller/WlyyAgreementKpiLogController.java
  9. 15 15
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/controller/WlyySignFamilyController.java
  10. 133 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/controller/patient/AdvertisementControlelr.java
  11. 2 2
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/dao/WlyyAgreementDao.java
  12. 2 2
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/dao/WlyyAgreementKpiDao.java
  13. 2 2
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/dao/WlyyAgreementKpiLogDao.java
  14. 7 2
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/dao/WlyySignFamilyDao.java
  15. 23 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/patient/AdvertisementDao.java
  16. 19 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/patient/BasePatientDao.java
  17. 1 1
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/common/entity/base/IdEntity.java
  18. 2 2
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyyAgreement.java
  19. 2 2
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyyAgreementKpi.java
  20. 2 2
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyyAgreementKpiLog.java
  21. 2 2
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyySignFamily.java
  22. 173 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/patient/WlyyAdvertisement.java
  23. 10 10
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyyAgreementKpiLogService.java
  24. 21 21
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyyAgreementKpiService.java
  25. 16 16
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyyAgreementService.java
  26. 28 17
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyySignFamilyService.java
  27. 150 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/patient/AdvertisementService.java
  28. 20 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/patient/PatientService.java
  29. 17 0
      web-gateway/src/main/java/com/yihu/jw/commnon/wlyy/PatientContants.java
  30. 103 0
      web-gateway/src/main/java/com/yihu/jw/controller/wlyy/patient/AdvertisementControlelr.java
  31. 50 0
      web-gateway/src/main/java/com/yihu/jw/fegin/wlyy/patient/AdvertisementFegin.java

+ 33 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/patient/WlyyPatientContants.java

@ -0,0 +1,33 @@
package com.yihu.jw.restmodel.wlyy.patient;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public class WlyyPatientContants {
    public static class Advertisement{
        public static final String api_common="wlyyAdvertisement";
        public static final String api_create="create";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_update="update";
        public static final String api_queryPage="queryPage";
        public static final String api_getList="getList";
        public static final String api_getListByPatientCode="getListByPatientCode";
        public static final String message_success_update="agreement update success";
        public static final String message_success_delete="agreement delete success";
        public static final String message_success_find="agreement find success";
        public static final String message_success_create="agreement create success";
        public static final String message_success_find_functions="agreement find success";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_status_is_null="status is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_exist="code exist";
        public static final String message_fail_saasid_is_null="saasid is null";
        public static final String message_fail_picture_is_null="picture is null";
        public static final String message_fail_wlyyAdvertisement_is_not_exist="WlyyAdvertisement is not exist";
    }
}

+ 5 - 0
svr-lib-parent-pom/pom.xml

@ -95,6 +95,11 @@
                <artifactId>common-rest-model</artifactId>
                <version>${version.myCommon}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.jw</groupId>
                <artifactId>svr-base</artifactId>
                <version>${version.myCommon}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.jw</groupId>
                <artifactId>common-util</artifactId>

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/SaasService.java

@ -68,4 +68,8 @@ public class SaasService extends BaseJpaService<Saas, SaasDao> {
        }
        saas.setStatus(-1);
    }
    public Saas findByName(String cityName) {
        return saasDao.findByName(cityName);
    }
}

+ 4 - 0
svr/svr-wlyy/pom.xml

@ -15,6 +15,10 @@
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>svr-base</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-swagger</artifactId>

+ 214 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/util/AddressUtils.java

@ -0,0 +1,214 @@
package com.yihu.jw.util;
import org.apache.commons.lang.StringUtils;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public class AddressUtils {
    /**
     * 返回"0" 为无效ip,局域网测试
     * "中国-西南-四川省-成都市- -电信"  (没有值,中间用空格隔开  country-area-region-city-county-isp)
     * @param content
     * @param encodingString
     * @return
     * @throws UnsupportedEncodingException
     */
    public String getAddresses(String content, String encodingString)
            throws UnsupportedEncodingException {
        // 这里调用pconline的接口
        String urlStr = "http://ip.taobao.com/service/getIpInfo.php";
        // 从http://whois.pconline.com.cn取得IP所在的省市区信息
        String returnStr = this.getResult(urlStr, content, encodingString);
        if (returnStr != null) {
            // 处理返回的省市区信息
            System.out.println(returnStr);
            String[] temp = returnStr.split(",");
            if (temp.length < 3) {
                return "0";//无效IP,局域网测试
            }
            String region = (temp[5].split(":"))[1].replaceAll("\"", "");
            region = decodeUnicode(region);// 省份
            String country = "";
            String area = "";
            // String region = "";
            String city = "";
            String county = "";
            String isp = "";
            for (int i = 0; i < temp.length; i++) {
                switch (i) {
                    case 1:
                        country = (temp[i].split(":"))[2].replaceAll("\"", "");
                        country = decodeUnicode(country);// 国家
                        break;
                    case 3:
                        area = (temp[i].split(":"))[1].replaceAll("\"", "");
                        area = decodeUnicode(area);// 地区
                        break;
                    case 5:
                        region = (temp[i].split(":"))[1].replaceAll("\"", "");
                        region = decodeUnicode(region);// 省份
                        break;
                    case 7:
                        city = (temp[i].split(":"))[1].replaceAll("\"", "");
                        city = decodeUnicode(city);// 市区
                        break;
                    case 9:
                        county = (temp[i].split(":"))[1].replaceAll("\"", "");
                        county = decodeUnicode(county);// 地区
                        break;
                    case 11:
                        isp = (temp[i].split(":"))[1].replaceAll("\"", "");
                        isp = decodeUnicode(isp); // ISP公司
                        break;
                }
            }
            String district = country + "-" + area + "-" + region + "-" + city + "-" + county + "-" + isp;
            return district;
        }
        return null;
    }
    /**
     * @param urlStr   请求的地址
     * @param content  请求的参数 格式为:name=xxx&pwd=xxx
     * @param encoding 服务器端请求编码。如GBK,UTF-8等
     * @return
     */
    private String getResult(String urlStr, String content, String encoding) {
        URL url = null;
        HttpURLConnection connection = null;
        try {
            url = new URL(urlStr);
            connection = (HttpURLConnection) url.openConnection();// 新建连接实例
            connection.setConnectTimeout(2000);// 设置连接超时时间,单位毫秒
            connection.setReadTimeout(2000);// 设置读取数据超时时间,单位毫秒
            connection.setDoOutput(true);// 是否打开输出流 true|false
            connection.setDoInput(true);// 是否打开输入流true|false
            connection.setRequestMethod("POST");// 提交方法POST|GET
            connection.setUseCaches(false);// 是否缓存true|false
            connection.connect();// 打开连接端口
            DataOutputStream out = new DataOutputStream(connection
                    .getOutputStream());// 打开输出流往对端服务器写数据
            out.writeBytes(content);// 写数据,也就是提交你的表单 name=xxx&pwd=xxx
            out.flush();// 刷新
            out.close();// 关闭输出流
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    connection.getInputStream(), encoding));// 往对端写完数据对端服务器返回数据
            // ,以BufferedReader流来读取
            StringBuffer buffer = new StringBuffer();
            String line = "";
            while ((line = reader.readLine()) != null) {
                buffer.append(line);
            }
            reader.close();
            return buffer.toString();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                connection.disconnect();// 关闭连接
            }
        }
        return null;
    }
    /**
     * unicode 转换成 中文
     *
     * @param theString
     * @return
     * @author fanhui 2007-3-15
     */
    public static String decodeUnicode(String theString) {
        char aChar;
        int len = theString.length();
        StringBuffer outBuffer = new StringBuffer(len);
        for (int x = 0; x < len; ) {
            aChar = theString.charAt(x++);
            if (aChar == '\\') {
                aChar = theString.charAt(x++);
                if (aChar == 'u') {
                    int value = 0;
                    for (int i = 0; i < 4; i++) {
                        aChar = theString.charAt(x++);
                        switch (aChar) {
                            case '0':
                            case '1':
                            case '2':
                            case '3':
                            case '4':
                            case '5':
                            case '6':
                            case '7':
                            case '8':
                            case '9':
                                value = (value << 4) + aChar - '0';
                                break;
                            case 'a':
                            case 'b':
                            case 'c':
                            case 'd':
                            case 'e':
                            case 'f':
                                value = (value << 4) + 10 + aChar - 'a';
                                break;
                            case 'A':
                            case 'B':
                            case 'C':
                            case 'D':
                            case 'E':
                            case 'F':
                                value = (value << 4) + 10 + aChar - 'A';
                                break;
                            default:
                                throw new IllegalArgumentException(
                                        "Malformed      encoding.");
                        }
                    }
                    outBuffer.append((char) value);
                } else {
                    if (aChar == 't') {
                        aChar = '\t';
                    } else if (aChar == 'r') {
                        aChar = '\r';
                    } else if (aChar == 'n') {
                        aChar = '\n';
                    } else if (aChar == 'f') {
                        aChar = '\f';
                    }
                    outBuffer.append(aChar);
                }
            } else {
                outBuffer.append(aChar);
            }
        }
        String string = outBuffer.toString();
        if(StringUtils.isBlank(string)){
            string=" ";
        }
        return string;
    }
    // 测试
    public static void main(String[] args) {
        AddressUtils addressUtils = new AddressUtils();
        // 测试ip 219.136.134.157 中国-华南-广东省-广州市-越秀区-电信
        String ip = "219.136.134.157";
        String address = "";
        try {
            address = addressUtils.getAddresses("ip=" + ip, "utf-8");
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println(address);
        // 输出结果为:广东省,广州市,越秀区
    }
}

+ 17 - 17
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/controller/WlyyAgreementController.java

@ -1,11 +1,11 @@
package com.yihu.jw.wlyy.agreement.controller;
package com.yihu.jw.wlyy.controller.agreement;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreement;
import com.yihu.jw.wlyy.agreement.service.WlyyAgreementService;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreement;
import com.yihu.jw.wlyy.service.agreement.WlyyAgreementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -19,67 +19,67 @@ import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(WlyyContants.Agreement.api_common)
@RequestMapping(WlyyAgreementContants.Agreement.api_common)
@Api(value = "协议相关操作", description = "协议相关操作")
public class WlyyAgreementController extends EnvelopRestController {
    @Autowired
    private WlyyAgreementService wlyyAgreementService;
    @PostMapping(value = WlyyContants.Agreement.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = WlyyAgreementContants.Agreement.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建协议", notes = "创建协议")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreement wlyyAgreement = toEntity(jsonData, WlyyAgreement.class);
            return Envelop.getSuccess(WlyyContants.Agreement.message_success_create, wlyyAgreementService.create(wlyyAgreement));
            return Envelop.getSuccess(WlyyAgreementContants.Agreement.message_success_create, wlyyAgreementService.create(wlyyAgreement));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WlyyContants.Agreement.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PutMapping(value = WlyyAgreementContants.Agreement.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改协议", notes = "修改协议")
    public Envelop update(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreement wlyyAgreement = toEntity(jsonData, WlyyAgreement.class);
            return Envelop.getSuccess(WlyyContants.Agreement.message_success_update, wlyyAgreementService.update(wlyyAgreement));
            return Envelop.getSuccess(WlyyAgreementContants.Agreement.message_success_update, wlyyAgreementService.update(wlyyAgreement));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value =WlyyContants.Agreement.api_delete)
    @DeleteMapping(value = WlyyAgreementContants.Agreement.api_delete)
    @ApiOperation(value = "删除协议", notes = "删除协议")
    public Envelop delete(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            wlyyAgreementService.delete(code);
            return Envelop.getSuccess(WlyyContants.Agreement.message_success_delete );
            return Envelop.getSuccess(WlyyAgreementContants.Agreement.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value =WlyyContants.Agreement.api_getByCode)
    @GetMapping(value = WlyyAgreementContants.Agreement.api_getByCode)
    @ApiOperation(value = "根据code查找协议", notes = "根据code查找协议")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(WlyyContants.Agreement.message_success_find, wlyyAgreementService.findByCode(code));
            return Envelop.getSuccess(WlyyAgreementContants.Agreement.message_success_find, wlyyAgreementService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value =WlyyContants.Agreement.api_queryPage, method = RequestMethod.GET)
    @RequestMapping(value = WlyyAgreementContants.Agreement.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取协议")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,parentCode,saasId,name,price,posterPic,remark,type,status")
@ -103,11 +103,11 @@ public class WlyyAgreementController extends EnvelopRestController {
        //封装返回格式
        List<WlyyAgreement> wlyyAgreement = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreement.class, fields);
        return Envelop.getSuccessListWithPage(WlyyContants.Agreement.message_success_find_functions,wlyyAgreement, page, size,count);
        return Envelop.getSuccessListWithPage(WlyyAgreementContants.Agreement.message_success_find_functions,wlyyAgreement, page, size,count);
    }
    @GetMapping(value =WlyyContants.Agreement.api_getList)
    @GetMapping(value = WlyyAgreementContants.Agreement.api_getList)
    @ApiOperation(value = "获取协议列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,parentCode,saasId,name,price,posterPic,remark,type,status")
@ -120,7 +120,7 @@ public class WlyyAgreementController extends EnvelopRestController {
        List<WlyyAgreement> list = wlyyAgreementService.search(fields,filters,sorts);
        //封装返回格式
        List<WlyyAgreement> wlyyAgreement = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreement.class, fields);
        return Envelop.getSuccessList(WlyyContants.Agreement.message_success_find_functions,wlyyAgreement);
        return Envelop.getSuccessList(WlyyAgreementContants.Agreement.message_success_find_functions,wlyyAgreement);
    }
}

+ 17 - 17
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/controller/WlyyAgreementKpiController.java

@ -1,11 +1,11 @@
package com.yihu.jw.wlyy.agreement.controller;
package com.yihu.jw.wlyy.controller.agreement;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreementKpi;
import com.yihu.jw.wlyy.agreement.service.WlyyAgreementKpiService;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreementKpi;
import com.yihu.jw.wlyy.service.agreement.WlyyAgreementKpiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -19,67 +19,67 @@ import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(WlyyContants.AgreementKpi.api_common)
@RequestMapping(WlyyAgreementContants.AgreementKpi.api_common)
@Api(value = "套餐指标相关操作", description = "套餐指标相关操作")
public class WlyyAgreementKpiController extends EnvelopRestController {
    @Autowired
    private WlyyAgreementKpiService wlyyAgreementKpiService;
    @PostMapping(value = WlyyContants.AgreementKpi.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = WlyyAgreementContants.AgreementKpi.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建套餐指标", notes = "创建套餐指标")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreementKpi wlyyAgreementKpi = toEntity(jsonData, WlyyAgreementKpi.class);
            return Envelop.getSuccess(WlyyContants.AgreementKpi.message_success_create, wlyyAgreementKpiService.create(wlyyAgreementKpi));
            return Envelop.getSuccess(WlyyAgreementContants.AgreementKpi.message_success_create, wlyyAgreementKpiService.create(wlyyAgreementKpi));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WlyyContants.AgreementKpi.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PutMapping(value = WlyyAgreementContants.AgreementKpi.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改套餐指标", notes = "修改套餐指标")
    public Envelop update(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreementKpi wlyyAgreementKpi = toEntity(jsonData, WlyyAgreementKpi.class);
            return Envelop.getSuccess(WlyyContants.AgreementKpi.message_success_update, wlyyAgreementKpiService.update(wlyyAgreementKpi));
            return Envelop.getSuccess(WlyyAgreementContants.AgreementKpi.message_success_update, wlyyAgreementKpiService.update(wlyyAgreementKpi));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value =WlyyContants.AgreementKpi.api_delete)
    @DeleteMapping(value = WlyyAgreementContants.AgreementKpi.api_delete)
    @ApiOperation(value = "删除套餐指标", notes = "删除套餐指标")
    public Envelop delete(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            wlyyAgreementKpiService.delete(code);
            return Envelop.getSuccess(WlyyContants.AgreementKpi.message_success_delete );
            return Envelop.getSuccess(WlyyAgreementContants.AgreementKpi.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value =WlyyContants.AgreementKpi.api_getByCode)
    @GetMapping(value = WlyyAgreementContants.AgreementKpi.api_getByCode)
    @ApiOperation(value = "根据code查找套餐指标", notes = "根据code查找套餐指标")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(WlyyContants.AgreementKpi.message_success_find, wlyyAgreementKpiService.findByCode(code));
            return Envelop.getSuccess(WlyyAgreementContants.AgreementKpi.message_success_find, wlyyAgreementKpiService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value =WlyyContants.AgreementKpi.api_queryPage, method = RequestMethod.GET)
    @RequestMapping(value = WlyyAgreementContants.AgreementKpi.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取套餐指标")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,agreementCode,kpiName,type,kpiTimes,status,del,kpiContent,keyword")
@ -103,11 +103,11 @@ public class WlyyAgreementKpiController extends EnvelopRestController {
        //封装返回格式
        List<WlyyAgreementKpi> wlyyAgreementKpi = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreementKpi.class, fields);
        return Envelop.getSuccessListWithPage(WlyyContants.AgreementKpi.message_success_find_functions,wlyyAgreementKpi, page, size,count);
        return Envelop.getSuccessListWithPage(WlyyAgreementContants.AgreementKpi.message_success_find_functions,wlyyAgreementKpi, page, size,count);
    }
    @GetMapping(value =WlyyContants.AgreementKpi.api_getList)
    @GetMapping(value = WlyyAgreementContants.AgreementKpi.api_getList)
    @ApiOperation(value = "获取套餐指标列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,agreementCode,kpiName,type,kpiTimes,status,del,kpiContent,keyword")
@ -120,7 +120,7 @@ public class WlyyAgreementKpiController extends EnvelopRestController {
        List<WlyyAgreementKpi> list = wlyyAgreementKpiService.search(fields,filters,sorts);
        //封装返回格式
        List<WlyyAgreementKpi> wlyyAgreementKpi = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreementKpi.class, fields);
        return Envelop.getSuccessList(WlyyContants.AgreementKpi.message_success_find_functions,wlyyAgreementKpi);
        return Envelop.getSuccessList(WlyyAgreementContants.AgreementKpi.message_success_find_functions,wlyyAgreementKpi);
    }
}

+ 13 - 13
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/controller/WlyyAgreementKpiLogController.java

@ -1,11 +1,11 @@
package com.yihu.jw.wlyy.agreement.controller;
package com.yihu.jw.wlyy.controller.agreement;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreementKpiLog;
import com.yihu.jw.wlyy.agreement.service.WlyyAgreementKpiLogService;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreementKpiLog;
import com.yihu.jw.wlyy.service.agreement.WlyyAgreementKpiLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -19,40 +19,40 @@ import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(WlyyContants.AgreementKpiLog.api_common)
@RequestMapping(WlyyAgreementContants.AgreementKpiLog.api_common)
@Api(value = "套餐指标执行日志相关操作", description = "套餐指标执行日志相关操作")
public class WlyyAgreementKpiLogController extends EnvelopRestController {
    @Autowired
    private WlyyAgreementKpiLogService wlyyAgreementKpiLogService;
    @PostMapping(value = WlyyContants.AgreementKpiLog.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = WlyyAgreementContants.AgreementKpiLog.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建套餐指标日志", notes = "创建套餐指标日志")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreementKpiLog wlyyAgreementKpiLog = toEntity(jsonData, WlyyAgreementKpiLog.class);
            return Envelop.getSuccess(WlyyContants.AgreementKpiLog.message_success_create, wlyyAgreementKpiLogService.create(wlyyAgreementKpiLog));
            return Envelop.getSuccess(WlyyAgreementContants.AgreementKpiLog.message_success_create, wlyyAgreementKpiLogService.create(wlyyAgreementKpiLog));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value =WlyyContants.AgreementKpiLog.api_getByCode)
    @GetMapping(value = WlyyAgreementContants.AgreementKpiLog.api_getByCode)
    @ApiOperation(value = "根据code查找套餐指标日志", notes = "根据code查找套餐指标日志")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(WlyyContants.AgreementKpiLog.message_success_find, wlyyAgreementKpiLogService.findByCode(code));
            return Envelop.getSuccess(WlyyAgreementContants.AgreementKpiLog.message_success_find, wlyyAgreementKpiLogService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value =WlyyContants.AgreementKpiLog.api_queryPage, method = RequestMethod.GET)
    @RequestMapping(value = WlyyAgreementContants.AgreementKpiLog.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取套餐指标日志")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,patientCode,signCode,kpiCode,agreementCode,kpiName")
@ -76,11 +76,11 @@ public class WlyyAgreementKpiLogController extends EnvelopRestController {
        //封装返回格式
        List<WlyyAgreementKpiLog> wlyyAgreementKpiLog = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreementKpiLog.class, fields);
        return Envelop.getSuccessListWithPage(WlyyContants.AgreementKpiLog.message_success_find_functions,wlyyAgreementKpiLog, page, size,count);
        return Envelop.getSuccessListWithPage(WlyyAgreementContants.AgreementKpiLog.message_success_find_functions,wlyyAgreementKpiLog, page, size,count);
    }
    @GetMapping(value =WlyyContants.AgreementKpiLog.api_getList)
    @GetMapping(value = WlyyAgreementContants.AgreementKpiLog.api_getList)
    @ApiOperation(value = "获取套餐指标日志列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,patientCode,signCode,kpiCode,agreementCode,kpiName")
@ -93,7 +93,7 @@ public class WlyyAgreementKpiLogController extends EnvelopRestController {
        List<WlyyAgreementKpiLog> list = wlyyAgreementKpiLogService.search(fields,filters,sorts);
        //封装返回格式
        List<WlyyAgreementKpiLog> wlyyAgreementKpiLog = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreementKpiLog.class, fields);
        return Envelop.getSuccessList(WlyyContants.AgreementKpiLog.message_success_find_functions,wlyyAgreementKpiLog);
        return Envelop.getSuccessList(WlyyAgreementContants.AgreementKpiLog.message_success_find_functions,wlyyAgreementKpiLog);
    }
}

+ 15 - 15
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/controller/WlyySignFamilyController.java

@ -1,11 +1,11 @@
package com.yihu.jw.wlyy.agreement.controller;
package com.yihu.jw.wlyy.controller.agreement;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.agreement.entity.WlyySignFamily;
import com.yihu.jw.wlyy.agreement.service.WlyySignFamilyService;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.wlyy.entity.agreement.WlyySignFamily;
import com.yihu.jw.wlyy.service.agreement.WlyySignFamilyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -20,53 +20,53 @@ import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(WlyyContants.SignFamily.api_common)
@RequestMapping(WlyyAgreementContants.SignFamily.api_common)
@Api(value = "签约相关操作", description = "签约相关操作")
public class WlyySignFamilyController extends EnvelopRestController {
    @Autowired
    private WlyySignFamilyService wlyySignFamilyService;
    @PostMapping(value = WlyyContants.SignFamily.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = WlyyAgreementContants.SignFamily.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建签约", notes = "创建签约")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws ParseException {
        try {
            WlyySignFamily wlyySignFamily = toEntity(jsonData, WlyySignFamily.class);
            return Envelop.getSuccess(WlyyContants.SignFamily.message_success_create, wlyySignFamilyService.create(wlyySignFamily));
            return Envelop.getSuccess(WlyyAgreementContants.SignFamily.message_success_create, wlyySignFamilyService.create(wlyySignFamily));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WlyyContants.SignFamily.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PutMapping(value = WlyyAgreementContants.SignFamily.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改签约", notes = "修改签约")
    public Envelop update(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws ParseException {
        try {
            WlyySignFamily wlyySignFamily = toEntity(jsonData, WlyySignFamily.class);
            return Envelop.getSuccess(WlyyContants.SignFamily.message_success_update, wlyySignFamilyService.update(wlyySignFamily));
            return Envelop.getSuccess(WlyyAgreementContants.SignFamily.message_success_update, wlyySignFamilyService.update(wlyySignFamily));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value =WlyyContants.SignFamily.api_getByCode)
    @GetMapping(value = WlyyAgreementContants.SignFamily.api_getByCode)
    @ApiOperation(value = "根据code查找协议", notes = "根据code查找协议")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(WlyyContants.SignFamily.message_success_find, wlyySignFamilyService.findByCode(code));
            return Envelop.getSuccess(WlyyAgreementContants.SignFamily.message_success_find, wlyySignFamilyService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value =WlyyContants.SignFamily.api_queryPage, method = RequestMethod.GET)
    @RequestMapping(value = WlyyAgreementContants.SignFamily.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取协议")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
@ -90,11 +90,11 @@ public class WlyySignFamilyController extends EnvelopRestController {
        //封装返回格式
        List<WlyySignFamily> wlyySignFamily = convertToModels(list, new ArrayList<>(list.size()), WlyySignFamily.class, fields);
        return Envelop.getSuccessListWithPage(WlyyContants.SignFamily.message_success_find_functions,wlyySignFamily, page, size,count);
        return Envelop.getSuccessListWithPage(WlyyAgreementContants.SignFamily.message_success_find_functions,wlyySignFamily, page, size,count);
    }
    @GetMapping(value =WlyyContants.SignFamily.api_getList)
    @GetMapping(value = WlyyAgreementContants.SignFamily.api_getList)
    @ApiOperation(value = "获取协议列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
@ -107,7 +107,7 @@ public class WlyySignFamilyController extends EnvelopRestController {
        List<WlyySignFamily> list = wlyySignFamilyService.search(fields,filters,sorts);
        //封装返回格式
        List<WlyySignFamily> wlyySignFamily = convertToModels(list, new ArrayList<>(list.size()), WlyySignFamily.class, fields);
        return Envelop.getSuccessList(WlyyContants.SignFamily.message_success_find_functions,wlyySignFamily);
        return Envelop.getSuccessList(WlyyAgreementContants.SignFamily.message_success_find_functions,wlyySignFamily);
    }
}

+ 133 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/controller/patient/AdvertisementControlelr.java

@ -0,0 +1,133 @@
package com.yihu.jw.wlyy.controller.patient;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.patient.WlyyPatientContants;
import com.yihu.jw.wlyy.entity.patient.WlyyAdvertisement;
import com.yihu.jw.wlyy.service.patient.AdvertisementService;
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.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public class AdvertisementControlelr extends EnvelopRestController {
    @Autowired
    private AdvertisementService advertisementService;
    @PostMapping(value = WlyyPatientContants.Advertisement.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建广告", notes = "创建广告")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAdvertisement advertisement = toEntity(jsonData, WlyyAdvertisement.class);
            return Envelop.getSuccess(WlyyPatientContants.Advertisement.message_success_create, advertisementService.create(advertisement));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WlyyPatientContants.Advertisement.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改广告", notes = "修改广告")
    public Envelop update(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAdvertisement advertisement = toEntity(jsonData, WlyyAdvertisement.class);
            return Envelop.getSuccess(WlyyPatientContants.Advertisement.message_success_update, advertisementService.update(advertisement));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = WlyyPatientContants.Advertisement.api_delete)
    @ApiOperation(value = "删除广告", notes = "删除广告")
    public Envelop delete(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            advertisementService.delete(code);
            return Envelop.getSuccess(WlyyPatientContants.Advertisement.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = WlyyPatientContants.Advertisement.api_getByCode)
    @ApiOperation(value = "根据code查找协议", notes = "根据code查找协议")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(WlyyPatientContants.Advertisement.message_success_find, advertisementService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = WlyyPatientContants.Advertisement.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取协议")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,parentCode,saasId,name,price,posterPic,remark,type,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<WlyyAdvertisement> list = advertisementService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=advertisementService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<WlyyAdvertisement> advertisement = convertToModels(list, new ArrayList<>(list.size()), WlyyAdvertisement.class, fields);
        return Envelop.getSuccessListWithPage(WlyyPatientContants.Advertisement.message_success_find_functions, advertisement, page, size, count);
    }
    @GetMapping(value = WlyyPatientContants.Advertisement.api_getList)
    @ApiOperation(value = "获取协议列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,parentCode,saasId,name,price,posterPic,remark,type,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<WlyyAdvertisement> list = advertisementService.search(fields,filters,sorts);
        //封装返回格式
        List<WlyyAdvertisement> advertisement = convertToModels(list, new ArrayList<>(list.size()), WlyyAdvertisement.class, fields);
        return Envelop.getSuccessList(WlyyPatientContants.Advertisement.message_success_find_functions,advertisement);
    }
    @GetMapping(value = WlyyPatientContants.Advertisement.api_getListByPatientCode)
    @ApiOperation(value = "根据患者code获取广告")
    public Envelop getListByPatientCode(
            @ApiParam(name="patientCode")
            @RequestParam(value="") String patientCode){
        List<WlyyAdvertisement> advertisements = advertisementService.getListByPatientCode(patientCode);
        return Envelop.getSuccessList(WlyyPatientContants.Advertisement.message_success_find_functions,advertisements);
    }
}

+ 2 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/dao/WlyyAgreementDao.java

@ -1,6 +1,6 @@
package com.yihu.jw.wlyy.agreement.dao;
package com.yihu.jw.wlyy.dao.agreement;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreement;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreement;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

+ 2 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/dao/WlyyAgreementKpiDao.java

@ -1,6 +1,6 @@
package com.yihu.jw.wlyy.agreement.dao;
package com.yihu.jw.wlyy.dao.agreement;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreementKpi;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreementKpi;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

+ 2 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/dao/WlyyAgreementKpiLogDao.java

@ -1,6 +1,6 @@
package com.yihu.jw.wlyy.agreement.dao;
package com.yihu.jw.wlyy.dao.agreement;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreementKpiLog;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreementKpiLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

+ 7 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/dao/WlyySignFamilyDao.java

@ -1,10 +1,12 @@
package com.yihu.jw.wlyy.agreement.dao;
package com.yihu.jw.wlyy.dao.agreement;
import com.yihu.jw.wlyy.agreement.entity.WlyySignFamily;
import com.yihu.jw.wlyy.entity.agreement.WlyySignFamily;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/6/2 0002.
 */
@ -12,4 +14,7 @@ public interface WlyySignFamilyDao  extends PagingAndSortingRepository<WlyySignF
    @Query("from WlyySignFamily w where w.code = ?1")
    WlyySignFamily findByCode(String code);
    @Query("from WlyySignFamily w where w.patientCode = ?1 and w.status = ?2")
    List<WlyySignFamily> findByPatientCode(String patientCode, Integer status);
}

+ 23 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/patient/AdvertisementDao.java

@ -0,0 +1,23 @@
package com.yihu.jw.wlyy.dao.patient;
import com.yihu.jw.wlyy.entity.patient.WlyyAdvertisement;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public interface AdvertisementDao extends PagingAndSortingRepository<WlyyAdvertisement, Long>, JpaSpecificationExecutor<WlyyAdvertisement> {
    @Query("from WlyyAdvertisement w where w.code =?1 and w.status!=-1")
    WlyyAdvertisement findByCode(String code);
    @Query("from WlyyAdvertisement w where w.id=?1 and w.status !=-1")
    WlyyAdvertisement findById(Long id);
    @Query("from WlyyAdvertisement w where w.code=?1 and w.status !=-1")
    List<WlyyAdvertisement> getListBySaasCode(String saasCode);
}

+ 19 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/patient/BasePatientDao.java

@ -0,0 +1,19 @@
package com.yihu.jw.wlyy.dao.patient;
import com.yihu.jw.wlyy.entity.patient.BasePatient;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public interface BasePatientDao extends PagingAndSortingRepository<BasePatient, Long>, JpaSpecificationExecutor<BasePatient> {
    @Query("from BasePatient w where w.code =?1")
    BasePatient findByCode(String code);
    @Query("from BasePatient w where w.id=?1 ")
    BasePatient findById(Long id);
}

+ 1 - 1
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/common/entity/base/IdEntity.java

@ -3,7 +3,7 @@
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.wlyy.common.entity.base;
package com.yihu.jw.wlyy.entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

+ 2 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyyAgreement.java

@ -1,8 +1,8 @@
package com.yihu.jw.wlyy.agreement.entity;
package com.yihu.jw.wlyy.entity.agreement;
import com.yihu.jw.wlyy.common.entity.base.IdEntity;
import com.yihu.jw.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 2 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyyAgreementKpi.java

@ -1,8 +1,8 @@
package com.yihu.jw.wlyy.agreement.entity;
package com.yihu.jw.wlyy.entity.agreement;
import com.yihu.jw.wlyy.common.entity.base.IdEntity;
import com.yihu.jw.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 2 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyyAgreementKpiLog.java

@ -1,7 +1,7 @@
package com.yihu.jw.wlyy.agreement.entity;
package com.yihu.jw.wlyy.entity.agreement;
import com.yihu.jw.wlyy.common.entity.base.IdEntity;
import com.yihu.jw.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 2 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyySignFamily.java

@ -1,6 +1,6 @@
package com.yihu.jw.wlyy.agreement.entity;
package com.yihu.jw.wlyy.entity.agreement;
import com.yihu.jw.wlyy.common.entity.base.IdEntity;
import com.yihu.jw.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 173 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/patient/WlyyAdvertisement.java

@ -0,0 +1,173 @@
package com.yihu.jw.wlyy.entity.patient;
import com.yihu.jw.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
@Entity
@Table(name = "wlyy_advertisement")
public class WlyyAdvertisement extends IdEntity implements Serializable {
    private static final long serialVersionUID = 1497635003375865515L;
    private String code;//业务code
    private String saasId;
    private String name;//名称
    private String picture;//展示的图片
    private String url;//链接
    private Integer sort;//排序( 数字越小排越前面)
    private String status;//状态 -1 删除 0 禁用 1可用
    private String createUser;//创建人
    private String createUserName;////创建人名
    private Date createTime;//创建时间
    private String updateUser;//修改人
    private String updateUserName;//修改人名
    private Date updateTime;//修改时间
    private String remark;//备注
    
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
    @Column(name = "picture")
    public String getPicture() {
        return picture;
    }
    public void setPicture(String picture) {
        this.picture = picture;
    }
    
    @Column(name = "url")
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    
    @Column(name = "sort")
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    
    @Column(name = "update_user")
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    
    @Column(name = "update_user_name")
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    
    @Column(name = "update_time")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 10 - 10
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyyAgreementKpiLogService.java

@ -1,11 +1,11 @@
package com.yihu.jw.wlyy.agreement.service;
package com.yihu.jw.wlyy.service.agreement;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.agreement.dao.WlyyAgreementKpiLogDao;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreementKpiLog;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.wlyy.dao.agreement.WlyyAgreementKpiLogDao;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreementKpiLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@ -25,22 +25,22 @@ public class WlyyAgreementKpiLogService extends BaseJpaService<WlyyAgreementKpiL
    @Transient
    public WlyyAgreementKpiLog create(WlyyAgreementKpiLog wlyyAgreementKpiLog) {
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getPatientCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_patientCode_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_patientCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getSignCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_signCode_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_signCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getKpiCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiCode_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_kpiCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getAgreementCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getKpiName())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        //设置创建时间
        Date date = new Date();

+ 21 - 21
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyyAgreementKpiService.java

@ -1,12 +1,12 @@
package com.yihu.jw.wlyy.agreement.service;
package com.yihu.jw.wlyy.service.agreement;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.agreement.dao.WlyyAgreementKpiDao;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreement;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreementKpi;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.wlyy.dao.agreement.WlyyAgreementKpiDao;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreement;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreementKpi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@ -29,25 +29,25 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
    @Transient
    public WlyyAgreementKpi create(WlyyAgreementKpi wlyyAgreementKpi) {
        if (StringUtils.isEmpty(wlyyAgreementKpi.getCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        //判断agreement是否存在
        String agreementCode = wlyyAgreementKpi.getAgreementCode();
        if (StringUtils.isEmpty(agreementCode)) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
        }
        WlyyAgreement agreement = wlyyAgreementService.findByCode(agreementCode);
        if(agreement == null){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreement_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_agreement_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getType())){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_type_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getStatus())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
@ -60,33 +60,33 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
    public WlyyAgreementKpi update(WlyyAgreementKpi wlyyAgreementKpi) {
        String code = wlyyAgreementKpi.getCode();
        if (StringUtils.isEmpty(code)) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        //判断agreement是否存在
        String agreementCode = wlyyAgreementKpi.getAgreementCode();
        if (StringUtils.isEmpty(agreementCode)) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
        }
        WlyyAgreement agreement = wlyyAgreementService.findByCode(agreementCode);
        if(agreement == null){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreement_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_agreement_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getType())){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_type_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getStatus())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        Long id = wlyyAgreementKpi.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WlyyContants.Agreement.message_fail_id_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        WlyyAgreementKpi wlyyAgreementKpi1 = wlyyAgreementKpiDao.findById(id);
        if(wlyyAgreementKpi1==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
@ -95,7 +95,7 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
        wlyyAgreementKpi1 = wlyyAgreementKpiDao.findCodeExcludeId(code,id);
        if(wlyyAgreementKpi1 !=null){
            throw new ApiException(WlyyContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
        }
        return wlyyAgreementKpiDao.save(wlyyAgreementKpi);
    }
@ -108,7 +108,7 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
    public void delete(String code) {
        WlyyAgreementKpi wlyyAgreementKpi = findByCode(code);
        if(wlyyAgreementKpi==null){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_wlyyAgreementKpi_is_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.AgreementKpi.message_fail_wlyyAgreementKpi_is_no_exist, CommonContants.common_error_params_code);
        }
        wlyyAgreementKpi.setStatus(-1);
        wlyyAgreementKpiDao.save(wlyyAgreementKpi);

+ 16 - 16
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyyAgreementService.java

@ -1,11 +1,11 @@
package com.yihu.jw.wlyy.agreement.service;
package com.yihu.jw.wlyy.service.agreement;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.agreement.dao.WlyyAgreementDao;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreement;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.wlyy.dao.agreement.WlyyAgreementDao;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@ -25,16 +25,16 @@ public class WlyyAgreementService extends BaseJpaService<WlyyAgreement, WlyyAgre
    @Transient
    public WlyyAgreement create(WlyyAgreement wlyyAgreement) {
        if (StringUtils.isEmpty(wlyyAgreement.getCode())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getName())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_name_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getPrice())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_price_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_price_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getStatus())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
@ -47,24 +47,24 @@ public class WlyyAgreementService extends BaseJpaService<WlyyAgreement, WlyyAgre
    public WlyyAgreement update(WlyyAgreement wlyyAgreement) {
        String code = wlyyAgreement.getCode();
        if (StringUtils.isEmpty(code)) {
            throw new ApiException(WlyyContants.Agreement.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getName())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_name_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getPrice())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_price_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_price_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getStatus())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        Long id = wlyyAgreement.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WlyyContants.Agreement.message_fail_id_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        WlyyAgreement wlyyAgreement1 = wlyyAgreementDao.findById(id);
        if(wlyyAgreement1==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
@ -73,7 +73,7 @@ public class WlyyAgreementService extends BaseJpaService<WlyyAgreement, WlyyAgre
        wlyyAgreement1 = wlyyAgreementDao.findCodeExcludeId(code,id);
        if(wlyyAgreement1 !=null){
            throw new ApiException(WlyyContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
        }
        return wlyyAgreementDao.save(wlyyAgreement);
    }
@ -87,7 +87,7 @@ public class WlyyAgreementService extends BaseJpaService<WlyyAgreement, WlyyAgre
    public void delete(String code) {
        WlyyAgreement wlyyAgreement = findByCode(code);
        if(wlyyAgreement==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
        wlyyAgreement.setStatus("-1");
        wlyyAgreementDao.save(wlyyAgreement);

+ 28 - 17
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyySignFamilyService.java

@ -1,19 +1,20 @@
package com.yihu.jw.wlyy.agreement.service;
package com.yihu.jw.wlyy.service.agreement;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.util.IDCard;
import com.yihu.jw.wlyy.agreement.dao.WlyySignFamilyDao;
import com.yihu.jw.wlyy.agreement.entity.WlyyAgreement;
import com.yihu.jw.wlyy.agreement.entity.WlyySignFamily;
import com.yihu.jw.wlyy.dao.agreement.WlyySignFamilyDao;
import com.yihu.jw.wlyy.entity.agreement.WlyyAgreement;
import com.yihu.jw.wlyy.entity.agreement.WlyySignFamily;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import java.text.ParseException;
import java.util.List;
/**
 * Created by Administrator on 2017/6/2 0002.
@ -51,49 +52,59 @@ public class WlyySignFamilyService extends BaseJpaService<WlyySignFamily, WlyySi
    private boolean canSaveOrUpdate(WlyySignFamily wlyySignFamily) throws ParseException {
        if (StringUtils.isEmpty(wlyySignFamily.getCode())) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getType())) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_type_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getName())) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_name_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        String idcard = wlyySignFamily.getIdcard();
        if (StringUtils.isEmpty(idcard)) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_idCard_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_idCard_is_null, CommonContants.common_error_params_code);
        }
        String s = new IDCard().IDCardValidate(idcard);//不为空字符串,说明身份证有问题啦
        if(!StringUtils.isEmpty(s)){
            throw new ApiException(s, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getSsc())) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_ssc_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_ssc_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getHospital())) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_hospital_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_hospital_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getHospitalName())) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_hospitalName_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_hospitalName_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getStatus())) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getExpenses())) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_expense_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_expense_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getExpensesStatus())) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_expenseStatus_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_expenseStatus_is_null, CommonContants.common_error_params_code);
        }
        String agreementCode = wlyySignFamily.getAgreementCode();
        if (StringUtils.isEmpty(agreementCode)) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.SignFamily.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
        }
        //根据agreementCode查找协议是否存在
        WlyyAgreement agreement = wlyyAgreementService.findByCode(agreementCode);
        if(agreement==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyAgreementContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
        return true;
    }
    /**
     * 根据患者code和签约状态查找签约
     * @param patientCode
     * @param status
     * @return
     */
    public List<WlyySignFamily> findByPatientCode(String patientCode,Integer status) {
        return wlyySignFamilyDao.findByPatientCode(patientCode,status);
    }
}

+ 150 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/patient/AdvertisementService.java

@ -0,0 +1,150 @@
package com.yihu.jw.wlyy.service.patient;
import com.yihu.jw.base.model.Saas;
import com.yihu.jw.base.service.SaasService;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.patient.WlyyPatientContants;
import com.yihu.jw.wlyy.dao.patient.AdvertisementDao;
import com.yihu.jw.wlyy.entity.agreement.WlyySignFamily;
import com.yihu.jw.wlyy.entity.patient.BasePatient;
import com.yihu.jw.wlyy.entity.patient.WlyyAdvertisement;
import com.yihu.jw.wlyy.service.agreement.WlyySignFamilyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public class AdvertisementService extends BaseJpaService<WlyyAdvertisement, AdvertisementDao> {
    @Autowired
    private AdvertisementDao advertisementDao;
    @Autowired
    private PatientService patientService;
    @Autowired
    private WlyySignFamilyService signFamilyService;
    @Autowired
    private SaasService saasService;
    @Transient
     public WlyyAdvertisement create(WlyyAdvertisement advertisement) {
        if (StringUtils.isEmpty(advertisement.getCode())) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(advertisement.getSaasId())) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_saasid_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(advertisement.getName())) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(advertisement.getPicture())) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_picture_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(advertisement.getStatus())) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
        advertisement.setCreateTime(date);
        advertisement.setUpdateTime(date);
        return advertisementDao.save(advertisement);
    }
    @Transient
    public WlyyAdvertisement update(WlyyAdvertisement advertisement) {
        String code = advertisement.getCode();
        if (StringUtils.isEmpty(code)) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(advertisement.getSaasId())) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_saasid_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(advertisement.getName())) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(advertisement.getPicture())) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_picture_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(advertisement.getStatus())) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        Long id = advertisement.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_picture_is_null, CommonContants.common_error_params_code);
        }
        //根据id获取修改前的记录
        WlyyAdvertisement advertisement1 = findById(id);
        if(null == advertisement1){
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_wlyyAdvertisement_is_not_exist, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
        advertisement.setCreateTime(advertisement1.getCreateTime());
        advertisement.setUpdateTime(date);
        return advertisementDao.save(advertisement);
    }
    public WlyyAdvertisement findById(Long id) {
        return advertisementDao.findById(id);
    }
    public WlyyAdvertisement findByCode(String code) {
        return advertisementDao.findByCode(code);
    }
    @Transient
    public void delete(String code) {
        WlyyAdvertisement advertisement = findByCode(code);
        if(advertisement==null){
            throw new ApiException(WlyyPatientContants.Advertisement.message_fail_wlyyAdvertisement_is_not_exist, CommonContants.common_error_params_code);
        }
        advertisement.setStatus("-1");
        advertisementDao.save(advertisement);
    }
    public List<WlyyAdvertisement> getListByPatientCode(String patientCode) {
        List<WlyyAdvertisement> advertisements = null;
        //查找已签约的
        List<WlyySignFamily> signs =  signFamilyService.findByPatientCode(patientCode,1);
        if(signs!=null){
            for(WlyySignFamily sign:signs){
                String hospital = sign.getHospital();
                //通过hospital查找市区
            }
        }
        //如果还是空的,则查询患者的地址,根据患者的地址显示广告
        if(advertisements==null){
            BasePatient patient = patientService.findByCode(patientCode);
            if(patient==null){
                return null;
            }else{
                String cityName = patient.getCityName();
                //根据cityName查找saas
                Saas saas = saasService.findByName(cityName);
                if(saas==null){
                    return null;
                }else{
                    String saasCode = saas.getCode();
                    //通过saasCode查找广告
                    return getListBySaasCode(saasCode);
                }
            }
        }
        return null;
    }
    public List<WlyyAdvertisement> getListBySaasCode(String saasCode){
        return advertisementDao.getListBySaasCode(saasCode);
    }
}

+ 20 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/patient/PatientService.java

@ -0,0 +1,20 @@
package com.yihu.jw.wlyy.service.patient;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.wlyy.dao.patient.BasePatientDao;
import com.yihu.jw.wlyy.entity.patient.BasePatient;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public class PatientService  extends BaseJpaService<BasePatient, BasePatientDao> {
    @Autowired
    private BasePatientDao basePatientDao;
    public BasePatient findByCode(String code){
        return basePatientDao.findByCode(code);
    }
}

+ 17 - 0
web-gateway/src/main/java/com/yihu/jw/commnon/wlyy/PatientContants.java

@ -0,0 +1,17 @@
package com.yihu.jw.commnon.wlyy;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public class PatientContants {
    public static class Advertisement{
        public static final String api_common="advertisement";
        public static final String api_create="create";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_update="update";
        public static final String api_queryPage="queryPage";
        public static final String api_getList="getList";
        public static final String api_getListByPatientCode="getListByPatientCode";
    }
}

+ 103 - 0
web-gateway/src/main/java/com/yihu/jw/controller/wlyy/patient/AdvertisementControlelr.java

@ -0,0 +1,103 @@
package com.yihu.jw.controller.wlyy.patient;
import com.yihu.jw.commnon.wlyy.PatientContants;
import com.yihu.jw.fegin.wlyy.patient.AdvertisementFegin;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
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.cloud.sleuth.Tracer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public class AdvertisementControlelr extends EnvelopRestController {
    private Logger logger = LoggerFactory.getLogger(AdvertisementControlelr.class);
    @Autowired
    private AdvertisementFegin advertisementFegin;
    @Autowired
    private Tracer tracer;
    @PostMapping(value = PatientContants.Advertisement.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建广告", notes = "创建广告")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return advertisementFegin.create(jsonData);
    }
    @PutMapping(value = PatientContants.Advertisement.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改广告", notes = "修改广告")
    public Envelop update(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return advertisementFegin.update(jsonData);
    }
    @DeleteMapping(value =PatientContants.Advertisement.api_delete)
    @ApiOperation(value = "删除广告", notes = "删除广告")
    public Envelop delete(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        return advertisementFegin.delete(code);
    }
    @GetMapping(value =PatientContants.Advertisement.api_getByCode)
    @ApiOperation(value = "根据code查找协议", notes = "根据code查找协议")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        return advertisementFegin.findByCode(code);
    }
    @RequestMapping(value =PatientContants.Advertisement.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取协议")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,parentCode,saasId,name,price,posterPic,remark,type,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        return advertisementFegin.queryPage(fields,filters,sorts,size,page);
    }
    @GetMapping(value =PatientContants.Advertisement.api_getList)
    @ApiOperation(value = "获取协议列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,parentCode,saasId,name,price,posterPic,remark,type,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        return advertisementFegin.getList(fields, filters, sorts);
    }
    @GetMapping(value =PatientContants.Advertisement.api_getListByPatientCode)
    @ApiOperation(value = "根据患者code获取广告")
    public Envelop getListByPatientCode(
            @ApiParam(name="patientCode")
            @RequestParam(value="") String patientCode){
        return advertisementFegin.getListByPatientCode(patientCode);
    }
}

+ 50 - 0
web-gateway/src/main/java/com/yihu/jw/fegin/wlyy/patient/AdvertisementFegin.java

@ -0,0 +1,50 @@
package com.yihu.jw.fegin.wlyy.patient;
import com.yihu.jw.fegin.fallbackfactory.wlyy.patient.AdvertisementFeginFallbackFactory;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.restmodel.wlyy.patient.WlyyPatientContants;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
@FeignClient(
        name = CommonContants.svr_wlyy // name值是eurika的实例名字
        ,fallbackFactory  = AdvertisementFeginFallbackFactory.class
)
@RequestMapping(WlyyAgreementContants.Agreement.api_common)
public interface AdvertisementFegin {
    @PostMapping(value = WlyyPatientContants.Advertisement.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Envelop create(@RequestBody String jsonData);
    @PutMapping(value = WlyyPatientContants.Advertisement.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Envelop update(@RequestBody String jsonData);
    @DeleteMapping(value = WlyyPatientContants.Advertisement.api_delete)
    Envelop delete( @RequestParam(value = "code") String code);
    @RequestMapping(value= WlyyPatientContants.Advertisement.api_getByCode,method = RequestMethod.GET)
    Envelop findByCode( @RequestParam(value = "code" ) String code);
    @RequestMapping(value = WlyyPatientContants.Advertisement.api_queryPage, method = RequestMethod.GET)
    Envelop queryPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
    @GetMapping(value = WlyyPatientContants.Advertisement.api_getList)
    Envelop getList(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts);
    @GetMapping(value= WlyyPatientContants.Advertisement.api_getListByPatientCode)
    Envelop getListByPatientCode(String patientCode);
}