xinyb
2024-09-14 ad7c8d2561e5ee1b35aa289fd3e18fa6b5e42481
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.yc.crm.custom.service;
 
import com.yc.action.grid.GridUtils;
import com.yc.crm.clues.entity.T482103Entity;
import com.yc.crm.custom.entity.T480601HEntity;
import com.yc.service.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
/**
 * @BelongsProject: eCoWorksV3
 * @BelongsPackage: com.yc.crm.custom.service
 * @author: xinyb
 * @CreateTime: 2024-08-24  14:45
 * @Description:
 */
@Service
public class CustomImpl extends BaseService implements CustomIfc {
    @Transactional(rollbackFor = Exception.class)
    @Override
    public String saveCustom(T480601HEntity custom) {
        String sql = "set nocount on\n";
        try {
            sql += "declare @docCode varchar(50) \n";
            sql += "exec sp_newdoccode 482101," + GridUtils.prossSqlParm(custom.getEnterCode()) + ",@docCode output \n";
            sql += "insert into t480601H(formId,docDate,periodId,docStatus,companyId,companyName,enterCode,enterName,enterDate," +
                    "postCode,postName,postDate,cltCode,cltName,country,province,city,district,street) " +
                    "values (" + custom.getFormId() + ",convert(varchar(10),getdate(),120),convert(varchar(7),getdate(),120),0," +
                    GridUtils.prossSqlParm(custom.getCompanyid()) + "," + GridUtils.prossSqlParm(custom.getCompanyname()) + "," +
                    GridUtils.prossSqlParm(custom.getEnterCode()) + "," + GridUtils.prossSqlParm(custom.getEnterName()) + ",getdate()," +
                    GridUtils.prossSqlParm(custom.getEnterCode()) + "," + GridUtils.prossSqlParm(custom.getEnterName()) + ",getdate()," +
                    "'',''," + GridUtils.prossSqlParm(custom.getCountry()) + "," + GridUtils.prossSqlParm(custom.getProvince()) + "," +
                    GridUtils.prossSqlParm(custom.getCity()) + "," + GridUtils.prossSqlParm(custom.getDistrict()) + "," +
                    GridUtils.prossSqlParm(custom.getStreet()) + ") \n";
            if (custom.getContactsList() != null && custom.getContactsList().size() > 0) {//插入联系人
                for (T482103Entity c : custom.getContactsList()) {
                    sql += "insert into t482103(main_customer_flag,refCode,name,email,gender,post,remark,image_list,birth,post_grade,growth_level,create_time,update_time) " +
                            "values(" + c.getMainCustomerFlag() + ",@docCode," + GridUtils.prossSqlParm(c.getName()) + "," + GridUtils.prossSqlParm(c.getEmail()) + "," +
                            GridUtils.prossSqlParm(c.getGender()) + "," + GridUtils.prossSqlParm(c.getPost()) + "," + GridUtils.prossSqlParm(c.getRemark()) + "," +
                            GridUtils.prossSqlParm(c.getImageList()) + "," + GridUtils.prossSqlParm(c.getBirth()) + "," + GridUtils.prossSqlParm(c.getPostGrade()) + "," +
                            c.getGrowthLevel() + ",getdate(),getdate()) \n";
                }
            }
            sql += "select @docCode as docCode";
            String docCode = jdbcTemplate.queryForObject(sql, String.class);
            return docCode;
        } catch (Exception e) {
            throw e;
        }
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateCustom(T480601HEntity custom) {
        String sql = "set nocunt on \n";
        try {
            sql += "update t480601H set modifyCode=" + GridUtils.prossSqlParm(custom.getEnterCode()) + ",modifyName=" + GridUtils.prossSqlParm(custom.getEnterName()) + "," +
                    "modifyDate=getdate(),country=" + GridUtils.prossSqlParm(custom.getCountry()) + ",province=" + GridUtils.prossSqlParm(custom.getProvince()) + "," +
                    "city=" + GridUtils.prossSqlParm(custom.getCity()) + ",district=" + GridUtils.prossSqlParm(custom.getDistrict()) + ",street=" + GridUtils.prossSqlParm(custom.getStreet()) +
                    " where docCode=" + GridUtils.prossSqlParm(custom.getDocCode());
            sql += "select @@ROWCOUNT \n";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteCustom(String docCode, String userCode) {
        String sql = "set nocunt on \n";
        try {
            sql += "delete t480601H where docCode=" + GridUtils.prossSqlParm(docCode);
            sql += "select @@ROWCOUNT \n";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
    }
 
    @Override
    public List<T480601HEntity> getCustomList(String userCode) {
        try {
            return null;
        } catch (Exception e) {
            throw e;
        }
    }
 
    @Override
    public T480601HEntity getCustomInfo(String docCode, String userCode) {
        try {
            return null;
        } catch (Exception e) {
            throw e;
        }
    }
}