@ -1,16 +1,28 @@
package com.zhgd.xmgl.modules.project.controller ;
import cn.hutool.core.collection.CollUtil ;
import cn.hutool.core.convert.Convert ;
import cn.hutool.core.date.DateUtil ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.gexin.fastjson.JSON ;
import com.zhgd.annotation.OperLog ;
import com.zhgd.jeecg.common.api.vo.Result ;
import com.zhgd.jeecg.common.execption.OpenAlertException ;
import com.zhgd.jeecg.common.mybatis.EntityMap ;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser ;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService ;
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl ;
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise ;
import com.zhgd.xmgl.modules.project.service.IProjectEnterpriseService ;
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo ;
import com.zhgd.xmgl.modules.worker.entity.EnterpriseQualification ;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo ;
import com.zhgd.xmgl.modules.worker.service.IEnterpriseInfoService ;
import com.zhgd.xmgl.modules.worker.service.IEnterpriseQualificationService ;
import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService ;
import com.zhgd.xmgl.util.EmailUtils ;
import com.zhgd.xmgl.util.FlowUtil ;
import com.zhgd.xmgl.util.MessageUtil ;
import io.swagger.annotations.Api ;
import io.swagger.annotations.ApiImplicitParam ;
@ -19,7 +31,11 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.collections.MapUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.web.bind.annotation.* ;
import org.springframework.context.annotation.Lazy ;
import org.springframework.web.bind.annotation.PostMapping ;
import org.springframework.web.bind.annotation.RequestBody ;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.RestController ;
import java.util.* ;
import java.util.stream.Collectors ;
@ -29,7 +45,7 @@ import java.util.stream.Collectors;
* @Title : Controller
* @Description : 项目劳务公司关联
* @author : pds
* @date : 2020 - 08 - 13
* @date : 2020 - 08 - 13
* @version : V1 . 0
* /
@RestController
@ -37,14 +53,27 @@ import java.util.stream.Collectors;
@Slf4j
@Api ( tags = " 项目劳务公司关联 " )
public class ProjectEnterpriseController {
@Lazy
@Autowired
NoticeServiceImpl noticeService ;
@Lazy
@Autowired
private IProjectEnterpriseService projectEnterpriseService ;
@Lazy
@Autowired
private IEnterpriseQualificationService enterpriseQualificationService ;
@Lazy
@Autowired
private IEnterpriseInfoService enterpriseInfoService ;
@Lazy
@Autowired
private IWorkerInfoService workerInfoService ;
@Lazy
@Autowired
private ISystemUserService systemUserService ;
@Lazy
@Autowired
private EmailUtils emailUtils ;
/ * *
* 分页列表查询
@ -73,7 +102,7 @@ public class ProjectEnterpriseController {
@ApiImplicitParam ( name = " sn " , value = " 项目sn或企业sn " , paramType = " body " , required = true , dataType = " String " ) ,
} )
@PostMapping ( value = " /selectList " )
public Result < List < EntityMap > > selectProjectEnterpriseList ( @RequestBody Map < String , Object > map ) {
public Result < List < EntityMap > > selectProjectEnterpriseList ( @RequestBody Map < String , Object > map ) {
List < EntityMap > pageList = projectEnterpriseService . selectProjectEnterpriseList ( map ) ;
return Result . success ( pageList ) ;
}
@ -84,7 +113,7 @@ public class ProjectEnterpriseController {
@ApiImplicitParam ( name = " sn " , value = " 项目sn或企业sn " , paramType = " body " , required = true , dataType = " String " ) ,
} )
@PostMapping ( value = " /selectDetailList " )
public Result < List < Map < String , Object > > > selectDetailList ( @RequestBody Map < String , Object > map ) {
public Result < List < Map < String , Object > > > selectDetailList ( @RequestBody Map < String , Object > map ) {
map . put ( " pageNo " , - 1 ) ;
map . put ( " pageSize " , 10 ) ;
IPage < EnterpriseInfo > pageList = projectEnterpriseService . selectProjectEnterprisePage ( map ) ;
@ -109,7 +138,8 @@ public class ProjectEnterpriseController {
}
/ * *
* 添加
* 添加
*
* @param projectEnterprise
* @return
* /
@ -122,12 +152,13 @@ public class ProjectEnterpriseController {
}
/ * *
* 编辑
* 编辑
*
* @param projectEnterprise
* @return
* /
@OperLog ( operModul = " 合作单位管理 " , operType = " 编辑合作的劳务公司 " , operDesc = " 编辑合作的劳务公司 " )
@ApiOperation ( value = " 编辑项目劳务公司关联信息 " , notes = " 编辑项目劳务公司关联信息 " , httpMethod = " POST " )
@OperLog ( operModul = " 合作单位管理 " , operType = " 编辑合作的劳务公司 " , operDesc = " 编辑合作的劳务公司 " )
@ApiOperation ( value = " 编辑项目劳务公司关联信息 " , notes = " 编辑项目劳务公司关联信息 " , httpMethod = " POST " )
@PostMapping ( value = " /edit " )
public Result < ProjectEnterprise > edit ( @RequestBody ProjectEnterprise projectEnterprise ) {
projectEnterpriseService . editProjectEnterprise ( projectEnterprise ) ;
@ -135,64 +166,197 @@ public class ProjectEnterpriseController {
}
/ * *
* 通过id删除
* 通过id删除
*
* @param
* @return
* /
@OperLog ( operModul = " 合作单位管理 " , operType = " 删除合作的劳务公司 " , operDesc = " 删除合作的劳务公司 " )
@OperLog ( operModul = " 合作单位管理 " , operType = " 删除合作的劳务公司 " , operDesc = " 删除合作的劳务公司 " )
@ApiOperation ( value = " 删除项目劳务公司关联信息 " , notes = " 删除项目劳务公司关联信息 " , httpMethod = " POST " )
@ApiImplicitParam ( name = " id " , value = " 项目劳务公司关联ID " , paramType = " body " , required = true , dataType = " Integer " )
@PostMapping ( value = " /delete " )
public Result < ProjectEnterprise > delete ( @RequestBody Map < String , Object > map ) {
public Result < ProjectEnterprise > delete ( @RequestBody Map < String , Object > map ) {
String id = MapUtils . getString ( map , " id " ) ;
projectEnterpriseService . delete ( id ) ;
return Result . ok ( ) ;
}
/ * *
* 批量删除
* 批量删除
*
* @param
* @return
* /
@OperLog ( operModul = " 合作单位管理 " , operType = " 批量删除合作的劳务公司 " , operDesc = " 批量删除合作的劳务公司 " )
@OperLog ( operModul = " 合作单位管理 " , operType = " 批量删除合作的劳务公司 " , operDesc = " 批量删除合作的劳务公司 " )
@ApiOperation ( value = " 批量删除项目劳务公司关联信息 " , notes = " 批量删除项目劳务公司关联信息 " , httpMethod = " POST " )
@ApiImplicitParam ( name = " ids " , value = " 项目劳务公司关联ID字符串 " , paramType = " body " , required = true , dataType = " String " )
@PostMapping ( value = " /deleteBatch " )
public Result < ProjectEnterprise > deleteBatch ( @RequestBody Map < String , Object > map ) {
public Result < ProjectEnterprise > deleteBatch ( @RequestBody Map < String , Object > map ) {
projectEnterpriseService . deleteBatch ( map ) ;
return Result . ok ( ) ;
}
/ * *
* 通过id查询
*
* @param
* @return
* /
@ApiOperation ( value = " 通过id查询项目劳务公司关联信息 " , notes = " 通过id查询项目劳务公司关联信息 " , httpMethod = " POST " )
@ApiImplicitParam ( name = " id " , value = " 项目劳务公司关联ID " , paramType = " body " , required = true , dataType = " Integer " )
@PostMapping ( value = " /queryById " )
public Result < ProjectEnterprise > queryById ( @RequestBody Map < String , Object > map ) {
public Result < ProjectEnterprise > queryById ( @RequestBody Map < String , Object > map ) {
Result < ProjectEnterprise > result = new Result < ProjectEnterprise > ( ) ;
ProjectEnterprise projectEnterprise = projectEnterpriseService . getById ( MapUtils . getString ( map , " id " ) ) ;
if ( projectEnterprise = = null ) {
ProjectEnterprise projectEnterprise = projectEnterpriseService . getById ( MapUtils . getString ( map , " id " ) ) ;
if ( projectEnterprise = = null ) {
result . error500 ( MessageUtil . get ( " notFindErr " ) ) ;
} else {
} else {
result . setResult ( projectEnterprise ) ;
result . setSuccess ( true ) ;
}
return result ;
}
@ApiOperation ( value = " 修改项目下劳务公司企业类型 " , notes = " 修改项目下劳务公司企业类型 " , httpMethod = " POST " )
@ApiOperation ( value = " 修改项目下劳务公司企业类型 " , notes = " 修改项目下劳务公司企业类型 " , httpMethod = " POST " )
@ApiImplicitParams ( {
@ApiImplicitParam ( name = " enterpriseTypeId " , value = " 企业类型ID " , paramType = " body " , required = true , dataType = " String " ) ,
@ApiImplicitParam ( name = " ids " , value = " 项目劳务公司关联ID,多个逗号分隔 " , paramType = " body " , required = true , dataType = " Integer " )
} )
@PostMapping ( value = " /updateEnterpriseType " )
public Result < ProjectEnterprise > updateEnterpriseType ( @RequestBody Map < String , Object > map ) {
public Result < ProjectEnterprise > updateEnterpriseType ( @RequestBody Map < String , Object > map ) {
projectEnterpriseService . updateEnterpriseType ( map ) ;
return Result . ok ( ) ;
}
@OperLog ( operModul = " 合作单位管理 " , operType = " " , operDesc = " 工作流承包商入场 " )
@ApiOperation ( value = " 工作流承包商入场 " , notes = " 工作流承包商入场 " , httpMethod = " POST " )
@PostMapping ( value = " /flow/add " )
public Result < ProjectEnterprise > addFromFlow ( @RequestBody Map < String , Object > map ) {
log . info ( " 工作流承包商入场:{} " , JSON . toJSONString ( map ) ) ;
String title = " 承包商入场申请 " ;
String enterpriseName = FlowUtil . getString ( map , " enterpriseName " ) ;
String description = FlowUtil . getString ( map , " description " ) ;
String enterpriseAddress = FlowUtil . getString ( map , " enterpriseAddress " ) ;
String enterpriseLegalPerson = FlowUtil . getString ( map , " enterpriseLegalPerson " ) ;
String legalPersonIdCard = FlowUtil . getString ( map , " legalPersonIdCard " ) ;
String enterpriseSafeAllow = FlowUtil . getString ( map , " enterpriseSafeAllow " ) ;
String legalPersonTel = FlowUtil . getString ( map , " legalPersonTel " ) ;
String socialCode = FlowUtil . getString ( map , " socialCode " ) ;
String businessNumber = FlowUtil . getString ( map , " businessNumber " ) ;
String qualificationNumber = FlowUtil . getString ( map , " qualificationNumber " ) ;
String enterpriseEmail = FlowUtil . getString ( map , " enterpriseEmail " ) ;
String registeredCapital = FlowUtil . getString ( map , " registeredCapital " ) ;
String bankname = FlowUtil . getString ( map , " bankname " ) ;
String bankcardnumber = FlowUtil . getString ( map , " bankcardnumber " ) ;
String bankcode = FlowUtil . getString ( map , " bankcode " ) ;
String enterpriseQualificationUrl = FlowUtil . getString ( map , " enterpriseQualificationUrl " ) ;
String businessLicenseEndDate = FlowUtil . getString ( map , " businessLicenseEndDate " ) ;
String registerPersonName = FlowUtil . getString ( map , " registerPersonName " ) ;
String registerPersonPhoneTel = FlowUtil . getString ( map , " registerPersonPhoneTel " ) ;
String enterpriseSn = FlowUtil . getString ( map , " enterpriseSn " ) ;
String logo = FlowUtil . getString ( map , " logo " ) ;
String projectSn = FlowUtil . getString ( map , " projectSn " ) ;
String registDate = FlowUtil . getString ( map , " registDate " ) ;
String businessLicenseUrl = FlowUtil . getString ( map , " businessLicenseUrl " ) ;
String projectDirectorName = FlowUtil . getString ( map , " projectDirectorName " ) ;
String projectDirectorPhone = FlowUtil . getString ( map , " projectDirectorPhone " ) ;
Long parentEnterpriseId = FlowUtil . getPullDownLong ( map , " parentEnterpriseId " ) ;
Long enterpriseTypeId = FlowUtil . getPullDownLong ( map , " enterpriseTypeId " ) ;
EnterpriseInfo enterpriseInfo = new EnterpriseInfo ( ) ;
enterpriseInfo . setEnterpriseName ( enterpriseName ) ;
enterpriseInfo . setDescription ( description ) ;
enterpriseInfo . setEnterpriseAddress ( enterpriseAddress ) ;
enterpriseInfo . setEnterpriseLegalPerson ( enterpriseLegalPerson ) ;
enterpriseInfo . setLegalPersonIdCard ( legalPersonIdCard ) ;
enterpriseInfo . setEnterpriseSafeAllow ( enterpriseSafeAllow ) ;
/ / enterpriseInfo . setEnterpriseProperty ( 0 ) ;
enterpriseInfo . setLegalPersonTel ( legalPersonTel ) ;
enterpriseInfo . setSocialCode ( socialCode ) ;
enterpriseInfo . setBusinessNumber ( businessNumber ) ;
/ / enterpriseInfo . setQualificationNumber ( qualificationNumber ) ;
/ / enterpriseInfo . setEnterpriseEmail ( enterpriseEmail ) ;
/ / enterpriseInfo . setRegisteredCapital ( registeredCapital ) ;
/ / enterpriseInfo . setBankname ( bankname ) ;
/ / enterpriseInfo . setBankcardnumber ( bankcardnumber ) ;
/ / enterpriseInfo . setBankcode ( bankcode ) ;
enterpriseInfo . setEnterpriseQualificationUrl ( enterpriseQualificationUrl ) ;
enterpriseInfo . setBusinessLicenseEndDate ( businessLicenseEndDate ) ;
enterpriseInfo . setRegisterPersonName ( registerPersonName ) ;
enterpriseInfo . setRegisterPersonPhoneTel ( registerPersonPhoneTel ) ;
enterpriseInfo . setEnterpriseSn ( enterpriseSn ) ;
/ / enterpriseInfo . setLogo ( logo ) ;
enterpriseInfo . setRegistDate ( registDate ) ;
enterpriseInfo . setBusinessLicenseUrl ( businessLicenseUrl ) ;
enterpriseInfo . setParentEnterpriseId ( parentEnterpriseId ) ;
enterpriseInfo . setEnterpriseTypeId ( enterpriseTypeId ) ;
enterpriseInfo . setProjectDirectorName ( projectDirectorName ) ;
enterpriseInfo . setProjectDirectorPhone ( projectDirectorPhone ) ;
enterpriseInfo . setProjectSn ( projectSn ) ;
String sub = enterpriseName + " (信用代码: " + socialCode + " ) " ;
EnterpriseInfo existEnterpriseInfo = enterpriseInfoService . getOne ( new LambdaQueryWrapper < EnterpriseInfo > ( ) . eq ( EnterpriseInfo : : getSocialCode , socialCode ) ) ;
if ( existEnterpriseInfo ! = null ) {
List < ProjectEnterprise > projectEnterpriseList = projectEnterpriseService . list ( new LambdaQueryWrapper < ProjectEnterprise > ( )
. eq ( ProjectEnterprise : : getEnterpriseId , existEnterpriseInfo . getId ( ) )
. eq ( ProjectEnterprise : : getProjectSn , projectSn ) ) ;
if ( CollUtil . isNotEmpty ( projectEnterpriseList ) ) {
String msg = sub + " 已存在 " ;
noticeService . addProjectLevelNotice ( projectSn , title , msg , " 1 " , null ) ;
return Result . ok ( ) ;
}
}
List enterpriseQualifications = Optional . ofNullable ( map . get ( " enterpriseQualifications " ) ) . map ( o - > ( ( List ) o ) ) . orElse ( null ) ;
if ( CollUtil . isEmpty ( enterpriseQualifications ) ) {
throw new OpenAlertException ( " 企业资质不能为空 " ) ;
}
HashSet < Integer > haveQualificationTypes = new HashSet < > ( ) ;
if ( Objects . equals ( enterpriseTypeId , 6 ) ) {
/ / 专业分包
haveQualificationTypes . add ( 1 ) ;
haveQualificationTypes . add ( 3 ) ;
haveQualificationTypes . add ( 4 ) ;
haveQualificationTypes . add ( 5 ) ;
haveQualificationTypes . add ( 6 ) ;
haveQualificationTypes . add ( 7 ) ;
} else {
haveQualificationTypes . add ( 1 ) ;
haveQualificationTypes . add ( 2 ) ;
}
ArrayList < EnterpriseQualification > qualificationList = new ArrayList < > ( ) ;
for ( Object qr : enterpriseQualifications ) {
Map map1 = ( Map ) qr ;
String fileName = MapUtils . getString ( map1 , " field3157982972904 " ) ;
String fileNumber = MapUtils . getString ( map1 , " field1097582981600 " ) ;
String fileUrl = FlowUtil . getFileUrl ( map1 , " field9706683030062 " ) ;
String remarks = MapUtils . getString ( map1 , " field8724783057283 " ) ;
String originFileName = FlowUtil . getFileOriginFileName ( map1 , " field9706683030062 " ) ;
Integer qualificationType = Optional . ofNullable ( map1 . get ( " field6906058457282 " ) ) . map ( o - > Convert . toInt ( ( ( List ) o ) . get ( 0 ) ) ) . orElse ( null ) ;
Date qualificationStartTime = FlowUtil . getStartDate ( map1 , " field8056482998908 " ) ;
Date qualificationEndTime = FlowUtil . getEndDate ( map1 , " field8056482998908 " ) ;
haveQualificationTypes . remove ( qualificationType ) ;
EnterpriseQualification qualification = new EnterpriseQualification ( ) ;
/ / qualification . setEnterpriseId ( 0L ) ;
qualification . setFileName ( fileName ) ;
qualification . setFileNumber ( fileNumber ) ;
qualification . setFileUrl ( fileUrl ) ;
qualification . setRemarks ( remarks ) ;
qualification . setOriginFileName ( originFileName ) ;
qualification . setQualificationType ( qualificationType ) ;
qualification . setQualificationStartTime ( qualificationStartTime ) ;
qualification . setQualificationEndTime ( qualificationEndTime ) ;
qualificationList . add ( qualification ) ;
}
if ( CollUtil . isNotEmpty ( haveQualificationTypes ) ) {
if ( Objects . equals ( enterpriseTypeId , 6 ) ) {
throw new OpenAlertException ( " 需要上传营业执照、企业资质、设计资质(设计专业提供)、安全生产许可证、职业健康安全管理体系认证证书、环境管理体系认证证书 " ) ;
} else {
throw new OpenAlertException ( " 需要上传营业执照、资质证书 " ) ;
}
}
enterpriseInfoService . saveEnterpriseInfo ( enterpriseInfo ) ;
for ( EnterpriseQualification qualification : qualificationList ) {
qualification . setEnterpriseId ( enterpriseInfo . getId ( ) ) ;
}
enterpriseQualificationService . saveBatch ( qualificationList ) ;
return Result . ok ( ) ;
}
}