| | |
| | | package com.example.service.shanxiqin.xian; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.pinyin.PinyinUtil; |
| | | import cn.hutool.json.JSON; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.example.config.ConfigValue; |
| | | import com.example.constant.ApiParamsConstants; |
| | | import com.example.constant.ApiParamsConstantsLis; |
| | | import com.example.service.LisService; |
| | | import com.example.utils.AjaxResult; |
| | | import com.example.utils.FieldNameConverter; |
| | | import com.example.utils.HttpClientUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Company: 西安路泰科技有限公司 |
| | |
| | | */ |
| | | @Service("ShanXiQinXiAnMeiJiLis") |
| | | public class MeiJiLisService implements LisService { |
| | | @Autowired |
| | | private ConfigValue configValue; |
| | | |
| | | private final ApplicationContext applicationContext; |
| | | |
| | | private final String LIS_URL; |
| | | private final String TJ_URL; |
| | | |
| | | @Autowired |
| | | public MeiJiLisService(ApplicationContext applicationContext, ConfigValue configValue) { |
| | | this.applicationContext = applicationContext; |
| | | this.configValue = configValue; |
| | | LIS_URL = configValue.getConfigValue("ShanXi_Qin_XiAn_MeiJi.lis_api_url") + ":" + configValue.getConfigValue("ShanXi_Qin_XiAn_MeiJi.lis_api_port") + configValue.getConfigValue("ShanXi_Qin_XiAn_MeiJi.lisapiappend"); |
| | | TJ_URL = configValue.getConfigValue("ShanXi_Qin_XiAn_MeiJi.tjUrl"); |
| | | } |
| | | |
| | | @Override |
| | | public String makeSqd(Map<String, Object> map) { |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | |
| | | hashMap.put("TELEPHONE",map.get(ApiParamsConstants.CUS_PHONE)); |
| | | hashMap.put("YBKH",""); |
| | | hashMap.put("TJDW",map.get(ApiParamsConstants.COMP_NAME)); |
| | | hashMap.put("ISACTIVE","1"); |
| | | hashMap.put("SENDDOCTOR",map.get(ApiParamsConstantsLis.SENDDOCTOR)); |
| | | hashMap.put("SENDDOCTORNAME",map.get(ApiParamsConstantsLis.SENDDOCTORNAME)); |
| | | hashMap.put("SENDDEPARTCODE",map.get(ApiParamsConstantsLis.SENDDEPARTCODE)); |
| | | hashMap.put("SENDDEPARTNAME",map.get(ApiParamsConstantsLis.SENDDEPARTNAME)); |
| | | hashMap.put("APPLYDEPARTCODE",map.get(ApiParamsConstantsLis.APPLYDEPARTCODE)); |
| | | hashMap.put("APPLYDEPARTNAME",map.get(ApiParamsConstantsLis.APPLYDEPARTNAME)); |
| | | hashMap.put("APPLYDOCTORCODE",map.get(ApiParamsConstantsLis.APPLYDOCTORCODE)); |
| | | hashMap.put("APPLYDOCTORNAME",map.get(ApiParamsConstantsLis.APPLYDOCTORNAME)); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String dqsj = format.format(new Date()); |
| | | hashMap.put("APPLYDATETIME",dqsj); |
| | | hashMap.put("BEDNO",""); |
| | | hashMap.put("SENDDATE",dqsj); |
| | | hashMap.put("SFDATE",dqsj); |
| | | // TODO |
| | | hashMap.put("HOSPITALID",""); |
| | | // TODO |
| | | hashMap.put("CARDTYPE",""); |
| | | hashMap.put("PATIENTTYPE","3"); |
| | | hashMap.put("SFYNAME",map.get(ApiParamsConstantsLis.SFYNAME)); |
| | | hashMap.put("jizhenBz","0"); |
| | | |
| | | JSONArray array = JSONUtil.parseArray(map.get(ApiParamsConstantsLis.mxList)); |
| | | JSONArray orderInfoList = JSONUtil.createArray(); |
| | | for (Object o : array) { |
| | | JSONObject entries = (JSONObject) o; |
| | | JSONObject object = JSONUtil.createObj(); |
| | | object.putOpt("SFXMID",entries.getStr(ApiParamsConstantsLis.SFXMID)); |
| | | object.putOpt("SFXMNAME",entries.getStr(ApiParamsConstantsLis.SFXMNAME)); |
| | | object.putOpt("SFXMPRICE",entries.getStr(ApiParamsConstantsLis.SFXMPRICE)); |
| | | object.putOpt("QUALITY",entries.getStr(ApiParamsConstantsLis.QUALITY)); |
| | | object.putOpt("SpecimenCode",entries.getStr(ApiParamsConstantsLis.SpecimenCode)); |
| | | object.putOpt("SpecimenDesc",entries.getStr(ApiParamsConstantsLis.SpecimenDesc)); |
| | | object.putOpt("KEYVALUE",entries.getStr(ApiParamsConstantsLis.PRIMARY_KEY)); |
| | | orderInfoList.add(object); |
| | | } |
| | | hashMap.put("OderInfoList",orderInfoList); |
| | | String post = sendPost(LIS_URL + "/lisinterface" + "/HisApplyList", hashMap); |
| | | JSONObject entries = JSONUtil.parseObj(post); |
| | | if (entries.getStr("MsgCode").equals("0")) |
| | | return AjaxResult.success(); |
| | | else return AjaxResult.error(); |
| | | } |
| | | |
| | | @Override |
| | | public String getXmlList(Map<String, Object> map) { |
| | | Map<String, Object> request = (Map<String, Object>) map.get("Request"); |
| | | String hospitalId = request.get("HospitalId").toString(); |
| | | String json = sendPost(TJ_URL + "/callBack/getZdList", new HashMap<>()); |
| | | JSONObject entries = JSONUtil.parseObj(json); |
| | | JSONObject result = JSONUtil.createObj(); |
| | | if (entries.getStr("code").equals("200")){ |
| | | result.putOpt("returnCode","200"); |
| | | result.putOpt("returnMessage","获取成功"); |
| | | result.putOpt("HOSPITALID",hospitalId); |
| | | JSONArray array = entries.getJSONArray("data"); |
| | | result.putOpt("Rows",array.size()); |
| | | JSONArray dataInfoList = JSONUtil.createArray(); |
| | | for (Object o : array) { |
| | | JSONObject object = (JSONObject) o; |
| | | JSONObject obj = JSONUtil.createObj(); |
| | | obj.putOpt("SFXMID",object.getStr("SFXMID")); |
| | | String sfxmname = object.getStr("SFXMNAME"); |
| | | obj.putOpt("SFXMNAME",sfxmname); |
| | | obj.putOpt("UNIT",""); |
| | | obj.putOpt("SFKZ",""); |
| | | obj.putOpt("SFXM",""); |
| | | obj.putOpt("PRICE",object.getStr("PRICE")); |
| | | obj.putOpt("SRM1", PinyinUtil.getFirstLetter(sfxmname,"")); |
| | | obj.putOpt("SRM2",""); |
| | | obj.putOpt("SRM3",""); |
| | | obj.putOpt("MEMO",""); |
| | | obj.putOpt("PATIENTTYPE","3"); |
| | | dataInfoList.add(obj); |
| | | } |
| | | result.putOpt("DataInfoList",dataInfoList); |
| | | return JSONUtil.toJsonStr(result); |
| | | }else { |
| | | result.putOpt("returnCode","400"); |
| | | result.putOpt("returnMessage","获取失败"); |
| | | result.putOpt("HospitalId",hospitalId); |
| | | return JSONUtil.toJsonStr(result); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String revoke(Map<String, Object> map) { |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | JSONArray list = (JSONArray) map.get("list"); |
| | | JSONArray array = JSONUtil.createArray(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String sj = format.format(new Date()); |
| | | for (Object o : list) { |
| | | JSONObject object = (JSONObject) o; |
| | | JSONObject entries = JSONUtil.createObj(); |
| | | entries.putOpt("TXM",object.getStr(ApiParamsConstantsLis.TXM)); |
| | | entries.putOpt("TFDOCTORID",object.getStr(ApiParamsConstantsLis.TFDOCTORID)); |
| | | entries.putOpt("TFDOCTORNAME",object.getStr(ApiParamsConstantsLis.TFDOCTORNAME)); |
| | | entries.putOpt("TFDATE",sj); |
| | | entries.putOpt("TFDEPARTID",object.getStr(ApiParamsConstantsLis.TFDEPARTID)); |
| | | entries.putOpt("TFDEPARTNAME",object.getStr(ApiParamsConstantsLis.TFDEPARTNAME)); |
| | | // TODO |
| | | entries.putOpt("HOSPITALID",""); |
| | | entries.putOpt("TFSFXMID",object.getStr(ApiParamsConstantsLis.SFXMID)); |
| | | entries.putOpt("TFSFXMNAME",object.getStr(ApiParamsConstantsLis.SFXMNAME)); |
| | | entries.putOpt("TFKEYVALUE",object.getStr(ApiParamsConstantsLis.PRIMARY_KEY)); |
| | | array.add(entries); |
| | | } |
| | | String post = HttpClientUtils.sendPost(LIS_URL + "/lisinterface/FetchChargebacksInformation", JSONUtil.toJsonStr(array)); |
| | | if (JSONUtil.parseObj(post).getStr("MsgCode").equals("0")) |
| | | return AjaxResult.success(); |
| | | else return AjaxResult.error(); |
| | | } |
| | | |
| | | @Override |
| | | public String confirmRevoke(Map<String, Object> map) { |
| | | String personid = map.get("PERSONID").toString(); |
| | | String hospitalid = map.get("HOSPITALID").toString(); |
| | | List<String> keys = Arrays.asList((String[]) map.get("KEYVALUELIST")); |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | hashMap.put("keys",keys); |
| | | hashMap.put("czy",personid); |
| | | hashMap.put("hospid",hospitalid); |
| | | String post = sendPost(TJ_URL + "/callBack/lisRevoke", hashMap); |
| | | JSONObject entries = JSONUtil.parseObj(post); |
| | | JSONObject object = JSONUtil.createObj(); |
| | | if (entries.getStr("code").equals("200")){ |
| | | object.putOpt("returnCode","200"); |
| | | return JSONUtil.toJsonStr(object); |
| | | }else { |
| | | object.putOpt("returnCode","500"); |
| | | return JSONUtil.toJsonStr(object); |
| | | } |
| | | } |
| | | |
| | | |
| | | return ""; |
| | | private String sendPost(String url, Map<String, Object> hashMap){ |
| | | return HttpClientUtils.sendPost(url, hashMap); |
| | | } |
| | | } |