|
@@ -13,6 +13,8 @@ import com.jeeplus.common.excel.ExcelOptions;
|
|
|
import com.jeeplus.common.excel.annotation.ExportMode;
|
|
|
import com.jeeplus.common.redis.RedisUtils;
|
|
|
import com.jeeplus.common.utils.ResponseUtil;
|
|
|
+import com.jeeplus.finance.invoice.controller.CwFinanceInvoiceController;
|
|
|
+import com.jeeplus.finance.invoice.service.dto.CwFinanceInvoiceDetailDTO;
|
|
|
import com.jeeplus.finance.invoice.util.EasyPoiUtil;
|
|
|
import com.jeeplus.finance.invoice.util.FreemarkerUtil;
|
|
|
import com.jeeplus.finance.invoice.util.SignaturePostUtil;
|
|
@@ -22,9 +24,11 @@ import com.jeeplus.finance.projectReport.domain.CwProjectReportSignature;
|
|
|
import com.jeeplus.finance.projectReport.domain.CwSignatureAnnotator;
|
|
|
import com.jeeplus.finance.projectReport.mapper.CwSignatureAnnotatorMapper;
|
|
|
import com.jeeplus.finance.projectReport.mapper.ProjectReportWorkAttachmentMapper;
|
|
|
+import com.jeeplus.finance.projectReport.service.CwProjectReportNumberApplyService;
|
|
|
import com.jeeplus.finance.projectReport.service.CwProjectReportService;
|
|
|
import com.jeeplus.finance.projectReport.service.dto.CwProjectReportDTO;
|
|
|
import com.jeeplus.finance.projectReport.service.dto.CwProjectReportSignatureDTO;
|
|
|
+import com.jeeplus.finance.projectReport.service.dto.NumberReplaceDTO;
|
|
|
import com.jeeplus.finance.projectReport.service.dto.ProjectReportWorkAttachmentDTO;
|
|
|
import com.jeeplus.finance.workClientInfo.service.dto.CwWorkClientBaseDTO;
|
|
|
import com.jeeplus.flowable.feign.IFlowableApi;
|
|
@@ -44,6 +48,11 @@ import freemarker.template.Template;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
@@ -56,6 +65,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.*;
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.lang.reflect.Type;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -69,6 +80,8 @@ import java.util.stream.Collectors;
|
|
|
@Api("财务报告信息")
|
|
|
@RequestMapping(value = "/cwProjectReport")
|
|
|
public class CwProjectReportController {
|
|
|
+ private static Logger log = LoggerFactory.getLogger(CwProjectReportController.class);
|
|
|
+
|
|
|
|
|
|
@Resource
|
|
|
private CwProjectReportService projectReportService;
|
|
@@ -78,6 +91,8 @@ public class CwProjectReportController {
|
|
|
private ProjectReportWorkAttachmentMapper attachmentMapper;
|
|
|
@Autowired
|
|
|
private IFlowableApi flowTaskService;
|
|
|
+ @Resource
|
|
|
+ private CwProjectReportNumberApplyService cwProjectReportNumberApplyService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -1151,5 +1166,89 @@ public class CwProjectReportController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 报告号替换
|
|
|
+ * @param file
|
|
|
+ * @param year
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiLog("报告号替换")
|
|
|
+ @PostMapping("numberReplace")
|
|
|
+ public void numberReplace(@RequestParam("file") MultipartFile file,@RequestParam("year") String year, HttpServletRequest request,HttpServletResponse response) throws IOException {
|
|
|
+ ArrayList<NumberReplaceDTO> replaceDTOArrayList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<NumberReplaceDTO> listA = new ArrayList<>();
|
|
|
+ //获取sheet
|
|
|
+ listA = EasyPoiUtil.importExcel(file, 0, 1, NumberReplaceDTO.class);
|
|
|
+ //去除excel中的空行
|
|
|
+ listA = getExcelList(listA);
|
|
|
+ //对报告号进行替换
|
|
|
+ cwProjectReportNumberApplyService.replaceNumber(listA,replaceDTOArrayList,year);
|
|
|
+ if (CollectionUtil.isNotEmpty(replaceDTOArrayList)){
|
|
|
+ //对文件再次进行导出
|
|
|
+ String fileName = file.getOriginalFilename ();
|
|
|
+ Workbook workbook = WorkbookFactory.create(file.getInputStream()); // 自动识别文件格式
|
|
|
+
|
|
|
+ // 获取第一个 sheet 的名称
|
|
|
+ Sheet sheet = workbook.getSheetAt(0); // 获取第一个 sheet
|
|
|
+ String sheetName = sheet.getSheetName(); // 获取 sheet 的名称
|
|
|
+
|
|
|
+ EasyPoiUtil.exportExcel ( replaceDTOArrayList, "报告信息", sheetName, NumberReplaceDTO.class, fileName, response );
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 去除excel中的空行
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<NumberReplaceDTO> getExcelList(List<NumberReplaceDTO> list){
|
|
|
+
|
|
|
+ ArrayList<NumberReplaceDTO> numberReplaceDTOS = new ArrayList<>();
|
|
|
+
|
|
|
+ list.stream().forEach(item->{
|
|
|
+ if(objectCheckIsNull(item)){
|
|
|
+ numberReplaceDTOS.add(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return numberReplaceDTOS;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static boolean objectCheckIsNull(Object object) {
|
|
|
+ boolean flag = false; //定义返回结果,默认为true
|
|
|
+
|
|
|
+ if (Objects.isNull(object)) {
|
|
|
+ flag = false;
|
|
|
+ } else {
|
|
|
+ Class clazz = (Class) object.getClass(); // 得到类对象
|
|
|
+ Field fields[] = clazz.getDeclaredFields(); // 得到所有属性
|
|
|
+ for (Field field : fields) {
|
|
|
+ if("serialVersionUID".equals(field.getName()) || "BIZ_CODE".equalsIgnoreCase(field.getName())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ field.setAccessible(true);
|
|
|
+ Object fieldValue = null;
|
|
|
+ try {
|
|
|
+ fieldValue = field.get(object); //得到属性值
|
|
|
+ Type fieldType = field.getGenericType();//得到属性类型
|
|
|
+ String fieldName = field.getName(); // 得到属性名
|
|
|
+ log.info("属性类型:" + fieldType + ",属性名:" + fieldName + ",属性值:" + fieldValue);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ if (fieldValue != null && fieldValue != "") { //只要有一个属性值不为null 就返回false 表示对象不为null
|
|
|
+ flag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
|
|
|
}
|