Compare commits

...

2 Commits

10 changed files with 393 additions and 9 deletions

View File

@ -0,0 +1,41 @@
package aiyh.utils.recordset;
import aiyh.utils.Util;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import java.lang.reflect.Field;
/**
* <p>float</p>
* <p>create 2022/4/29 2:34 PM</p>
*
* @author ayh
*/
public class DoubleTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "0.0");
return Double.parseDouble(string);
}
@Override
public Object getValue(RecordSet rs, int index, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(index), "0.0");
return Double.parseDouble(string);
}
@Override
public Object getValue(RecordSetTrans rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "0.0");
return Double.parseDouble(string);
}
@Override
public Object getValue(RecordSetTrans rs, int index, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(index), "0.0");
return Double.parseDouble(string);
}
}

View File

@ -42,7 +42,9 @@ public class ResultMapper {
typeHandler.put(boolean.class, new BooleanTypeHandler());
typeHandler.put(Date.class, new DataTypeHandler());
typeHandler.put(Float.class, new FloatTypeHandler());
typeHandler.put(float.class, new FloatTypeHandler());
typeHandler.put(Float.class, new FloatTypeHandler());
typeHandler.put(double.class, new DoubleTypeHandler());
typeHandler.put(Double.class, new DoubleTypeHandler());
}
static {
@ -56,6 +58,8 @@ public class ResultMapper {
paramType.put(boolean.class, Boolean::parseBoolean);
paramType.put(Float.class, Float::parseFloat);
paramType.put(float.class, Float::parseFloat);
paramType.put(double.class, Double::parseDouble);
paramType.put(Double.class, Double::parseDouble);
}
public <T> T mapperResult(RecordSet rs, Method method, Class<T> tClass, RecordsetUtil recordsetUtil) {

View File

@ -33,7 +33,7 @@ public interface DzInvoiceMapper {
* @param fieldValue
* @return
*/
@Update("update APInvoice set check_status = #{checkStatus} where $t{fieldId} = #{fieldValue}")
@Update("update fnaInvoiceLedger set check_status = #{checkStatus} where $t{fieldId} = #{fieldValue}")
boolean updateInvoiceCheckStatus(@ParamMapper("check_status") int checkStatus,
@ParamMapper("fieldId") String fieldId,
@ParamMapper("fieldValue") Object fieldValue);
@ -45,7 +45,7 @@ public interface DzInvoiceMapper {
* @param fieldValue
* @return
*/
@Update("update APInvoice set check_status = #{checkStatus} where $t{fieldId} in ${fieldValue}")
@Update("update fnaInvoiceLedger set check_status = #{checkStatus} where $t{fieldId} in ${fieldValue}")
boolean batchUpdateInvoiceCheckStatus(@ParamMapper("check_status") int checkStatus,
@ParamMapper("fieldId") String fieldId,
@ParamMapper("fieldValue") Object fieldValue);
@ -55,7 +55,7 @@ public interface DzInvoiceMapper {
* <h2></h2>
* @return
*/
@Select("select * from APInvoice where check_status = 2 or check_status = 3")
@Select("select * from fnaInvoiceLedger where (check_status = 2 or check_status = 3) and hxjksflr = 'Y'")
List<Map<String,Object>> queryOnChooseInvoices();
}

View File

@ -0,0 +1,53 @@
package com.api.bokang.xiao.wx_report.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.bokang.xiao.wx_report.service.ReportService;
import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl;
import org.apache.log4j.Logger;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
/**
* @ClassName ReportController
* @Author
* @Date 2023/2/21 12:45
* @Description <h1></h1>
**/
@Path("/xbk/wx_report")
public class ReportController {
private final Logger log = Util.getLogger();
private final ReportService reportService = new ReportServiceImpl();
/**
* <h2></h2>
* @param request
* @param response
* @return
*/
@Path("/getReportData")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getReportData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try{
log.info("====== into getCondition success =======");
User loginUser = HrmUserVarify.getUser(request, response);
return ApiResult.success("");
}catch (Exception e){
log.error("获取搜索组件信息 ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
}

View File

@ -0,0 +1,29 @@
package com.api.bokang.xiao.wx_report.entity;
import lombok.Data;
/**
* @ClassName ReportEntity
* @Author
* @Date 2023/2/26 21:06
* @Description <h1></h1>
**/
@Data
public class ReportEntityVO {
/** 款项类别 */
private String category;
/** 日期 */
private String date;
/** 月份 */
private Integer month;
/** 月份 */
private Integer year;
/** 金额合计 */
private Double amount;
}

View File

@ -0,0 +1,125 @@
package com.api.bokang.xiao.wx_report.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import com.api.bokang.xiao.wx_report.entity.ReportEntityVO;
import java.util.List;
import java.util.Map;
/**
* @ClassName ReportMapper
* @Author
* @Date 2023/2/26 21:04
* @Description <h1></h1>
**/
@SqlMapper
public interface ReportMapper {
/**
* <h2></h2>
* @param queryStr sql
* @param param
* @return
*/
@Select("select 90 category,sqrq date,sum(jkjey) amount,month(sqrq) month,year(sqrq) year,day(sqrq) day " +
"from uf_byjjksqtzbb " +
"where 1=1 $t{queryStr} " +
"group by sqrq " +
"union all " +
"select kxlb category,main.qwfkrq date,sum(fkjey) amount,month(main.qwfkrq) month,year(main.qwfkrq) year,day(main.qwfkrq) day " +
"from uf_dgfksqtzbb main " +
"inner join uf_dgfksqtzbb_dt1 dt on main.id = dt.mainid " +
"where kxlb is not null $t{queryStr}" +
"group by dt.kxlb,main.qwfkrq " +
"union all " +
"select kxlb category,main.sqrq date,sum(bxjey) amount,month(main.sqrq) month,year(main.sqrq) year,day(main.sqrq) day " +
"from uf_dsbxsqtzbb main " +
"inner join uf_dsbxsqtzbb_dt1 dt on main.id = dt.mainid " +
"where kxlb is not null $t{queryStr}" +
"group by dt.kxlb,main.sqrq " +
"union all " +
"select kxlb category,main.sqrq date,sum(bxjey) amount,month(main.sqrq) month,year(main.sqrq) year,day(main.sqrq) day " +
"from uf_dsbxsqtzclbb main " +
"inner join uf_dsbxsqtzclbb_dt1 dt on main.id = dt.mainid " +
"where kxlb is not null $t{queryStr}" +
"group by dt.kxlb,main.sqrq " +
"union all " +
"select kxlb category,rq date,sum(hsjey) amount,month(rq) month,year(rq) year,day(rq) day " +
"from uf_srmxb " +
"where kxlb is not null " +
"group by kxlb,rq " +
"order by category ")
List<ReportEntityVO> queryReportList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
/**
* <h2></h2>
* @param queryStr sql
* @param param
* @return
*/
@Select("select kxlb category,rq date,sum(hsjey) amount,month(rq) month,year(rq) year,day(rq) day " +
"from uf_srmxb " +
"where kxlb is not null $t{queryStr}" +
"group by kxlb,rq " +
"order by category ")
List<ReportEntityVO> queryDataInList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
/**
* <h2></h2>
* @param queryStr sql
* @param param
* @return
*/
@Select("select 90 category,sqrq date,sum(jkjey) amount,month(sqrq) month,year(sqrq) year,day(sqrq) day " +
"from uf_byjjksqtzbb " +
"where 1=1 $t{queryStr} " +
"group by sqrq ")
List<ReportEntityVO> queryPettyCashList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
/**
* <h2></h2>
* @param queryStr sql
* @param param
* @return
*/
@Select("select kxlb category,main.qwfkrq date,sum(fkjey) amount,month(main.qwfkrq) month,year(main.qwfkrq) year,day(main.qwfkrq) day " +
"from uf_dgfksqtzbb main " +
"inner join uf_dgfksqtzbb_dt1 dt on main.id = dt.mainid " +
"where kxlb is not null $t{queryStr}" +
"group by dt.kxlb,main.qwfkrq " +
"order by category ")
List<ReportEntityVO> queryPublicPayList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
/**
* <h2></h2>
* @param queryStr sql
* @param param
* @return
*/
@Select("select kxlb category,main.sqrq date,sum(bxjey) amount,month(main.sqrq) month,year(main.sqrq) year,day(main.sqrq) day " +
"from uf_dsbxsqtzbb main " +
"inner join uf_dsbxsqtzbb_dt1 dt on main.id = dt.mainid " +
"where kxlb is not null $t{queryStr}" +
"group by dt.kxlb,main.sqrq " +
"order by category ")
List<ReportEntityVO> queryPrivatePayList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
/**
* <h2></h2>
* @param queryStr sql
* @param param
* @return
*/
@Select("select kxlb category,main.sqrq date,sum(bxjey) amount,month(main.sqrq) month,year(main.sqrq) year,day(main.sqrq) day " +
"from uf_dsbxsqtzclbb main " +
"inner join uf_dsbxsqtzclbb_dt1 dt on main.id = dt.mainid " +
"where kxlb is not null $t{queryStr}" +
"group by dt.kxlb,main.sqrq " +
"order by category ")
List<ReportEntityVO> queryBusinessList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
}

View File

@ -0,0 +1,10 @@
package com.api.bokang.xiao.wx_report.service;
/**
* @ClassName ReportService
* @Author
* @Date 2023/2/21 12:38
* @Description <h1></h1>
**/
public interface ReportService {
}

View File

@ -0,0 +1,12 @@
package com.api.bokang.xiao.wx_report.service.impl;
import com.api.bokang.xiao.wx_report.service.ReportService;
/**
* @ClassName ReportServiceImpl
* @Author
* @Date 2023/2/21 12:38
* @Description <h1></h1>
**/
public class ReportServiceImpl implements ReportService {
}

View File

@ -2,11 +2,16 @@ package weaver.xiao.commons.utils;
import aiyh.utils.excention.CustomerException;
import org.apache.log4j.Logger;
import org.apache.poi.ooxml.POIXMLDocument;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import weaver.docs.docs.DocImageManager;
import weaver.docs.webservices.DocInfo;
import weaver.docs.webservices.DocServiceImpl;
import weaver.file.ImageFileManager;
import weaver.general.IOUtils;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.xiao.commons.config.entity.WeaverFile;
@ -14,8 +19,7 @@ import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.List;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
@ -289,4 +293,57 @@ public class DocImageFileUtil {
}
}
/**
* <h2>word</h2>
* @param replaceMap
* @param docSourcePath
* @return
*/
public static String replaceDocument(Map<String, Object> replaceMap, String docSourcePath) {
String sourcePath = docSourcePath.substring(0,docSourcePath.lastIndexOf(File.separator));
String fileType = docSourcePath.substring(docSourcePath.lastIndexOf("."));
String targetFileName = sourcePath + File.separator + UUID.randomUUID().toString().replace("-","") + fileType;
DocImageFileUtil.replaceDocument(replaceMap,docSourcePath,targetFileName);
return targetFileName;
}
/**
* <h2>word</h2>
* @param replaceMap
* @param docSourcePath
* @param targetPath
*/
public static void replaceDocument(Map<String, Object> replaceMap, String docSourcePath, String targetPath) {
XWPFDocument document = null;
try {
document = new XWPFDocument(POIXMLDocument.openPackage(docSourcePath));
} catch (IOException e) {
logger.error("模板文件位置错误:" + LogUtil.getExceptionStr(e));
throw new RuntimeException("模板文件位置错误:" + docSourcePath);
}
Iterator<XWPFParagraph> itPara = document.getParagraphsIterator();
while (itPara.hasNext()) {
XWPFParagraph paragraph = itPara.next();
List<XWPFRun> runs = paragraph.getRuns();
for (XWPFRun run : runs) {
String currentString = run.getText(run.getTextPosition()).trim();
for (Map.Entry<String, Object> entry : replaceMap.entrySet()) {
if (currentString.equals(entry.getKey())) {
currentString = currentString.replace(entry.getKey(), Util.null2String(entry.getValue()));
}
}
run.setText(currentString, 0);
}
}
try {
FileOutputStream outStream = null;
outStream = new FileOutputStream(targetPath);
document.write(outStream);
outStream.close();
} catch (IOException e) {
logger.error("写入文件位置错误:" + LogUtil.getExceptionStr(e));
throw new RuntimeException("写入文件位置错误:" + docSourcePath);
}
}
}

View File

@ -8,12 +8,24 @@ import basetest.BaseTest;
import bokang.xiao.mapper.TestMapper;
import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper;
import com.api.bokang.xiao.porsche_review.service.impl.ReviewServiceImpl;
import com.api.bokang.xiao.wx_report.entity.ReportEntityVO;
import com.api.bokang.xiao.wx_report.mapper.ReportMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.poi.POIXMLDocument;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.junit.Test;
import weaver.bokang.xiao.dz_invoice.action.InvoiceDeductionAction;
import weaver.bokang.xiao.dz_invoice.schedule.InvoiceQuerySchedule;
import weaver.xiao.commons.config.entity.ResponseMapping;
import weaver.xiao.commons.utils.DocImageFileUtil;
import java.io.IOException;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
@ -27,8 +39,8 @@ public class NormalTest extends BaseTest {
@Test
public void testWord(){
GenerateFileUtil.createActionDocument(InvoiceDeductionAction.class);
GenerateFileUtil.createCronJobDocument(InvoiceQuerySchedule.class);
//GenerateFileUtil.createActionDocument(InvoiceDeductionAction.class);
//GenerateFileUtil.createCronJobDocument(InvoiceQuerySchedule.class);
}
@Test
@ -50,8 +62,49 @@ public class NormalTest extends BaseTest {
}
@Test
public void testReport(){
ReportMapper mapper = Util.getMapper(ReportMapper.class);
Map<String,Object> queryParam = new HashMap<>();
queryParam.put("month","12");
queryParam.put("year","2022");
StringBuilder PettyCashBuilder = new StringBuilder();
StringBuilder PublicPayBuilder = new StringBuilder();
StringBuilder PrivatePayBuilder = new StringBuilder();
StringBuilder BusinessBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
String month = Util.null2String(queryParam.get("month"));
String year = Util.null2String(queryParam.get("year"));
String date = Util.null2String(queryParam.get("date"));
String company = Util.null2String(queryParam.get("company"));
String depart = Util.null2String(queryParam.get("depart"));
if(StringUtils.isNotBlank(month)){
}
List<ReportEntityVO> reportEntityVOS = mapper.queryReportList(whereBuilder.toString(),queryParam);
Map<String, List<ReportEntityVO>> groupMap = reportEntityVOS.stream().collect(Collectors.groupingBy(ReportEntityVO::getCategory));
System.out.println(groupMap);
}
@Test
public void testPdf() throws IOException {
Map<String, Object> map = new HashMap<>();
map.put("$name", "1231");
String s = DocImageFileUtil.replaceDocument(map, "E:\\test\\test.docx");
System.out.println(s);
new Thread(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
DocImageFileUtil.deleteTempFile(s);
}).start();
}
@Test
public void testRequest() throws IOException {
HttpUtils httpUtils = new HttpUtils();
Map<String,Object> param = new HashMap<>();
param.put("grant_type","client_credentials");