Browse Source

Merge branch 'dev' of yeshijie/wlyy2.0 into dev

叶仕杰 3 years ago
parent
commit
6c450d6548

+ 4 - 0
gateway/ag-basic/src/main/resources/application.yml

@ -62,6 +62,10 @@ zuul:
    svr-base:
      path: /cityihealth/base/**
      serviceId: svr-base
#新冠患者招募
    svr-base-vol:
      path: /cityihealth/baseVol/**
      serviceId: svr-base-vol
    svr-authentication:
      path: /cityihealth/auth/**
      serviceId: svr-authentication

+ 5 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/voluntary/VoluntaryRecruitmentCompanyDao.java

@ -4,6 +4,8 @@ import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @Author: yeshijie
 * @Date: 2021/8/1
@ -11,6 +13,9 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface VoluntaryRecruitmentCompanyDao extends PagingAndSortingRepository<VoluntaryRecruitmentCompanyDO, String>, JpaSpecificationExecutor<VoluntaryRecruitmentCompanyDO> {
    VoluntaryRecruitmentCompanyDO findByName(String name);
    boolean existsByName(String name);
    List<VoluntaryRecruitmentCompanyDO> findByContactsAndPhone(String contacts,String phone);
}

+ 1 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/voluntary/VoluntaryRecruitmentPeopleDao.java

@ -14,6 +14,7 @@ import java.util.List;
 */
public interface VoluntaryRecruitmentPeopleDao extends PagingAndSortingRepository<VoluntaryRecruitmentPeopleDO, String>, JpaSpecificationExecutor<VoluntaryRecruitmentPeopleDO> {
    boolean existsByPhone(String phone);
    List<VoluntaryRecruitmentPeopleDO> queryByIdIn(String[] id);

+ 64 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/voluntary/VoluntaryRecruitmentEndpoint.java

@ -1,11 +1,14 @@
package com.yihu.jw.base.endpoint.voluntary;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentPeopleDao;
import com.yihu.jw.base.service.voluntary.VoluntaryRecruitmentCompanyService;
import com.yihu.jw.base.service.voluntary.VoluntaryRecruitmentService;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -30,6 +33,8 @@ public class VoluntaryRecruitmentEndpoint extends EnvelopRestEndpoint {
    private VoluntaryRecruitmentService voluntaryRecruitmentService;
    @Autowired
    private VoluntaryRecruitmentCompanyService companyService;
    @Autowired
    private VoluntaryRecruitmentPeopleDao peopleDao;
    @PostMapping(value = "add")
    @ApiOperation(value = "企业报名")
@ -38,8 +43,11 @@ public class VoluntaryRecruitmentEndpoint extends EnvelopRestEndpoint {
         @RequestParam String jsonData){
        try {
            VoluntaryRecruitmentCompanyDO companyDO = toEntity(jsonData, VoluntaryRecruitmentCompanyDO.class);
            voluntaryRecruitmentService.add(companyDO);
            return success("报名成功");
            String result = voluntaryRecruitmentService.add(companyDO);
            if(StringUtil.isBlank(result)){
                return success("报名成功");
            }
           return Envelop.getError(result,-1);
        }catch (Exception e){
            e.printStackTrace();
            return failedException2(e);
@ -70,5 +78,59 @@ public class VoluntaryRecruitmentEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "existsByPhone")
    @ApiOperation(value = "人员是否已报名")
    public ObjEnvelop existsByPhone (
            @ApiParam(name = "phone", value = "联系人手机")
            @RequestParam(value = "phone", required = true) String phone){
        try {
            return ObjEnvelop.getSuccess("查找成功",peopleDao.existsByPhone(phone));
        }catch (Exception e){
            e.printStackTrace();
            return  ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "findByContactsAndPhone")
    @ApiOperation(value = "查找单个企业")
    public ObjEnvelop<VoluntaryRecruitmentCompanyDO> findByContactsAndPhone (
            @ApiParam(name = "contacts", value = "联系人姓名")
            @RequestParam(value = "contacts", required = true) String contacts,
            @ApiParam(name = "phone", value = "联系人手机")
            @RequestParam(value = "phone", required = true) String phone){
        try {
            VoluntaryRecruitmentCompanyDO companyDO = voluntaryRecruitmentService.findByContactsAndPhone(contacts,phone);
            if(companyDO==null){
               return ObjEnvelop.getError("未找到关联企业");
            }
            return ObjEnvelop.getSuccess("查找成功",companyDO);
        }catch (Exception e){
            e.printStackTrace();
            return  ObjEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = "arrange")
    @ApiOperation(value = "人员安排")
    public Envelop arrange (
            @ApiParam(name = "companyId", value = "联系人姓名")
            @RequestParam(value = "companyId", required = true) String companyId,
            @ApiParam(name = "day", value = "服务日期")
            @RequestParam(value = "day", required = true) String day,
            @ApiParam(name = "time", value = "服务时间段")
            @RequestParam(value = "time", required = true) String time,
            @ApiParam(name = "peoples", value = "服务人员 id+姓名逗号间隔。例:1:测试1,2:测试2")
            @RequestParam(value = "peoples", required = true) String peoples,
            @ApiParam(name = "station", value = "服务站")
            @RequestParam(value = "station", required = true) String station){
        try {
            voluntaryRecruitmentService.arrange(companyId, day, time, peoples, station);
            return success("报名成功");
        }catch (Exception e){
            e.printStackTrace();
            return failedException2(e);
        }
    }
}

+ 76 - 11
svr/svr-base/src/main/java/com/yihu/jw/base/service/voluntary/VoluntaryRecruitmentService.java

@ -3,11 +3,14 @@ package com.yihu.jw.base.service.voluntary;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentArrangeDao;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentCompanyDao;
import com.yihu.jw.base.dao.voluntary.VoluntaryRecruitmentPeopleDao;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentArrangeDO;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentPeopleDO;
import com.yihu.jw.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@ -27,25 +30,87 @@ public class VoluntaryRecruitmentService {
    @Autowired
    private VoluntaryRecruitmentPeopleDao peopleDao;
    /**
     * 人员安排
     */
    public void arrange(String companyId,String day,String time,String peoples,String station){
        List<VoluntaryRecruitmentArrangeDO> arrangeDOs = new ArrayList<>();
        String people[] = peoples.split(",");
        for (String peo:people){
            String p[] = peo.split(":");
            VoluntaryRecruitmentArrangeDO arrangeDO = new VoluntaryRecruitmentArrangeDO();
            arrangeDO.setCompanyId(companyId);
            arrangeDO.setDay(day);
            arrangeDO.setPeopleId(p[0]);
            arrangeDO.setPeopleName(p[1]);
            arrangeDO.setStation(station);
            arrangeDO.setTime(time);
            arrangeDOs.add(arrangeDO);
        }
        arrangeDao.save(arrangeDOs);
    }
    public VoluntaryRecruitmentCompanyDO findByContactsAndPhone(String contacts,String phone){
        List<VoluntaryRecruitmentCompanyDO> companyDOs = companyDao.findByContactsAndPhone(contacts,phone);
        if(companyDOs!=null&&companyDOs.size()>0){
            return companyDOs.get(0);
        }
        return null;
    }
    /**
     * 企业报名
     */
    public void add(VoluntaryRecruitmentCompanyDO companyDO){
    public String add(VoluntaryRecruitmentCompanyDO companyDO){
        List<VoluntaryRecruitmentPeopleDO> peopleDOs = new ArrayList<>();
        if(StringUtil.isBlank(companyDO.getId())){
            if(companyDao.existsByName(companyDO.getName())){
                return "该企业已报名,请勿重复报名";
            }
            List<VoluntaryRecruitmentCompanyDO> companyDOs = companyDao.findByContactsAndPhone(companyDO.getContacts(),companyDO.getPhone());
            if(companyDOs!=null&&companyDOs.size()>0){
                return "该联系人已被其他企业添加";
            }
            List<VoluntaryRecruitmentPeopleDO> peopleDOList = companyDO.getPeopleDOList();
            if(peopleDOList!=null){
                addPeople(peopleDOList,peopleDOs,companyDO);
                return null;
            }
            return null;
        }
        List<VoluntaryRecruitmentPeopleDO> peopleDOList = companyDO.getPeopleDOList();
        if(peopleDOList!=null){
            companyDO.setNum(peopleDOList.size());
            companyDao.save(companyDO);
        if(peopleDOList==null){
            return "请添加人员";
        }
            for (VoluntaryRecruitmentPeopleDO peopleDO:peopleDOList){
                peopleDO.setCompanyId(companyDO.getId());
                peopleDO.setCompanyName(companyDO.getName());
        addPeople(peopleDOList,peopleDOs,companyDO);
        return null;
    }
    public void addPeople(List<VoluntaryRecruitmentPeopleDO> peopleDOList,List<VoluntaryRecruitmentPeopleDO> peopleDOs,VoluntaryRecruitmentCompanyDO companyDO){
        for (VoluntaryRecruitmentPeopleDO peopleDO:peopleDOList){
            if(peopleDao.existsByPhone(peopleDO.getPhone())){
                continue;
            }
            peopleDao.save(peopleDOList);
            return;
            peopleDO.setCompanyId(companyDO.getId());
            peopleDO.setCompanyName(companyDO.getName());
            peopleDOs.add(peopleDO);
        }
        if(peopleDOs.size()>0){
            peopleDao.save(peopleDOs);
        }
        companyDO.setNum(0);
        companyDao.save(companyDO);
        if(!StringUtil.isBlank(companyDO.getId())){
            VoluntaryRecruitmentCompanyDO old = companyDao.findOne(companyDO.getId());
            old.setNum(old.getNum()+peopleDOs.size());
            companyDao.save(old);
        }
        companyDO.setNum(peopleDOs.size());
        companyDao.save(companyDO);
    }