| | |
| | | import com.ltkj.common.core.page.TableDataInfo; |
| | | import com.ltkj.hosp.domain.*; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | |
| | | import java.awt.image.BufferedImage; |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Base64; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private TjProConsumablesService proConsumablesService; |
| | | @Resource |
| | | private ITjConsumablesService consumablesService; |
| | | @Value("${path.filePath}") |
| | | private String value; |
| | | // @Value("${path.filePath}") |
| | | // private String value; |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | /** |
| | | * 打印条码 |
| | | */ |
| | |
| | | LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjOrder::getTjNumber, tjNumber); |
| | | TjOrder tjOrder = tjOrderService.getOne(wq); |
| | | |
| | | String value = configService.selectConfigByKey("path_filePath"); |
| | | if (tjOrder!=null){ |
| | | LambdaQueryWrapper<TjCustomer> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjCustomer::getCusId, tjOrder.getUserId()); |
| | | TjCustomer one = tjCustomerService.getOne(wq1); |
| | | |
| | | //查到项目详情 判断每个项目的耗材 去重 is_calculation为Y的打印 且拿到耗材名称 |
| | | LambdaQueryWrapper<TjOrderDetail> wq2 = new LambdaQueryWrapper<>(); |
| | | wq2.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId()); |
| | | List<TjOrderDetail> list = tjOrderDetailService.list(wq2); |
| | | // LambdaQueryWrapper<TjOrderDetail> wq2 = new LambdaQueryWrapper<>(); |
| | | // wq2.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId()); |
| | | // List<TjOrderDetail> list = tjOrderDetailService.list(wq2); |
| | | |
| | | List<TjProConsumables> list1=new ArrayList<>(); |
| | | for (TjOrderDetail tjOrderDetail : list) { |
| | | LambdaQueryWrapper<TjProConsumables> wq3 = new LambdaQueryWrapper<>(); |
| | | wq3.eq(TjProConsumables::getProId, tjOrderDetail.getProId()); |
| | | List<TjProConsumables> list2 = proConsumablesService.list(wq3); |
| | | for (TjProConsumables tjProConsumables : list2) { |
| | | list1.add(tjProConsumables); |
| | | } |
| | | } |
| | | List<TjProConsumables> collect = list1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.size()==0){ |
| | | List<TjOrderDetail> list = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId()); |
| | | |
| | | // List<TjProConsumables> list1=new ArrayList<>(); |
| | | // for (TjOrderDetail tjOrderDetail : list) { |
| | | // LambdaQueryWrapper<TjProConsumables> wq3 = new LambdaQueryWrapper<>(); |
| | | // wq3.eq(TjProConsumables::getProId, tjOrderDetail.getProId()); |
| | | // List<TjProConsumables> list2 = proConsumablesService.list(wq3); |
| | | // for (TjProConsumables tjProConsumables : list2) { |
| | | // list1.add(tjProConsumables); |
| | | // } |
| | | // } |
| | | // List<TjProConsumables> collect = list1.stream().distinct().collect(Collectors.toList()); |
| | | if (list.isEmpty()){ |
| | | return AjaxResult.success("该体检号无抽血项目!"); |
| | | } |
| | | //纵向拼接用 |
| | | //List<String> pac=new ArrayList<>(); |
| | | for (TjProConsumables tjProConsumables : collect) { |
| | | TjConsumables tjConsumables = consumablesService.selectTjConsumablesById(tjProConsumables.getConsumablesId()); |
| | | if ("Y".equals(tjConsumables.getIsCalculation())){ |
| | | try { |
| | | BufferedImage image = BarCodeUtils.getBarCodeWithWords(tjNumber+tjConsumables.getId(), tjNumber, one.getCusName(), tjConsumables.getMakings()); |
| | | ImageIO.write(image, "jpg", new File(value+"\\"+tjNumber+tjConsumables.getMakings()+".jpg")); |
| | | //pac.add(value+tjNumber+tjConsumables.getMakings()+".jpg"); //纵向拼接用 |
| | | //BarCodeUtils.barCodePrint(image,250,150,250,150); //纵向拼接用 |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | try { |
| | | BufferedImage image = BarCodeUtils.getBarCodeWithWords(tjNumber, tjNumber, one.getCusName(),null); |
| | | |
| | | // ImageIO.write(image, "jpg", new File(value+"\\"+one.getCusName()+tjNumber+".jpg")); |
| | | ByteArrayOutputStream out=new ByteArrayOutputStream(); |
| | | ImageIO.write(image,"jpg",out); |
| | | byte[] bytes = out.toByteArray(); |
| | | String encodedToString = Base64.getEncoder().encodeToString(bytes); |
| | | return AjaxResult.success("条码已生成!在文件夹下:"+value,encodedToString); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | | //纵向拼接 |
| | | //String[] title = pac.toArray(new String[pac.size()]); |
| | | //joinImageListVertical(title,"jpg","E:\\mycode\\2023-2\\2.16\\"+tjNumber+".jpg"); |
| | | //识别条码内容 |
| | | //String s = QRCodeUtils.deEncodeByPath("E:\\mycode\\2023-2\\2.16\\10001230128175552红盖子抽血管.jpg"); |
| | | //System.out.println(s); |
| | | return AjaxResult.success("条码已生成!在文件夹下:"+value); |
| | | } |
| | | return AjaxResult.error("该体检号无效!"); |
| | | |
| | |
| | | @GetMapping("/GetByCode") |
| | | @ApiOperation(value = "根据图片识别条码") |
| | | public AjaxResult GetByCode(String path) { |
| | | path=value+"10001230306223716蓝色头盖管.jpg"; |
| | | // path=value+"10001230306223716蓝色头盖管.jpg"; |
| | | //识别条码 |
| | | String s = QRCodeUtils.deEncodeByPath(path); |
| | | return AjaxResult.success(s); |