lxy_01 2 주 전
부모
커밋
acf6d8e9ac

+ 8 - 2
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/MealApplicationsController.java

@@ -13,13 +13,16 @@ import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
 import com.management.platform.entity.MealApplications;
 import com.management.platform.entity.User;
 import com.management.platform.service.MealApplicationsService;
+import com.management.platform.service.MealTypesService;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletRequest;
 import java.awt.image.BufferedImage;
@@ -132,7 +135,7 @@ public class MealApplicationsController {
             return msg.fail("二维码不存在");
         }
         msg.setData(mealApplications);
-      return msg;
+        return msg;
     }
     /**
      * 生成二维码并返回Base64编码
@@ -162,7 +165,10 @@ public class MealApplicationsController {
         return "data:image/png;base64," + Base64.getEncoder().encodeToString(bytes);
     }
 
-
+    @RequestMapping("/getMealApplicationList")
+    private HttpRespMsg getMealApplicationList(String deptIds, String userId, String startDate, String endDate, Integer pageIndex, Integer pageSize,Integer mealTypeId){
+        return  mealApplicationsService.getMealApplicationList(deptIds,userId,startDate,endDate,pageIndex,pageSize,mealTypeId);
+    }
 
 }
 

+ 6 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/MealTypesController.java

@@ -77,5 +77,11 @@ public class MealTypesController {
         return msg;
     }
 
+    @RequestMapping("/getMealTypeList")
+    private HttpRespMsg getMealTypeList() {
+        return mealTypesService.getMealTypeList();
+    }
+
+
 }
 

+ 6 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/mapper/MealApplicationsMapper.java

@@ -2,6 +2,11 @@ package com.management.platform.mapper;
 
 import com.management.platform.entity.MealApplications;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.management.platform.util.HttpRespMsg;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -13,4 +18,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface MealApplicationsMapper extends BaseMapper<MealApplications> {
 
+    List<Map<String, Object>> getMealList(Integer companyId, String startDate, String endDate, @Param("list") List<Integer> deptId, String userId,String mealTypeIdString);
 }

+ 3 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/MealApplicationsService.java

@@ -19,4 +19,7 @@ public interface MealApplicationsService extends IService<MealApplications> {
     HttpRespMsg writeOffCode(String code);
 
     HttpRespMsg getTodayStatistics();
+    HttpRespMsg getDinnerBookingList(String date);
+
+    HttpRespMsg getMealApplicationList(String deptIds, String userId, String startDate, String endDate, Integer pageIndex, Integer pageSize, Integer mealTypeId);
 }

+ 3 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/MealTypesService.java

@@ -2,6 +2,7 @@ package com.management.platform.service;
 
 import com.management.platform.entity.MealTypes;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.management.platform.util.HttpRespMsg;
 
 /**
  * <p>
@@ -13,4 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface MealTypesService extends IService<MealTypes> {
 
+    HttpRespMsg getMealTypeList();
+
 }

+ 180 - 9
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/MealApplicationsServiceImpl.java

@@ -1,25 +1,25 @@
 package com.management.platform.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.management.platform.entity.MealApplications;
-import com.management.platform.entity.MealTypes;
-import com.management.platform.entity.User;
-import com.management.platform.entity.Factory;
-import com.management.platform.mapper.FactoryMapper;
-import com.management.platform.mapper.MealApplicationsMapper;
-import com.management.platform.mapper.MealTypesMapper;
-import com.management.platform.mapper.UserMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.management.platform.entity.*;
+import com.management.platform.mapper.*;
 import com.management.platform.service.MealApplicationsService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -43,6 +43,15 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
     private UserMapper userMapper;
     @Resource
     private FactoryMapper factoryMapper;
+    @Resource
+    private DepartmentMapper departmentMapper;
+
+
+    @Override
+    public HttpRespMsg getDinnerBookingList(String date) {
+        return null;
+    }
+
 
     //获取当天订餐列表
     @Override
@@ -169,4 +178,166 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
         msg.setData(mealTypesList);
         return msg;
     }
+
+
+    @Override
+    public HttpRespMsg getMealApplicationList(String deptIds, String userId, String startDate, String endDate, Integer pageIndex, Integer pageSize, Integer mealTypeId) {
+        HttpRespMsg httpRespMsg=new HttpRespMsg();
+        HashMap resultMap=new HashMap();
+        DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        DateTimeFormatter dtf1=DateTimeFormatter.ofPattern("yyyyMMdd");
+        List<LocalDate> dateList = getDays(LocalDate.parse(startDate, dtf), LocalDate.parse(endDate, dtf));
+        List<String> dataStringList=new ArrayList<>();
+        //日期列表
+        for (LocalDate localDate : dateList) {
+            dataStringList.add(localDate.format(dtf1));
+        }
+        resultMap.put("header",dataStringList);
+
+        User user = userMapper.selectById(request.getHeader("token"));
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
+        Integer companyId = user.getCompanyId();
+
+        QueryWrapper<User> queryWrapper=new QueryWrapper<>();
+        queryWrapper.eq("company_id",companyId);
+        List<Integer> deptIdList=new ArrayList<>();
+        if(deptIds!=null&&!StringUtils.isEmpty(deptIds)){
+            String[] split = deptIds.split(",");
+            for (String deptId : split) {
+                List<Integer> branchDepartment = getBranchDepartment(Integer.valueOf(deptId), departmentList);
+                deptIdList.addAll(branchDepartment);
+            }
+            queryWrapper.in("department_id",deptIdList);
+        }
+        if(!StringUtils.isEmpty(userId)){
+            queryWrapper.eq("id",userId);
+        }
+        String mealTypeIdString = "";
+        if(mealTypeId!=null){
+            mealTypeIdString = mealTypeId.toString();
+        }
+
+        queryWrapper.eq("is_active",1);
+        queryWrapper.orderByAsc("department_id");
+        IPage<User> userIPage = userMapper.selectPage(new Page<>(pageIndex, pageSize), queryWrapper);
+        List<User> userList = userIPage.getRecords();
+
+        //先将数据全部取出来,再根据人员和部门进行筛选
+        List<Map<String,Object>>  mealList = mealApplicationsMapper.getMealList(companyId,startDate,endDate,deptIdList,userId,mealTypeIdString);
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+        for(Map<String,Object>mealMap:mealList){
+            //mealMap.get("date")为Date类型
+            if(mealMap.get("date") != null && mealMap.get("date") instanceof Date) {
+                Date date = (Date) mealMap.get("date");
+                mealMap.put("date",sdf.format(date));
+            }
+
+        }
+
+        //
+        List<Map<String,Object>> totalList=new ArrayList<>();
+        for (String date : dataStringList) {
+            Map<String,Object> map=new HashMap<>();
+            List<Map<String, Object>> targetList = mealList.stream().filter(p -> p.get("date").equals(date)).collect(Collectors.toList());
+            int ApplyAmount=0;//总报餐
+            int getMeal=0;//已用餐
+            int cancel=0;//已取消
+            int overLine=0;//已过期
+            for (Map<String, Object> mealMap : targetList) {
+                Integer status = (Integer)  mealMap.get("status");
+                if (status != null) {
+                    switch (status) {
+                        case 0 :
+                            ApplyAmount += 1;
+                            break;
+                        case 1:
+                            ApplyAmount += 1;
+                            getMeal += 1;
+                            break;
+                        case 2:
+                            cancel += 1;
+                        case  3:
+                            ApplyAmount += 1;
+                            cancel += 1;
+                            break;
+                        default:
+                            break;
+                    }
+                }
+            }
+
+            map.put("userId","0");
+            map.put("date",date);
+            map.put("applyAmount",ApplyAmount);//总报餐
+            map.put("getMeal",getMeal);//已用餐
+            map.put("cancel",cancel);//已取消
+            map.put("overLine",overLine);//已过期
+            totalList.add(map);
+        }
+
+        mealList.addAll(totalList);
+
+        List<Map<String,Object>> records= new ArrayList<>();
+        if(!StringUtils.isEmpty(deptIds)){
+            String[] split = deptIds.split(",");
+            for (String deptId : split) {
+                List<Integer> branchDepartment = getBranchDepartment(Integer.valueOf(deptId), departmentList);
+                deptIdList.addAll(branchDepartment);
+            }
+        }
+
+
+        for(User itemUser:userList){
+            Map<String,Object> map=new HashMap<>();
+            String personId = itemUser.getId();
+            map.put("userId",itemUser.getId());
+            map.put("name",itemUser.getName());
+            if (map.get("userId").equals("0")) {
+                map.put("name","小计");
+            }
+            map.put("departmentId",itemUser.getDepartmentId());
+            String departmentName="未设置部门";
+
+            Integer departmentId = Integer.valueOf(String.valueOf(map.get("departmentId")));
+            map.put("departmentName", getBranchDepartment(departmentId, departmentList));
+
+            List<Map<String,Object>> personList = new ArrayList<>();
+            if (personId!= null){
+                personList = totalList.stream().filter(p -> p.get("userId").equals(personId)).collect(Collectors.toList());
+            }
+            map.put("personList",personList);
+
+            records.add(map);
+        }
+        resultMap.put("total",userIPage.getTotal());
+        resultMap.put("records",records);
+        httpRespMsg.setData(resultMap);
+
+
+        return httpRespMsg;
+    }
+
+
+    private  List<LocalDate> getDays(LocalDate start, LocalDate end) {
+        List<LocalDate> result = new ArrayList();
+        while (start.isBefore(end)) {
+            result.add(start);
+            start=start.plusDays(1);
+        }
+        result.add(start);
+        return result;
+    }
+
+    private List<Integer> getBranchDepartment(Integer departmentId, List<Department> departmentList) {
+        List<Integer> list = new ArrayList<>();
+        list.add(departmentId);
+        //搜到子部门进行添加
+        for (Department department : departmentList) {
+            if (departmentId.equals(department.getSuperiorId())) {
+                list.addAll(getBranchDepartment(department.getDepartmentId(), departmentList));
+            }
+        }
+        return list;
+    }
 }

+ 17 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/MealTypesServiceImpl.java

@@ -1,11 +1,16 @@
 package com.management.platform.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.management.platform.entity.MealTypes;
 import com.management.platform.mapper.MealTypesMapper;
 import com.management.platform.service.MealTypesService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.management.platform.util.HttpRespMsg;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.*;
+
 /**
  * <p>
  *  服务实现类
@@ -16,5 +21,17 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class MealTypesServiceImpl extends ServiceImpl<MealTypesMapper, MealTypes> implements MealTypesService {
+    @Resource
+    private MealTypesMapper mealTypesMapper;
+
+
+    @Override
+    public HttpRespMsg getMealTypeList() {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+
+        httpRespMsg.data = mealTypesMapper.selectList(new QueryWrapper<MealTypes>().eq("is_active",1));
+
+        return  httpRespMsg;
+    }
 
 }

+ 27 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/resources/mapper/MealApplicationsMapper.xml

@@ -25,4 +25,31 @@
         id, user_id, application_date, meal_type_id, factory_id, status, qr_code, applied_at, used_at, cancelled_at, cancel_reason, created_at, updated_at, code
     </sql>
 
+    <select id="getMealList" resultType="java.util.Map">
+        select u.id as userId,u.department_id,d.department_name AS departmentName,u.name AS userName,ma.status as status,ma.application_date as date,ma.meal_type_id as mealTypeIdString
+        FROM user u
+        left join meal_applications ma on u.id = ma.user_id
+        left join department d on u.department_id = d.department_id
+        where ma.status!= 2
+            <if test="userId!=null and userId.length() > 0">
+                and u.id = #{userId}
+            </if>
+
+            <if test="list!=null and list.size()>0">
+                and u.department_id in
+                <foreach collection="list" close=")" open="(" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="startDate!=null and startDate!='' and  endDate!=null and endDate!=''">
+                and ma.application_date between #{startDate} and #{endDate}
+            </if>
+
+            <if test="mealTypeIdString != null">
+                and ma.meal_type_id = #{mealTypeIdString}
+            </if>
+
+    </select>
+
 </mapper>

+ 127 - 2
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/statistic/index.vue

@@ -24,6 +24,7 @@
                   <el-menu-item index="1-5"  @click="ssl(4)"><p>{{'部门生产统计表'}}</p></el-menu-item>
                   <el-menu-item index="1-6"  @click="ssl(5)"><p>{{'月生产件数报表'}}</p></el-menu-item>
                   <el-menu-item index="1-7"  @click="ssl(6)"><p>{{'车间工位计划表'}}</p></el-menu-item>
+                  <el-menu-item index="1-8"  @click="ssl(7)"><p>{{'报餐数据表'}}</p></el-menu-item>
                 </el-submenu>
               </el-menu>
           </el-col>
@@ -62,6 +63,15 @@
               <el-date-picker v-model="rangeDatas" type="daterange" value-format="yyyy-MM-dd" :placeholder="$t('selectstartdate')" @change="picks()" :range-separator="$t('other.to')" :start-placeholder="$t('time.startDate')" :end-placeholder="$t('time.endDate')" style="width:240px" :clearable="ins == 15" size="small"> </el-date-picker>
             </span>
           </template>
+          <!-- 选择餐别 -->
+          <el-select v-if="ins == 7" v-model="mealTypeId" :placeholder="'请选择餐别'" @change="selcts()" clearable size="small" style="width:100px;margin-left:10px">
+            <el-option 
+              v-for="(meal, index) in mealTypeList" 
+              :key="index" 
+              :label="meal.name" 
+              :value="meal.id"
+            ></el-option>
+          </el-select>
 
           <br />
           <!-- 车辆序号 -->
@@ -291,6 +301,43 @@
                   </template>
                 </el-table-column>
             </el-table>
+            
+            <!-- 报餐数据表 -->
+            <el-table v-if="ins == 7"  :key="8" border :data="mealApplicationList" highlight-current-row v-loading="listLoading" :height="+tableHeight - 1" style="width: 100%;">
+                <el-table-column align="center" prop="departmentCascade" label="部门名称" min-width="150" fixed="left">
+                  <template slot-scope="scope">
+                    {{scope.row.departmentCascade}}
+                  </template>
+                </el-table-column>
+                <el-table-column align="center" prop="name" label="人员" min-width="100" fixed="left"></el-table-column>
+                <el-table-column v-for="(item, index) in personWorkHoursWagesHead" :key="index" :label="item" align="center" min-width="150">
+                    <template slot-scope="scope">
+                        <div v-for="(items, indexs) in scope.row.personWorkHoursWages" :key="indexs" :class="`${scope.row.departmentCascade== '小计' ? '' : 'colorText'}`">
+                            <div v-if="items.crateDate == item" @click.stop="showReportDetail(scope.row,item,0)">
+                              <div  style="color: black;" v-if="items.planWorkTime">平均 {{items.planWorkTime}}分钟  {{items.planCost}}元</div>
+                              <!-- <div @click.stop="showReportDetail(scope.row,item,0)" v-if="items.workTime>0">已填 {{items.workTime}}分钟  {{items.cost}}元 </div>{{items.leave}}
+                              <div style="color: green;" @click.stop="showTempReportDetail(scope.row,item,0)" v-if="items.tempWorkTime>0||items.tempCost>0">临时报工 {{items.tempWorkTime}}分钟  {{items.tempCost}}元</div> -->
+                              <div  v-if="items.workTime>0">已填 {{items.workTime}}分钟  {{items.cost}}元 </div>{{items.leave}}
+                              <div style="color: green;" v-if="items.tempWorkTime>0||items.tempCost>0">临时报工 {{items.tempWorkTime}}分钟  {{items.tempCost}}元</div>
+                              <div style="color: red;" v-if="items.surplusTime">剩余 {{items.surplusTime}}分钟  {{items.surplusCost}}元</div>
+                            </div>
+                        </div>
+                    </template>
+                </el-table-column>
+                <el-table-column align="center" prop="totalResult" label="合计" min-width="180">
+                   <template slot-scope="scope" >
+                    <div @click="showReportDetail(scope.row,item,1)">
+                      <div style="color: black;">{{scope.row.totalPlanResult | formatStr('平均') }}</div>
+                      <!-- <div style="color: #02a7f0;"  @click="showReportDetail(scope.row,item,1)"> {{scope.row.totalResult | formatStr('已填')}}</div> 
+                      <div style="color: green;"  @click="showTempReportDetail(scope.row,item,1)">{{scope.row.totalTempResult | formatStr('临时报工')}}</div>  -->
+                      <div style="color: #02a7f0;" > {{scope.row.totalResult | formatStr('已填')}}</div> 
+                      <div style="color: green;" >{{scope.row.totalTempResult | formatStr('临时报工')}}</div> 
+                      <div style="color: red;">{{scope.row.totalSurplusResult | formatStr('剩余') }}</div>
+                    </div>
+                  </template>
+                </el-table-column>
+            </el-table>
+            
 
         <!--工具条-->
         <el-col :span="24" class="toolbar" v-if="ins != 6">
@@ -577,9 +624,9 @@ export default {
       z   : null,
       value: null,
       dialog: false, // 单据查看展示
-      shuz: ['人员工时工价表', '工序实时进度表','报工查询表','计划实时进度表','部门生产统计表','月度生产件数表','车间工位计划表'],
+      shuz: ['人员工时工价表', '工序实时进度表','报工查询表','计划实时进度表','部门生产统计表','月度生产件数表','车间工位计划表','报餐数据表'],
 
-      shuzArr: ['人员工时工价表', '工序实时进度表','报工查询表','计划实时进度表','部门生产统计表','月度生产件数表','车间工位计划表'],
+      shuzArr: ['人员工时工价表', '工序实时进度表','报工查询表','计划实时进度表','部门生产统计表','月度生产件数表','车间工位计划表','报餐数据表'],
 
       ins: 10000,
       user: JSON.parse(sessionStorage.user),
@@ -680,6 +727,14 @@ export default {
       isViewUser:false,
       exportDeptId:null,
 
+      //报餐数据相关
+      mealApplicationList:[],
+      mealTypeId:1,
+      mealTypeList: [
+      { name: '饿哇噶', id: 1 },
+      { name: '第三方', id: 2}
+      ],
+
       //筛选项
       productId:"",
       productList:[],
@@ -706,6 +761,8 @@ export default {
     window.onresize = function temp() {
         that.tableHeight = window.innerHeight - 175;
     };
+    //加载餐别
+    this.getMealTypeList()
   },
 
   mounted() {
@@ -1286,6 +1343,68 @@ export default {
           });
         });
     },
+    //报餐数据表
+    getMealApplication(){
+      
+      let deptArr = []
+        for(var i in this.departmentIdArray){
+          let itemList = this.departmentIdArray[i] 
+          deptArr.push(itemList[itemList.length - 1])
+        }
+      
+      let param= {
+          startDate:this.rangeDatas[0],
+          endDate:this.rangeDatas[1],
+          pageIndex: this.page,
+          pageSize: this.size,
+          deptIds:deptArr.join(','),
+          userId:this.userId,
+          mealTypeId:this.mealTypeId,
+      }
+      console.log(param)
+      
+      this.http.post( "/meal-applications/getMealApplicationList",param,
+        res => {
+          if (res.code == "ok") {
+            console.log(res.data)
+            
+          } else {
+            this.$message({
+              message: res.msg,
+              type: "error"
+            });
+          }
+        },error => {
+          this.$message({
+            message: error,
+            type: "error"
+          });
+        });
+
+    },
+    //获取餐别
+    getMealTypeList(){
+      this.http.post( "/meal-types/getMealTypeList",{},
+        res => {
+          if (res.code == "ok") {
+            this.mealTypeList = res.data
+            if (this.mealTypeList.length > 0) {
+              this.mealTypeId = this.mealTypeList[0].id;
+              }
+          } else {
+            this.$message({
+              message: res.msg,
+              type: "error"
+            });
+          }
+        },error => {
+          this.$message({
+            message: error,
+            type: "error"
+          });
+        });
+      
+    },
     // 获取相同名称的个数 tableData: 表格的数据, productId: 确定相同的参数
     handleTableData(tableData){
           let rowSpanArr = [], position = 0;
@@ -1436,6 +1555,8 @@ export default {
             this.getProductionQuantityList()
         }else if(this.ins==6){
             this.getPlanDataWithStation()
+        }else if(this.ins==7){
+            this.getMealApplication()
         }
     },
     exportExcel() {
@@ -1593,6 +1714,10 @@ export default {
         //TODO: 获取数据
         this.getPlanDataWithStation()
       }
+      if(this.ins == 7){
+        //TODO: 获取数据
+        this.getMealApplication()
+      }
     },
     // 日期
     getCurrentRangeTime() {