| | |
| | | package com.ltkj.web.controller.system; |
| | | |
| | | import cn.hutool.core.codec.Base64; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.pinyin.PinyinUtil; |
| | |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.google.common.base.Joiner; |
| | | import com.ltkj.common.annotation.RepeatSubmit; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | | import com.ltkj.common.core.domain.entity.SysDept; |
| | | import com.ltkj.common.core.domain.entity.SysDictData; |
| | | import com.ltkj.common.core.domain.entity.SysUser; |
| | | import com.ltkj.common.excelConfig.ExcelUtils; |
| | | import com.ltkj.common.task.TaskService; |
| | | import com.ltkj.common.utils.SecurityUtils; |
| | | import com.ltkj.common.utils.StringUtils; |
| | | import com.ltkj.framework.config.MatchUtils; |
| | | import com.ltkj.hosp.domain.*; |
| | | import com.ltkj.hosp.dto.ConfirmDto; |
| | | import com.ltkj.hosp.idutil.IdUtils; |
| | | import com.ltkj.hosp.mapper.TjSamplingMapper; |
| | | import com.ltkj.hosp.service.*; |
| | |
| | | import com.ltkj.system.service.ISysDeptService; |
| | | import com.ltkj.system.service.ISysDictDataService; |
| | | import com.ltkj.system.service.ISysUserService; |
| | | import com.ltkj.web.config.pdfutils.PDFBinaryUtil; |
| | | import com.ltkj.web.config.task.TjReservationTask; |
| | | import com.ltkj.web.controller.his.HisApiMethod; |
| | | import com.ltkj.web.controller.his.HisApiMethodService; |
| | | import com.ltkj.web.controller.lis.LisApiMethod; |
| | | import com.ltkj.web.wxUtils.HttpClientUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import jodd.util.StringUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.NoTransactionException; |
| | | import org.springframework.transaction.annotation.Isolation; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.net.URL; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Company: 西安路泰科技有限公司 |
| | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/zhiye/order") |
| | | @Api(tags = "职业病相关接口") |
| | | public class ZhiYeController { |
| | | @Autowired |
| | | private ISysUserService userService; |
| | |
| | | private ITjCustomerService tjCustomerService; |
| | | @Autowired |
| | | private ITjReservationService tjReservationService; |
| | | @Resource |
| | | private ITjDwGroupingService dwGroupingService; |
| | | @Resource |
| | | private ITjGroupingProService groupingProService; |
| | | @Autowired |
| | | private IMallOrderService mallOrderService; |
| | | @Autowired |
| | | private ITjDwGroupingService dwGroupingService; |
| | | @Autowired |
| | | private ITbTransitionService transitionService; |
| | | @Autowired |
| | | private ITjOrderService tjOrderService; |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | @Resource |
| | | private IDictCompService compService; |
| | | @Resource |
| | | private ITjDwDeptService dwDeptService; |
| | | @Resource |
| | | private TjAsyncService asyncService; |
| | | @Resource |
| | | private ITjCompPayService compPayService; |
| | | @Resource |
| | | private ITjTeamSelectRecordService selectRecordService; |
| | | @Autowired |
| | | private IdUtils idUtils; |
| | | @Autowired |
| | |
| | | private ISysDeptService sysDeptService; |
| | | @Autowired |
| | | private TjFlowingWaterHisService tjFlowingWaterHisService; |
| | | @Autowired |
| | | private ISysDictDataService dictDataService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | |
| | | ReentrantLock lock = new ReentrantLock(); |
| | | |
| | |
| | | wq.eq(TjCustomer::getCusId, tjOrder.getUserId()); |
| | | TjCustomer tjCustomer = tjCustomerService.getOne(wq); |
| | | if (tjCustomer == null) return AjaxResult.error("该客户未登记"); |
| | | |
| | | TjFlowingWater tjFlowingWater = new TjFlowingWater(); |
| | | LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard()); |
| | |
| | | if (null != tjReservation.getJobNo()) tjOrder.setFirmWorkId(tjReservation.getJobNo()); |
| | | if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId()); |
| | | if (null != tjReservation.getTjCategory()) tjOrder.setTjCategory(tjReservation.getTjCategory()); |
| | | |
| | | if (null != tjReservation.getZhiyeJhgln()) tjOrder.setZhiyeJhgln(tjReservation.getZhiyeJhgln()); |
| | | if (null != tjReservation.getZhiyeJhgly()) tjOrder.setZhiyeJhgly(tjReservation.getZhiyeJhgly()); |
| | | if (null != tjReservation.getZhiyeKsjhrq()) tjOrder.setZhiyeKsjhrq(tjReservation.getZhiyeKsjhrq()); |
| | | if (null != tjReservation.getZhiyeGh()) tjOrder.setZhiyeGh(tjReservation.getZhiyeGh()); |
| | | if (null != tjReservation.getZhiyeGz()) tjOrder.setZhiyeGz(tjReservation.getZhiyeGz()); |
| | | if (null != tjReservation.getZhiyeZgln()) tjOrder.setZhiyeZgln(tjReservation.getZhiyeZgln()); |
| | | if (null != tjReservation.getZhiyeZgly()) tjOrder.setZhiyeZgly(tjReservation.getZhiyeZgly()); |
| | | if (null != tjReservation.getZhiyeJhys()) tjOrder.setZhiyeJhys(tjReservation.getZhiyeJhys()); |
| | | if (null != tjReservation.getZhiyeRzsj()) tjOrder.setZhiyeRzsj(tjReservation.getZhiyeRzsj()); |
| | | if (null != tjReservation.getZhiyeScdw()) tjOrder.setZhiyeScdw(tjReservation.getZhiyeScdw()); |
| | | if (null != tjReservation.getZhiyeZysksrq()) tjOrder.setZhiyeZysksrq(tjReservation.getZhiyeZysksrq()); |
| | | if (null != tjReservation.getZhiyeZysjsrq()) tjOrder.setZhiyeZysjsrq(tjReservation.getZhiyeZysjsrq()); |
| | | if (null != tjReservation.getZhiyeZysszdw()) tjOrder.setZhiyeZysszdw(tjReservation.getZhiyeZysszdw()); |
| | | |
| | | if (null != tjReservation.getGroupingId()) { |
| | | TjDwGrouping dwGrouping = dwGroupingService.getById(tjReservation.getGroupingId()); |
| | | tjOrder.setGroupId(tjReservation.getGroupingId()); |
| | |
| | | } |
| | | tjReservation.setIsExpire(1); |
| | | tjReservationService.updateById(tjReservation); |
| | | if (null != tjReservation.getTeamNo()) { |
| | | if (null != tjReservation.getTeamNo() && tjOrder.getTjType().equals("1")) { |
| | | tjOrder.setTjType("1"); |
| | | } else if (tjOrder.getTjType().equals("2")) { |
| | | tjOrder.setTjType("2"); |
| | |
| | | } |
| | | }catch (Exception e){ |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | log.error(String.valueOf(e)); |
| | | log.error(String.valueOf(e),e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | finally { |
| | | lock.unlock(); |
| | |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) // 共享事务 |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public AjaxResult processOrderWithTransaction(TjOrder tjOrder, TjCustomer tjCustomer, TjReservation tjReservation, TjFlowingWater tjFlowingWater, MallOrder mallOrder, SysUser sysUser) { |
| | | |
| | | //获取拼接前缀 |
| | | String sfkqtjhqz = configService.selectConfigByKey("sfkqtjhqz"); |
| | | String makeLisTmhPrefix = ""; |
| | | if(sfkqtjhqz.equalsIgnoreCase("Y")){ |
| | | makeLisTmhPrefix = configService.selectConfigByKey("make_lis_tmh_prefix"); |
| | | } |
| | | //生成体检号 |
| | | String makeLisTmhPrefix = configService.selectConfigByKey("make_lis_tmh_prefix"); |
| | | String tjNumber = null; |
| | | int a =0; |
| | | while (tjNumber ==null){ |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | throw new IllegalStateException(); |
| | | }finally { |
| | | a++; |
| | | } |
| | | } |
| | | if(StringUtil.isBlank(tjNumber)) return AjaxResult.error("登记失败 重新操作"); |
| | | |
| | | tjOrder.setTjNumber(tjNumber); |
| | | |
| | | BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount())); |
| | | tjOrder.setDiscount(discount.toString()); |
| | | if (tjOrderService.save(tjOrder)) { |
| | |
| | | /*调用his接口*/ |
| | | String config = configService.selectConfigByKey("sfkqdyhis"); |
| | | if (null != config && config.equals("Y")) { |
| | | if(tjCustomer.getPationId().equals("0")){ |
| | | AjaxResult result = controller.Outpincreateapply(tjCustomer); |
| | | String result1 = getAjaxResult(result); |
| | | JSONObject object = getJSONObject(result1); |
| | | String code = object.getStr("ResultCode"); |
| | | if (code.equals("0")) { |
| | | JSONArray resultDatass = object.getJSONArray("ResultData"); |
| | | Map<String, Object> resultData = (Map<String, Object>) resultDatass.get(0); |
| | | if (null != resultData && !resultData.isEmpty()) { |
| | | String pationid = resultData.get("PationId").toString(); |
| | | if (null != pationid) { |
| | | tjCustomer.setPationId(pationid); |
| | | tjCustomerService.updateById(tjCustomer); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | AjaxResult result = hisApiMethod.HisApiMethods(tjCustomer, tjOrder); |
| | | AjaxResult result = null; |
| | | try { |
| | | result = hisApiMethod.HisApiMethods(tjCustomer, tjOrder); |
| | | if (!result.get("code").toString().equals("200")) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | Object jzh = result.get("jzh"); |
| | |
| | | hisApiMethod.ZfHisApiMethod(jzh.toString()); |
| | | } |
| | | log.info("该登记人挂号失败, 就诊号为: " + tjOrder.getCardId()); |
| | | throw new IllegalStateException("挂号失败!" + result.get("msg").toString()); |
| | | return AjaxResult.error("挂号失败!" + result.get("msg").toString()); |
| | | } |
| | | } catch (NoTransactionException e) { |
| | | log.error(e.getMessage()); |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | log.info("该登记人的his就诊号是: " + tjOrder.getCardId()); |
| | | // 查询 对接Lis、Pacs申请如果类型包含在配置内则使用对接lis、pacs |
| | | try { |
| | | if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) { |
| | | log.info("调用his开启 进入不收费方法 该体检人员不收费:"+tjOrder.getTjNumber()); |
| | | // 这是上面个人方法引入数据 |
| | | tjFlowingWater.setPayStasus(1L); |
| | | newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater); |
| | |
| | | remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString()); |
| | | List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber()); |
| | | xdPictureService.saveBatch(xdPictureList); |
| | | List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId()); |
| | | addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null); |
| | | log.info("调用his开启 进入不收费方法 该方法执行完毕"); |
| | | } else { |
| | | log.info("调用his开启 进入收费方法 该体检人员收费:"+tjOrder.getTjNumber()); |
| | | newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater); |
| | | List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId()); |
| | | addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null); |
| | | String isUseMx = configService.selectConfigByKey("jcxhis_is_use_mx"); |
| | | if (isUseMx.equalsIgnoreCase("Y")) |
| | | hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId()); |
| | | else hisApiMethod.tijianshenqingJinchuanNew(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | throw new IllegalStateException(); |
| | | } |
| | | return AjaxResult.success(tjNumber); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } else { |
| | | tjCustomer.setCardId(tjOrder.getTjNumber()); |
| | | tjCustomerService.updateById(tjCustomer); |
| | |
| | | tjOrder.setCardId(tjOrder.getTjNumber()); |
| | | tjOrderService.updateById(tjOrder); |
| | | } |
| | | |
| | | // 查询 对接Lis、Pacs申请如果类型包含在配置内则使用对接lis、pacs |
| | | log.info("签到登记接口该人员: "+tjOrder.getTjNumber()+" 的体检类型是:"+tjOrder.getTjType()); |
| | | if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) { |
| | | String drrysfsf = configService.selectConfigByKey("drrysfsf"); |
| | | try { |
| | | log.info(tjOrder.getTjNumber()+"签到登记进入未收费方法"); |
| | | // 这是上面个人方法引入数据 |
| | | tjFlowingWater.setPayStasus(1L); |
| | | if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) { |
| | | if(StringUtil.isNotBlank(drrysfsf) && drrysfsf.equalsIgnoreCase("Y")){ |
| | | if(null != tjReservation){ |
| | | return isUseLisAndPacsRegister(tjOrder, tjCustomer, tjReservation, tjFlowingWater, sysUser, discount, tjNumber); |
| | | }else { |
| | | newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater); |
| | | tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()), |
| | | sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString()); |
| | | List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber()); |
| | | xdPictureService.saveBatch(xdPictureList); |
| | | List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId()); |
| | | log.info(tjOrder.getTjNumber()+"签到登记:采样数据查询个数"+detailList.size()); |
| | | addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null); |
| | | AjaxResult error = isRequestCommonHisApi(tjOrder, tjCustomer, tjFlowingWater); |
| | | if (error != null) return error; |
| | | |
| | | return AjaxResult.success(tjNumber); |
| | | } |
| | | } |
| | | return isUseLisAndPacsRegister(tjOrder, tjCustomer, tjReservation, tjFlowingWater, sysUser, discount, tjNumber); |
| | | |
| | | } else { |
| | | newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater); |
| | | AjaxResult error = isRequestCommonHisApi(tjOrder, tjCustomer, tjFlowingWater); |
| | | if (error != null) return error; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | throw new IllegalStateException(e); |
| | | } |
| | | } else { |
| | | try { |
| | | log.info(tjOrder.getTjNumber()+"else签到登记进入收费方法"); |
| | | newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater); |
| | | isRequestCommonHisApi(tjOrder, tjCustomer, tjFlowingWater); |
| | | } catch (Exception e) { |
| | | log.error("processOrderWithTransaction 方法异常"+e.getMessage()); |
| | | throw new RuntimeException("调用公共方法失败 强制触发回滚"); |
| | | } |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | return AjaxResult.success(tjNumber); |
| | | } |
| | | throw new RuntimeException("体检记录保存失败 强制触发回滚"); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) // 共享事务 |
| | | public void newSaveextracted(TjOrder tjOrder, TjCustomer tjCustomer, BigDecimal discount, SysUser sysUser, TjReservation tjReservation, TjFlowingWater tjFlowingWater) { |
| | | try { |
| | | tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId())); |
| | |
| | | xdPictureService.saveBatch(xdPictureList); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) // 共享事务 |
| | | public void addCaiYangDengJi(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser, String jxbz) { |
| | | try { |
| | | String lis_tmh_prefix = configService.selectConfigByKey("make_lis_tmh_prefix"); |
| | | String config = configService.selectConfigByKey("sfkqdyhis"); |
| | | Boolean lisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order); |
| | |
| | | } else { |
| | | tjSamplingMapper.updateUserIdByTjNum(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId())); |
| | | } |
| | | } |
| | | |
| | | private AjaxResult isUseLisAndPacsRegister(TjOrder tjOrder, TjCustomer tjCustomer, TjReservation tjReservation, TjFlowingWater tjFlowingWater, SysUser sysUser, BigDecimal discount, String tjNumber) { |
| | | try { |
| | | log.info("签到登记进入未收费方法"); |
| | | // 这是上面个人方法引入数据 |
| | | tjFlowingWater.setPayStasus(1L); |
| | | newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater); |
| | | tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()), |
| | | sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString()); |
| | | List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber()); |
| | | xdPictureService.saveBatch(xdPictureList); |
| | | List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId()); |
| | | log.info("签到登记:采样数据查询个数"+detailList.size()); |
| | | addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null); |
| | | return AjaxResult.success(tjNumber); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) // 共享事务 |
| | | public void isRequestCommonHisApi(TjOrder tjOrder, TjCustomer tjCustomer, TjFlowingWater tjFlowingWater) { |
| | | private AjaxResult isRequestCommonHisApi(TjOrder tjOrder, TjCustomer tjCustomer, TjFlowingWater tjFlowingWater) { |
| | | String s = configService.selectConfigByKey("is_request_common_his_api"); |
| | | if (null != s && s.equals("Y")) { |
| | | String apiUrl = configService.selectConfigByKey("common_api_url"); |
| | |
| | | SysDept dept = sysDeptService.getOne(wrapper2); |
| | | |
| | | JSONObject obj = JSONUtil.createObj(); |
| | | // Integer sl = project.getSl(); |
| | | int sl = 1; |
| | | BigDecimal danjia = transition.getNowPrice(); |
| | | BigDecimal allPrice = danjia.multiply(new BigDecimal(sl)); |
| | |
| | | } |
| | | tjFlowingWaterService.updateById(tjFlowingWater); |
| | | } else { |
| | | log.error("isRequestCommonHisApi 方法异常"); |
| | | throw new RuntimeException("is_request_common_his_api 强制触发回滚"); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/importTemplate") |
| | | @ApiOperation(value = "导出excel表模板") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | String value = configService.selectConfigByKey("path_filePath"); |
| | | //原来的下载模板调用接口 |
| | | try { |
| | | String base64String = PDFBinaryUtil.getPDFBinary(value + File.separator + "西安路泰机电科技有限公司.xls"); |
| | | if (null != base64String) { |
| | | PDFBinaryUtil.base64StringToPDF(base64String, FileUtil.mkdir(value).getPath() + File.separator + "团体预约Excel模版.xls"); |
| | | String filePath = value + File.separator + "团体预约Excel模版.xls"; |
| | | File f = new File(filePath); |
| | | BufferedInputStream br = null; |
| | | OutputStream out = null; |
| | | FileInputStream fileInputStream = null; |
| | | try { |
| | | fileInputStream = new FileInputStream(f); |
| | | br = new BufferedInputStream(fileInputStream); |
| | | byte[] bs = new byte[1024]; |
| | | int len = 0; |
| | | response.reset(); // 非常重要 |
| | | if (true) { |
| | | // 在线打开方式 |
| | | URL u = new URL("file:///" + filePath); |
| | | //System.out.println(u); |
| | | String contentType = u.openConnection().getContentType(); |
| | | response.setContentType(contentType); |
| | | response.setHeader("Content-Disposition", "inline;filename=团体预约Excel模版.xls"); |
| | | } else { |
| | | // 纯下载方式 |
| | | response.setContentType("application/x-msdownload"); |
| | | response.setContentType("application/pdf;charset=utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=团体预约Excel模版.xls"); |
| | | } |
| | | out = response.getOutputStream(); |
| | | while ((len = br.read(bs)) > 0) { |
| | | out.write(bs, 0, len); |
| | | } |
| | | out.flush(); |
| | | out.close(); |
| | | br.close(); |
| | | fileInputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | //System.out.println("pdf处理文件异常" + e); |
| | | } finally { |
| | | if (out != null) { |
| | | try { |
| | | out.close(); |
| | | br.close(); |
| | | fileInputStream.close(); |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | ExcelUtils.exportTemplate(response,"团体预约Excel模版",TjReservation.class); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public String getAjaxResult(AjaxResult result) { |
| | | return result.get("data").toString(); |
| | | |
| | | @PostMapping("/newExcelImportNotDwDeptId") |
| | | @ApiOperation(value = "团体excel表导入 (新版本不传单位部门id)") |
| | | @Transactional |
| | | public AjaxResult newExcelImportNotDwDeptId(@RequestPart(value = "file") @ApiParam(value = "Excel文件") MultipartFile file, |
| | | @RequestParam @ApiParam(value = "单位id") String dwId) { |
| | | List<TjReservation> tjReservations = null; |
| | | try { |
| | | tjReservations = ExcelUtils.readMultipartFile(file, TjReservation.class); |
| | | } catch (Exception e) { |
| | | return AjaxResult.error("导入文件有误请检查导入文件!"); |
| | | } |
| | | int grouping = dwGroupingService.selectTjDwGroupingByDwId(dwId); |
| | | |
| | | if (grouping == 0) { |
| | | return AjaxResult.error("请检查该单位是否存否存在项目!"); |
| | | } |
| | | |
| | | public JSONObject getJSONObject(String builder) { |
| | | String Response = JSONUtil.parseObj(builder).getStr("Response"); |
| | | return JSONUtil.parseObj(Response); |
| | | List<String> wrongList = new ArrayList<>(); |
| | | List<TjReservation> rightList = new ArrayList<>(); |
| | | List<String> yyList = new ArrayList<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<TjDwGrouping> groupingMans = null;//男 |
| | | List<TjDwGrouping> groupingWoMans = null;//女 |
| | | List<TjDwGrouping> groupingWzs = null;//未知(不分性别) |
| | | try { |
| | | groupingMans = dwGroupingService.list(new LambdaQueryWrapper<TjDwGrouping>().eq(TjDwGrouping::getDwId, dwId) |
| | | .eq(TjDwGrouping::getSex, 0)); |
| | | groupingWoMans = dwGroupingService.list(new LambdaQueryWrapper<TjDwGrouping>().eq(TjDwGrouping::getDwId, dwId) |
| | | .eq(TjDwGrouping::getSex, 1)); |
| | | groupingWzs = dwGroupingService.list(new LambdaQueryWrapper<TjDwGrouping>().eq(TjDwGrouping::getDwId, dwId) |
| | | .eq(TjDwGrouping::getSex, 2)); |
| | | } catch (Exception e) { |
| | | return AjaxResult.error("分组信息有误请重新分组!"); |
| | | } |
| | | |
| | | try { |
| | | String sfjysfzh = configService.selectConfigByKey("sfjysfzh"); |
| | | String sfjysjh = configService.selectConfigByKey("sfjysjh"); |
| | | |
| | | //计算合计 |
| | | BigDecimal hjMoney = new BigDecimal("0.00"); |
| | | //男组金额 |
| | | BigDecimal manMoney = new BigDecimal("0.00"); |
| | | //女组金额 |
| | | BigDecimal woManMoney = new BigDecimal("0.00"); |
| | | int count = 0;//总计人数 |
| | | int manCount = 0;//男组人数 |
| | | int woManCount = 0;//女组人数 |
| | | List<String> ids = new ArrayList<>(); |
| | | |
| | | // String errMsg = ""; |
| | | for (TjReservation tjReservation : tjReservations) { |
| | | String name = tjReservation.getName(); |
| | | String idCard = tjReservation.getIdCard(); |
| | | String phoe = tjReservation.getPhoe(); |
| | | name = name.replaceAll("[',,;.。 ‘“]", "").replaceAll(" ", ""); |
| | | phoe = phoe.replaceAll("[',,;.。 ‘“]", "").replaceAll(" ", ""); |
| | | idCard = idCard.replaceAll("[',,;.。 ‘“]", "").replaceAll(" ", ""); |
| | | |
| | | if (!StringUtils.isBlank(idCard) || !StringUtils.isBlank(phoe) || null != tjReservation.getDwxm()) { |
| | | //将科学计数的手机号转换成文本形式 |
| | | phoe = MatchUtils.translateToPlainStr(tjReservation.getPhoe()); |
| | | |
| | | if (!ids.isEmpty() && ids.contains(idCard)) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return AjaxResult.error("此身份证号: " + tjReservation.getIdCard() + " 重复,请核对后上传!"); |
| | | } |
| | | |
| | | ids.add(idCard); |
| | | |
| | | if (!Objects.equals(tjReservation.getSex(), MatchUtils.getSexByIdCard(idCard))){ |
| | | wrongList.add(tjReservation.getName() + " " + tjReservation.getIdCard()+"以下人员性别 不准确"); |
| | | log.info(tjReservation.getName() + " " + idCard); |
| | | } |
| | | |
| | | if ((sfjysfzh.equalsIgnoreCase("Y") && !MatchUtils.isIdCard(idCard)) || |
| | | (sfjysjh.equalsIgnoreCase("Y") && !MatchUtils.isMobileNO(phoe))) { |
| | | wrongList.add(tjReservation.getName() + " " + tjReservation.getIdCard()+"身份证号/手机号 格式不准确"); |
| | | // errMsg = "身份证号/手机号 格式不准确"; |
| | | log.info(tjReservation.getName() + " " + idCard + MatchUtils.isIdCard(idCard) + " " + phoe + " " + MatchUtils.isMobileNO(phoe)); |
| | | } |
| | | // else { |
| | | |
| | | tjReservation.setPhoe(phoe); |
| | | |
| | | tjReservation.setName(name); |
| | | |
| | | tjReservation.setIdCard(idCard); |
| | | |
| | | //年龄 |
| | | tjReservation.setAge(String.valueOf(MatchUtils.getAgeByIdCard(tjReservation.getIdCard().replaceAll(" ", "")))); |
| | | //出生日期 |
| | | try { |
| | | tjReservation.setBirthday(MatchUtils.getBirthDayByIdCard(tjReservation.getIdCard().replaceAll(" ", ""))); |
| | | } catch (Exception e) { |
| | | // return AjaxResult.error("身份证号不正确"); |
| | | } |
| | | |
| | | TjDwDept dwDept = dwDeptService.getOne(new LambdaQueryWrapper<TjDwDept>(). |
| | | eq(TjDwDept::getDwDeptName, tjReservation.getDwxm().trim()).eq(TjDwDept::getDwId,dwId)); |
| | | if (null != dwDept) { |
| | | for (TjDwGrouping groupingMan : groupingMans) { |
| | | if (null != groupingMan && groupingMan.getSex().equals(String.valueOf(tjReservation.getSex())) && groupingMan.getDwDeptId().equals(dwDept.getId())) { |
| | | tjReservation.setGroupingId(groupingMan.getId()); |
| | | tjReservation.setGroupingName(groupingMan.getGroupingName()); |
| | | tjReservation.setYsPrice(groupingMan.getYsPrice()); |
| | | //合计 |
| | | hjMoney = hjMoney.add(groupingMan.getYsPrice()); |
| | | count += 1; |
| | | //男组人数 |
| | | manMoney = manMoney.add(groupingMan.getYsPrice()); |
| | | manCount += 1; |
| | | } |
| | | } |
| | | |
| | | for (TjDwGrouping groupingWoMan : groupingWoMans) { |
| | | if (null != groupingWoMan && groupingWoMan.getSex().equals(String.valueOf(tjReservation.getSex())) && groupingWoMan.getDwDeptId().equals(dwDept.getId())) { |
| | | tjReservation.setGroupingId(groupingWoMan.getId()); |
| | | tjReservation.setGroupingName(groupingWoMan.getGroupingName()); |
| | | tjReservation.setYsPrice(groupingWoMan.getYsPrice()); |
| | | //合计 |
| | | hjMoney = hjMoney.add(groupingWoMan.getYsPrice()); |
| | | count += 1; |
| | | woManMoney = woManMoney.add(groupingWoMan.getYsPrice()); |
| | | woManCount += 1; |
| | | } |
| | | } |
| | | for (TjDwGrouping groupingWz : groupingWzs) { |
| | | if (null != groupingWz && groupingWz.getDwDeptId().equals(dwDept.getId())) { |
| | | tjReservation.setGroupingId(groupingWz.getId()); |
| | | tjReservation.setGroupingName(groupingWz.getGroupingName()); |
| | | tjReservation.setYsPrice(groupingWz.getYsPrice()); |
| | | //合计 |
| | | hjMoney = hjMoney.add(groupingWz.getYsPrice()); |
| | | count += 1; |
| | | if (tjReservation.getSex() == 0) { |
| | | manMoney = manMoney.add(groupingWz.getYsPrice()); |
| | | manCount += 1; |
| | | } |
| | | if (tjReservation.getSex() == 1) { |
| | | woManMoney = woManMoney.add(groupingWz.getYsPrice()); |
| | | woManCount += 1; |
| | | } |
| | | |
| | | } |
| | | } |
| | | LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjReservation::getIdCard, tjReservation.getIdCard()); |
| | | wq.eq(TjReservation::getIsExpire, 2); |
| | | TjReservation one = tjReservationService.getOne(wq); |
| | | if (null != one) { |
| | | yyList.add(one.getName() + " " + tjReservation.getIdCard()); |
| | | } else { |
| | | rightList.add(tjReservation); |
| | | } |
| | | |
| | | } else { |
| | | wrongList.add(tjReservation.getName() + " " + tjReservation.getIdCard()+"所填写的套餐分类名 不正确"); |
| | | } |
| | | // } |
| | | |
| | | } |
| | | else { |
| | | wrongList.add(tjReservation.getName()+"身份证号/手机号/套餐分类名名为空"); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (!yyList.isEmpty()) { |
| | | map.put("list", yyList); |
| | | map.put("hjMoney", hjMoney); |
| | | return AjaxResult.error("操作失败,以上人员已经预约无需导入!!!", map); |
| | | } |
| | | |
| | | if (!wrongList.isEmpty()) { |
| | | map.put("list", wrongList); |
| | | map.put("hjMoney", hjMoney); |
| | | return AjaxResult.error("操作失败, 请认真核对错误信息后重新导入!!!", map); |
| | | } else { |
| | | map.put("list", rightList); |
| | | map.put("count", count); |
| | | map.put("hjMoney", hjMoney); |
| | | map.put("manCount", manCount); |
| | | map.put("manMoney", manMoney); |
| | | map.put("woManCount", woManCount); |
| | | map.put("woManMoney", woManMoney); |
| | | return AjaxResult.success("操作成功", map); |
| | | } |
| | | } catch (NoTransactionException e) { |
| | | // throw new RuntimeException(e); |
| | | log.error(String.valueOf(e), e.getMessage()); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/newReservationConfirmxbb") |
| | | @ApiOperation(value = "团体预约确认接口 (新版本)") |
| | | @Transactional |
| | | @RepeatSubmit |
| | | public AjaxResult newReservationConfirmxbb(@RequestBody ConfirmDto dto) { |
| | | //预约的所有人 |
| | | List<TjReservation> rightList = dto.getReservations(); |
| | | |
| | | //预约时间 |
| | | String reservationTime = dto.getReservationTime(); |
| | | if (null == reservationTime) { |
| | | return AjaxResult.error("请选择预约时间!"); |
| | | } |
| | | |
| | | Date date = new Date(); |
| | | |
| | | //异步数据 |
| | | // asyncService.addNewReservationConfirm(rightList); |
| | | asyncService.saveNewReservationConfirm(rightList); |
| | | |
| | | //体检单位部门 |
| | | DictComp comp = compService.getById(dto.getDwId()); |
| | | |
| | | String teamNo = PinyinUtil.getFirstLetter(comp.getCnName(), "") + DateUtil.format(date, "yyMMddHHmmss"); |
| | | |
| | | //团体人数合计价格 |
| | | BigDecimal compPay = new BigDecimal("0.00"); |
| | | |
| | | String payTypeGlTjType = configService.selectConfigByKey("reservation_pay_type_gl_tj_type"); |
| | | JSONObject parseObj = JSONUtil.parseObj(payTypeGlTjType); |
| | | if (null != rightList && !rightList.isEmpty()) { |
| | | |
| | | List<String> ids=new ArrayList<>(); |
| | | |
| | | for (TjReservation reservation : rightList) { |
| | | |
| | | if(!ids.isEmpty() && ids.contains(reservation.getIdCard())){ |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return AjaxResult.error("此身份证号: "+reservation.getIdCard()+" 重复,请核对后上传!"); |
| | | |
| | | } |
| | | reservation.setName(reservation.getName().replaceAll(" ","").replaceAll(" ","")); |
| | | ids.add(reservation.getIdCard()); |
| | | |
| | | TjDwGrouping dwGrouping = dwGroupingService.getById(reservation.getGroupingId()); |
| | | |
| | | if(null !=dwGrouping){ |
| | | TjDwDept dwDept = dwDeptService.getById(dwGrouping.getDwDeptId()); |
| | | |
| | | LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjReservation::getIdCard, reservation.getIdCard()); |
| | | wq.eq(TjReservation::getIsExpire, 2); |
| | | TjReservation one = tjReservationService.getOne(wq); |
| | | if (null != one) { |
| | | continue; |
| | | } |
| | | LambdaQueryWrapper<TjGroupingPro> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjGroupingPro::getGroupingId, reservation.getGroupingId()); |
| | | List<String> proIds = groupingProService.list(wq1).stream().map(TjGroupingPro::getProId).collect(Collectors.toList()); |
| | | reservation.setProIds(Joiner.on(",").join(proIds)); |
| | | reservation.setReservationTime(DateUtil.parse(reservationTime, "yyyy-MM-dd")); |
| | | reservation.setCompanyId(dwGrouping.getDwId()); |
| | | reservation.setCompany(dwGrouping.getDwName()); |
| | | reservation.setPayType(Long.valueOf(dwGrouping.getPayType())); |
| | | LambdaQueryWrapper<SysDictData> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(SysDictData::getDictType, "reservation_pay_type"); |
| | | wrapper.eq(SysDictData::getDictValue, reservation.getPayType()); |
| | | SysDictData dictData = dictDataService.getOne(wrapper); |
| | | for (Map.Entry<String, Object> entry : parseObj.entrySet()) { |
| | | String[] split = entry.getValue().toString().split("-"); |
| | | if (split[0].equals(String.valueOf(dictData.getDictCode()))) { |
| | | reservation.setTjType(dictDataService.selectDictDataById(Long.valueOf(split[1])).getDictValue()); |
| | | } |
| | | } |
| | | |
| | | |
| | | reservation.setPacId(dwDept.getId()); |
| | | compPay = compPay.add(dwGrouping.getYsPrice()); |
| | | // reservation.setTjType(String.valueOf(1)); |
| | | reservation.setTeamNo(teamNo); |
| | | reservation.setYxts(dto.getYxts()); |
| | | tjReservationService.save(reservation); |
| | | taskService.addTask(new TjReservationTask(reservation.getId(), |
| | | DateUtil.between(date, DateUtil.endOfDay(DateUtil.offsetDay(reservation.getReservationTime(), dto.getYxts())), DateUnit.MS))); |
| | | } |
| | | } |
| | | |
| | | LambdaQueryWrapper<TjCompPay> wq0 = new LambdaQueryWrapper<>(); |
| | | wq0.eq(TjCompPay::getCompId, dto.getDwId()); |
| | | wq0.eq(TjCompPay::getTeamNo, teamNo); |
| | | TjCompPay one = compPayService.getOne(wq0); |
| | | if (null != one) { |
| | | one.setCopeWith(compPay); |
| | | one.setSerialNumber(SecurityUtils.getUsername() + DateUtil.format(date, "yyMMddHHmmssSSS")); |
| | | one.setInvoiceNo("FP" + DateUtil.format(date, "yyMMddHHmmssSSS")); |
| | | one.setPaidIn(new BigDecimal("0.00")); |
| | | compPayService.updateById(one); |
| | | } else { |
| | | TjCompPay tjCompPay = new TjCompPay(); |
| | | tjCompPay.setCompId(dto.getDwId()); |
| | | tjCompPay.setTeamNo(teamNo); |
| | | tjCompPay.setCopeWith(compPay); |
| | | tjCompPay.setSerialNumber(SecurityUtils.getUsername() + DateUtil.format(date, "yyMMddHHmmssSSS")); |
| | | tjCompPay.setInvoiceNo("FP" + DateUtil.format(date, "yyMMddHHmmssSSS")); |
| | | tjCompPay.setPaidIn(new BigDecimal("0.00")); |
| | | tjCompPay.setDifference(tjCompPay.getCopeWith().subtract(BigDecimal.valueOf(0.00))); |
| | | compPayService.save(tjCompPay); |
| | | } |
| | | |
| | | // .filter(a-> null != a.getPacId()) |
| | | |
| | | Map<String, List<TjReservation>> collect = rightList.stream().collect(Collectors.groupingBy(TjReservation::getPacId)); |
| | | |
| | | if (!collect.isEmpty()) { |
| | | for (Map.Entry<String, List<TjReservation>> entry : collect.entrySet()) { |
| | | LambdaQueryWrapper<TjTeamSelectRecord> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjTeamSelectRecord::getTeamNo, teamNo); |
| | | wq.eq(TjTeamSelectRecord::getCompId, dto.getDwId()); |
| | | TjTeamSelectRecord recordServiceOne = selectRecordService.getOne(wq); |
| | | if (null != recordServiceOne) { |
| | | recordServiceOne.setPacId(entry.getKey()); |
| | | recordServiceOne.setCompId(dto.getDwId()); |
| | | recordServiceOne.setTeamNo(teamNo); |
| | | recordServiceOne.setTransactionAmount(new BigDecimal("0.00")); |
| | | recordServiceOne.setCount(entry.getValue().size()); |
| | | recordServiceOne.setDifference(compPay); |
| | | selectRecordService.updateById(recordServiceOne); |
| | | } else { |
| | | TjTeamSelectRecord selectRecord = new TjTeamSelectRecord(); |
| | | selectRecord.setCompId(dto.getDwId()); |
| | | selectRecord.setPacId(entry.getKey()); |
| | | selectRecord.setTeamNo(teamNo); |
| | | selectRecord.setTransactionAmount(new BigDecimal("0.00")); |
| | | selectRecord.setCount(entry.getValue().size()); |
| | | selectRecord.setDifference(compPay); |
| | | selectRecordService.save(selectRecord); |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.success("预约成功"); |
| | | } |
| | | return AjaxResult.error("请选择预约对象"); |
| | | } |
| | | |
| | | } |