@ -1,28 +1,10 @@
package jnpf.service.impl ;
import cn.hutool.json.JSONUtil ;
import com.alibaba.fastjson.JSONArray ;
import jnpf.base.ActionResult ;
import jnpf.engine.controller.FlowBeforeController ;
import jnpf.engine.model.flowbefore.FlowBeforeInfoVO ;
import jnpf.engine.model.flowbefore.FlowTaskOperatorRecordModel ;
import jnpf.engine.model.flowengine.FlowModel ;
import jnpf.entity.* ;
import jnpf.exception.WorkFlowException ;
import jnpf.mapper.CwpaymentreceiptMapper ;
import jnpf.mapper.PaymentApplicationMapper ;
import jnpf.model.cwpaymentreceipt.PaymentdocMessage ;
import jnpf.permission.entity.OrganizeEntity ;
import jnpf.permission.service.OrganizeService ;
import jnpf.permission.service.UserService ;
import jnpf.service.* ;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl ;
import jnpf.model.paymentapplication.* ;
import java.io.BufferedOutputStream ;
import java.io.ByteArrayOutputStream ;
import java.io.IOException ;
import java.io.UnsupportedEncodingException ;
import java.math.BigDecimal ;
import cn.hutool.core.util.ObjectUtil ;
import jnpf.permission.model.authorize.AuthorizeConditionModel ;
@ -32,13 +14,10 @@ import jnpf.database.model.superQuery.ConditionJsonModel;
import jnpf.database.model.superQuery.SuperQueryConditionModel ;
import java.lang.reflect.Field ;
import com.baomidou.mybatisplus.annotation.TableField ;
import java.net.URLEncoder ;
import java.util.regex.Pattern ;
import jnpf.model.QueryModel ;
import java.util.stream.Collectors ;
import jnpf.base.model.ColumnDataModel ;
import jnpf.util.context.SpringContext ;
import org.springframework.stereotype.Service ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import jnpf.database.model.superQuery.SuperJsonModel ;
@ -51,16 +30,13 @@ import jnpf.util.*;
import java.util.* ;
import jnpf.base.UserInfo ;
import jnpf.permission.entity.UserEntity ;
import javax.servlet.http.HttpServletResponse ;
/ * *
*
* PaymentApplication
* 版 本 : V3 .5
* 版 权 : 引 迈 信 息 技 术 有 限 公 司 ( https : //www.jnpfsoft.com)
* 作 者 : JNPF 开 发 平 台 组
* 日 期 : 2024 - 06 - 06
* 日 期 : 2024 - 06 - 24
* /
@Service
public class PaymentApplicationServiceImpl extends ServiceImpl < PaymentApplicationMapper , PaymentApplicationEntity > implements PaymentApplicationService {
@ -69,16 +45,9 @@ public class PaymentApplicationServiceImpl extends ServiceImpl<PaymentApplicatio
@Autowired
private UserProvider userProvider ;
@Autowired
private CwpaymentreceiptMapper cwpaymentreceiptMapper ;
@Autowired
private OrganizeService organizeService ;
@Autowired
private UserService userService ;
@Autowired
private SubjectbasicService subjectbasicService ;
@Autowired
private PaymentapplicationsettlementService paymentapplicationsettlementService ;
@Override
public List < PaymentApplicationEntity > getList ( PaymentApplicationPagination paymentApplicationPagination ) {
return getTypeList ( paymentApplicationPagination , paymentApplicationPagination . getDataType ( ) ) ;
@ -97,6 +66,9 @@ public class PaymentApplicationServiceImpl extends ServiceImpl<PaymentApplicatio
int total = 0 ;
int paymentApplicationNum = 0 ;
QueryWrapper < PaymentApplicationEntity > paymentApplicationQueryWrapper = new QueryWrapper < > ( ) ;
int paymentapplicationsettlementNum = 0 ;
QueryWrapper < PaymentapplicationsettlementEntity > paymentapplicationsettlementQueryWrapper = new QueryWrapper < > ( ) ;
long paymentapplicationsettlementcount = paymentapplicationsettlementService . count ( ) ;
List < String > allSuperIDlist = new ArrayList < > ( ) ;
String superOp = "" ;
if ( ObjectUtil . isNotEmpty ( paymentApplicationPagination . getSuperQueryJson ( ) ) ) {
@ -114,6 +86,14 @@ public class PaymentApplicationServiceImpl extends ServiceImpl<PaymentApplicatio
intersectionSuperList . add ( paymentApplicationList ) ;
superNum + + ;
}
String paymentapplicationsettlementTable = "jg_cw_payment_application_settlement" ;
boolean paymentapplicationsettlementHasSql = queryJson . contains ( paymentapplicationsettlementTable ) ;
List < String > paymentapplicationsettlementList = generaterSwapUtil . selectIdsByChildCondition ( PaymentApplicationConstant . getTableList ( ) , paymentapplicationsettlementTable , queryJson , null ) ;
if ( paymentapplicationsettlementHasSql ) {
allSuperList . addAll ( paymentapplicationsettlementList ) ;
intersectionSuperList . add ( paymentapplicationsettlementList ) ;
superNum + + ;
}
superOp = superNum > 0 ? superJsonModel . getMatchLogic ( ) : "" ;
//and or
if ( superOp . equalsIgnoreCase ( "and" ) ) {
@ -138,6 +118,14 @@ public class PaymentApplicationServiceImpl extends ServiceImpl<PaymentApplicatio
intersectionRuleList . add ( paymentApplicationList ) ;
ruleNum + + ;
}
String paymentapplicationsettlementTable = "jg_cw_payment_application_settlement" ;
boolean paymentapplicationsettlementHasSql = ruleJson . contains ( paymentapplicationsettlementTable ) ;
List < String > paymentapplicationsettlementList = generaterSwapUtil . selectIdsByChildCondition ( PaymentApplicationConstant . getTableList ( ) , paymentapplicationsettlementTable , ruleJson , null ) ;
if ( paymentapplicationsettlementHasSql ) {
allRuleList . addAll ( paymentapplicationsettlementList ) ;
intersectionRuleList . add ( paymentapplicationsettlementList ) ;
ruleNum + + ;
}
ruleOp = ruleNum > 0 ? ruleJsonModel . getMatchLogic ( ) : "" ;
//and or
if ( ruleOp . equalsIgnoreCase ( "and" ) ) {
@ -146,79 +134,115 @@ public class PaymentApplicationServiceImpl extends ServiceImpl<PaymentApplicatio
allRuleIDlist = allRuleList ;
}
}
boolean pcPermission = true ;
boolean appPermission = false ;
if ( isPc & & pcPermission ) {
if ( ! userProvider . get ( ) . getIsAdministrator ( ) ) {
Object paymentApplicationObj = generaterSwapUtil . getAuthorizeCondition ( new QueryModel ( paymentApplicationQueryWrapper , PaymentApplicationEntity . class , paymentApplicationPagination . getMenuId ( ) , "0" ) ) ;
if ( ObjectUtil . isEmpty ( paymentApplicationObj ) ) {
return new ArrayList < > ( ) ;
} else {
paymentApplicationQueryWrapper = ( QueryWrapper < PaymentApplicationEntity > ) paymentApplicationObj ;
if ( paymentApplicationQueryWrapper . getExpression ( ) . getNormal ( ) . size ( ) > 0 ) {
paymentApplicationNum + + ;
}
}
}
}
if ( ! isPc & & appPermission ) {
if ( ! userProvider . get ( ) . getIsAdministrator ( ) ) {
Object paymentApplicationObj = generaterSwapUtil . getAuthorizeCondition ( new QueryModel ( paymentApplicationQueryWrapper , PaymentApplicationEntity . class , paymentApplicationPagination . getMenuId ( ) , "0" ) ) ;
if ( ObjectUtil . isEmpty ( paymentApplicationObj ) ) {
return new ArrayList < > ( ) ;
} else {
paymentApplicationQueryWrapper = ( QueryWrapper < PaymentApplicationEntity > ) paymentApplicationObj ;
if ( paymentApplicationQueryWrapper . getExpression ( ) . getNormal ( ) . size ( ) > 0 ) {
paymentApplicationNum + + ;
}
boolean pcPermission = true ;
boolean appPermission = false ;
if ( isPc & & pcPermission ) {
if ( ! userProvider . get ( ) . getIsAdministrator ( ) ) {
Object paymentApplicationObj = generaterSwapUtil . getAuthorizeCondition ( new QueryModel ( paymentApplicationQueryWrapper , PaymentApplicationEntity . class , paymentApplicationPagination . getMenuId ( ) , "0" ) ) ;
if ( ObjectUtil . isEmpty ( paymentApplicationObj ) ) {
return new ArrayList < > ( ) ;
} else {
paymentApplicationQueryWrapper = ( QueryWrapper < PaymentApplicationEntity > ) paymentApplicationObj ;
if ( paymentApplicationQueryWrapper . getExpression ( ) . getNormal ( ) . size ( ) > 0 ) {
paymentApplicationNum + + ;
}
}
Object paymentapplicationsettlementObj = generaterSwapUtil . getAuthorizeCondition ( new QueryModel ( paymentapplicationsettlementQueryWrapper , PaymentapplicationsettlementEntity . class , paymentApplicationPagination . getMenuId ( ) , "0" ) ) ;
if ( ObjectUtil . isEmpty ( paymentapplicationsettlementObj ) ) {
return new ArrayList < > ( ) ;
} else {
paymentapplicationsettlementQueryWrapper = ( QueryWrapper < PaymentapplicationsettlementEntity > ) paymentapplicationsettlementObj ;
if ( paymentapplicationsettlementQueryWrapper . getExpression ( ) . getNormal ( ) . size ( ) > 0 ) {
paymentapplicationsettlementNum + + ;
}
}
}
}
if ( ! isPc & & appPermission ) {
if ( ! userProvider . get ( ) . getIsAdministrator ( ) ) {
Object paymentApplicationObj = generaterSwapUtil . getAuthorizeCondition ( new QueryModel ( paymentApplicationQueryWrapper , PaymentApplicationEntity . class , paymentApplicationPagination . getMenuId ( ) , "0" ) ) ;
if ( ObjectUtil . isEmpty ( paymentApplicationObj ) ) {
return new ArrayList < > ( ) ;
} else {
paymentApplicationQueryWrapper = ( QueryWrapper < PaymentApplicationEntity > ) paymentApplicationObj ;
if ( paymentApplicationQueryWrapper . getExpression ( ) . getNormal ( ) . size ( ) > 0 ) {
paymentApplicationNum + + ;
}
}
}
}
Object paymentapplicationsettlementObj = generaterSwapUtil . getAuthorizeCondition ( new QueryModel ( paymentapplicationsettlementQueryWrapper , PaymentapplicationsettlementEntity . class , paymentApplicationPagination . getMenuId ( ) , "0" ) ) ;
if ( ObjectUtil . isEmpty ( paymentapplicationsettlementObj ) ) {
return new ArrayList < > ( ) ;
} else {
paymentapplicationsettlementQueryWrapper = ( QueryWrapper < PaymentapplicationsettlementEntity > ) paymentapplicationsettlementObj ;
if ( paymentapplicationsettlementQueryWrapper . getExpression ( ) . getNormal ( ) . size ( ) > 0 ) {
paymentapplicationsettlementNum + + ;
}
}
}
}
if ( isPc ) {
if ( ObjectUtil . isNotEmpty ( paymentApplicationPagination . getCode ( ) ) ) {
paymentApplicationNum + + ;
paymentApplicationNum + + ;
String value = paymentApplicationPagination . getCode ( ) instanceof List ?
JsonUtil . getObjectToString ( paymentApplicationPagination . getCode ( ) ) :
String . valueOf ( paymentApplicationPagination . getCode ( ) ) ;
JsonUtil . getObjectToString ( paymentApplicationPagination . getCode ( ) ) :
String . valueOf ( paymentApplicationPagination . getCode ( ) ) ;
paymentApplicationQueryWrapper . lambda ( ) . like ( PaymentApplicationEntity : : getCode , value ) ;
}
if ( ObjectUtil . isNotEmpty ( paymentApplicationPagination . getPreparationTime ( ) ) ) {
paymentApplicationNum + + ;
List PreparationTimeList = JsonUtil . getJsonToList ( paymentApplicationPagination . getPreparationTime ( ) , String . class ) ;
Long fir = Long . valueOf ( String . valueOf ( PreparationTimeList . get ( 0 ) ) ) ;
Long sec = Long . valueOf ( String . valueOf ( PreparationTimeList . get ( 1 ) ) ) ;
paymentApplicationQueryWrapper . ge ( "f_creator_time" , new Date ( fir ) )
. le ( "f_creator_time" , DateUtil . stringToDate ( DateUtil . daFormatYmd ( sec ) + " 23:59:59" ) ) ;
}
if ( ObjectUtil . isNotEmpty ( paymentApplicationPagination . getPayee ( ) ) ) {
paymentApplicationNum + + ;
paymentApplicationNum + + ;
String value = paymentApplicationPagination . getPayee ( ) instanceof List ?
JsonUtil . getObjectToString ( paymentApplicationPagination . getPayee ( ) ) :
String . valueOf ( paymentApplicationPagination . getPayee ( ) ) ;
JsonUtil . getObjectToString ( paymentApplicationPagination . getPayee ( ) ) :
String . valueOf ( paymentApplicationPagination . getPayee ( ) ) ;
paymentApplicationQueryWrapper . lambda ( ) . like ( PaymentApplicationEntity : : getPayee , value ) ;
}
if ( ObjectUtil . isNotEmpty ( paymentApplicationPagination . getPayer ( ) ) ) {
paymentApplicationNum + + ;
paymentApplicationNum + + ;
String value = paymentApplicationPagination . getPayer ( ) instanceof List ?
JsonUtil . getObjectToString ( paymentApplicationPagination . getPayer ( ) ) :
String . valueOf ( paymentApplicationPagination . getPayer ( ) ) ;
JsonUtil . getObjectToString ( paymentApplicationPagination . getPayer ( ) ) :
String . valueOf ( paymentApplicationPagination . getPayer ( ) ) ;
paymentApplicationQueryWrapper . lambda ( ) . like ( PaymentApplicationEntity : : getPayer , value ) ;
}
if ( ObjectUtil . isNotEmpty ( paymentApplicationPagination . getPaymentState ( ) ) ) {
paymentApplicationNum + + ;
String value = paymentApplicationPagination . getPaymentState ( ) instanceof List ?
JsonUtil . getObjectToString ( paymentApplicationPagination . getPaymentState ( ) ) :
String . valueOf ( paymentApplicationPagination . getPaymentState ( ) ) ;
paymentApplicationQueryWrapper . lambda ( ) . like ( PaymentApplicationEntity : : getPaymentState , value ) ;
}
if ( ObjectUtil . isNotEmpty ( paymentApplicationPagination . getDocState ( ) ) ) {
paymentApplicationNum + + ;
String value = paymentApplicationPagination . getDocState ( ) instanceof List ?
JsonUtil . getObjectToString ( paymentApplicationPagination . getDocState ( ) ) :
String . valueOf ( paymentApplicationPagination . getDocState ( ) ) ;
paymentApplicationQueryWrapper . lambda ( ) . like ( PaymentApplicationEntity : : getDocState , value ) ;
}
}
if ( paymentapplicationsettlementNum > 0 ) {
List < String > paymentapplicationsettlementIdList = paymentapplicationsettlementService . list ( paymentapplicationsettlementQueryWrapper ) . stream ( ) . filter ( t - > StringUtil . isNotEmpty ( t . getPaymentApplicationId ( ) ) ) . map ( t - > t . getPaymentApplicationId ( ) ) . collect ( Collectors . toList ( ) ) ;
long count = paymentapplicationsettlementService . count ( ) ;
if ( count > 0 ) {
intersectionList . add ( paymentapplicationsettlementIdList ) ;
}
AllIdList . addAll ( paymentapplicationsettlementIdList ) ;
}
total + = paymentapplicationsettlementNum ;
List < String > intersection = generaterSwapUtil . getIntersection ( intersectionList ) ;
if ( total > 0 ) {
if ( intersection . size ( ) = = 0 ) {
@ -226,7 +250,7 @@ public class PaymentApplicationServiceImpl extends ServiceImpl<PaymentApplicatio
}
paymentApplicationQueryWrapper . lambda ( ) . in ( PaymentApplicationEntity : : getId , intersection ) ;
}
//是否有高级查询
//是否有高级查询
if ( StringUtil . isNotEmpty ( superOp ) ) {
if ( allSuperIDlist . size ( ) = = 0 ) {
allSuperIDlist . add ( "jnpfNullList" ) ;
@ -234,7 +258,7 @@ public class PaymentApplicationServiceImpl extends ServiceImpl<PaymentApplicatio
List < String > finalAllSuperIDlist = allSuperIDlist ;
paymentApplicationQueryWrapper . lambda ( ) . and ( t - > t . in ( PaymentApplicationEntity : : getId , finalAllSuperIDlist ) ) ;
}
//是否有数据过滤查询
//是否有数据过滤查询
if ( StringUtil . isNotEmpty ( ruleOp ) ) {
if ( allRuleIDlist . size ( ) = = 0 ) {
allRuleIDlist . add ( "jnpfNullList" ) ;
@ -295,6 +319,27 @@ public class PaymentApplicationServiceImpl extends ServiceImpl<PaymentApplicatio
this . removeById ( entity . getId ( ) ) ;
}
}
/** Paymentapplicationsettlement子表方法 */
@Override
public List < PaymentapplicationsettlementEntity > getPaymentapplicationsettlementList ( String id , PaymentApplicationPagination paymentApplicationPagination ) {
Map < String , Object > newtabMap = PaymentApplicationConstant . TABLEFIELDKEY . entrySet ( )
. stream ( ) . collect ( Collectors . toMap ( e - > e . getValue ( ) , e - > e . getKey ( ) ) ) ;
String tableName = "paymentapplicationsettlement" ;
tableName = newtabMap . get ( tableName ) = = null ? tableName : newtabMap . get ( tableName ) . toString ( ) ;
QueryWrapper < PaymentapplicationsettlementEntity > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper = paymentapplicationsettlementService . getChild ( paymentApplicationPagination , queryWrapper ) ;
queryWrapper . lambda ( ) . eq ( PaymentapplicationsettlementEntity : : getPaymentApplicationId , id ) ;
generaterSwapUtil . wrapperHandle ( PaymentApplicationConstant . getColumnData ( ) , PaymentApplicationConstant . getAppColumnData ( ) , queryWrapper , PaymentapplicationsettlementEntity . class , "sub" , tableName ) ;
return paymentapplicationsettlementService . list ( queryWrapper ) ;
}
/** Paymentapplicationsettlement子表方法 */
@Override
public List < PaymentapplicationsettlementEntity > getPaymentapplicationsettlementList ( String id ) {
QueryWrapper < PaymentapplicationsettlementEntity > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . lambda ( ) . eq ( PaymentapplicationsettlementEntity : : getPaymentApplicationId , id ) ;
return paymentapplicationsettlementService . list ( queryWrapper ) ;
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm ( PaymentApplicationForm form , int i ) {
@ -305,174 +350,74 @@ public class PaymentApplicationServiceImpl extends ServiceImpl<PaymentApplicatio
id = form . getId ( ) ;
}
//主表字段验证
if ( StringUtil . isEmpty ( form . getPayee ( ) ) ) {
return "收款方不能为空" ;
}
if ( StringUtil . isEmpty ( form . getPayer ( ) ) ) {
return "付款方不能为空" ;
}
if ( StringUtil . isEmpty ( form . getPayee ( ) ) ) {
return "收款方不能为空" ;
}
if ( StringUtil . isEmpty ( form . getPayer ( ) ) ) {
return "付款方不能为空" ;
}
/ * if ( StringUtil . isNotEmpty ( form . getPayer ( ) ) ) {
form . setPayer ( form . getPayer ( ) . trim ( ) ) ;
QueryWrapper < PaymentApplicationEntity > payerWrapper = new QueryWrapper < > ( ) ;
payerWrapper . lambda ( ) . eq ( PaymentApplicationEntity : : getPayer , form . getPayer ( ) ) ;
//假删除标志
payerWrapper . lambda ( ) . isNull ( PaymentApplicationEntity : : getDeleteMark ) ;
if ( isUp ) {
payerWrapper . lambda ( ) . ne ( PaymentApplicationEntity : : getId , id ) ;
}
if ( ( int ) this . count ( payerWrapper ) > 0 ) {
countRecover = "付款方不能重复" ;
}
} * /
//子表字段验证
if ( form . getPaymentapplicationsettlementList ( ) ! = null ) {
}
return countRecover ;
}
/ * *
* 新 增 修 改 数 据 ( 事 务 回 滚 )
* @param id
* @param paymentApplicationForm
* @return
* /
* 新 增 修 改 数 据 ( 事 务 回 滚 )
* @param id
* @param paymentApplicationForm
* @return
* /
@Override
@Transactional
public void saveOrUpdate ( PaymentApplicationForm paymentApplicationForm , String id , boolean isSave ) throws Exception {
UserInfo userInfo = userProvider . get ( ) ;
UserEntity userEntity = generaterSwapUtil . getUser ( userInfo . getUserId ( ) ) ;
paymentApplicationForm = JsonUtil . getJsonToBean (
generaterSwapUtil . swapDatetime ( PaymentApplicationConstant . getFormData ( ) , paymentApplicationForm ) , PaymentApplicationForm . class ) ;
generaterSwapUtil . swapDatetime ( PaymentApplicationConstant . getFormData ( ) , paymentApplicationForm ) , PaymentApplicationForm . class ) ;
PaymentApplicationEntity entity = JsonUtil . getJsonToBean ( paymentApplicationForm , PaymentApplicationEntity . class ) ;
if ( isSave ) {
String mainId = id ;
entity . setCode ( generaterSwapUtil . getBillNumber ( "FKSQ" , false ) ) ;
String mainId = RandomUt il. uuI d( ) ;
entity . setCode ( generaterSwapUtil . getBillNumber ( "FKSQ" , false ) ) ;
entity . setId ( mainId ) ;
entity . setFlowId ( paymentApplicationForm . getFlowId ( ) ) ;
entity . setVersion ( 0 ) ;
} else {
entity . setCode ( generaterSwapUtil . getBillNumber ( "FKSQ" , false ) ) ;
entity . setFlowId ( paymentApplicationForm . getFlowId ( ) ) ;
entity . setCode ( generaterSwapUtil . getBillNumber ( "FKSQ" , false ) ) ;
}
this . saveOrUpdate ( entity ) ;
}
@Override
public void getPaymentDocPdf ( String id ) throws IOException {
List < Map < String , Object > > paymentDocNodeInfo = cwpaymentreceiptMapper . getPaymentDocNodeInfo ( id ) ;
String stringtime = null ;
if ( paymentDocNodeInfo ! = null & & paymentDocNodeInfo . size ( ) > 0 ) {
System . out . println ( paymentDocNodeInfo . get ( 0 ) . get ( "handleTime" ) ) ;
stringtime = paymentDocNodeInfo . get ( 0 ) . get ( "handleTime" ) . toString ( ) ;
}
PaymentdocMessage paymentdocMessage = new PaymentdocMessage ( ) ;
PaymentApplicationEntity paymentApplicationEntity = this . getById ( id ) ;
SubjectbasicEntity subjectbasicEntity = subjectbasicService . getById ( paymentApplicationEntity . getSubjectId ( ) ) ;
UserEntity userEntity = userService . getInfo ( paymentApplicationEntity . getCreatorUserId ( ) ) ;
paymentdocMessage . setRealName ( userEntity . getRealName ( ) ) ;
paymentdocMessage . setMobilePhone ( userEntity . getAccount ( ) ) ;
paymentdocMessage . setNowTime ( new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) . format ( paymentApplicationEntity . getCreatorTime ( ) ) ) ;
OrganizeEntity companyEntity = organizeService . getById ( paymentApplicationEntity . getCompanyId ( ) ) ;
if ( companyEntity = = null ) {
companyEntity = new OrganizeEntity ( ) ;
}
paymentdocMessage . setCustomerName ( companyEntity . getFullName ( ) + "请示" ) ;
paymentdocMessage . setDocumentNo ( paymentApplicationEntity . getCode ( ) ) ;
paymentdocMessage . setSupplierName ( paymentApplicationEntity . getPayee ( ) ) ;
paymentdocMessage . setRamout ( paymentApplicationEntity . getApplyAmount ( ) . toString ( ) ) ;
paymentdocMessage . setPaymentAmout ( "" ) ;
paymentdocMessage . setCollectionAccout ( subjectbasicEntity . getBankAccount ( ) ) ;
paymentdocMessage . setColletionBank ( subjectbasicEntity . getBankBranchName ( ) ) ;
paymentdocMessage . setRemark ( paymentApplicationEntity . getRemark ( ) ) ;
paymentdocMessage . setEnclosure ( paymentApplicationEntity . getAnnex ( ) ) ;
paymentdocMessage . setPayType ( "货款" ) ;
OrganizeEntity departmentEntity = organizeService . getById ( paymentApplicationEntity . getDepartmentId ( ) ) ;
if ( departmentEntity = = null ) {
departmentEntity = new OrganizeEntity ( ) ;
}
paymentdocMessage . setFullName ( companyEntity . getFullName ( ) + "/" + departmentEntity . getFullName ( ) ) ;
StringBuilder payEnclosureStr = new StringBuilder ( ) ;
if ( paymentdocMessage . getEnclosure ( ) ! = null ) { //附件不为空
String enclosure = paymentdocMessage . getEnclosure ( ) ;
JSONArray jsonToJsonArray = JsonUtil . getJsonToJsonArray ( enclosure ) ;
for ( int i = 0 ; i < jsonToJsonArray . size ( ) ; i + + ) {
Map o = ( Map ) jsonToJsonArray . get ( i ) ;
Object name = o . get ( "name" ) ;
if ( i = = 0 ) {
payEnclosureStr . append ( name ) ;
} else {
payEnclosureStr . append ( "<br/>" + name ) ;
}
}
paymentdocMessage . setEnclosure ( payEnclosureStr . toString ( ) ) ;
if ( paymentApplicationForm . getPaymentapplicationsettlementList ( ) ! = null & & paymentApplicationForm . getPaymentapplicationsettlementList ( ) . size ( ) > 0 ) {
//entity.set
}
this . saveOrUpdate ( entity ) ;
// StringUtil.indexOf()
// String templateFilePath = configValueUtil.getTemplateFilePath() +"paymentDocPdf//";
Map < String , Object > map = JsonUtil . stringToMap ( JSONUtil . toJsonStr ( paymentdocMessage ) ) ;
map . put ( "substring" , companyEntity . getFullName ( ) ) ;
map . put ( "substring1" , departmentEntity . getFullName ( ) ) ;
// map.put("reportList",paymentDocNodeInfo);
FlowBeforeController bean = SpringContext . getBean ( FlowBeforeController . class ) ;
ActionResult info = null ;
try {
info = bean . info ( id , new FlowModel ( ) ) ;
} catch ( WorkFlowException e ) {
throw new RuntimeException ( e ) ;
}
FlowBeforeInfoVO data = ( FlowBeforeInfoVO ) info . getData ( ) ;
List < FlowTaskOperatorRecordModel > recordList = data . getFlowTaskOperatorRecordList ( ) ;
List < Map < String , Object > > maps = new ArrayList < > ( ) ;
for ( int i = 0 ; i < recordList . size ( ) ; i + + ) {
Map < String , Object > map1 = new HashMap < String , Object > ( ) ;
FlowTaskOperatorRecordModel model = recordList . get ( i ) ;
Map < String , Object > map2 = paymentDocNodeInfo . get ( i ) ;
map1 . put ( "realName" , model . getUserName ( ) ) ;
map1 . put ( "nodeName" , model . getNodeName ( ) ) ;
map1 . put ( "handleOpinion" , model . getHandleOpinion ( ) ) ;
map1 . put ( "handleTime" , DateUtil . daFormat ( model . getHandleTime ( ) ) ) ;
map1 . put ( "node" , map2 . get ( "node" ) ) ;
maps . add ( map1 ) ;
//Paymentapplicationsettlement子表数据新增修改
if ( ! isSave ) {
QueryWrapper < PaymentapplicationsettlementEntity > PaymentapplicationsettlementqueryWrapper = new QueryWrapper < > ( ) ;
PaymentapplicationsettlementqueryWrapper . lambda ( ) . eq ( PaymentapplicationsettlementEntity : : getPaymentApplicationId , entity . getId ( ) ) ;
paymentapplicationsettlementService . remove ( PaymentapplicationsettlementqueryWrapper ) ;
}
ArrayList < Map < String , Object > > maps1 = new ArrayList < Map < String , Object > > ( ) ;
int num = 6 ;
if ( maps . size ( ) > num ) {
for ( int i = 0 ; i < maps . size ( ) ; i + + ) {
Map < String , Object > map1 = maps . get ( i ) ;
if ( i > = num ) {
maps1 . add ( map1 ) ;
if ( paymentApplicationForm . getPaymentapplicationsettlementList ( ) ! = null ) {
List < PaymentapplicationsettlementEntity > tableField113 = JsonUtil . getJsonToList ( paymentApplicationForm . getPaymentapplicationsettlementList ( ) , PaymentapplicationsettlementEntity . class ) ;
for ( PaymentapplicationsettlementEntity entitys : tableField113 ) {
entitys . setId ( RandomUtil . uuId ( ) ) ;
entitys . setPaymentApplicationId ( entity . getId ( ) ) ;
if ( isSave ) {
} else {
}
paymentapplicationsettlementService . saveOrUpdate ( entitys ) ;
}
while ( maps . size ( ) > num ) {
maps . remove ( num ) ;
}
}
map . put ( "reportList" , maps ) ;
map . put ( "reportList1" , maps1 ) ;
byte [ ] bytes = null ;
ByteArrayOutputStream out = null ;
ExportPdf exportPdf = new ExportPdf ( ) ;
// word模板
try {
out = exportPdf . createPdf ( map , "paymentDoc.ftl" , "/templates/export" ) ;
bytes = out . toByteArray ( ) ;
out . close ( ) ;
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
}
String fileName = paymentdocMessage . getCustomerName ( ) = = null ? companyEntity . getFullName ( ) + "请示.pdf" : companyEntity . getFullName ( ) + "请示(" + paymentdocMessage . getCustomerName ( ) + ").pdf" ;
HttpServletResponse response = ServletUtil . getResponse ( ) ;
response . reset ( ) ;
String excelTitle = fileName ;
String filen = null ;
try {
filen = URLEncoder . encode ( excelTitle , "UTF-8" ) . replaceAll ( "\\+" , "%20" ) ;
} catch ( UnsupportedEncodingException e ) {
throw new RuntimeException ( e ) ;
}
// 设置response的Header
response . setHeader ( "Content-disposition" , "attachment;filename*=utf-8''" + filen ) ;
response . setContentType ( "application/x-download;charset=utf-8" ) ;
BufferedOutputStream toClient = null ;
try {
toClient = new BufferedOutputStream ( response . getOutputStream ( ) ) ;
toClient . write ( out . toByteArray ( ) ) ;
toClient . flush ( ) ;
toClient . close ( ) ;
} catch ( IOException e ) {
throw new RuntimeException ( e ) ;
}
log . warn ( "pdf文件生成成功! " ) ;
}
}