| | |
| | | import com.kidgrow.common.constant.CommonConstant; |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.common.model.*; |
| | | import com.kidgrow.common.utils.AesUtils; |
| | | import com.kidgrow.common.utils.DateUtils; |
| | | import com.kidgrow.oprationcenter.model.HospitalInfo; |
| | | import com.kidgrow.oprationcenter.model.ProductOrder; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.validation.Valid; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | |
| | |
| | | private IProductOrderService productOrderService; |
| | | @Autowired |
| | | private SysUserService sysUserServiceFeign; |
| | | |
| | | /** |
| | | * 列表 |
| | | */ |
| | |
| | | } |
| | | return productOrderDetailService.all(params); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | */ |
| | |
| | | } |
| | | return productOrderDetailService.groupList(params); |
| | | } |
| | | |
| | | /** |
| | | * 查询到期列表 |
| | | */ |
| | |
| | | } |
| | | return productOrderDetailService.productEndList(params); |
| | | } |
| | | |
| | | /** |
| | | * 获取医院套餐是否到期和到期时间 |
| | | * data内 isend为true说明套餐到期 |
| | |
| | | |
| | | @ApiOperation(value = "获取医院套餐是否到期和到期时间") |
| | | @GetMapping("/UserProductDetailData") |
| | | public ResultBody<UserProductData> serProductDetailData(@RequestParam Long hospitalId, @RequestParam Long departmentId,@RequestParam String diagnosticId) { |
| | | return productOrderDetailService.userProductDetailData(hospitalId, departmentId,diagnosticId); |
| | | public ResultBody<UserProductData> serProductDetailData(@RequestParam Long hospitalId, @RequestParam Long departmentId, @RequestParam String diagnosticId) { |
| | | return productOrderDetailService.userProductDetailData(hospitalId, departmentId, diagnosticId); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "获取医院套餐是否到期和到期时间") |
| | | @PostMapping("/serviceperiod") |
| | | public ResultBody<UserProductData> servicePeriod(@RequestBody HospitalInfo hospitalInfo) { |
| | | return productOrderDetailService.userProductDetailData(hospitalInfo.getHospitalId(), hospitalInfo.getDepartmentId(),hospitalInfo.getDiagnosticId()); |
| | | return productOrderDetailService.userProductDetailData(hospitalInfo.getHospitalId(), hospitalInfo.getDepartmentId(), hospitalInfo.getDiagnosticId()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody ProductOrderDetail productOrderDetail, BindingResult bindingResult, @LoginUser SysUser sysUser) { |
| | | public ResultBody save(@Valid @RequestBody ProductOrderDetail productOrderDetail, BindingResult bindingResult, @LoginUser SysUser sysUser) { |
| | | List<String> errMsg = new ArrayList<>(); |
| | | if (bindingResult.hasErrors()) { |
| | | for (ObjectError error : bindingResult.getAllErrors()) { |
| | |
| | | if (organizations.size() > 0) { |
| | | productOrderDetail.setCreateUserOrgCode(organizations.get(organizations.size() - 1).getOrgCode()); |
| | | } |
| | | // 对于读片量、产品有效的开始、结束日期进行加密 |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | if ((productOrderDetail.getAilightCountEncryption() == null) || (productOrderDetail.getAilightCountEncryption().isEmpty())) { |
| | | try { |
| | | productOrderDetail.setAilightCountEncryption(AesUtils.encrypt(productOrderDetail.getAilightCount().toString())); |
| | | productOrderDetail.setProBegintimeEncryption(AesUtils.encrypt(dateFormat.format(productOrderDetail.getProBegintime()))); |
| | | productOrderDetail.setProEndtimeEncryption(AesUtils.encrypt(dateFormat.format(productOrderDetail.getProEndtime()))); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | boolean v = productOrderDetailService.saveOrUpdate(productOrderDetail); |
| | | if (v) { |
| | | return ResultBody.ok().data(productOrderDetail).msg("保存成功"); |
| | |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping("/saveall") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResultBody batchInsert(@Valid @RequestBody List<ProductOrderDetail> list,BindingResult bindingResult) { |
| | | public ResultBody batchInsert(@Valid @RequestBody List<ProductOrderDetail> list, BindingResult bindingResult) { |
| | | List<String> errMsg = new ArrayList<>(); |
| | | if (bindingResult.hasErrors()) { |
| | | for (ObjectError error : bindingResult.getAllErrors()) { |
| | |
| | | ProductOrder productOrder = productOrderService.getById(list.get(0).getOrderId()); |
| | | if (productOrder != null) { |
| | | //是否管理人员 |
| | | boolean ismanager=false, |
| | | boolean ismanager = false, |
| | | //是否有待审核套餐 |
| | | isenabled=false; |
| | | isenabled = false; |
| | | //如果是超管,高管,销售部门管理 则不受次数限制 |
| | | ResultBody<LoginAppUser> loginAppUserTemp=sysUserServiceFeign.getLoginAppUser(); |
| | | LoginAppUser loginAppUser=loginAppUserTemp.getData(); |
| | | ResultBody<LoginAppUser> loginAppUserTemp = sysUserServiceFeign.getLoginAppUser(); |
| | | LoginAppUser loginAppUser = loginAppUserTemp.getData(); |
| | | if (loginAppUser != null) { |
| | | |
| | | List<SysRole> sysRoleList = loginAppUser.getRoles(); |
| | |
| | | roleName.equals(CommonConstant.SALE_MANAGER_ROLE_CODE) || |
| | | roleName.equals(CommonConstant.PC_ADMIN_ROLE_CODE) || |
| | | roleName.equals(CommonConstant.OPRATIONMANAGER_ROLE_CODE)) { |
| | | ismanager=true; |
| | | ismanager = true; |
| | | break; |
| | | } |
| | | } |
| | |
| | | int counts = productOrderDetailService.getEnabledCount(productOrder.getDepartmentId()); |
| | | if (counts >= CommonConstant.MAX_FREE_COUNT) { |
| | | //超过了限定次数 将试用套餐改为禁用 待审核 |
| | | for (int i = 0; i <list.size() ; i++) { |
| | | if (list.get(i).getProType()==0) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).getProType() == 0) { |
| | | //试用套餐 |
| | | list.get(i).setEnabled(false); |
| | | isenabled=true; |
| | | isenabled = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // 对于读片量、产品有效的开始、结束日期进行加密 |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if ((list.get(i).getAilightCountEncryption() == null) || (list.get(i).getAilightCountEncryption().isEmpty())) { |
| | | try { |
| | | list.get(i).setAilightCountEncryption(AesUtils.encrypt(list.get(i).getAilightCount().toString())); |
| | | list.get(i).setProBegintimeEncryption(AesUtils.encrypt(dateFormat.format(list.get(i).getProBegintime()))); |
| | | list.get(i).setProEndtimeEncryption(AesUtils.encrypt(dateFormat.format(list.get(i).getProEndtime()))); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | //写充值套餐给用户 |
| | |
| | | if (v && r && p) { |
| | | if (isenabled) { |
| | | return ResultBody.ok().data(list.size()).msg("充值成功,但是试用套餐需要管理审核才可使用!"); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return ResultBody.ok().data(list.size()).msg("产品充值成功..."); |
| | | } |
| | | } else { |
| | |
| | | |
| | | /** |
| | | * 统计获取数据量 |
| | | * @param datatype |
| | | * 0 试用审核量 |
| | | * 1 套餐总量 |
| | | * 2 未处理用户反馈 |
| | | * 3 未处理数据需求 |
| | | * |
| | | * @param datatype 0 试用审核量 |
| | | * 1 套餐总量 |
| | | * 2 未处理用户反馈 |
| | | * 3 未处理数据需求 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "统计获取数据量") |
| | | @GetMapping("/oprationChart") |
| | | public ResultBody oprationChart(int datatype) { |
| | | int counts=productOrderDetailService.oprationChart(datatype); |
| | | return ResultBody.ok().data(counts).msg("数据获取成功!") ; |
| | | int counts = productOrderDetailService.oprationChart(datatype); |
| | | return ResultBody.ok().data(counts).msg("数据获取成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 按指定类型统计合同数量 |
| | | * @param params |
| | | * datatype 1 按年 |
| | | * 2 按月 |
| | | * 3 按天 |
| | | * 4 按周 |
| | | * beginTime 查询时间段的开始时间 |
| | | * endTime 结束时间 |
| | | * |
| | | * @param params datatype 1 按年 |
| | | * 2 按月 |
| | | * 3 按天 |
| | | * 4 按周 |
| | | * beginTime 查询时间段的开始时间 |
| | | * endTime 结束时间 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "按指定类型统计合同数量") |
| | | @GetMapping("/productOrderChart") |
| | | public ResultBody productOrderChart(@RequestParam Map<String, Object> params) { |
| | | List<OrderChartVo> orderChartVo=productOrderDetailService.productOrderChart(params); |
| | | return ResultBody.ok().data(orderChartVo).msg("数据获取成功!") ; |
| | | public ResultBody productOrderChart(@RequestParam Map<String, Object> params) { |
| | | List<OrderChartVo> orderChartVo = productOrderDetailService.productOrderChart(params); |
| | | return ResultBody.ok().data(orderChartVo).msg("数据获取成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 统计产品的使用数量 |
| | | * @return ccount 是数量 |
| | | * units 是产品名称 |
| | | * |
| | | * @return ccount 是数量 |
| | | * units 是产品名称 |
| | | */ |
| | | @ApiOperation(value = "统计产品的使用数量") |
| | | @GetMapping("/proCountChart") |
| | | public ResultBody proCountChart() { |
| | | List<OrderChartVo> orderChartVo=productOrderDetailService.proCountChart(); |
| | | return ResultBody.ok().data(orderChartVo).msg("数据获取成功!") ; |
| | | List<OrderChartVo> orderChartVo = productOrderDetailService.proCountChart(); |
| | | return ResultBody.ok().data(orderChartVo).msg("数据获取成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 获取软件服务周期 和 读片总量 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "获取软件服务周期") |
| | | @GetMapping("/getContractBeginEndTimeAndNum") |
| | | public ResultBody getContractBeginEndTimeAndNum(@RequestParam("departmentId") Long departmentId) { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("department_id",departmentId); |
| | | map.put("enabled",true); |
| | | map.put("is_del",false); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("department_id", departmentId); |
| | | map.put("enabled", true); |
| | | map.put("is_del", false); |
| | | List<ProductOrder> productOrders = productOrderService.listByMap(map); |
| | | map = new HashMap<>(); |
| | | if(productOrders!=null&&productOrders.size()>0){ |
| | | IntSummaryStatistics intSummaryStatistics = productOrders.stream().filter(a-> a.getContractNum()!=null&&a.getEnabled()).mapToInt((x) -> x.getContractNum()).summaryStatistics(); |
| | | Date minDate = productOrders.stream().filter(a->a.getEnabled()).map(e -> e.getContractBeginTime()).min((e1, e2) -> e1.compareTo(e2)).get(); |
| | | Date manDate = productOrders.stream().filter(a->a.getEnabled()).map(e -> e.getContractEndTime()).max((e1, e2) -> e1.compareTo(e2)).get(); |
| | | if (productOrders != null && productOrders.size() > 0) { |
| | | IntSummaryStatistics intSummaryStatistics = productOrders.stream().filter(a -> a.getContractNum() != null && a.getEnabled()).mapToInt((x) -> x.getContractNum()).summaryStatistics(); |
| | | Date minDate = productOrders.stream().filter(a -> a.getEnabled()).map(e -> e.getContractBeginTime()).min((e1, e2) -> e1.compareTo(e2)).get(); |
| | | Date manDate = productOrders.stream().filter(a -> a.getEnabled()).map(e -> e.getContractEndTime()).max((e1, e2) -> e1.compareTo(e2)).get(); |
| | | map.put("count", intSummaryStatistics.getSum()); |
| | | map.put("beginTime",DateUtils.formatDate(minDate,"yyyy-MM-dd HH:mm:ss")); |
| | | map.put("endTime",DateUtils.formatDate(manDate,"yyyy-MM-dd HH:mm:ss")); |
| | | map.put("beginTime", DateUtils.formatDate(minDate, "yyyy-MM-dd HH:mm:ss")); |
| | | map.put("endTime", DateUtils.formatDate(manDate, "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | return ResultBody.ok().data(map); |
| | | return ResultBody.ok().data(map); |
| | | } |
| | | |
| | | /** |
| | | * 私有云套餐验证 |
| | | * @param params 参数 |
| | | * hospitalId 医院ID |
| | | * departmentId 科室ID |
| | | * @return com.kidgrow.common.model.ResultBody |
| | | */ |
| | | @ApiOperation(value = "私有云套餐验证") |
| | | @PostMapping("/verificateProductOrderDetail") |
| | | public ResultBody verificateProductOrderDetail(@RequestBody Map<String,Object> params ){ |
| | | Long hospitalId = Long.valueOf(params.get("hospitalId").toString()); |
| | | Long departmentId = Long.valueOf(params.get("departmentId").toString()); |
| | | return productOrderDetailService.verificateProductOrderDetail(hospitalId,departmentId); |
| | | } |
| | | |
| | | /** |
| | | * 根据Map的条件获取合同明细(套餐)列表 |
| | | * @param params |
| | | * @return com.kidgrow.common.model.ResultBody |
| | | */ |
| | | @ApiOperation(value = "根据Map的条件获取合同明细(套餐)列表") |
| | | @PostMapping("/findProductOrderDetailListByMap") |
| | | public ResultBody findProductOrderDetailListByMap(@RequestBody Map<String, Object> params) { |
| | | List<ProductOrderDetail> productOrderDetailList = productOrderDetailService.listByMap(params); |
| | | if ((productOrderDetailList!=null) && (productOrderDetailList.size() > 0)) { |
| | | return ResultBody.ok().data(productOrderDetailList); |
| | | } else { |
| | | return ResultBody.failed(); |
| | | } |
| | | } |
| | | } |