فهرست منبع

Merge branch 'test' of http://git.tjyourong.com.cn/ctop/adsp-cloud into test

huangxuechao 3 سال پیش
والد
کامیت
eaef217250

+ 8 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java

@@ -63,4 +63,12 @@ public class ExportReportController {
     }
 
 
+    @ApiOperation(value = "财务结算-给运营发送消息", notes = "财务结算-给运营发送消息")
+    @GetMapping(value = "/sendMessageToOperate")
+    public Result sendMessageToOperate(@RequestParam(value = "userId",required = false) String userId) {
+        return reportSettlementService.sendMessageToOperate(userId);
+
+    }
+
+
 }

+ 15 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java

@@ -79,4 +79,19 @@ public interface ReportSettlementMapper {
 
 
 
+    /**
+     * 查询 所有已绑定用户的运营人员id
+     * @return
+     */
+    List<Map<String,Object>> getAccountOperateUserId();
+
+    /**
+     * 查询运营人员 绑定的账户 以及产品
+     * @return
+     */
+    List<Map<String,Object>> getAccountAndProductByOperate(String userId);
+
+
+
+
 }

+ 36 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml

@@ -197,4 +197,40 @@
 
 
 
+    <!--  给运营人员发送微信通知 -->
+
+
+<!--  查询 所有已绑定用户的运营人员id -->
+    <select id="getAccountOperateUserId" resultType="java.util.LinkedHashMap">
+        SELECT user_id userId,user_name userName
+        from ctop_user_allocation
+        GROUP BY user_id
+    </select>
+
+    <!-- 查询运营人员 绑定的账户 以及产品 -->
+    <select id="getAccountAndProductByOperate" resultType="java.util.LinkedHashMap">
+        SELECT
+            c.user_id as userId,
+            c.user_name as userName,
+            c.account_id as accountId,
+            c.project_id as projectId,
+            p.product_id as productId,
+            d.product_name as productName
+        FROM
+            ctop_user_allocation c
+                LEFT JOIN ctop_project p ON c.project_id = p.id
+                LEFT JOIN ctop_product d ON p.product_id = d.id
+        WHERE
+            c.account_status = 0
+        AND p.product_id IS NOT NULL
+	AND c.user_id = #{userId}
+    </select>
+
+
+
+
+
+    <!--  给运营人员发送微信通知 -->
+
+
 </mapper>

+ 5 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/IReportSettlementService.java

@@ -25,4 +25,9 @@ public interface IReportSettlementService {
 
     Result porfitReportKuaiShou(SettlementFileParamsVo paramsVo,HttpServletResponse response);
 
+
+
+
+    Result sendMessageToOperate(String userId);
+
 }

+ 57 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java

@@ -2,6 +2,10 @@ package org.jeecg.ctop.finance.settlement.service.serviceImpl;
 
 import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.*;
@@ -24,9 +28,12 @@ import javax.servlet.http.HttpServletResponse;
 import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URLEncoder;
+import java.text.MessageFormat;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 @Slf4j
@@ -36,6 +43,12 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     @Resource
     private ReportSettlementMapper reportSettlementMapper;
 
+    @Resource
+    private CorpWexinUtils corpWexinUtils;
+    @Resource
+    private MailLogMapper mailLogMapper;
+
+
     @Override
     public List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance() {
         return reportSettlementMapper.getAccountTransactionDayBytedance(null);
@@ -550,8 +563,51 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     }
 
 
+    /**
+     *
+     * @description: 给运营发送消息
+     *
+     * @param userId
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result sendMessageToOperate(String userId) {
+        int month = Calendar.getInstance().get(Calendar.MONTH) + 1;
+        int productNum = 0;
+        int accountNum = 0;
+        String productInfo = null;
+        String message =  "运营人{0},您好!您{1}月份有{2}个产品的账户需要进行媒体后台消耗截图上传,共计{3}个账户。产品分别为:{4}。请及时上传,多谢配合!";
+
+        //查询所有 运营绑定的账户
+        List<Map<String,Object>> userList = reportSettlementMapper.getAccountOperateUserId();
+        for (Map<String, Object> userMap : userList) {
+             userId = userMap.get("userId").toString();
+            //查询运营下的 账户 和 产品信息
+            List<Map<String,Object>> productList = reportSettlementMapper.getAccountAndProductByOperate(userId);
+            if (Check.isNull(productList)){
+                continue;
+            }
+            //产品名称
+            List product = productList.stream().map(map -> map.get("productName")).distinct().collect(Collectors.toList());
+            productNum = product.size();
+            accountNum = productList.size();
+            productInfo = StringUtils.join(product.toArray(),"、");
+
+            //发送微信通知
+            JSONObject jsonObject =  mailLogMapper.getWChatIdByUserId("f990f815ecef43fab9cbe1bb22bb6d63");
+            String msg = MessageFormat.format(message,userMap.get("userName").toString(),month,productNum,accountNum,productInfo);
+            corpWexinUtils.sendMessageByWeChatId(jsonObject,msg);
+        }
+        return Result.successMsg("成功。",null);
+    }
 
 
-
+    public static void main(String[] args) {
+        String a =  "woshiwoshi{1}woshi{2}111{3}===";
+        String b = MessageFormat.format(a,"测试","我","你","结束");
+        System.out.println(a);
+        System.out.println(b);
+    }
 
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java

@@ -84,4 +84,6 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
     Map<String, Object> getListByParams(String tagCode, String type, Integer status, String materialName, List<Long> projectIds, String code, String startDate, String endDate, String userId, String clipId, String shotId, String planId, String leaderName,Integer offlineFlag, Integer pageNo, Integer pageSize);
 
     void correlationUploadV2(JSONObject json);
+
+    JSONArray checkArrayCode(JSONArray array);
 }

+ 45 - 16
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -455,7 +455,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                         e.printStackTrace();
                     } catch (EncoderException e) {
                         e.printStackTrace();
-
                     } finally {
                         try {
                             if (fis != null) {
@@ -467,8 +466,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                     }
                 }
             }
-
-
         });
     }
 
@@ -507,15 +504,13 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         Map<String, Object> resultMap = new HashMap<>();
         try {
             String type = json.getString("type");
-            String url = "";
-            if (!Check.isNull(json.getString("url"))) {
-                url = "https:" + json.getString("url");
-            }
+            String url = json.getString("url");
+            String code = json.getString("code");
             MaterialInfo info = new MaterialInfo();
             Long projectId = json.getLong("projectId");
             Project project = projectService.getById(projectId);
             Long productId = project.getProductId();
-            String code = MD5Util.md5ByUrl(url);
+
             info.setId(UUID.randomUUID().toString().replace("-", ""));
             info.setCode(code);
             if (!Check.isNull(json.getString("watermarkUrl"))) {
@@ -586,13 +581,19 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                 //TODO 需要添加获取设计负责人代码
                 SysUser clip = userService.getById(clipId);
                 String roleCode = userService.getRoleCodeByUserId(clipId);
+                log.info("剪辑人员名称:"+clip.getRealname()+";ID:"+clipId);
+                String leaderName = "";
+                String leaderId = "";
                 if("designTeamLeader".equals(roleCode)){
-                    materialAscription.setLeaderId(clipId);
-                    materialAscription.setLeaderName(clip.getRealname());
+                    leaderId = clipId;
+                    leaderName = clip.getRealname();
                 }else{
-                    materialAscription.setLeaderId(clip.getLeaderId());
-                    materialAscription.setLeaderName(clip.getLeaderName());
+                    leaderId = clip.getLeaderId();
+                    leaderName = clip.getLeaderName();
                 }
+                log.info("负责人名称:"+leaderName+";ID:"+leaderId);
+                materialAscription.setLeaderName(leaderName);
+                materialAscription.setLeaderId(leaderId);
                 int result = materialAscriptionMapper.insert(materialAscription);
                 if (result > 0) {
                     log.info("素材归属信息入库完成,MaterialId:{}", info.getId());
@@ -615,6 +616,28 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         }
     }
 
+    @Override
+    public JSONArray checkArrayCode(JSONArray array) {
+        if(null == array||array.isEmpty()){
+            return new JSONArray();
+        }
+        Map<String,String> codeMap = new HashMap<>();
+        JSONArray resultArray = new JSONArray();
+        for(int i=0;i<array.size();i++){
+            JSONObject data = array.getJSONObject(i);
+            String url = "https:"+data.getString("url");
+            data.put("url",url);
+            String code = MD5Util.md5ByUrl(url);
+            if(codeMap.containsKey(code)){
+                continue;
+            }
+            codeMap.put(code,code);
+            data.put("code",code);
+            resultArray.add(data);
+        }
+        return resultArray;
+    }
+
     /**
      * 素材库关联上传素材 1
      *
@@ -706,13 +729,19 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                 //TODO 需要添加获取设计负责人代码
                 SysUser clip = userService.getById(clipId);
                 String roleCode = userService.getRoleCodeByUserId(clipId);
+                log.info("剪辑人员名称:"+clip.getRealname()+";ID:"+clipId);
+                String leaderName = "";
+                String leaderId = "";
                 if("designTeamLeader".equals(roleCode)){
-                    materialAscription.setLeaderId(clipId);
-                    materialAscription.setLeaderName(clip.getRealname());
+                    leaderId = clipId;
+                    leaderName = clip.getRealname();
                 }else{
-                    materialAscription.setLeaderId(clip.getLeaderId());
-                    materialAscription.setLeaderName(clip.getLeaderName());
+                    leaderId = clip.getLeaderId();
+                    leaderName = clip.getLeaderName();
                 }
+                log.info("负责人名称:"+leaderName+";ID:"+leaderId);
+                materialAscription.setLeaderName(leaderName);
+                materialAscription.setLeaderId(leaderId);
                 int result = materialAscriptionMapper.insert(materialAscription);
                 if (result > 0) {
                     log.info("素材归属信息入库完成,MaterialId:{}", info.getId());

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceAccountReportCtrl.java

@@ -123,7 +123,7 @@ public class BytedanceAccountReportCtrl {
         if (columns.isEmpty()) {
             log.error("请选择需要导出的字段");
         }
-        String filed = JsonResourceUtil.joinFiled(AccountReportConstants.getDicMapByVideo(), columns);
+        String filed = JsonResourceUtil.joinFiled(AccountReportConstants.getDictMapBy(), columns);
         List<String> titles = new ArrayList<>();
         titles.add("账户Id");
         titles.add("账户名称");

+ 5 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/common/utils/JsonResourceUtil.java

@@ -87,10 +87,11 @@ public class JsonResourceUtil {
         System.out.println(array);
         StringBuilder sb = new StringBuilder();
         array.forEach(it -> {
-            if (mapMap.get(it.toString()).isEmpty()) {
+            String filedName = it.toString();
+            if (null== mapMap.get(filedName)||mapMap.get(filedName).isEmpty()) {
                 sb.append(it).append(",");
             } else {
-                sb.append(mapMap.get(it.toString()).get("filed")).append(",");
+                sb.append(mapMap.get(filedName).get("filed")).append(",");
             }
         });
         return sb.deleteCharAt(sb.length() - 1).toString();
@@ -102,7 +103,8 @@ public class JsonResourceUtil {
     public static List<String> joinTitle(Map<String, Map<String,Object>> mapMap,JSONArray array) {
         List<String> titles = new ArrayList<>(20);
         array.forEach(it -> {
-            if (mapMap.get(it.toString()).isEmpty()) {
+            String titleName = it.toString();
+            if (null== mapMap.get(titleName)||mapMap.get(titleName).isEmpty()) {
                 titles.add(it.toString());
             } else {
                 titles.add(mapMap.get(it.toString()).get("comment").toString());

+ 3 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/FileController.java

@@ -55,7 +55,9 @@ public class FileController {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         Long projectId = data.getLong("projectId");
         JSONArray array = data.getJSONArray("videoArray");
-        if(null!=array&&!array.isEmpty()){
+        //校验重复code逻辑
+        JSONArray checkArray = materialInfoService.checkArrayCode(array);
+        if(null!=checkArray&&!checkArray.isEmpty()){
             for (int i=0;i<array.size();i++){
                 JSONObject json = array.getJSONObject(i);
                 json.put("userId", user.getId());