|
@ -12,14 +12,23 @@ import com.ccsens.common.bean.vo.CClockingInVo; |
|
|
import com.ccsens.common.persist.dao.ProClockingInDao; |
|
|
import com.ccsens.common.persist.dao.ProClockingInDao; |
|
|
import com.ccsens.common.persist.dao.ProMemberDao; |
|
|
import com.ccsens.common.persist.dao.ProMemberDao; |
|
|
import com.ccsens.common.util.CommonCodeError; |
|
|
import com.ccsens.common.util.CommonCodeError; |
|
|
|
|
|
import com.ccsens.util.PoiUtil; |
|
|
|
|
|
import com.ccsens.util.PropUtil; |
|
|
|
|
|
import com.ccsens.util.WebConstant; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import lombok.Data; |
|
|
import lombok.Data; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.io.OutputStream; |
|
|
import java.text.DateFormat; |
|
|
import java.text.DateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
@ -218,12 +227,92 @@ public class ClockingInService implements IClockingInService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public CClockingInVo.ExcelUrl exportRecord(CClockingInDto.QueryClockingIn params, Long userId) { |
|
|
public CClockingInVo.ExcelUrl exportRecord(CClockingInDto.QueryClockingIn params, Long userId) throws IOException { |
|
|
log.info("开始调用查询考勤方法"); |
|
|
log.info("开始调用查询考勤方法"); |
|
|
List<CClockingInVo.ClockingInInfo> clockingInInfos = queryClockingIn(params, userId); |
|
|
List<CClockingInVo.ClockingInInfo> clockingInInfos = queryClockingIn(params, userId); |
|
|
log.info("调用查询考勤方法结束{}",clockingInInfos); |
|
|
log.info("调用查询考勤方法结束{}",clockingInInfos); |
|
|
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
|
|
//空白格
|
|
|
|
|
|
PoiUtil.PoiUtilCell blank = new PoiUtil.PoiUtilCell(); |
|
|
|
|
|
//excel
|
|
|
|
|
|
List<List<PoiUtil.PoiUtilCell>> list = new ArrayList<>(); |
|
|
|
|
|
//第一行list
|
|
|
|
|
|
List<PoiUtil.PoiUtilCell> firstCells = new ArrayList<>(); |
|
|
|
|
|
//第二行list
|
|
|
|
|
|
List<PoiUtil.PoiUtilCell> secondCells = new ArrayList<>(); |
|
|
|
|
|
//第一行开始
|
|
|
|
|
|
PoiUtil.PoiUtilCell poiUtilCell = new PoiUtil.PoiUtilCell(); |
|
|
|
|
|
poiUtilCell.setValue(""); |
|
|
|
|
|
poiUtilCell.setColspan(1); |
|
|
|
|
|
poiUtilCell.setRowspan(2); |
|
|
|
|
|
firstCells.add(poiUtilCell); |
|
|
|
|
|
//第二行开始
|
|
|
|
|
|
secondCells.add(blank); |
|
|
|
|
|
for (CClockingInVo.ClockingInInfo clockingInInfo : clockingInInfos) { |
|
|
|
|
|
PoiUtil.PoiUtilCell cellOne = new PoiUtil.PoiUtilCell(); |
|
|
|
|
|
cellOne.setValue(clockingInInfo.getDateTime()); |
|
|
|
|
|
cellOne.setColspan(2); |
|
|
|
|
|
cellOne.setRowspan(1); |
|
|
|
|
|
firstCells.add(cellOne); |
|
|
|
|
|
firstCells.add(blank); |
|
|
|
|
|
PoiUtil.PoiUtilCell cellTwo = new PoiUtil.PoiUtilCell(); |
|
|
|
|
|
cellTwo.setValue("早"); |
|
|
|
|
|
secondCells.add(cellTwo); |
|
|
|
|
|
PoiUtil.PoiUtilCell cellTwo2 = new PoiUtil.PoiUtilCell(); |
|
|
|
|
|
cellTwo2.setValue("晚"); |
|
|
|
|
|
secondCells.add(cellTwo2); |
|
|
|
|
|
} |
|
|
|
|
|
list.add(firstCells); |
|
|
|
|
|
list.add(secondCells); |
|
|
|
|
|
for (CClockingInVo.ClockingInInfo clockingInInfo : clockingInInfos) { |
|
|
|
|
|
//添加考勤信息
|
|
|
|
|
|
for (CClockingInVo.ClockRecord clockRecord : clockingInInfo.getRecordList()) { |
|
|
|
|
|
List<PoiUtil.PoiUtilCell> memberCells = new ArrayList<>(); |
|
|
|
|
|
PoiUtil.PoiUtilCell cell = new PoiUtil.PoiUtilCell(); |
|
|
|
|
|
cell.setValue(clockRecord.getMemberName()); |
|
|
|
|
|
memberCells.add(cell); |
|
|
|
|
|
list.add(memberCells); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); |
|
|
|
|
|
for (CClockingInVo.ClockingInInfo clockingInInfo : clockingInInfos) { |
|
|
|
|
|
for (int i = 0; i < clockingInInfo.getRecordList().size(); i++) { |
|
|
|
|
|
List<PoiUtil.PoiUtilCell> poiUtilCells = list.get(i + 2); |
|
|
|
|
|
PoiUtil.PoiUtilCell morning = new PoiUtil.PoiUtilCell(); |
|
|
|
|
|
if (ObjectUtil.isNull(clockingInInfo.getRecordList().get(i).getMorning()) || 0 == clockingInInfo.getRecordList().get(i).getMorning()){ |
|
|
|
|
|
morning.setValue("未打卡"); |
|
|
|
|
|
}else{ |
|
|
|
|
|
morning.setValue(format.format(new Date(clockingInInfo.getRecordList().get(i).getMorning()))); |
|
|
|
|
|
} |
|
|
|
|
|
poiUtilCells.add(morning); |
|
|
|
|
|
PoiUtil.PoiUtilCell night = new PoiUtil.PoiUtilCell(); |
|
|
|
|
|
if (ObjectUtil.isNull(clockingInInfo.getRecordList().get(i).getNight()) || 0 == clockingInInfo.getRecordList().get(i).getNight()){ |
|
|
|
|
|
night.setValue("未打卡"); |
|
|
|
|
|
}else{ |
|
|
|
|
|
night.setValue(format.format(new Date(clockingInInfo.getRecordList().get(i).getNight()))); |
|
|
|
|
|
} |
|
|
|
|
|
poiUtilCells.add(night); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
//导出操作
|
|
|
|
|
|
String fileName = cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; |
|
|
|
|
|
String path = PropUtil.path + fileName; |
|
|
|
|
|
File tmpFile = new File(path); |
|
|
|
|
|
if (!tmpFile.getParentFile().exists()) { |
|
|
|
|
|
tmpFile.getParentFile().mkdirs(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Workbook wbs = PoiUtil.exportWB("Sheet1", list, workbook); |
|
|
|
|
|
OutputStream stream = new FileOutputStream(tmpFile); |
|
|
|
|
|
wbs.write(stream); |
|
|
|
|
|
stream.close(); |
|
|
|
|
|
CClockingInVo.ExcelUrl excelUrl = new CClockingInVo.ExcelUrl(); |
|
|
|
|
|
String url = PropUtil.imgDomain+fileName; |
|
|
|
|
|
excelUrl.setUrl(url); |
|
|
|
|
|
return excelUrl; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|