yusm пре 5 месеци
родитељ
комит
a0d099ebdf
18 измењених фајлова са 1575 додато и 105 уклоњено
  1. 28 13
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContractController.java
  2. 19 2
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContractPaymentController.java
  3. 35 1
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContractTypeSecController.java
  4. 8 2
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/CompanyDingding.java
  5. 21 2
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Contract.java
  6. 3 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/ContractTypeSec.java
  7. 2 2
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/ContractMapper.java
  8. 11 4
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ContractService.java
  9. 10 1
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ContractTypeSecService.java
  10. 13 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/DingDingService.java
  11. 7 6
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ExcelExportService.java
  12. 733 36
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContractServiceImpl.java
  13. 117 2
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContractTypeSecServiceImpl.java
  14. 398 26
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java
  15. 2 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java
  16. 138 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/util/ExcelUtil.java
  17. 1 1
      fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ContractLogMapper.xml
  18. 29 7
      fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ContractMapper.xml

+ 28 - 13
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContractController.java

@@ -2,9 +2,7 @@ package com.management.platform.controller;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.management.platform.entity.Contract;
-import com.management.platform.entity.Project;
-import com.management.platform.entity.User;
+import com.management.platform.entity.*;
 import com.management.platform.mapper.ProjectMapper;
 import com.management.platform.mapper.UserMapper;
 import com.management.platform.service.ContractService;
@@ -44,16 +42,27 @@ public class ContractController {
      * 分页查询合同
      */
     @RequestMapping("/getContractPage")
-    public HttpRespMsg getContractPage (HttpServletRequest request, @RequestParam Integer pageIndex, @RequestParam Integer pageSize, String number,String name,String typeName,Integer status,String startDate,String endDate, String paymentStartDate, String paymentEndDate){
-        return contractService.getContractPage(request,pageIndex,pageSize,number,name,typeName,status,startDate,endDate, paymentStartDate, paymentEndDate);
+    public HttpRespMsg getContractPage (HttpServletRequest request, @RequestParam Integer pageIndex, @RequestParam Integer pageSize, String number,String name,String typeName,Integer status,
+                                        String startDate,String endDate, String paymentStartDate, String paymentEndDate, Integer secTypeId,@RequestParam(required = false) String customerOrg,@RequestParam(required = false) Integer finishStatus){
+        return contractService.getContractPage(request,pageIndex,pageSize,number,name,typeName,status,startDate,endDate, paymentStartDate, paymentEndDate, secTypeId,customerOrg,finishStatus);
     }
 
     /**
      * 导出合同
      */
-    @RequestMapping("/ExportContract")
-    public HttpRespMsg ExportContract (HttpServletRequest request, String number,String name,String typeName,Integer status,String startDate,String endDate, String paymentStartDate, String paymentEndDate){
-        return contractService.ExportContract(request,number,name,typeName,status,startDate,endDate, paymentStartDate, paymentEndDate);
+    @RequestMapping("/exportContract")
+    public HttpRespMsg exportContract (HttpServletRequest request, String number,String name,String typeName,Integer status,String startDate,
+                                       String endDate, String paymentStartDate, String paymentEndDate, Integer secTypeId,@RequestParam(required = false) String customerOrg,@RequestParam(required = false) Integer finishStatus){
+        return contractService.ExportContract(request,number,name,typeName,status,startDate,endDate, paymentStartDate, paymentEndDate, secTypeId,customerOrg,finishStatus);
+    }
+
+    /**
+     * 导出合同
+     */
+    @RequestMapping("/exportContractOneToMany")
+    public HttpRespMsg exportContractOneToMany (HttpServletRequest request, String number,String name,String typeName,Integer status,String startDate,
+                                                String endDate, String paymentStartDate, String paymentEndDate, Integer secTypeId,@RequestParam(required = false) String customerOrg,@RequestParam(required = false) Integer finishStatus){
+        return contractService.exportContractOneToMany(request,number,name,typeName,status,startDate,endDate, paymentStartDate, paymentEndDate, secTypeId,customerOrg,finishStatus);
     }
 
     /**
@@ -61,23 +70,29 @@ public class ContractController {
      */
     @RequestMapping("/importContract")
     public HttpRespMsg importContract (HttpServletRequest request, MultipartFile file){
-        return contractService.importContract(request,file);
+        String token = request.getHeader("TOKEN");
+        User user = userMapper.selectById(token);
+        if (user.getCompanyId() == 10 || user.getCompanyId() == 4215) {
+            return contractService.importContractCustom(request,file);
+        } else {
+            return contractService.importContract(request,file);
+        }
     }
 
     /**
      * 新增合同
      */
     @RequestMapping("/addContract")
-    public HttpRespMsg addContract (HttpServletRequest request,Contract contract, String paymentListStr){
-        return contractService.addContract(request,contract, paymentListStr);
+    public HttpRespMsg addContract (HttpServletRequest request, Contract contract, ContractCustom custom, String paymentListStr){
+        return contractService.addContract(request,contract, custom, paymentListStr);
     }
 
     /**
      * 编辑合同
      */
     @RequestMapping("/editContract")
-    public HttpRespMsg editContract (HttpServletRequest request,Contract contract, String paymentListStr){
-        return contractService.editContract(request,contract, paymentListStr);
+    public HttpRespMsg editContract (HttpServletRequest request,Contract contract,ContractCustom custom, String paymentListStr){
+        return contractService.editContract(request,contract, custom, paymentListStr);
     }
 
     /**

+ 19 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContractPaymentController.java

@@ -2,14 +2,19 @@ package com.management.platform.controller;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.management.platform.entity.ContractPayCustomized;
 import com.management.platform.entity.ContractPayment;
+import com.management.platform.entity.User;
+import com.management.platform.service.ContractPayCustomizedService;
 import com.management.platform.service.ContractPaymentService;
+import com.management.platform.service.UserService;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 
 /**
  * <p>
@@ -26,10 +31,22 @@ public class ContractPaymentController {
     @Resource
     private ContractPaymentService contractPaymentService;
 
+    @Resource
+    private UserService userService;
+
+    @Resource
+    private ContractPayCustomizedService payCustomizedService;
+
     @RequestMapping("/getList")
-    public HttpRespMsg getList(Integer contractId) {
+    public HttpRespMsg getList(HttpServletRequest request,Integer contractId) {
         HttpRespMsg msg = new HttpRespMsg();
-        msg.data = contractPaymentService.list(new QueryWrapper<ContractPayment>().eq("contract_id", contractId));
+        String token = request.getHeader("token");
+        User user = userService.getById(token);
+        if (user.getCompanyId()!=4215){
+            msg.data = contractPaymentService.list(new QueryWrapper<ContractPayment>().eq("contract_id", contractId));
+        }else {
+            msg.data = payCustomizedService.list(new QueryWrapper<ContractPayCustomized>().eq("contract_id", contractId));
+        }
         return msg;
     }
 

+ 35 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContractTypeSecController.java

@@ -1,21 +1,55 @@
 package com.management.platform.controller;
 
 
+import com.management.platform.entity.ContractType;
+import com.management.platform.entity.ContractTypeSec;
+import com.management.platform.service.ContractTypeSecService;
+import com.management.platform.service.ContractTypeService;
+import com.management.platform.util.HttpRespMsg;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
 /**
  * <p>
  *  前端控制器
  * </p>
  *
  * @author Seyason
- * @since 2024-11-25
+ * @since 2024-09-14
  */
 @RestController
 @RequestMapping("/contract-type-sec")
 public class ContractTypeSecController {
+    @Resource
+    private ContractTypeSecService contractTypeSecService;
+
+    /**
+     * 返回公司自定义合同类型
+     */
+    @RequestMapping("/getContractType")
+    public HttpRespMsg getContractType (HttpServletRequest request){
+
+        return contractTypeSecService.getContractType(request);
+    }
+
+    /**
+     * 新增、修改合同类型
+     */
+    @RequestMapping("/changeContractType")
+    public HttpRespMsg changeContractType (HttpServletRequest request, ContractTypeSec contractType){
+        return contractTypeSecService.changeContractType(request,contractType);
+    }
 
+    /**
+     * 删除合同类型
+     */
+    @RequestMapping("/deleteContractType")
+    public HttpRespMsg deleteContractType (HttpServletRequest request, Integer deleteId){
+        return contractTypeSecService.deleteContractType(request,deleteId);
+    }
 }
 

+ 8 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/CompanyDingding.java

@@ -11,11 +11,11 @@ import lombok.experimental.Accessors;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author Seyason
- * @since 2023-05-26
+ * @since 2024-04-20
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -108,6 +108,12 @@ public class CompanyDingding extends Model<CompanyDingding> {
     @TableField("sync_contact")
     private Integer syncContact;
 
+    /**
+     * 通讯录是否需要转译
+     */
+    @TableField("contact_need_translate")
+    private Integer contactNeedTranslate;
+
 
     @Override
     protected Serializable pkVal() {

+ 21 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Contract.java

@@ -16,11 +16,11 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author Seyason
- * @since 2023-05-24
+ * @since 2024-09-14
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -160,6 +160,25 @@ public class Contract extends Model<Contract> {
     @TableField(exist = false)
     private BigDecimal nextPaymentAmount;
 
+    @TableField(exist = false)
+    public ContractCustom customData;
+
+    @TableField(exist = false)
+    public ContractPayCustomized payCustomizedData;
+
+    /**
+     * 二级分类id
+     */
+    @TableField("sec_type_id")
+    private Integer secTypeId;
+
+    /**
+     * 二级分类名称
+     */
+    @TableField(exist = false)
+    private String secTypeName;
+
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 3 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/ContractTypeSec.java

@@ -48,6 +48,9 @@ public class ContractTypeSec extends Model<ContractTypeSec> {
     @TableField("main_type_id")
     private Integer mainTypeId;
 
+    @TableField(exist = false)
+    private String mainTypeName;
+
 
     @Override
     protected Serializable pkVal() {

+ 2 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/ContractMapper.java

@@ -14,6 +14,6 @@ import java.util.List;
  * @since 2022-11-29
  */
 public interface ContractMapper extends BaseMapper<Contract> {
-    List<Contract> selectContract(Integer companyId, Integer pageStart, Integer pageSize, String number, String name, String typeName, Integer status, String startDate,String endDate, String paymentStartDate, String paymentEndDate);
-    Long selectContractCnt(Integer companyId, String number, String name, String typeName, Integer status, String startDate,String endDate, String paymentStartDate, String paymentEndDate);
+    List<Contract> selectContract(Integer companyId, Integer pageStart, Integer pageSize, String number, String name, String typeName, Integer status, String startDate,String endDate, String paymentStartDate, String paymentEndDate, Integer secTypeId,String customerOrg,Integer finishStatus);
+    Long selectContractCnt(Integer companyId, String number, String name, String typeName, Integer status, String startDate,String endDate, String paymentStartDate, String paymentEndDate, Integer secTypeId,String customerOrg,Integer finishStatus);
 }

+ 11 - 4
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ContractService.java

@@ -2,6 +2,8 @@ package com.management.platform.service;
 
 import com.management.platform.entity.Contract;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.management.platform.entity.ContractCustom;
+import com.management.platform.entity.ContractPayCustomized;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.multipart.MultipartFile;
@@ -19,19 +21,24 @@ import java.util.List;
  */
 public interface ContractService extends IService<Contract> {
 
-    HttpRespMsg getContractPage(HttpServletRequest request, Integer pageIndex, Integer pageSize, String number, String name, String typeName, Integer status, String startDate, String endDate, String paymentStartDate, String paymentEndDate);
+    HttpRespMsg getContractPage(HttpServletRequest request, Integer pageIndex, Integer pageSize, String number, String name, String typeName, Integer status, String startDate, String endDate, String paymentStartDate, String paymentEndDate, Integer secTypeId,String customerOrg,Integer finishStatus);
 
-    HttpRespMsg ExportContract(HttpServletRequest request, String number, String name, String typeName, Integer status, String startDate, String endDate, String paymentStartDate, String paymentEndDate);
+    HttpRespMsg ExportContract(HttpServletRequest request, String number, String name, String typeName, Integer status, String startDate, String endDate, String paymentStartDate, String paymentEndDate, Integer secTypeId,String customerOrg,Integer finishStatus);
 
-    HttpRespMsg addContract(HttpServletRequest request, Contract contract, String paymentListStr);
+    HttpRespMsg addContract(HttpServletRequest request, Contract contract, ContractCustom custom, String paymentListStr);
 
-    HttpRespMsg editContract(HttpServletRequest request, Contract contract, String paymentListStr);
+    HttpRespMsg editContract(HttpServletRequest request, Contract contract, ContractCustom custom, String paymentListStr);
 
     HttpRespMsg importContract(HttpServletRequest request, MultipartFile file);
 
+    HttpRespMsg importContractCustom(HttpServletRequest request, MultipartFile file);
+
     HttpRespMsg processContract(HttpServletRequest request, Integer id, Integer status ,String msg);
 
     HttpRespMsg contractFile(HttpServletRequest request, Integer id);
 
     HttpRespMsg deleteContract(HttpServletRequest request, Integer id);
+
+    HttpRespMsg exportContractOneToMany(HttpServletRequest request, String number, String name, String typeName, Integer status, String startDate,
+                                        String endDate, String paymentStartDate, String paymentEndDate, Integer secTypeId,String customerOrg,Integer finishStatus);
 }

+ 10 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ContractTypeSecService.java

@@ -1,7 +1,11 @@
 package com.management.platform.service;
 
+import com.management.platform.entity.ContractType;
 import com.management.platform.entity.ContractTypeSec;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.management.platform.util.HttpRespMsg;
+
+import javax.servlet.http.HttpServletRequest;
 
 /**
  * <p>
@@ -9,8 +13,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * </p>
  *
  * @author Seyason
- * @since 2024-11-25
+ * @since 2024-09-14
  */
 public interface ContractTypeSecService extends IService<ContractTypeSec> {
 
+    HttpRespMsg getContractType(HttpServletRequest request);
+
+    HttpRespMsg changeContractType(HttpServletRequest request, ContractTypeSec contractTypeSec);
+
+    HttpRespMsg deleteContractType(HttpServletRequest request, Integer deleteId);
 }

+ 13 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/DingDingService.java

@@ -2,6 +2,7 @@ package com.management.platform.service;
 
 import com.alibaba.fastjson.JSONArray;
 import com.management.platform.entity.CompanyDingding;
+import com.management.platform.entity.UserDingdingTime;
 import com.management.platform.util.HttpRespMsg;
 import com.taobao.api.ApiException;
 
@@ -52,4 +53,16 @@ public interface DingDingService {
     String inactiveUserNotInAuthRange(String corpid);
 
     HttpRespMsg fixAttendance(Integer companyId);
+
+    String getTranslationMediaId(String fileName,CompanyDingding dingding) throws Exception;
+
+    String syncTranslation(String mediaId,String fileName,String unionId,CompanyDingding dingding) throws Exception;
+
+    String getSyncTranslationResult(String jobId,CompanyDingding dingding) throws Exception;
+
+    HttpRespMsg getAuthInfo(String corpid) throws Exception;
+
+    HttpRespMsg refreshUserCardTime(Integer companyId, String userId, String date);
+
+    UserDingdingTime listUserScheduleByDay(Integer companyId, String userId, String date);
 }

+ 7 - 6
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ExcelExportService.java

@@ -1,5 +1,6 @@
 package com.management.platform.service;
 
+import com.management.platform.entity.CompanyDingding;
 import com.management.platform.entity.WxCorpInfo;
 import com.management.platform.util.HttpRespMsg;
 
@@ -8,11 +9,11 @@ import java.util.Map;
 
 public interface ExcelExportService {
     public void testRead(String jobId);
-    public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception;
-    public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception;
-    public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception;
-    public HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo,String title) throws Exception;
+    public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
+    public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
+    public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception;
+    public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndListNew(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception;
+    public HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title) throws Exception;
     void testAdd(String jobId);
-
-    HttpRespMsg exportGeneralExcelForExpense(WxCorpInfo wxCorpInfo, String fileName, List<List<String>> allList, List<Map> mapList, String path) throws Exception;
+    HttpRespMsg exportGeneralExcelForExpense(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String fileName, List<List<String>> allList, List<Map> mapList, String path) throws Exception;
 }

Разлика између датотеке није приказан због своје велике величине
+ 733 - 36
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContractServiceImpl.java


+ 117 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContractTypeSecServiceImpl.java

@@ -1,20 +1,135 @@
 package com.management.platform.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.management.platform.entity.Contract;
+import com.management.platform.entity.ContractType;
 import com.management.platform.entity.ContractTypeSec;
-import com.management.platform.mapper.ContractTypeSecMapper;
+import com.management.platform.entity.User;
+import com.management.platform.entity.vo.SysRichFunction;
+import com.management.platform.mapper.*;
 import com.management.platform.service.ContractTypeSecService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.management.platform.service.ExcelExportService;
+import com.management.platform.util.HttpRespMsg;
+import com.management.platform.util.MessageUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
  * </p>
  *
  * @author Seyason
- * @since 2024-11-25
+ * @since 2024-09-14
  */
 @Service
 public class ContractTypeSecServiceImpl extends ServiceImpl<ContractTypeSecMapper, ContractTypeSec> implements ContractTypeSecService {
+    @Resource
+    private ContractTypeSecMapper contractTypeSecMapper;
+    @Resource
+    private ContractTypeMapper contractTypeMapper;
+    @Resource
+    private ContractMapper contractMapper;
+    @Resource
+    private UserMapper userMapper;
+    @Resource
+    private SysFunctionMapper sysFunctionMapper;
+
+    /**
+     * 返回公司自定义合同类型
+     * @param request
+     * @return
+     */
+    @Override
+    public HttpRespMsg getContractType(HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        String token = request.getHeader("token");
+        User user = userMapper.selectById(token);
+        List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部合同");
+        if(functionContractList.size() <= 0){
+            return httpRespMsg;
+        }
+        List<ContractTypeSec> types = contractTypeSecMapper.selectList(new QueryWrapper<ContractTypeSec>().eq("company_id", user.getCompanyId()));
+        List<ContractType> mainList = contractTypeMapper.selectList(new QueryWrapper<ContractType>().eq("company_id", user.getCompanyId()));
+        for (ContractTypeSec secType : types) {
+            secType.setMainTypeName(mainList.stream().filter(mainType -> mainType.getId().equals(secType.getMainTypeId())).findFirst().get().getTypeName());
+        }
+        httpRespMsg.data = types;
+        return httpRespMsg;
+    }
+
+    /**
+     * 新增、修改合同类型
+     * @param request
+     * @param contractType
+     * @return
+     */
+    @Override
+    public HttpRespMsg changeContractType(HttpServletRequest request, ContractTypeSec contractType) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        String token = request.getHeader("token");
+        User user = userMapper.selectById(token);
+        List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "合同类型管理");
+        if(functionContractList.size() <= 0){
+            httpRespMsg.setError(MessageUtils.message("access.operationError"));
+            return httpRespMsg;
+        }
+        if (StringUtils.isBlank(contractType.getSecTypeName())){
+            //合同类型名不可为空
+            httpRespMsg.setError(MessageUtils.message("contract.typeNameEmpty"));
+            return httpRespMsg;
+        }
+        List<ContractTypeSec> types = contractTypeSecMapper.selectList(new QueryWrapper<ContractTypeSec>().eq("company_id", user.getCompanyId()));
+        //新增或修改自定义类型
+        for (ContractTypeSec type : types) {
+            if (type.getSecTypeName().equals(contractType.getSecTypeName()) && type.getMainTypeId().equals(contractType.getMainTypeId()) && !type.getId().equals(contractType.getId())){
+                //类型名不可重复
+                httpRespMsg.setError("[" + type.getSecTypeName() + "]" + MessageUtils.message("contract.typeNameRepeat"));
+                return httpRespMsg;
+            }
+        }
+        if (contractType.getId() == null){
+            contractType.setCompanyId(user.getCompanyId());
+            contractTypeSecMapper.insert(contractType);
+        }else {
+            contractType.setCompanyId(null);
+            contractTypeSecMapper.updateById(contractType);
+        }
+        //操作成功
+        httpRespMsg.msg = MessageUtils.message("contract.operationSuc");
+        return httpRespMsg;
+    }
+
+    /**
+     * 删除合同类型
+     * @param request
+     * @param deleteId
+     * @return
+     */
+    @Override
+    public HttpRespMsg deleteContractType(HttpServletRequest request, Integer deleteId) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        String token = request.getHeader("token");
+        User user = userMapper.selectById(token);
+        List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "合同类型管理");
+        if(functionContractList.size() <= 0){
+            httpRespMsg.setError(MessageUtils.message("access.deleteError"));
+            return httpRespMsg;
+        }
+        List<Contract> types = contractMapper.selectList(new QueryWrapper<Contract>().eq("sec_type_id", deleteId));
+        if (types.size() > 0){
+            //该类型尚有合同在使用,无法删除!
+            httpRespMsg.setError(MessageUtils.message("Contract.typeDelError"));
+        }else {
+            contractTypeSecMapper.deleteById(deleteId);
+            httpRespMsg.setMsg(MessageUtils.message("file.deleteSuc"));
+        }
+        return httpRespMsg;
+    }
 
 }

+ 398 - 26
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java

@@ -1,25 +1,25 @@
 package com.management.platform.service.impl;
 
+import com.management.platform.entity.CompanyDingding;
 import com.management.platform.entity.CorpwxJobResult;
+import com.management.platform.entity.User;
 import com.management.platform.entity.WxCorpInfo;
 import com.management.platform.mapper.CorpwxJobResultMapper;
+import com.management.platform.mapper.UserMapper;
+import com.management.platform.service.DingDingService;
 import com.management.platform.service.ExcelExportService;
 import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
-import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.ss.usermodel.BorderStyle;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.FillPatternType;
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.FileSystemResource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.io.File;
-import java.io.FileOutputStream;
+import javax.servlet.http.HttpServletRequest;
 import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
@@ -29,11 +29,20 @@ import java.util.Map;
 public class ExcelExportServiceImpl implements ExcelExportService {
     //用于控制线程锁
     public static HashMap<String, CorpwxJobResult> corpwxJobCenter = new HashMap();
+    public static HashMap<String, Integer> corpddJobCenter = new HashMap();
     @Resource
     private WxCorpInfoService wxCorpInfoService;
+    @Resource
+    private DingDingService dingDingService;
+    @Resource
+    private HttpServletRequest request;
+    @Resource
+    private UserMapper userMapper;
 
     @Resource
     private CorpwxJobResultMapper corpwxJobResultMapper;
+    @Value("${upload.path}")
+    private String path;
 
     @Transactional(isolation = Isolation.READ_COMMITTED)
     public void testRead(String jobId) {
@@ -61,7 +70,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
         }
     }
 
-    public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception {
+    public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         if (title.contains("/")) {
             //文件名不能含有路径,得替换掉
@@ -74,9 +83,33 @@ public class ExcelExportServiceImpl implements ExcelExportService {
         String resp = ExcelUtil.exportGeneralExcelByTitleAndList(title, list, downloadPath);
         String fileUrlSuffix = title + ".xlsx";
         if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
+            FileSystemResource fileSystemResource = new FileSystemResource(path+fileUrlSuffix);
+//            String md5 = DigestUtils.md5Hex(FileUtil.readBytes(fileSystemResource.getFile()));
+
+            Long checkSize = 20L*1024*1024;
+            if(fileSystemResource.getFile().length() >= checkSize){
+                httpRespMsg.setError("文件过大,请缩短查询日期范围");
+                return httpRespMsg;
+            }
+            String jobId = "";
             String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
-            String jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+            jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+//            if(fileSystemResource.getFile().length() >= checkSize){
+//                String tmpFileJobId = wxCorpInfoService.getTranslationJobId(fileUrlSuffix,md5,wxCorpInfo);
+//                if(!StringUtils.isEmpty(tmpFileJobId)){
+//                    String mediaId = wxCorpInfoService.getAsyncJobResult(tmpFileJobId,wxCorpInfo);
+//                    jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+//                }
+//            }else{
+//                String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
+//                jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+//            }
+
             System.out.println("上传待转译文件到企业微信, jobId==" + jobId);
+//            if(StringUtils.isEmpty(jobId)){
+//                httpRespMsg.setError("转义jobId为空,请联系管理员");
+//                return httpRespMsg;
+//            }
             int i = 0;
             String syncTranslationResult = null;
             /**
@@ -84,7 +117,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
              * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
              */
             long t = System.currentTimeMillis();
-            while (i < 30) {
+            while (i < 40) {
                 if (i < 10) {
                     Thread.sleep(300);
                 } else if (i < 20){
@@ -94,26 +127,176 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 }
                 System.out.println("i=="+i+", "+LocalDateTime.now());
                 CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
+                if (corpwxJobResult != null) {
+                    if (corpwxJobResult.getErrCode() == 0) {
+                        syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
+                        corpwxJobCenter.remove(jobId);
+                    } else {
+                        long t2 = System.currentTimeMillis();
+                        System.out.println("222企业微信转译报错:"+corpwxJobResult.getErrMsg()+",耗时:" + (t2 - t) + "ms");
+                        httpRespMsg.setError(corpwxJobResult.getErrMsg());
+                        return httpRespMsg;
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
+            User user = userMapper.selectById(request.getHeader("token"));
+            String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
+            String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
+            System.out.println("上传待转译文件到钉钉, jobId==" + jobId);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            long t = System.currentTimeMillis();
+            while (i < 30) {
+                if (i < 10) {
+                    Thread.sleep(300);
+                } else if (i < 20){
+                    Thread.sleep(1000);
+                } else {
+                    Thread.sleep(3000);
+                }
+                System.out.println("i=="+i+", "+LocalDateTime.now());
+                Integer status = corpddJobCenter.get(jobId);
+                if (status != null) {
+                    if (status == 1) {
+                        syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
+                        corpddJobCenter.remove(jobId);
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("钉钉转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else {
+            httpRespMsg.data = resp;
+        }
+        return httpRespMsg;
+    }
 
-
-                syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
-                if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
-                    long t2 = System.currentTimeMillis();
-                    System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
-                    httpRespMsg.data = syncTranslationResult;
-                    return httpRespMsg;
+    public HttpRespMsg exportGeneralExcelByTitleAndListNew(String userId,WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        if (title.contains("/")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("/", "@");
+        }
+        if (title.contains("\\")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("\\", "@");
+        }
+        String resp = ExcelUtil.exportGeneralExcelByTitleAndList(title, list, downloadPath);
+        String fileUrlSuffix = title + ".xlsx";
+        if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
+            String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
+            String jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+            System.out.println("上传待转译文件到企业微信, jobId==" + jobId);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            long t = System.currentTimeMillis();
+            while (i < 40) {
+                if (i < 10) {
+                    Thread.sleep(300);
+                } else if (i < 20){
+                    Thread.sleep(1000);
+                } else {
+                    Thread.sleep(3000);
+                }
+                System.out.println("i=="+i+", "+LocalDateTime.now());
+                CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
+                if (corpwxJobResult != null) {
+                    if (corpwxJobResult.getErrCode() == 0) {
+                        syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
+                        corpwxJobCenter.remove(jobId);
+                    } else {
+                        long t2 = System.currentTimeMillis();
+                        System.out.println("222企业微信转译报错:"+corpwxJobResult.getErrMsg()+",耗时:" + (t2 - t) + "ms");
+                        httpRespMsg.setError(corpwxJobResult.getErrMsg());
+                        return httpRespMsg;
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
+                httpRespMsg.data = syncTranslationResult;
+                wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,userId,syncTranslationResult, null, WxCorpInfoServiceImpl.TEXT_CARD_MSG__ASYNC_DWONLOAD);
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
+            User user = userMapper.selectById(request.getHeader("token"));
+            String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
+            String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
+            System.out.println("上传待转译文件到钉钉, jobId==" + jobId);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            long t = System.currentTimeMillis();
+            while (i < 30) {
+                if (i < 10) {
+                    Thread.sleep(300);
+                } else if (i < 20){
+                    Thread.sleep(1000);
+                } else {
+                    Thread.sleep(3000);
+                }
+                System.out.println("i=="+i+", "+LocalDateTime.now());
+                Integer status = corpddJobCenter.get(jobId);
+                if (status != null) {
+                    if (status == 1) {
+                        syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
+                        corpddJobCenter.remove(jobId);
+                    }
+                    break;
                 }
                 i++;
             }
+            if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("钉钉转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
+                httpRespMsg.data = syncTranslationResult;
+            } else {
                 //httpRespMsg.setError("处理超时...");
-            httpRespMsg.setError(MessageUtils.message("request.outTime"));
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
         }else {
             httpRespMsg.data = resp;
         }
         return httpRespMsg;
     }
 
-    public HttpRespMsg exportGeneralExcelForExpense(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, List<Map> mapList, String downloadPath) throws Exception {
+
+    public HttpRespMsg exportGeneralExcelForExpense(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, List<Map> mapList, String downloadPath) throws Exception {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         if (title.contains("/")) {
             //文件名不能含有路径,得替换掉
@@ -149,7 +332,35 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 }
                 i++;
             }
-            if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
+            if (syncTranslationResult != null) {
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
+            User user = userMapper.selectById(request.getHeader("token"));
+            String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
+            String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            while (i < 10) {
+                Thread.sleep(300);
+                Integer status = corpddJobCenter.get(jobId);
+                if (status != null) {
+                    if (status == 1) {
+                        syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
+                        corpddJobCenter.remove(jobId);
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");
@@ -161,7 +372,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
         return httpRespMsg;
     }
 
-    public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception {
+    public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         String resp = ExcelUtil.exportGeneralExcelByTitleAndList2(title, list, downloadPath);
         if (title.contains("/")) {
@@ -197,7 +408,35 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 }
                 i++;
             }
-            if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
+            if (syncTranslationResult != null) {
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
+            User user = userMapper.selectById(request.getHeader("token"));
+            String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
+            String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            while (i < 10) {
+                Thread.sleep(300);
+                Integer status = corpddJobCenter.get(jobId);
+                if (status != null) {
+                    if (status == 1) {
+                        syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
+                        corpddJobCenter.remove(jobId);
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");
@@ -210,7 +449,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
     }
 
 
-    public  HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception {
+    public  HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         String resp = ExcelUtil.exportMultiSheetGeneralExcelByTitleAndList(title,multiSheetList, downloadPath,sheetsName);
         if (title.contains("/")) {
@@ -246,7 +485,112 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 }
                 i++;
             }
-            if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
+            if (syncTranslationResult != null) {
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
+            User user = userMapper.selectById(request.getHeader("token"));
+            String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
+            String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix,user.getDingdingUnionid(), dingding);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            while (i < 10) {
+                Thread.sleep(300);
+                Integer status = corpddJobCenter.get(jobId);
+                if (status != null) {
+                    if (status == 1) {
+                        syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
+                        corpddJobCenter.remove(jobId);
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else {
+            httpRespMsg.data = resp;
+        }
+        return httpRespMsg;
+    }
+
+    @Override
+    public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndListNew(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>>[] multiSheetList, String downloadPath, String[] sheetsName) throws Exception {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        String resp = ExcelUtil.exportMultiSheetGeneralExcelByTitleAndListNew(title,multiSheetList, downloadPath,sheetsName);
+        if (title.contains("/")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("/", "@");
+        }
+        if (title.contains("\\")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("\\", "@");
+        }
+        String fileUrlSuffix = title + ".xlsx";
+        if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
+            String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
+            String jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            while (i < 10) {
+                Thread.sleep(300);
+                CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
+                if (corpwxJobResult != null) {
+                    if (corpwxJobResult.getErrCode() == 0) {
+                        syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
+                        corpwxJobCenter.remove(jobId);
+                    } else {
+                        httpRespMsg.setError(corpwxJobResult.getErrMsg());
+                        return httpRespMsg;
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
+            User user = userMapper.selectById(request.getHeader("token"));
+            String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
+            String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix,user.getDingdingUnionid(), dingding);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            while (i < 10) {
+                Thread.sleep(300);
+                Integer status = corpddJobCenter.get(jobId);
+                if (status != null) {
+                    if (status == 1) {
+                        syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
+                        corpddJobCenter.remove(jobId);
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");
@@ -258,7 +602,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
         return httpRespMsg;
     }
 
-    public  HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo,String title) throws Exception {
+    public  HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title) throws Exception {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         if (title.contains("/")) {
             //文件名不能含有路径,得替换掉
@@ -293,7 +637,35 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 }
                 i++;
             }
-            if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
+            if (syncTranslationResult != null) {
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
+            User user = userMapper.selectById(request.getHeader("token"));
+            String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
+            String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix,user.getDingdingUnionid(), dingding);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            while (i < 10) {
+                Thread.sleep(300);
+                Integer status = corpddJobCenter.get(jobId);
+                if (status != null) {
+                    if (status == 1) {
+                        syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
+                        corpddJobCenter.remove(jobId);
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");

+ 2 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -89,6 +89,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
     public static final int TEXT_CARD_MSG_EXPENSE_DENY = 22;//费用报销审核驳回
     public static final int TEXT_CARD_MSG_TASK = 23;//费用报销审核驳回
 
+    public static final int TEXT_CARD_MSG__ASYNC_DWONLOAD = 23;//文件异步下载
+
     private static Object userLock = new Object();
 
     @Value("${suitId}")

+ 138 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/util/ExcelUtil.java

@@ -763,4 +763,142 @@ public class ExcelUtil {
         }
         return true;
     }
+
+    public static String exportMultiSheetGeneralExcelByTitleAndListNew(String title, List<List<String>>[] multiSheetList, String downloadPath, String[] sheetsName) {
+        String result="系统提示:Excel文件导出成功!";
+        String fileName= title+".xlsx";
+        try {
+            // 创建工作簿
+            SXSSFWorkbook workBook = new SXSSFWorkbook();
+            // 创建工作类
+            for (int sheetIndex=0;sheetIndex<multiSheetList.length; sheetIndex++) {
+                Sheet sheetOne = workBook.createSheet();
+                workBook.setSheetName(sheetIndex,sheetsName[sheetIndex]);
+                sheetOne.setDefaultColumnWidth(16);
+
+                //设置字体样式
+                Font headFont = workBook.createFont();
+                headFont.setBold(true);
+                headFont.setFontHeightInPoints((short) 10);
+                headFont.setFontName("黑体");
+
+                Font titleFont = workBook.createFont();
+                titleFont.setBold(true);
+                titleFont.setFontHeightInPoints((short) 10);
+                titleFont.setFontName("黑体");
+
+                Font font = workBook.createFont();
+                font.setFontHeightInPoints((short) 10);
+                font.setFontName("宋体");
+
+                //设置单元格样式
+                XSSFCellStyle  headStyle = (XSSFCellStyle) workBook.createCellStyle();
+                headStyle.setFont(headFont);
+                headStyle.setAlignment(HorizontalAlignment.CENTER);
+                headStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
+                headStyle.setWrapText(true);
+                headStyle.setBorderBottom(BorderStyle.THIN); //下边框
+                headStyle.setBorderLeft(BorderStyle.THIN);//左边框
+                headStyle.setBorderTop(BorderStyle.THIN);//上边框
+                headStyle.setBorderRight(BorderStyle.THIN);//右边框
+
+                String color = "c0c0c0";    //此处得到的color为16进制的字符串
+                //转为RGB码
+                int r = Integer.parseInt((color.substring(0,2)),16);   //转为16进制
+                int g = Integer.parseInt((color.substring(2,4)),16);
+                int b = Integer.parseInt((color.substring(4,6)),16);
+
+                //自定义cell颜色
+//            HSSFPalette palette = workBook.getCustomPalette();
+                //这里的9是索引
+//            palette.setColorAtIndex((short)9, (byte) r, (byte) g, (byte) b);
+
+                //设置自定义颜色
+                XSSFColor xssfColor = new XSSFColor();
+                byte[] colorRgb = { (byte)118, (byte)147, (byte)60 };
+                xssfColor.setRGB(colorRgb);
+//                headStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
+//                headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);// 填充模式(和背景颜色成对使用)
+                //cs.setFillForegroundColor(IndexedColors.AQUA.getIndex()); //设置自带的颜色
+
+                CellStyle titleStyle = workBook.createCellStyle();
+                titleStyle.setFont(titleFont);
+                titleStyle.setAlignment(HorizontalAlignment.CENTER);
+                titleStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
+                titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);  //填充单元格
+//                titleStyle.setFillForegroundColor((short)9);    //填色
+                titleStyle.setWrapText(true);
+                titleStyle.setBorderBottom(BorderStyle.THIN); //下边框
+                titleStyle.setBorderLeft(BorderStyle.THIN);//左边框
+                titleStyle.setBorderTop(BorderStyle.THIN);//上边框
+                titleStyle.setBorderRight(BorderStyle.THIN);//右边框
+
+                CellStyle cellStyle = workBook.createCellStyle();
+                cellStyle.setFont(font);
+                cellStyle.setAlignment(HorizontalAlignment.CENTER);
+                cellStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
+                cellStyle.setWrapText(true);
+                cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
+                cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
+                cellStyle.setBorderTop(BorderStyle.THIN);//上边框
+                cellStyle.setBorderRight(BorderStyle.THIN);//右边框
+
+                if(multiSheetList[sheetIndex].size() > 0) {
+                    int start = 0;
+                    for(List<String> rowList : multiSheetList[sheetIndex]) {
+                        Row row = sheetOne.createRow(start);
+                        row.setHeightInPoints(24);
+                        for(int i = 0; i < rowList.size(); i++) {
+                            Cell cell = row.createCell(i);
+                            if(start == 0) {
+                                cell.setCellStyle(headStyle);
+                            }else {
+                                cell.setCellStyle(cellStyle);
+                            }
+                            cell.setCellValue(rowList.get(i));
+                        }
+                        start++;
+                    }
+                    if (sheetIndex==1){
+                        Row row0 = sheetOne.getRow(0);
+                        for (int i = 0; i < 4; i++) {
+                            sheetOne.addMergedRegion(new CellRangeAddress(0, 1, i,i));
+                        }
+                        int numberOfCells = row0.getPhysicalNumberOfCells();
+                        int index=-1;
+                        for (int i = 0; i < numberOfCells; i++) {
+                            if (row0.getCell(i).getStringCellValue().equals("项目工时分配")){
+                                index=i;
+                                break;
+                            }
+                        }
+                        if (index!=-1){
+                            sheetOne.addMergedRegion(new CellRangeAddress(0, 0, 4,index-1));
+                        }
+                        short lastCellNum = row0.getLastCellNum();
+                        if (index!=-1&&index<lastCellNum-1){
+                            sheetOne.addMergedRegion(new CellRangeAddress(0, 0, index,lastCellNum-1));
+                        }
+
+
+
+                    }
+                }
+            }
+
+
+            File dir = new File(downloadPath);
+            if (!dir.exists()) {
+                dir.mkdirs();
+            }
+            FileOutputStream os = new FileOutputStream(downloadPath+fileName);//保存到本地
+            workBook.write(os);
+            os.flush();
+            os.close();
+        }catch(Exception e) {
+            System.out.println(result);
+            e.printStackTrace();
+        }
+        return "/upload/"+fileName;
+    }
 }

+ 1 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ContractLogMapper.xml

@@ -26,6 +26,6 @@
         left join user
         on contract_log.operator_id = user.id
         where contract_log.company_id = #{companyId}
-		AND contract_log.id in(SELECT MAX(id) FROM contract_log WHERE type = 3 GROUP BY contract_id)
+        AND contract_log.id in(SELECT MAX(id) FROM contract_log WHERE type = 3 GROUP BY contract_id)
     </select>
 </mapper>

+ 29 - 7
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ContractMapper.xml

@@ -19,32 +19,38 @@
         <result column="indate" property="indate" />
         <result column="remarks" property="remarks" />
         <result column="payment" property="payment" />
+        <result column="sec_type_id" property="secTypeId" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, company_id, creator_id, start_date, end_date, number, project_id, name, amounts, type_id, checkerId, status, indate, remarks, payment
+        id, company_id, creator_id, start_date, end_date, number, project_id, name, amounts, type_id, checkerId, status, indate, remarks, payment, sec_type_id
     </sql>
     <select id="selectContract" resultType="com.management.platform.entity.Contract">
         select contract.id,contract.company_id,contract.creator_id,contract.number,contract.name,contract.amounts,contract.type_id,contract_type.type_name,contract.status,contract.indate,contract.remarks,
-        contract.start_date as startDate,contract.end_date as endDate,
+        contract.start_date as startDate,contract.end_date as endDate,contract_type_sec.sec_type_name,contract.sec_type_id,
         user.name as creatorName,user.corpwx_userid as creatorWxCorpId, contract.project_id, contract.payment, cp.pay_date AS next_payment_date, cp.amount AS next_payment_amount
         from contract
         left join contract_type
         on contract.type_id = contract_type.id
+        left join contract_type_sec on contract.sec_type_id = contract_type_sec.id
         LEFT JOIN (SELECT contract_id, pay_date, amount FROM contract_payment WHERE is_payed = 0 GROUP BY contract_id) cp ON cp.contract_id=contract.id
         left join user
         on contract.creator_id = user.id
+        left join contract_custom cc on cc.contract_id=contract.id
         where contract.company_id = #{companyId}
         <if test="number!=null">
-            and number like #{number}
+            and number like CONCAT('%', #{number}, '%')
         </if>
         <if test="name!=null">
-            and contract.name like #{name}
+            and contract.name like CONCAT('%', #{name}, '%')
         </if>
         <if test="typeName!=null">
             and contract_type.id = #{typeName}
         </if>
+        <if test="secTypeId!=null">
+            and contract.sec_type_id = #{secTypeId}
+        </if>
         <if test="status!=null">
             and status = #{status}
         </if>
@@ -54,7 +60,13 @@
         <if test="paymentStartDate != null and paymentEndDate != null">
             and cp.pay_date between #{paymentStartDate} and #{paymentEndDate}
         </if>
-        order by contract.id desc
+        <if test="finishStatus!=null">
+            and cc.finish_status = #{finishStatus}
+        </if>
+        <if test="customerOrg!=null">
+            and cc.customer_org like  CONCAT('%', #{customerOrg}, '%')
+        </if>
+        order by contract.number desc
         <if test="pageStart!=null and pageSize!=null">
             limit #{pageStart},#{pageSize}
         </if>
@@ -67,16 +79,20 @@
         LEFT JOIN (SELECT contract_id, pay_date, amount FROM contract_payment WHERE is_payed = 0 GROUP BY contract_id) cp ON cp.contract_id=contract.id
         left join user
         on contract.creator_id = user.id
+        left join contract_custom cc on cc.contract_id=contract.id
         where contract.company_id = #{companyId}
         <if test="number!=null">
-            and number like #{number}
+            and number like CONCAT('%', #{number}, '%')
         </if>
         <if test="name!=null">
-            and contract.name like #{name}
+            and contract.name like CONCAT('%', #{name}, '%')
         </if>
         <if test="typeName!=null">
             and contract_type.id = #{typeName}
         </if>
+        <if test="secTypeId!=null">
+            and contract.sec_type_id = #{secTypeId}
+        </if>
         <if test="status!=null">
             and status = #{status}
         </if>
@@ -86,5 +102,11 @@
         <if test="paymentStartDate != null and paymentEndDate != null">
             and cp.pay_date between #{paymentStartDate} and #{paymentEndDate}
         </if>
+        <if test="finishStatus!=null">
+            and cc.finish_status = #{finishStatus}
+        </if>
+        <if test="customerOrg!=null">
+            and cc.customer_org like  CONCAT('%', #{customerOrg}, '%')
+        </if>
     </select>
 </mapper>