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
package cn.autoform.log.service.impl;
 
import cn.autoform.log.mapper.SystemMathMapper;
import cn.autoform.log.service.SystemMathService;
import com.iemsoft.framework.cloud.core.thread.Keys;
import com.iemsoft.framework.cloud.core.thread.ThreadData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
 
/**
 * 系统变量业务层
 *
 * @author liush
 */
@Service("systemMathServiceImpl")
@Slf4j
public class SystemMathServiceImpl implements SystemMathService {
 
    @Resource
    private SystemMathMapper systemMathMapper;
 
 
    @Override
    public Map<String,String> getCostTypeByFormId(String formId) {
        String tenantId = ThreadData.get(Keys.TENANT_ID);
        String companyId = ThreadData.get(Keys.COMPANY_ID);
 
       List<Map<String,String>> list = systemMathMapper.getCostTypeByFormId(tenantId, companyId, formId);
        /**
         费用类型     表名
         SQ        通用申请单智泽SQa-----------> 需要
         SQ     通用申请单智泽SQa486
         筛选出长度最短的表名,同时返回此bean
         */
        Map costFromMapping1 = null;
        if(!CollectionUtils.isEmpty(list)){
            log.debug("查询出的费用类型为:{}", list.toString());
            int length = list.get(0).get("f_name").length();
                for (int i = 0; i < list.size(); i++) {
                    int lengthNew = list.get(i).get("f_name").length();
                    if (length > lengthNew){
                        length = list.get(i).get("f_name").length();
                        costFromMapping1 = list.get(i);
                    }
                }
            return costFromMapping1;
        }
        return null;
    }
 
}