|
@@ -4,14 +4,8 @@ package com.jpsoft.shinestar.modules.base.controller;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.util.StringUtil;
|
|
|
import com.jpsoft.shinestar.config.OSSConfig;
|
|
|
-import com.jpsoft.shinestar.modules.base.entity.CanteenDining;
|
|
|
-import com.jpsoft.shinestar.modules.base.entity.CanteenDiningRecord;
|
|
|
-import com.jpsoft.shinestar.modules.base.entity.CanteenInfo;
|
|
|
-import com.jpsoft.shinestar.modules.base.entity.CompanyInfo;
|
|
|
-import com.jpsoft.shinestar.modules.base.service.CanteenDiningRecordService;
|
|
|
-import com.jpsoft.shinestar.modules.base.service.CanteenDiningService;
|
|
|
-import com.jpsoft.shinestar.modules.base.service.CanteenInfoService;
|
|
|
-import com.jpsoft.shinestar.modules.base.service.CompanyInfoService;
|
|
|
+import com.jpsoft.shinestar.modules.base.entity.*;
|
|
|
+import com.jpsoft.shinestar.modules.base.service.*;
|
|
|
import com.jpsoft.shinestar.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.shinestar.modules.common.dto.Sort;
|
|
|
import com.jpsoft.shinestar.modules.common.utils.OSSUtil;
|
|
@@ -33,6 +27,7 @@ import java.io.ByteArrayInputStream;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -54,7 +49,7 @@ public class CanteenRearServiceController {
|
|
|
private CompanyInfoService companyInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
- private CanteenDiningService canteenDiningService;
|
|
|
+ private PersonInfoService personInfoService;
|
|
|
|
|
|
@ApiOperation(value="食堂后勤人员就餐明细表")
|
|
|
@RequestMapping(value = "canteenRearServiceList",method = RequestMethod.POST)
|
|
@@ -74,12 +69,9 @@ public class CanteenRearServiceController {
|
|
|
try {
|
|
|
|
|
|
Map<String, Object> searchParams = new HashMap<>();
|
|
|
- Map<String, Object> searchParams1 = new HashMap<>();
|
|
|
- Map<String, Object> searchParams2 = new HashMap<>();
|
|
|
- Map<String, Object> searchParams3 = new HashMap<>();
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("a.create_time", "desc"));
|
|
|
+ sortList.add(new Sort("b.hq_sort_no", "asc"));
|
|
|
|
|
|
if (StringUtils.isNotEmpty(recordTimeRange)) {
|
|
|
String[] timeRangeArray = recordTimeRange.split(",");
|
|
@@ -97,15 +89,6 @@ public class CanteenRearServiceController {
|
|
|
|
|
|
searchParams.put("beginTime", beginTime);
|
|
|
searchParams.put("endTime", endTime);
|
|
|
-
|
|
|
- searchParams1.put("beginTime", beginTime);
|
|
|
- searchParams1.put("endTime", endTime);
|
|
|
-
|
|
|
- searchParams2.put("beginTime", beginTime);
|
|
|
- searchParams2.put("endTime", endTime);
|
|
|
-
|
|
|
- searchParams3.put("beginTime", beginTime);
|
|
|
- searchParams3.put("endTime", endTime);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -125,86 +108,195 @@ public class CanteenRearServiceController {
|
|
|
searchParams.put("hqStatus", parentCompanyInfo.getClassify());
|
|
|
}
|
|
|
}
|
|
|
- else{
|
|
|
- searchParams.put("querHq", "yes");
|
|
|
- }
|
|
|
|
|
|
Page<Map> page = canteenDiningRecordService.canteenHqPersonList(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
|
|
|
List<Map> mapList = new ArrayList<>();
|
|
|
|
|
|
- //行政食堂
|
|
|
- List<CanteenDining> canteenDiningList = canteenDiningService.findByCanteenId("2");
|
|
|
-
|
|
|
- BigDecimal lunFee = BigDecimal.ZERO;
|
|
|
- BigDecimal supFee = BigDecimal.ZERO;
|
|
|
+ for (Map map : page) {
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
|
|
|
- for (CanteenDining canteenDining:canteenDiningList) {
|
|
|
- if(canteenDining.getDiningType().equals("2")){
|
|
|
- lunFee = canteenDining.getOutsourcerDiningFee();
|
|
|
- }
|
|
|
- else if(canteenDining.getDiningType().equals("3")){
|
|
|
- supFee = canteenDining.getOutsourcerDiningFee();
|
|
|
- }
|
|
|
+ if(exportFlag) {
|
|
|
+ String filePath = canteenExportXls(mapList);
|
|
|
+ msgResult.setData(filePath);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
|
|
|
+ dataMap.put("data", mapList);
|
|
|
+ msgResult.setData(dataMap);
|
|
|
}
|
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
+ msgResult.setResult(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
|
|
|
- for (Map map : page) {
|
|
|
- if(map.get("person_id")!=null){
|
|
|
- Long personId = Long.parseLong(map.get("person_id").toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private String canteenExportXls(List<Map> mapList) throws IOException {
|
|
|
+ String downloadUrl = "";
|
|
|
+
|
|
|
+ Workbook workbook = new HSSFWorkbook();
|
|
|
+ Sheet sheet = workbook.createSheet();
|
|
|
+
|
|
|
+ //表头
|
|
|
+ Row rowTitle = sheet.createRow(0);
|
|
|
+
|
|
|
+ String[] titles = new String[]{"序号","部门","工号","姓名","中餐就餐总数","晚餐就餐总数", "宵夜就餐总数","总计总数","就餐金额(元)",};
|
|
|
+
|
|
|
+ for (int i=0;i<titles.length;i++) {
|
|
|
+ Cell cell = rowTitle.createCell(i);
|
|
|
+ cell.setCellValue(titles[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i=0;i<mapList.size();i++){
|
|
|
+ Map<String,Object> map = mapList.get(i);
|
|
|
+
|
|
|
+ Row row = sheet.createRow(i+1);
|
|
|
+
|
|
|
+ int colIndex = 0;
|
|
|
+ row.createCell(colIndex++).setCellValue(i+1);
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("companyName"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("jobNumber"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("personName"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("lunch"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("supper"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("nightSnack"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("personNum"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("totalFee"),""));
|
|
|
+ }
|
|
|
|
|
|
- searchParams1.put("personId", personId);
|
|
|
- searchParams2.put("personId", personId);
|
|
|
- searchParams3.put("personId", personId);
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+
|
|
|
+ try {
|
|
|
+ workbook.write(output);
|
|
|
|
|
|
- //总数
|
|
|
- int countTotal = canteenDiningRecordService.findCountByPersonIdAndAddress(searchParams1);
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+
|
|
|
+ downloadUrl = OSSUtil.upload(ossConfig,"canteenRearService","后勤人员就餐统计表.xls",input);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+ }
|
|
|
|
|
|
- searchParams2.put("category", "2");
|
|
|
- searchParams2.put("address", "行政食堂%");
|
|
|
+ return downloadUrl;
|
|
|
+ }
|
|
|
|
|
|
- //中餐
|
|
|
- int countLun = canteenDiningRecordService.findCountByPersonIdAndAddress(searchParams2);
|
|
|
|
|
|
- searchParams3.put("category", "3");
|
|
|
- searchParams3.put("address", "行政食堂%");
|
|
|
|
|
|
- //晚餐
|
|
|
- int countSup = canteenDiningRecordService.findCountByPersonIdAndAddress(searchParams3);
|
|
|
|
|
|
+ @ApiOperation(value="食堂后勤人员就餐详情")
|
|
|
+ @RequestMapping(value = "canteenRearServiceDetail",method = RequestMethod.POST)
|
|
|
+ public MessageResult<Object> canteenRearServiceDetail(
|
|
|
+ String recordTimeRange,String personId,String categoryStr,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
+ @RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
|
|
|
- BigDecimal decLun = BigDecimal.valueOf(countLun);
|
|
|
- BigDecimal decSup = BigDecimal.valueOf(countSup);
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
|
|
|
- int countOther = countTotal - countLun - countSup;
|
|
|
+ MessageResult<Object> msgResult = new MessageResult<>();
|
|
|
|
|
|
- BigDecimal decOther = BigDecimal.valueOf(countOther);
|
|
|
|
|
|
- BigDecimal totalFee = BigDecimal.ZERO;
|
|
|
+ try {
|
|
|
|
|
|
- totalFee = totalFee.add(lunFee.multiply(decLun));
|
|
|
- totalFee = totalFee.add(supFee.multiply(decSup));
|
|
|
- totalFee = totalFee.add(decOther);
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
|
|
- map.put("totalFee",totalFee);
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("record_time", "desc"));
|
|
|
|
|
|
-// List<CanteenDiningRecord> list = canteenDiningRecordService.findByPersonId(personId);
|
|
|
-// for (CanteenDiningRecord canteenDiningRecord:list) {
|
|
|
-// if (canteenDiningRecord.getCategory().equals("2") && canteenDiningRecord.getAddress().contains("行政食堂")) {
|
|
|
-// totalFee = totalFee.add(lunFee);
|
|
|
-// } else if (canteenDiningRecord.getCategory().equals("3") && canteenDiningRecord.getAddress().contains("行政食堂")) {
|
|
|
-// totalFee = totalFee.add(supFee);
|
|
|
-// } else {
|
|
|
-// totalFee = totalFee.add(BigDecimal.ONE);
|
|
|
-// }
|
|
|
-// }
|
|
|
+ if (StringUtils.isNotEmpty(recordTimeRange)) {
|
|
|
+ String[] timeRangeArray = recordTimeRange.split(",");
|
|
|
+ String beginTime = "";
|
|
|
+ String endTime = "";
|
|
|
+ beginTime+=" 00:00:00";
|
|
|
+ if (timeRangeArray.length == 1) {
|
|
|
+ beginTime = timeRangeArray[0];
|
|
|
+ } else if (timeRangeArray.length == 2) {
|
|
|
+ beginTime = timeRangeArray[0];
|
|
|
+ endTime = timeRangeArray[1];
|
|
|
+ beginTime+=" 00:00:00";
|
|
|
+ endTime+=" 23:59:59";
|
|
|
}
|
|
|
|
|
|
+ searchParams.put("beginTime", beginTime);
|
|
|
+ searchParams.put("endTime", endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ searchParams.put("personId", personId);
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(categoryStr)){
|
|
|
+ searchParams.put("category", categoryStr);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Page<CanteenDiningRecord> page = canteenDiningRecordService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
+
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+
|
|
|
+ for (CanteenDiningRecord canteenDiningRecord : page) {
|
|
|
+ Map map = new HashMap();
|
|
|
+ String personName="";
|
|
|
+ String jobNumber="";
|
|
|
+ String companyName="";
|
|
|
+ String recordTime="";
|
|
|
+ String categoryN="";
|
|
|
+
|
|
|
+ PersonInfo personInfo = personInfoService.get(canteenDiningRecord.getPersonId());
|
|
|
+ if(personInfo!=null){
|
|
|
+ personName = personInfo.getName();
|
|
|
+ jobNumber = personInfo.getJobNumber();
|
|
|
+
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ if(companyInfo!=null){
|
|
|
+ if(StringUtils.isNotEmpty(companyInfo.getFullName())){
|
|
|
+ companyName = companyInfo.getFullName();
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ companyName = companyInfo.getName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("companyName",companyName);
|
|
|
+ map.put("personName",personName);
|
|
|
+ map.put("jobNumber",jobNumber);
|
|
|
+ if(StringUtils.isNotEmpty(canteenDiningRecord.getCategory())){
|
|
|
+ if(canteenDiningRecord.getCategory().equals("2")){
|
|
|
+ categoryN="中餐";
|
|
|
+ }
|
|
|
+ else if(canteenDiningRecord.getCategory().equals("3")){
|
|
|
+ categoryN="晚餐";
|
|
|
+ }
|
|
|
+ else if(canteenDiningRecord.getCategory().equals("4")){
|
|
|
+ categoryN="宵夜";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("category",categoryN);
|
|
|
+ map.put("categoryAmount",canteenDiningRecord.getCategoryAmount());
|
|
|
+ if(canteenDiningRecord.getRecordTime()!=null){
|
|
|
+ recordTime = sdf.format(canteenDiningRecord.getRecordTime());
|
|
|
+ }
|
|
|
+ map.put("recordTime",recordTime);
|
|
|
+ map.put("address",canteenDiningRecord.getAddress());
|
|
|
+
|
|
|
mapList.add(map);
|
|
|
}
|
|
|
|
|
|
if(exportFlag) {
|
|
|
- String filePath = canteenExportXls(mapList);
|
|
|
+ String filePath = canteenDetailExportXls(mapList);
|
|
|
msgResult.setData(filePath);
|
|
|
}
|
|
|
else{
|
|
@@ -225,7 +317,8 @@ public class CanteenRearServiceController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private String canteenExportXls(List<Map> mapList) throws IOException {
|
|
|
+
|
|
|
+ private String canteenDetailExportXls(List<Map> mapList) throws IOException {
|
|
|
String downloadUrl = "";
|
|
|
|
|
|
Workbook workbook = new HSSFWorkbook();
|
|
@@ -234,7 +327,7 @@ public class CanteenRearServiceController {
|
|
|
//表头
|
|
|
Row rowTitle = sheet.createRow(0);
|
|
|
|
|
|
- String[] titles = new String[]{"序号","部门","工号","姓名","中餐就餐总数","晚餐就餐总数", "宵夜就餐总数","总计总数","就餐金额(元)",};
|
|
|
+ String[] titles = new String[]{"序号","部门","工号","姓名","就餐时间","就餐地点", "餐别","就餐金额(元)",};
|
|
|
|
|
|
for (int i=0;i<titles.length;i++) {
|
|
|
Cell cell = rowTitle.createCell(i);
|
|
@@ -251,11 +344,10 @@ public class CanteenRearServiceController {
|
|
|
row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("companyName"),""));
|
|
|
row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("jobNumber"),""));
|
|
|
row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("personName"),""));
|
|
|
- row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("lunch"),""));
|
|
|
- row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("supper"),""));
|
|
|
- row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("nightSnack"),""));
|
|
|
- row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("personNum"),""));
|
|
|
- row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("totalFee"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("recordTime"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("address"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("category"),""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.shinestar.modules.common.utils.StringUtils.strValue(map.get("categoryAmount"),""));
|
|
|
}
|
|
|
|
|
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
@@ -266,7 +358,7 @@ public class CanteenRearServiceController {
|
|
|
byte[] buffer = output.toByteArray();
|
|
|
ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
|
|
|
- downloadUrl = OSSUtil.upload(ossConfig,"canteenRearService","后勤人员就餐统计表.xls",input);
|
|
|
+ downloadUrl = OSSUtil.upload(ossConfig,"canteenRearServiceDetail","后勤人员就餐详情表.xls",input);
|
|
|
}
|
|
|
catch (Exception ex){
|
|
|
logger.error(ex.getMessage(),ex);
|