|
@@ -15,6 +15,8 @@ import com.ruoyi.project.ticket.service.ITPermitRelationService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -108,14 +110,13 @@ public class THazardWorkPermitController extends BaseController {
|
|
|
*/
|
|
|
@Log(title = "危害工作许可证", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody THazardWorkPermit tHazardWorkPermit) {
|
|
|
+ public AjaxResult add(@RequestBody THazardWorkPermit tHazardWorkPermit) throws IOException {
|
|
|
Long ticketId = tTicketIdController.createId();
|
|
|
logger.info("ticketId:" + ticketId);
|
|
|
tHazardWorkPermit.setaId(ticketId);
|
|
|
//生成word
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- // 渲染文本
|
|
|
- params.put("aId",ticketId);
|
|
|
+ //渲染文本
|
|
|
+ Map<String, Object> params = getWordData(tHazardWorkPermit);
|
|
|
// 模板路径
|
|
|
String templatePath = "static/word/ticket.docx";
|
|
|
// 生成word的路径
|
|
@@ -130,7 +131,6 @@ public class THazardWorkPermitController extends BaseController {
|
|
|
permitRelation.setPermitId(tHazardWorkPermit.getaId());
|
|
|
permitRelation.setPermitType("A");
|
|
|
permitRelation.setPermitStatus(1L);
|
|
|
-
|
|
|
this.itPermitRelationService.add(permitRelation);
|
|
|
return AjaxResult.success(tHazardWorkPermit.getaId());
|
|
|
}
|
|
@@ -140,15 +140,14 @@ public class THazardWorkPermitController extends BaseController {
|
|
|
*/
|
|
|
@Log(title = "危害工作许可证", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody THazardWorkPermit tHazardWorkPermit) {
|
|
|
+ public AjaxResult edit(@RequestBody THazardWorkPermit tHazardWorkPermit) throws IOException {
|
|
|
//生成word
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- // 渲染文本
|
|
|
- params.put("aId",tHazardWorkPermit.getaId());
|
|
|
+ //渲染文本
|
|
|
+ Map<String, Object> params = getWordData(tHazardWorkPermit);
|
|
|
// 模板路径
|
|
|
String templatePath = "static/word/ticket.docx";
|
|
|
// 生成word的路径
|
|
|
- String fileDir = RuoYiConfig.getProfile();
|
|
|
+ String fileDir = RuoYiConfig.getProfile() + "/"+ "ticketWord";
|
|
|
// 生成word的文件
|
|
|
String fileName = "A" + tHazardWorkPermit.getaId() + ".docx";
|
|
|
String wordPath = this.wordController.createWord(templatePath, fileDir, fileName, params);
|
|
@@ -164,4 +163,15 @@ public class THazardWorkPermitController extends BaseController {
|
|
|
public AjaxResult remove(@PathVariable Long[] aIds) {
|
|
|
return toAjax(tHazardWorkPermitService.deleteTHazardWorkPermitByIds(aIds));
|
|
|
}
|
|
|
+
|
|
|
+ public Map<String, Object> getWordData (THazardWorkPermit tHazardWorkPermit){
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ // 渲染文本
|
|
|
+ params.put("aId",tHazardWorkPermit.getaId());
|
|
|
+ params.put("aEquipmentName" , tHazardWorkPermit.getaEquipmentName());
|
|
|
+ params.put("aEquipmentLeader" , tHazardWorkPermit.getaEquipmentLeader());
|
|
|
+ params.put("aEquipmentTel" , tHazardWorkPermit.getaEquipmentTel());
|
|
|
+ params.put("aEquipmentOffice" , tHazardWorkPermit.getaEquipmentOffice());
|
|
|
+ return params;
|
|
|
+ }
|
|
|
}
|