zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package cn.autoform.util;
 
import cn.autoform.log.bean.OperationLog;
import cn.autoform.log.mapper.InitCompanyMapper;
import cn.autoform.log.mapper.OperationLogMapper;
import cn.autoform.log.service.SystemMathService;
import com.iemsoft.framework.cloud.core.thread.Keys;
import com.iemsoft.framework.cloud.core.thread.ThreadData;
import com.iemsoft.framework.cloud.core.tools.JSONTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;
 
/**
 * Created by guoqy on 2019/10/14
 */
@Slf4j
@Service
public class OperationLogTool  {
 
 
    @Resource
    private InitCompanyMapper initCompanyMapper;
    @Resource
    private  OperationLogMapper operationLogMapper;
    @Resource
    private SystemMathService  systemMathService;
 
    public  void addOperationLog(String formId,String operNum){
        //----------→添加日志
        //----------→获取tenantname,companyname,costType
        String tenantId = ThreadData.get(Keys.TENANT_ID);
        String companyId = ThreadData.get(Keys.COMPANY_ID);
        String openId = ThreadData.get(Keys.USER_ID);
        log.debug("准备查询公司名称租户名称---------------------");
        Map<String, String> initCompany = initCompanyMapper.selectTenantnameAndCompanynameByid(String.valueOf(tenantId), String.valueOf(companyId));
        log.debug("装备查询费用类型-----------------------------");
        Map<String,String> costType = systemMathService.getCostTypeByFormId(formId);
 
        log.debug("查询租户名称:{},公司名称:{}", initCompany.get("tenant_name"), initCompany.get("company_name"));
        log.debug("费用类型:{},表单名称:{}",costType.get("type"),costType.get("f_name"));
 
        if (initCompany != null && costType != null) {
            OperationLog operationLog = new OperationLog();
            operationLog.setTenantId(tenantId);
            operationLog.setCompanyId(companyId);
            operationLog.setTenantName(Objects.toString(initCompany.get("tenant_name"),""));
            operationLog.setCompanyName(Objects.toString(initCompany.get("company_name"),""));
            operationLog.setOpenId(openId);
            operationLog.setFormId(costType.get("formId"));
            operationLog.setCostType(Objects.toString(costType.get("type"),""));
            operationLog.setFormName(Objects.toString(costType.get("f_name"),""));
            operationLog.setOperation(operNum);//删除
            try {
                log.debug("操作日志启动---------->:{}", JSONTool.toJson(operationLog));
 
                operationLogMapper.addOperationLog(operationLog);
                log.debug("操作日志成功记录---------->");
            } catch (Exception e) {
                log.error("操作日志添加异常---------->{}", e.getMessage());
            }
            //----------→添加日志
        }
    }
}