|
@@ -1,16 +1,23 @@
|
|
|
package org.jeecg.modules.contract.file.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.util.oaEntity.OaEntity;
|
|
|
+import org.jeecg.common.util.OkHttpClientUtil;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.basedata.entity.BaseArchivesProjectApproval;
|
|
|
+import org.jeecg.modules.basedata.entity.FdCustomer;
|
|
|
+import org.jeecg.modules.basedata.service.BaseArchivesProjectApprovalService;
|
|
|
+import org.jeecg.modules.basedata.service.IFdCustomerService;
|
|
|
import org.jeecg.modules.contract.file.entity.ContractFile;
|
|
|
import org.jeecg.modules.contract.file.service.IContractFileService;
|
|
|
|
|
@@ -19,6 +26,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import org.jeecg.modules.system.service.ISysDictService;
|
|
|
+import org.jeecg.modules.system.service.ISysSerialPatternService;
|
|
|
+import org.jeecg.modules.system.vo.CallResult;
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
@@ -45,6 +55,17 @@ import com.alibaba.fastjson.JSON;
|
|
|
public class ContractFileController {
|
|
|
@Autowired
|
|
|
private IContractFileService contractFileService;
|
|
|
+ @Autowired
|
|
|
+ private IFdCustomerService iFdCustomerService;
|
|
|
+ @Autowired
|
|
|
+ private ISysDictService iSysDictService;
|
|
|
+ @Autowired
|
|
|
+ private ISysSerialPatternService sysSerialPatternService;
|
|
|
+ @Autowired
|
|
|
+ private BaseArchivesProjectApprovalService baseArchivesProjectApprovalService;
|
|
|
+
|
|
|
+// @Autowired
|
|
|
+// private OkHttpClient okHttpClient;
|
|
|
|
|
|
/**
|
|
|
* 分页列表查询
|
|
@@ -67,9 +88,68 @@ public class ContractFileController {
|
|
|
IPage<ContractFile> pageList = contractFileService.page(page, queryWrapper);
|
|
|
result.setSuccess(true);
|
|
|
result.setResult(pageList);
|
|
|
+
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author chenchuang
|
|
|
+ * @Description //TODO 分页查询
|
|
|
+ * @Date 2021/11/25 13:35
|
|
|
+ * @Param [contractFile, pageNo, pageSize, req]
|
|
|
+ * @return org.jeecg.common.api.vo.Result<com.baomidou.mybatisplus.core.metadata.IPage<org.jeecg.modules.contract.file.entity.ContractFile>>
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/getPageList")
|
|
|
+ public Result<IPage<ContractFile>> getPageList(ContractFile contractFile,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ Result<IPage<ContractFile>> result = new Result<IPage<ContractFile>>();
|
|
|
+ String pkOrg="";
|
|
|
+ if(StringUtils.isNotBlank(contractFile.getPkOrg())){
|
|
|
+ pkOrg=contractFile.getPkOrg();
|
|
|
+ contractFile.setPkOrg(null);
|
|
|
+ }
|
|
|
+ String code="";
|
|
|
+ if(StringUtils.isNotBlank(contractFile.getCode())){
|
|
|
+ code=contractFile.getCode();
|
|
|
+ contractFile.setCode(null);
|
|
|
+ }
|
|
|
+ QueryWrapper<ContractFile> queryWrapper = QueryGenerator.initQueryWrapper(contractFile, req.getParameterMap());
|
|
|
+ queryWrapper.eq("cf.del_flag","0");
|
|
|
+ queryWrapper.eq("cf.pk_org",pkOrg);
|
|
|
+ if(StringUtils.isNotBlank(code)){
|
|
|
+ queryWrapper.eq("cf.code",code);
|
|
|
+ }
|
|
|
+ queryWrapper.orderByDesc("cf.create_time");
|
|
|
+ Page<ContractFile> page = new Page<ContractFile>(pageNo, pageSize);
|
|
|
+ IPage<ContractFile> pageList = contractFileService.getPageList(page, queryWrapper);
|
|
|
+ getDictName(pageList.getRecords());
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取数据字典数据
|
|
|
+ public void getDictName(List<ContractFile> contractFileList){
|
|
|
+ if(contractFileList!=null&&contractFileList.size()>0){
|
|
|
+ //获取里程碑类型名称
|
|
|
+ //里程碑类型数据字典数据
|
|
|
+ List<Map<String,Object>> dictList= iSysDictService.queryDictItemsByCode("base_archives_milestone_type");
|
|
|
+ if(dictList!=null){
|
|
|
+ for(ContractFile contractFile:contractFileList){
|
|
|
+ for(Map<String,Object> dict:dictList){
|
|
|
+ if(contractFile.getMilestoneId().equals(dict.get("value").toString())){
|
|
|
+ contractFile.setMilestoneName(dict.get("text").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
* @param contractFile
|
|
@@ -100,6 +180,12 @@ public class ContractFileController {
|
|
|
public Result<ContractFile> saveMainAndChild(@RequestBody ContractFile contractFile) {
|
|
|
Result<ContractFile> result = new Result<ContractFile>();
|
|
|
try {
|
|
|
+ // 设置编码
|
|
|
+ CallResult<String> nextSerial = sysSerialPatternService.getNextSerial(contractFile, "contract_file", "code", true);
|
|
|
+ if(!nextSerial.isSucceed()){
|
|
|
+ throw new RuntimeException("获取编号失败");
|
|
|
+ }
|
|
|
+ contractFile.setCode(nextSerial.getContent());
|
|
|
contractFileService.saveMainAndChild(contractFile);
|
|
|
result.success("添加成功!");
|
|
|
} catch (Exception e) {
|
|
@@ -252,6 +338,11 @@ public class ContractFileController {
|
|
|
if(contractFile==null) {
|
|
|
result.error500("未找到对应实体");
|
|
|
}else {
|
|
|
+ //获取客户名称
|
|
|
+ FdCustomer fdCustomer= iFdCustomerService.getById(contractFile.getFdCustomerId());
|
|
|
+ if(fdCustomer!=null){
|
|
|
+ contractFile.setFdCustomerName(fdCustomer.getName());
|
|
|
+ }
|
|
|
//获取所有子表数据
|
|
|
contractFileService.queryMainAndChildById(contractFile);
|
|
|
result.setResult(contractFile);
|
|
@@ -329,4 +420,43 @@ public class ContractFileController {
|
|
|
return Result.ok("文件导入失败!");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Author chenchuang
|
|
|
+ * @Description //TODO 提交流程
|
|
|
+ * @Date 2021/11/26 16:15
|
|
|
+ * @Param [id]
|
|
|
+ * @return org.jeecg.common.api.vo.Result
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/submitProcess")
|
|
|
+ public Result submitProcess(@RequestParam(name="id",required=true) String id){
|
|
|
+ Result result=new Result();
|
|
|
+ ContractFile contractFile = contractFileService.getById(id);
|
|
|
+ if(contractFile==null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ }else {
|
|
|
+ OkHttpClientUtil okHttpClientUtil = new OkHttpClientUtil();
|
|
|
+ //参数
|
|
|
+ OaEntity oaEntity = new OaEntity();
|
|
|
+ oaEntity.setUrl("/actBusiness/external/apply");
|
|
|
+ oaEntity.setExternalUsername("chenc");
|
|
|
+ oaEntity.setProcDefId("测试外部流程:1:175034");
|
|
|
+ oaEntity.setTableName("外部表单contract-file");
|
|
|
+ //获取项目立项名称
|
|
|
+ BaseArchivesProjectApproval projectApproval= baseArchivesProjectApprovalService.getById(contractFile.getProId());
|
|
|
+ if(projectApproval!=null){
|
|
|
+ oaEntity.setTitle(projectApproval.getName());
|
|
|
+ }
|
|
|
+ oaEntity.setTableId(id);
|
|
|
+ //调用Oa接口
|
|
|
+ JSONObject jsonObject = okHttpClientUtil.getPost(oaEntity);
|
|
|
+ if (jsonObject.get("success").toString().equals("true")) {
|
|
|
+ result.success("提交成功");
|
|
|
+ } else {
|
|
|
+ result.setSuccess(false);
|
|
|
+ result.setMessage("提交失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|