第二模块开发完成
This commit is contained in:
parent
947d0de2bd
commit
ea7d66c50d
|
@ -1,15 +1,15 @@
|
||||||
package org.jeecg.modules.demo.Try.controller;
|
package org.jeecg.modules.demo.Try.controller;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import org.jeecg.modules.demo.Try.service.IPurchaseRequestService;
|
import org.jeecg.modules.demo.Try.service.IPurchaseRequestService;
|
||||||
|
import org.jeecg.modules.demo.Try.service.WordGeneratorService;
|
||||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
|
@ -31,6 +32,10 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
@ -81,8 +86,8 @@ public class PurchaseOrderConfirmationController extends JeecgController<Purchas
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* 查询所有被接收的订单并连接
|
* 查询所有被接收的订单并连接
|
||||||
|
*
|
||||||
* @param purchaseOrderConfirmation
|
* @param purchaseOrderConfirmation
|
||||||
* @param pageNo
|
* @param pageNo
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
|
@ -91,9 +96,17 @@ public class PurchaseOrderConfirmationController extends JeecgController<Purchas
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "采购订单确认-连接查询", notes = "采购订单确认-连接查询")
|
@ApiOperation(value = "采购订单确认-连接查询", notes = "采购订单确认-连接查询")
|
||||||
@GetMapping(value = "/joinList")
|
@GetMapping(value = "/joinList")
|
||||||
public Result<List<PurchaseAndOrder>> queryAllList() {
|
public Result<IPage<PurchaseAndOrder>> queryAllList(PurchaseAndOrder purchaseAndOrder,
|
||||||
return Result.OK(purchaseOrderConfirmationService.queryAllConfirm());
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
// QueryWrapper<PurchaseAndOrder> queryWrapper = QueryGenerator.initQueryWrapper(purchaseAndOrder, req.getParameterMap());
|
||||||
|
Page<PurchaseAndOrder> page = new Page<PurchaseAndOrder>(pageNo, pageSize);
|
||||||
|
// IPage<PurchaseAndOrder> pageList = purchaseOrderConfirmationService.page(page, queryWrapper);
|
||||||
|
IPage<PurchaseAndOrder> pageList = purchaseOrderConfirmationService.queryPageList(page);
|
||||||
|
return Result.OK(pageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加
|
* 添加
|
||||||
*
|
*
|
||||||
|
@ -118,7 +131,10 @@ public class PurchaseOrderConfirmationController extends JeecgController<Purchas
|
||||||
@ApiOperation(value = "采购订单确认-编辑", notes = "采购订单确认-编辑")
|
@ApiOperation(value = "采购订单确认-编辑", notes = "采购订单确认-编辑")
|
||||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||||
public Result<String> edit(@RequestBody PurchaseOrderConfirmation purchaseOrderConfirmation) {
|
public Result<String> edit(@RequestBody PurchaseOrderConfirmation purchaseOrderConfirmation) {
|
||||||
purchaseOrderConfirmationService.updateById(purchaseOrderConfirmation);
|
LambdaUpdateWrapper<PurchaseOrderConfirmation> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(PurchaseOrderConfirmation::getAssociationNumber, purchaseOrderConfirmation.getAssociationNumber())
|
||||||
|
.set(PurchaseOrderConfirmation::getSupplierSelection, purchaseOrderConfirmation.getSupplierSelection());
|
||||||
|
purchaseOrderConfirmationService.update(updateWrapper);
|
||||||
return Result.OK("编辑成功!");
|
return Result.OK("编辑成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,4 +245,45 @@ public class PurchaseOrderConfirmationController extends JeecgController<Purchas
|
||||||
return super.importExcel(request, response, PurchaseOrderConfirmation.class);
|
return super.importExcel(request, response, PurchaseOrderConfirmation.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final Object lock = new Object(); // 用于同步的锁对象
|
||||||
|
@Autowired
|
||||||
|
private WordGeneratorService wordGeneratorService;
|
||||||
|
|
||||||
|
@PostMapping("/outWordDoc")
|
||||||
|
public ResponseEntity<byte[]> exportWord(@RequestBody String jsonData) {
|
||||||
|
synchronized (lock) {
|
||||||
|
System.out.println("jsonData:" + jsonData);
|
||||||
|
if (jsonData == null || jsonData.length() == 0) {
|
||||||
|
return new ResponseEntity<byte[]>(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
File file = new File(wordGeneratorService.createWord(jsonData));
|
||||||
|
//将文件转换为二进制数组
|
||||||
|
byte[] buffer = null;
|
||||||
|
try {
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
byte[] b = new byte[1024];
|
||||||
|
int n;
|
||||||
|
while ((n = fis.read(b)) != -1) {
|
||||||
|
bos.write(b, 0, n);
|
||||||
|
}
|
||||||
|
fis.close();
|
||||||
|
bos.close();
|
||||||
|
buffer = bos.toByteArray();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (buffer != null) {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
headers.setContentDispositionFormData("attachment", "generated-file.docx");
|
||||||
|
return new ResponseEntity<byte[]>(buffer, headers, HttpStatus.OK);
|
||||||
|
} else
|
||||||
|
return new ResponseEntity<byte[]>(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,16 +20,16 @@ import lombok.EqualsAndHashCode;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 采购表
|
* @Description: 采购订单确认
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2023-08-12
|
* @Date: 2023-08-13
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("purchase_request")
|
@TableName("purchase_order_confirmation")
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ApiModel(value = "purchase_request联表purchase_order_confirmation", description = "采购表连接采购确认表")
|
@ApiModel(value = "purchase_order_confirmation对象", description = "采购订单确认")
|
||||||
public class PurchaseAndOrder implements Serializable {
|
public class PurchaseAndOrder implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -38,57 +38,71 @@ public class PurchaseAndOrder implements Serializable {
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
@ApiModelProperty(value = "主键")
|
@ApiModelProperty(value = "主键")
|
||||||
private String id;
|
private java.lang.String id;
|
||||||
/**
|
/**
|
||||||
* 申请人
|
* 创建人
|
||||||
*/
|
*/
|
||||||
@Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
|
@ApiModelProperty(value = "创建人")
|
||||||
@ApiModelProperty(value = "申请人")
|
private java.lang.String createBy;
|
||||||
private String createBy;
|
|
||||||
/**
|
/**
|
||||||
* 申请日期
|
* 创建日期
|
||||||
*/
|
*/
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@ApiModelProperty(value = "申请日期")
|
@ApiModelProperty(value = "创建日期")
|
||||||
private Date createTime;
|
private java.util.Date createTime;
|
||||||
/**
|
|
||||||
* 需求编号
|
|
||||||
*/
|
|
||||||
@Excel(name = "需求编号", width = 15)
|
|
||||||
@ApiModelProperty(value = "需求编号")
|
|
||||||
private String requirementNumber;
|
|
||||||
/**
|
|
||||||
* 申请部门
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "申请部门")
|
|
||||||
private String sysOrgCode;
|
|
||||||
/**
|
|
||||||
* 需求状态
|
|
||||||
*/
|
|
||||||
@Excel(name = "需求状态", width = 15, dicCode = "procurement_approval_status")
|
|
||||||
@Dict(dicCode = "procurement_approval_status")
|
|
||||||
@ApiModelProperty(value = "需求状态")
|
|
||||||
private Integer demandStatus;
|
|
||||||
/**
|
|
||||||
* 更新人员
|
|
||||||
*/
|
|
||||||
@Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
|
|
||||||
@ApiModelProperty(value = "更新人员")
|
|
||||||
private String updateBy;
|
|
||||||
/**
|
|
||||||
* 审批人
|
|
||||||
*/
|
|
||||||
@Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
|
|
||||||
@ApiModelProperty(value = "审批人")
|
|
||||||
private String approvedBy;
|
|
||||||
/**
|
/**
|
||||||
* 更新日期
|
* 更新日期
|
||||||
*/
|
*/
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@ApiModelProperty(value = "更新日期")
|
@ApiModelProperty(value = "更新日期")
|
||||||
private Date updateTime;
|
private java.util.Date updateTime;
|
||||||
|
/**
|
||||||
|
* 所属部门
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "所属部门")
|
||||||
|
private java.lang.String sysOrgCode;
|
||||||
|
/**
|
||||||
|
* 关联编号
|
||||||
|
*/
|
||||||
|
@Excel(name = "关联编号", width = 15)
|
||||||
|
@ApiModelProperty(value = "关联编号")
|
||||||
|
private java.lang.String associationNumber;
|
||||||
|
/**
|
||||||
|
* 供应商选择
|
||||||
|
*/
|
||||||
|
@Excel(name = "供应商选择", width = 15)
|
||||||
|
@ApiModelProperty(value = "供应商选择")
|
||||||
|
private java.lang.String supplierSelection;
|
||||||
|
/**
|
||||||
|
* 接单人
|
||||||
|
*/
|
||||||
|
@Excel(name = "接单人", width = 15, dictTable = "sys_user", dicText = "realname", dicCode = "username")
|
||||||
|
@Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
|
||||||
|
@ApiModelProperty(value = "接单人")
|
||||||
|
private java.lang.String receiver;
|
||||||
|
/**
|
||||||
|
* 接单时间
|
||||||
|
*/
|
||||||
|
@Excel(name = "接单时间", width = 15, format = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@ApiModelProperty(value = "接单时间")
|
||||||
|
private java.util.Date receivingTime;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@Excel(name = "备注", width = 15)
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private java.lang.String notes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批人
|
||||||
|
*/
|
||||||
|
@Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
|
||||||
|
@ApiModelProperty(value = "审批人")
|
||||||
|
private String approvedBy;
|
||||||
/**
|
/**
|
||||||
* 采购类别
|
* 采购类别
|
||||||
*/
|
*/
|
||||||
|
@ -127,36 +141,9 @@ public class PurchaseAndOrder implements Serializable {
|
||||||
@ApiModelProperty(value = "审核结果")
|
@ApiModelProperty(value = "审核结果")
|
||||||
private String auditResults;
|
private String auditResults;
|
||||||
/**
|
/**
|
||||||
* 采购方向
|
* 是否被接受
|
||||||
*/
|
*/
|
||||||
@Excel(name = "是否被接受", width = 15)
|
@Excel(name = "是否被接受", width = 15)
|
||||||
@ApiModelProperty(value = "是否被接受")
|
@ApiModelProperty(value = "是否被接受")
|
||||||
private String isReceiving;
|
private String isReceiving;
|
||||||
/**
|
|
||||||
* 供应商选择
|
|
||||||
*/
|
|
||||||
@Excel(name = "供应商选择", width = 15)
|
|
||||||
@ApiModelProperty(value = "供应商选择")
|
|
||||||
private java.lang.String supplierSelection;
|
|
||||||
/**
|
|
||||||
* 接单人
|
|
||||||
*/
|
|
||||||
@Excel(name = "接单人", width = 15, dictTable = "sys_user", dicText = "realname", dicCode = "username")
|
|
||||||
@Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
|
|
||||||
@ApiModelProperty(value = "接单人")
|
|
||||||
private java.lang.String receiver;
|
|
||||||
/**
|
|
||||||
* 接单时间
|
|
||||||
*/
|
|
||||||
@Excel(name = "接单时间", width = 15, format = "yyyy-MM-dd")
|
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@ApiModelProperty(value = "接单时间")
|
|
||||||
private java.util.Date receivingTime;
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
@Excel(name = "备注", width = 15)
|
|
||||||
@ApiModelProperty(value = "备注")
|
|
||||||
private java.lang.String notes;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,10 @@ package org.jeecg.modules.demo.Try.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.jeecg.modules.demo.Try.entity.PurchaseAndOrder;
|
||||||
import org.jeecg.modules.demo.Try.entity.PurchaseOrderConfirmation;
|
import org.jeecg.modules.demo.Try.entity.PurchaseOrderConfirmation;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
@ -13,5 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
public interface PurchaseOrderConfirmationMapper extends BaseMapper<PurchaseOrderConfirmation> {
|
public interface PurchaseOrderConfirmationMapper extends BaseMapper<PurchaseOrderConfirmation> {
|
||||||
|
IPage<PurchaseAndOrder> getAllData(IPage<PurchaseAndOrder> page);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
*/
|
*/
|
||||||
public interface PurchaseRequestMapper extends BaseMapper<PurchaseRequest> {
|
public interface PurchaseRequestMapper extends BaseMapper<PurchaseRequest> {
|
||||||
|
|
||||||
@Select("select r.*,c.receiver,c.receiving_time,c.supplier_selection,c.notes from purchase_request r,purchase_order_confirmation c where r.requirement_number=c.association_number")
|
|
||||||
List<PurchaseAndOrder> getAllData();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,11 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="org.jeecg.modules.demo.Try.mapper.PurchaseOrderConfirmationMapper">
|
<mapper namespace="org.jeecg.modules.demo.Try.mapper.PurchaseOrderConfirmationMapper">
|
||||||
|
|
||||||
</mapper>
|
<select id="getAllData" resultType="org.jeecg.modules.demo.Try.entity.PurchaseAndOrder">
|
||||||
|
select c.id,r.create_by,r.create_time,r.update_time,r.sys_org_code,c.association_number,c.supplier_selection,c.receiver,c.receiving_time,c.notes,r.approved_by
|
||||||
|
,r.procurement_category,r.procurement_direction,r.procurement_content,r.procurement_budget,r.annex,
|
||||||
|
r.audit_results,r.is_receiving
|
||||||
|
from purchase_order_confirmation c,purchase_request r where r.requirement_number=c.association_number;
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.jeecg.modules.demo.Try.service;
|
package org.jeecg.modules.demo.Try.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.jeecg.modules.demo.Try.entity.PurchaseAndOrder;
|
import org.jeecg.modules.demo.Try.entity.PurchaseAndOrder;
|
||||||
import org.jeecg.modules.demo.Try.entity.PurchaseOrderConfirmation;
|
import org.jeecg.modules.demo.Try.entity.PurchaseOrderConfirmation;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
@ -18,5 +19,6 @@ public interface IPurchaseOrderConfirmationService extends IService<PurchaseOrde
|
||||||
|
|
||||||
PurchaseOrderConfirmation queryByRequireNo(String queryByRequireNo);
|
PurchaseOrderConfirmation queryByRequireNo(String queryByRequireNo);
|
||||||
|
|
||||||
List<PurchaseAndOrder> queryAllConfirm();
|
IPage<PurchaseAndOrder> queryPageList(IPage<PurchaseAndOrder> page);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.jeecg.modules.demo.Try.service;
|
||||||
|
|
||||||
|
import org.jeecg.modules.demo.Try.entity.PurchaseAndOrder;
|
||||||
|
|
||||||
|
public interface WordGeneratorService {
|
||||||
|
|
||||||
|
public String createWord(String jsonData);
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.demo.Try.service.impl;
|
package org.jeecg.modules.demo.Try.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.jeecg.modules.demo.Try.entity.PurchaseAndOrder;
|
import org.jeecg.modules.demo.Try.entity.PurchaseAndOrder;
|
||||||
import org.jeecg.modules.demo.Try.entity.PurchaseOrderConfirmation;
|
import org.jeecg.modules.demo.Try.entity.PurchaseOrderConfirmation;
|
||||||
import org.jeecg.modules.demo.Try.mapper.PurchaseOrderConfirmationMapper;
|
import org.jeecg.modules.demo.Try.mapper.PurchaseOrderConfirmationMapper;
|
||||||
|
@ -39,8 +40,10 @@ public class PurchaseOrderConfirmationServiceImpl extends ServiceImpl<PurchaseOr
|
||||||
return purchaseOrderConfirmation;
|
return purchaseOrderConfirmation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PurchaseAndOrder> queryAllConfirm() {
|
public IPage<PurchaseAndOrder> queryPageList(IPage<PurchaseAndOrder> page) {
|
||||||
return purchaseRequestMapper.getAllData();
|
return purchaseOrderConfirmationMapper.getAllData(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package org.jeecg.modules.demo.Try.service.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFTable;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
|
||||||
|
import org.jeecg.modules.demo.Try.service.WordGeneratorService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class WordGeneratorServiceImpl implements WordGeneratorService {
|
||||||
|
@Override
|
||||||
|
public String createWord(String jsonData) {
|
||||||
|
try {
|
||||||
|
//将Json数据转换为Map处理
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
Map<String, Object> map = objectMapper.readValue(jsonData, Map.class);
|
||||||
|
//根据模板生成word文档
|
||||||
|
FileInputStream templateStream = new FileInputStream("jeecg-module-system/jeecg-system-start/src/main/resources/jeecg/wordtemplate/template.docx");
|
||||||
|
XWPFDocument document = new XWPFDocument(templateStream);
|
||||||
|
|
||||||
|
//填充第一行数据
|
||||||
|
XWPFParagraph paragraph1 = document.getParagraphs().get(0);
|
||||||
|
//转为String处理
|
||||||
|
String paragraph1Text = paragraph1.getText();
|
||||||
|
//根据:分割
|
||||||
|
String[] split = paragraph1Text.split(":");
|
||||||
|
System.out.println(split[0]);
|
||||||
|
//将每段:后面的内容替换为传入的数据
|
||||||
|
paragraph1Text = split[0].trim() + ":" + map.get("requirementNumber") +
|
||||||
|
split[1] + ":" + map.get("sysOrgCode") +
|
||||||
|
split[2] + ":" + map.get("procurementDirection");
|
||||||
|
System.out.println(paragraph1Text);
|
||||||
|
//删除原来的内容,将新的内容写入
|
||||||
|
// 清除段落的所有 runs
|
||||||
|
for (int i = paragraph1.getRuns().size() - 1; i >= 0; i--) {
|
||||||
|
paragraph1.removeRun(i);
|
||||||
|
}
|
||||||
|
paragraph1.createRun().setText(paragraph1Text);
|
||||||
|
//获取表格
|
||||||
|
XWPFTable table = document.getTables().get(0);
|
||||||
|
//获取表格的行
|
||||||
|
XWPFTableRow row = table.getRows().get(0);
|
||||||
|
//设置第一行第二列的值
|
||||||
|
row.getCell(1).setText(map.get("createBy_dictText").toString());
|
||||||
|
//设置第一行第四列的值
|
||||||
|
row.getCell(3).setText(map.get("createTime").toString());
|
||||||
|
//设置第一行第六列的值
|
||||||
|
row.getCell(5).setText(map.get("sysOrgCode").toString());
|
||||||
|
//获取第二行
|
||||||
|
XWPFTableRow row1 = table.getRows().get(1);
|
||||||
|
//设置第二行第二列的值
|
||||||
|
row1.getCell(1).setText(map.get("procurementCategory_dictText").toString());
|
||||||
|
//设置第二行第四列的值
|
||||||
|
row1.getCell(3).setText(map.get("procurementBudget").toString());
|
||||||
|
//获取第三行
|
||||||
|
XWPFTableRow row2 = table.getRows().get(2);
|
||||||
|
//设置第三行第二列的值
|
||||||
|
row2.getCell(1).setText(map.get("approvedBy_dictText").toString());
|
||||||
|
//获取第四行并设置第四行第二列的值
|
||||||
|
XWPFTableRow row3 = table.getRows().get(3);
|
||||||
|
//将procurementContent从Map中获取出并解析Json将其转换为Map
|
||||||
|
List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("procurementContent");
|
||||||
|
for (Map<String, Object> stringObjectMap : list) {
|
||||||
|
row3.getCell(1).setText(row3.getCell(1).getText()+ "物品名:" + stringObjectMap.get("name")
|
||||||
|
+ " 数量:" + stringObjectMap.get("number") + stringObjectMap.get("unit")+
|
||||||
|
"\n");
|
||||||
|
}
|
||||||
|
String fileName = "/temp/"+System.currentTimeMillis() + "_" + map.get("requirementNumber") + ".docx";
|
||||||
|
document.write(new FileOutputStream(fileName));
|
||||||
|
return fileName;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "fail to create word";
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in New Issue