|
|
@@ -12,7 +12,9 @@ import com.goafanti.common.enums.NoticeTypes;
|
|
|
import com.goafanti.common.error.BusinessException;
|
|
|
import com.goafanti.common.model.*;
|
|
|
import com.goafanti.common.utils.*;
|
|
|
+import com.goafanti.common.utils.excel.FileUtils;
|
|
|
import com.goafanti.common.utils.excel.NewExcelUtil;
|
|
|
+import com.goafanti.common.utils.pdf.PDFUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.JDBCIdGenerator;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
@@ -23,13 +25,25 @@ import com.goafanti.expenseAccount.Enums.EAsecondaryTypes;
|
|
|
import com.goafanti.expenseAccount.bo.*;
|
|
|
import com.goafanti.expenseAccount.service.ExpenseAccountService;
|
|
|
import com.goafanti.organization.bo.OrganizationListOut;
|
|
|
+import com.itextpdf.text.Document;
|
|
|
+import com.itextpdf.text.DocumentException;
|
|
|
+import com.itextpdf.text.Paragraph;
|
|
|
+import com.itextpdf.text.Phrase;
|
|
|
+import com.itextpdf.text.pdf.PdfPCell;
|
|
|
+import com.itextpdf.text.pdf.PdfPRow;
|
|
|
+import com.itextpdf.text.pdf.PdfPTable;
|
|
|
+import com.itextpdf.text.pdf.PdfWriter;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -391,13 +405,22 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
|
|
|
public Object updateTypeOther(Integer id, String typeOther,String remarks,String orderNo) {
|
|
|
ExpenseAccount ea = new ExpenseAccount();
|
|
|
ea.setId(id);
|
|
|
- if (StringUtils.isNotEmpty(typeOther))ea.setTypeOther(typeOther);
|
|
|
- if (StringUtils.isNotEmpty(remarks))ea.setRemarks(remarks);
|
|
|
- if (StringUtils.isNotEmpty(orderNo)){
|
|
|
+ if (StringUtils.isNotEmpty(typeOther)){
|
|
|
+ ea.setTypeOther(typeOther);
|
|
|
+ expenseAccountMapper.updateByPrimaryKeySelective(ea);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(remarks)){
|
|
|
+ ea.setRemarks(remarks);
|
|
|
+ expenseAccountMapper.updateByPrimaryKeySelective(ea);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(orderNo)){
|
|
|
+ ea.setTargetType(0);
|
|
|
+ expenseAccountMapper.updateRemoveOrderNo(ea);
|
|
|
+ }else {
|
|
|
ea.setOrderNo(orderNo);
|
|
|
ea.setTargetType(1);
|
|
|
+ expenseAccountMapper.updateByPrimaryKeySelective(ea);
|
|
|
}
|
|
|
- expenseAccountMapper.updateByPrimaryKeySelective(ea);
|
|
|
if (StringUtils.isNotEmpty(typeOther)){
|
|
|
MainExpenseAccount mainExpenseAccount = expenseAccountMapper.selectbySonId(id);
|
|
|
StringBuffer types=new StringBuffer();
|
|
|
@@ -430,6 +453,196 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
|
|
|
return expenseAccountDetailsMapper.updateByPrimaryKeySelective(in);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Object mainExpenseExport(Integer id, HttpServletResponse response) {
|
|
|
+ MainExpenseAccount mainExpenseAccount = mainExpense(id);
|
|
|
+ pushMainExpenseExport(mainExpenseAccount,response,uploadPath);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void pushMainExpenseExport(MainExpenseAccount mainExpenseAccount,HttpServletResponse response, String uploadPath) {
|
|
|
+ String title = "报销明细表";
|
|
|
+ String attName = String.format("报销明细表_%s.pdf",new Date().getTime());
|
|
|
+ String realFileName = uploadPath+"/tmp/"+new Date().getTime() + ".pdf";
|
|
|
+
|
|
|
+ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
+ Document document=new Document();
|
|
|
+ try {
|
|
|
+ FileUtils.setAttachmentResponseHeader(response, title,attName);
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(realFileName);
|
|
|
+ PdfWriter.getInstance(document, outputStream);
|
|
|
+ document.open();
|
|
|
+ Paragraph paragraph = new Paragraph(title, PDFUtils.getTitleFont());
|
|
|
+ paragraph.setAlignment(1);
|
|
|
+ document.add(paragraph);
|
|
|
+ //默认算60
|
|
|
+ PDFUtils.pushExpenseTitle(document,mainExpenseAccount);
|
|
|
+ PdfPTable table = new PdfPTable(12);
|
|
|
+ table.setWidthPercentage(100);
|
|
|
+ ArrayList<PdfPRow> rows = table.getRows();
|
|
|
+ float[] columnWidths ={12,24,14,50,50,42,28,18,12,12,50,50};
|
|
|
+ table.setWidths(columnWidths);
|
|
|
+ table.setSpacingBefore(10f);
|
|
|
+ table.setSpacingAfter(10f);
|
|
|
+ //填充表格头部
|
|
|
+ addTitle(rows);
|
|
|
+ //获取填充数据
|
|
|
+ List<Map<Integer,String>> mapList = pushMainExpenseAccount(mainExpenseAccount);
|
|
|
+ //填充数据写入表格
|
|
|
+ pushTable(rows,mapList);
|
|
|
+ document.add(table);
|
|
|
+ document.close();
|
|
|
+ outputStream.close();
|
|
|
+// FileUtils.writeBytes(realFileName, response.getOutputStream());
|
|
|
+// FileUtils.deleteFile(realFileName);
|
|
|
+ } catch (DocumentException | IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void addTitle(ArrayList<PdfPRow> rows) {
|
|
|
+ PdfPCell[] cells =new PdfPCell[12];
|
|
|
+ PdfPRow row=new PdfPRow(cells);
|
|
|
+ cells[0] = new PdfPCell(new Phrase("序号",PDFUtils.getFont(8)));
|
|
|
+ cells[1] = new PdfPCell(new Phrase("费用时间",PDFUtils.getFont(8)));
|
|
|
+ cells[2] = new PdfPCell(new Phrase("时长",PDFUtils.getFont(8)));
|
|
|
+ cells[3] = new PdfPCell(new Phrase("出差地址",PDFUtils.getFont(8)));
|
|
|
+ cells[4] = new PdfPCell(new Phrase("出差企业",PDFUtils.getFont(8)));
|
|
|
+ cells[5] = new PdfPCell(new Phrase("合同编号",PDFUtils.getFont(8)));
|
|
|
+ cells[6] = new PdfPCell(new Phrase("类型",PDFUtils.getFont(8)));
|
|
|
+ cells[7] = new PdfPCell(new Phrase("详情",PDFUtils.getFont(8)));
|
|
|
+ cells[8] = new PdfPCell(new Phrase("费用",PDFUtils.getFont(8)));
|
|
|
+ cells[9] = new PdfPCell(new Phrase("实报",PDFUtils.getFont(8)));
|
|
|
+ cells[10] = new PdfPCell(new Phrase("出差事由",PDFUtils.getFont(8)));
|
|
|
+ cells[11] = new PdfPCell(new Phrase("报销订单/部门",PDFUtils.getFont(8)));
|
|
|
+ rows.add(row);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pushTable(ArrayList<PdfPRow> rows, List<Map<Integer, String>> mapList) {
|
|
|
+ for (Map<Integer, String> map : mapList) {
|
|
|
+ PdfPCell[] cells =new PdfPCell[12];
|
|
|
+ PdfPRow row=new PdfPRow(cells);
|
|
|
+ for (int i = 0; i < 12; i++) {
|
|
|
+ cells[i] = new PdfPCell(new Phrase(map.get(i),PDFUtils.getFont(8)));
|
|
|
+ }
|
|
|
+ rows.add(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<Integer, String>> pushMainExpenseAccount(MainExpenseAccount mainExpenseAccount) {
|
|
|
+ List<Map<Integer,String>> mapList = new ArrayList<>();
|
|
|
+ if (mainExpenseAccount.getSonList()!=null){
|
|
|
+ int index=0;
|
|
|
+ for (SonExpenseAccount e : mainExpenseAccount.getSonList()) {
|
|
|
+ List<SonExpenseAccountDetails> detList = e.getDetList();
|
|
|
+ //详情计算,详情完成后需要一个统计
|
|
|
+ int detIndex = 0;
|
|
|
+ for (SonExpenseAccountDetails det : detList) {
|
|
|
+ index++;
|
|
|
+ detIndex++;
|
|
|
+ Map<Integer, String> map = new HashMap<>();
|
|
|
+ map.put(0, String.valueOf(index));
|
|
|
+ if (detIndex==1){
|
|
|
+ if (e.getPublicReleaseType()!=null){
|
|
|
+ map.put(1,DateUtils.formatDate(e.getReleaseStart(),AFTConstants.YYYYMMDDHHMM)+"~"+DateUtils.formatDate(e.getReleaseEnd(),AFTConstants.YYYYMMDDHHMM));
|
|
|
+ map.put(2,e.getDuration());
|
|
|
+ map.put(3,e.getDistrictName());
|
|
|
+ map.put(4,e.getUserNames());
|
|
|
+ map.put(6,getExpenseType(e));
|
|
|
+ }else {
|
|
|
+ map.put(1,det.getAgreeTime());
|
|
|
+ map.put(2,"");
|
|
|
+ map.put(3,"");
|
|
|
+ map.put(4,"");
|
|
|
+ map.put(6,"");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ map.put(1,det.getAgreeTime());
|
|
|
+ map.put(2,"");
|
|
|
+ map.put(3,"");
|
|
|
+ map.put(4,"");
|
|
|
+ map.put(6,"");
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put(5,e.getContractNo());
|
|
|
+ map.put(7,getExpenseSecondaryType(e,det));
|
|
|
+ map.put(8,getBigDecimalZeros(det.getAmount()));
|
|
|
+ map.put(9,getBigDecimalZeros(det.getRealAmount()));
|
|
|
+ map.put(10,e.getPlan());
|
|
|
+ if (index==1){
|
|
|
+ map.put(11,getOrderNoAndDepartment(e,mainExpenseAccount.getApplyDepName()));
|
|
|
+ }else {
|
|
|
+ map.put(11,"");
|
|
|
+ }
|
|
|
+ mapList.add(map);
|
|
|
+ if (detIndex==detList.size()){
|
|
|
+ index++;
|
|
|
+ addCount(e.getAmount(),e.getRealAmount(),mapList,index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //循环结束新增合计
|
|
|
+ index++;
|
|
|
+ addCount(mainExpenseAccount.getAmount(),mainExpenseAccount.getRealAmount(),mapList,index,1);
|
|
|
+ }
|
|
|
+ return mapList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getBigDecimalZeros(BigDecimal amount) {
|
|
|
+ return amount.stripTrailingZeros().toEngineeringString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addCount(BigDecimal amount,BigDecimal realAmount,List<Map<Integer, String>> mapList,int index) {
|
|
|
+ addCount(amount,realAmount,mapList,index,0);
|
|
|
+ }
|
|
|
+ private void addCount(BigDecimal amount,BigDecimal realAmount,List<Map<Integer, String>> mapList,int index,int type) {
|
|
|
+ String str="小计";
|
|
|
+ if (type==1)str="合计";
|
|
|
+ Map<Integer, String> map = new HashMap<>();
|
|
|
+ for (int i = 0; i < 12; i++){
|
|
|
+ if (i==0){
|
|
|
+ map.put(i, String.valueOf(index));
|
|
|
+ }else if (i==7){
|
|
|
+ map.put(i, str);
|
|
|
+ }else if (i==8){
|
|
|
+ map.put(i, getBigDecimalZeros(amount));
|
|
|
+ }else if (i==9){
|
|
|
+ map.put(i, getBigDecimalZeros(realAmount));
|
|
|
+ }else {
|
|
|
+ map.put(i, "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private String getOrderNoAndDepartment(SonExpenseAccount e,String applyDepName) {
|
|
|
+ return e.getOrderNo()+"\n"+applyDepName;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getExpenseSecondaryType(SonExpenseAccount e,SonExpenseAccountDetails det) {
|
|
|
+ if (e.getType()==1){
|
|
|
+ if (det.getType()==1){
|
|
|
+ //交通工具待完善
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (e.getSecondaryType()==0){
|
|
|
+ return EAsecondaryTypes.getDescByCode(e.getSecondaryType())+"("+e.getSecondaryTypeOther()+")";
|
|
|
+ }
|
|
|
+ return EAsecondaryTypes.getDescByCode(e.getSecondaryType());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private String getExpenseType(SonExpenseAccount e) {
|
|
|
+ if (e.getType()==0){
|
|
|
+ return EATypes.getDescByCode(e.getType())+"("+e.getTypeOther()+")";
|
|
|
+ }
|
|
|
+ return EATypes.getDescByCode(e.getType());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
private void pushResettingDebit(InputExpenseAccount in, Integer debitId) {
|
|
|
ExpenseAccount debit = expenseAccountMapper.selectByPrimaryKey(debitId);
|
|
|
@@ -1323,17 +1536,24 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
|
|
|
if (in.getStartTime()!=null)params.put("startTime",in.getStartTime());
|
|
|
if (in.getEndTime()!=null)params.put("endTime",in.getEndTime());
|
|
|
if (in.getCheckNo()!=null)params.put("checkNo",in.getCheckNo());
|
|
|
+ params.put("current",TokenManager.getAdminId());
|
|
|
+ if (in.getMyType()!=null){
|
|
|
+ params.put("myType",in.getMyType());
|
|
|
+ }else {
|
|
|
+ params.put("myType",0);
|
|
|
+ }
|
|
|
//0=自己 1=财务 2=财务经理 3=超管
|
|
|
if (TokenManager.hasRole(AFTConstants.SUPERADMIN)||TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)){
|
|
|
params.put("roleType",3);
|
|
|
}else if (TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)){
|
|
|
params.put("roleType",2);
|
|
|
- params.put("current",TokenManager.getAdminId());
|
|
|
+
|
|
|
}else if (TokenManager.hasRole(AFTConstants.FINANCE)){
|
|
|
params.put("roleType",1);
|
|
|
params.put("current",TokenManager.getAdminId());
|
|
|
}else{
|
|
|
params.put("roleType",0);
|
|
|
+ params.put("aid",TokenManager.getAdminId());
|
|
|
}
|
|
|
return findPagePlus("ExpenseDetailsList","ExpenseDetailsCount","ExpenseDetailsTotalAmount",params,in.getPageNo(),in.getPageSize());
|
|
|
}
|
|
|
@@ -1430,33 +1650,37 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
|
|
|
}
|
|
|
if (in.getStatus()!=null)param.put("status",in.getStatus());
|
|
|
//如果前端未传 0自己 1审核的参数,默认自己,在审核列表的时候判断Aid,在
|
|
|
- if (in.getProcessStatus()==null) in.setProcessStatus(0);
|
|
|
- if(in.getProcessStatus()==2){
|
|
|
- if(TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)){
|
|
|
- //财务经理查看权限
|
|
|
- in.setProcessStatus(5);
|
|
|
- }else if(TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)||TokenManager.hasRole(AFTConstants.SUPERADMIN)||
|
|
|
- TokenManager.hasRole(AFTConstants.VICE_CEO)|| TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
|
|
|
- //财务管理员和超级管理员查看全部
|
|
|
- in.setProcessStatus(6);
|
|
|
- }else if (TokenManager.hasRole(AFTConstants.FINANCE)){
|
|
|
- //0 设置为财务查看
|
|
|
- param.put("roleType",0);
|
|
|
- }
|
|
|
- if (in.getAid()!=null){
|
|
|
- param.put("aid",in.getAid());
|
|
|
- }
|
|
|
+ param.put("auditor",TokenManager.getAdminId());
|
|
|
+ if(TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)){
|
|
|
+ //财务经理查看权限
|
|
|
+ in.setProcessStatus(5);
|
|
|
param.put("auditor",TokenManager.getAdminId());
|
|
|
- }else if(in.getProcessStatus()==1) {
|
|
|
+ }else if(TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)||TokenManager.hasRole(AFTConstants.SUPERADMIN)||
|
|
|
+ TokenManager.hasRole(AFTConstants.VICE_CEO)|| TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
|
|
|
+ //财务管理员和超级管理员查看全部
|
|
|
+ in.setProcessStatus(6);
|
|
|
param.put("auditor",TokenManager.getAdminId());
|
|
|
- if (in.getAid()!=null){
|
|
|
- param.put("aid",in.getAid());
|
|
|
- }
|
|
|
+ }else if (TokenManager.hasRole(AFTConstants.FINANCE)){
|
|
|
+ //0 设置为财务查看
|
|
|
+
|
|
|
+ param.put("auditor",TokenManager.getAdminId());
|
|
|
+ //如果是空设置为
|
|
|
+ if (in.getProcessStatus()==null)in.setProcessStatus(2);
|
|
|
}else {
|
|
|
- param.put("aid",TokenManager.getAdminId());
|
|
|
+ in.setProcessStatus(0);
|
|
|
+ }
|
|
|
+ if (in.getRoleType()==null){
|
|
|
+ param.put("roleType",0);
|
|
|
+ }else {
|
|
|
+ param.put("roleType",in.getRoleType());
|
|
|
+ }
|
|
|
+ if(in.getProcessStatus()==2||in.getProcessStatus()==1){
|
|
|
+ if (in.getAid()!=null){
|
|
|
+ param.put("aid",in.getAid());
|
|
|
+ }
|
|
|
}
|
|
|
- param.put("processStatus",in.getProcessStatus());
|
|
|
|
|
|
+ param.put("processStatus",in.getProcessStatus());
|
|
|
if (in.getExamineStatus()!=null){
|
|
|
param.put("examineStatus",in.getExamineStatus());
|
|
|
}else {
|
|
|
@@ -1475,20 +1699,6 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
|
|
|
if (in.getExpenseMain()!=null)param.put("expenseMain",in.getExpenseMain());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 检查权限判断是否是总裁、董事长或超级管理员权限
|
|
|
- * @return
|
|
|
- */
|
|
|
- private boolean checkShiroCED() {
|
|
|
- if (TokenManager.hasRole(AFTConstants.CED)||TokenManager.hasRole(AFTConstants.CED_ASSISTANT)||
|
|
|
- TokenManager.hasRole(AFTConstants.SUPERADMIN)||TokenManager.hasRole(AFTConstants.APPROVAL_DECISION_ASSISTANT)
|
|
|
- ||TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
@Cacheable(value = "expenseAccountStatistics#300", key = "'page:'+#name+',depId'+#depId+',startTime'+#startTime+',endTime'+#endTime+'lander'+#lander")
|
|
|
public List<OutExpenseAccountStatistics> statistics(String name,String depId,String startTime,String endTime,String lander) {
|