Min 1 tahun lalu
induk
melakukan
e3acde133d

+ 15 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/PlanController.java

@@ -3,6 +3,7 @@ package com.management.platform.controller;
 
 import com.management.platform.entity.Plan;
 import com.management.platform.entity.PlanProcedureTotal;
+import com.management.platform.entity.ProdProcedureTeam;
 import com.management.platform.service.PlanService;
 import com.management.platform.util.HttpRespMsg;
 import org.apache.ibatis.annotations.Param;
@@ -84,6 +85,20 @@ public class PlanController {
     public HttpRespMsg teamAllocation(PlanProcedureTotal planProcedureTotal, String teamIds,Integer planType) throws Exception {
         return planService.teamAllocation(planProcedureTotal,teamIds,planType);
     }
+    /*换人操作*/
+    @RequestMapping("/changePeople")
+    public HttpRespMsg changePeople(ProdProcedureTeam prodProcedureTeam,String newPeopleId){
+        return planService.changePeople(prodProcedureTeam,newPeopleId);
+    }
+
+    @RequestMapping("/deletePeople")
+    public HttpRespMsg deletePeople(Integer id){
+        return planService.deletePeople(id);
+    }
 
+    @RequestMapping("/receivePlan")
+    public HttpRespMsg receivePlan(String ids){
+        return planService.receivePlan(ids);
+    }
 }
 

+ 2 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/entity/Plan.java

@@ -219,6 +219,8 @@ public class Plan extends Model<Plan> {
      * 创建时间
      */
     @TableField("create_time")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat( pattern="yyyy-MM-dd HH:mm:ss")
     private LocalDateTime createTime;
 
     /**

+ 8 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/entity/PlanProcedureTotal.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
+import java.util.List;
+
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -63,6 +65,12 @@ public class PlanProcedureTotal extends Model<PlanProcedureTotal> {
     @TableField(exist = false)
     private Integer totalProgress;
 
+    @TableField(exist = false)
+    private List<ProdProcedureTeam> prodProcedureTeamList;
+
+    @TableField(exist = false)
+    private boolean canReceive;
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 3 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/entity/ProdProcedureTeam.java

@@ -80,6 +80,9 @@ public class ProdProcedureTeam extends Model<ProdProcedureTeam> {
     @TableField("status")
     private Integer status;
 
+    @TableField(exist = false)
+    private User user;
+
 
     @Override
     protected Serializable pkVal() {

+ 7 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/PlanService.java

@@ -3,6 +3,7 @@ package com.management.platform.service;
 import com.management.platform.entity.Plan;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.management.platform.entity.PlanProcedureTotal;
+import com.management.platform.entity.ProdProcedureTeam;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -35,4 +36,10 @@ public interface PlanService extends IService<Plan> {
     HttpRespMsg hasSetDeptDetail();
 
     HttpRespMsg teamAllocation(PlanProcedureTotal planProcedureTotal, String teamIds,Integer planType) throws Exception;
+
+    HttpRespMsg changePeople(ProdProcedureTeam prodProcedureTeam, String newPeopleId);
+
+    HttpRespMsg deletePeople(Integer id);
+
+    HttpRespMsg receivePlan(String ids);
 }

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

@@ -20,6 +20,7 @@ import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -792,6 +793,51 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
         return httpRespMsg;
     }
 
+    @Override
+    public HttpRespMsg receivePlan(String ids) {
+        HttpRespMsg msg=new HttpRespMsg();
+        if(StringUtils.isEmpty(ids)){
+            return msg;
+        }
+        List<String> idList =Arrays.asList(ids.split(","));
+        List<ProdProcedureTeam> procedureTeams = prodProcedureTeamService.list(new QueryWrapper<ProdProcedureTeam>().in("id", idList));
+        procedureTeams.forEach(pl->{
+            pl.setStatus(1);
+        });
+        if(!prodProcedureTeamService.updateBatchById(procedureTeams)){
+            msg.setError("验证失败");
+        }
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg deletePeople(Integer id) {
+        HttpRespMsg msg=new HttpRespMsg();
+        ProdProcedureTeam prodProcedureTeam = prodProcedureTeamService.getById(id);
+        if(prodProcedureTeam.getStatus()!=0){
+            msg.setError("非待接收状态无法删除");
+            return msg;
+        }
+        if(!prodProcedureTeamService.removeById(prodProcedureTeam)){
+            msg.setError("验证失败");
+        }
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg changePeople(ProdProcedureTeam prodProcedureTeam, String newPeopleId) {
+        HttpRespMsg msg=new HttpRespMsg();
+        ProdProcedureTeam p=new ProdProcedureTeam();
+        BeanUtils.copyProperties(prodProcedureTeam,p);
+        p.setId(null);
+        p.setUserId(newPeopleId);
+        p.setStatus(0);
+        if(!prodProcedureTeamService.save(p)){
+            msg.setError("验证失败");
+        }
+        return msg;
+    }
+
     @Override
     public HttpRespMsg teamAllocation(PlanProcedureTotal planProcedureTotal,String teamIds,Integer planType) throws Exception {
         HttpRespMsg msg=new HttpRespMsg();
@@ -813,20 +859,21 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
             List<ProdProcedureTeam> procedureTeamList = prodProcedureTeamService.list(new QueryWrapper<ProdProcedureTeam>().eq("plan_procedure_id",planProcedureTotal.getId()));
             List<User> userList = userMapper.selectBatchIds(Arrays.asList(team));
             //处理人员
-            procedureTeamList.stream().forEach(pt->{
-                if(!Arrays.asList(team).contains(pt.getUserId())){
-                    Integer cut = reportMapper.selectCount(new QueryWrapper<Report>().eq("user_procedure_team_id", pt.getId()));
-                    if(cut<1){
-                        prodProcedureTeamService.removeById(pt.getId());
-                    }
-                }
-            });
+//            procedureTeamList.stream().forEach(pt->{
+//                if(!Arrays.asList(team).contains(pt.getUserId())){
+//                    Integer cut = reportMapper.selectCount(new QueryWrapper<Report>().eq("user_procedure_team_id", pt.getId()));
+//                    if(cut<1){
+//                        prodProcedureTeamService.removeById(pt.getId());
+//                    }
+//                }
+//            });
             for (int i = 0; i < team.length; i++) {
                 ProdProcedureTeam prodProcedureTeam=new ProdProcedureTeam();
                 prodProcedureTeam.setCompanyId(companyId);
                 prodProcedureTeam.setPlanProcedureId(planProcedureTotal.getId());
                 prodProcedureTeam.setUserId(team[i]);
                 int finalI = i;
+                //已存在的人员更新处理
                 Optional<ProdProcedureTeam> first = procedureTeamList.stream().filter(pl -> pl.getUserId().equals(team[finalI])).findFirst();
                 if(first.isPresent()){
                     prodProcedureTeam.setId(first.get().getId());
@@ -874,6 +921,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
         HttpRespMsg msg=new HttpRespMsg();
         Plan plan = planMapper.selectOne(new QueryWrapper<Plan>().eq("id", id));
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        String userId = request.getHeader("token");
         if(plan!=null){
             switch (type){
                 case 0:
@@ -889,7 +937,18 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                             ps.setProdProcedure(first.get());
                         }
                         if(procedureTeams.size()>0){
-                            ps.setTeamIds(procedureTeams.stream().filter(pt->pt.getPlanProcedureId().equals(ps.getId())).map(ProdProcedureTeam::getUserId).distinct().collect(Collectors.joining(",")));
+                            List<ProdProcedureTeam> procedureTeamList = procedureTeams.stream().filter(pt -> pt.getPlanProcedureId().equals(ps.getId())).collect(Collectors.toList());
+                            ps.setTeamIds(procedureTeamList.stream().map(ProdProcedureTeam::getUserId).distinct().collect(Collectors.joining(",")));
+                            procedureTeamList.forEach(pt->{
+                                Optional<User> user = userList.stream().filter(ul -> ul.getId().equals(pt.getUserId())).findFirst();
+                                if(user.isPresent()){
+                                    pt.setUser(user.get());
+                                }
+                            });
+                            ps.setProdProcedureTeamList(procedureTeamList);
+                            if(procedureTeamList.stream().anyMatch(pl->pl.getStatus()==0&&pl.getUserId().equals(userId))){
+                                ps.setCanReceive(true);
+                            }
                             if(!StringUtils.isEmpty(ps.getTeamIds())){
                                 String userNames = userList.stream().filter(ul -> Arrays.asList(ps.getTeamIds().split(",")).contains(ul.getId())).collect(Collectors.toList())
                                         .stream().map(User::getName).collect(Collectors.joining(","));

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/planView/component/planComponent.vue

@@ -4,7 +4,7 @@
       <div class="planComponent_box" v-for="item, index in productList" :key="index">
         <div class="planComponent_Item">
           <div class="planComponent_ItemTop">
-            <div>{{ item.productName }}</div>
+            <div>{{ item.productName}}</div>
             <div>{{ item.productSchedulingNum }}</div>
             <div>
               <p>{{ item.startDate }}-{{ item.endDate }}</p><span @click="workShowHide(index)">{{ item.flg ? paiArr[0] : paiArr[1] }}</span>

+ 170 - 26
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/planView/todayPlan/distribution.vue

@@ -1,4 +1,5 @@
 <template>
+<div>
   <div class="distribution">
     <van-nav-bar :title="titleText" left-text="返回" :right-text="!todayAndTomorrow ? '下发计划' : ''" @click-left="back" @click-right="placeAnOrder" fixed left-arrow/>
     <div class="distribution_header">
@@ -9,14 +10,11 @@
     <div class="distribution_con contentRoll">
       <div class="distribution_box" v-for="item,index in distributionList" :key="index">
         <div class="distribution_ItemBom">
+          <van-checkbox v-model="item.prodProcedure.isSelected"  @click="itemChecked" shape="square">
+          </van-checkbox>
           <div class="PlanItem">
             <span>{{ item.prodProcedure.name }}</span>
           </div>
-          <div class="PlanItem" v-show="todayAndTomorrow">
-            <div>组员:</div>
-            <span class="" v-if="item.teamNames" @click="distributionProp(item,index)">{{ item.teamNames }} <van-icon name="edit" color="#1989fa" /> </span>
-            <span style="color: #1989fa;" v-if="!item.teamNames && beDeptList" @click="distributionProp(item,index)">分配</span>
-          </div>
           <div class="PlanItem">
             <div>单件工价:</div><span class="textBeyondHiding">{{ item.prodProcedure.workingTime }}</span>
           </div>
@@ -37,25 +35,68 @@
               {{ item.prodProcedure.checkType == 0 ? '自检' : item.prodProcedure.checkType == 1 ? '互检' : '专检' }}
             </span>
           </div>
+           <div class="PlanItem" v-show="todayAndTomorrow" style="width:100%">
+            <div>组员:</div>
+            <span class="" v-if="item.teamNames">{{ item.teamNames }}</span>
+            <span style="color: #1989fa;" v-if="!item.teamNames && beDeptList" @click="distributionProp(item,index)">分配</span>
+            <div>
+              <span style="color: #1989fa;" v-if="item.prodProcedureTeamList" @click="workShowHide(index)">{{ item.flg ? paiArr[0] : paiArr[1] }}</span>
+            </div>
+          </div>
+          <div>
+              <collapse>
+                <div v-if="item.flg">
+                    <div>
+                      <div class="distribution_box" v-for="second_item,index in item.prodProcedureTeamList " :key="index">
+                        <div class="distribution_ItemBom">
+                          <div class="PlanItem">
+                            <span>{{ second_item.user.name }}</span>
+                            <span>{{ second_item.status==0?"待接收":second_item.status==1?"进行中":second_item.status==2?"已完工":"已终止"}}</span>
+                            <span class="" v-if="second_item.status==3" @click="changePeople(second_item)"  style="color: #1989fa;">换人</span>
+                            <span class="" v-if="second_item.status==0" @click="deletePeople(second_item.id)"  style="color: #1989fa;">删除</span>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="PlanItem">
+                            <span class="" v-if="item.teamNames" @click="distributionProp(item,index)"  style="color: #1989fa;">新增</span>
+                          </div>
+                    </div>
+                </div>
+              </collapse>
+          </div>
         </div>
       </div>
     </div>
+    
     <!-- 弹出层选人 -->
     <van-popup v-model="popupShow" round position="bottom" :style="{ height: '80%',background: '#F4F4F4' }" >
       <ChooseSomeone ref="ChooseSomeone" :groupView="2" :groupViewBack="true" :peopleList="peopleList" @ChooseSomeoneChanhe="chooseSomeoneChanhe" :peopleListId="peopleListId"></ChooseSomeone>
     </van-popup>
   </div>
+<div class="formBatch">
+        <van-checkbox v-model="isAllChecked" :disabled="distributionList.length == 0" @click="allChecked" shape="square" style="padding-left:3vw"></van-checkbox>
+        <div style="padding:1vh 2vw">
+        <van-button @click="batchReceive()" :disabled="!isCanAgree || distributionList.length == 0" type="info" size="small">批量接收</van-button>
+        <!-- <van-button @click="batchAgree(false)" :disabled="!isCanAgree || distributionList.length == 0" type="danger" size="small" style="margin-left:2vw">批量驳回</van-button> -->
+        </div>
+    </div>
+</div>
 </template>
 
 <script>
 import ChooseSomeone from '../../../components/chooseSomeone.vue'
+import collapse from '../../../assets/collapse.js'
+import { CellGroup } from 'vant';
 export default {
   props: {},
   components: {
+    collapse,
     ChooseSomeone
   },
   data() {
     return {
+      isAllChecked:  false,
+      activeNames: ['1'],
       beDeptList: JSON.parse(localStorage.getItem('beDeptList')), // 是否为工长
       distributionList: [],
       distributionIndex: null,
@@ -70,13 +111,16 @@ export default {
 
       dates: '',
       productSchedulingNum: '',
-      productName: ''
+      productName: '',
+      isCanAgree:false,
+      user: JSON.parse(localStorage.userInfo)
     };
   },
   computed: {},
   watch: {},
   created() {},
   mounted() {
+    this.paiArr = ['收起', '展开'],
     this.id = this.$route.query.id
     this.type = this.$route.query.type
     this.departmentId = this.$route.query.departmentId
@@ -94,38 +138,102 @@ export default {
     this.getPeople()
   },
   methods: {
+    // 批量操作
+    allChecked(){
+        if(this.isAllChecked){
+            for(let i in this.distributionList){
+                this.distributionList[i].prodProcedure.isSelected = true
+                console.log('===============');
+            }
+            this.isCanAgree = true
+        }else{
+            for(let i in this.distributionList){
+                this.distributionList[i].prodProcedure.isSelected = false
+            }
+            this.isCanAgree = false
+        }
+        this.$forceUpdate();
+    },
+    itemChecked(){
+        let isall = true
+        let iscan = false
+        for(let i in this.distributionList){
+            if(!this.distributionList[i].prodProcedure.isSelected){
+                isall = false
+            }else {
+                iscan = true
+            }
+        }
+        this.isAllChecked = isall
+        this.isCanAgree = iscan
+    },
+    batchReceive(bol){
+        let ids = ''
+        console.log(this.user)
+        let resArr=  this.distributionList.map(item=>{
+          if(item.prodProcedure.isSelected){
+            if(item.prodProcedureTeamList.filter(i=>i.userId==this.user.id).length>0){
+               return item.prodProcedureTeamList.filter(i=>i.userId==this.user.id)[0].id
+            }else{
+              return ""
+            }
+          }
+         })
+         console.log('res===============',resArr)
+        if(resArr.length > 0){
+            ids = resArr.join(",").trim()
+            this.$axios.post(
+              "/plan/receivePlan",
+              {
+                ids:ids
+              }
+            ).then(res => {
+              if (res.code == "ok") {
+                this.isAllChecked=false
+                this.isCanAgree=false
+                this.getDistributionList()
+              } else {
+                this.$toast.clear();
+                this.$toast.fail(res.msg);
+              }
+            }).catch(err => { this.$toast.clear(); })
+        }
+    },
+    workShowHide(index) {
+      this.distributionList[index].flg = !this.distributionList[index].flg;
+      console.log('=========>',this.distributionList[index].flg)
+    },
     back() {
       this.$router.go(-1);
     },
+    // 删除分配人员
+    deletePeople(item) {
+      const _this=this
+      this.$axios.post(
+        "/plan/deletePeople",
+        {
+          id:item
+        }
+      ).then(res => {
+        if (res.code == "ok") {
+          this.getDistributionList()
+        } else {
+          this.$toast.clear();
+          this.$toast.fail(res.msg);
+        }
+      }).catch(err => { this.$toast.clear(); })
+    },
     // 下单计划
     placeAnOrder() {
       let ids=[this.id];
+
       this.$axios.post(
         "/plan/allocationPlan",
         {
           ids: ids.join(","),
           planType: this.type
-        },
-        (res) => {
-          if (res.code == "ok") {
-            this.$message({
-              message: '下发成功',
-              type: "success",
-            });
-          } else {
-            this.$message({
-              message: res.msg,
-              type: "error",
-            });
-          }
-        },
-        (error) => {
-          this.$message({
-            message: error,
-            type: "error",
-          });
         }
-      );
+      )
     },
     distributionProp(item, index) {
       if(this.beDeptList) {
@@ -146,6 +254,7 @@ export default {
       })
       .then(res => {
         if (res.code == "ok") {
+          res.data.forEach(item => { item.flg = false })
           this.distributionList = res.data
         } else {
           this.$toast.clear();
@@ -153,6 +262,27 @@ export default {
         }
       }).catch(err => { this.$toast.clear(); });
     },
+    //换人
+    changePeople(item,newPeopleId){
+        this.$axios.post('/plan/changePeople', {
+        departmentId: this.departmentId,
+      })
+      .then(res => {
+        if (res.code == "ok") {
+          this.peopleList = res.data.map(item => {
+            return {
+              name: item.name,
+              id: item.id,
+              phone: item.phone,
+              jobNumber: item.jobNumber
+            }
+          })
+        } else {
+          this.$toast.clear();
+          this.$toast.fail(res.msg);
+        }
+      }).catch(err => { this.$toast.clear(); });
+    },
     // 获取人员
     getPeople() {
       this.$axios.post('/user/getSimpleActiveUserList', {
@@ -177,6 +307,7 @@ export default {
     teamAllocation(item, nameArr){
       let newDistributionList = JSON.parse(JSON.stringify(this.distributionList[this.distributionIndex]))
       delete newDistributionList.prodProcedure
+      delete newDistributionList.prodProcedureTeamList
       this.$axios.post('/plan/teamAllocation', {
         ...newDistributionList,
         teamIds: item.join(","),
@@ -187,6 +318,7 @@ export default {
         this.$refs.ChooseSomeone['loadingBtn'] = false
         if (res.code == "ok") {
           this.distributionList[this.distributionIndex].teamNames = nameArr.join(',')
+          this.getDistributionList()
           this.popupShow = false
         } else {
           this.$toast.clear();
@@ -214,6 +346,18 @@ export default {
   * {
     box-sizing: border-box;
   }
+  .formBatch{
+        position: fixed;
+        bottom: 0;
+        width: 100%;
+        z-index: 2;
+        background-color: #fff;
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        height: 1.2rem;
+        border-top: 1px solid #ebebeb;
+    }
   .distribution {
     width: 100%;
     height: 100%;

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/planView/todayPlan/todayPlan.vue

@@ -3,7 +3,7 @@
     <van-nav-bar title="今日计划" left-text="返回" @click-left="back" fixed left-arrow />
     <div class="todayPlan flexCoum-box">
       <PlanComponent :titleText="'今日计划'" :planList="planList" v-if="planList.length > 0"></PlanComponent>
-      <van-empty description="无数据" v-else />
+      <van-empty description="无数据" v-else />
     </div>
   </div>
 </template>

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/planView/tomorrowPlan/tomorrowPlan.vue

@@ -3,7 +3,7 @@
     <van-nav-bar title="明日计划" left-text="返回" @click-left="back" fixed left-arrow/>
     <div class="todayPlan flexCoum-box">
       <PlanComponent :titleText="'明日计划'" :planList="planList" v-if="planList.length > 0"></PlanComponent>
-      <van-empty description="无数据" v-else />
+      <van-empty description="无数据" v-else />
     </div>
   </div>
 </template>