浏览代码

Merge branch 'medicare' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into medicare

wangzhinan 3 年之前
父节点
当前提交
ad89412763

+ 22 - 1
common/common-entity/sql记录

@ -1600,4 +1600,25 @@ CREATE TABLE wlyy_patient_safe_area_confirm (
  `manage_status` tinyint(2) DEFAULT '0' COMMENT '电子围栏确认情况 0待确认 1已确认',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='患者电子围栏新增记录';
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='患者电子围栏新增记录';
-- 2022-05-26
ALTER table base_ylz_medical_mx add column setl_msgid VARCHAR(255) default null COMMENT'发送方报文ID【用于门诊结算接口,自助机fsi.terminal.charge接口】';
ALTER table base_ylz_medical_mx add column fee_msgid VARCHAR(255) default null COMMENT'发送方报文ID【用于门诊费用明细上传接口】';
ALTER table base_ylz_medical_mx add column chrg_bchno VARCHAR(255) default null COMMENT'收费批次号';
ALTER table base_ylz_medical_mx add column insur_settle_sort VARCHAR(255) default null COMMENT'医保结算序号';
ALTER table base_ylz_medical_mx add column med_type VARCHAR(255) default null COMMENT'医保结算序号';
ALTER table base_ylz_medical_icd add column dise_msgid VARCHAR(255) default null COMMENT'发送方报文ID【用于门诊就诊信息上传接口】';
ALTER table base_ylz_medical_relation add column med_type VARCHAR(50) default null COMMENT'医疗类别';
-- 2022-06-01
CREATE TABLE `t_mediicine_device_param` (
  `id` varchar(50) NOT NULL,
  `device_id` varchar(50) DEFAULT NULL COMMENT '设备id,关联t_mediicine_device表',
  `del` int(11) DEFAULT '1' COMMENT '删除',
  `device_ip` varchar(20) DEFAULT NULL COMMENT '设备ip地址',
  `yb_strin` varchar(500) DEFAULT NULL COMMENT '医保固定参数值',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='药柜接口参数配置';

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalIcdDO.java

@ -22,6 +22,9 @@ public class YlzMedicalIcdDO extends UuidIdentityEntity {
    private Integer del;
    private Date createTime;
    //自助机字段
    private String diseMsgid; //发送方报文ID【用于门诊就诊信息上传接口】
    public String getMedicalId() {
        return medicalId;
    }
@ -79,4 +82,12 @@ public class YlzMedicalIcdDO extends UuidIdentityEntity {
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getDiseMsgid() {
        return diseMsgid;
    }
    public void setDiseMsgid(String diseMsgid) {
        this.diseMsgid = diseMsgid;
    }
}

+ 47 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalMxDO.java

@ -46,6 +46,13 @@ public class YlzMedicalMxDO extends UuidIdentityEntity {
    private Integer del;
    private Date createTime;
    //自助机字段
    private String setlMsgid;//发送方报文ID【用于门诊结算接口,自助机fsi.terminal.charge接口】
    private String feeMsgid;//发送方报文ID【用于门诊费用明细上传接口】
    private String chrgBchno;//收费批次号
    private String insurSettleSort;//医保结算序号
    private String medType;//医保结算序号
    public String getMedicalId() {
        return medicalId;
    }
@ -301,4 +308,44 @@ public class YlzMedicalMxDO extends UuidIdentityEntity {
    public void setPeopleType(String peopleType) {
        this.peopleType = peopleType;
    }
    public String getSetlMsgid() {
        return setlMsgid;
    }
    public void setSetlMsgid(String setlMsgid) {
        this.setlMsgid = setlMsgid;
    }
    public String getFeeMsgid() {
        return feeMsgid;
    }
    public void setFeeMsgid(String feeMsgid) {
        this.feeMsgid = feeMsgid;
    }
    public String getChrgBchno() {
        return chrgBchno;
    }
    public void setChrgBchno(String chrgBchno) {
        this.chrgBchno = chrgBchno;
    }
    public String getInsurSettleSort() {
        return insurSettleSort;
    }
    public void setInsurSettleSort(String insurSettleSort) {
        this.insurSettleSort = insurSettleSort;
    }
    public String getMedType() {
        return medType;
    }
    public void setMedType(String medType) {
        this.medType = medType;
    }
}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationDO.java

@ -92,6 +92,9 @@ public class YlzMedicalRelationDO extends UuidIdentityEntity {
    private String medicalPrice;//医保基金总额
    private Date settleDate;//his结算时间
    //自助机字段
    private String medType; //医疗类别
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name="settle_date")
    public Date getSettleDate() {
@ -729,4 +732,12 @@ public class YlzMedicalRelationDO extends UuidIdentityEntity {
    public void setCollector(String collector) {
        this.collector = collector;
    }
    public String getMedType() {
        return medType;
    }
    public void setMedType(String medType) {
        this.medType = medType;
    }
}

+ 88 - 5
gateway/ag-basic/pom.xml

@ -137,20 +137,103 @@
        </dependency>
    </dependencies>
<!--    <build>-->
<!--        <finalName>ag-basic</finalName>-->
<!--        <plugins>-->
<!--            <plugin>-->
<!--                <groupId>org.springframework.boot</groupId>-->
<!--                <artifactId>spring-boot-maven-plugin</artifactId>-->
<!--            </plugin>-->
<!--            <plugin>-->
<!--                <artifactId>maven-war-plugin</artifactId>-->
<!--                <configuration>-->
<!--                    <failOnMissingWebXml>false</failOnMissingWebXml>-->
<!--                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>-->
<!--                </configuration>-->
<!--            </plugin>-->
<!--        </plugins>-->
<!--    </build>-->
    <build>
        <finalName>ag-basic</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 -->
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <!-- 是否要把第三方jar加入到类构建路径 -->
                            <addClasspath>true</addClasspath>
                            <!-- 外部依赖jar包的最终位置 -->
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.yihu.AgBasicServer</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!--拷贝依赖到jar外面的lib目录-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-lib</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <!-- 依赖包输出目录,将来不打进jar包里 -->
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <excludeTransitive>false</excludeTransitive>
                            <stripVersion>false</stripVersion>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--指定配置文件,将resources打成外部resource-->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                    <archive>
                        <!-- 指定配置文件目录,这样jar运行时会去找到同目录下的resources文件夹下查找 -->
                        <manifestEntries>
                            <Class-Path>resources/</Class-Path>
                        </manifestEntries>
                    </archive>
                    <!-- 打包时忽略的文件(也就是不打进jar包里的文件) -->
                    <excludes>
                        <exclude>**/*.yml</exclude>
                        <exclude>**/*.xml</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <!-- 拷贝资源文件 外面的resource目录-->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <!-- 资源文件输出目录 -->
                            <outputDirectory>${project.build.directory}/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

+ 20 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/user/RoleDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.security.dao.user;
import com.yihu.jw.entity.base.role.RoleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Dao - 角色
 * Created by progr1mmer on 2018/8/17.
 */
public interface RoleDao extends PagingAndSortingRepository<RoleDO, String>, JpaSpecificationExecutor<RoleDO> {
    RoleDO findByCode(String code);
    List<RoleDO> findByNameAndStatus(String name, Integer status);
    List<RoleDO> findByNameAndSaasIdAndStatus(String name, String saasId, Integer status);
}

+ 19 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/user/WlyyUserAreaDao.java

@ -0,0 +1,19 @@
package com.yihu.jw.security.dao.user;
import com.yihu.jw.entity.equipment.WlyyUserAreaDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface WlyyUserAreaDao extends PagingAndSortingRepository<WlyyUserAreaDO, String>, JpaSpecificationExecutor<WlyyUserAreaDO> {
    @Query("select id from WlyyUserAreaDO where userId = ?1 ")
    List<WlyyUserAreaDO> findAllByUserId(String userId);
    @Modifying
    @Query("delete from WlyyUserAreaDO p where p.userId=?1 ")
    void deleteByUserId(String userId);
}

+ 19 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/user/WlyyUserEquipmentDao.java

@ -0,0 +1,19 @@
package com.yihu.jw.security.dao.user;
import com.yihu.jw.entity.equipment.WlyyUserEquipmentDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface WlyyUserEquipmentDao extends PagingAndSortingRepository<WlyyUserEquipmentDO, String>, JpaSpecificationExecutor<WlyyUserEquipmentDO> {
    @Modifying
    @Query("delete from WlyyUserEquipmentDO p where p.userId=?1 and del=1 ")
    void deleteByUserId(String userId);
    @Query("select id from WlyyUserEquipmentDO where userId = ?1 and del=1 ")
    List<WlyyUserEquipmentDO> findAllByUserId(String userId);
}

+ 74 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -1876,6 +1876,80 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
        return ObjEnvelop.getError("登录失败!");
    }*/
    /**
     * I健康医生端授权登录
     * @param code 医生code
     * @param client_id
     * @param login_type 3
     * @param httpSession
     * @return
     */
    @RequestMapping(value = "/oauth/checkWlyyUserLogin", method = RequestMethod.POST)
    public ObjEnvelop checkQRUserCodeLogin(String code,String client_id,String login_type,HttpSession httpSession){
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
        }
        if (StringUtils.isEmpty(code)) {
            throw new InvalidRequestException("doctor is null");
        }
        logger.info("origin doctorCode :"+code);
        KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
        String doctorCode = com.yihu.jw.security.utils.RSAUtils.decryptBase64(code, keyPair);
        logger.info("after doctorCode :"+doctorCode);
        JSONObject map = null;
        try{
            map= oauthWlyyConfigService.checkWlyyUserDoctor(doctorCode);
        }catch (Exception e){
            logger.error(e);
            return ObjEnvelop.getError("授权失败");
        }
        String authCode = map.getString("authCode");
        if(!"1".equals(authCode)){
            map.remove("doctor");
            return ObjEnvelop.getError("授权失败");
        }
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        JSONObject doctor = map.getJSONObject("doctor");
        Map<String, String> parameters = new HashedMap();
        parameters.put("login_type","2");
        parameters.put("username",doctor.getString("idcard"));
        parameters.put("grant_type", "ihealthCode");
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        if (authenticatedClient != null) {
            oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        }
        OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());
        wlyyUserSimple.setExpiresIn(token.getExpiresIn());
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        String loginType = parameters.get("login_type");
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
        baseLoginLogDO.setUserId(wlyyUserSimple.getId());
        baseLoginLogDO.setCreateTime(new Date());
        String userAgent = JSONObject.toJSONString(wlyyUserSimple);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogService.save(baseLoginLogDO);
        map.put("WlyyUserSimple",wlyyUserSimple);
        map.remove("doctor");
        return ObjEnvelop.getSuccess("success",map);
    }
    @RequestMapping(value = "/oauth/registerPatientAndLogin", method = RequestMethod.POST)
    public ObjEnvelop registerPatientAndLogin(String name, String mobile, String idcard, String ssc, String pw,String client_id,String login_type,String captcha,String openid,String wxId
    ,String geetestChallenge,String geetestValidate,String geetestSeccode )throws Exception{

+ 149 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthWlyyConfigService.java

@ -4,6 +4,10 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.equipment.WlyyUserAreaDO;
import com.yihu.jw.entity.equipment.WlyyUserEquipmentDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.wlyyinfo.OauthWlyyConfigDO;
import com.yihu.jw.security.dao.OauthWlyyConfigDao;
@ -11,6 +15,10 @@ import com.yihu.jw.security.dao.doctor.BaseDoctorDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorHospitalDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorRoleDao;
import com.yihu.jw.security.dao.doctor.DoctorMappingDao;
import com.yihu.jw.security.dao.iot.UserDao;
import com.yihu.jw.security.dao.user.RoleDao;
import com.yihu.jw.security.dao.user.WlyyUserAreaDao;
import com.yihu.jw.security.dao.user.WlyyUserEquipmentDao;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.utils.security.MD5;
import org.apache.commons.collections.map.HashedMap;
@ -49,6 +57,14 @@ public class OauthWlyyConfigService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private UserDao userDao;
    @Autowired
    private WlyyUserAreaDao userAreaDao;
    @Autowired
    private WlyyUserEquipmentDao userEquipmentDao;
    @Autowired
    private RoleDao roleDao;
    public JSONObject checkWlyyDoctor(String code)throws Exception{
@ -221,6 +237,139 @@ public class OauthWlyyConfigService {
    }
    public JSONObject checkWlyyUserDoctor(String doctor)throws Exception{
        OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("wlyyConfig");
        //token获取accesstoken
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("appid", oauthWlyyConfigDO.getAppId()));
        params.add(new BasicNameValuePair("appSecret",oauthWlyyConfigDO.getAppSecret()));
        String res = httpClientUtil.post(oauthWlyyConfigDO.getTokenUrl(),params,"UTF-8");
        String token = null;
        JSONObject rsjson = JSONObject.parseObject(res);
        logger.info("checkWlyyDoctor token :"+rsjson.toString());
        Integer status = rsjson.getInteger("status");
        if(status==10000){
            //设置入参
            List<NameValuePair> p = new ArrayList<>();
            p.add(new BasicNameValuePair("doctor", doctor));
            //设置头部
            token = rsjson.getJSONObject("result").getString("accesstoken");
            Map<String,Object> headerMap = new HashedMap();
            headerMap.put("accesstoken",token);
            String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
            logger.info("checkWlyyDoctor doctorInfo :"+rs);
            JSONObject auth = JSONObject.parseObject(rs);
            Integer s = auth.getInteger("status");
            if(s == 200){
                JSONObject data = auth.getJSONObject("data");
                String authCode =  data.getString("authCode");
                if("1".equals(authCode)){
                    JSONObject doctorJson = data.getJSONObject("doctor");
                    String idcard = doctorJson.getString("idcard");
                    String mobile = doctorJson.getString("mobile");
                    if(StringUtils.isBlank(idcard)){
                        data.put("authCode","-3");
                        data.put("mes","I健康账户信息不完整,授权失败");
                        return data;
                    }
                    UserDO userDO = userDao.findByMobile(mobile);
                    if(userDO!=null){
                        return data;
                    }else{
                        //存储医生全科医生信息
                        userDO = new UserDO();
                        userDO.setSaasId("808080eb7bc87123017bf16ba0ad0046");
                        userDO.setName(doctorJson.getString("name"));
                        userDO.setIdcard(doctorJson.getString("idcard"));
                        userDO.setUsername(doctorJson.getString("mobile"));
                        userDO.setMobile(doctorJson.getString("mobile"));
                        if (doctorJson.getInteger("sex")==1){
                            userDO.setGender(UserDO.Gender.male);
                        }else if (doctorJson.getInteger("sex")==2){
                            userDO.setGender(UserDO.Gender.female);
                        }
                        //认证信息设置
                        String salt = randomString(5);
                        String pw = idcard.substring(idcard.length()-6);
                        userDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                        userDO.setSalt(salt);
                        userDO.setEnabled(1);
                        userDO.setLocked(0);
                        userDO.setCreateTime(new Date());
                        userDO.setUpdateTime(new Date());
                        userDO = userDao.save(userDO);
                        //18补货员19社区药柜管理员20药柜区域管理员21药柜超级管理员
                        String expandLevel = doctorJson.getString("expandLevel");
                        RoleDO roleDO = roleDao.findOne(expandLevel);
                        userDO.setRoleId(roleDO.getId());
                        userDO = userDao.save(userDO);
                        List<WlyyUserAreaDO> userAreaDOList = userAreaDao.findAllByUserId(userDO.getId());
                        if (userAreaDOList==null||userAreaDOList.size()==0){
                            WlyyUserAreaDO userAreaDO = new  WlyyUserAreaDO();
                            userAreaDO.setUserId(userDO.getId());
                            userAreaDO.setCity(doctorJson.getString("city"));
                            userAreaDO.setCityName(doctorJson.getString("cityName"));
                            userAreaDO.setTown(doctorJson.getString("town"));
                            userAreaDO.setTownName(doctorJson.getString("townName"));
                            userAreaDO.setHospital(doctorJson.getString("hospital"));
                            userAreaDO.setHospitalName(doctorJson.getString("hospitalName"));
                            userAreaDO.setUpdateTime(new Date());
                            userAreaDO.setCreateTime(new Date());
                            userAreaDO.setDel(1);
                            userAreaDao.save(userAreaDO);
                        }
                        if (roleDO.getCode().equalsIgnoreCase("replenisher")){
                            String sql = "select d.id as id,d.equ_name as name from t_mediicine_device d where d.belong_community ='"+doctorJson.getString("hospital")+"' ";
                            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
                            for (Map<String,Object> map:mapList){
                                WlyyUserEquipmentDO equipmentDO = new WlyyUserEquipmentDO();
                                String id = map.get("id").toString();
                                String name = map.get("name")==null?"":map.get("name").toString();
                                equipmentDO.setEquipmentId(id);
                                equipmentDO.setEquipmentName(name);
                                equipmentDO.setUserId(userDO.getId());
                                equipmentDO.setDel(1);
                                equipmentDO.setCityName(doctorJson.getString("cityName"));
                                equipmentDO.setCity(doctorJson.getString("city"));
                                equipmentDO.setTown(doctorJson.getString("town"));
                                equipmentDO.setTownName(doctorJson.getString("townName"));
                                equipmentDO.setHospital(doctorJson.getString("hospital"));
                                equipmentDO.setHospitalName(doctorJson.getString("hospitalName"));
                                equipmentDO.setCreateTime(new Date());
                                equipmentDO.setUpdateTime(new Date());
                                userEquipmentDao.save(equipmentDO);
                            }
                        }
                        return data;
                    }
                }else{
                    return data;
                }
            }else{
                //请求异常
                JSONObject data = new JSONObject();
                data.put("authCode","-2");
                return data;
            }
        }else {
            //请求异常
            JSONObject data = new JSONObject();
            data.put("authCode","-2");
            return data;
        }
    }
    /**
     * 获取全部职称

+ 40 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/CommonEndpoint.java

@ -0,0 +1,40 @@
package com.yihu.jw.base.endpoint.common;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.service.a3service.YlzService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Bing on 2022/6/1.
 */
@RestController
@RequestMapping("/common/test/open")
@Api(tags = "通用测试接口", description = "通用测试接口")
public class CommonEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private YlzService ylzService;
    @RequestMapping(value = "/deviceYBApi",method = RequestMethod.GET)
    @ApiOperation("药柜自助机医保接口")
    public ObjEnvelop deviceYBApi(@ApiParam(name = "apiStr",value = "接口地址",required = true)
                                  @RequestParam(value = "apiStr")String apiStr,
                                  @ApiParam(name = "orgCode",value = "药柜所在机构",required = true)
                                  @RequestParam(value = "orgCode")String orgCode,
                                  @ApiParam(name = "dataInfo",value = "医保data参数",required = true)
                                  @RequestParam(value = "dataInfo")String dataInfo){
        try {
            return ObjEnvelop.getSuccess("success",ylzService.deviceYBApi(apiStr,orgCode,dataInfo));
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
}

+ 294 - 8
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/JwService.java

@ -2,6 +2,7 @@ package com.yihu.jw.base.service.a3service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalIcdDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalMxDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
@ -9,6 +10,7 @@ import com.yihu.jw.hospital.healthCare.YlzMedicailIcdDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailMxDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -18,6 +20,9 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
 * 基卫相关接口
 */
@Transactional
@Service
@ -35,7 +40,7 @@ public class JwService {
    private YlzMedicailMxDao ylzMedicailMxDao;
    /**
     * 获取智业待结算数据接口
     * 获取智业待结算数据接口--自助机
     * @param cardNo 卡号
     * @param orgCode 机构编码
     * @return
@ -61,12 +66,12 @@ public class JwService {
    }
    /**
     * 确认结算-智业
     * 确认结算-智业--自助机
     * @param
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String executeSickSettleMultiNew(String recipe_no) throws Exception {
    public JSONObject executeSickSettleMultiNew(String recipe_no) throws Exception {
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLog_no(recipe_no);
        if (null==recipe_no){
            throw new Exception("无结算信息");
@ -74,30 +79,311 @@ public class JwService {
        if (ylzMedicalRelationDO.getState()==1){
            throw new Exception("订单已结算,无法重复结算");
        }
        List<YlzMedicalMxDO> ylzMedicalMxDO = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
        List<YlzMedicalMxDO> ylzMedicalMxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
        List<YlzMedicalIcdDO> ylzMedicalIcdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
        JSONObject msgBody = new JSONObject();
        JSONArray insurVisitInfo = new JSONArray();
        JSONObject insurResult = new JSONObject(); //医保结算信息 自费病人没有产生医保收费记录,insurResult节点不传自费结算信息
        JSONArray insurResult = new JSONArray(); //医保结算信息 自费病人没有产生医保收费记录,insurResult节点不传自费结算信息
        msgBody.put("cardNo",ylzMedicalRelationDO.getCardNo());//病人卡号
        msgBody.put("settleDept",ylzMedicalRelationDO.getDeptCode());//结算科室编码
        msgBody.put("settleOperator",ylzMedicalRelationDO.getCollector());//结算人员编码
        if (0==ylzMedicalRelationDO.getMedicalState()){//自费
            msgBody.put("insurResult",insurResult);//todo
        }else if (1==ylzMedicalRelationDO.getMedicalState()){//医保
            for (YlzMedicalMxDO medicalMxDO:ylzMedicalMxDOList){
                JSONObject insurResultTmp = new JSONObject();
                insurResultTmp.put("visitNo",ylzMedicalRelationDO.getRelationCode()); //院内挂号号
                insurResultTmp.put("insurSettleSort",medicalMxDO.getInsurSettleSort()); //医保结算序号
                insurResultTmp.put("setl_msgid",medicalMxDO.getSetlMsgid()); //发送方报文ID
                insurResultTmp.put("fee_msgid",medicalMxDO.getFeeMsgid()); //费用上传发送方报文ID
                insurResultTmp.put("dise_msgid",""); //就诊信息上传发送方报文ID todo
                insurResultTmp.put("chrg_bchno",medicalMxDO.getChrgBchno());   //收费批次号
                insurResultTmp.put("insuplc_admdvs",ylzMedicalRelationDO.getRegionCode()); //参保地医保区划【窗口冲销有用】
                insurResultTmp.put("card_sn",""); //卡识别码 todo
                insurResultTmp.put("mdtrt_cert_no",ylzMedicalRelationDO.getCardNo()); //就诊凭证编号
                insurResultTmp.put("fm_acct_balc",""); //家庭共济账户余额 todo
                insurResultTmp.put("hl_acct_balc",""); //健康账户余额 todo
                insurResultTmp.put("cvl_acct_balc",""); //公务员账户余额 todo
                insurResultTmp.put("acct_used_flag","1"); //个人账户使用标志【窗口目前默认固定1,后续可开放前端选择传入】
                insurResultTmp.put("mdtrt_id",ylzMedicalRelationDO.getHisSerial()); //就诊 ID
                insurResultTmp.put("setl_id",""); //结算ID   todo
                insurResultTmp.put("psn_no","1"); //人员编号   医保人员基本信息获取接口返回
                insurResultTmp.put("psn_name",ylzMedicalRelationDO.getName()); //人员姓名
                insurResultTmp.put("psn_cert_type",""); //人员证件类型 todo
                insurResultTmp.put("certno",""); //证件号码 todo
                insurResultTmp.put("gend",""); //性别 todo
                insurResultTmp.put("naty",""); //民族 todo
                insurResultTmp.put("brdy",""); //出生日期 todo
                insurResultTmp.put("age",""); //年龄 todo
                insurResultTmp.put("insutype","1"); //险种类型
                insurResultTmp.put("psn_type","11"); //人员类别"
                insurResultTmp.put("cvlserv_flag","0"); //公务员标志
                insurResultTmp.put("setl_time", DateUtil.getStringDateShort());    //结算时间
                insurResultTmp.put("mdtrt_cert_type","03");  //就诊凭证类型
                insurResultTmp.put("med_type",ylzMedicalRelationDO.getMedType()); //医疗类别
                insurResultTmp.put("medfee_sumamt","");  //医疗费总额 todo
                insurResultTmp.put("fulamt_ownpay_amt",ylzMedicalRelationDO.getOwnPay()); //全自费金额 todo
                insurResultTmp.put("overlmt_selfpay","");  //超限价自费费用 todo
                insurResultTmp.put("preselfpay_amt","");   //先行自付金额 todo
                insurResultTmp.put("inscp_scp_amt","");    //符合政策范围金额 todo
                insurResultTmp.put("act_pay_dedc",""); //实际支付起付线 todo
                insurResultTmp.put("hifp_pay",""); //基本医疗保险统筹基金支出
                insurResultTmp.put("pool_prop_selfpay","");    //基本医疗保险统筹基金支付比例 todo
                insurResultTmp.put("cvlserv_pay","");  //公务员医疗补助资金支出 todo
                insurResultTmp.put("hifes_pay","");    //企业补充医疗保险基金支出
                insurResultTmp.put("hifmi_pay","");    //居民大病保险资金支出
                insurResultTmp.put("hifob_pay","");    //职工大额医疗费用补助基金支出
                insurResultTmp.put("maf_pay","");  //医疗救助基金支出
                insurResultTmp.put("oth_pay","");  //其他支出
                insurResultTmp.put("fund_pay_sumamt","");  //基金支付总额
                insurResultTmp.put("psn_part_amt",""); //个人负担总金额
                insurResultTmp.put("acct_pay",""); //个人账户支出
                insurResultTmp.put("psn_cash_pay",""); //个人现金支出
                insurResultTmp.put("hosp_part_amt","");    //医院负担金额
                insurResultTmp.put("balc",""); //余额
                insurResultTmp.put("acct_mulaid_pay","");  //个人账户共济支付金额
                insurResultTmp.put("medins_setl_id",medicalMxDO.getSetlMsgid());   //医药机构结算ID(应跟setl_msgid值一致)
                insurResultTmp.put("clr_optins","");   //清算经办机构
                insurResultTmp.put("clr_way","");  //清算方式
                insurResultTmp.put("clr_type","11"); //清算类别
                insurResultTmp.put("hifdm_pay","0");    //伤残人员医疗保障基金支出
                insurResultTmp.put("exp_content","");  //
                JSONArray setldetail  = new JSONArray();
                JSONObject setldetailTmp = new JSONObject();
                setldetailTmp.put("fund_pay_type","");  //基金支付类型
                setldetailTmp.put("inscp_scp_amt","");  //符合政策范围金额
                setldetailTmp.put("crt_payb_lmt_amt","");   //本次可支付限额金额
                setldetailTmp.put("fund_payamt","");    //基金支付金额
                setldetailTmp.put("fund_pay_type_name",""); //基金支付类型名称
                setldetailTmp.put("setl_proc_info",""); //结算过程信息
                setldetail.add(setldetailTmp);
                JSONArray fpdetail  = new JSONArray();
                JSONObject fpdetailTmp  = new JSONObject();
                fpdetailTmp.put("chrgitmType",""); //发票项目类别
                fpdetailTmp.put("chrgitmTypeName","");  //发票项目类别名称
                fpdetailTmp.put("medChrgitmType","");   //发票项目类别
                fpdetailTmp.put("medChrgitmName","");   //发票项目类别名称
                fpdetailTmp.put("itemSumamt","");   //发票项目费用
                fpdetailTmp.put("itemClaaAmt","");  //医保发票费用
                fpdetailTmp.put("itemClabAmt","");  //医保个人费用
                fpdetailTmp.put("itemOthAmt","");   //特殊项目发票费用
                fpdetailTmp.put("itemOwnpayAmt","");    //非医保发票费用
                fpdetail.add(fpdetailTmp);
                JSONArray feedetail_result  = new JSONArray();
                JSONObject feedetail_resultTmp  = new JSONObject();
                feedetail_resultTmp.put("feedetl_sn",medicalMxDO.getHisDetailSn());   // 费用明细流水
                feedetail_resultTmp.put("det_item_fee_sumamt",medicalMxDO.getTotalMoney()); //明细项目费用总额
                feedetail_resultTmp.put("cnt",medicalMxDO.getAmount()); //数量
                feedetail_resultTmp.put("pric",medicalMxDO.getPrice()); //单价
                feedetail_resultTmp.put("pric_uplmt_amt",""); //定价上限金额
                feedetail_resultTmp.put("selfpay_prop",""); //自付比例
                feedetail_resultTmp.put("fulamt_ownpay_amt",""); //全自费金额
                feedetail_resultTmp.put("overlmt_amt",""); //超限价金额
                feedetail_resultTmp.put("preselfpay_amt",""); //先行自付金额
                feedetail_resultTmp.put("inscp_scp_amt",""); //符合政策范围金额
                feedetail_resultTmp.put("chrgitm_lv",""); //收费项目等级
                feedetail_resultTmp.put("med_chrgitm_type",""); //医疗收费项目类别
                feedetail_resultTmp.put("bas_medn_flag",""); //基本药物标志
                feedetail_resultTmp.put("hi_nego_drug_flag",""); //医保谈判药品标志
                feedetail_resultTmp.put("chld_medc_flag",""); //儿童用药标志
                feedetail_resultTmp.put("list_sp_item_flag",""); //目录特项标志
                feedetail_resultTmp.put("lmt_used_flag",""); //限制使用标志
                feedetail_resultTmp.put("drt_reim_flag",""); //直报标志
                feedetail_resultTmp.put("memo",""); //备注
                feedetail_resultTmp.put("exp_content",""); //字段扩展
                feedetail_result.add(feedetail_resultTmp);
                insurResultTmp.put("setldetail",setldetail);
                insurResultTmp.put("fpdetail",fpdetail);
                insurResultTmp.put("feedetail_result",feedetail_result);
                insurResult.add(insurResultTmp);
            }
            msgBody.put("insurResult",insurResult);
        }
        JSONObject insurVisitTmp = new JSONObject();
        insurVisitTmp.put("visit_msgid",ylzMedicalRelationDO.getHisSettleNo());//发送方报文ID"
        insurVisitTmp.put("insuplc_admdvs",ylzMedicalRelationDO.getRegionCode());//参保地医保区划【窗口冲销有用】
        insurVisitTmp.put("insutype","310");//险种类型【挂号时用的险种,医保目前以此为准】
        insurVisitTmp.put("mdtrt_id","");//就诊ID  医保挂号接口返回
        insurVisitTmp.put("psn_no","");//人员编号   医保人员基本信息获取接口返回
        insurVisitTmp.put("mdtrt_id",ylzMedicalRelationDO.getHisSerial());//就诊ID  医保挂号接口返回 todo
        insurVisitTmp.put("psn_no","");//人员编号   医保人员基本信息获取接口返回 todo
        insurVisitTmp.put("ipt_otp_no",ylzMedicalRelationDO.getRelationCode());//门诊号
        insurVisitTmp.put("exp_content","");//字段扩展【应需要解决转义字符反斜杠被过滤问题,否则要将里面的扩展节点独立字段出
        insurVisitInfo.add(insurVisitTmp);
        msgBody.put("insurVisitInfo",insurVisitInfo);
        Map<String,String> param = new HashMap<>();
        param.put("interfaceStr","executeSickSettleMultiNew");//接口方法
        param.put("orgCode",ylzMedicalRelationDO.getOrgCode());
        param.put("msgBody",msgBody.toJSONString());
        JSONObject re = wlyyHttpService.sendWlyyMes("callEhrInterfaceYG", null,param);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("callEhrInterfaceYG");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("智业院内结算确认接口");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
        return null;
    /**
     * 病人注册接口--自助机
     * @param json 注册信息 {"saveDept":"注册科室编码","saveOperator":"注册员工编码","dtSick":{"sickName":"病人姓名","sickSex":"病人性别【字典】","sickPhone":"病人电话","birthday":"病人生日【yyyy-mm-dd】","rateType":"病人费别【字典】","identityCardNo":"病人身份证号","cardNo":"病人卡号","cardType":"病人卡类型【字典】"}}
     * @param orgCode 机构编码
     * @return
     */
    public JSONObject saveRegisterInfoZy(String json,String orgCode){
        Map<String,String> param = new HashMap<>();
        param.put("interfaceStr","saveRegisterInfo");//接口方法
        param.put("orgCode",orgCode);
        param.put("msgBody",json);
        JSONObject re = wlyyHttpService.sendWlyyMes("callEhrInterfaceYG", null,param);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("callEhrInterfaceYG");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("智业病人注册接口");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
    /**
     * 查询余额信息接口--自助机
     * @param cardNo 病人卡号
     * @param orgCode
     * @return
     */
    public JSONObject getSickDispBalanceZy(String cardNo,String orgCode){
        Map<String,String> param = new HashMap<>();
        param.put("interfaceStr","getSickDispBalance");//接口方法
        param.put("orgCode",orgCode);
        JSONObject msgBody = new JSONObject();
        msgBody.put("cardNo",cardNo);
        param.put("msgBody",msgBody.toJSONString());
        JSONObject re = wlyyHttpService.sendWlyyMes("callEhrInterfaceYG", null,param);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("callEhrInterfaceYG");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("智业查询余额信息接口");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
    /**
     * 查询检验报告单列表接口--自助机
     * @param cardNo 病人卡号
     * @param orgCode
     * @return
     */
    public JSONObject getSickReportForSSMZy(String cardNo,String orgCode){
        Map<String,String> param = new HashMap<>();
        param.put("interfaceStr","getSickReportForSSM");//接口方法
        param.put("orgCode",orgCode);
        JSONObject msgBody = new JSONObject();
        msgBody.put("cardNo",cardNo);
        param.put("msgBody",msgBody.toJSONString());
        JSONObject re = wlyyHttpService.sendWlyyMes("callEhrInterfaceYG", null,param);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("callEhrInterfaceYG");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("智业查询检验报告单列表接口");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
    /**
     * 更新报告单打印信息接口--自助机
     * @param inspectionNo 检验编号
     * @param operatorStaff 打印人编码
     * @param orgCode
     * @return
     */
    public JSONObject updatePrintCountForSSMZY(String inspectionNo,String operatorStaff,String orgCode){
        Map<String,String> param = new HashMap<>();
        param.put("interfaceStr","updatePrintCountForSSM");//接口方法
        param.put("orgCode",orgCode);
        JSONObject msgBody = new JSONObject();
        msgBody.put("inspectionNo",inspectionNo);
        msgBody.put("operatorStaff",operatorStaff);
        param.put("msgBody",msgBody.toJSONString());
        JSONObject re = wlyyHttpService.sendWlyyMes("callEhrInterfaceYG", null,param);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("callEhrInterfaceYG");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("智业更新报告单打印信息接口");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
    /**
     * 充值接口(自助机只充不退)--自助机
     * @param json {"cardNo":"病人卡号","operateType":"1","paymentType":"支付方式【字典】","prepayType":"1","rateType":"病人费别【字典】","prepayStatus":"1","prepayOperator":"收费员编码","PrepayDept":"收费科室编码","remark":"备注","prepayMoney":"预交金额","prepayBillNO":"预交金票据号","outChargeNo":"商户充值业务流水","termNo":"自助机终端编号","depositType":"充值方式","authCode":"支付码","channelType":"渠道类型"}
     * @param orgCode
     * @return
     */
    public JSONObject savePrepayZy(String json,String orgCode){
        Map<String,String> param = new HashMap<>();
        param.put("interfaceStr","savePrepay");//接口方法
        param.put("orgCode",orgCode);
        param.put("msgBody",json);
        JSONObject re = wlyyHttpService.sendWlyyMes("callEhrInterfaceYG", null,param);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("callEhrInterfaceYG");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("智业充值接口");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
    /**
     * 查询收费记录接口--自助机
     * @param cardNo 病人卡号
     * @param settleTimeFrom 结算时间从【yyyy-mm-dd】
     * @param settleTimeTo 结算时间到【yyyy-mm-dd】
     * @param orgCode
     * @return
     */
    public JSONObject getSettleRecordZy(String cardNo,String settleTimeFrom,String settleTimeTo,String orgCode){
        Map<String,String> param = new HashMap<>();
        param.put("interfaceStr","getSettleRecord");//接口方法
        param.put("orgCode",orgCode);
        JSONObject msgBody = new JSONObject();
        msgBody.put("cardNo",cardNo);
        msgBody.put("settleTimeFrom",settleTimeFrom);
        msgBody.put("settleTimeTo",settleTimeTo);
        param.put("msgBody",msgBody.toJSONString());
        JSONObject re = wlyyHttpService.sendWlyyMes("callEhrInterfaceYG", null,param);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("callEhrInterfaceYG");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("智业查询收费记录接口");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
}

文件差异内容过多而无法显示
+ 218 - 230
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedOrderService.java


+ 173 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/YlzService.java

@ -0,0 +1,173 @@
package com.yihu.jw.base.service.a3service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
 * 易联众相关接口
 */
@Service
@Transactional
public class YlzService {
    private static Logger logger = LoggerFactory.getLogger(YlzService.class);
    @Autowired
    private WlyyHttpService wlyyHttpService;
    @Autowired
    private WlyyHttpLogDao httpLogDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${spring.profiles}")
    private String springProfiles;
    private final String entranceUrl="https://zb.xmtyw.cn/medicine/cityihealth/base";
    /**
     *药柜预缴金充值--易慧
     * @param orgCode
     * @param operatorId 自助机编码
     * @param ssc 社保卡
     * @param depositType 支付方式ALI_QR 支付宝二维码支付;WX_QR微信二维码
     * @param amount 金额 单位元 2位小数
     * @param outChargeNo 流水号 后续查询结果需要用到
     * @param hisCustId 患者his系统编号 可传身份证
     * @param userName 患者名字
     * @param notifyUrl 后端回调地址
     * @param returnUrl 支付成功后中转地址
     * @return
     */
    public JSONObject hlwyyRecharge(String orgCode,String operatorId,String ssc,String depositType,String amount,
                                    String outChargeNo,String hisCustId,String userName,String notifyUrl,String returnUrl){
        Map<String,String> param = new HashMap<>();
        param.put("orgCode",orgCode);
        param.put("operatorId",operatorId);
        param.put("ssc",ssc);
        param.put("depositType",depositType);
        param.put("amount",amount);
        param.put("outChargeNo",outChargeNo);
        param.put("hisCustId",hisCustId);
        param.put("userName",userName);
        if (StringUtils.isNotBlank(notifyUrl)){
            param.put("notifyUrl",userName);
        }
        if (StringUtils.isNotBlank(returnUrl)){
            param.put("returnUrl",returnUrl);
        }
        JSONObject re = wlyyHttpService.sendWlyyMes("hlwyyRecharge", null,param);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("hlwyyRecharge");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("药柜易慧预缴金充值");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
    /**
     *智慧药柜预缴金充值结果查询--易慧
     * @param orgCode
     * @param operatorId 自助机编号
     * @param tradeType 充值:hop.trade.recharge 退费:hop.trade.refund
     * @param outTradeNo 流水号 对应充值接口outChargeNo
     * @return
     */
    public JSONObject hlwyyQueryDetail(String orgCode,String operatorId,String tradeType,String outTradeNo){
        Map<String,String> param = new HashMap<>();
        param.put("orgCode",orgCode);
        param.put("operatorId",operatorId);
        param.put("tradeType",tradeType);
        param.put("outTradeNo",outTradeNo);
        JSONObject re = wlyyHttpService.sendWlyyMes("hlwyyQueryDetail", null,param);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setCode("hlwyyQueryDetail");
        wlyyHttpLogDO.setRequest(param.toString());
        wlyyHttpLogDO.setResponse(re.toJSONString());
        wlyyHttpLogDO.setName("药柜预缴金充值结果查询");
        wlyyHttpLogDO.setStatus("1");
        wlyyHttpLogDO.setCreateTime(new Date());
        httpLogDao.save(wlyyHttpLogDO);
        return re;
    }
    /**
     * 药柜自助机-医保接口
     * @param apiStr 接口名称 如:fsi.terminal.readcard
     * @param orgCode 药柜索要机构编码
     * @param dataInfo 医保参数data信息
     * @return
     * @throws Exception
     */
    public String deviceYBApi(String apiStr,String orgCode,String dataInfo)throws Exception{
        if ("jwZnygProdIn".equals(springProfiles)){//内网访问
            String sql = " select dp.* from t_mediicine_device de INNER JOIN t_mediicine_device_param dp on de.id = dp.device_id  " +
                    "where de.del=1 and dp.del=1 and de.belong_community='"+orgCode+"' ";
            List<Map<String,Object>> deviceParams =  jdbcTemplate.queryForList(sql);
            if (deviceParams.size()==0){
                throw new Exception("药柜参数获取错误");
            }
            Map<String,Object> deviceParam = deviceParams.get(0);
            JSONObject strinObj = JSONObject.parseObject(deviceParam.get("yb_strin").toString());
            strinObj.put("func",apiStr);
            strinObj.put("data",JSONObject.parseObject(dataInfo));
            String deviceIp = deviceParam.get("device_ip").toString();
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("strin", strinObj.toJSONString()));
            String url = "http://"+deviceIp+":9000/api/Mi";
            String result =  httpClientUtil.get(url,params,"UTF-8");
            WlyyHttpLogDO logDO = new WlyyHttpLogDO();
            logDO.setCode(apiStr);
            logDO.setName("药柜医保接口");
            logDO.setRequest(url+JSONObject.toJSONString(params));
            logDO.setResponse(result);
            httpLogDao.save(logDO);
            return result;
        }else {
            String url = entranceUrl+"/common/test/open/deviceYBApi";
            Map map = new HashMap<String, String>();
            map.put("apiStr", apiStr);
            map.put("orgCode", orgCode);
            map.put("dataInfo",dataInfo);
            String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
            String params = AesEncryptUtils.agEncrypt(content);
            String resultStr =  httpClientUtil.getBodyRawForm(url,params);
            JSONObject resultObject = com.alibaba.fastjson.JSONObject.parseObject(resultStr);
            if (resultObject.get("status").equals("200")) {
                JSONObject jsonObjectData = JSONObject.parseObject(AesEncryptUtils.agDecrypt(resultObject.get("data").toString()));
                logger.info(jsonObjectData.toJSONString());
//                String resultStr="{\"message\":\"success\",\"status\":200,\"obj\":\"\\\"{\\\\\\\"func\\\\\\\":\\\\\\\"fsi.terminal.readcard\\\\\\\",\\\\\\\"retCode\\\\\\\":\\\\\\\"-4\\\\\\\",\\\\\\\"retMsg\\\\\\\":\\\\\\\"服务器连接失败。\\\\\\\"}\\\"\"}";
                if (200==jsonObjectData.getInteger("status")){
                    return jsonObjectData.getString("obj");
                }else {
                    throw new Exception(jsonObjectData.getString("message"));
                }
            }else {
                throw new Exception("请求失败");
            }
        }
    }
}

+ 1 - 1
wlyy-parent-pom/pom.xml

@ -85,7 +85,7 @@
        <!-- Version start -->
        <version.wlyy-common>2.0.0</version.wlyy-common>
        <version.jackson>2.8.1</version.jackson>
        <verion.fastjson>1.2.72</verion.fastjson>
        <verion.fastjson>1.2.83</verion.fastjson>
        <version.json>20160212</version.json>
        <version.net-json>2.4</version.net-json>
        <version.logback>1.2.3</version.logback>