|  |  | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | import com.ruoyi.common.annotation.NotRepeatCommit; | 
 |  |  | import com.ruoyi.common.config.RuoYiConfig; | 
 |  |  | import com.ruoyi.common.enums.OrganEnum; | 
 |  |  | import com.ruoyi.common.exception.base.BaseException; | 
 |  |  | import com.ruoyi.common.utils.StringUtils; | 
 |  |  | import com.ruoyi.common.utils.bean.DtoConversionUtils; | 
 |  |  | import com.ruoyi.project.domain.ServiceDonatebaseinfo; | 
 |  |  | import com.ruoyi.project.domain.ServiceDonateorgan; | 
 |  |  | import com.ruoyi.project.domain.ServiceDonationwitnessorgan; | 
 |  |  | import com.ruoyi.project.domain.vo.DonationWitnessVO; | 
 |  |  | import com.ruoyi.project.domain.vo.TimeVO; | 
 |  |  | import com.ruoyi.project.service.IBaseOnlyvalueService; | 
 |  |  | 
 |  |  | import freemarker.template.TemplateException; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | import io.swagger.annotations.ApiOperation; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.util.CollectionUtils; | 
 |  |  | import org.springframework.web.bind.annotation.GetMapping; | 
 |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
 |  |  | import org.springframework.web.bind.annotation.PathVariable; | 
 |  |  | 
 |  |  |  * @author ruoyi | 
 |  |  |  * @date 2021-11-17 | 
 |  |  |  */ | 
 |  |  | @Slf4j | 
 |  |  | @Api("捐献见证管理") | 
 |  |  | @RestController | 
 |  |  | @RequestMapping("/project/donationwitness") | 
 |  |  | 
 |  |  |      * 查询捐献见证列表 | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("获取捐献见证列表") | 
 |  |  |     //@PreAuthorize("@ss.hasPermi('project:donationwitness:list')") | 
 |  |  |     //// @PreAuthorize("@ss.hasPermi('project:donationwitness:list')") | 
 |  |  |     @GetMapping("/list") | 
 |  |  |     public TableDataInfo list(ServiceDonationwitness serviceDonationwitness) { | 
 |  |  |         startPage(); | 
 |  |  | 
 |  |  |      * 导出捐献见证列表 | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("导出捐献见证列表") | 
 |  |  |     //@PreAuthorize("@ss.hasPermi('project:donationwitness:export')") | 
 |  |  |     //// @PreAuthorize("@ss.hasPermi('project:donationwitness:export')") | 
 |  |  |     @Log(title = "捐献见证", businessType = BusinessType.EXPORT) | 
 |  |  |     @GetMapping("/export") | 
 |  |  |     public AjaxResult export(ServiceDonationwitness serviceDonationwitness) { | 
 |  |  | 
 |  |  |      * 获取捐献见证详细信息 | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("通过id获取见证信息") | 
 |  |  |     //@PreAuthorize("@ss.hasPermi('project:donationwitness:query')") | 
 |  |  |     //// @PreAuthorize("@ss.hasPermi('project:donationwitness:query')") | 
 |  |  |     @GetMapping(value = "/{id}") | 
 |  |  |     public AjaxResult getInfo(@PathVariable("id") Long id) { | 
 |  |  |         return AjaxResult.success(serviceDonationwitnessService.getById(id)); | 
 |  |  | 
 |  |  |      * 新增捐献见证 | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("新增捐献见证") | 
 |  |  |     //@PreAuthorize("@ss.hasPermi('project:donationwitness:add')") | 
 |  |  |     //// @PreAuthorize("@ss.hasPermi('project:donationwitness:add')") | 
 |  |  |     @Log(title = "捐献见证", businessType = BusinessType.INSERT) | 
 |  |  |     @PostMapping | 
 |  |  |     @PostMapping("/add") | 
 |  |  |     @RepeatSubmit | 
 |  |  |     public AjaxResult add(@RequestBody ServiceDonationwitness serviceDonationwitness) { | 
 |  |  |  | 
 |  |  |         return toAjax(serviceDonationwitnessService.save(serviceDonationwitness)); | 
 |  |  |         boolean save = serviceDonationwitnessService.save(serviceDonationwitness); | 
 |  |  |         log.info("新增捐献见证是否成功:{},id为:{},infoId为:{}", save, serviceDonationwitness.getId(), serviceDonationwitness.getInfoid()); | 
 |  |  | //        if (save) { | 
 |  |  | //            //生成“捐献者编号” | 
 |  |  | //            ServiceDonatebaseinfo serviceDonatebaseinfo = serviceDonatebaseinfoService.getById(serviceDonationwitness.getInfoid()); | 
 |  |  | //            log.info("serviceDonatebaseinfo的信息为{}", serviceDonatebaseinfo); | 
 |  |  | //            String donorno = serviceDonatebaseinfoService.getDonateNumber(serviceDonatebaseinfo); | 
 |  |  | //            log.info("生成的捐献者编号为:{}", donorno); | 
 |  |  | //            serviceDonatebaseinfo.setDonorno(donorno); | 
 |  |  | //            serviceDonatebaseinfoService.updateById(serviceDonatebaseinfo); | 
 |  |  | //        } | 
 |  |  |         return AjaxResult.success(serviceDonationwitness); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改捐献见证 | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("修改捐献见证") | 
 |  |  |     //@PreAuthorize("@ss.hasPermi('project:donationwitness:edit')") | 
 |  |  |     //// @PreAuthorize("@ss.hasPermi('project:donationwitness:edit')") | 
 |  |  |     @Log(title = "捐献见证", businessType = BusinessType.UPDATE) | 
 |  |  |     @PostMapping("/edit") | 
 |  |  |     @RepeatSubmit | 
 |  |  |     public AjaxResult edit(@RequestBody ServiceDonationwitness serviceDonationwitness) { | 
 |  |  |         log.info("新增捐献见证id为:{},infoId为:{}", serviceDonationwitness.getId(), serviceDonationwitness.getInfoid()); | 
 |  |  |  | 
 |  |  |         int last = -1; | 
 |  |  |         if (StringUtils.isNotEmpty(serviceDonationwitness.getDonorno())) { | 
 |  |  |             last = serviceDonationwitness.getDonorno().lastIndexOf("*"); | 
 |  |  | 
 |  |  |      * 删除捐献见证 | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("删除捐献见证") | 
 |  |  |     //@PreAuthorize("@ss.hasPermi('project:donationwitness:remove')") | 
 |  |  |     //// @PreAuthorize("@ss.hasPermi('project:donationwitness:remove')") | 
 |  |  |     @Log(title = "捐献见证", businessType = BusinessType.DELETE) | 
 |  |  |     @GetMapping("/remove/{ids}") | 
 |  |  |     public AjaxResult remove(@PathVariable Long[] ids) { | 
 |  |  | 
 |  |  |         } | 
 |  |  |         Map<String, Object> map = new HashMap<>(); | 
 |  |  |         map.put("downloadUrl", "/profile/download/wordtemplate/" + name + ".doc"); | 
 |  |  |         map.put("downloadName", name + ".doc"); | 
 |  |  |         return map; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         dataMap.put("ZDMCG", donationWitness.getAortacannulatime() == null ? "" : sformat.format(donationWitness.getAortacannulatime())); | 
 |  |  |         dataMap.put("ZDMGZ", donationWitness.getAortaperfusiontime() == null ? "" : sformat.format(donationWitness.getAortaperfusiontime())); | 
 |  |  |  | 
 |  |  |         if (donationWitness.getIsrestoreremains() == 0) { | 
 |  |  |         if (donationWitness.getIsrestoreremains() != null && donationWitness.getIsrestoreremains() == 0) { | 
 |  |  |             dataMap.put("HFYT", "□"); | 
 |  |  |             dataMap.put("BHFYT", (char) 8730); | 
 |  |  |         } else if (donationWitness.getIsrestoreremains() == 1) { | 
 |  |  |         } else if (donationWitness.getIsrestoreremains() != null && donationWitness.getIsrestoreremains() == 1) { | 
 |  |  |             dataMap.put("HFYT", (char) 8730); | 
 |  |  |             dataMap.put("BHFYT", "□"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (donationWitness.getIsspendremember() == 0) { | 
 |  |  |         if (donationWitness.getIsspendremember() != null && donationWitness.getIsspendremember() == 0) { | 
 |  |  |             dataMap.put("MA", "□"); | 
 |  |  |             dataMap.put("BMA", (char) 8730); | 
 |  |  |         } else if (donationWitness.getIsspendremember() == 1) { | 
 |  |  |         } else if (donationWitness.getIsspendremember() != null && donationWitness.getIsspendremember() == 1) { | 
 |  |  |             dataMap.put("MA", (char) 8730); | 
 |  |  |             dataMap.put("BMA", "□"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |         return AjaxResult.success(serviceDonationwitnessService.getStats(timeVO)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RepeatSubmit | 
 |  |  |     @ApiOperation("新增或修改捐献见证管理") | 
 |  |  |     @Log(title = "捐献完成", businessType = BusinessType.UPDATE) | 
 |  |  |     @PostMapping("/saveOrUpdateDonationwitness") | 
 |  |  |     public AjaxResult saveOrUpdateDonationwitness(@RequestBody List<ServiceDonationwitness> serviceDonationwitnessList) { | 
 |  |  |         if (CollectionUtils.isEmpty(serviceDonationwitnessList)) { | 
 |  |  |             throw new BaseException("请检查需要新增或修改的捐献见证管理参数是否完整"); | 
 |  |  |         } | 
 |  |  |         Boolean i = null; | 
 |  |  |         for (ServiceDonationwitness serviceDonationwitness : serviceDonationwitnessList) { | 
 |  |  |             log.info("捐献见证管理id是否为空 : {},基础表的id为 : {}", serviceDonationwitness.getId(), serviceDonationwitness.getInfoid()); | 
 |  |  |             ServiceDonationwitness sd2 = new ServiceDonationwitness(); | 
 |  |  |             sd2.setInfoid(serviceDonationwitness.getInfoid()); | 
 |  |  |             sd2.setDel_flag(0); | 
 |  |  |             List<ServiceDonationwitness> serviceDonationwitnesses = serviceDonationwitnessService.queryList(sd2); | 
 |  |  |             if (!CollectionUtils.isEmpty(serviceDonationwitnesses)) { | 
 |  |  |                 serviceDonationwitness.setId(serviceDonationwitnesses.get(0).getId()); | 
 |  |  |             } | 
 |  |  |             if (serviceDonationwitness.getId() == null) { | 
 |  |  |                 i = serviceDonationwitnessService.save(serviceDonationwitness); | 
 |  |  |             } else { | 
 |  |  |                 i = serviceDonationwitnessService.updateById(serviceDonationwitness); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return toAjax(i); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |