package com.hx.phip.controller.deduction; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hx.common.BaseController; import com.hx.exception.TipsException; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.common.DeductionSingleConstants; import com.hx.phiappt.constants.tool.PerformanceInfoTool; import com.hx.phiappt.constants.tool.user.UserProjectTool; import com.hx.phiappt.dao.mapper.IntroProjectManualMapper; import com.hx.phiappt.dao.mapper.NotificationLogMapper; import com.hx.phiappt.dao.mapper.ProjectMapper; import com.hx.phiappt.model.*; import com.hx.phiappt.model.deduction.*; import com.hx.phiappt.model.intro.IntroProjectManual; import com.hx.phiappt.model.performance.PerformanceInfo; import com.hx.phiappt.model.project.ProjectGeneral; import com.hx.phip.config.CustomParameter; import com.hx.phip.dao.mapper.ProjectGeneralMapper; import com.hx.phip.dao.mapper.ShopMapper; import com.hx.phip.dao.mapper.UserMapper; import com.hx.phip.service.ComparePhotoRecordPicturesService; import com.hx.phip.service.ComparePhotoRecordService; import com.hx.phip.service.deduction.*; import com.hx.resultTool.Result; import com.hx.util.HttpServletRequestUtil; import com.hx.util.StringUtils; import com.hx.util.thread.ExecutorServiceTool; import com.hz.his.dto.deduction.DeductionDto; import com.platform.constants.LoginConstant; import com.platform.entity.ThirtApplication; import com.platform.exception.PlatTipsException; import com.platform.resultTool.PlatformCode; import com.platform.resultTool.PlatformResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 执行划扣控制器 * * @USER: Andru * @DATE: 2021/12/10 */ @RestController @RequestMapping("/deduction") public class DeductionController extends BaseController { //log4j日志 private static final Logger logger = LoggerFactory.getLogger(DeductionController.class.getName()); /**固定线程池-改*/ public static ExecutorServiceTool threadPool = new ExecutorServiceTool(10,200); @Resource private CustomParameter customParameter; @Resource private DeductionSingleService deductionSingleService; @Resource private DeductionProjectService deductionProjectService; @Resource private DeductionJoinService deductionJoinService; @Resource private DeductionSignService deductionSignService; @Resource private DeductionDrugsService deductionDrugsService; @Resource private DeductionDeviceParameterService deductionDeviceParameterService; @Resource private ComparePhotoRecordService comparePhotoRecordService; @Resource private ComparePhotoRecordPicturesService comparePhotoRecordPicturesService; /** * 获取划扣清单id * @param param 参数值 * @return id */ private String getId(String param) { JSONObject jsonObject = JSONObject.parseObject(param); if (jsonObject == null || !jsonObject.containsKey("deductionSingleId")) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "参数不能为空不能为空"); } // 获取接收的对象 return jsonObject.getString("deductionSingleId"); } /** * 校验参数 * @param deductionDto 参数对象 */ private void checkParam(DeductionDto deductionDto) { if (StringUtils.isEmpty(deductionDto.getUserProjectId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "userProjectId不能为空"); } if (deductionDto.getDeductionNum() <= 0) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "数量/划扣次数需要大于0"); } /* if (deductionDto.getExecuteStartTime() == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "执行开始时间不内为空!"); } if (deductionDto.getExecuteEndTime() == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "执行结束时间不内为空!"); } */ } /** * 查看记录 */ @RequestMapping(value = "/see", method = RequestMethod.POST) public Result seeData(HttpServletRequest request, @RequestBody String param) { // 获取接收的参数里面的id String deductionSingleId = getId(param); // 获取用户信息 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!"); } Map mapData = new HashMap<>(); DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(deductionSingleId); if (deductionSingle != null) { // 划扣记录 mapData.put("deductionSingle", deductionSingle); // 项目划扣 DeductionProject deductionProject = deductionProjectService.selectOneByDeductionSingleId(deductionSingle.getId()); mapData.put("deductionProject", deductionProject); if (deductionProject != null) { // 参与人员信息 List deductionJoinList = deductionJoinService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId()); mapData.put("deductionJoinList", deductionJoinList); // 消耗物品信息 List deductionDrugsList = deductionDrugsService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId()); mapData.put("deductionDrugsList", deductionDrugsList); // 治疗参数(设备)信息 List deductionDeviceParameterList = deductionDeviceParameterService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId()); mapData.put("deductionDeviceParameterList", deductionDeviceParameterList); // 客户签名信息 List deductionSignList = deductionSignService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId()); mapData.put("deductionSignList", deductionSignList); // 治疗图片 ComparePhotoRecord comparePhotoRecord = comparePhotoRecordService.selectOneByDeductionSingleId(deductionSingle.getId(), deductionProject.getId()); if (comparePhotoRecord != null) { List comparePhotoRecordPicturesList = comparePhotoRecordPicturesService.selectListByComparePhotoRecordId(comparePhotoRecord.getId()); mapData.put("comparePhotoRecordPicturesList", comparePhotoRecordPicturesList); } else { mapData.put("comparePhotoRecordPicturesList", null); } } } return Result.success(mapData); } /** * 新增划扣记录 */ @RequestMapping(value = "/add", method = RequestMethod.POST) public Result addData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) { logger.info("新增划扣记录打印入参数据:"+ JSONObject.toJSONString(deductionDto)); // 校验参数 checkParam(deductionDto); // 获取用户信息 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!"); } // 填充接口登入信息 deductionDto.setAppId(thirtApplication.getAppId()); deductionDto.setAppIdCode(thirtApplication.getAppIdCode()); deductionDto.setSourceCode(thirtApplication.getAppId()); deductionDto.setSourceName(thirtApplication.getName()); // 添加数据 String id = deductionSingleService.editInfo(deductionDto, BaseEntity.YES); logger.info("多线程队列数DeductionController-1:{}", threadPool.getThreadPool().getQueue().size()); // 判断是否发送消息 if (BaseEntity.YES == deductionDto.getIsSentNotice()) { // 发送公众号确认消息 threadPool.getThreadPool().execute(() -> deductionSingleService.sendConfirmNotice(id)); // 发送划扣成功调查问卷 threadPool.getThreadPool().execute(() -> deductionSingleService.sendGZHQuestionnaire(id)); } // 计算新增划扣业绩信息 threadPool.getThreadPool().execute(() -> this.handlerPerformanceInfoDeduction(id, BaseEntity.YES)); // 划扣自动打标签处理 threadPool.getThreadPool().execute(() -> deductionSingleService.autoTag(id)); // 处理保妥适俱乐部权益 threadPool.getThreadPool().execute(() -> deductionSingleService.handleBotoxClub(id)); // 返回id return Result.success(id); } /** * 新增划扣记录(Phitab数据划扣) */ @RequestMapping(value = "/add/phitab", method = RequestMethod.POST) public Result addPhitabData(@RequestBody DeductionDto deductionDto) { logger.info("新增划扣记录(Phitab)打印入参数据:"+ JSONObject.toJSONString(deductionDto)); // 校验参数 checkParam(deductionDto); // 填充接口登入信息 deductionDto.setAppId("phitab"); deductionDto.setAppIdCode("phitab"); deductionDto.setSourceCode("phitab"); deductionDto.setSourceName("phitab"); // 添加数据 String id = deductionSingleService.addInfoPhitab(deductionDto); // 返回id return Result.success(id); } /** * 新增划扣记录 直接划扣his系统 */ //@RequestMapping(value = "/add", method = RequestMethod.POST) public Result addHisData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) { // 获取用户信息 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!"); } // 填充接口登入信息 deductionDto.setAppId(thirtApplication.getAppId()); deductionDto.setAppIdCode(thirtApplication.getAppIdCode()); deductionDto.setSourceCode(thirtApplication.getAppId()); deductionDto.setSourceName(thirtApplication.getName()); // 校验参数 if (StringUtils.isEmpty(deductionDto.getUserProjectId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "userProjectId不能为空"); } if (StringUtils.isEmpty(deductionDto.getShopId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "userProjectId不能为空"); } if (deductionDto.getDeductionNum() <= 0) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "数量/划扣次数需要大于0"); } // 划扣成功返回hisId //String id = deductionSingleService.hisDeduction(deductionDto); String id = ""; return Result.success(id); } /** * 批量新增划扣记录 */ @RequestMapping(value = "/batch/add", method = RequestMethod.POST) public Result batchAddData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) { logger.info("批量新增划扣记录打印入参数据:"+ JSONObject.toJSONString(deductionDto)); // 获取用户信息 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!"); } // 填充接口登入信息 deductionDto.setAppId(thirtApplication.getAppId()); deductionDto.setAppIdCode(thirtApplication.getAppIdCode()); deductionDto.setSourceCode(thirtApplication.getAppId()); deductionDto.setSourceName(thirtApplication.getName()); // 判断 批量添加项目id列表 是否为空 if (StringUtils.isEmpty(deductionDto.getUserProjectIds())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "批量添加项目id列表不能为空"); } // 解析批量id List userProjectIdList = JSONArray.parseArray(deductionDto.getUserProjectIds(), String.class); // 判断是否传值 if (userProjectIdList == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "用户项目id列表不能为空!"); } // 批量划扣 for (String userProjectId : userProjectIdList) { deductionDto.setUserProjectId(userProjectId); // 添加数据 String id = deductionSingleService.editInfo(deductionDto, BaseEntity.YES); // 切换领建屏蔽代码 date:20230108 /*// 参数构造 DeductionDto paramDeductionDto = new DeductionDto(); paramDeductionDto.setDeductionSingleId(id); // 同步划扣记录到his系统 String returnData; try { returnData = ApiPlatformUtil.syncHisDeduction(customParameter, id); } catch (Exception ex) { logger.error("同步划扣数据到his系统失败!", ex); // his操作失败删除记录 deductionSingleService.deleteOne(paramDeductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL); throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回错误消息:" + ex.getMessage()); } // 处理返回消息 if (!StringUtils.isEmpty(returnData)) { JSONObject jsonObject = JSONObject.parseObject(returnData); String code = jsonObject.getString("code"); if (!"100".equals(code)) { String error = jsonObject.getString("msg"); // his操作失败删除记录 deductionSingleService.deleteOne(paramDeductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL); throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回错误消息:" + error); } else { String hisId = jsonObject.getString("data"); if (!StringUtils.isEmpty(hisId)) { SqlSentence sqlSentence = new SqlSentence(); String sql = String.format(" hisId='%s' WHERE isDel = 0 AND id ='%s'", hisId, id); sqlSentence.setSqlSentence(sql); deductionSingleService.updateWhere(sqlSentence); } } } else { deductionSingleService.deleteOne(paramDeductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL); throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回空消息!"); }*/ } return Result.success(); } /** * 修改划扣记录 注释划扣没有编辑功能 */ @RequestMapping(value = "/update", method = RequestMethod.POST) public Result updateData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) { logger.info("修改划扣记录打印入参数据:"+ JSONObject.toJSONString(deductionDto)); // 判断deductionSingleId 是否为空 if (StringUtils.isEmpty(deductionDto.getDeductionSingleId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空"); } // 校验参数 checkParam(deductionDto); // 获取用户信息 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!"); } // 填充接口登入信息 deductionDto.setAppId(thirtApplication.getAppId()); deductionDto.setAppIdCode(thirtApplication.getAppIdCode()); deductionDto.setSourceCode(thirtApplication.getAppId()); deductionDto.setSourceName(thirtApplication.getName()); // 添加数据 deductionSingleService.editInfo(deductionDto, BaseEntity.NO); return Result.success(); } /** * 删除记录 */ @RequestMapping(value = "/delete", method = RequestMethod.POST) public Result deleteData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) { logger.info("删除划扣记录接口打印入参数据:"+ JSONObject.toJSONString(deductionDto)); // 判断deductionSingleId 是否为空 if (StringUtils.isEmpty(deductionDto.getDeductionSingleId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空"); } // 判断操作人id 是否为空 if (StringUtils.isEmpty(deductionDto.getOperatorId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "operatorId不能为空"); } // 验签数据 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!"); } // 删除数据 deductionSingleService.deleteOne(deductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL, BaseEntity.NO); logger.info("多线程队列数DeductionController-2:{}", threadPool.getThreadPool().getQueue().size()); // 计算撤销或删除划扣业绩信息 threadPool.getThreadPool().execute(() -> this.handlerPerformanceInfoDeduction(deductionDto.getDeductionSingleId(), BaseEntity.NO)); // 划扣自动打标签处理 threadPool.getThreadPool().execute(() -> deductionSingleService.autoTag(deductionDto.getDeductionSingleId())); // 返回 return Result.success(); } /** * 作废记录 */ @RequestMapping(value = "/rescinded", method = RequestMethod.POST) public Result rescindedData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) { logger.info("撤销划扣记录接口打印入参数据:"+ JSONObject.toJSONString(deductionDto)); // 判断deductionSingleId 是否为空 if (StringUtils.isEmpty(deductionDto.getDeductionSingleId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空"); } // 判断操作人id 是否为空 if (StringUtils.isEmpty(deductionDto.getOperatorId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "operatorId不能为空"); } // 验签数据 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!"); } // 删除数据 deductionSingleService.deleteOne(deductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_RESCINDED, BaseEntity.NO); logger.info("多线程队列数DeductionController-3:{}", threadPool.getThreadPool().getQueue().size()); // 计算撤销或删除划扣业绩信息 threadPool.getThreadPool().execute(() -> this.handlerPerformanceInfoDeduction(deductionDto.getDeductionSingleId(), BaseEntity.NO)); // 划扣自动打标签处理 threadPool.getThreadPool().execute(() -> deductionSingleService.autoTag(deductionDto.getDeductionSingleId())); // 保妥适俱乐部撤回赠送优惠券 threadPool.getThreadPool().execute(() -> deductionSingleService.cancelDeductionSingleCoupon(deductionDto.getDeductionSingleId())); // 返回 return Result.success(); } /** * 作废记录(不退回库存) */ @RequestMapping(value = "/rescinded/not/stock", method = RequestMethod.POST) public Result rescindedNotStockData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) { logger.info("撤销划扣记录(不退回库存)接口打印入参数据:" + JSONObject.toJSONString(deductionDto)); // 判断deductionSingleId 是否为空 if (StringUtils.isEmpty(deductionDto.getDeductionSingleId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空"); } // 判断操作人id 是否为空 if (StringUtils.isEmpty(deductionDto.getOperatorId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "operatorId不能为空"); } // 验签数据 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!"); } // 删除数据 deductionSingleService.deleteOne(deductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_RESCINDED, BaseEntity.YES); logger.info("多线程队列数DeductionController-4:{}", threadPool.getThreadPool().getQueue().size()); // 计算撤销或删除划扣业绩信息 threadPool.getThreadPool().execute(() -> this.handlerPerformanceInfoDeduction(deductionDto.getDeductionSingleId(), BaseEntity.NO)); return Result.success(); } /** * 同步划扣到his系统 */ @RequestMapping(value = "/sync/deduction/his", method = RequestMethod.POST) public PlatformResult syncToHis(HttpServletRequest request) { // 获取返回参数 String bodyData = HttpServletRequestUtil.getBody(request); if (StringUtils.isEmpty(bodyData)) { throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "数据格式错误"); } // 获取传参 JSONObject jsonObject = JSONObject.parseObject(bodyData); if (jsonObject == null || !jsonObject.containsKey("deductionSingleId")) { throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "参数错误!"); } String deductionSingleId = jsonObject.getString("deductionSingleId"); if (StringUtils.isEmpty(deductionSingleId)) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "划扣记录id不能为空!"); } DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(deductionSingleId); if (deductionSingle == null) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到划扣记录!"); } else { if (!StringUtils.isEmpty(deductionSingle.getHisId())) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "您的记录已同步,请不要重复同步划扣记录!"); } } // 切换领建屏蔽代码 date:20230108 /*// 同步划扣记录到his系统 String returnHisData; try { returnHisData = ApiPlatformUtil.syncHisDeduction(customParameter, deductionSingleId); } catch (Exception ex) { logger.error("同步划扣数据到his系统失败!", ex); throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回错误消息:" + ex.getMessage()); } if (!StringUtils.isEmpty(returnHisData)) { JSONObject jsonHisObject = JSONObject.parseObject(returnHisData); String code = jsonHisObject.getString("code"); if (!"100".equals(code)) { String error = jsonHisObject.getString("msg"); throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回错误消息:" + error); } else { String hisId = jsonHisObject.getString("data"); if (!StringUtils.isEmpty(hisId)) { SqlSentence sqlSentence = new SqlSentence(); String sql = String.format(" hisId='%s' WHERE isDel = 0 AND id ='%s'", hisId, deductionSingleId); sqlSentence.setSqlSentence(sql); deductionSingleService.updateWhere(sqlSentence); } } } else { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回空消息!"); }*/ return PlatformResult.success(); } /** * 同步修改划扣到his系统 */ @RequestMapping(value = "/sync/edit/deduction/his", method = RequestMethod.POST) public PlatformResult syncEditHis(HttpServletRequest request) { // 获取返回参数 String bodyData = HttpServletRequestUtil.getBody(request); if (StringUtils.isEmpty(bodyData)) { throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "数据格式错误"); } // 获取传参 JSONObject jsonObject = JSONObject.parseObject(bodyData); if (jsonObject == null || !jsonObject.containsKey("deductionSingleId")) { throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "参数错误!"); } String deductionSingleId = jsonObject.getString("deductionSingleId"); if (StringUtils.isEmpty(deductionSingleId)) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "划扣记录id不能为空!"); } DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(deductionSingleId); if (deductionSingle == null) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到划扣记录!"); } // 切换领建屏蔽代码 date:20230108 /*// 同步操作到领建 deductionSingleService.syncEditHisDeduction(deductionSingle.getId());*/ // 返回 return PlatformResult.success(); } /** * 查看his划扣接口 */ @RequestMapping(value = "/sync/executionRecord/get/obtain", method = RequestMethod.POST) public PlatformResult syncToHis(HttpServletRequest request,@RequestBody(required = false) DeductionDto dto) { if (dto==null) { throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "数据格式异常"); } ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!"); } if(StringUtils.isEmpty(dto.getUserId())){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "用户标识未空"); } if(StringUtils.isEmpty(dto.getShopId())){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "门店标识未空"); } SqlSentence sqlSentence = new SqlSentence(); Map map=new HashMap<>(); sqlSentence.setM(map); map.put("isDel",BaseEntity.NO); map.put("userId",dto.getUserId()); map.put("shopId",dto.getShopId()); User user=commonService.selectOneByKey(UserMapper.class,dto.getUserId()); if(user==null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "该用户不存在"); } Shop shop=commonService.selectOneByKey(ShopMapper.class,dto.getShopId()); if(shop==null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "该门店不存在"); } // 切换领建屏蔽代码 date:20230108 /*JSONObject param =new JSONObject(); param.put("clinicId",shop.getApiId()); param.put("customerId",user.getApiId()); param.put("page",dto.getPage()==null?0:dto.getPage()); param.put("size",dto.getSize()==null?20:dto.getSize()); param.put("start",dto.getLogStartTime()); param.put("end",dto.getLogEndTime()); String returnData = ApiPlatformUtil.executionRecordLog(customParameter, param); if(StringUtils.noNull(returnData)){ JSONObject jsonObject = JSONObject.parseObject(returnData); String code = jsonObject.getString("code"); if("100".equals(code)){ String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"同步中心-查看划扣日志操作:返回data没有数据"); } JSONObject contentsObject = JSONObject.parseObject(data); JSONObject object; JSONArray jsonArray=new JSONArray(); if(contentsObject!=null){ JSONArray contentList = contentsObject.getJSONArray("content"); if(contentList!=null || contentList.size()>0){ for(int i=0;i data = deductionSingleService.customerConfirmBefore(dto, deductionSingle); // 返回 return PlatformResult.success(data); } /** * 划扣客户确认之前页面所有未确认数据 */ @RequestMapping(value = "/customer/confirm/all/before", method = RequestMethod.POST) public PlatformResult customerConfirmAllBefore(HttpServletRequest request, @RequestBody DeductionDto dto) { if (dto == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传划扣参数"); } ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "签名失败,请检查签名!"); } if (StringUtils.isEmpty(dto.getUserId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传用户id参数"); } logger.info("打印客户确认划扣之前页面所有数据接口参数:{}", JSONObject.toJSONString(dto)); // 校验参数 User user = commonService.selectOneByKey(UserMapper.class, dto.getUserId()); if (user == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "划用户不存在"); } // 返回数据处理 List> list = new ArrayList<>(); // 获取数据处理 SqlSentence sqlSentence = new SqlSentence(); Map sqlValues = new HashMap<>(); sqlValues.put("isDel", BaseEntity.NO); sqlValues.put("userId", dto.getUserId()); sqlValues.put("isCustomerConfirm", BaseEntity.NO); sqlValues.put("status", DeductionSingleConstants.STATUS_DONE_EXECUTE); String sql = "SELECT * FROM deduction_single WHERE userId=#{m.userId} AND status=#{m.status} " + "AND isCustomerConfirm=#{m.isCustomerConfirm} AND isDel=#{m.isDel} ORDER BY createTime DESC"; sqlSentence.sqlSentence(sql, sqlValues); List deductionSingleList = deductionSingleService.selectList(sqlSentence); if (deductionSingleList != null && deductionSingleList.size() > 0) { for (DeductionSingle deductionSingle : deductionSingleList) { // 数据查询 Map data = deductionSingleService.customerConfirmBefore(dto, deductionSingle); if (data != null && data.size() > 0) { list.add(data); } } } // 返回 return PlatformResult.success(list); } /** * 划扣计算业绩信息 * @param deductionSingleId 划扣id * @param type 是否 新增划扣 0 否(撤销划扣) 1 是(新增划扣) */ private synchronized void handlerPerformanceInfoDeduction(String deductionSingleId, Integer type) { try { deductionSingleService.handlerPerformanceInfoDeduction(deductionSingleId, type); } catch (Exception ex) { // 打印日志 logger.error("划扣计算业绩信息出现错误,划扣id:{},错误信息:{}", deductionSingleId, ex); // 添加错误日志 PerformanceInfoTool.addErrorLog(commonService, deductionSingleId, PerformanceInfo.ASSOCIATION_TYPE_DEDUCTION, ex.getMessage()); // 企业微信错误提示 deductionSingleService.performanceInfoErrorTips(deductionSingleId, ex.getMessage()); } } /** * 获取用户划扣信息之前医生信息 */ @RequestMapping(value = "/project/before/doctor/info", method = RequestMethod.POST) public Result projectBeforeDoctorInfo(@RequestBody(required = false) DeductionDto dto) { if (dto == null) { throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "数据格式错误"); } if (StringUtils.isEmpty(dto.getUserId())) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "请传用户id!"); } // 判断用户信息 User user = commonService.selectOneByKey(UserMapper.class, dto.getUserId()); if (user == null) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到用户!"); } // 项目id数据 if (dto.getProjectIds() == null || dto.getProjectIds().size() < 1) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "请传项目id数据!"); } // 获取数据并返回处理 List> list = new ArrayList<>(); for (String projectId : dto.getProjectIds()) { // 获取数据处理 SqlSentence sqlSentence = new SqlSentence(); Map sqlValues = new HashMap<>(); sqlValues.put("isDel", BaseEntity.NO); sqlValues.put("userId", dto.getUserId()); sqlValues.put("projectId", projectId); sqlValues.put("status", DeductionSingleConstants.STATUS_DONE_EXECUTE); String sql = "SELECT dp.projectId,dp.projectName,dp.departmentId,dp.departmentCode,dp.departmentName,dp.primaryDoctorId,dp.primaryDoctorName," + "dp.treatmentDoctorId,dp.treatmentDoctorName FROM deduction_single AS ds LEFT JOIN deduction_project AS dp " + "ON dp.deductionSingleId=ds.id WHERE ds.userId=#{m.userId} AND ds.status=#{m.status} AND dp.projectId=#{m.projectId} " + "AND ds.isDel=#{m.isDel} ORDER BY ds.createTime DESC LIMIT 1"; sqlSentence.sqlSentence(sql, sqlValues); Map map = deductionProjectService.selectOneMap(sqlSentence); if (map != null) { list.add(map); } } // 返回数据 return Result.success(list); } /** * 划扣术后提示卡通知获取数据 */ @RequestMapping(value = "/postoperative/card/info", method = RequestMethod.POST) public PlatformResult postoperativeCardInfo(HttpServletRequest request, @RequestBody DeductionDto dto) { if (dto == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传参数"); } ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "签名失败,请检查签名!"); } if (StringUtils.isEmpty(dto.getCommonId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传id参数"); } logger.info("打印划扣术后提示卡通知获取数据接口参数:{}", JSONObject.toJSONString(dto)); // 校验参数 NotificationLog notificationLog = commonService.selectOneByKey(NotificationLogMapper.class, dto.getCommonId()); if (notificationLog == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "数据不存在"); } // 获取项目信息 JSONArray projectIdList; try { projectIdList = JSONArray.parseArray(notificationLog.getOtherInfo()); } catch (Exception ex) { throw new TipsException("解析项目信息列表出现异常!"); } // 判断是否有项目信息 if (projectIdList.size() <= 0) { throw new TipsException("解析项目信息列表不能为空!"); } // 获取数据并返回处理 List> list = new ArrayList<>(); // 查询数据 SqlSentence sqlSentence = new SqlSentence(); Map sqlValues = new HashMap<>(); sqlValues.put("isDel", BaseEntity.NO); StringBuilder sql = new StringBuilder(); // 获取查询数据 StringBuilder sqlIn = new StringBuilder(); for (int i = 0; i < projectIdList.size(); i++) { // 拼接数据 String projectId = projectIdList.getString(i); if (!StringUtils.isEmpty(projectId)) { sqlIn.append("'").append(projectId).append("'"); // 添加逗号符号分隔 if (i != projectIdList.size() - 1) { sqlIn.append(","); } } } sql.append(" SELECT * FROM project WHERE id IN (").append(sqlIn).append(") AND isDel=#{m.isDel} ORDER BY createTime ASC"); sqlSentence.sqlSentence(sql.toString(), sqlValues); List projectList = commonService.selectList(ProjectMapper.class, sqlSentence); if (projectList != null && projectList.size() > 0) { for (Project project : projectList) { // 返回数据 Map data = new HashMap<>(); data.put("projectId", project.getId()); data.put("projectName", project.getName()); data.put("postoperativeCardUrl", ""); // 获取术后提示卡信息 IntroProjectManual introProjectManual = UserProjectTool.getIntroProjectManualByProject(commonService, project); if (introProjectManual != null && !StringUtils.isEmpty(introProjectManual.getContent())) { data.put("postoperativeCardUrl", introProjectManual.getContent()); } list.add(data); } } // 返回 return PlatformResult.success(list); } }