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.T480601Entity; 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(T480601Entity custom) { String sql = "set nocount on\n"; try { sql += "declare @docCode varchar(50) \n"; sql += "exec sp_newdoccode t480601," + 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(T480601Entity 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 getCustomList(String userCode) { try { return null; } catch (Exception e) { throw e; } } @Override public T480601Entity getCustomInfo(String docCode, String userCode) { try { return null; } catch (Exception e) { throw e; } } }