xinyb
2024-07-18 80430d52f7716e3eb3e517dc96f94c4a6f9657bf
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
package com.yc.sdk.shopping.service;
 
import org.springframework.context.annotation.Scope;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
 
import com.yc.action.grid.GridUtils;
import com.yc.service.BaseService;
 
@Service("UserSettingImpl")
@Scope("prototype")
public class UserSettingImpl extends BaseService implements UserSettingIfc {
 
    @Override
    public Integer changeCurrency(String userCode,String currency,Integer logonType) {
        //  logonType  : 0表示登录号用户 ,1 表示客户,2 表示工号, 3 表示供应商 
        if (logonType == null) logonType = 0 ;
        String sql = "set nocount on ;"
                + " update a set Currency = "+GridUtils.prossSqlParm(currency)+" from _sysuser a where UserCode= "+GridUtils.prossSqlParm(userCode)+" ; select @@rowcount ; " ;
        String sql1 = "set nocount on ;"
                + " update a set Currency = "+GridUtils.prossSqlParm(currency)+" from t110203 a where CltCode = "+GridUtils.prossSqlParm(userCode)+" ; select @@rowcount ; " ;
        String sql2 = "set nocount on ;"
                + " update a set Currency = "+GridUtils.prossSqlParm(currency)+" from t180201 a where HrCode = "+GridUtils.prossSqlParm(userCode)+" ; select @@rowcount ; " ;
        String sql3 = "set nocount on ;"
                + " update a set Currency = "+GridUtils.prossSqlParm(currency)+" from t110302 a where VndCode = "+GridUtils.prossSqlParm(userCode)+" ; select @@rowcount ; " ;
        try {
            Integer ret = null ;
            if (logonType == 0) ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ;
            if (logonType == 1) ret = this.jdbcTemplate.queryForObject(sql1,Integer.class) ;
            if (logonType == 2) ret = this.jdbcTemplate.queryForObject(sql2,Integer.class) ;
            if (logonType == 3) ret = this.jdbcTemplate.queryForObject(sql3,Integer.class) ;
            return ret;
        }catch(DataAccessException e ) {
            if (e instanceof EmptyResultDataAccessException){
                return null ;
            }else {
                e.printStackTrace();
                 throw e;
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
 
    @Override
    public Integer changeLang(String userCode,Integer langId,Integer logonType) {
        //  logonType  : 0表示登录号用户 ,1 表示客户,2 表示工号, 3 表示供应商 
        if (logonType == null) logonType = 0 ;
        String sql = "set nocount on ;"
                + " update a set LangId = "+langId+" from _sysuser a where UserCode= "+GridUtils.prossSqlParm(userCode)+" ; select @@rowcount ; " ;
        String sql1 = "set nocount on ;"
                + " update a set LangId = "+langId+" from t110203 a where CltCode = "+GridUtils.prossSqlParm(userCode)+" ; select @@rowcount ; " ;
        String sql2 = "set nocount on ;"
                + " update a set Currency = "+langId+" from t180201 a where HrCode = "+GridUtils.prossSqlParm(userCode)+" ; select @@rowcount ; " ;
        String sql3 = "set nocount on ;"
                + " update a set LangId = "+langId+" from t110302 a where VndCode = "+GridUtils.prossSqlParm(userCode)+" ; select @@rowcount ; " ;
        try {
            Integer ret = null ;
            if (logonType == 0) ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ;
            if (logonType == 1) ret = this.jdbcTemplate.queryForObject(sql1,Integer.class) ;
            if (logonType == 2) ret = this.jdbcTemplate.queryForObject(sql2,Integer.class) ;
            if (logonType == 3) ret = this.jdbcTemplate.queryForObject(sql3,Integer.class) ;
            return ret;
        }catch(DataAccessException e ) {
            if (e instanceof EmptyResultDataAccessException){
                return null ;
            }else {
                e.printStackTrace();
                 throw e;
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
}