Commit 0ebd6219 authored by eddie.woo's avatar eddie.woo

modify

parent 8effdfec
......@@ -518,7 +518,8 @@ public class ReportGeneratorImpl {
public void addFunctionsAndContext(Workbook workbook, String[] functions, FormulaContext formulaContext) {
FreeRefFunction[] functionImpls = {new SGSR(formulaContext), new FSJZ(formulaContext), new ND(formulaContext),
new BB(formulaContext), new XXFP(formulaContext), new GZSD(formulaContext), new ProjectContext(formulaContext)
, new JXFPMX(formulaContext), new JXFP(formulaContext), new PSUM(formulaContext) ,new DFFS(formulaContext)};
, new JXFPMX(formulaContext), new JXFP(formulaContext), new PSUM(formulaContext), new DFFS(formulaContext),
new WPSR(formulaContext)};
UDFFinder udfs = new DefaultUDFFinder(functions, functionImpls);
UDFFinder udfToolpack = new AggregatingUDFFinder(udfs);
workbook.addToolPack(udfToolpack);
......
......@@ -50,7 +50,8 @@ import static pwc.taxtech.atms.dto.vatdto.WrapPeriodJobDto.*;
public class ReportServiceImpl {
private final static Logger logger = LoggerFactory.getLogger(ReportServiceImpl.class);
private BlockingQueue<PeriodJob> queue = new LinkedBlockingQueue<>();
private final static String[] functions = {"SGSR", "FSJZ", "ND", "BB", "XXFP", "GZSD", "ProjectContext", "JXFPMX", "JXFP","PSUM","DFFS"};
private final static String[] functions = {"SGSR", "FSJZ", "ND", "BB", "XXFP", "GZSD", "ProjectContext", "JXFPMX",
"JXFP", "PSUM", "DFFS", "WPSR"};
@Autowired
private ReportGeneratorImpl reportGenerator;
......
......@@ -104,6 +104,14 @@ public class FunctionBase {
public Long saveDataSource(OperationEvaluationContext ec, List<Object> dataSourceList,
FormulaDataSourceDetailType formulaDataSourceDetailType, BigDecimal val,
int period, Long templateGroupId, Integer colNumP, Integer rowNumP, String projectId) {
return saveDataSource(ec, dataSourceList, FormulaDataSourceType.Report, formulaDataSourceDetailType, val, period,
templateGroupId, colNumP, rowNumP, projectId);
}
public Long saveDataSource(OperationEvaluationContext ec, List<Object> dataSourceList, FormulaDataSourceType dataSourceType,
FormulaDataSourceDetailType formulaDataSourceDetailType, BigDecimal val,
int period, Long templateGroupId, Integer colNumP, Integer rowNumP, String projectId) {
String reportCode = ec.getWorkbook().getSheetName(ec.getSheetIndex());
int colNum = ec.getColumnIndex();
int rowNum = ec.getRowIndex();
......@@ -121,7 +129,7 @@ public class FunctionBase {
PeriodDataSource dataSource = new PeriodDataSource();
Long dataSourceId = SpringContextUtil.distributedIdService.nextId();
dataSource.setId(dataSourceId);
dataSource.setType(FormulaDataSourceType.Report.getCode());
dataSource.setType(dataSourceType.getCode());
dataSource.setName("ReportDataSource");
dataSource.setAmount(val.setScale(0, BigDecimal.ROUND_HALF_DOWN));
dataSource.setDescription("描述");
......
package pwc.taxtech.atms.vat.service.impl.report.functions;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.entity.Organization;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.vat.dao.HlOutputInterfaceLineMapper;
import pwc.taxtech.atms.vat.dao.HlOutputOrderKpsqmxbMapper;
import pwc.taxtech.atms.vat.dao.HlOutputOrderKpsqzbMapper;
import pwc.taxtech.atms.vat.entity.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
public class WPSR extends FunctionBase implements FreeRefFunction {
private static final ValueEval ZERO_EVAL = new StringEval("0");
private HlOutputInterfaceLineMapper interfaceLineMapper;
private HlOutputOrderKpsqmxbMapper kpsqmxbMapper;
private HlOutputOrderKpsqzbMapper zbMapper;
public WPSR(FormulaContext formulaContext) {
super(formulaContext);
this.interfaceLineMapper = SpringContextUtil.getBean(HlOutputInterfaceLineMapper.class);
this.kpsqmxbMapper = SpringContextUtil.getBean(HlOutputOrderKpsqmxbMapper.class);
this.zbMapper = SpringContextUtil.getBean(HlOutputOrderKpsqzbMapper.class);
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length != 2) {
return ZERO_EVAL;
}
Integer type = getIntParam(args[0], ec);
Integer rate = getIntParam(args[1], ec);
String rateStr = String.valueOf(rate / 100);
if (null == type || null == rate) {
return ZERO_EVAL;
}
ValueEval result = ZERO_EVAL;
try {
int period = formulaContext.getPeriod();
int year = formulaContext.getYear();
Project project = SpringContextUtil.projectMapper.selectByPrimaryKey(formulaContext.getProjectId());
Organization organization = SpringContextUtil.organizationMapper.selectByPrimaryKey(project.getOrganizationId());
String periodStart = DateUtils.getPeriodBeginFormat(project.getYear(), period);
String periodEnd = DateUtils.getPeriodEndFormat(project.getYear(), period);
if (1 == type) {
//未开票收入
HlOutputInterfaceLineExample lineExample = new HlOutputInterfaceLineExample();
lineExample.createCriteria().andSjfyrqBetween(periodStart, periodEnd).andSfkpNotEqualTo("1")
.andEbsSrbjEqualTo("1").andYwstidEqualTo(organization.getCode()); //排除 状态1:已开票,即未开票和预开票
List<HlOutputInterfaceLine> lineList = interfaceLineMapper.selectByExample(lineExample); //todo 无订单业务
if (!CollectionUtils.isEmpty(lineList)) {
result = new StringEval(getSum(lineList, rateStr).toPlainString());
}
} else if (2 == type) {
//跨月开票
HlOutputInterfaceLineExample lineExample = new HlOutputInterfaceLineExample();
lineExample.createCriteria().andSjfyrqNotBetween(periodStart, periodEnd).andKprqBetween(periodStart, periodEnd)
.andSfkpEqualTo("1").andEbsSrbjEqualTo("1").andYwstidEqualTo(organization.getCode());
List<HlOutputInterfaceLine> lineList = interfaceLineMapper.selectByExample(lineExample);
if (!CollectionUtils.isEmpty(lineList)) {
result = new StringEval(getSum(lineList, rateStr).toPlainString());
}
}
} catch (Exception e) {
logger.error("evaluate WPSR error.", e);
}
return result;
}
/**
* 接口行数据 -> 发票明细 求不含税金额总和
*
* @param lineList List<HlOutputInterfaceLine>
* @param rateStr eg:0.16
* @return BigDecimal
*/
private BigDecimal getSum(List<HlOutputInterfaceLine> lineList, String rateStr) {
List<String> idList = lineList.stream().map(HlOutputInterfaceLine::getUuid).collect(Collectors.toList());
HlOutputOrderKpsqmxbExample mxbExample = new HlOutputOrderKpsqmxbExample();
mxbExample.createCriteria().andIdIn(idList);
List<String> sqList = kpsqmxbMapper.selectByExample(mxbExample).stream().map(HlOutputOrderKpsqmxb::getSquuid)
.collect(Collectors.toList());
HlOutputOrderKpsqzbExample zbExample = new HlOutputOrderKpsqzbExample();
zbExample.createCriteria().andSquuidIn(sqList);
List<String> sqbhList = zbMapper.selectByExample(zbExample).stream().map(HlOutputOrderKpsqzb::getSqbh)
.collect(Collectors.toList());
OutputInvoiceExample outputInvoiceExample = new OutputInvoiceExample();
outputInvoiceExample.createCriteria().andSQBHIn(sqbhList);
List<String> lshList = SpringContextUtil.outputInvoiceMapper.selectByExample(outputInvoiceExample).stream()
.map(OutputInvoice::getFPQQLSH).collect(Collectors.toList());
OutputInvoiceDetailExample detailExample = new OutputInvoiceDetailExample();
detailExample.createCriteria().andFPQQLSHIn(lshList).andSLVEqualTo(rateStr);
return SpringContextUtil.outputInvoiceDetailMapper.selectByExample(detailExample).stream()
.map(o -> NumberUtils.createBigDecimal(o.getJE())).reduce(BigDecimal.ZERO, BigDecimal::add);
}
}
......@@ -234,11 +234,24 @@
<!--<columnOverride column="PERIOD" javaType="java.lang.Integer" />-->
<!--</table>-->
<table tableName="GL_BALANCE" schema="tax_admin_longi" domainObjectName="GlBalance">
<!--<table tableName="GL_BALANCE" schema="tax_admin_longi" domainObjectName="GlBalance">-->
<!--<property name="useActualColumnNames" value="false"/>-->
<!--<property name="ignoreQualifiersAtRuntime" value="true"/>-->
<!--<columnOverride column="ID" javaType="java.lang.Long" />-->
<!--</table>-->
<table tableName="OUTPUT_INTERFACE_LINE" schema="pwc_invoice" domainObjectName="HlOutputInterfaceLine">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
<columnOverride column="ID" javaType="java.lang.Long" />
</table>
<table tableName="OUTPUT_ORDER_KPSQMXB" schema="pwc_invoice" domainObjectName="HlOutputOrderKpsqmxb">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
<table tableName="OUTPUT_ORDER_KPSQZB" schema="pwc_invoice" domainObjectName="HlOutputOrderKpsqzb">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
package pwc.taxtech.atms.vat.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.HlOutputInterfaceLine;
import pwc.taxtech.atms.vat.entity.HlOutputInterfaceLineExample;
@Mapper
public interface HlOutputInterfaceLineMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_INTERFACE_LINE
*
* @mbg.generated
*/
long countByExample(HlOutputInterfaceLineExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_INTERFACE_LINE
*
* @mbg.generated
*/
int deleteByExample(HlOutputInterfaceLineExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_INTERFACE_LINE
*
* @mbg.generated
*/
int insert(HlOutputInterfaceLine record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_INTERFACE_LINE
*
* @mbg.generated
*/
int insertSelective(HlOutputInterfaceLine record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_INTERFACE_LINE
*
* @mbg.generated
*/
List<HlOutputInterfaceLine> selectByExample(HlOutputInterfaceLineExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_INTERFACE_LINE
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") HlOutputInterfaceLine record, @Param("example") HlOutputInterfaceLineExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_INTERFACE_LINE
*
* @mbg.generated
*/
int updateByExample(@Param("record") HlOutputInterfaceLine record, @Param("example") HlOutputInterfaceLineExample example);
}
\ No newline at end of file
package pwc.taxtech.atms.vat.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.HlOutputOrderKpsqmxb;
import pwc.taxtech.atms.vat.entity.HlOutputOrderKpsqmxbExample;
@Mapper
public interface HlOutputOrderKpsqmxbMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
long countByExample(HlOutputOrderKpsqmxbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
int deleteByExample(HlOutputOrderKpsqmxbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
int deleteByPrimaryKey(String uuid);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
int insert(HlOutputOrderKpsqmxb record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
int insertSelective(HlOutputOrderKpsqmxb record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
List<HlOutputOrderKpsqmxb> selectByExample(HlOutputOrderKpsqmxbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
HlOutputOrderKpsqmxb selectByPrimaryKey(String uuid);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") HlOutputOrderKpsqmxb record, @Param("example") HlOutputOrderKpsqmxbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
int updateByExample(@Param("record") HlOutputOrderKpsqmxb record, @Param("example") HlOutputOrderKpsqmxbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(HlOutputOrderKpsqmxb record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQMXB
*
* @mbg.generated
*/
int updateByPrimaryKey(HlOutputOrderKpsqmxb record);
}
\ No newline at end of file
package pwc.taxtech.atms.vat.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.HlOutputOrderKpsqzb;
import pwc.taxtech.atms.vat.entity.HlOutputOrderKpsqzbExample;
@Mapper
public interface HlOutputOrderKpsqzbMapper extends MyVatMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
long countByExample(HlOutputOrderKpsqzbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
int deleteByExample(HlOutputOrderKpsqzbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
int deleteByPrimaryKey(String squuid);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
int insert(HlOutputOrderKpsqzb record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
int insertSelective(HlOutputOrderKpsqzb record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
List<HlOutputOrderKpsqzb> selectByExample(HlOutputOrderKpsqzbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
HlOutputOrderKpsqzb selectByPrimaryKey(String squuid);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") HlOutputOrderKpsqzb record, @Param("example") HlOutputOrderKpsqzbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
int updateByExample(@Param("record") HlOutputOrderKpsqzb record, @Param("example") HlOutputOrderKpsqzbExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(HlOutputOrderKpsqzb record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table PWC_INVOICE.OUTPUT_ORDER_KPSQZB
*
* @mbg.generated
*/
int updateByPrimaryKey(HlOutputOrderKpsqzb record);
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment