浏览代码

Merge remote-tracking branch 'origin/master'

zhengqiang 4 年之前
父节点
当前提交
a563264bc9

+ 6 - 0
common/src/main/java/com/jpsoft/shinestar/modules/base/entity/PersonInfo.java

@@ -245,4 +245,10 @@ public class PersonInfo implements Serializable {
 
     @ApiModelProperty(value = "车牌号")
     private String carNum;
+
+    @ApiModelProperty(value = "后勤人员类别")
+    private String hqStatus;
+
+    @ApiModelProperty(value = "后勤排序号")
+    private String hqSortNo;
 }

+ 39 - 33
common/src/main/resources/mapper/base/CanteenDiningRecord.xml

@@ -163,6 +163,9 @@
 			<if test="searchParams.personId != null">
 				and a.person_id = #{searchParams.personId}
 			</if>
+			<if test="searchParams.category != null">
+				and a.category_ = #{searchParams.category}
+			</if>
 			<if test="searchParams.isOutsourcer != null">
 				and a.is_outsourcer = #{searchParams.isOutsourcer}
 			</if>
@@ -436,13 +439,9 @@
         </foreach>
     </select>
 
-
-
-
 	<select id="canteenHqPersonList" parameterType="hashmap" resultType="hashmap">
-
-		SELECT count(a.person_id) as personNum,b.name_ as personName,b.job_number as jobNumber,c.name_ as companyName,a.person_id,
-		(SELECT count(z.person_id) from base_canteen_dining_record z WHERE z.person_id = a.person_id and  z.category_='2' and z.del_flag=FALSE
+		SELECT a.id_ as personId,a.job_number as jobNumber,a.name_ as personName,IFNULL(b.full_name, b.name_) as companyName,
+		(SELECT count(id_) FROM base_canteen_dining_record z WHERE z.person_id=a.id_ and z.del_flag=FALSE and z.category_='2'
 		<if test="searchParams.beginTime != null">
 			<![CDATA[
                   and z.record_time >= #{searchParams.beginTime}
@@ -454,7 +453,7 @@
 				]]>
 		</if>
 		) as 'lunch',
-		(SELECT count(z.person_id) from base_canteen_dining_record z WHERE z.person_id = a.person_id and  z.category_='3' and z.del_flag=FALSE
+		(SELECT count(id_) FROM base_canteen_dining_record z WHERE z.person_id=a.id_ and z.del_flag=FALSE and z.category_='3'
 		<if test="searchParams.beginTime != null">
 			<![CDATA[
                   and z.record_time >= #{searchParams.beginTime}
@@ -466,7 +465,31 @@
 				]]>
 		</if>
 		) as 'supper',
-		(SELECT count(z.person_id) from base_canteen_dining_record z WHERE z.person_id = a.person_id and  z.category_='4' and z.del_flag=FALSE
+		(SELECT count(id_) FROM base_canteen_dining_record z WHERE z.person_id=a.id_ and z.del_flag=FALSE and z.category_='4'
+		<if test="searchParams.beginTime != null">
+			<![CDATA[
+                  and z.record_time >= #{searchParams.beginTime}
+             ]]>
+		</if>
+		<if test="searchParams.endTime != null">
+			<![CDATA[
+				and z.record_time <= #{searchParams.endTime}
+			]]>
+		</if>
+		) as 'nightSnack',
+		(SELECT count(id_) FROM base_canteen_dining_record z WHERE z.person_id=a.id_ and z.del_flag=FALSE
+		<if test="searchParams.beginTime != null">
+			<![CDATA[
+                  and z.record_time >= #{searchParams.beginTime}
+             ]]>
+		</if>
+		<if test="searchParams.endTime != null">
+			<![CDATA[
+				and z.record_time <= #{searchParams.endTime}
+			]]>
+		</if>
+		) as 'personNum',
+		(SELECT IFNULL(sum(z.category_amount), 0.0) FROM base_canteen_dining_record z WHERE z.person_id=a.id_ and z.del_flag=FALSE
 		<if test="searchParams.beginTime != null">
 			<![CDATA[
                   and z.record_time >= #{searchParams.beginTime}
@@ -477,39 +500,22 @@
 				and z.record_time <= #{searchParams.endTime}
 			]]>
 		</if>
-		) as 'nightSnack'
-		FROM base_canteen_dining_record a
-		inner join base_person_info b on a.person_id=b.id_
-		inner join base_company_info c on b.company_id = c.id_
+		) as 'totalFee'
+		FROM base_person_info a
+		left join base_company_info b on a.company_id=b.id_
 		<where>
-			a.del_flag = FALSE and b.del_flag = FALSE and c.del_flag = FALSE
+			a.del_flag = FALSE and b.del_flag = FALSE
 			<if test='searchParams.companyCode!=null'>
-				and c.code_ like #{searchParams.companyCode}
+				and b.code_ like #{searchParams.companyCode}
 			</if>
 			<if test="searchParams.hqStatus != null">
-				and a.person_id in(
-				select person_id from base_hq_person
-				where hq_status=#{searchParams.hqStatus}
-				and del_flag=0
-				)
+				and a.hq_status = #{searchParams.hqStatus}
 			</if>
 			<if test="searchParams.querHq != null">
-				and a.person_id in(
-				select person_id from base_hq_person
-				where del_flag=0
-				)
-			</if>
-			<if test="searchParams.beginTime != null">
 				<![CDATA[
-                  and a.record_time >= #{searchParams.beginTime}
-                ]]>
-			</if>
-			<if test="searchParams.endTime != null">
-				<![CDATA[
-                  and a.record_time <= #{searchParams.endTime}
-                ]]>
+					and a.hq_status <> '0' and a.hq_status is not null
+				]]>
 			</if>
-			GROUP BY a.person_id
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 			${sort.name} ${sort.order}

+ 12 - 8
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -43,7 +43,8 @@
         <result property="workStatus" column="work_status"/>
         <result property="jobNumber" column="job_number"/>
         <result property="carNum" column="car_num"/>
-
+        <result property="hqSortNo" column="hq_sort_no"/>
+        <result property="hqStatus" column="hq_status"/>
     </resultMap>
     <insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.PersonInfo">
         <selectKey resultType="long" keyColumn="id_" keyProperty="id">
@@ -55,7 +56,7 @@
 	    app_enabled,password_enabled,guest_enabled,position1_,position2_,
 	    position3_,position4_,position5_,face_image_url,del_flag,
 	    create_by,create_time,update_by,update_time,popedom_,wechat_notice_enabled,allow_view_local,health_ertificate_url,is_sync,sex_,
-	    park_id,work_status,job_number,car_num)
+	    park_id,work_status,job_number,car_num,hq_sort_no,hq_status)
 		values
 		(
             #{companyId,jdbcType=VARCHAR}
@@ -90,7 +91,8 @@
             ,#{workStatus,jdbcType=VARCHAR}
             ,#{jobNumber,jdbcType=VARCHAR}
             ,#{carNum,jdbcType=VARCHAR}
-
+            ,#{hqSortNo,jdbcType= NUMERIC }
+            ,#{hqStatus,jdbcType=VARCHAR}
 		)
 	]]>
     </insert>
@@ -199,6 +201,12 @@
             <if test="carNum != null">
                 car_num = #{carNum,jdbcType=VARCHAR}
             </if>
+            <if test="isHq != null">
+                is_hq = #{isHq,jdbcType=NUMERIC}
+            </if>
+            <if test="hqStatus != null">
+                hq_status = #{hqStatus,jdbcType=VARCHAR}
+            </if>
         </set>
         where id_=#{id}
     </update>
@@ -409,11 +417,7 @@
                 </if>
             </trim>
             <if test="searchParams.hqStatus != null">
-                and a.id_ in(
-                    select person_id from base_hq_person
-                    where find_in_set(hq_status,#{searchParams.hqStatus})>0
-                    and del_flag=0
-                )
+                and a.hq_status = #{searchParams.hqStatus}
             </if>
             <if test="searchParams.querHq != null">
                 and a.id_ in(

+ 173 - 78
web/src/main/java/com/jpsoft/shinestar/modules/base/controller/CanteenRearServiceController.java

@@ -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("a.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);
             }
 
 
@@ -133,78 +116,190 @@ public class CanteenRearServiceController {
 
             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);
+        }
 
-            for (Map map : page) {
-                if(map.get("person_id")!=null){
-                    Long personId = Long.parseLong(map.get("person_id").toString());
+        return msgResult;
+
+    }
+
+
+    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"),""));
+        }
+
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+
+        try {
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            downloadUrl = OSSUtil.upload(ossConfig,"canteenRearService","后勤人员就餐统计表.xls",input);
+        }
+        catch (Exception ex){
+            logger.error(ex.getMessage(),ex);
+        }
+
+        return downloadUrl;
+    }
 
-                    searchParams1.put("personId", personId);
-                    searchParams2.put("personId", personId);
-                    searchParams3.put("personId", personId);
 
-                    //总数
-                    int countTotal = canteenDiningRecordService.findCountByPersonIdAndAddress(searchParams1);
 
-                    searchParams2.put("category", "2");
-                    searchParams2.put("address", "行政食堂%");
 
-                    //中餐
-                    int countLun = canteenDiningRecordService.findCountByPersonIdAndAddress(searchParams2);
+    @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) {
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Object> msgResult = new MessageResult<>();
+
+
+        try {
+
+            Map<String, Object> searchParams = new HashMap<>();
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("record_time", "desc"));
 
-                    searchParams3.put("category", "3");
-                    searchParams3.put("address", "行政食堂%");
+            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";
+                }
 
-                    //晚餐
-                    int countSup = canteenDiningRecordService.findCountByPersonIdAndAddress(searchParams3);
+                searchParams.put("beginTime", beginTime);
+                searchParams.put("endTime", endTime);
+            }
 
 
-                    BigDecimal decLun = BigDecimal.valueOf(countLun);
-                    BigDecimal decSup = BigDecimal.valueOf(countSup);
+            searchParams.put("personId", personId);
 
-                    int countOther = countTotal - countLun - countSup;
+            if(StringUtils.isNotEmpty(categoryStr)){
+                searchParams.put("category", categoryStr);
+            }
 
-                    BigDecimal decOther = BigDecimal.valueOf(countOther);
 
-                    BigDecimal totalFee = BigDecimal.ZERO;
+            Page<CanteenDiningRecord> page = canteenDiningRecordService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 
-                    totalFee = totalFee.add(lunFee.multiply(decLun));
-                    totalFee = totalFee.add(supFee.multiply(decSup));
-                    totalFee = totalFee.add(decOther);
+            List<Map> mapList = new ArrayList<>();
 
-                    map.put("totalFee",totalFee);
+            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();
+                        }
+                    }
+                }
 
-//                    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);
-//                        }
-//                    }
+                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 +320,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 +330,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 +347,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 +361,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);