|
@@ -1,827 +0,0 @@
|
|
-package com.management.platform.service.impl;
|
|
|
|
-
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
-import com.jayway.jsonpath.internal.function.numeric.Sum;
|
|
|
|
-import com.management.platform.constant.Constant;
|
|
|
|
-import com.management.platform.entity.*;
|
|
|
|
-import com.management.platform.entity.vo.SysRichFunction;
|
|
|
|
-import com.management.platform.mapper.*;
|
|
|
|
-import com.management.platform.service.*;
|
|
|
|
-import com.management.platform.util.ExcelUtil;
|
|
|
|
-import com.management.platform.util.HttpRespMsg;
|
|
|
|
-import com.management.platform.util.MessageUtils;
|
|
|
|
-import org.apache.poi.EncryptedDocumentException;
|
|
|
|
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
|
-import org.apache.poi.ss.usermodel.CellType;
|
|
|
|
-import org.apache.poi.ss.usermodel.Header;
|
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
-
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
-import java.io.*;
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.time.Instant;
|
|
|
|
-import java.time.LocalDate;
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
-import java.time.ZoneId;
|
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * <p>
|
|
|
|
- * 服务实现类
|
|
|
|
- * </p>
|
|
|
|
- *
|
|
|
|
- * @author Seyason
|
|
|
|
- * @since 2021-05-17
|
|
|
|
- */
|
|
|
|
-@Service
|
|
|
|
-@Transactional
|
|
|
|
-public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, ExpenseSheet> implements ExpenseSheetService {
|
|
|
|
- @Value(value = "${upload.path}")
|
|
|
|
- private String path;
|
|
|
|
- @Resource
|
|
|
|
- private HttpServletRequest request;
|
|
|
|
- @Resource
|
|
|
|
- private UserMapper userMapper;
|
|
|
|
- @Resource
|
|
|
|
- private InformationMapper informationMapper;
|
|
|
|
- @Resource
|
|
|
|
- private ExpenseSheetMapper expenseSheetMapper;
|
|
|
|
- @Resource
|
|
|
|
- private ExpenseItemService expenseItemService;
|
|
|
|
- @Resource
|
|
|
|
- private ExpenseItemMapper expenseItemMapper;
|
|
|
|
- @Resource
|
|
|
|
- private ProjectMapper projectMapper;
|
|
|
|
- @Resource
|
|
|
|
- private SysFunctionMapper sysFunctionMapper;
|
|
|
|
- @Resource
|
|
|
|
- private ExpenseTypeMapper expenseTypeMapper;
|
|
|
|
- @Resource
|
|
|
|
- private WxCorpInfoMapper wxCorpInfoMapper;
|
|
|
|
- @Resource
|
|
|
|
- private SysRoleMapper sysRoleMapper;
|
|
|
|
- @Resource
|
|
|
|
- private WxCorpInfoService wxCorpInfoService;
|
|
|
|
- @Resource
|
|
|
|
- private InformationService informationService;
|
|
|
|
- @Resource
|
|
|
|
- private SysRoleFunctionMapper sysRoleFunctionMapper;
|
|
|
|
- @Resource
|
|
|
|
- private ExcelExportService excelExportService;
|
|
|
|
- @Resource
|
|
|
|
- private ExpenseMainTypeService expenseMainTypeService;
|
|
|
|
- @Resource
|
|
|
|
- private ProjectBasecostSettingMapper projectBasecostSettingMapper;
|
|
|
|
- @Resource
|
|
|
|
- private ProjectCurrentcostMapper projectCurrentcostMapper;
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg add(ExpenseSheet sheet, String items, String userId) {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- User user = userMapper.selectById(userId);
|
|
|
|
- List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "费用审核");
|
|
|
|
- boolean isAuditor = functionDeptList.size() > 0;
|
|
|
|
- boolean isNew = false;
|
|
|
|
- if (sheet.getId() == null) {
|
|
|
|
- if (isAuditor) {
|
|
|
|
- sheet.setStatus(0);
|
|
|
|
- } else {
|
|
|
|
- sheet.setStatus(1);
|
|
|
|
- }
|
|
|
|
- isNew = true;
|
|
|
|
- //检查code不能重复
|
|
|
|
- Integer num = expenseSheetMapper.selectCount(new QueryWrapper<ExpenseSheet>().eq("company_id", user.getCompanyId()).eq("code", sheet.getCode()));
|
|
|
|
- if (num > 0) {
|
|
|
|
- //msg.setError("票据编号已存在");
|
|
|
|
- msg.setError(MessageUtils.message("other.billNoExist"));
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- //如果是驳回状态,改成待审核,否则不变
|
|
|
|
- if (sheet.getStatus() == 2) {
|
|
|
|
- if (isAuditor) {
|
|
|
|
- sheet.setStatus(0);
|
|
|
|
- } else {
|
|
|
|
- sheet.setStatus(1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- sheet.setDenyReason(null);
|
|
|
|
- sheet.setOperatorId(userId);//设置操作人id
|
|
|
|
- JSONArray array = JSONArray.parseArray(items);
|
|
|
|
- sheet.setOwnerName(userMapper.selectById(sheet.getOwnerId()).getName());
|
|
|
|
- sheet.setCompanyId(user.getCompanyId());
|
|
|
|
- //校验费用成本是否超过预算
|
|
|
|
- //先获取该类型的费用对应的成本预算是多少
|
|
|
|
- Integer type = sheet.getType();
|
|
|
|
- ExpenseMainType expenseType = expenseMainTypeService.getById(type);
|
|
|
|
- Integer basecostSettingId = expenseType.getBasecostSettingId();
|
|
|
|
- //设置了对应的成本预算项
|
|
|
|
- if (basecostSettingId != null) {
|
|
|
|
- ProjectBasecostSetting projectBasecostSetting = projectBasecostSettingMapper.selectById(basecostSettingId);
|
|
|
|
- String settingName = projectBasecostSetting.getName();
|
|
|
|
- HashMap<Integer, Double> map = new HashMap<>();
|
|
|
|
- for (int i=0;i<array.size(); i++) {
|
|
|
|
- JSONObject obj = array.getJSONObject(i);
|
|
|
|
- ExpenseItem expenseItem = JSONObject.toJavaObject(obj, ExpenseItem.class);
|
|
|
|
- Integer projectId = expenseItem.getProjectId();
|
|
|
|
- if (map.get(projectId) == null) {
|
|
|
|
- map.put(projectId, expenseItem.getAmount());
|
|
|
|
- } else {
|
|
|
|
- //累加
|
|
|
|
- map.put(projectId, map.get(projectId) + expenseItem.getAmount());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (Map.Entry<Integer, Double> entry : map.entrySet()) {
|
|
|
|
- Integer projectId = entry.getKey();
|
|
|
|
- Double amount = entry.getValue();
|
|
|
|
- Project p = projectMapper.selectById(projectId);
|
|
|
|
- //获取该项目的这一项当前成本预算
|
|
|
|
- ProjectCurrentcost pCurCost = projectCurrentcostMapper.selectOne(new QueryWrapper<ProjectCurrentcost>().eq("project_id", projectId).eq("base_id", basecostSettingId));
|
|
|
|
- if (pCurCost == null || pCurCost.getBaseAmount() == null || pCurCost.getBaseAmount() == 0) {
|
|
|
|
- msg.setError("项目【"+p.getProjectName()+"】没有下拨"+settingName+"的预算");
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- //计算该项目当前已经填报的费用报销的金额
|
|
|
|
- Double sumAmount = expenseItemMapper.selectSumAmountByProjectAndType(projectId, type);
|
|
|
|
- if (amount + sumAmount > pCurCost.getBaseAmount()) {
|
|
|
|
- msg.setError("项目【"+p.getProjectName()+"】的"+settingName+"费用预算不足,无法提交");
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (isNew) {
|
|
|
|
- expenseSheetMapper.insert(sheet);
|
|
|
|
- if (!isAuditor) {
|
|
|
|
- WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
- if(wxCorpInfo!=null){
|
|
|
|
- //获取具有费用报销审核权限的人员
|
|
|
|
- SysFunction sysFunction = sysFunctionMapper.selectOne(new QueryWrapper<SysFunction>().eq("name", "费用审核"));
|
|
|
|
- List<SysRoleFunction> sysRoleFunctions = sysRoleFunctionMapper.selectList(new QueryWrapper<SysRoleFunction>().eq("function_id", sysFunction.getId()));
|
|
|
|
- List<Integer> roleIds = sysRoleFunctions.stream().map(sf -> sf.getRoleId()).distinct().collect(Collectors.toList());
|
|
|
|
- List<Integer> targetRoleIds = sysRoleMapper.selectList(new QueryWrapper<SysRole>().eq("company_id", user.getCompanyId()).in("id", roleIds))
|
|
|
|
- .stream().map(sl -> sl.getId()).distinct().collect(Collectors.toList());
|
|
|
|
- List<User> targetUserList = userMapper.selectList(new QueryWrapper<User>().in("role_id", targetRoleIds));
|
|
|
|
- String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
|
|
|
|
- User targetUser = userMapper.selectById(sheet.getOwnerId());
|
|
|
|
- ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
|
|
|
|
- //推送到企业微信
|
|
|
|
- JSONObject json=new JSONObject();
|
|
|
|
- JSONArray dataJson=new JSONArray();
|
|
|
|
- JSONObject jsonObj=new JSONObject();
|
|
|
|
- jsonObj.put("key", "报销人");
|
|
|
|
- jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
|
|
|
|
- JSONObject jsonObj1=new JSONObject();
|
|
|
|
- jsonObj1.put("key", "填报日期");
|
|
|
|
- jsonObj1.put("value",sheet.getCreateDate());
|
|
|
|
- JSONObject jsonObj2=new JSONObject();
|
|
|
|
- jsonObj2.put("key", "票据类型");
|
|
|
|
- jsonObj2.put("value",mainType.getName());
|
|
|
|
- JSONObject jsonObj3=new JSONObject();
|
|
|
|
- jsonObj3.put("key", "金额");
|
|
|
|
- jsonObj3.put("value",sheet.getTotalAmount());
|
|
|
|
- JSONObject jsonObj4=new JSONObject();
|
|
|
|
- jsonObj4.put("key", "备注");
|
|
|
|
- jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
|
|
|
|
- dataJson.add(jsonObj);
|
|
|
|
- dataJson.add(jsonObj1);
|
|
|
|
- dataJson.add(jsonObj2);
|
|
|
|
- dataJson.add(jsonObj3);
|
|
|
|
- dataJson.add(jsonObj4);
|
|
|
|
- json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
|
|
|
|
- json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
|
|
|
|
- json.put("content_item",dataJson);
|
|
|
|
- wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
|
|
|
|
- List<Information> informationList=new ArrayList<>();
|
|
|
|
- for (User item : targetUserList) {
|
|
|
|
- Information information=new Information();
|
|
|
|
- information.setUserId(item.getId());
|
|
|
|
- information.setTime(LocalDateTime.now());
|
|
|
|
- information.setMsg("费用报销待审核");
|
|
|
|
- information.setType(3);
|
|
|
|
- information.setContent(sheet.getCreateDate()+"");
|
|
|
|
- informationList.add(information);
|
|
|
|
- }
|
|
|
|
- informationService.saveBatch(informationList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- expenseSheetMapper.updateById(sheet);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<ExpenseItem> itemList = new ArrayList<ExpenseItem>();
|
|
|
|
- if (array != null) {
|
|
|
|
- for (int i=0;i<array.size(); i++) {
|
|
|
|
- JSONObject obj = array.getJSONObject(i);
|
|
|
|
- ExpenseItem expenseItem = JSONObject.toJavaObject(obj, ExpenseItem.class);
|
|
|
|
- expenseItem.setExpenseId(sheet.getId());
|
|
|
|
- itemList.add(expenseItem);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //对于修改的情况,要删除之前的
|
|
|
|
- if (!isNew) {
|
|
|
|
- expenseItemService.remove(new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId()));
|
|
|
|
- }
|
|
|
|
- expenseItemService.saveBatch(itemList);
|
|
|
|
-
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg delete(Integer id) {
|
|
|
|
- expenseItemService.remove(new QueryWrapper<ExpenseItem>().eq("expense_id", id));
|
|
|
|
- expenseSheetMapper.deleteById(id);
|
|
|
|
- return new HttpRespMsg();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg queryList(ExpenseSheet sheet, String startDate, String endDate, Integer pageIndex, Integer pageSize) {
|
|
|
|
- QueryWrapper<ExpenseSheet> queryWrapper = new QueryWrapper<ExpenseSheet>();
|
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
- queryWrapper.eq("company_id", sheet.getCompanyId()).orderByDesc("id");
|
|
|
|
-
|
|
|
|
- if (!StringUtils.isEmpty(sheet.getCode())) {
|
|
|
|
- queryWrapper.eq("code", sheet.getCode());
|
|
|
|
- }
|
|
|
|
- //增加状态
|
|
|
|
- if (sheet.getStatus() != null) {
|
|
|
|
- queryWrapper.eq("status", sheet.getStatus());
|
|
|
|
- }
|
|
|
|
- if (!StringUtils.isEmpty(sheet.getOwnerId())) {
|
|
|
|
- queryWrapper.eq("owner_id", sheet.getOwnerId());
|
|
|
|
- }
|
|
|
|
- if (sheet.getType() != null) {
|
|
|
|
- queryWrapper.eq("type", sheet.getType());
|
|
|
|
- }
|
|
|
|
- if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(endDate)) {
|
|
|
|
- queryWrapper.between("create_date", startDate, endDate);
|
|
|
|
- }
|
|
|
|
- IPage<ExpenseSheet> listIPager = expenseSheetMapper.selectPage(new Page<>(pageIndex, pageSize),
|
|
|
|
- queryWrapper);
|
|
|
|
- List<ExpenseSheet> records = listIPager.getRecords();
|
|
|
|
- List<ExpenseMainType> expenseMainTypes = expenseMainTypeService.list(new QueryWrapper<ExpenseMainType>().eq("company_id", sheet.getCompanyId()).or().eq("is_system",1));
|
|
|
|
- records.forEach(re->{
|
|
|
|
- Optional<ExpenseMainType> first = expenseMainTypes.stream().filter(et -> et.getId().equals(re.getType())).findFirst();
|
|
|
|
- if(first.isPresent()){
|
|
|
|
- re.setExpenseMainTypeName(first.get().getName());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- Long total = listIPager.getTotal();
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("records", records);
|
|
|
|
- map.put("total", total);
|
|
|
|
- httpRespMsg.data = map;
|
|
|
|
- return httpRespMsg;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg getNextCode(String userId) {
|
|
|
|
- User user = userMapper.selectById(userId);
|
|
|
|
- DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
- String format = yyyyMMdd.format(LocalDate.now());
|
|
|
|
- List<ExpenseSheet> list = expenseSheetMapper.selectList(new QueryWrapper<ExpenseSheet>()
|
|
|
|
- .eq("company_id", user.getCompanyId())
|
|
|
|
- .like("code", format).orderByDesc("id").last("limit 1"));
|
|
|
|
- int start = 1;
|
|
|
|
- if (list.size() > 0) {
|
|
|
|
- String code = list.get(0).getCode();
|
|
|
|
- code = code.substring(format.length(), code.length());
|
|
|
|
- System.out.println("code====="+code);
|
|
|
|
- if (code.length() > 0) {
|
|
|
|
- start = Integer.parseInt(code) + 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- msg.data = format+start;
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg getDetail(Integer id) {
|
|
|
|
- ExpenseSheet expenseSheet = expenseSheetMapper.selectById(id);
|
|
|
|
- List<ExpenseItem> list = expenseItemMapper.selectList(new QueryWrapper<ExpenseItem>().eq("expense_id", id));
|
|
|
|
- List<Project> Project = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", expenseSheet.getCompanyId()));
|
|
|
|
- for (ExpenseItem expenseItem : list) {
|
|
|
|
- for (Project project : Project) {
|
|
|
|
- if ((project.getId().equals(expenseItem.getProjectId()))){
|
|
|
|
- expenseItem.setProjectName(project.getProjectName());
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- expenseSheet.setInvoiceList(list);
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- msg.data = expenseSheet;
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg approve(Integer id) {
|
|
|
|
- String token = request.getHeader("TOKEN");
|
|
|
|
- User user = userMapper.selectById(token);
|
|
|
|
- ExpenseSheet sheet = new ExpenseSheet();
|
|
|
|
- sheet.setId(id);
|
|
|
|
- sheet.setStatus(0);
|
|
|
|
- expenseSheetMapper.updateById(sheet);
|
|
|
|
-
|
|
|
|
- sheet = expenseSheetMapper.selectById(id);
|
|
|
|
- WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
- if (wxCorpInfo != null) {
|
|
|
|
- sendAuditResult(wxCorpInfo, user, sheet, null);
|
|
|
|
- }
|
|
|
|
- saveNotifyToApplier(sheet, user);
|
|
|
|
-
|
|
|
|
- return new HttpRespMsg();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg deny(Integer id,String denyReason) {
|
|
|
|
- String token = request.getHeader("TOKEN");
|
|
|
|
- User user = userMapper.selectById(token);
|
|
|
|
- ExpenseSheet sheet = new ExpenseSheet();
|
|
|
|
- sheet.setId(id);
|
|
|
|
- sheet.setStatus(2);
|
|
|
|
- sheet.setDenyReason(denyReason);
|
|
|
|
- expenseSheetMapper.updateById(sheet);
|
|
|
|
-
|
|
|
|
- //给填报人发送消息
|
|
|
|
- sheet = expenseSheetMapper.selectById(id);
|
|
|
|
- WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
- if (wxCorpInfo != null) {
|
|
|
|
- sendAuditResult(wxCorpInfo, user, sheet, denyReason);
|
|
|
|
- }
|
|
|
|
- saveNotifyToApplier(sheet, user);
|
|
|
|
-
|
|
|
|
- return new HttpRespMsg();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //发送审核结果消息提醒
|
|
|
|
- private void sendAuditResult(WxCorpInfo wxCorpInfo, User auditor, ExpenseSheet sheet, String denyReason) {
|
|
|
|
- //推送到企业微信
|
|
|
|
- StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("M月d日");
|
|
|
|
- stringBuilder.append("$userName="+auditor.getCorpwxUserid()+"$")
|
|
|
|
- .append(sheet.getStatus() == 0?"通过":"驳回")
|
|
|
|
- .append("了您")
|
|
|
|
- .append(dateTimeFormatter.format(sheet.getCreateDate()))
|
|
|
|
- .append("的费用报销申请。");
|
|
|
|
- if (sheet.getStatus() == 2) {
|
|
|
|
- //驳回加原因
|
|
|
|
- stringBuilder.append("原因: ").append(denyReason);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String ownerId = sheet.getOwnerId();
|
|
|
|
- User owner = userMapper.selectById(ownerId);
|
|
|
|
- wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,owner.getCorpwxUserid(), stringBuilder.toString(), "expense",
|
|
|
|
- sheet.getStatus() == 0?WxCorpInfoServiceImpl.TEXT_CARD_MSG_EXPENSE_AGREE:WxCorpInfoServiceImpl.TEXT_CARD_MSG_EXPENSE_DENY);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- private void saveNotifyToApplier(ExpenseSheet sheet, User auditor) {
|
|
|
|
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("M月d日");
|
|
|
|
- String ownerId = sheet.getOwnerId();
|
|
|
|
- User owner = userMapper.selectById(ownerId);
|
|
|
|
- //系统内消息
|
|
|
|
- Information information=new Information();
|
|
|
|
- information.setUserId(owner.getId());
|
|
|
|
- information.setTime(LocalDateTime.now());
|
|
|
|
- information.setMsg("您"+dateTimeFormatter.format(sheet.getCreateDate()) + "费用报销申请审核"+(sheet.getStatus() == 0?"已通过":"已驳回")+", 审核人:"
|
|
|
|
- +(auditor.getCorpwxUserid() != null ? ("$userName="+auditor.getCorpwxUserid()+"$"):auditor.getName()));
|
|
|
|
- information.setType(3);//费用报销模块
|
|
|
|
- information.setContent(sheet.getId()+"");
|
|
|
|
- informationMapper.insert(information);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg importData(HttpServletRequest request,MultipartFile[] files) {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
- WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
- //然后处理文件
|
|
|
|
- for (MultipartFile multipartFile : files) {
|
|
|
|
- String fileName = multipartFile.getOriginalFilename();
|
|
|
|
- File file = new File(fileName == null ? "file" : fileName);
|
|
|
|
- InputStream inputStream = null;
|
|
|
|
- OutputStream outputStream = null;
|
|
|
|
- try {
|
|
|
|
- inputStream = multipartFile.getInputStream();
|
|
|
|
- outputStream = new FileOutputStream(file);
|
|
|
|
- byte[] buffer = new byte[4096];
|
|
|
|
- int temp = 0;
|
|
|
|
- while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
|
|
|
|
- outputStream.write(buffer, 0, temp);
|
|
|
|
- }
|
|
|
|
- inputStream.close();
|
|
|
|
- outputStream.close();
|
|
|
|
- //然后解析表格
|
|
|
|
- XSSFWorkbook workbook = new XSSFWorkbook(file);
|
|
|
|
- //我们只需要第一个sheet
|
|
|
|
- XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
- //获取全部人员
|
|
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
|
|
|
|
- List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
|
|
|
|
- List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "费用审核");
|
|
|
|
- List<ExpenseMainType> expenseMainTypeList = expenseMainTypeService.list(new QueryWrapper<ExpenseMainType>().eq("company_id", user.getCompanyId()));
|
|
|
|
- List<ExpenseType> expenseTypeList = expenseTypeMapper.selectList(new QueryWrapper<ExpenseType>().eq("company_id",user.getCompanyId()));
|
|
|
|
- //由于第一行需要指明报销人列对应的标题
|
|
|
|
- XSSFRow firstRow = sheet.getRow(2);
|
|
|
|
- if (firstRow == null) {
|
|
|
|
- //msg.setError("错误数据,导入失败");
|
|
|
|
- msg.setError(MessageUtils.message("file.dataFormatError"));
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- //报销人 填报日期 费用类型 备注
|
|
|
|
- XSSFCell reimburserCell = firstRow.getCell(0);
|
|
|
|
- XSSFCell reportDateCell = firstRow.getCell(1);
|
|
|
|
- XSSFCell expenseTypeCell = firstRow.getCell(2);
|
|
|
|
- XSSFCell remarksCell = firstRow.getCell(3);
|
|
|
|
-
|
|
|
|
- if (reimburserCell != null) reimburserCell.setCellType(CellType.STRING);
|
|
|
|
- if (reportDateCell != null) reportDateCell.setCellType(CellType.NUMERIC);
|
|
|
|
- if (expenseTypeCell != null) expenseTypeCell.setCellType(CellType.STRING);
|
|
|
|
- if (remarksCell != null) remarksCell.setCellType(CellType.STRING);
|
|
|
|
- if (reimburserCell == null || StringUtils.isEmpty(reimburserCell.getStringCellValue())) {//报销人为空的直接跳过
|
|
|
|
- throw new Exception("报销人名称不能为空");
|
|
|
|
- }
|
|
|
|
- if (expenseTypeCell == null) {
|
|
|
|
- throw new Exception("费用类型不能为空");
|
|
|
|
- }
|
|
|
|
- if (reportDateCell == null || reportDateCell.getDateCellValue() == null) {
|
|
|
|
- throw new Exception("填报日期不能为空");
|
|
|
|
- }
|
|
|
|
- //做完非空校验后,进行姓名处理
|
|
|
|
-
|
|
|
|
- String reimburserName = reimburserCell.getStringCellValue();
|
|
|
|
-
|
|
|
|
- HttpRespMsg respMsg= null;
|
|
|
|
- List<User> targetUserList= new ArrayList<>();
|
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
- List<String> userNameList=new ArrayList<>();
|
|
|
|
- userNameList.add(reimburserName);
|
|
|
|
- System.out.println("参与搜素的人员列表"+userNameList);
|
|
|
|
- respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
|
|
|
|
- if(respMsg.code.equals("0")){
|
|
|
|
- msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- targetUserList = (List<User>) respMsg.data;
|
|
|
|
- }
|
|
|
|
- ExpenseSheet expenseSheet = new ExpenseSheet();
|
|
|
|
- if(functionList.size()>0){
|
|
|
|
- expenseSheet.setStatus(0);
|
|
|
|
- }else {
|
|
|
|
- expenseSheet.setStatus(1);
|
|
|
|
- }
|
|
|
|
- //处理编号
|
|
|
|
- DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
- String format = yyyyMMdd.format(LocalDate.now());
|
|
|
|
- List<ExpenseSheet> list = expenseSheetMapper.selectList(new QueryWrapper<ExpenseSheet>()
|
|
|
|
- .eq("company_id", user.getCompanyId())
|
|
|
|
- .like("code", format).orderByDesc("id").last("limit 1"));
|
|
|
|
- int start = 1;
|
|
|
|
- if (list.size() > 0) {
|
|
|
|
- String code = list.get(0).getCode();
|
|
|
|
- code = code.substring(format.length(), code.length());
|
|
|
|
- System.out.println("code=====" + code);
|
|
|
|
- if (code.length() > 0) {
|
|
|
|
- start = Integer.parseInt(code) + 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- expenseSheet.setCode(format + start);
|
|
|
|
- expenseSheet.setCompanyId(user.getCompanyId());
|
|
|
|
- LocalDate localDate = Instant.ofEpochMilli(reportDateCell.getDateCellValue().getTime())
|
|
|
|
- .atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
|
- expenseSheet.setCreateDate(localDate);
|
|
|
|
- Optional<User> first;
|
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
- Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(reimburserName)).findFirst();
|
|
|
|
- first = userList.stream().filter(us -> us.getName().equals(reimburserName)||(us.getJobNumber()!=null&&us.getJobNumber().equals(reimburserName))||(optional.isPresent()&&us.getCorpwxUserid()!=null&&us.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
|
- }else {
|
|
|
|
- first = userList.stream().filter(us -> us.getName().equals(reimburserName)||(us.getJobNumber()!=null&&us.getJobNumber().equals(reimburserName))).findFirst();
|
|
|
|
- }
|
|
|
|
- if (first != null && first.isPresent()) {
|
|
|
|
- expenseSheet.setOwnerId(first.get().getId());
|
|
|
|
- expenseSheet.setOwnerName(first.get().getName());
|
|
|
|
- } else {
|
|
|
|
- throw new Exception("报销人[" +reimburserCell+"]不存在");
|
|
|
|
- }
|
|
|
|
- expenseSheet.setOperatorId(user.getId());
|
|
|
|
- expenseSheet.setRemark(remarksCell.getStringCellValue());
|
|
|
|
- if(StringUtils.isEmpty(expenseTypeCell.getStringCellValue())){
|
|
|
|
- msg.setError("请填写费用报销类型");
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- if(!expenseMainTypeList.stream().anyMatch(el->el.getName().equals(expenseTypeCell.getStringCellValue()))){
|
|
|
|
- msg.setError("当前费用类型["+expenseTypeCell.getStringCellValue()+"]不存在");
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- Optional<ExpenseMainType> any = expenseMainTypeList.stream().filter(el -> el.getName().equals(expenseTypeCell.getStringCellValue())).findAny();
|
|
|
|
- if(any.isPresent()){
|
|
|
|
- expenseSheet.setType(any.get().getId());
|
|
|
|
- }
|
|
|
|
- expenseSheetMapper.insert(expenseSheet);
|
|
|
|
- //前提需要指定第一二行为报销人数据 从第三行数据开始处理 报销单据详情
|
|
|
|
- int rowNum = sheet.getLastRowNum();
|
|
|
|
- //计算总费用
|
|
|
|
- BigDecimal bigDecimal = new BigDecimal(0);
|
|
|
|
- List<ExpenseItem> expenseItemList = new ArrayList<>();
|
|
|
|
- int i=0;
|
|
|
|
- String errorAboutProject="";
|
|
|
|
- for (int rowIndex = 5; rowIndex <= rowNum; rowIndex++) {
|
|
|
|
- XSSFRow row = sheet.getRow(rowIndex);
|
|
|
|
- if (row == null) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- //跳过空行
|
|
|
|
- if (ExcelUtil.isRowEmpty(row)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- //项目编号 费用日期 发拍种类 费用类型 费用金额 发票号 税率 税额 备注
|
|
|
|
- XSSFCell codeCell = row.getCell(0);
|
|
|
|
- if (codeCell != null) codeCell.setCellType(CellType.STRING);
|
|
|
|
- Optional<Project> project = projectList.stream().filter(pro ->(StringUtils.isEmpty(pro.getProjectCode())?"":pro.getProjectCode()).equals(codeCell.getStringCellValue())
|
|
|
|
- || (StringUtils.isEmpty(pro.getProjectName())?"":pro.getProjectName()).equals(codeCell.getStringCellValue())).findFirst();
|
|
|
|
- if (!project.isPresent()) {
|
|
|
|
- errorAboutProject+=codeCell.getStringCellValue()+"/";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(!errorAboutProject.equals("")){
|
|
|
|
- throw new Exception("项目编号/项目名称为[" +errorAboutProject+"]的项目不存在");
|
|
|
|
- }
|
|
|
|
- for (int rowIndex = 5; rowIndex <= rowNum; rowIndex++) {
|
|
|
|
- XSSFRow row = sheet.getRow(rowIndex);
|
|
|
|
- if (row == null) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- //跳过空行
|
|
|
|
- if (ExcelUtil.isRowEmpty(row)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- //项目编号 费用日期 发拍种类 费用类型 费用金额 发票号 税率 税额 备注
|
|
|
|
- XSSFCell codeCell = row.getCell(0);
|
|
|
|
- XSSFCell happenDateCell = row.getCell(1);
|
|
|
|
- XSSFCell invoiceTypeCell = row.getCell(2);
|
|
|
|
- XSSFCell subExpenseTypeCell = row.getCell(3);
|
|
|
|
- XSSFCell amountCell = row.getCell(4);
|
|
|
|
- XSSFCell invoiceNoCell = row.getCell(5);
|
|
|
|
- XSSFCell taxPercentCell = row.getCell(6);
|
|
|
|
- XSSFCell remarkCell = row.getCell(7);
|
|
|
|
-
|
|
|
|
- if (codeCell != null) codeCell.setCellType(CellType.STRING);
|
|
|
|
- if (happenDateCell != null) happenDateCell.setCellType(CellType.NUMERIC);
|
|
|
|
- if (invoiceTypeCell != null) invoiceTypeCell.setCellType(CellType.STRING);
|
|
|
|
- if (subExpenseTypeCell != null) subExpenseTypeCell.setCellType(CellType.STRING);
|
|
|
|
- if (amountCell != null) amountCell.setCellType(CellType.NUMERIC);
|
|
|
|
- if (invoiceNoCell != null) invoiceNoCell.setCellType(CellType.STRING);
|
|
|
|
- if (taxPercentCell != null) taxPercentCell.setCellType(CellType.NUMERIC);
|
|
|
|
- if (remarkCell != null) remarkCell.setCellType(CellType.STRING);
|
|
|
|
- //项目为空 直接跳过
|
|
|
|
- if(codeCell==null){
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- ExpenseItem expenseItem = new ExpenseItem();
|
|
|
|
- System.out.println(codeCell.getStringCellValue());
|
|
|
|
- Optional<Project> project = projectList.stream().filter(pro ->(StringUtils.isEmpty(pro.getProjectCode())?"":pro.getProjectCode()).equals(codeCell.getStringCellValue())
|
|
|
|
- || (StringUtils.isEmpty(pro.getProjectName())?"":pro.getProjectName()).equals(codeCell.getStringCellValue())).findFirst();
|
|
|
|
- if (project.isPresent()) {
|
|
|
|
- expenseItem.setProjectId(project.get().getId());
|
|
|
|
- }
|
|
|
|
- expenseItem.setExpenseId(expenseSheet.getId());
|
|
|
|
- if(happenDateCell!=null && !happenDateCell.toString().trim().equals("")){
|
|
|
|
- LocalDate happenDate = Instant.ofEpochMilli(happenDateCell.getDateCellValue().getTime())
|
|
|
|
- .atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
|
- expenseItem.setHappenDate(String.valueOf(happenDate));
|
|
|
|
- }
|
|
|
|
- if(invoiceTypeCell!=null){
|
|
|
|
- switch (invoiceTypeCell.getStringCellValue()) {
|
|
|
|
- case "增值税专用发票":
|
|
|
|
- case "VAT special invoice":
|
|
|
|
- expenseItem.setInvoiceType(0);
|
|
|
|
- break;
|
|
|
|
- case "增值税普通发票":
|
|
|
|
- case "VAT ordinary invoice":
|
|
|
|
- expenseItem.setInvoiceType(1);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(subExpenseTypeCell!=null){
|
|
|
|
- List<String> stringList = expenseTypeList.stream().filter(et -> et.getMainType().equals(expenseSheet.getType())).map(et -> et.getTypeName()).collect(Collectors.toList());
|
|
|
|
- if(stringList!=null&&!stringList.contains(subExpenseTypeCell.getStringCellValue())){
|
|
|
|
- //msg.setError("当前费用类型["+expenseTypeCell.getStringCellValue()+"]中不存在["+subExpenseTypeCell.getStringCellValue()+"]类型");
|
|
|
|
- msg.setError(MessageUtils.message("Reimbursement.TypeError",expenseTypeCell.getStringCellValue(),subExpenseTypeCell.getStringCellValue()));
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- expenseItem.setExpenseType(subExpenseTypeCell.getStringCellValue());
|
|
|
|
- }
|
|
|
|
- if(invoiceNoCell!=null){
|
|
|
|
- expenseItem.setInvoiceNo(invoiceNoCell.getStringCellValue());
|
|
|
|
- }
|
|
|
|
- if(amountCell!=null){
|
|
|
|
- expenseItem.setAmount(amountCell.getNumericCellValue());
|
|
|
|
- //计算税额
|
|
|
|
- BigDecimal bd = new BigDecimal(amountCell.getNumericCellValue());
|
|
|
|
- bigDecimal=bigDecimal.add(BigDecimal.valueOf(amountCell.getNumericCellValue()));
|
|
|
|
-
|
|
|
|
- if (taxPercentCell != null) {
|
|
|
|
- //税率是加百分号后显示的数据
|
|
|
|
- BigDecimal taxRate = new BigDecimal(taxPercentCell.getNumericCellValue()).divide(new BigDecimal(100));
|
|
|
|
- //原始金额
|
|
|
|
- BigDecimal divide = bd.divide(taxRate.add(new BigDecimal(1)),2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
- BigDecimal subtract = bd.subtract(divide);
|
|
|
|
- expenseItem.setTaxValue(subtract.doubleValue());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(remarkCell!=null){
|
|
|
|
- expenseItem.setRemark(remarkCell.getStringCellValue());
|
|
|
|
- }
|
|
|
|
- if(taxPercentCell!=null){
|
|
|
|
- expenseItem.setTaxPercent(taxPercentCell.getNumericCellValue());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expenseItemList.add(expenseItem);
|
|
|
|
- i++;
|
|
|
|
- }
|
|
|
|
- expenseSheet.setTicketNum(i);
|
|
|
|
- expenseSheet.setTotalAmount(bigDecimal.doubleValue());
|
|
|
|
- expenseSheetMapper.updateById(expenseSheet);
|
|
|
|
- expenseItemService.saveBatch(expenseItemList);
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- } catch (NullPointerException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- //msg.setError("数据格式有误或存在空数据 导入失败");
|
|
|
|
- msg.setError(MessageUtils.message("file.dataFormatError"));
|
|
|
|
- return msg;
|
|
|
|
- } catch (InvalidFormatException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- //msg.setError("文件格式错误,如果安装了加密软件需要先解密再上传");
|
|
|
|
- msg.setError(MessageUtils.message("file.FormatErrorAndDecrypt"));
|
|
|
|
- } catch (EncryptedDocumentException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- //msg.setError("文件加密状态,需要先解除加密状态再上传");
|
|
|
|
- msg.setError(MessageUtils.message("file.encryption"));
|
|
|
|
- return msg;
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- //msg.setError("上传失败:" + e.getMessage());
|
|
|
|
- msg.setError(MessageUtils.message("file.uploadError",e.getMessage()));
|
|
|
|
- return msg;
|
|
|
|
- } finally {
|
|
|
|
- //关闭流
|
|
|
|
- try {
|
|
|
|
- if (outputStream != null && inputStream != null) {
|
|
|
|
- outputStream.close();
|
|
|
|
- inputStream.close();
|
|
|
|
- System.out.println("流已关闭");
|
|
|
|
- }
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
-// file.deleteOnExit();//程序退出时删除临时文件
|
|
|
|
- System.out.println(file.delete());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 费用报销单据的导出
|
|
|
|
- * @param sheet
|
|
|
|
- * @param startDate
|
|
|
|
- * @param endDate
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg exportList(ExpenseSheet sheet, String startDate, String endDate) {
|
|
|
|
- WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", sheet.getCompanyId()));
|
|
|
|
- QueryWrapper<ExpenseSheet> queryWrapper = new QueryWrapper<ExpenseSheet>();
|
|
|
|
- queryWrapper.eq("company_id", sheet.getCompanyId()).orderByDesc("id");
|
|
|
|
- if (!StringUtils.isEmpty(sheet.getCode())) {
|
|
|
|
- queryWrapper.eq("code", sheet.getCode());
|
|
|
|
- }
|
|
|
|
- //增加状态
|
|
|
|
- if (sheet.getStatus() != null) {
|
|
|
|
- queryWrapper.eq("status", sheet.getStatus());
|
|
|
|
- }
|
|
|
|
- if (!StringUtils.isEmpty(sheet.getOwnerId())) {
|
|
|
|
- queryWrapper.eq("owner_id", sheet.getOwnerId());
|
|
|
|
- }
|
|
|
|
- if (sheet.getType() != null) {
|
|
|
|
- queryWrapper.eq("type", sheet.getType());
|
|
|
|
- }
|
|
|
|
- if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(endDate)) {
|
|
|
|
- queryWrapper.between("create_date", startDate, endDate);
|
|
|
|
- }
|
|
|
|
- List<ExpenseSheet> records = expenseSheetMapper.selectList(queryWrapper);
|
|
|
|
- List<List<String>> allList=new ArrayList<>();
|
|
|
|
- List<String> titleList=new ArrayList<>();
|
|
|
|
-// titleList.add("票据编号");
|
|
|
|
-// titleList.add("金额(元)");
|
|
|
|
-// titleList.add("报销人");
|
|
|
|
-// titleList.add("填报日期");
|
|
|
|
-// titleList.add("发票张数");
|
|
|
|
-// titleList.add("票据类型");
|
|
|
|
-// titleList.add("备注");
|
|
|
|
-// titleList.add("状态");
|
|
|
|
- titleList.add(MessageUtils.message("Reimbursement.No"));
|
|
|
|
- titleList.add(MessageUtils.message("Reimbursement.amount"));
|
|
|
|
- titleList.add(MessageUtils.message("excel.reiPer"));
|
|
|
|
- titleList.add(MessageUtils.message("excel.fillDate"));
|
|
|
|
- titleList.add(MessageUtils.message("Reimbursement.numberOfInvoices"));
|
|
|
|
- titleList.add(MessageUtils.message("Reimbursement.billType"));
|
|
|
|
- titleList.add(MessageUtils.message("excel.remark"));
|
|
|
|
- titleList.add(MessageUtils.message("leave.status"));
|
|
|
|
- allList.add(titleList);
|
|
|
|
- BigDecimal sumAmount = new BigDecimal(0);
|
|
|
|
- for (ExpenseSheet record : records) {
|
|
|
|
- List<String> item=new ArrayList<>();
|
|
|
|
- item.add(record.getCode());
|
|
|
|
- item.add(record.getTotalAmount()==null?"0":record.getTotalAmount()+"");
|
|
|
|
- if (wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
- item.add("$userName=" + record.getOwnerName() +"$");
|
|
|
|
- }else {
|
|
|
|
- item.add(record.getOwnerName());
|
|
|
|
- }
|
|
|
|
- item.add(record.getCreateDate()==null?"":record.getCreateDate()+"");
|
|
|
|
- item.add(record.getTicketNum()==null?"0":record.getTicketNum()+"");
|
|
|
|
- switch (record.getType()){
|
|
|
|
- case 0:
|
|
|
|
- item.add("一般费用");
|
|
|
|
- break;
|
|
|
|
- case 1:
|
|
|
|
- item.add("差旅费用");
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- item.add("外包费用");
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- item.add("");
|
|
|
|
- }
|
|
|
|
- item.add(record.getRemark()==null?"":record.getRemark());
|
|
|
|
- switch (record.getStatus()){
|
|
|
|
- case 0:
|
|
|
|
- item.add("审核通过");
|
|
|
|
- break;
|
|
|
|
- case 1:
|
|
|
|
- item.add("待审核");
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- item.add("驳回");
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- item.add("已撤回");
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- item.add("");
|
|
|
|
- }
|
|
|
|
- allList.add(item);
|
|
|
|
- if (record.getTotalAmount() == null) record.setTotalAmount(0.0);
|
|
|
|
- sumAmount = sumAmount.add(BigDecimal.valueOf(record.getTotalAmount()));
|
|
|
|
- }
|
|
|
|
- //合计
|
|
|
|
- List<String> sumRow = new ArrayList<String>();
|
|
|
|
- //sumRow.add("合计");
|
|
|
|
- sumRow.add(MessageUtils.message("entry.total"));
|
|
|
|
- sumRow.add(sumAmount.setScale(2,BigDecimal.ROUND_UP)+"");
|
|
|
|
- for (int i = 0; i < titleList.size() - 2; i++) {
|
|
|
|
- sumRow.add("");
|
|
|
|
- }
|
|
|
|
- allList.add(sumRow);
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- //生成excel文件导出
|
|
|
|
- //String fileName = "费用报销单据列表"+System.currentTimeMillis();
|
|
|
|
- String fileName = MessageUtils.message("fileName.expense")+System.currentTimeMillis();
|
|
|
|
- try {
|
|
|
|
- return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName , allList, path);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
-// String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , dataList, path);
|
|
|
|
-// msg.data = resp;
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
-}
|
|
|