Browse Source

合同档案

chenc 3 years ago
parent
commit
124b59ac23

+ 5 - 0
pom.xml

@@ -206,6 +206,11 @@
 			<optional>true</optional>
 			<scope>true</scope>
 		</dependency>
+		<dependency>
+			<groupId>com.squareup.okhttp3</groupId>
+			<artifactId>okhttp</artifactId>
+			<version>3.9.1</version>
+		</dependency>
 		  
 	</dependencies>
 

+ 49 - 0
src/main/java/org/jeecg/common/util/OkHttpClientUtil.java

@@ -0,0 +1,49 @@
+package org.jeecg.common.util;
+
+import com.alibaba.fastjson.JSONObject;
+import okhttp3.FormBody;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import org.jeecg.common.util.oaEntity.OaEntity;
+
+import java.io.IOException;
+
+/**
+ * 功能描述:访问Oa系统请求
+ *
+ * @Author: chenchuang
+ * @Date: 2021/11/26 15:40
+ */
+public class OkHttpClientUtil {
+    public JSONObject getPost(OaEntity oaEntity){
+        JSONObject j=null;
+        OkHttpClient okHttpClient=new OkHttpClient();
+        okhttp3.RequestBody requestBody = new FormBody.Builder()
+                .add("procDefId",oaEntity.getProcDefId())
+                .add("title",oaEntity.getTitle())
+                .add("tableName",oaEntity.getTableName())
+                .add("externalUsername",oaEntity.getExternalUsername())
+                .add("tableId",oaEntity.getTableId())
+//                .add("procDefId","测试外部流程:1:175034")
+//                .add("title","测试外部流程")
+//                .add("tableName","外部表单contract-file")
+//                .add("externalUsername","chenc")
+                .build();
+        Request reqa = new Request.Builder()
+//                .url("http://127.0.0.1:8090/jeecg-boot/actBusiness/external/apply")
+                .url("http://127.0.0.1:8090/jeecg-boot"+oaEntity.getUrl())
+                .post(requestBody)
+//				 .get()
+//				 .method("POST", FormBody.create(MediaType.parse("application/json"),"" ))
+//				 .header("token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2Mzc5Mzg1NjQsInVzZXJuYW1lIjoiY2hlbmMifQ.4YUvC01eHOeF7_h9Dgt1qeKmAJgWkySMUe59GsA-oH8")
+                .build();
+
+        try {
+            String resBody = okHttpClient.newCall(reqa).execute().body().string();
+            j= JSONObject.parseObject(new String(resBody));
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return j;
+    }
+}

+ 70 - 0
src/main/java/org/jeecg/common/util/oaEntity/OaEntity.java

@@ -0,0 +1,70 @@
+package org.jeecg.common.util.oaEntity;
+
+/**
+ * 功能描述:
+ *
+ * @Author: chenchuang
+ * @Date: 2021/11/26 15:48
+ */
+public class OaEntity {
+    //流程id
+    private String procDefId;
+    //标题
+    private String title;
+    //表单业务数据id
+    private String tableId;
+    //表单名称(格式:“外部表单”+数据库表名称;例:外部表单test_demo)
+    private String tableName;
+    //当前登录人账号username
+    private String externalUsername;
+    //接口地址
+    private String url;
+
+    public String getProcDefId() {
+        return procDefId;
+    }
+
+    public void setProcDefId(String procDefId) {
+        this.procDefId = procDefId;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    public void setTableName(String tableName) {
+        this.tableName = tableName;
+    }
+
+    public String getExternalUsername() {
+        return externalUsername;
+    }
+
+    public void setExternalUsername(String externalUsername) {
+        this.externalUsername = externalUsername;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getTableId() {
+        return tableId;
+    }
+
+    public void setTableId(String tableId) {
+        this.tableId = tableId;
+    }
+}

+ 134 - 4
src/main/java/org/jeecg/modules/contract/file/controller/ContractFileController.java

@@ -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;
+  }
+
 }

+ 4 - 1
src/main/java/org/jeecg/modules/contract/file/entity/ContractFile.java

@@ -142,7 +142,10 @@ public class ContractFile implements Serializable {
 	private String fdCustomeraddress;
 	/**项目立项名称*/
 	@TableField(exist = false)
-private String proName;
+	private String proName;
+	/**里程碑类型名称*/
+	@TableField(exist = false)
+	private String milestoneName;
 
 	/**合同产品子表*/
 	@TableField(exist = false)

+ 10 - 1
src/main/java/org/jeecg/modules/contract/file/mapper/ContractFileMapper.java

@@ -2,6 +2,8 @@ package org.jeecg.modules.contract.file.mapper;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.contract.file.entity.ContractFile;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -13,5 +15,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @version: V1.0
  */
 public interface ContractFileMapper extends BaseMapper<ContractFile> {
-
+    /**
+    * @Author chenchuang
+    * @Description //TODO 合同分页查询
+    * @Date 2021/11/25 11:57
+    * @Param [page, queryWrapper]
+    * @return com.baomidou.mybatisplus.core.metadata.IPage<org.jeecg.modules.contract.file.entity.ContractFile>
+    */
+    IPage<ContractFile> getPageList(IPage<ContractFile> page, @Param("ew") QueryWrapper<ContractFile> queryWrapper);
 }

+ 11 - 1
src/main/java/org/jeecg/modules/contract/file/mapper/xml/ContractFileMapper.xml

@@ -1,5 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.contract.file.mapper.ContractFileMapper">
-
+    <select id="getPageList" resultType="org.jeecg.modules.contract.file.entity.ContractFile">
+        SELECT
+            cf.*,
+            fc.NAME AS fdCustomerName,
+            bapa.NAME AS proName
+        FROM
+            contract_file cf
+            LEFT JOIN fd_customer fc ON cf.fd_customer_id = fc.id
+            LEFT JOIN base_archives_project_approval bapa ON bapa.id = cf.pro_id
+            ${ew.customSqlSegment}
+    </select>
 </mapper>

+ 12 - 0
src/main/java/org/jeecg/modules/contract/file/service/IContractFileService.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.contract.file.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.jeecg.modules.contract.file.entity.ContractFile;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -10,6 +12,16 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @version: V1.0
  */
 public interface IContractFileService extends IService<ContractFile> {
+
+    /**
+     * @Author chenchuang
+     * @Description //TODO 合同分页查询
+     * @Date 2021/11/25 11:57
+     * @Param [page, queryWrapper]
+     * @return com.baomidou.mybatisplus.core.metadata.IPage<org.jeecg.modules.contract.file.entity.ContractFile>
+     */
+    IPage<ContractFile> getPageList(IPage<ContractFile> page,QueryWrapper<ContractFile> queryWrapper);
+
     /**
     * @Author chenchuang
     * @Description //TODO 主表和子表一起新增

+ 7 - 1
src/main/java/org/jeecg/modules/contract/file/service/impl/ContractFileServiceImpl.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.contract.file.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.jeecg.modules.contract.file.entity.ContractFile;
 import org.jeecg.modules.contract.file.entity.ContractFileAndBusiness;
 import org.jeecg.modules.contract.file.entity.ContractFileModular;
@@ -36,6 +37,11 @@ public class ContractFileServiceImpl extends ServiceImpl<ContractFileMapper, Con
     @Resource
     IContractFileAndBusinessService iContractFileAndBusinessService;
 
+    @Override
+    public IPage<ContractFile> getPageList(IPage<ContractFile> page, QueryWrapper<ContractFile> queryWrapper) {
+        return contractFileMapper.getPageList(page,queryWrapper);
+    }
+
     @Override
     public void saveMainAndChild(ContractFile contractFile) {
         //新增主表
@@ -180,6 +186,6 @@ public class ContractFileServiceImpl extends ServiceImpl<ContractFileMapper, Con
         contractFileAndBusinessQueryWrapper.lambda().eq(ContractFileAndBusiness::getContractFileId,contractFile.getId());
         ContractFileAndBusiness contractFileAndBusiness=new ContractFileAndBusiness();
         contractFileAndBusiness.setDelFlag("1");
-        iContractFileAndBusinessService.update(contractFileAndBusinessQueryWrapper);
+        iContractFileAndBusinessService.update(contractFileAndBusiness,contractFileAndBusinessQueryWrapper);
     }
 }