cy
2022-06-27 150ced737ad5d16d476df143c7e4238fc6b8b998
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
69
70
71
72
73
74
75
76
77
78
79
80
package cn.ksource.web.service.impl;
 
import java.util.Random;
 
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import cn.ksource.core.dao.BaseDao;
import cn.ksource.core.dao.SqlParameter;
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.DateUtil;
import cn.ksource.web.service.BillReportCodeService;
 
@Service
public class BillReportCodeServiceImpl implements BillReportCodeService {
 
    @Autowired
    private BaseDao baseDao;
    
    /**
     * 获取统一code,XXX-20150127-001
     * @param type
     * @param serial
     * @return
     */
    private String getUnityCode(String type, int serial) {
        return type + "-" + DateUtil.getCurrentDate8() + "-" + StringUtils.leftPad(String.valueOf(serial + 1), 3, '0');
    }
    
    @Override
    public String getDailyOperationCode(String customerId) {
        String sql = "select count(1) as NUM from sc_daily_operation_record where CUSTOMER_ID=:customer_id and RECORD_DATE=:report_date";
        
        SqlParameter param = new SqlParameter();
        param.addValue("report_date", DateUtil.getCurrentDate8());
        param.addValue("customer_id", customerId);
        
        int num = baseDao.queryForInteger(sql, param);
        
        return getUnityCode("RCYW", num);
    }
 
    @Override
    public String getDailyPatrolCode(String customerId) {
        String sql = "select count(1) as NUM from sc_daily_patrol_report where CUSTOMER_ID=:customer_id and REPORT_DATE=:report_date";
        
        SqlParameter param = new SqlParameter();
        param.addValue("report_date", DateUtil.getCurrentDate8());
        param.addValue("customer_id", customerId);
        
        int num = baseDao.queryForInteger(sql, param);
        return getUnityCode("RCXJ", num);
    }
 
    @Override
    public String getDailyOperationWeeklyCode(String customerId) {
        String sql = "select count(1) as NUM from sc_daily_operation_weekly where CUSTOMER_ID=:customer_id ";
        
        SqlParameter param = new SqlParameter();
        param.addValue("customer_id", customerId);
        
        int num = baseDao.queryForInteger(sql, param);
        
        return getUnityCode("YWZB", num);
    }
 
    @Override
    public String getCustomerSatisCode(String partnerId) {
        String sql = "select count(1) from customer_satis_info where PARTNER_ID=:partner_id ";
        
        SqlParameter param = new SqlParameter();
        param.addValue("partner_id", partnerId);
        
        int num = baseDao.queryForInteger(sql, param);
        
        return getUnityCode("MYDDC", num);
    }
 
}