Commit 3fc8a6e7 authored by 位宇华's avatar 位宇华

东欢坨工资代码提交

parent b328c658
...@@ -3,8 +3,10 @@ package com.ruoyi.system.controller; ...@@ -3,8 +3,10 @@ package com.ruoyi.system.controller;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.model.salary.LxSalaryModel; import com.ruoyi.system.model.salary.LxSalaryModel;
import com.ruoyi.system.service.DhtSalaryService; import com.ruoyi.system.service.DhtSalaryService;
import com.ruoyi.system.service.LjtSalaryService;
import com.ruoyi.system.service.LxSalaryService; import com.ruoyi.system.service.LxSalaryService;
import com.ruoyi.system.service.TsSalarySaveService; import com.ruoyi.system.service.TsSalarySaveService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -17,12 +19,15 @@ public class SalaryController { ...@@ -17,12 +19,15 @@ public class SalaryController {
private final DhtSalaryService dhtSalaryService; private final DhtSalaryService dhtSalaryService;
private final LjtSalaryService ljtSalaryService;
private final TsSalarySaveService salarySaveService; private final TsSalarySaveService salarySaveService;
public SalaryController(TsSalarySaveService salarySaveService, LxSalaryService lxSalaryService, DhtSalaryService dhtSalaryService) { public SalaryController(TsSalarySaveService salarySaveService, LxSalaryService lxSalaryService, DhtSalaryService dhtSalaryService, LjtSalaryService ljtSalaryService) {
this.salarySaveService = salarySaveService; this.salarySaveService = salarySaveService;
this.lxSalaryService = lxSalaryService; this.lxSalaryService = lxSalaryService;
this.dhtSalaryService = dhtSalaryService; this.dhtSalaryService = dhtSalaryService;
this.ljtSalaryService = ljtSalaryService;
} }
/** /**
...@@ -47,8 +52,27 @@ public class SalaryController { ...@@ -47,8 +52,27 @@ public class SalaryController {
return lxSalaryService.lxSave(multipartFile, salaryDate); return lxSalaryService.lxSave(multipartFile, salaryDate);
} }
/**
* 东欢坨
*
* @param multipartFile
* @param salaryDate
* @return
*/
@PostMapping("/dht/salary") @PostMapping("/dht/salary")
public AjaxResult dhtSave(@RequestParam("multipartFile") MultipartFile multipartFile, @RequestParam("salaryDate") String salaryDate) { public AjaxResult dhtSave(@RequestParam("multipartFile") MultipartFile multipartFile, @RequestParam("salaryDate") String salaryDate) {
return dhtSalaryService.dhtSave(multipartFile, salaryDate); return dhtSalaryService.dhtSave(multipartFile, salaryDate);
} }
/**
* 吕家坨
*
* @param multipartFile
* @param salaryDate
* @return
*/
@PostMapping("/ljt/salary")
public AjaxResult ljtSave(@RequestParam("multipartFile") MultipartFile multipartFile, @RequestParam("salaryDate") String salaryDate) {
return ljtSalaryService.ljtSave(multipartFile, salaryDate);
}
} }
package com.ruoyi.system.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.ruoyi.system.model.salary.LjtSalaryModel;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class LjtExcelListener<T> extends AnalysisEventListener<T> {
private final static Logger logger = LoggerFactory.getLogger(LjtExcelListener.class);
private final List<LjtSalaryModel> ljtSalaryModelList = new ArrayList<>();
private int endRow;
@Override
public void invoke(T t, AnalysisContext analysisContext) {
LjtSalaryModel ljtSalaryModel = (LjtSalaryModel) t;
if (StringUtils.equals("合计", ljtSalaryModel.getOrg())) {
endRow = analysisContext.getCurrentRowNum();
}
int count = analysisContext.getCurrentRowNum();
if (endRow == 0 || (endRow - 1 >= count)) {
ljtSalaryModelList.add(ljtSalaryModel);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
logger.info("解析完成!");
}
public List<LjtSalaryModel> getLjtSalaryModelList() {
return ljtSalaryModelList;
}
}
package com.ruoyi.system.model.salary;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import java.io.Serializable;
@ExcelIgnoreUnannotated
public class LjtSalaryModel implements Serializable {
@ExcelProperty("单位")
private String org;
@ExcelProperty("医疗保险")
private String medicalInsurance;
@ExcelProperty("养老保险")
private String oldInsurance;
@ExcelProperty("失业保险")
private String unemploymentInsurance;
@ExcelProperty("住房公积金")
private String houseFund;
@ExcelProperty("会费")
private String laborUnionDues;
@ExcelProperty("年金")
private String annuity;
@ExcelProperty("扣取暖")
private String warmSubsidy;
@ExcelProperty("工资总额")
private String sumSalary;
@ExcelProperty("班餐")
private String lunch;
@ExcelProperty("计育")
private String oneChild;
@ExcelProperty("医贴")
private String medicalSubsidy;
@ExcelProperty("培训费随资")
private String edufFees;
public String getOrg() {
return org;
}
public void setOrg(String org) {
this.org = org;
}
public String getMedicalInsurance() {
return medicalInsurance;
}
public void setMedicalInsurance(String medicalInsurance) {
this.medicalInsurance = medicalInsurance;
}
public String getOldInsurance() {
return oldInsurance;
}
public void setOldInsurance(String oldInsurance) {
this.oldInsurance = oldInsurance;
}
public String getUnemploymentInsurance() {
return unemploymentInsurance;
}
public void setUnemploymentInsurance(String unemploymentInsurance) {
this.unemploymentInsurance = unemploymentInsurance;
}
public String getHouseFund() {
return houseFund;
}
public void setHouseFund(String houseFund) {
this.houseFund = houseFund;
}
public String getLaborUnionDues() {
return laborUnionDues;
}
public void setLaborUnionDues(String laborUnionDues) {
this.laborUnionDues = laborUnionDues;
}
public String getAnnuity() {
return annuity;
}
public void setAnnuity(String annuity) {
this.annuity = annuity;
}
public String getWarmSubsidy() {
return warmSubsidy;
}
public void setWarmSubsidy(String warmSubsidy) {
this.warmSubsidy = warmSubsidy;
}
public String getSumSalary() {
return sumSalary;
}
public void setSumSalary(String sumSalary) {
this.sumSalary = sumSalary;
}
public String getLunch() {
return lunch;
}
public void setLunch(String lunch) {
this.lunch = lunch;
}
public String getOneChild() {
return oneChild;
}
public void setOneChild(String oneChild) {
this.oneChild = oneChild;
}
public String getMedicalSubsidy() {
return medicalSubsidy;
}
public void setMedicalSubsidy(String medicalSubsidy) {
this.medicalSubsidy = medicalSubsidy;
}
public String getEdufFees() {
return edufFees;
}
public void setEdufFees(String edufFees) {
this.edufFees = edufFees;
}
}
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.web.multipart.MultipartFile;
public interface LjtSalaryService {
AjaxResult ljtSave(MultipartFile multipartFile, String salaryDate);
}
package com.ruoyi.system.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.listener.LjtExcelListener;
import com.ruoyi.system.mapper.SalaryMapper;
import com.ruoyi.system.model.salary.LjtSalaryModel;
import com.ruoyi.system.service.LjtSalaryService;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.util.List;
@Service
public class LjtSalaryServiceImpl implements LjtSalaryService {
private final SalaryMapper salaryMapper;
public LjtSalaryServiceImpl(SalaryMapper salaryMapper) {
this.salaryMapper = salaryMapper;
}
@Override
@SneakyThrows
public AjaxResult ljtSave(MultipartFile multipartFile, String salaryDate) {
InputStream inputStream = multipartFile.getInputStream();
LjtExcelListener<LjtSalaryModel>ljtExcelListener = new LjtExcelListener<>();
//工资分析表
EasyExcel.read(inputStream,LjtSalaryModel.class,ljtExcelListener).sheet(0).headRowNumber(1).doRead();
List<LjtSalaryModel> ljtSalaryModelList = ljtExcelListener.getLjtSalaryModelList();
System.err.println(JSON.toJSONString(ljtSalaryModelList));
return null;
}
}
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