| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.pinyin.PinyinUtil; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | |
| | | import com.ltkj.common.utils.poi.ExcelUtil; |
| | | import com.ltkj.common.core.page.TableDataInfo; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.OutputStream; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | TjCustomer requestCommonHisApi = isRequestCommonHisApi(tjCustomer); |
| | | if (null !=requestCommonHisApi){ |
| | | if (tjCustomerService.save(requestCommonHisApi)) { |
| | | saveCustomerSfzImg(tjCustomer,dataSourceType); |
| | | return AjaxResult.success(requestCommonHisApi); |
| | | } |
| | | } |
| | | }else { |
| | | if (tjCustomerService.save(tjCustomer)) { |
| | | saveCustomerSfzImg(tjCustomer,dataSourceType); |
| | | return AjaxResult.success(tjCustomer); |
| | | } |
| | | } |
| | |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | private void saveCustomerSfzImg(TjCustomer tjCustomer,String hospId){ |
| | | if (StrUtil.isNotBlank(tjCustomer.getSfzImg())){ |
| | | hospId = hospId.replace("ltkjpeis10_",""); |
| | | String value = sysConfigService.selectConfigByKey("path_sfzfilePath"); |
| | | String outputPath = value + File.separator + hospId + File.separator+tjCustomer.getCusId()+".jpg"; |
| | | File outFile = new File(outputPath); |
| | | File parentDir = outFile.getParentFile(); |
| | | if (!parentDir.exists()) { |
| | | parentDir.mkdirs(); |
| | | } |
| | | try { |
| | | String base64Str = tjCustomer.getSfzImg(); |
| | | if (base64Str.contains(",")) { |
| | | base64Str = base64Str.split(",")[1]; |
| | | } |
| | | byte[] imageBytes = Base64.getDecoder().decode(base64Str); |
| | | try (OutputStream out = new FileOutputStream(outFile)) { |
| | | out.write(imageBytes); |
| | | out.flush(); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("保存身份证人像图片失败",e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private TjCustomer isRequestCommonHisApi(TjCustomer tjCustomer) { |
| | | String apiUrl = sysConfigService.selectConfigByKey("common_api_url"); |
| | | String hospbm = sysConfigService.selectConfigByKey("common_api_service_hospbm"); |