package com.yc.open.deli.service.v2;
|
|
import com.yc.action.grid.GridUtils;
|
import com.yc.entity.DataSourceEntity;
|
import com.yc.exception.ApplicationException;
|
import com.yc.factory.FactoryBean;
|
import com.yc.open.deli.entity.*;
|
import com.yc.open.deli.service.PostDataBaseService;
|
import com.yc.open.init.Task;
|
import com.yc.service.BaseService;
|
import org.apache.commons.lang3.RandomStringUtils;
|
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.EmptyResultDataAccessException;
|
import org.springframework.stereotype.Service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Set;
|
import java.util.stream.Collectors;
|
|
/**
|
* 德立接口
|
*/
|
@Service
|
public class DeLiImplV2 extends BaseService implements DeLiIfc {
|
|
|
@Override
|
public List<T110203Entity> getCustomerList(String cltcode) {
|
List<T110203Entity> results=null;
|
|
return results;
|
}
|
|
@Override
|
public List<T170139Entity> getT170139List(String docCode,Task task) {
|
List<T170139Entity> results=null;
|
String sql=" set nocount on \n"
|
+ " declare @DefaultVndCode varchar(50), @mydocStatus int="+task.getCurrentDocStatus()+",@myDocCode varchar(50)="+GridUtils.prossSqlParm(docCode)+" \n"
|
+ " select top 1 @DefaultVndCode = DefaultVndCode from t110561 \n"
|
+ " if isnull(@DefaultVndCode,'') = '' \n"
|
+ " begin \n"
|
+ " raiserror('请在 110561 功能号中维护【缺省供应商编号】',16,1) \n"
|
+ " return \n"
|
+ " end \n" +
|
" select " +
|
" b.docCode,--单号\n" +
|
" b.docDate,--单据日期\n" +
|
" b.refCode,--引用单号\n" +
|
" b.cltCode,--客户编号\n" +
|
" b.cltName,--客户名称\n" +
|
" b.tel,--电话\n" +
|
" b.propertyAddress,--送货地址\n" +
|
" b.opportunity,--客户意向\n" +
|
" b.description,--跟进情况\n" +
|
" b.lostType,--跟踪状态\n" +
|
" b.lostMemo,--流失原因\n" +
|
" b.attachment, --附件 \n" +
|
" a.cshopCode,a.cshopName ,a.cVenCode,a.cVenName," +
|
" case when (select controltype from gField where formid=170139 and HeadFlag = 0 and fieldid='attachment')=9 then 1 else 3 end as attachmentType," +
|
" b.hrname,b.docStatus, b.docStatusName,b.EnterName,b.PostDate "+
|
" from t170139H b join t110606 a on a.ccCode=b.ccCode " +
|
" where isnull(b.cccode,'') <> '' " +
|
" and b.DocStatus=@mydocStatus \n" +
|
" and b.DocCode=@myDocCode \n" +
|
" and exists(select 1 from t120201h h join t120201d d on h.doccode = d.doccode \n" +
|
" join t110560 t on t.ObjCode = @DefaultVndCode and d.matcode = t.matcode \n" +
|
" where b.cltcode = h.cltcode )\n" +
|
" order by b.DocCode";
|
try {
|
List<Map<String,Object>> list= this.jdbcTemplate.queryForList(sql);
|
if(list!=null&&list.size()>0) {
|
results=new ArrayList<>();
|
for (Map<String, Object> map : list) {
|
//处理附件
|
String attachment=GridUtils.prossRowSetDataType_String(map,"attachment");
|
if(attachment!=null&&!"".equals(attachment)){
|
attachment="uuid="+attachment+"&type="+GridUtils.prossRowSetDataType_String(map,"attachmentType");
|
}
|
|
results.add(new T170139Entity(
|
GridUtils.prossRowSetDataType_String(map,"docCode"),
|
GridUtils.prossRowSetDataType_Date(map,"docDate"),
|
GridUtils.prossRowSetDataType_String(map,"refCode"),
|
GridUtils.prossRowSetDataType_String(map,"cltCode"),
|
GridUtils.prossRowSetDataType_String(map,"cltName"),
|
GridUtils.prossRowSetDataType_String(map,"tel"),
|
GridUtils.prossRowSetDataType_String(map,"propertyAddress"),
|
GridUtils.prossRowSetDataType_String(map,"opportunity"),
|
GridUtils.prossRowSetDataType_String(map,"description"),
|
GridUtils.prossRowSetDataType_String(map,"lostType"),
|
GridUtils.prossRowSetDataType_String(map,"lostMemo"),
|
attachment,
|
GridUtils.prossRowSetDataType_Int(map,"docStatus"),
|
GridUtils.prossRowSetDataType_String(map,"docStatusName"),
|
GridUtils.prossRowSetDataType_String(map,"hrname"),
|
GridUtils.prossRowSetDataType_String(map,"cVenCode"),
|
GridUtils.prossRowSetDataType_String(map,"cVenName"),
|
GridUtils.prossRowSetDataType_String(map,"cshopCode"),
|
GridUtils.prossRowSetDataType_String(map,"cshopName"),
|
GridUtils.prossRowSetDataType_String(map,"EnterName"),
|
GridUtils.prossRowSetDataType_Date(map,"PostDate")
|
));
|
}
|
}
|
}catch(Exception e ) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
this.doErrorLog(170139,e);
|
}
|
}
|
return results;
|
}
|
|
/**
|
*把推送时查询sql出错信息写到日志表110562
|
* @param sql
|
*/
|
private void doErrorLog(int formid,Exception ex){
|
PostDataBaseService postDataBaseService= (PostDataBaseService) FactoryBean.getBean("postDataBaseService");
|
List<T110562Entity> list=new ArrayList<>();
|
//一个功能号只生成一条运行时出错日志
|
list.add(new T110562Entity(formid,"",0, RandomStringUtils.randomAlphanumeric(6),"","","","",0,0,0,"","","sql出错",0,0,ex.getMessage().replaceAll("'","''")));
|
try {
|
postDataBaseService.doLogBy110562(list);
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
|
}
|
@Override
|
public List<T640109Entity> getT640109(String docCode,Task task) {
|
List<T640109Entity> results=null;
|
String sql=" set nocount on \n"
|
+ " declare @docCode varchar(20),@docDate datetime,@preSendDate datetime,@factdate datetime,@docType varchar(50),@mydocStatus int="+task.getCurrentDocStatus()+",@myDocCode varchar(50)="+GridUtils.prossSqlParm(docCode)+" \n" +
|
" ,@cltCode varchar(20),@cltName varchar(80),@meterName varchar(200),@tel varchar(50),@propertyAddress varchar(200),@sellerName varchar(50),\n" +
|
" @shopGuideName varchar(50),@shejiCode varchar(50),@shejiName varchar(50),@hDMemo varchar(400),@attachmentDate datetime, \n" +
|
" @approvalMemo varchar(200),@approvalMemo2 varchar(200),@approvalMemo3 varchar(200), \n" +
|
" @approvalMemo4 varchar(200),@docStatus int, @docStatusName varchar(50),@refCode varchar(20),@EnterName varchar(50),@cccode varchar(20), \n" +
|
" @cshopCode varchar(50),@cshopName varchar(50) ,@cVenCode varchar(50),@cVenName varchar(50) , \n" +
|
|
" @rowid varchar(20),@DocItem int, \n" +
|
" @ObjMatCode varchar(50),@ObjMatName varchar(80),@ObjSpecial varchar(80), \n" +
|
" @uom varchar(20),@digit money,@locationName varchar(200),@ItemMemo varchar(400),@refcodeitem varchar(50),@refrowid varchar(20),@PushStatus int \n" +
|
" declare @table table(docCode varchar(20),docDate datetime,preSendDate datetime,factdate datetime,docType varchar(50), \n" +
|
" cltCode varchar(20),cltName varchar(80),meterName varchar(200),tel varchar(50),propertyAddress varchar(200),sellerName varchar(50),\n" +
|
" shopGuideName varchar(50),shejiCode varchar(50),shejiName varchar(50),hDMemo varchar(400),attachmentDate datetime, \n" +
|
" approvalMemo varchar(200),approvalMemo2 varchar(200),approvalMemo3 varchar(200), \n" +
|
" approvalMemo4 varchar(200),docStatus int, docStatusName varchar(50),refCode varchar(20),EnterName varchar(50),cccode varchar(20), \n" +
|
" cshopCode varchar(50),cshopName varchar(50) ,cVenCode varchar(50),cVenName varchar(50) , \n" +
|
|
" rowid varchar(20),DocItem int, \n" +
|
" matcode varchar(50),matname varchar(80),special varchar(80), \n" +
|
" uom varchar(20),digit money,locationName varchar(200),ItemMemo varchar(400),refcodeitem varchar(50),refrowid varchar(20),PushStatus int )\n" +
|
|
" declare @ccname varchar(80),@errMsg varchar(500)\n" +
|
" declare @myrowcount int,@myerror int\n" +
|
" declare @DefaultVndCode varchar(50), @DefaultVndName varchar(80) ,@postdocstatus int,@formid int = 640109 \n" +
|
" declare @MatCode varchar(50),@MatName varchar(120) ,@Special varchar(120) \n" +
|
|
" select top 1 @DefaultVndCode = a.DefaultVndCode ,@DefaultVndName = b.vndName \n" +
|
" from t110561 a left join t110302 b on a.DefaultVndCode = b.vndCode \n" +
|
" if isnull(@DefaultVndCode,'') = '' \n" +
|
" begin \n" +
|
" raiserror('请在 110561 功能号中维护【缺省供应商编号】',16,1) \n" +
|
" return \n" +
|
" end \n" +
|
|
" declare mycurDeli cursor for\n" +
|
" select b.docCode,b.docDate,b.preSendDate,b.factdate,b.docType, \n" +
|
" b.cltCode,b.cltName,b.meterName,b.tel,b.propertyAddress,b.sellerName,\n" +
|
" b.shopGuideName,b.shejiCode,b.shejiName,b.hDMemo,b.attachmentDate, \n" +
|
" b.approvalMemo,b.approvalMemo2,b.approvalMemo3, \n" +
|
" b.approvalMemo4,b.docStatus, b.docStatusName,b.refCode,b.EnterName,b.cccode, \n" +
|
|
" c.rowid,c.DocItem,c.matcode,c.matname, \n" +
|
" c.uom,c.digit,c.locationName,c.ItemMemo,c.refcodeitem,c.refrowid,0 \n" +
|
|
" from t640109H b --join t110606 a on a.ccCode=b.ccCode \n" +
|
" join t640109D c on b.doccode = c.doccode \n" +
|
" --join t110560 d on d.ObjCode = @DefaultVndCode and c.matcode = d.matcode \n" +
|
" --join t110203 e on b.cltcode = e.cltcode \n" +
|
" join t110503 e on c.matcode = e.matcode \n" +
|
" where isnull(b.cccode,'') <> '' \n" +
|
" and b.docStatus=@mydocStatus \n"+
|
" and b.docCode=@myDocCode \n"+
|
" and isnull(e.vndcode,'') = @DefaultVndCode \n" +
|
" order by b.DocCode\n" +
|
|
" open mycurDeli \n" +
|
" fetch next from mycurDeli into @docCode,@docDate,@preSendDate,@factdate,@docType, \n" +
|
" @cltCode,@cltName,@meterName,@tel,@propertyAddress,@sellerName,\n" +
|
" @shopGuideName,@shejiCode,@shejiName,@hDMemo,@attachmentDate, \n" +
|
" @approvalMemo,@approvalMemo2,@approvalMemo3, \n" +
|
" @approvalMemo4,@docStatus, @docStatusName,@refCode,@EnterName,@cccode, \n" +
|
" @rowid,@DocItem,@matcode,@matname, \n" +
|
" @uom,@digit,@locationName,@ItemMemo,@refcodeitem,@refrowid,@PushStatus \n" +
|
" while @@FETCH_STATUS = 0\n" +
|
" begin\n" +
|
" --检查该客户是否存在\n" +
|
" if not exists(select 1 from t110203 where cltcode = @cltcode) \n" +
|
" begin \n" +
|
" set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据【'+ isnull(@doccode,'') + '】客户编号【'+ isnull(@cltcode,'') + '】不存在,请在 110203 中新增该客户编号' \n" +
|
" end \n" +
|
|
" --检查与德立对照表是否存在或有重复设置照表\n" +
|
" select @cvenCode = cvenCode,@cvenName = cvenName,@cshopCode=cshopCode,@cshopName=cshopName from t110606 where cccode = @CcCode and isnull(cccode,'') <> '' \n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 or isnull(@cvenCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应代理商编号中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cshopCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应门店编号中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cvenName,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应代理商名称中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cshopName,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应门店名称中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount <> 1 set @errMsg =case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end + '在 110606 功能号找到多条部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】对照关系,请去掉重复的,保留一条即可'\n" +
|
" --检查物料主数据 是否有对照表关系 \n" +
|
" select @ObjMatCode = ObjMatCode,@ObjMatName = ObjMatName ,@ObjSpecial = ObjSpecial\n" +
|
" from t110560 a where a.ObjCode = @DefaultVndCode and a.matcode = @matcode \n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 or isnull(@ObjMatCode,'') = '' \n" +
|
" begin\n" +
|
" set @errMsg =case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'物料编号【'+ isnull(@matcode,'') + '】【'+isnull(@matname,'') + '】在 110560 中没找到业务伙伴属于【'+isnull(@DefaultVndCode,'') + '】【'+isnull(@DefaultVndName,'')+'】对照关系,请在 110560 中预先维护好' \n" +
|
" end \n" +
|
" if isnull(@errMsg,'') <> '' \n" +
|
" begin\n" +
|
" if exists(select 1 from t110562 where doccode = @docCode and rowid = @rowid )\n" +
|
" begin\n" +
|
" update a set PushStatus = 0,PushDate = getdate(),PushTimes = isnull(PushTimes,0) + 1,PushMsg = @errMsg\n" +
|
" from t110562 a \n" +
|
" where a.doccode = @docCode and a.rowid = @rowid \n" +
|
" end else \n" +
|
" begin\n" +
|
" insert into t110562(FormId,DocCode,DocItem,RowId,MatCode,MatName,Special,Uom,\n" +
|
" Digit,Price,TotalMoney,StCode,StName,ItemMemo,PushStatus,PushDate,PushTimes,PushMsg)\n" +
|
" values (@FormId,@DocCode,@DocItem,@RowId,@MatCode,@MatName,@Special,@Uom,\n" +
|
" @Digit,0,0,'','',@ItemMemo,0,getdate(),1,@errMsg)\n" +
|
" end \n" +
|
" end else \n" +
|
" begin\n" +
|
" insert into @table (docCode,docDate,preSendDate,factdate,docType, \n" +
|
" cltCode,cltName,meterName,tel,propertyAddress,sellerName,\n" +
|
" shopGuideName,shejiCode,shejiName,hDMemo,attachmentDate, \n" +
|
" approvalMemo,approvalMemo2,approvalMemo3, \n" +
|
" approvalMemo4,docStatus, docStatusName,refCode,EnterName,cccode, \n" +
|
" cshopCode ,cshopName ,cVenCode ,cVenName,\n" +
|
" rowid,DocItem,matcode ,matname ,special,\n" +
|
" uom,digit,locationName,ItemMemo,refcodeitem,refrowid,PushStatus )\n" +
|
" values(@docCode,@docDate,@preSendDate,@factdate,@docType, \n" +
|
" @cltCode,@cltName,@meterName,@tel,@propertyAddress,@sellerName,\n" +
|
" @shopGuideName,@shejiCode,@shejiName,@hDMemo,@attachmentDate, \n" +
|
" @approvalMemo,@approvalMemo2,@approvalMemo3, \n" +
|
" @approvalMemo4,@docStatus, @docStatusName,@refCode,@EnterName,@cccode, \n" +
|
" @cshopCode ,@cshopName ,@cVenCode ,@cVenName,\n" +
|
|
" @rowid,@DocItem,@ObjMatCode ,@ObjMatName ,@ObjSpecial ,\n" +
|
" @uom,@digit,@locationName,@ItemMemo,@refcodeitem,@refrowid,@PushStatus )\n" +
|
|
" end \n" +
|
" fetch next from mycurDeli into @docCode,@docDate,@preSendDate,@factdate,@docType, \n" +
|
" @cltCode,@cltName,@meterName,@tel,@propertyAddress,@sellerName,\n" +
|
" @shopGuideName,@shejiCode,@shejiName,@hDMemo,@attachmentDate, \n" +
|
" @approvalMemo,@approvalMemo2,@approvalMemo3, \n" +
|
" @approvalMemo4,@docStatus, @docStatusName,@refCode,@EnterName,@cccode, \n" +
|
" @rowid,@DocItem,@matcode,@matname, \n" +
|
" @uom,@digit,@locationName,@ItemMemo,@refcodeitem,@refrowid,@PushStatus \n" +
|
" end \n" +
|
" close mycurDeli\n" +
|
" deallocate mycurDeli \n" +
|
" select docCode,docDate,preSendDate,factdate,docType, \n" +
|
" cltCode,cltName,meterName,tel,propertyAddress,sellerName,\n" +
|
" shopGuideName,shejiCode,shejiName,hDMemo,attachmentDate, \n" +
|
" approvalMemo,approvalMemo2,approvalMemo3, \n" +
|
" approvalMemo4,docStatus, docStatusName,refCode,EnterName,cccode, \n" +
|
" cshopCode ,cshopName ,cVenCode ,cVenName,\n" +
|
" rowid,DocItem,matcode ,matname ,special,\n" +
|
" uom,digit,locationName,ItemMemo,refcodeitem,refrowid,PushStatus\n" +
|
" from @table ";
|
|
|
try {
|
List<Map<String,Object>> list= this.jdbcTemplate.queryForList(sql);
|
if(list!=null&&list.size()>0) {
|
Set<Object> distinctDoccdeList = list.stream().map(x -> x.get("docCode")).collect(Collectors.toSet());//取出集合中不重复单号
|
for (Object dist : distinctDoccdeList) {
|
List<T640109DetailEntity> detailEntities=new ArrayList<>();
|
T640109Entity t640109Entity = new T640109Entity();
|
boolean flag = false;//
|
List<Map<String,Object>> t640109List = list.stream().filter(x -> dist.equals(x.get("docCode"))).collect(Collectors.toList());
|
if(results==null){ results = new ArrayList<>();}
|
for(Map<String,Object> map : t640109List) {
|
if (!flag) {//表示第一次,则要取主表
|
t640109Entity.setCustomer(new T640109HeadEntity(
|
GridUtils.prossRowSetDataType_String(map, "docCode"),
|
GridUtils.prossRowSetDataType_Date(map, "docdate"),
|
GridUtils.prossRowSetDataType_Date(map, "preSendDate"),
|
GridUtils.prossRowSetDataType_Date(map, "factdate"),
|
GridUtils.prossRowSetDataType_String(map, "docType"),
|
GridUtils.prossRowSetDataType_String(map, "cltCode"),
|
GridUtils.prossRowSetDataType_String(map, "cltName"),
|
GridUtils.prossRowSetDataType_String(map, "meterName"),
|
GridUtils.prossRowSetDataType_String(map, "tel"),
|
GridUtils.prossRowSetDataType_String(map, "propertyAddress"),
|
GridUtils.prossRowSetDataType_String(map, "sellerName"),
|
GridUtils.prossRowSetDataType_String(map, "shopGuideName"),
|
GridUtils.prossRowSetDataType_String(map, "shejiCode"),
|
GridUtils.prossRowSetDataType_String(map, "shejiName"),
|
GridUtils.prossRowSetDataType_String(map, "hDMemo"),
|
GridUtils.prossRowSetDataType_Date(map, "attachmentDate"),
|
GridUtils.prossRowSetDataType_String(map, "approvalMemo"),
|
GridUtils.prossRowSetDataType_String(map, "approvalMemo2"),
|
GridUtils.prossRowSetDataType_String(map, "approvalMemo3"),
|
GridUtils.prossRowSetDataType_String(map, "approvalMemo4"),
|
GridUtils.prossRowSetDataType_Int(map, "docStatus"),
|
GridUtils.prossRowSetDataType_String(map, "docStatusName"),
|
GridUtils.prossRowSetDataType_String(map, "refCode"),
|
GridUtils.prossRowSetDataType_String(map,"cVenCode"),
|
GridUtils.prossRowSetDataType_String(map,"cVenName"),
|
GridUtils.prossRowSetDataType_String(map,"cshopCode"),
|
GridUtils.prossRowSetDataType_String(map,"cshopName"),
|
GridUtils.prossRowSetDataType_String(map,"cccode"),
|
GridUtils.prossRowSetDataType_String(map,"EnterName")
|
|
));
|
}
|
detailEntities.add(new T640109DetailEntity(
|
GridUtils.prossRowSetDataType_String(map, "matCode"),
|
GridUtils.prossRowSetDataType_String(map, "matName"),
|
GridUtils.prossRowSetDataType_String(map, "uom"),
|
GridUtils.prossRowSetDataType_Double(map, "digit"),
|
GridUtils.prossRowSetDataType_String(map, "ItemMemo"),
|
GridUtils.prossRowSetDataType_Int(map, "DocItem"),
|
GridUtils.prossRowSetDataType_String(map, "rowid"),
|
GridUtils.prossRowSetDataType_String(map, "DocCode"),
|
GridUtils.prossRowSetDataType_String(map, "locationName"),
|
GridUtils.prossRowSetDataType_String(map, "special"),
|
GridUtils.prossRowSetDataType_String(map, "refcodeitem"),
|
GridUtils.prossRowSetDataType_Int(map, "PushStatus"),
|
GridUtils.prossRowSetDataType_String(map, "refrowid")
|
|
));
|
flag=true;
|
}
|
t640109Entity.setDetails(detailEntities);
|
results.add(t640109Entity);
|
|
}
|
}
|
}catch(Exception e ) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
this.doErrorLog(640109,e);
|
}
|
}
|
return results;
|
}
|
|
@Override
|
public Agent get110606(String ccCode) {
|
String sql="select cVenCode,cVenName,cshopCode,cshopName from t110606 where ccCode=?";
|
Agent agent=null;
|
try {
|
Map<String,Object> map= this.jdbcTemplate.queryForMap(sql,ccCode);
|
if(map!=null){
|
agent=new Agent(
|
GridUtils.prossRowSetDataType_String(map,"cVenCode"),
|
GridUtils.prossRowSetDataType_String(map,"cVenName"),
|
GridUtils.prossRowSetDataType_String(map,"cshopCode"),
|
GridUtils.prossRowSetDataType_String(map,"cshopName")
|
);
|
}
|
}catch(Exception e ) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
this.doErrorLog(110606,e);
|
}
|
}
|
return agent;
|
}
|
|
@Override
|
public int updatePrimaryKey(String doccodes,String tableName) {
|
Integer result = this.jdbcTemplate.queryForObject("update "+tableName+" set isPosted=1 where DocCode in ('"+doccodes+"') ; select @@rowcount",Integer.class);
|
return result==null?0:result;
|
}
|
|
@Override
|
public List<T110601Entity> getT110601List() {
|
List<T110601Entity> results=null;
|
String sql=" select Tel,Address ,fax, longitude, latitude, tel2, hrcode, hrname, generalHrcode, generalHrname, b.cshopCode,b.cshopName ,b.cVenCode,b.cVenName from t110601 a ,t110606 b where a.ccCode=b.ccCode and ISNULL(a.isIndependentAccountAbility,0) = 1";
|
try {
|
List<Map<String,Object>> list= this.jdbcTemplate.queryForList(sql);
|
if(list!=null&&list.size()>0){
|
results=new ArrayList<>();
|
|
for(Map<String,Object> map : list) {
|
|
results.add(new T110601Entity(
|
GridUtils.prossRowSetDataType_String(map,"cshopCode"),
|
GridUtils.prossRowSetDataType_String(map,"cshopName"),
|
GridUtils.prossRowSetDataType_String(map,"Tel"),
|
GridUtils.prossRowSetDataType_String(map,"Address"),
|
GridUtils.prossRowSetDataType_String(map,"fax"),
|
GridUtils.prossRowSetDataType_String(map,"longitude"),
|
GridUtils.prossRowSetDataType_String(map,"latitude"),
|
GridUtils.prossRowSetDataType_String(map,"tel2"),
|
GridUtils.prossRowSetDataType_String(map,"hrcode"),
|
GridUtils.prossRowSetDataType_String(map,"hrname"),
|
GridUtils.prossRowSetDataType_String(map,"generalHrcode"),
|
GridUtils.prossRowSetDataType_String(map,"generalHrname"),
|
GridUtils.prossRowSetDataType_String(map,"cVenCode"),
|
GridUtils.prossRowSetDataType_String(map,"cVenName")
|
)
|
);
|
}
|
}
|
}catch(Exception e ) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
this.doErrorLog(110601,e);
|
}
|
}
|
return results;
|
}
|
|
@Override
|
public List<T120201Entity> getT120201List(String docCode,Task task) {
|
List<T120201Entity> results=null;
|
String sql=" set nocount on \n"+
|
" declare @shouKuanAmount money,@docCode varchar(20),@preSendDate datetime,@docType varchar(50),\n" +
|
" @cltCode varchar(20),@cltName varchar(80),@linkMan varchar(50),@ccCode varchar(20),@ccName varchar(50),@hDMemo varchar(400), @tel varchar(50), \n" +
|
" @tel2 varchar(50),@propertyAddress varchar(200), @sellerName varchar(50), @shopGuideName varchar(50),@serviceName varchar(50), \n" +
|
" @dengjiname varchar(80), @referralsName varchar(80),@docStatus int, @docStatusName varchar(50),@docDate datetime,@mydocStatus int="+task.getCurrentDocStatus()+",@myDocCode varchar(50)="+GridUtils.prossSqlParm(docCode)+" \n" +
|
" ,@actname varchar(50),@refCode varchar(20),@cshopCode varchar(50),@cshopName varchar(50) ,@cVenCode varchar(50),@cVenName varchar(50),@EnterName varchar(50), \n" +
|
" @rowid varchar(20),@DocItem int,@ObjMatCode varchar(50),@ObjMatName varchar(120) ,@ObjSpecial varchar(120) ,\n" +
|
" @uom varchar(20),@digit money,@price money,@totalmoney money,@stcode varchar(20),@stname varchar(50),@ItemMemo varchar(400), \n" +
|
" @overallcoding varchar(50),@locationName varchar(200), @brand varchar(50),@trademarkPrice money, \n" +
|
" @discount money, @cv2 varchar(80), @unsubscribeDoccode varchar(200), @subDocdate datetime , \n" +
|
" @cltdocdate datetime,@cltType varchar(50),@sourceInfo varchar(50),@clttel varchar(50),@clttel2 varchar(50),@cltpropertyAddress varchar(200), \n" +
|
" @cltenterName varchar(50),@cltsellerName varchar(50),@cltHDNote varchar(200), \n" +
|
" @cltreferralsName varchar(50),@cltbrithday varchar(50) ,@cltdocStatus int, @cltdocStatusName varchar(50)\n" +
|
" declare @errMsg varchar(500), @myrowcount int,@myerror int,@formid int\n" +
|
" declare @table table (shouKuanAmount money,docCode varchar(20),preSendDate datetime,docType varchar(50),\n" +
|
" cltCode varchar(20),cltName varchar(80),linkMan varchar(50),ccCode varchar(20),ccName varchar(50),hDMemo varchar(400), tel varchar(50), \n" +
|
" tel2 varchar(50),propertyAddress varchar(200), sellerName varchar(50), shopGuideName varchar(50),serviceName varchar(50), \n" +
|
" dengjiname varchar(80), referralsName varchar(80),docStatus int, docStatusName varchar(50),docDate datetime, \n" +
|
" actname varchar(50),refCode varchar(20),cshopCode varchar(50),cshopName varchar(50) ,cVenCode varchar(50),cVenName varchar(50),EnterName varchar(50), \n" +
|
" rowid varchar(20),DocItem int,ObjMatCode varchar(50),ObjMatName varchar(120) ,ObjSpecial varchar(120) ,\n" +
|
" uom varchar(20),digit money,price money,totalmoney money,stcode varchar(20),stname varchar(50),ItemMemo varchar(400), \n" +
|
" overallcoding varchar(50),locationName varchar(200), brand varchar(50),trademarkPrice money, \n" +
|
" discount money, cv2 varchar(80), unsubscribeDoccode varchar(200), subDocdate datetime , \n" +
|
" cltdocdate datetime,cltType varchar(50),sourceInfo varchar(50),clttel varchar(50),clttel2 varchar(50),cltpropertyAddress varchar(200), \n" +
|
" cltenterName varchar(50),cltsellerName varchar(50),cltHDNote varchar(200), \n" +
|
" cltreferralsName varchar(50),cltbrithday varchar(50) ,cltdocStatus int, cltdocStatusName varchar(50) )\n" +
|
" declare @DefaultVndCode varchar(50), @DefaultVndName varchar(80) ,@postdocstatus int\n" +
|
" declare @MatCode varchar(50),@MatName varchar(120) ,@Special varchar(120) \n" +
|
|
" select top 1 @DefaultVndCode = a.DefaultVndCode ,@DefaultVndName = b.vndName \n" +
|
" from t110561 a left join t110302 b on a.DefaultVndCode = b.vndCode \n" +
|
" if isnull(@DefaultVndCode,'') = '' \n" +
|
" begin \n" +
|
" raiserror('请在 110561 功能号中维护【缺省供应商编号】',16,1) \n" +
|
" return \n" +
|
" end \n" +
|
|
" declare mycurDeli cursor for\n" +
|
" select b.formid,b.shouKuanAmount,b.docCode,b.preSendDate,b.docType,\n" +
|
" b.cltCode,b.linkMan,b.ccCode,b.ccName,b.hDMemo, b.tel, \n" +
|
" b.tel2, b.propertyAddress, b.sellerName, b.shopGuideName, b.serviceName, \n" +
|
" b.dengjiname, b.referralsName,b.docStatus, b.docStatusName,b.docDate, \n" +
|
" b.actname,b.refCode, a.cshopCode,a.cshopName ,a.cVenCode,a.cVenName,b.EnterName, \n" +
|
|
" c.rowid,c.DocItem,c.MatCode , c.MatName,c.special,\n" +
|
" c.uom,c.digit,c.price,c.totalmoney,c.stcode,c.stname,c.ItemMemo, \n" +
|
" c.overallcoding,c.locationName, c.brand, c.trademarkPrice, \n" +
|
" c.discount, c.cv2, c.unsubscribeDoccode, c.subDocdate, \n" +
|
|
" e.cltname,\n" +
|
" e.docdate as cltdocdate,--登记日期 \n" +
|
" e.cltType,--客户类型 \n" +
|
" e.sourceInfo,--客户来源 \n" +
|
" e.tel as clttel,--客户电话 \n" +
|
" e.tel2 as clttel2,--联系人电话 \n" +
|
" e.propertyAddress as cltpropertyAddress,--送货地址 \n" +
|
" e.enterName as cltenterName,--登记人 \n" +
|
" e.sellerName as cltsellerName,--业务员 \n" +
|
" e.hDnote as cltHDNote,--备注 \n" +
|
" e.referralsName as cltreferralsName,--介绍人 \n" +
|
" e.cltbrithday as cltbrithday,\n" +
|
" e.docStatus as cltdocStatus, e.docStatusName as cltdocStatusName \n" +
|
" from t120201H b join t110606 a on a.ccCode=b.ccCode \n" +
|
" join t120201D c on b.doccode = c.doccode \n" +
|
" join t110503 d on c.matcode = d.matcode \n" +
|
" join t110203 e on b.cltcode = e.cltcode \n" +
|
" where isnull(b.cccode,'') <> '' \n" +
|
" and b.docStatus=@mydocStatus \n"+
|
" and b.docCode=@myDocCode \n"+
|
" and isnull(d.vndcode,'') = @DefaultVndCode \n" +
|
" order by b.DocCode\n" +
|
" open mycurDeli \n" +
|
" fetch next from mycurDeli into @formid,@shouKuanAmount,@docCode,@preSendDate,@docType,\n" +
|
" @cltCode,@linkMan,@ccCode,@ccName,@hDMemo, @tel, \n" +
|
" @tel2, @propertyAddress,@sellerName, @shopGuideName,@serviceName, \n" +
|
" @dengjiname, @referralsName,@docStatus, @docStatusName,@docDate, \n" +
|
" @actname,@refCode,@cshopCode ,@cshopName,@cVenCode,@cVenName, @EnterName,@rowid,@DocItem,@MatCode , @MatName,@special,\n" +
|
" @uom,@digit,@price,@totalmoney,@stcode,@stname,@ItemMemo, \n" +
|
" @overallcoding,@locationName, @brand, @trademarkPrice, \n" +
|
" @discount, @cv2, @unsubscribeDoccode, @subDocdate, \n" +
|
|
" @cltname,@cltdocdate,@cltType,@sourceInfo,@clttel,@clttel2,\n" +
|
" @cltpropertyAddress,@cltenterName,@cltsellerName,@cltHDNote,\n" +
|
" @cltreferralsName,@cltbrithday,@cltdocStatus,@cltdocStatusName \n" +
|
" while @@FETCH_STATUS = 0\n" +
|
" begin\n" +
|
" --检查该客户是否存在\n" +
|
" select @cltname = a.cltname ,@cltdocdate = a.docdate ,@cltType = a.cltType,@sourceInfo = a.sourceInfo,\n" +
|
" @clttel = a.tel ,@clttel2 = a.tel2 ,@cltpropertyAddress = a.propertyAddress , \n" +
|
" @cltenterName = a.enterName,@cltsellerName = a.sellerName ,@cltHDNote = a.hDnote , \n" +
|
" @cltreferralsName = a.referralsName ,@cltbrithday = a.cltbrithday ,\n" +
|
" @cltdocStatus = a.docStatus , @cltdocStatusName = a.docStatusName \n" +
|
" from t110203 a where cltcode = @cltcode\n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 \n" +
|
" begin \n" +
|
" set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据【'+ isnull(@doccode,'') + '】客户编号【'+ isnull(@cltcode,'') + '】不存在,请在 110203 中新增该客户编号' \n" +
|
" end \n" +
|
" if isnull(@cltName,'')='' " +
|
" begin \n" +
|
" set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'请在 110203 功能号中维护【客户名称】' \n" +
|
|
" end \n" +
|
" if isnull(@clttel,'')='' and isnull(@clttel2,'')='' " +
|
" begin \n" +
|
" set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'请在 110203 功能号中维护【客户手机号】'\n" +
|
" end \n" +
|
" if isnull(@cltpropertyAddress,'')='' " +
|
" begin \n" +
|
" set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'请在 110203 功能号中维护【客户地址】' \n" +
|
" end \n" +
|
|
" --检查与德立对照表是否存在或有重复设置照表\n" +
|
" select @cvenCode = cvenCode,@cvenName = cvenName,@cshopCode=cshopCode,@cshopName=cshopName from t110606 where cccode = @CcCode and isnull(cccode,'') <> '' \n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 or isnull(@cvenCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应代理商编号中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cshopCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应门店编号中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cvenName,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应代理商名称中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cshopName,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应门店名称中不存在,请在 110606 功能号维护对照关系' \n" +
|
|
" if @myrowcount <> 1 set @errMsg =case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end + '在 110606 功能号找到多条部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】对照关系,请去掉重复的,保留一条即可'\n" +
|
" --检查物料主数据 是否有对照表关系 \n" +
|
" select @ObjMatCode = ObjMatCode,@ObjMatName = ObjMatName ,@ObjSpecial = ObjSpecial\n" +
|
" from t110560 a where a.ObjCode = @DefaultVndCode and a.matcode = @matcode \n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 or isnull(@ObjMatCode,'') = '' \n" +
|
" begin\n" +
|
" set @errMsg =case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'物料编号【'+ isnull(@matcode,'') + '】【'+isnull(@matname,'') + '】在 110560 中没找到业务伙伴属于【'+isnull(@DefaultVndCode,'') + '】【'+isnull(@DefaultVndName,'')+'】对照关系,请在 110560 中预先维护好' \n" +
|
" end \n" +
|
" if isnull(@errMsg,'') <> '' \n" +
|
" begin\n" +
|
" if exists(select 1 from t110562 where doccode = @docCode and rowid = @rowid )\n" +
|
" begin\n" +
|
" update a set PushStatus = 0,PushDate = getdate(),PushTimes = isnull(PushTimes,0) + 1,PushMsg = @errMsg\n" +
|
" from t110562 a \n" +
|
" where a.doccode = @docCode and a.rowid = @rowid \n" +
|
" end else \n" +
|
" begin\n" +
|
" insert into t110562(FormId,DocCode,DocItem,RowId,MatCode,MatName,Special,Uom,\n" +
|
" Digit,Price,TotalMoney,StCode,StName,ItemMemo,PushStatus,PushDate,PushTimes,PushMsg)\n" +
|
" values (@FormId,@DocCode,@DocItem,@RowId,@MatCode,@MatName,@Special,@Uom,\n" +
|
" @Digit,@Price,@TotalMoney,@StCode,@StName,@ItemMemo,0,getdate(),1,@errMsg)\n" +
|
" end \n" +
|
" end else \n" +
|
" begin\n" +
|
" insert into @table (shouKuanAmount,docCode,preSendDate,docType,\n" +
|
" cltCode,linkMan,ccCode,ccName,hDMemo, tel, \n" +
|
" tel2, propertyAddress,sellerName, shopGuideName,serviceName, \n" +
|
" dengjiname, referralsName,docStatus, docStatusName,docDate, \n" +
|
" actname,refCode,cshopCode ,cshopName,cVenCode,cVenName, EnterName,\n" +
|
" rowid,DocItem,ObjMatCode,ObjMatName,ObjSpecial ,\n" +
|
" uom,digit,price,totalmoney,stcode,stname,ItemMemo, \n" +
|
" overallcoding,locationName, brand, trademarkPrice, \n" +
|
" discount, cv2, unsubscribeDoccode, subDocdate, " +
|
" cltname,cltdocdate,cltType,sourceInfo,clttel,clttel2,\n" +
|
" cltpropertyAddress,cltenterName,cltsellerName,cltHDNote,\n" +
|
" cltreferralsName,cltbrithday,cltdocStatus,cltdocStatusName \n" +
|
")\n" +
|
" values (@shouKuanAmount,@docCode,@preSendDate,@docType,\n" +
|
" @cltCode,@linkMan,@ccCode,@ccName,@hDMemo, @tel, \n" +
|
" @tel2, @propertyAddress,@sellerName, @shopGuideName,@serviceName, \n" +
|
" @dengjiname, @referralsName,@docStatus, @docStatusName,@docDate, \n" +
|
" @actname,@refCode, @cshopCode ,@cshopName,@cVenCode,@cVenName,@EnterName,\n" +
|
" @rowid,@DocItem,@ObjMatCode,@ObjMatName,@ObjSpecial ,\n" +
|
" @uom,@digit,@price,@totalmoney,@stcode,@stname,@ItemMemo, \n" +
|
" @overallcoding,@locationName, @brand, @trademarkPrice, \n" +
|
" @discount, @cv2, @unsubscribeDoccode, @subDocdate," +
|
" @cltname,@cltdocdate,@cltType,@sourceInfo,@clttel,@clttel2,\n" +
|
" @cltpropertyAddress,@cltenterName,@cltsellerName,@cltHDNote,\n" +
|
" @cltreferralsName,@cltbrithday,@cltdocStatus,@cltdocStatusName \n" +
|
")\n" +
|
" end \n" +
|
" fetch next from mycurDeli into @formid,@shouKuanAmount,@docCode,@preSendDate,@docType,\n" +
|
" @cltCode,@linkMan,@ccCode,@ccName,@hDMemo, @tel, \n" +
|
" @tel2, @propertyAddress,@sellerName, @shopGuideName,@serviceName, \n" +
|
" @dengjiname, @referralsName,@docStatus, @docStatusName,@docDate, \n" +
|
" @actname,@refCode,@cshopCode ,@cshopName,@cVenCode,@cVenName, @EnterName,@rowid,@DocItem,@MatCode , @MatName,@special,\n" +
|
" @uom,@digit,@price,@totalmoney,@stcode,@stname,@ItemMemo, \n" +
|
" @overallcoding,@locationName, @brand, @trademarkPrice, \n" +
|
" @discount, @cv2, @unsubscribeDoccode, @subDocdate,\n" +
|
" @cltname,@cltdocdate,@cltType,@sourceInfo,@clttel,@clttel2,\n" +
|
" @cltpropertyAddress,@cltenterName,@cltsellerName,@cltHDNote,\n" +
|
" @cltreferralsName,@cltbrithday,@cltdocStatus,@cltdocStatusName \n" +
|
" end \n" +
|
" close mycurDeli\n" +
|
" deallocate mycurDeli \n" +
|
" select shouKuanAmount,docCode,preSendDate,docType,\n" +
|
" cltCode,linkMan,ccCode,ccName,hDMemo, tel, \n" +
|
" tel2, propertyAddress,sellerName, shopGuideName,serviceName, \n" +
|
" dengjiname, referralsName,docStatus, docStatusName,docDate, \n" +
|
" actname,refCode,cshopCode ,cshopName,cVenCode,cVenName, EnterName,\n" +
|
" rowid,DocItem,ObjMatCode as matcode,ObjMatName as matname,ObjSpecial as special ,\n" +
|
" uom,digit,price,totalmoney,stcode,stname,ItemMemo, \n" +
|
" overallcoding,locationName, brand, trademarkPrice, \n" +
|
" discount, cv2, unsubscribeDoccode, subDocdate,\n" +
|
" cltname,cltdocdate,cltType,sourceInfo,clttel,clttel2,\n" +
|
" cltpropertyAddress,cltenterName,cltsellerName,cltHDNote,\n" +
|
" cltreferralsName,cltbrithday,cltdocStatus,cltdocStatusName \n" +
|
" from @table " ;
|
|
|
|
try {
|
List<Map<String,Object>> list= this.jdbcTemplate.queryForList(sql);
|
if(list!=null&&list.size()>0) {
|
results=new ArrayList<>();
|
Set<Object> distinctDoccdeList = list.stream().map(x -> x.get("docCode")).collect(Collectors.toSet());//取出集合中不重复单号
|
for (Object dist : distinctDoccdeList) {
|
List<Map<String,Object>> t120201List = list.stream().filter(x -> dist.equals(x.get("docCode"))).collect(Collectors.toList());
|
boolean flag=false ;//
|
T120201Entity t120201Entity = new T120201Entity();
|
List<T120201DetailEntity> detailEntityList = new ArrayList<>();
|
for (Map<String,Object> map : t120201List) {
|
if (!flag) {//表示第一次,则要取主表和客户信息
|
t120201Entity.setHead(new T120201HeadEntity(
|
GridUtils.prossRowSetDataType_String(map, "docCode"),
|
GridUtils.prossRowSetDataType_Date(map, "preSendDate"),
|
GridUtils.prossRowSetDataType_String(map, "docType"),
|
GridUtils.prossRowSetDataType_String(map, "cltCode"),
|
GridUtils.prossRowSetDataType_String(map, "cltName"),
|
GridUtils.prossRowSetDataType_String(map, "linkMan"),
|
GridUtils.prossRowSetDataType_String(map, "cshopCode"),
|
GridUtils.prossRowSetDataType_String(map, "cshopName"),
|
GridUtils.prossRowSetDataType_String(map, "hDMemo"),
|
GridUtils.prossRowSetDataType_Double(map, "shouKuanAmount"),
|
GridUtils.prossRowSetDataType_String(map, "tel"),
|
GridUtils.prossRowSetDataType_String(map, "tel2"),
|
GridUtils.prossRowSetDataType_String(map, "propertyAddress"),
|
GridUtils.prossRowSetDataType_String(map, "sellerName"),
|
GridUtils.prossRowSetDataType_String(map, "shopGuideName"),
|
GridUtils.prossRowSetDataType_String(map, "serviceName"),
|
GridUtils.prossRowSetDataType_String(map, "dengjiname"),
|
GridUtils.prossRowSetDataType_String(map, "referralsName"),
|
GridUtils.prossRowSetDataType_Int(map, "docStatus"),
|
GridUtils.prossRowSetDataType_String(map, "docStatusName"),
|
GridUtils.prossRowSetDataType_Date(map, "docDate"),
|
GridUtils.prossRowSetDataType_String(map, "actname"),
|
GridUtils.prossRowSetDataType_String(map, "refCode"),
|
GridUtils.prossRowSetDataType_String(map, "cVenCode"),
|
GridUtils.prossRowSetDataType_String(map, "cVenName"),
|
GridUtils.prossRowSetDataType_String(map, "enterName")
|
));
|
//客户信息
|
t120201Entity.setCustomer(new T110203Entity(
|
GridUtils.prossRowSetDataType_String(map, "cltCode"),
|
GridUtils.prossRowSetDataType_String(map, "cltName"),
|
GridUtils.prossRowSetDataType_Date(map, "cltdocdate"),
|
GridUtils.prossRowSetDataType_String(map, "cltType"),
|
GridUtils.prossRowSetDataType_String(map, "sourceInfo"),
|
GridUtils.prossRowSetDataType_String(map, "clttel"),
|
GridUtils.prossRowSetDataType_String(map, "clttel2"),
|
GridUtils.prossRowSetDataType_String(map, "cshopCode"),
|
GridUtils.prossRowSetDataType_String(map, "cshopName"),
|
GridUtils.prossRowSetDataType_String(map, "cltpropertyAddress"),
|
GridUtils.prossRowSetDataType_String(map, "cltenterName"),
|
GridUtils.prossRowSetDataType_String(map, "cltsellerName"),
|
GridUtils.prossRowSetDataType_String(map, "cltHDNote"),
|
GridUtils.prossRowSetDataType_String(map, "cltreferralsName"),
|
GridUtils.prossRowSetDataType_String(map, "cltbrithday"),
|
GridUtils.prossRowSetDataType_Int(map, "cltdocStatus"),
|
GridUtils.prossRowSetDataType_String(map, "cltdocStatusName"),
|
GridUtils.prossRowSetDataType_String(map, "cVenCode"),
|
GridUtils.prossRowSetDataType_String(map, "cVenName"),null
|
));
|
}
|
//取明细表
|
detailEntityList.add(new T120201DetailEntity(
|
GridUtils.prossRowSetDataType_String(map, "matCode"),
|
GridUtils.prossRowSetDataType_String(map, "matName"),
|
GridUtils.prossRowSetDataType_String(map, "uom"),
|
GridUtils.prossRowSetDataType_Double(map, "digit"),
|
GridUtils.prossRowSetDataType_Double(map, "price"),
|
GridUtils.prossRowSetDataType_Double(map, "totalmoney"),
|
GridUtils.prossRowSetDataType_String(map, "stcode"),
|
GridUtils.prossRowSetDataType_String(map, "stname"),
|
GridUtils.prossRowSetDataType_String(map, "ItemMemo"),
|
GridUtils.prossRowSetDataType_Int(map, "DocItem"),
|
GridUtils.prossRowSetDataType_String(map, "rowid"),
|
GridUtils.prossRowSetDataType_String(map, "docCode"),
|
GridUtils.prossRowSetDataType_String(map, "overallcoding"),
|
GridUtils.prossRowSetDataType_String(map, "locationName"),
|
GridUtils.prossRowSetDataType_String(map, "brand"),
|
GridUtils.prossRowSetDataType_Double(map, "trademarkPrice"),
|
GridUtils.prossRowSetDataType_Double(map, "discount"),
|
GridUtils.prossRowSetDataType_String(map, "cv2"),
|
GridUtils.prossRowSetDataType_String(map, "unsubscribeDoccode"),
|
GridUtils.prossRowSetDataType_Date(map, "subDocdate"),
|
GridUtils.prossRowSetDataType_String(map, "special")
|
));
|
flag=true;
|
}
|
t120201Entity.setOrders(detailEntityList);
|
results.add(t120201Entity);
|
}
|
}
|
}catch(Exception e) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
this.doErrorLog(120201,e);
|
}
|
}
|
return results;
|
}
|
@Override
|
public CanelEntity getCanelEntityByTableName(String hdtable,String dttable,String doccode,int formid) {
|
|
String hsql="";
|
if(formid==170139) {
|
hsql = " set nocount on " +
|
" select distinct b.docCode,b.docType,a.cvenCode, a.cshopCode,b.refcode " +
|
" from " + hdtable + " b join t110606 a on a.ccCode=b.ccCode " +
|
" where isnull(b.cccode,'') <> '' and b.pushStatus=1 and b.DocCode=?";
|
}else{
|
hsql = " set nocount on " +
|
" select distinct b.docCode,b.docType,a.cvenCode, a.cshopCode,b.refcode " +
|
" from " + hdtable + " b join t110606 a on a.ccCode=b.ccCode " +
|
" join "+dttable+" c on b.doccode = c.doccode " +
|
" where isnull(b.cccode,'') <> '' and c.pushStatus=1 and b.DocCode=?";
|
}
|
try {
|
Map<String,Object> map= this.jdbcTemplate.queryForMap(hsql,doccode);
|
CanelEntity canelEntity=new CanelEntity(
|
GridUtils.prossRowSetDataType_String(map,"docCode"),
|
GridUtils.prossRowSetDataType_String(map,"docType"),
|
GridUtils.prossRowSetDataType_String(map,"cvenCode"),
|
GridUtils.prossRowSetDataType_String(map,"cshopCode"),
|
GridUtils.prossRowSetDataType_String(map,"refcode")
|
);
|
|
return canelEntity;
|
}catch(DataAccessException e ) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
throw e;
|
}
|
}
|
}
|
@Override
|
public List<T130301Entity> getT130301List(String docCode,Task task) {
|
List<T130301Entity> results=null;
|
String hsql=" set nocount on " +
|
" declare @DefaultVndCode varchar(50),@DefaultVndName varchar(80) ,@postdocstatus int \n" +
|
" declare @table table(docCode varchar(20),docDate datetime,docType varchar(50) , \n" +
|
" cvenCode varchar(50),cvenName varchar(80),factoryNumber varchar(50),cltCode varchar(20),\n" +
|
" cltName varchar(200),plateNO varchar(50), \n" +
|
" plateTel varchar(50),cccode varchar(50),ccname varchar(50),buyerCode varchar(20),buyerName varchar(50), \n" +
|
" hDMemo varchar(400),sumtotalmoney2 money,transCosts money,reduceMoney money,receivMoney money, \n" +
|
" docStatus int,docStatusName varchar(50),refCode varchar(20),EnterName varchar(50),rowid varchar(20), \n" +
|
" DocItem int,matCode varchar(50),matName varchar(80),special varchar(80),uom varchar(20),digit float, \n" +
|
" stcode varchar(20),stname varchar(30),ItemMemo varchar(400),soDocCode varchar(20),canceldigit money, \n" +
|
" propertyAddress varchar(200),brand varchar(20),cv2 varchar(80),trademarkPrice money, \n" +
|
" price float,totalmoney money,packingQuantity varchar(100),weight money,totalWeight money, \n" +
|
" discount money,unsubscribeDoccode varchar(20),sORowid varchar(20),errMsg varchar(500) ) \n" +
|
" declare @docCode varchar(20),@docDate datetime,@docType varchar(50) , @mydocStatus int="+task.getCurrentDocStatus()+",@myDocCode varchar(50)="+GridUtils.prossSqlParm(docCode)+" \n" +
|
" ,@cvenCode varchar(50),@cvenName varchar(80),@factoryNumber varchar(50),@cltCode varchar(20),\n" +
|
" @cltName varchar(200),@plateNO varchar(50), \n" +
|
" @plateTel varchar(50),@cccode varchar(50),@ccname varchar(50),@buyerCode varchar(20),@buyerName varchar(50), \n" +
|
" @hDMemo varchar(400),@sumtotalmoney2 money,@transCosts money,@reduceMoney money,@receivMoney money, \n" +
|
" @docStatus int,@docStatusName varchar(50),@refCode varchar(20),@EnterName varchar(50),@rowid varchar(20), \n" +
|
" @DocItem int,@matCode varchar(50),@matName varchar(80),@special varchar(80),@uom varchar(20),@digit float, \n" +
|
" @stcode varchar(20),@stname varchar(30),@ItemMemo varchar(400),@soDocCode varchar(20),@canceldigit money, \n" +
|
" @propertyAddress varchar(200),@brand varchar(20),@cv2 varchar(80),@trademarkPrice money, \n" +
|
" @price float,@totalmoney money,@packingQuantity varchar(100),@weight money,@totalWeight money, \n" +
|
" @discount money,@unsubscribeDoccode varchar(20),@soRowid varchar(20) ,@soCcCode varchar(20),@soCcName varchar(50) \n" +
|
" declare @ObjMatCode varchar(50),@ObjMatName varchar(120) ,@ObjSpecial varchar(120) ,@FormId int = 130301,@cshopCode varchar(80),@cshopName varchar(80) \n" +
|
" select top 1 @DefaultVndCode = a.DefaultVndCode ,@DefaultVndName = b.vndName \n" +
|
" from t110561 a left join t110302 b on a.DefaultVndCode = b.vndCode \n" +
|
" if isnull(@DefaultVndCode,'') = '' \n" +
|
" begin \n" +
|
" raiserror('请在 110561 功能号中维护【缺省供应商编号】',16,1) \n" +
|
" return \n" +
|
" end \n" +
|
" select @postdocstatus = postdocstatus from gform where formid = @FormId \n" +
|
" declare @errMsg varchar(2000) = '',@myrowcount int,@myerror int\n" +
|
" declare mycurDeli cursor for\n" +
|
" select a.docCode,a.docDate,a.docType,a.factoryNumber,\n" +
|
" a.plateNO, a.plateTel, a.cccode, d.ccname, a.buyerCode, \n" +
|
" a.buyerName, a.hDMemo, a.sumtotalmoney2, a.transCosts, a.reduceMoney, a.receivMoney,\n" +
|
" a.docStatus, a.docStatusName,a.refCode,a.EnterName,b.MatCode,b.MatName,b.rowid ,b.SODoccode,b.SOrowid\n" +
|
" from t130301H a join t130301D b on a.DocCode = b.DocCode\n" +
|
" left join t110601 d on a.cccode = d.cccode\n" +
|
" join t110503 e on b.matcode = e.matcode " +
|
" where a.vndCode = @DefaultVndCode \n" +
|
" and a.DocStatus=@mydocStatus \n" +
|
" and a.DocCode=@myDocCode \n" +
|
" and isnull(e.vndcode,'') = @DefaultVndCode \n" +
|
" order by a.doccode asc,b.DocItem asc \n" +
|
" open mycurDeli \n" +
|
" fetch next from mycurDeli into @docCode,@docDate,@docType,@factoryNumber,\n" +
|
" @plateNO, @plateTel, @cccode, @ccname, @buyerCode, \n" +
|
" @buyerName, @hDMemo, @sumtotalmoney2, @transCosts, @reduceMoney, @receivMoney,\n" +
|
" @docStatus, @docStatusName,@refCode,@EnterName,@MatCode,@MatName,@RowId,@soDocCode,@soRowId\n" +
|
" while @@FETCH_STATUS = 0 \n" +
|
" begin\n" +
|
" select @errMsg = '',@cvenCode = '',@cvenName='',@ObjMatCode='',@ObjMatName = '' ,@ObjSpecial=''\n" +
|
" if isnull(@soDocCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'【soDocCode】字段值为空,自动推送的采购订单必须引用销售订单行记录'\n" +
|
" --检查销售订单是否存在 \n" +
|
" select @soCcCode = a.cccode,@soCcName = b.ccname ,@cltCode = a.cltcode ,@cltName = a.CltName \n" +
|
" from t120201h a left join t110601 b on a.ccCode = b.ccCode\n" +
|
" where a.doccode = @soDocCode \n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end + '引用的销售订单【单号:'+isnull(@soDocCode,'') + '】不存在,【rowid: + ' + isnull(@soRowid,'') + '】'\n" +
|
" if isnull(@soCcCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end + '当前单据【'+ isnull(@doccode,'')+ '】引用的销售订单【'+ isnull(@soDocCode,'') + '】部门编号不能为空'\n" +
|
" if isnull(@soCcName,'') = '' set @errMsg =case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end + '当前单据【'+ isnull(@doccode,'') + '】引用的销售订单【'+ isnull(@soDocCode,'') + '】部门参数【'+ isnull(@soCcCode,'') + '】不存在(可能名称为空值),请在 110601 中维护该部门编号及其名称'\n" +
|
" --检查该客户是否存在\n" +
|
" if not exists(select 1 from t110203 where cltcode = @cltcode) \n" +
|
" begin \n" +
|
" set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据【'+ isnull(@doccode,'') + '】客户编号【'+ isnull(@cltcode,'') + '】不存在,请在 110203 中新增该客户编号' \n" +
|
" end \n" +
|
|
" --检查与德立对照表是否存在或有重复设置照表\n" +
|
" select @cvenCode = cvenCode,@cvenName = cvenName,@cshopCode=cshopCode,@cshopName=cshopName from t110606 where cccode = @CcCode and isnull(cccode,'') <> '' \n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 or isnull(@cvenCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应代理商编号中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cshopCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应门店编号中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cvenName,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应代理商名称中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cshopName,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应门店名称中不存在,请在 110606 功能号维护对照关系' \n" +
|
|
" if @myrowcount <> 1 set @errMsg =case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end + '在 110606 功能号找到多条部门【'+isnull(@soCcCode,'') + '】【'+ isnull(@soCcName,'') + '】对照关系,请去掉重复的,保留一条即可'\n" +
|
" --检查物料主数据 是否有对照表关系 \n" +
|
" select @ObjMatCode = ObjMatCode,@ObjMatName = ObjMatName ,@ObjSpecial = ObjSpecial\n" +
|
" from t110560 a where a.ObjCode = @DefaultVndCode and a.matcode = @matcode \n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 or isnull(@ObjMatCode,'') = '' \n" +
|
" begin\n" +
|
" set @errMsg =case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'物料编号【'+ isnull(@matcode,'') + '】【'+isnull(@matname,'') + '】在 110560 中没找到业务伙伴属于【'+isnull(@DefaultVndCode,'') + '】【'+isnull(@DefaultVndName,'')+'】对照关系,请在 110560 中预先维护好' \n" +
|
" end \n" +
|
" if isnull(@errMsg,'') <> '' \n" +
|
" begin\n" +
|
" if exists(select 1 from t110562 where doccode = @docCode and rowid = @rowid )\n" +
|
" begin\n" +
|
" update a set PushStatus = 0,PushDate = getdate(),PushTimes = isnull(PushTimes,0) + 1,PushMsg = @errMsg\n" +
|
" from t110562 a \n" +
|
" where a.doccode = @docCode and a.rowid = @rowid \n" +
|
" end else \n" +
|
" begin\n" +
|
" insert into t110562(FormId,DocCode,DocItem,RowId,MatCode,MatName,Special,Uom,\n" +
|
" Digit,Price,TotalMoney,StCode,StName,ItemMemo,PushStatus,PushDate,PushTimes,PushMsg)\n" +
|
" values (@FormId,@DocCode,@DocItem,@RowId,@MatCode,@MatName,@Special,@Uom,\n" +
|
" @Digit,@Price,@TotalMoney,@StCode,@StName,@ItemMemo,0,getdate(),1,@errMsg)\n" +
|
" end \n"+
|
" end else \n" +
|
" begin \n" +
|
" insert into @table(docCode ,docDate ,docType , \n" +
|
" cvenCode ,cvenName ,factoryNumber,cltCode ,cltName,plateNO , \n" +
|
" plateTel ,cccode ,ccname,buyerCode ,buyerName , \n" +
|
" hDMemo,sumtotalmoney2 ,transCosts ,reduceMoney ,receivMoney , \n" +
|
" docStatus ,docStatusName,refCode ,EnterName,rowid, \n" +
|
" DocItem ,matCode ,matName,special ,uom ,digit , \n" +
|
" stcode,stname ,ItemMemo ,soDocCode,canceldigit, \n" +
|
" propertyAddress,brand,cv2,trademarkPrice , \n" +
|
" price ,totalmoney ,packingQuantity,[weight] ,totalWeight , \n" +
|
" discount ,unsubscribeDoccode,sORowid ,errMsg) \n" +
|
" values(@docCode ,@docDate ,@docType , \n" +
|
" @cvenCode ,@cvenName ,@factoryNumber,@cltCode ,@cltName,@plateNO , \n" +
|
" @plateTel ,@cccode ,@ccname,@buyerCode ,@buyerName , \n" +
|
" @hDMemo,@sumtotalmoney2 ,@transCosts ,@reduceMoney ,@receivMoney , \n" +
|
" @docStatus ,@docStatusName,@refCode ,@EnterName,@rowid, \n" +
|
" @DocItem ,@ObjMatCode ,@ObjMatName,@ObjSpecial ,@uom ,@digit , \n" +
|
" @stcode,@stname ,@ItemMemo ,@soDocCode,@canceldigit, \n" +
|
" @propertyAddress,@brand,@cv2,@trademarkPrice , \n" +
|
" @price ,@totalmoney ,@packingQuantity,@weight ,@totalWeight , \n" +
|
" @discount ,@unsubscribeDoccode,@sORowid ,@errMsg )\n" +
|
" end \n" +
|
" fetch next from mycurDeli into @docCode,@docDate,@docType,@factoryNumber,\n" +
|
" @plateNO, @plateTel, @cccode, @ccname, @buyerCode, \n" +
|
" @buyerName, @hDMemo, @sumtotalmoney2, @transCosts, @reduceMoney, @receivMoney,\n" +
|
" @docStatus, @docStatusName,@refCode,@EnterName,@MatCode,@MatName,@RowId,@soDocCode,@soRowId\n" +
|
" end \n" +
|
" close mycurDeli\n" +
|
" deallocate mycurDeli \n" +
|
" select docCode ,docDate ,docType , \n" +
|
" cvenCode ,cvenName ,factoryNumber,cltCode ,\n" +
|
" cltName,plateNO , \n" +
|
" plateTel ,cccode ,ccname,buyerCode ,buyerName , \n" +
|
" hDMemo,sumtotalmoney2 ,transCosts ,reduceMoney ,receivMoney , \n" +
|
" docStatus ,docStatusName,refCode ,EnterName,rowid, \n" +
|
" DocItem ,matCode ,matName,special ,uom ,digit , \n" +
|
" stcode,stname ,ItemMemo ,soDocCode,canceldigit, \n" +
|
" propertyAddress,brand,cv2,trademarkPrice , \n" +
|
" price ,totalmoney ,packingQuantity,[weight] as weight ,totalWeight , \n" +
|
" discount ,unsubscribeDoccode,sORowid ,errMsg\n" +
|
" from @table ";
|
|
|
try {
|
|
List<Map<String,Object>> list= this.jdbcTemplate.queryForList(hsql);
|
if(list!=null&&list.size()>0) {
|
results=new ArrayList<>();
|
Set<Object> distinctDoccdeList = list.stream().map(x -> x.get("docCode")).collect(Collectors.toSet());//取出集合中不重复单号
|
|
for (Object dist : distinctDoccdeList) {
|
List<Map<String,Object>> t130301List = list.stream().filter(x -> dist.equals(x.get("docCode"))).collect(Collectors.toList());
|
boolean flag = false;//
|
T130301Entity t130301Entity =new T130301Entity();
|
List<T130301DetailEntity> detailEntityList=new ArrayList<>();
|
for (Map<String,Object> map : t130301List) {
|
if (!flag) {//表示第一次,则要取主表和客户信息
|
t130301Entity.setSupplier(new T130301HeadEntity(
|
GridUtils.prossRowSetDataType_String(map,"docCode"),
|
GridUtils.prossRowSetDataType_Date(map,"docDate"),
|
GridUtils.prossRowSetDataType_String(map,"docType"),
|
GridUtils.prossRowSetDataType_String(map,"vndCode") ,
|
GridUtils.prossRowSetDataType_String(map,"vndName") ,
|
GridUtils.prossRowSetDataType_String(map,"factoryNumber"),
|
GridUtils.prossRowSetDataType_String(map,"cltCode"),
|
GridUtils.prossRowSetDataType_String(map,"cltName"),
|
GridUtils.prossRowSetDataType_String(map,"plateNO"),
|
GridUtils.prossRowSetDataType_String(map,"plateTel"),
|
|
GridUtils.prossRowSetDataType_String(map,"buyerCode"),
|
GridUtils.prossRowSetDataType_String(map,"buyerName"),
|
GridUtils.prossRowSetDataType_String(map,"hDMemo"),
|
GridUtils.prossRowSetDataType_Double(map,"sumtotalmoney2"),
|
GridUtils.prossRowSetDataType_Double(map,"transCosts"),
|
GridUtils.prossRowSetDataType_Double(map,"reduceMoney"),
|
GridUtils.prossRowSetDataType_Double(map,"receivMoney"),
|
GridUtils.prossRowSetDataType_Int(map,"docStatus"),
|
GridUtils.prossRowSetDataType_String(map,"docStatusName"),
|
GridUtils.prossRowSetDataType_String(map,"refCode"),
|
GridUtils.prossRowSetDataType_String(map,"enterName")
|
));
|
|
}
|
detailEntityList.add(new T130301DetailEntity(
|
GridUtils.prossRowSetDataType_String(map,"matCode"),
|
GridUtils.prossRowSetDataType_String(map,"matName"),
|
GridUtils.prossRowSetDataType_String(map,"special"),
|
GridUtils.prossRowSetDataType_String(map,"uom"),
|
GridUtils.prossRowSetDataType_Double(map,"digit"),
|
GridUtils.prossRowSetDataType_String(map,"stcode") ,
|
GridUtils.prossRowSetDataType_String(map,"stname") ,
|
GridUtils.prossRowSetDataType_String(map,"ItemMemo"),
|
GridUtils.prossRowSetDataType_String(map,"soDocCode"),
|
GridUtils.prossRowSetDataType_Int(map,"DocItem"),
|
GridUtils.prossRowSetDataType_String(map,"rowid"),
|
GridUtils.prossRowSetDataType_String(map,"DocCode"),
|
GridUtils.prossRowSetDataType_Double(map,"canceldigit"),
|
GridUtils.prossRowSetDataType_String(map,"propertyAddress"),
|
GridUtils.prossRowSetDataType_String(map,"brand"),
|
GridUtils.prossRowSetDataType_String(map,"cv2"),
|
GridUtils.prossRowSetDataType_Double(map,"trademarkPrice"),
|
GridUtils.prossRowSetDataType_Double(map,"price"),
|
GridUtils.prossRowSetDataType_Double(map,"totalmoney"),
|
GridUtils.prossRowSetDataType_String(map,"packingQuantity"),
|
GridUtils.prossRowSetDataType_Double(map,"weight"),
|
GridUtils.prossRowSetDataType_Double(map,"totalWeight"),
|
GridUtils.prossRowSetDataType_Double(map,"discount"),
|
GridUtils.prossRowSetDataType_String(map,"unsubscribeDoccode"),
|
GridUtils.prossRowSetDataType_String(map,"sORowid"),
|
GridUtils.prossRowSetDataType_String(map,"cccode"),
|
GridUtils.prossRowSetDataType_String(map,"ccname")
|
));
|
flag=true;
|
}
|
t130301Entity.setDetails(detailEntityList);
|
results.add(t130301Entity);
|
}
|
}
|
}catch(Exception e ) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
this.doErrorLog(130301,e);
|
}
|
}
|
return results;
|
}
|
|
@Override
|
public List<T640201Entity> getT640201List(String docCode,Task task) {
|
List<T640201Entity> results=null;
|
String sql=" set nocount on \n"+
|
" declare @DefaultVndCode varchar(50), @DefaultVndName varchar(80) ,@postdocstatus int\n" +
|
" declare @docCode varchar(20),@docDate datetime,@docType varchar(50),@weixiuWay varchar(20),@preSendDate datetime,@cltCode varchar(20),@cltName varchar(80) , @mydocStatus int="+task.getCurrentDocStatus()+",@myDocCode varchar(50)="+GridUtils.prossSqlParm(docCode)+" \n" +
|
" ,@refCode varchar(50), @tel varchar(50), @propertyAddress varchar(200), @actionname varchar(100) ,@paigongname varchar(50), \n" +
|
" @shopGuideCode varchar(50), @neibushejicode varchar(50), @hDMemo varchar(400), @serverCode varchar(50),@approvalMemo varchar(200),\n" +
|
" @docStatus int, @docStatusName varchar(50),@cshopCode varchar(50),@cshopName varchar(200) ,@cVenCode varchar(50),@cVenName varchar(200),@EnterName varchar(80) ,\n" +
|
" @rowid varchar(20),@DocItem int ,@matcode varchar(50),@matname varchar(120) ,@Special varchar(80),\n" +
|
" @uom varchar(20),@digit money,@stcode varchar(20),@stname varchar(50),@ItemMemo varchar(400),\n" +
|
" @locationName varchar(200),@brand varchar(50) ,@refcodeitem varchar(50), @price money, @totalmoney2 money,@shopGuideName varchar(50),\n" +
|
" @cccode varchar(50),@ccname varchar(80),@errMsg varchar(500)\n" +
|
"\n" +
|
" declare @myrowcount int,@myerror int\n" +
|
" declare @table table (docCode varchar(20),docDate datetime,docType varchar(50),weixiuWay varchar(20),preSendDate datetime,cltCode varchar(20),cltName varchar(80) ,\n" +
|
" refCode varchar(50), tel varchar(50), propertyAddress varchar(200), actionname varchar(100) ,paigongname varchar(50), \n" +
|
" shopGuideCode varchar(50), neibushejicode varchar(50), hDMemo varchar(400), serverCode varchar(50),approvalMemo varchar(200),\n" +
|
" docStatus int, docStatusName varchar(50),cshopCode varchar(50),cshopName varchar(200) ,cVenCode varchar(50),cVenName varchar(200),EnterName varchar(80) ,\n" +
|
" rowid varchar(20),DocItem int, matcode varchar(50),matname varchar(120) ,Special varchar(80),\n" +
|
" uom varchar(20),digit money,stcode varchar(20),stname varchar(50),ItemMemo varchar(400),\n" +
|
" locationName varchar(200),brand varchar(50) ,refcodeitem varchar(50), price money,totalmoney2 money,shopGuideName varchar(50),errMsg varchar(500),cccode varchar(50),ccname varchar(80))\n" +
|
" \n" +
|
" declare @ObjMatCode varchar(50),@ObjMatName varchar(120) ,@ObjSpecial varchar(120) ,@FormId int = 640201 \n" +
|
" select top 1 @DefaultVndCode = a.DefaultVndCode ,@DefaultVndName = b.vndName \n" +
|
" from t110561 a left join t110302 b on a.DefaultVndCode = b.vndCode \n" +
|
" if isnull(@DefaultVndCode,'') = '' \n" +
|
" begin \n" +
|
" raiserror('请在 110561 功能号中维护【缺省供应商编号】',16,1) \n" +
|
" return \n" +
|
" end \n" +
|
" declare mycurDeli cursor for\n" +
|
" select b.docCode,b.docDate,b.docType,b.weixiuWay,b.preSendDate,b.cltCode,b.cltName ,\n" +
|
" b.refCode, b.tel, b.propertyAddress, b.actionname, b.paigongname, b.shopGuideCode, b.neibushejicode, b.hDMemo, b.serverCode, b.approvalMemo,\n" +
|
" b.docStatus, b.docStatusName,b.EnterName ,\n" +
|
" c.rowid,c.DocItem,c.matcode,c.matname,c.special,\n" +
|
" c.uom,c.digit,c.stcode,c.stname,c.ItemMemo,c.locationName,c.brand ,c.refcodeitem, c.price, c.totalmoney2, c.shopGuideName,\n" +
|
" b.cccode ,d.ccname \n" +
|
" from t640201H b \n" +
|
" join t640201D c on b.doccode = c.doccode \n" +
|
" left join t110601 d on b.cccode = d.cccode\n" +
|
" join t110503 e on c.matcode = e.matcode \n" +
|
" where isnull(b.cccode,'') <> '' \n" +
|
" and b.DocStatus=@mydocStatus \n" +
|
" and b.DocCode=@myDocCode \n" +
|
" and isnull(e.vndcode,'') = @DefaultVndCode \n" +
|
" order by b.DocCode\n" +
|
" open mycurDeli \n" +
|
" fetch next from mycurDeli into @docCode,@docDate,@docType,@weixiuWay,@preSendDate,@cltCode,@cltName ,\n" +
|
" @refCode, @tel, @propertyAddress, @actionname,@paigongname, @shopGuideCode, @neibushejicode, @hDMemo, @serverCode,@approvalMemo,\n" +
|
" @docStatus, @docStatusName,@EnterName ,\n" +
|
" @rowid,@DocItem,@matcode,@MatName,@special,\n" +
|
" @uom,@digit,@stcode,@stname,@ItemMemo,@locationName,@brand ,@refcodeitem, @price, @totalmoney2,@shopGuideName,\n" +
|
" @cccode,@ccname\n" +
|
" while @@fetch_status = 0 \n" +
|
" begin\n" +
|
" --检查该客户是否存在\n" +
|
" if not exists(select 1 from t110203 where cltcode = @cltcode) \n" +
|
" begin \n" +
|
" set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据【'+ isnull(@doccode,'') + '】客户编号【'+ isnull(@cltcode,'') + '】不存在,请在 110203 中新增该客户编号' \n" +
|
" end \n" +
|
" --检查与德立对照表是否存在或有重复设置照表\n" +
|
" select @cvenCode = cvenCode,@cvenName = cvenName,@cshopCode=cshopCode,@cshopName=cshopName from t110606 where cccode = @CcCode and isnull(cccode,'') <> '' \n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 or isnull(@cvenCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应代理商编号中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cshopCode,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应门店编号中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cvenName,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应代理商名称中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount = 0 or isnull(@cshopName,'') = '' set @errMsg = case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'当前单据所在的部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】,在德立系统对应门店名称中不存在,请在 110606 功能号维护对照关系' \n" +
|
" if @myrowcount <> 1 set @errMsg =case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end + '在 110606 功能号找到多条部门【'+isnull(@CcCode,'') + '】【'+ isnull(@CcName,'') + '】对照关系,请去掉重复的,保留一条即可'\n" +
|
" --检查物料主数据 是否有对照表关系 \n" +
|
" select @ObjMatCode = ObjMatCode,@ObjMatName = ObjMatName ,@ObjSpecial = ObjSpecial\n" +
|
" from t110560 a where a.ObjCode = @DefaultVndCode and a.matcode = @matcode \n" +
|
" select @myrowcount = @@ROWCOUNT,@myerror = @@ERROR\n" +
|
" if @myrowcount = 0 or isnull(@ObjMatCode,'') = '' \n" +
|
" begin\n" +
|
" set @errMsg =case when isnull(@errMsg,'') = '' then '' else @errMsg + ';' end +'物料编号【'+ isnull(@matcode,'') + '】【'+isnull(@matname,'') + '】在 110560 中没找到业务伙伴属于【'+isnull(@DefaultVndCode,'') + '】【'+isnull(@DefaultVndName,'')+'】对照关系,请在 110560 中预先维护好' \n" +
|
" end \n" +
|
" if isnull(@errMsg,'') <> '' \n" +
|
" begin\n" +
|
" if exists(select 1 from t110562 where doccode = @docCode and rowid = @rowid )\n" +
|
" begin\n" +
|
" update a set PushStatus = 0,PushDate = getdate(),PushTimes = isnull(PushTimes,0) + 1,PushMsg = @errMsg\n" +
|
" from t110562 a \n" +
|
" where a.doccode = @docCode and a.rowid = @rowid \n" +
|
" end else \n" +
|
" begin\n" +
|
" insert into t110562(FormId,DocCode,DocItem,RowId,MatCode,MatName,Special,Uom,\n" +
|
" Digit,Price,TotalMoney,StCode,StName,ItemMemo,PushStatus,PushDate,PushTimes,PushMsg)\n" +
|
" values (@FormId,@DocCode,@DocItem,@RowId,@MatCode,@MatName,@Special,@Uom,\n" +
|
" @Digit,@Price,@TotalMoney2,@StCode,@StName,@ItemMemo,0,getdate(),1,@errMsg)\n" +
|
" end \n" +
|
" end else \n" +
|
" begin\n" +
|
" insert into @table (docCode,docDate,docType,weixiuWay,preSendDate,cltCode,cltName ,\n" +
|
" refCode, tel, propertyAddress, actionname,paigongname, shopGuideCode, neibushejicode, hDMemo, serverCode,approvalMemo,\n" +
|
" docStatus, docStatusName,EnterName , rowid,DocItem,matcode,MatName,\n" +
|
" uom,digit,stcode,stname,ItemMemo,locationName,brand ,refcodeitem, price, totalmoney2,shopGuideName,\n" +
|
" cshopCode,cshopName ,cVenCode,cVenName,ccCode,ccName )\n" +
|
" values(@docCode,@docDate,@docType,@weixiuWay,@preSendDate,@cltCode,@cltName ,\n" +
|
" @refCode, @tel, @propertyAddress, @actionname,@paigongname, @shopGuideCode, @neibushejicode, @hDMemo, @serverCode,@approvalMemo,\n" +
|
" @docStatus, @docStatusName,@EnterName , \n" +
|
" @rowid,@DocItem,@ObjMatCode ,@ObjMatName,\n" +
|
" @uom,@digit,@stcode,@stname,@ItemMemo,@locationName,@brand ,@refcodeitem, @price, @totalmoney2,@shopGuideName,\n" +
|
" @cshopCode,@cshopName ,@cVenCode,@cVenName,@ccCode,@ccName)\n" +
|
" end \n" +
|
|
" fetch next from mycurDeli into @docCode,@docDate,@docType,@weixiuWay,@preSendDate,@cltCode,@cltName ,\n" +
|
" @refCode, @tel, @propertyAddress, @actionname,@paigongname, @shopGuideCode, @neibushejicode, @hDMemo, @serverCode,@approvalMemo,\n" +
|
" @docStatus, @docStatusName,@EnterName ,\n" +
|
" @rowid,@DocItem,@matcode,@MatName,@special,\n" +
|
" @uom,@digit,@stcode,@stname,@ItemMemo,@locationName,@brand ,@refcodeitem, @price, @totalmoney2,@shopGuideName,\n" +
|
" @cccode,@ccname\n" +
|
" end \n" +
|
" close mycurDeli\n" +
|
" deallocate mycurDeli\n" +
|
" select docCode,docDate,docType,weixiuWay,preSendDate,cltCode,cltName ,\n" +
|
" refCode, tel, propertyAddress, actionname,paigongname, shopGuideCode, neibushejicode, hDMemo, serverCode,approvalMemo,\n" +
|
" docStatus, docStatusName,EnterName , rowid,DocItem,matcode,matName,\n" +
|
" uom,digit,stcode,stname,ItemMemo,locationName,brand ,refcodeitem, price, totalmoney2,shopGuideName,\n" +
|
" cshopCode,cshopName ,cVenCode,cVenName,ccCode,ccName\n" +
|
" from @table " ;
|
|
|
try {
|
//取主表
|
List<Map<String,Object>> list= this.jdbcTemplate.queryForList(sql);
|
if(list!=null&&list.size()>0){
|
results=new ArrayList<>();
|
Set<Object> distinctDoccdeList = list.stream().map(x -> x.get("docCode")).collect(Collectors.toSet());//取出集合中不重复单号
|
|
for (Object dist : distinctDoccdeList) {
|
List<Map<String,Object>> t640201List = list.stream().filter(x -> dist.equals(x.get("docCode"))).collect(Collectors.toList());
|
boolean flag=false ;//
|
List<T640201DetailEntity> detailEntityList=new ArrayList<>();
|
T640201Entity t640201Entity =new T640201Entity();
|
|
for(Map<String,Object> map : t640201List) {
|
if (!flag) {//表示第一次,则要取主表
|
t640201Entity.setCustomer(new T640201HeadEntity(
|
GridUtils.prossRowSetDataType_String(map,"docCode"),
|
GridUtils.prossRowSetDataType_Date(map,"docDate"),
|
GridUtils.prossRowSetDataType_Date(map,"preSendDate") ,
|
GridUtils.prossRowSetDataType_String(map,"docType"),
|
GridUtils.prossRowSetDataType_String(map,"weixiuWay") ,
|
GridUtils.prossRowSetDataType_String(map,"cltCode"),
|
GridUtils.prossRowSetDataType_String(map,"cltName"),
|
GridUtils.prossRowSetDataType_String(map,"refCode"),
|
GridUtils.prossRowSetDataType_String(map,"tel"),
|
GridUtils.prossRowSetDataType_String(map,"propertyAddress"),
|
GridUtils.prossRowSetDataType_String(map,"actionname"),
|
GridUtils.prossRowSetDataType_String(map,"paigongname"),
|
GridUtils.prossRowSetDataType_String(map,"shopGuideCode"),
|
GridUtils.prossRowSetDataType_String(map,"neibushejicode"),
|
GridUtils.prossRowSetDataType_String(map,"hDMemo"),
|
GridUtils.prossRowSetDataType_String(map,"serverCode"),
|
GridUtils.prossRowSetDataType_String(map,"approvalMemo"),
|
GridUtils.prossRowSetDataType_Int(map,"docStatus"),
|
GridUtils.prossRowSetDataType_String(map,"docStatusName"),
|
GridUtils.prossRowSetDataType_String(map,"cVenCode"),
|
GridUtils.prossRowSetDataType_String(map,"cVenName"),
|
GridUtils.prossRowSetDataType_String(map,"cshopCode"),
|
GridUtils.prossRowSetDataType_String(map,"cshopName"),
|
GridUtils.prossRowSetDataType_String(map,"enterName")
|
));
|
}
|
detailEntityList.add(new T640201DetailEntity(
|
GridUtils.prossRowSetDataType_String(map,"matCode"),
|
GridUtils.prossRowSetDataType_String(map,"matName"),
|
GridUtils.prossRowSetDataType_String(map,"special"),
|
GridUtils.prossRowSetDataType_String(map,"uom"),
|
GridUtils.prossRowSetDataType_Double(map,"digit"),
|
GridUtils.prossRowSetDataType_String(map,"locationName"),
|
GridUtils.prossRowSetDataType_String(map,"brand"),
|
GridUtils.prossRowSetDataType_String(map,"stcode") ,
|
GridUtils.prossRowSetDataType_String(map,"stname") ,
|
GridUtils.prossRowSetDataType_String(map,"ItemMemo"),
|
GridUtils.prossRowSetDataType_Int(map,"DocItem"),
|
GridUtils.prossRowSetDataType_String(map,"rowid"),
|
GridUtils.prossRowSetDataType_String(map,"DocCode"),
|
GridUtils.prossRowSetDataType_String(map,"refcodeitem"),
|
GridUtils.prossRowSetDataType_Double(map,"price"),
|
GridUtils.prossRowSetDataType_Double(map,"totalmoney2"),
|
GridUtils.prossRowSetDataType_String(map,"shopGuideName") ));
|
flag=true;
|
}
|
t640201Entity.setOrders(detailEntityList);
|
results.add(t640201Entity);
|
|
|
}
|
}
|
}catch(Exception e ) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
this.doErrorLog(640201,e);
|
}
|
}
|
return results;
|
}
|
|
@Override
|
public T640109Entity getT640109(String doccode, String docitem, String rowid) {
|
T640109Entity results=null;
|
String sql=" set nocount on \n"
|
+ " declare @DefaultVndCode varchar(50),@DefaultVndName varchar(80) ,@mycccode varchar(50),@myccname varchar(80),@mycshopcode varchar(50) \n" +
|
" declare @cltcode varchar(50) ,@matcode varchar(50),@matname varchar(120),@myrowcount int,@myerror int \n"
|
+" declare @doccode varchar(50) =? ,@rowid varchar(20) = ? \n"
|
+" declare @refcodeitem varchar(50),@refrowid varchar(50) ,@vndcode varchar(50) \n"
|
+ " select top 1 @DefaultVndCode = a.DefaultVndCode ,@DefaultVndName = b.vndName \n"
|
+" from t110561 a left join t110302 b on a.DefaultVndCode = b.vndCode \n"
|
+ " if isnull(@DefaultVndCode,'') = '' \n"
|
+ " begin \n"
|
+ " raiserror('请在 110561 功能号中维护【缺省供应商编号】',16,1) \n"
|
+ " return \n"
|
+ " end \n"
|
+ " select @mycccode=a.cccode,@myccname = c.ccname,@cltcode = a.cltcode ,@matcode = b.matcode,@matname = b.matname ,@refcodeitem=b.refcodeitem,@refrowid=b.refrowid \n" +
|
" from t640109H a join t640109D b on a.doccode = b.doccode \n" +
|
" left join t110601 c on a.cccode = c.cccode \n" +
|
" where a.doccode = @doccode and b.rowid = @rowid \n" +
|
" select @myrowcount = @@rowcount , @myerror = @@error \n" +
|
" if @myrowcount = 0 \n" +
|
" begin \n" +
|
" raiserror('当前单据【单号:%s】【rowid: %s】不存在',16,1,@doccode,@rowid ) \n" +
|
" return \n" +
|
" end \n" +
|
" select @vndcode = vndcode from t110503 where matcode = @matcode \n" +
|
" select @myrowcount = @@rowcount , @myerror = @@error \n" +
|
" if @myrowcount = 0 \n" +
|
" begin \n" +
|
" raiserror('当前物料【%s】不存在,请在 110503 中预先维护!',16,1,@matcode ) \n" +
|
" return \n" +
|
" end \n" +
|
" if isnull(@vndcode,'') = '' \n" +
|
" begin \n" +
|
" raiserror('当前物料【%s】不是德立物料,请在 110503 维护默认供应商为【%s】,然后重试此操作!',16,1,@matcode,@DefaultVndCode ) \n" +
|
" return \n" +
|
" end \n" +
|
" if isnull(@mycccode,'') = '' \n" +
|
" begin \n" +
|
" raiserror('当前单据【%s】部门编号不能为空',16,1,@doccode) \n" +
|
" return \n" +
|
" end \n" +
|
" if isnull(@myccname,'') = '' \n" +
|
" begin \n" +
|
" raiserror('当前单据【%s】部门参数【%s】不存在(可能名称为空值),请在 110601 中维护该部门编号及其名称',16,1,@doccode,@mycccode) \n" +
|
" return \n" +
|
" end \n" +
|
" if not exists(select 1 from t110203 where cltcode = @cltcode) \n" +
|
" begin \n" +
|
" raiserror('当前单据【%s】客户编号【%s】不存在,请在 110203 中新增该客户编号',16,1,@doccode,@cltcode) \n" +
|
" return \n" +
|
" end \n" +
|
" if isnull(@refcodeitem,'') = '' \n" +
|
" begin \n" +
|
" raiserror('当前单据【%s】refcodeitem不能为空',16,1,@doccode,@refcodeitem) \n" +
|
" return \n" +
|
" end \n" +
|
" if isnull(@refrowid,'') = '' \n" +
|
" begin \n" +
|
" raiserror('当前单据【%s】refrowid不能为空',16,1,@doccode,@refrowid) \n" +
|
" return \n" +
|
" end \n" +
|
" select @mycshopcode=a.cshopCode from t110606 a where a.cccode = @mycccode \n" +
|
" select @myrowcount = @@rowcount , @myerror = @@error \n" +
|
" if @myrowcount = 0 or isnull(@mycshopcode,'') = '' \n" +
|
" begin \n" +
|
" raiserror('当前单据所在的部门【%s】【%s】,在德立系统对应门店编号中不存在,请在 110606 功能号维护对照关系',16,1,@mycccode,@myccname) \n" +
|
" return \n" +
|
" end \n" +
|
" if @myrowcount <> 1 \n" +
|
" begin \n" +
|
" raiserror('在 110606 功能号找到多条部门【%s】【%s】对照关系,请去掉重复的,保留一条即可',16,1,@mycccode,@myccname) \n" +
|
" return \n" +
|
" end \n" +
|
" if not exists(select 1 from t110560 a where a.ObjCode = @DefaultVndCode and a.matcode = @matcode )\n" +
|
" begin \n" +
|
" raiserror('物料编号【%s】【%s】在 110560 中没找到业务伙伴属于【%s】【%s】对照关系,请在 110560 中预先维护好',16,1,@matcode,@matname,@DefaultVndCode,@DefaultVndName) \n" +
|
" return \n" +
|
" end \n" +
|
" select @matname=a.matname from t110560 a where a.matcode = @matcode \n" +
|
" select @myrowcount = @@rowcount , @myerror = @@error \n" +
|
" if @myrowcount <> 1 \n" +
|
" begin \n" +
|
" raiserror('在 t110560 功能号找到多个物料【%s】【%s】,请去掉重复的,保留一条即可',16,1,@matcode,@matname) \n" +
|
" return \n" +
|
" end " +
|
" select b.docCode,b.docDate,b.preSendDate,b.factdate,b.docType,b.cltCode,\n" +
|
" b.cltName,b.meterName,b.tel,b.propertyAddress,b.sellerName,b.shopGuideName,\n" +
|
" b.shejiCode,b.shejiName,b.hDMemo,b.attachmentDate,b.approvalMemo,\n" +
|
" b.approvalMemo2,b.approvalMemo3,\n" +
|
" b.approvalMemo4,b.docStatus, b.docStatusName,b.refCode,b.EnterName, b.cccode,\n" +
|
" a.cshopCode,a.cshopName ,a.cVenCode,a.cVenName, \n" +
|
" c.DocCode,c.rowid,c.DocItem,\n" +
|
" d.ObjMatCode as matCode,d.ObjMatName as matName,d.ObjSpecial as special,\n" +
|
" c.uom,c.digit,c.locationName,c.ItemMemo,c.refcodeitem,c.refrowid \n"+
|
" from t640109H b join t110606 a on a.ccCode=b.ccCode \n" +
|
" join t640109D c on b.doccode = c.doccode \n" +
|
" join t110560 d on d.ObjCode = @DefaultVndCode and c.matcode = d.matcode \n" +
|
" join t110203 e on b.cltcode = e.cltcode \n" +
|
" where b.doccode=@doccode and c.rowid=@rowid \n" +
|
" order by b.DocCode \n" ;
|
|
try {
|
Map<String,Object> map= this.jdbcTemplate.queryForMap(sql,doccode,rowid);
|
if(map!=null&&map.size()>0){
|
List<T640109DetailEntity> detailEntityList=new ArrayList<>();
|
detailEntityList.add(new T640109DetailEntity(
|
GridUtils.prossRowSetDataType_String(map,"matCode"),
|
GridUtils.prossRowSetDataType_String(map,"matName"),
|
GridUtils.prossRowSetDataType_String(map,"uom"),
|
GridUtils.prossRowSetDataType_Double(map,"digit"),
|
GridUtils.prossRowSetDataType_String(map,"ItemMemo"),
|
GridUtils.prossRowSetDataType_Int(map,"DocItem"),
|
GridUtils.prossRowSetDataType_String(map,"rowid"),
|
GridUtils.prossRowSetDataType_String(map,"DocCode"),
|
GridUtils.prossRowSetDataType_String(map,"locationName") ,
|
GridUtils.prossRowSetDataType_String(map,"special"),
|
GridUtils.prossRowSetDataType_String(map, "refcodeitem"),
|
0,
|
GridUtils.prossRowSetDataType_String(map, "refrowid")
|
));
|
|
//主表
|
if(results==null){ results=new T640109Entity();}
|
results.setCustomer(new T640109HeadEntity(
|
GridUtils.prossRowSetDataType_String(map,"docCode"),
|
GridUtils.prossRowSetDataType_Date(map,"docdate"),
|
GridUtils.prossRowSetDataType_Date(map,"preSendDate"),
|
GridUtils.prossRowSetDataType_Date(map,"factdate"),
|
GridUtils.prossRowSetDataType_String(map,"docType"),
|
GridUtils.prossRowSetDataType_String(map,"cltCode"),
|
GridUtils.prossRowSetDataType_String(map,"cltName"),
|
GridUtils.prossRowSetDataType_String(map,"meterName"),
|
GridUtils.prossRowSetDataType_String(map,"tel") ,
|
GridUtils.prossRowSetDataType_String(map,"propertyAddress") ,
|
GridUtils.prossRowSetDataType_String(map,"sellerName"),
|
GridUtils.prossRowSetDataType_String(map,"shopGuideName"),
|
GridUtils.prossRowSetDataType_String(map,"shejiCode"),
|
GridUtils.prossRowSetDataType_String(map,"shejiName"),
|
GridUtils.prossRowSetDataType_String(map,"hDMemo"),
|
GridUtils.prossRowSetDataType_Date(map,"attachmentDate"),
|
GridUtils.prossRowSetDataType_String(map,"approvalMemo"),
|
GridUtils.prossRowSetDataType_String(map,"approvalMemo2"),
|
GridUtils.prossRowSetDataType_String(map,"approvalMemo3"),
|
GridUtils.prossRowSetDataType_String(map,"approvalMemo4"),
|
GridUtils.prossRowSetDataType_Int(map,"docStatus"),
|
GridUtils.prossRowSetDataType_String(map,"docStatusName"),
|
GridUtils.prossRowSetDataType_String(map,"refCode"),
|
GridUtils.prossRowSetDataType_String(map,"cVenCode"),
|
GridUtils.prossRowSetDataType_String(map,"cVenName"),
|
GridUtils.prossRowSetDataType_String(map,"cshopCode"),
|
GridUtils.prossRowSetDataType_String(map,"cshopName"),
|
GridUtils.prossRowSetDataType_String(map,"cccode"),
|
GridUtils.prossRowSetDataType_String(map,"EnterName")
|
));
|
results.setDetails(detailEntityList);
|
}
|
}catch(Exception e ) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
throw new ApplicationException(e.getCause()!=null?e.getCause().getMessage():e.getMessage());
|
// this.doErrorLog(640109,e);
|
}
|
}
|
return results;
|
}
|
|
@Override
|
public Integer bindUserAccount(DataSourceEntity dataSource) {
|
return this.jdbcTemplate.update("set nocount on \n update a set a.DeliUserCode =? , a.DeliUserId =? from gsystem a where id=?",dataSource.getDeliUserCode(),dataSource.getDeliUserId(),dataSource.getDbId());
|
}
|
|
@Override
|
public Integer unbindUserAccount(DataSourceEntity dataSource) {
|
return this.jdbcTemplate.update("set nocount on \n update a set a.DeliUserCode =null , a.DeliUserId =null from gsystem a where id=?",dataSource.getDbId());
|
}
|
}
|