|
|
|
@ -23,17 +23,19 @@ import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.form.ParentAndAllDeptDTO; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dto.EnterpriseReportDTO; |
|
|
|
import com.elink.esua.epdc.dto.SysSimpleDictDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.EnterpriseReportAddFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.EnterpriseReportFormDTO; |
|
|
|
import com.elink.esua.epdc.modules.enterprisereport.dao.EnterpriseReportDao; |
|
|
|
import com.elink.esua.epdc.modules.enterprisereport.entity.EnterpriseReportEntity; |
|
|
|
import com.elink.esua.epdc.modules.enterprisereport.service.EnterpriseReportService; |
|
|
|
import com.elink.esua.epdc.modules.feign.AdminFeignClient; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
@ -50,6 +52,8 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class EnterpriseReportServiceImpl extends BaseServiceImpl<EnterpriseReportDao, EnterpriseReportEntity> implements EnterpriseReportService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AdminFeignClient adminFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<EnterpriseReportDTO> page(Map<String, Object> params) { |
|
|
|
@ -68,16 +72,20 @@ public class EnterpriseReportServiceImpl extends BaseServiceImpl<EnterpriseRepor |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<EnterpriseReportEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String gridId = (String)params.get("GRID_ID"); |
|
|
|
String year = (String)params.get("YEAR"); |
|
|
|
String quarter = (String)params.get("QUARTER"); |
|
|
|
String enterpriseName = (String)params.get("ENTERPRISE_NAME"); |
|
|
|
String legalPerson = (String)params.get("LEGAL_PERSON"); |
|
|
|
String concat = (String)params.get("CONCAT"); |
|
|
|
String enterpriseStatus = (String)params.get("ENTERPRISE_STATUS"); |
|
|
|
String gridId = (String)params.get("gridId"); |
|
|
|
String communityId = (String)params.get("communityId"); |
|
|
|
String streetId = (String)params.get("streetId"); |
|
|
|
String year = (String)params.get("year"); |
|
|
|
String quarter = (String)params.get("quarter"); |
|
|
|
String enterpriseName = (String)params.get("enterpriseName"); |
|
|
|
String legalPerson = (String)params.get("legalPerson"); |
|
|
|
String concat = (String)params.get("concat"); |
|
|
|
String enterpriseStatus = (String)params.get("enterpriseStatus"); |
|
|
|
|
|
|
|
QueryWrapper<EnterpriseReportEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(gridId), "GRID_ID", gridId); |
|
|
|
wrapper.apply(StringUtils.isNotBlank(gridId),"FIND_IN_SET ("+gridId+",ALL_DEPT_IDS)"); |
|
|
|
wrapper.apply(StringUtils.isNotBlank(communityId),"FIND_IN_SET ("+communityId+",ALL_DEPT_IDS)"); |
|
|
|
wrapper.apply(StringUtils.isNotBlank(streetId),"FIND_IN_SET ("+streetId+",ALL_DEPT_IDS)"); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(year), "YEAR", year); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(quarter), "QUARTER", quarter); |
|
|
|
wrapper.like(StringUtils.isNotBlank(enterpriseName), "ENTERPRISE_NAME", enterpriseName); |
|
|
|
@ -117,34 +125,49 @@ public class EnterpriseReportServiceImpl extends BaseServiceImpl<EnterpriseRepor |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<EnterpriseReportDTO>> getEnterpriseReportList(EnterpriseReportFormDTO formDTO) { |
|
|
|
Long userId = SecurityUser.getUserId(); |
|
|
|
if(userId == null){ |
|
|
|
return new Result<List<EnterpriseReportDTO>>().error("无法获取到用户ID"); |
|
|
|
} |
|
|
|
formDTO.setUserId(userId); |
|
|
|
int pageIndex = (formDTO.getPageIndex() - NumConstant.ONE) * formDTO.getPageSize(); |
|
|
|
formDTO.setPageIndex(pageIndex); |
|
|
|
|
|
|
|
List<EnterpriseReportDTO> list = this.baseDao.getEnterpriseReportList(formDTO); |
|
|
|
//处理字典信息
|
|
|
|
formatList(list); |
|
|
|
return new Result().ok(list); |
|
|
|
} |
|
|
|
|
|
|
|
private void formatList(List<EnterpriseReportDTO> list) { |
|
|
|
Result<List<SysSimpleDictDTO>> enterpriseStatusRes = adminFeignClient.getListSimpleByDictType("enterprise_status"); |
|
|
|
if(enterpriseStatusRes.success()){ |
|
|
|
List<SysSimpleDictDTO> dict = enterpriseStatusRes.getData(); |
|
|
|
for (SysSimpleDictDTO sysSimpleDictDTO : dict) { |
|
|
|
for (EnterpriseReportDTO enterpriseReportDTO : list) { |
|
|
|
if(enterpriseReportDTO.getEnterpriseStatus().equals(sysSimpleDictDTO.getDictValue())){ |
|
|
|
enterpriseReportDTO.setEnterpriseStatus(sysSimpleDictDTO.getDictName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Result<List<SysSimpleDictDTO>> enterpriseQuarterRes = adminFeignClient.getListSimpleByDictType("enterprise_quarter"); |
|
|
|
if(enterpriseQuarterRes.success()){ |
|
|
|
List<SysSimpleDictDTO> dict = enterpriseQuarterRes.getData(); |
|
|
|
for (SysSimpleDictDTO sysSimpleDictDTO : dict) { |
|
|
|
for (EnterpriseReportDTO enterpriseReportDTO : list) { |
|
|
|
if(enterpriseReportDTO.getQuarter().equals(sysSimpleDictDTO.getDictValue())){ |
|
|
|
enterpriseReportDTO.setQuarter(sysSimpleDictDTO.getDictName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result addEnterpriseReport(EnterpriseReportAddFormDTO enterpriseReportAddFormDTO) { |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
if(user == null){ |
|
|
|
return new Result<List<EnterpriseReportDTO>>().error("无法获取到用户"); |
|
|
|
} |
|
|
|
QueryWrapper<EnterpriseReportEntity> entityQueryWrapper =new QueryWrapper<>(); |
|
|
|
entityQueryWrapper.eq("YEAR",enterpriseReportAddFormDTO.getYear()); |
|
|
|
entityQueryWrapper.eq("QUARTER",enterpriseReportAddFormDTO.getQuarter()); |
|
|
|
entityQueryWrapper.eq("ENTERPRISE_NAME",enterpriseReportAddFormDTO.getEnterpriseName()); |
|
|
|
|
|
|
|
EnterpriseReportEntity enterpriseReportEntity = new EnterpriseReportEntity(); |
|
|
|
enterpriseReportEntity.setDept(user.getDeptName()); |
|
|
|
enterpriseReportEntity.setDeptId(user.getDeptId()); |
|
|
|
enterpriseReportEntity.setMobile(user.getMobile()); |
|
|
|
enterpriseReportEntity.setRealName(user.getRealName()); |
|
|
|
enterpriseReportEntity.setFaceImg(user.getHeadUrl()); |
|
|
|
enterpriseReportEntity.setDept(enterpriseReportAddFormDTO.getDept()); |
|
|
|
enterpriseReportEntity.setDeptId(enterpriseReportAddFormDTO.getDeptId()); |
|
|
|
enterpriseReportEntity.setMobile(enterpriseReportAddFormDTO.getMobile()); |
|
|
|
enterpriseReportEntity.setRealName(enterpriseReportAddFormDTO.getRealName()); |
|
|
|
enterpriseReportEntity.setFaceImg(enterpriseReportAddFormDTO.getFaceImg()); |
|
|
|
enterpriseReportEntity.setUserId(enterpriseReportAddFormDTO.getUserId()); |
|
|
|
enterpriseReportEntity.setYear(enterpriseReportAddFormDTO.getYear()); |
|
|
|
enterpriseReportEntity.setQuarter(enterpriseReportAddFormDTO.getQuarter()); |
|
|
|
enterpriseReportEntity.setEnterpriseName(enterpriseReportAddFormDTO.getEnterpriseName()); |
|
|
|
@ -154,7 +177,23 @@ public class EnterpriseReportServiceImpl extends BaseServiceImpl<EnterpriseRepor |
|
|
|
enterpriseReportEntity.setEnterpriseIncome(enterpriseReportAddFormDTO.getEnterpriseIncome()); |
|
|
|
enterpriseReportEntity.setEnterprisePeopleNum(enterpriseReportAddFormDTO.getEnterprisePeopleNum()); |
|
|
|
enterpriseReportEntity.setQuestion(enterpriseReportAddFormDTO.getQuestion()); |
|
|
|
//获取部门信息
|
|
|
|
Result<ParentAndAllDeptDTO> parentAndAllDept = adminFeignClient.getParentAndAllDept(Long.parseLong(enterpriseReportAddFormDTO.getGridId())); |
|
|
|
if(!parentAndAllDept.success()){ |
|
|
|
return new Result().error("获取部门信息失败"); |
|
|
|
} |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = parentAndAllDept.getData(); |
|
|
|
enterpriseReportEntity.setGrid(parentAndAllDeptDTO.getGrid()); |
|
|
|
enterpriseReportEntity.setGridId(parentAndAllDeptDTO.getGridId()); |
|
|
|
enterpriseReportEntity.setAllDeptIds(parentAndAllDeptDTO.getAllDeptIds()); |
|
|
|
enterpriseReportEntity.setAllDeptNames(parentAndAllDeptDTO.getAllDeptNames()); |
|
|
|
enterpriseReportEntity.setParentDeptIds(parentAndAllDeptDTO.getParentDeptIds()); |
|
|
|
enterpriseReportEntity.setParentDeptNames(parentAndAllDeptDTO.getParentDeptNames()); |
|
|
|
//校验唯一性
|
|
|
|
QueryWrapper<EnterpriseReportEntity> entityQueryWrapper =new QueryWrapper<>(); |
|
|
|
entityQueryWrapper.eq("YEAR",enterpriseReportAddFormDTO.getYear()); |
|
|
|
entityQueryWrapper.eq("QUARTER",enterpriseReportAddFormDTO.getQuarter()); |
|
|
|
entityQueryWrapper.eq("ENTERPRISE_NAME",enterpriseReportAddFormDTO.getEnterpriseName()); |
|
|
|
List<EnterpriseReportEntity> enterpriseReportEntities = baseDao.selectList(entityQueryWrapper); |
|
|
|
if(enterpriseReportEntities.size()>1){ |
|
|
|
enterpriseReportEntity.setId(enterpriseReportEntities.get(0).getId()); |
|
|
|
@ -165,5 +204,29 @@ public class EnterpriseReportServiceImpl extends BaseServiceImpl<EnterpriseRepor |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<EnterpriseReportDTO> getEnterpriseReportDetail(String id) { |
|
|
|
EnterpriseReportDTO enterpriseReportDTO = get(id); |
|
|
|
Result<List<SysSimpleDictDTO>> enterpriseStatusRes = adminFeignClient.getListSimpleByDictType("enterprise_status"); |
|
|
|
if(enterpriseStatusRes.success()){ |
|
|
|
List<SysSimpleDictDTO> dict = enterpriseStatusRes.getData(); |
|
|
|
for (SysSimpleDictDTO sysSimpleDictDTO : dict) { |
|
|
|
if(enterpriseReportDTO.getEnterpriseStatus().equals(sysSimpleDictDTO.getDictValue())){ |
|
|
|
enterpriseReportDTO.setEnterpriseStatus(sysSimpleDictDTO.getDictName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Result<List<SysSimpleDictDTO>> enterpriseQuarterRes = adminFeignClient.getListSimpleByDictType("enterprise_quarter"); |
|
|
|
if(enterpriseQuarterRes.success()){ |
|
|
|
List<SysSimpleDictDTO> dict = enterpriseQuarterRes.getData(); |
|
|
|
for (SysSimpleDictDTO sysSimpleDictDTO : dict) { |
|
|
|
if(enterpriseReportDTO.getQuarter().equals(sysSimpleDictDTO.getDictValue())){ |
|
|
|
enterpriseReportDTO.setQuarter(sysSimpleDictDTO.getDictName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return new Result<EnterpriseReportDTO>().ok(enterpriseReportDTO); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|