| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794 |
- package platform.modules.build.service;
- import com.aliyuncs.exceptions.ClientException;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import org.apache.commons.lang3.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import platform.common.Constant;
- import platform.common.base.service.BaseService;
- import platform.common.base.service.DictionaryItemService;
- import platform.common.util.*;
- import platform.modules.api.dto.CompanyInfoDto;
- import platform.modules.api.service.SkyImageApiService;
- import platform.modules.build.DTO.CompanyDto;
- import platform.modules.build.DTO.CompanyFeeDto;
- import platform.modules.build.dao.CompanyDao;
- import platform.modules.build.entity.BuildInfo;
- import platform.modules.build.entity.Company;
- import platform.modules.build.entity.CompanyContact;
- import platform.modules.carrier.dto.CompanyContacts;
- import platform.modules.carrier.dto.CustomSearchCondition;
- import platform.modules.carrier.dto.SearchCondition;
- import platform.modules.company.entity.CompanyBuildingStreet;
- import platform.modules.company.entity.ProjectApplication;
- import platform.modules.company.entity.ProjectApplicationCompanyInfo;
- import platform.modules.company.entity.StockLand;
- import platform.modules.company.service.CompanyBuildingStreetService;
- import platform.modules.company.service.CompanyContactsService;
- import platform.modules.company.service.ProjectApplicationCompanyInfoService;
- import platform.modules.government.dto.StreetCompanys;
- import platform.modules.government.entity.BuildType;
- import platform.modules.government.entity.Street;
- import platform.modules.government.entity.User;
- import platform.modules.government.service.BuildTypeService;
- import platform.modules.government.service.StreetService;
- import platform.modules.government.service.UserService;
- import platform.modules.sys.entity.Approval;
- import platform.modules.sys.entity.Department;
- import platform.modules.sys.service.ApprovalService;
- import platform.modules.sys.service.DepartmentService;
- import platform.modules.sys.service.WaitToDoService;
- import platform.modules.sys.web.ResponseMessage;
- import tk.mybatis.mapper.entity.Example;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.Objects;
- /**
- * 企业信息Service
- *
- * @author lhf
- * @version 2017-10-26
- */
- @Service
- @Transactional(readOnly = true)
- public class CompanyService extends BaseService<Company> {
- private static Logger logger = LoggerFactory.getLogger(CompanyService.class);
- @Autowired
- private CompanyDao companyDao;
- @Autowired
- private CompanyContactService companyContactService;
- @Autowired
- private BuildTypeService buildTypeService;
- @Autowired
- private DepartmentService departmentService;
- @Autowired
- private UserService userService;
- @Autowired
- private ApprovalService approvalService;
- @Autowired
- CompanyContactsService companyContactsService;
- @Autowired
- private DictionaryItemService dictionaryItemService;
- @Autowired
- private BuildInfoService buildInfoService;
- @Autowired
- private StreetService streeService;
- @Autowired
- private CompanyBuildingStreetService buildingStreetService;
- @Autowired
- private WaitToDoService waitToDoService;
-
- @Autowired
- private ProjectApplicationCompanyInfoService applicationCompanyInfoService;
- @Autowired
- private SkyImageApiService skyImageApiService;
- public PageInfo<Company> findPage(Integer pageNum, Integer pageSize, String param, CompanyDto companyDto) throws Exception {
- /*Example example = new Example(Company.class);
- Example.Criteria criteria = example.createCriteria();
- Example.Criteria criteria2 = example.createCriteria();
- if (StringUtils.isNotBlank(param)) {
- criteria.andLike("company_name", "%" + WebUtil.covertData(param) + "%");
- //.orLike("phone", "%" + WebUtil.covertData(param) + "%")
- //.orLike("contact", "%" + WebUtil.covertData(param) + "%");
- }
- criteria2.andEqualTo("del_flag", 0);
- criteria2.andEqualTo("build_id", ShiroUtils.getUserEntity().getBuild_id());
- if (null != companyDto.getIs_start()) {
- criteria2.andEqualTo("is_start", companyDto.getIs_start());
- }
- // 倒序
- example.and(criteria2);
- example.orderBy("create_time").desc();*/
- PageHelper.startPage(pageNum, pageSize);
- Integer build_id = ShiroUtils.getUserEntity().getBuild_id();
- Integer street_id = ShiroUtils.getUserEntity().getStreet_id();
- List<Company> contents = null;
- if (StringUtils.isNotBlank(param)) {
- String trim = param.trim();
- contents = companyDao.selectCompanyByCondition(street_id, build_id, trim);
- } else {
- contents = companyDao.selectCompanyByCondition(street_id, build_id, param);
- }
- for (Company company : contents) {
- if (null != company.getType_id()) {
- BuildType buildType = buildTypeService.findById(company.getType_id());
- if (null != buildType) {
- company.setType_name(buildType.getType());
- }
- }
- company.setCompanyContacts(companyContactService.findByCompanyId(company.getId()));
- }
- return new PageInfo<Company>(contents);
- }
- @Transactional(readOnly = false)
- public Boolean saveCompany(Company company) throws Exception {
- company.setBuild_id(ShiroUtils.getUserEntity().getBuild_id());
- company.setStreet_id(ShiroUtils.getUserEntity().getStreet_id());
- company.setIs_register(1);
- company.setIs_start(true);
- if (this.insertAndGetId(company) == 1) {
- for (CompanyContact companyContact : company.getCompanyContacts()) {
- companyContact.setCompany_id(company.getId());
- company.setIs_start(true);
- companyContactService.saveSelective(companyContact);
- }
- return true;
- }
- return false;
- }
- @Transactional(readOnly = false)
- public Boolean updateCompany(Company company) throws Exception {
- if (this.updateSelective(company) == 1) {
- User user = new User();
- user.setBuild_id(company.getBuild_id());
- user.setStreet_id(company.getStreet_id());
- Street street = streeService.findById(company.getStreet_id());
- if (street != null) {
- user.setStreet_name(street.getName());
- }
- if (company.getBuild_id() == null) {
- user.setBuild_id(null);
- user.setBuild_name("");
- } else {
- BuildInfo build = buildInfoService.findById(company.getBuild_id());
- if (build != null) {
- user.setBuild_name(build.getName());
- }
- }
- userService.updateByCompanyId(company.getId().toString(), user);
- companyContactService.deleteByCompanyId(company.getId());
- for (CompanyContact companyContact : company.getCompanyContacts()) {
- if (null != companyContact.getPhone() || null != companyContact.getContact()) {
- companyContact.setCompany_id(company.getId());
- companyContactService.saveSelective(companyContact);
- }
- }
- //更新厂房所在属地
- if (null != company.getBuildingStreets() && company.getBuildingStreets().size() > 0) {
- buildingStreetService.deleteByCompanyId(company.getId());
- for (CompanyBuildingStreet buildingStreet : company.getBuildingStreets()) {
- if (null != buildingStreet.getStreet_id()) {
- buildingStreet.setCompany_id(company.getId());
- buildingStreetService.saveSelective(buildingStreet);
- }
- }
- }
- return true;
- }
- return false;
- }
- public Company findByCompanyName(String companyName) throws Exception {
- return companyDao.findByCompanyName(companyName);
- }
- public PageInfo<Company> findPageByName(Integer pageNum, Integer pageSize, String name, List<String> ids) {
- PageHelper.startPage(pageNum, pageSize);
- List<Company> result = companyDao.findListByCompanyName(name, ids);
- return new PageInfo<Company>(result);
- }
- public List<Company> findListByCompanyIds(List<String> ids) {
- List<Company> result = companyDao.findListByCompanyIds(ids);
- return result;
- }
- public List<Company> findCompanyList() {
- Example example = new Example(Company.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("build_id", ShiroUtils.getUserEntity().getBuild_id());
- criteria.andEqualTo("del_flag", 0);
- criteria.andEqualTo("is_start", 1);
- if (null != ShiroUtils.getUserType() && ShiroUtils.getUserType().equals(Constant.UserType.COMPANY)) {
- criteria.andEqualTo("id", ShiroUtils.getCompanyId());
- }
- example.orderBy("sort").desc();
- List<Company> list = companyDao.selectByExample(example);
- return list;
- }
- public List<Company> findCompanies() {
- Example example = new Example(Company.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("del_flag", 0);
- criteria.andEqualTo("is_start", 1);
- List<Company> list = companyDao.selectByExample(example);
- return list;
- }
- public Integer findCuntCompanyByBuildId(Integer buildId, String dateFrom, String dateTo) {
- return companyDao.findCuntCompanyByBuildId(buildId, dateFrom, dateTo);
- }
- public PageInfo<Company> findCompanyList(Integer pageNum, Integer pageSize, CompanyDto companyDto) {
- Example example = new Example(Company.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("del_flag", 0);
- criteria.andEqualTo("is_start", 1);
- User currUser = ShiroUtils.getUserEntity();
- if (currUser.getUser_type().equals(Constant.UserType.STREET)) {
- criteria.andEqualTo("street_id", ShiroUtils.getUserEntity().getStreet_id());
- } else if (currUser.getUser_type().equals(Constant.UserType.BUILD)) {
- criteria.andEqualTo("build_id", ShiroUtils.getUserEntity().getBuild_id());
- }
- if (StringUtils.isNotBlank(companyDto.getCompany_name())) {
- criteria.andLike("company_name", "%" + WebUtil.covertData(companyDto.getCompany_name()) + "%");
- }
- if (null != companyDto.getType()) {
- criteria.andEqualTo("type", companyDto.getType());
- }
- if (null != companyDto.getIs_product()) {
- criteria.andEqualTo("is_product", companyDto.getIs_product());
- }
- if (StringUtils.isNotBlank(companyDto.getStreet_ids())) {
- criteria.andIn("street_id", companyDto.getStreetIdList());
- }
- if (StringUtils.isNotBlank(companyDto.getBuild_ids())) {
- criteria.andIn("build_id", companyDto.getBuildIdList());
- }
- example.orderBy("sort").desc();
- PageHelper.startPage(pageNum, pageSize);
- List<Company> list = companyDao.selectByExample(example);
- return new PageInfo<Company>(list);
- }
- /**
- * 企业费用查询
- *
- * @param pageNum
- * @param pageSize
- * @return
- * @throws Exception
- */
- public PageInfo<CompanyFeeDto> findCompanyFeePage(Integer pageNum, Integer pageSize, String status, String fee_type) throws Exception {
- PageHelper.startPage(pageNum, pageSize);
- List<CompanyFeeDto> companyFees = companyDao.findCompanyFee(new CompanyFeeDto(ShiroUtils.getUserEntity().getCompany_id(), fee_type, status));
- return new PageInfo<CompanyFeeDto>(companyFees);
- }
- public List<CompanyFeeDto> findLatestCompnayFee(CompanyFeeDto companyFeeDto) {
- List<CompanyFeeDto> companyFees = companyDao.findCompanyFee(companyFeeDto);
- return companyFees;
- }
- public Integer findAllCuntCompanyByBuildId(Integer buildId) {
- return companyDao.findAllCuntCompanyByBuildId(buildId);
- }
- public Integer getCompanyCountByStreetName(String name) {
- return companyDao.getCompanyCountByStreetName(name);
- }
- public Integer countByType(Integer typeId) {
- return companyDao.countByType(typeId);
- }
- public Integer countAllCompany() {
- platform.modules.government.dto.SearchCondition condition = new platform.modules.government.dto.SearchCondition();
- return companyDao.countAllCompany(condition);
- }
- public Integer countAllCompanyByUserType() {
- platform.modules.government.dto.SearchCondition condition = new platform.modules.government.dto.SearchCondition();
- if (null != ShiroUtils.getUserType() && ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
- condition.setUser_type(Constant.UserType.STREET);
- condition.setStreet_id(ShiroUtils.getStreetId());
- }
- return companyDao.countAllCompany(condition);
- }
- //根据id获取企业信息
- public Company getCompanyInfo(Integer company_id) {
- Company companyInfo = null;
- if (null != company_id) {
- companyInfo = this.findById(company_id);
- }
- if (companyInfo != null) {
- List<CompanyContact> list = companyContactService.findByCompanyId(company_id);
- companyInfo.setCompanyContacts(list);
- if (null != list && list.size() > 0) {
- companyInfo.setContact(list.get(0).getContact());
- companyInfo.setContact_phone((list.get(0).getPhone()));
- }
- if (null != companyInfo.getStreet_id()) {
- try {
- companyInfo.setStreet_name(streeService.getStreetName(companyInfo.getStreet_id()));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- companyInfo.setBuildingStreets(buildingStreetService.findByCompanyId(company_id));
- //是否经营
- if (companyInfo.getOperated() != null) {
- if (companyInfo.getOperated()) {
- companyInfo.setOperatedStr("是");
- } else {
- companyInfo.setOperatedStr("否");
- }
- }
- }
- return companyInfo == null ? new Company() : companyInfo;
- }
- //根据id获取企业信息
- public Company getCompanyInfo(StockLand stockLand) {
- Integer company_id = stockLand.getCompany_id();
- Company company = null;
- if (null != company_id) {
- company = this.findById(company_id);
- }
- if (company != null) {
- ProjectApplicationCompanyInfo companyInfo =
- applicationCompanyInfoService.findByApplyIdAndType(stockLand.getId(),
- Constant.DictionaryType.STOCKLAND);
- if (companyInfo != null) {
- company.setContact(companyInfo.getContact());
- company.setContact_phone(companyInfo.getContact_phone());
- }
- if (null != company.getStreet_id()) {
- try {
- company.setStreet_name(streeService.getStreetName(company.getStreet_id()));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- company.setBuildingStreets(buildingStreetService.findByCompanyId(company_id));
- //是否经营
- if (company.getOperated() != null) {
- if (company.getOperated()) {
- company.setOperatedStr("是");
- } else {
- company.setOperatedStr("否");
- }
- }
- }
- return company == null ? new Company() : company;
- }
-
- /**
- * 查询企业名称是否存在
- */
- public boolean isCompanyNameExist(String company_name) {
- boolean flag = companyDao.isCompanyNameExist(company_name) > 0 ? true : false;
- return flag;
- }
- /**
- * 查询企业统一社会信用代码是否存在
- */
- public boolean isCompanyUsccExist(String uscc) {
- boolean flag = companyDao.isCompanyUsccExist(uscc) > 0 ? true : false;
- return flag;
- }
- /**
- * 查询企业组织机构代码是否存在
- */
- public boolean isCompanyOrganizationCodeExist(String organization_code, String company_id) {
- boolean flag = companyDao.isCompanyOrganizationCodeExist(organization_code, company_id) > 0 ? true : false;
- return flag;
- }
- /**
- * 根据企业名称和组织机构代码查询唯一企业
- */
- public boolean isCompanyExist(String company_name, String organization_code) {
- boolean flag = companyDao.isCompanyExist(company_name, organization_code) > 0 ? true : false;
- return flag;
- }
- public ResponseMessage approval(Integer type, Integer id, String approval_comment) throws Exception {
- Example userexample = new Example(User.class);
- Example.Criteria usercriteria = userexample.createCriteria();
- usercriteria.andEqualTo("del_flag", "0");
- usercriteria.andEqualTo("user_type", Constant.UserType.COMPANY);
- usercriteria.andEqualTo("company_id", id);
- userexample.orderBy("create_time").asc();
- List<User> users = userService.selectByExample(userexample);
- List<CompanyContact> companyContacts = companyContactService.findByCompanyId(id);
- if (type == 1) {//通过
- //查询最近的一条审核记录
- Approval approval = approvalService.getLatestApproval(id, Constant.DictionaryType.COMPANY_REGISTER);
- if (approval.getOper_type().equals(Constant.OperType.APPROVED) || approval.getOper_type().equals(Constant.OperType.REJECT)) {
- return ResponseMessage.error("该单据已审核!");
- }
- String nextChecker = approval.getNextchecker() == null ? "" : approval.getNextchecker();
- Company company = this.findById(id);
- User user = userService.findById(company.getCreate_by());
- user.setIs_register(1);
- user.setIs_start(true);
- userService.updateSelective(user);
- //userService.updateIsRegist(user.getId() + "", 1 + "");
- company.setIs_register(1);
- company.setIs_start(true);
- //}
- this.updateSelective(company);
- nextChecker = nextChecker.replace(ShiroUtils.getUserEntity().getId() + ",", "");
- Approval approval1 = new Approval();
- String department = "";
- if (null != userService.findById(ShiroUtils.getUserId()).getDepartment_id()) {
- Department dept = departmentService.findById(userService.findById(ShiroUtils.getUserId()).getDepartment_id());
- if (null != dept) {
- department = dept.getName();
- }
- }
- approval1.setDepartment(department);
- approval1.setApply_id(id);
- approval1.setType(Constant.DictionaryType.COMPANY_REGISTER);
- approval1.setApproval_comment(approval_comment);
- approval1.setBefore_approvalstatus("0");
- approval1.setAfter_approvalstatus("1");
- approval1.setDeal_time(DateUtil.getTimeString(new Date()));
- approval1.setChecker(ShiroUtils.getUserId());
- approval1.setNextchecker(nextChecker);
- approval1.setOper_type(Constant.OperType.APPROVED);
- //保存审核记录
- approvalService.insertAndGetId(approval1);
- if (CommonUtils.isNotNull(users) && users.size() > 0 ) {
- sendSMSToRegisteredCompanyUser(users.get(0), true, approval1);
- }
- } else {//退回
- //查询最近的一条审核记录
- Approval approval = approvalService.getLatestApproval(id, Constant.DictionaryType.COMPANY_REGISTER);
- if (approval.getOper_type().equals(Constant.OperType.APPROVED) || approval.getOper_type().equals(Constant.OperType.REJECT)) {
- return ResponseMessage.error("该单据已审核!");
- }
- Approval approval1 = new Approval();
- String department = "";
- if (null != userService.findById(ShiroUtils.getUserId()).getDepartment_id()) {
- Department dept = departmentService.findById(userService.findById(ShiroUtils.getUserId()).getDepartment_id());
- if (null != dept) {
- department = dept.getName();
- }
- }
- approval1.setDepartment(department);
- approval1.setApply_id(id);
- approval1.setType(Constant.DictionaryType.COMPANY_REGISTER);
- approval1.setApproval_comment(approval_comment);
- approval1.setBefore_approvalstatus("0");
- approval1.setAfter_approvalstatus("0");
- approval1.setDeal_time(DateUtil.getTimeString(new Date()));
- approval1.setChecker(ShiroUtils.getUserId());
- approval1.setOper_type(Constant.OperType.REJECT);
- //保存审核记录
- approvalService.insertAndGetId(approval1);
- //退回,把company删掉,否则不能再注册相同名称的企业
- Company company = this.findById(id);
- company.setDel_flag(true);
- this.updateSelective(company);
- User user = userService.findById(company.getCreate_by());
- user.setIs_register(2);
- user.setDel_flag(true);
- userService.updateSelective(user);
- if (CommonUtils.isNotNull(user) && users.size() > 0) {
- sendSMSToRegisteredCompanyUser(users.get(0), false, approval1);
- }
- //同步信息给天启
- // SyncUserDto dto = new SyncUserDto();
- // dto.setAction(Constant.METHOD_STATUS.INSERT);
- // dto.setOldUserName("");
- // dto.setUserName(user.getUser_name());
- // dto.setUserLoginName(user.getNick_name());
- // dto.setPassword(user.getPassword().trim());
- // dto.setCompanyName(user.getCompany_name());
- // if (null != user.getStreet_id()) {
- // Street street = streeService.findById(user.getStreet_id());
- // dto.setStreetName(street.getName());
- // }
- // dto.setToken(skyImageApiService.accessToken());
- // skyImageApiService.syncUserInfo(dto);
- }
- //完成待办
- waitToDoService.completeAllTODO(id, Constant.DictionaryType.COMPANY_REGISTER);
- return ResponseMessage.success("审核成功!");
- }
- //发送短信给企业用户,账号注册成功/失败
- // 发送短信 错误修改 wangjiang 2020-1-8
- private void sendSMSToRegisteredCompanyUser(User user, Boolean isPassed, Approval approval) {
- String templateParam;
- String phone = user.getPhone();
- logger.info("send msg to register company user which phone is : {}", phone);
- if (isPassed) {
- //发送短信给企业用户,账号注册成功
- //您的企业${company_name}账号注册,审核通过啦! 账号名为${nick_name}。感谢您的支持。
- // String phone = user.getPhone();
- String nick_name = user.getNick_name();
- String company_name = user.getCompany_name();
- templateParam = "{\"nick_name\":\"" + nick_name + "\",\"company_name\":\"" + company_name + "\"}";
- // AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.COMPANY_USER_REGISTER_PASSED, Constant.SINGNAMW, templateParam);
- } else {
- //发送短信给企业用户,账号注册失败
- //您的企业${company_name}账号注册(账号名为${nick_name}),审核失败。${comment}感谢您的支持。
- // String phone = user.getPhone();
- String nick_name = user.getNick_name();
- String company_name = user.getCompany_name();
- String comment = approval.getApproval_comment();
- if (null != comment && comment.length() > 20) {
- comment = comment.substring(0, 20);
- }
- templateParam = "{\"nick_name\":\"" + nick_name + "\",\"comment\":\"" + comment + "\",\"company_name\":\"" + company_name + "\"}";
- }
- try {
- AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.COMPANY_USER_REGISTER_REJECT, Constant.SINGNAMW, templateParam);
- } catch (ClientException e) {
- logger.error("发送阿里巴巴sms错误(ClientException):{}", e.getMessage());
- e.printStackTrace();
- throw new RuntimeException("发送阿里巴巴sms错误(ClientException):" + e.getMessage());
- } catch (InterruptedException e) {
- logger.error("发送阿里巴巴sms错误(InterruptedException):{}", e.getMessage());
- e.printStackTrace();
- throw new RuntimeException("发送阿里巴巴sms错误(InterruptedException):" + e.getMessage());
- }
- }
- public List<Company> findCompanyByCondition(Integer currentStreet_id, Integer currentUserId, String keyword, Company searchCondition) {
- return companyDao.findCompanyByCondition(currentStreet_id, currentUserId,
- Constant.DictionaryType.COMPANY_REGISTER, keyword, searchCondition);
- }
- public List<Company> findListByContidion(Integer userId, Integer currentStreet_id, String keyword, Company searchCondition) {
- return companyDao.findListByContidion(userId, currentStreet_id, Constant.DictionaryType.COMPANY_REGISTER, keyword, searchCondition);
- }
- public String getCompanyName(Integer id) {
- Company company = this.findById(id);
- if (null != company) {
- return company.getCompany_name();
- }
- return "";
- }
- //获取企业信息,基本信息、联系人
- public Company findCompanyInfo(Integer companyId) {
- if (null != companyId) {
- Company company = this.findById(companyId);
- if (null != company.getStreet_id()) {
- try {
- company.setStreet_name(streeService.getStreetName(company.getStreet_id()));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- if (null != company) {
- company.setCompanyContacts(companyContactService.findByCompanyId(companyId));
- company.setBuildingStreets(buildingStreetService.findByCompanyId(companyId));
- return company;
- }
- }
- return new Company();
- }
- public List<Company> findCompanysByBuildIds(List<String> buildIds, String type_id) {
- Example example = new Example(Company.class);
- Example.Criteria criteria = example.createCriteria();
- Example.Criteria criteria2 = example.createCriteria();
- criteria.andEqualTo("del_flag", "0");
- if (!Objects.equals("", type_id) && !Objects.equals(null, type_id)) {
- criteria.andEqualTo("type_id", type_id);
- }
- for (String id : buildIds) {
- criteria2.orEqualTo("build_id", id);
- }
- example.and(criteria2);
- //倒序
- example.orderBy("create_time").desc();
- List<Company> companyInfo = this.selectByExample(example);
- return companyInfo;
- }
- /**
- * selectCompanyById(由企业id获取企业信息)
- *
- * @param id
- * @return Company
- */
- public Company selectCompanyById(int id) {
- return companyDao.selectCompanyById(id);
- }
- @SuppressWarnings({"unused", "unused"})
- public Company findConpanyInfoById(int id) {
- Company company = this.findById(id);
- Integer type = company.getType();
- //企业性质
- if (null != type) {
- company.setType_name(dictionaryItemService.findByItemId(type).getName());
- } else {
- company.setType_name("");
- }
- //注册资本
- Integer currency_unit = company.getCurrency_unit();
- if (null != currency_unit) {
- company.setCurrency_unit_name(dictionaryItemService.findByItemId(currency_unit).getName());
- } else {
- company.setCurrency_unit_name("");
- }
- //街道
- Integer street_id = company.getStreet_id();
- if (null != street_id) {
- company.setStreet_name(streeService.selectById(street_id).getName());
- } else {
- company.setStreet_name("");
- }
- //园区
- Integer build_id = company.getBuild_id();
- if (null != build_id) {
- company.setBuild_name(buildInfoService.selectById(build_id).getName());
- } else {
- company.setBuild_name("");
- }
- return company;
- }
- //存量用地街道查询企业,包含厂房在本街道的企业
- public PageInfo<Company> findStockLandCompany(Integer pageNum, Integer pageSize, String keyword,
- CompanyDto companyDto) {
- PageHelper.startPage(pageNum, pageSize);
- Integer street_id = ShiroUtils.getUserEntity().getStreet_id();
- List<Company> companys = null;
- companys = companyDao.selectStockLandCompany(street_id, keyword);
- for (Company company : companys) {
- if (null != company.getType_id()) {
- BuildType buildType = buildTypeService.findById(company.getType_id());
- if (null != buildType) {
- company.setType_name(buildType.getType());
- }
- }
- company.setCompanyContacts(companyContactService.findByCompanyId(company.getId()));
- }
- return new PageInfo<Company>(companys);
- }
- public List<StreetCompanys> getStreetCompanys() {
- return companyDao.getStreetCompanys();
- }
- @Transactional(readOnly = true)
- public List<Company> getTotalCompanys() {
- Example example = new Example(Company.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("del_flag", 0);
- criteria.andEqualTo("is_register", 1);
- criteria.andEqualTo("is_start", 1);
- criteria.andIsNotNull("street_id");
- return this.selectByExample(example);
- }
- public List<Company> getCompanyByCondition(SearchCondition condition) {
- return companyDao.getCompanyByCondition(condition);
- }
- public PageInfo<Company> getCompanyPageByCondition(Integer pageNum, Integer pageSize, CustomSearchCondition condition) {
- PageHelper.startPage(pageNum, pageSize);
- SearchCondition searchCondition = new SearchCondition();
- searchCondition.setCompanyName(condition.getName());
- List<Company> list = companyDao.getCompanyByCondition(searchCondition);
- return new PageInfo<>(list);
- }
- public List<Company> getCompanyListByCondition(CustomSearchCondition condition) {
- SearchCondition searchCondition = new SearchCondition();
- searchCondition.setCompanyName(condition.getName());
- List<Company> list = companyDao.getCompanyByCondition(searchCondition);
- return list;
- }
- public Company findByParkIdAndCompanyName(String company_name, Integer id) {
- return companyDao.findByParkIdAndCompanyName(company_name, id);
- }
- /**
- * 获取公司信息
- *
- * @param userId
- * @return
- */
- public CompanyInfoDto findByUserId(Integer userId) {
- return companyDao.findByUserId(userId);
- }
- /**
- * 获取公司联系人
- *
- * @param letter
- * @return
- */
- public List<CompanyContacts> findCompanyListByName(String letter, String companyName) {
- return companyContactService.findCompanyContactList(letter, companyName, ShiroUtils.getStreetId(), ShiroUtils.getBuildId());
- }
- private List<Company> companyContacts(String letter, String searchName) {
- List<CompanyContact> companies = companyContactService.findContactList(searchName);
- List<Company> companyList = new ArrayList<>();
- List<CompanyContact> contactList = new ArrayList<>();
- CompanyContacts ccs = new CompanyContacts();
- for (LetterEnum anEnum : LetterEnum.values()) {
- ccs.setLetter(anEnum.toString());
- for (CompanyContact contact : companies) {
- if (contact.getLetter().equals(anEnum.toString())){
- }
- }
- }
- return null;
- }
- /**
- * 根据社会统一信用代码查找企业
- *
- * @param uscc
- */
- public List<Company> findListByUscc(String uscc) {
- return companyDao.findListByUscc(uscc);
- }
- }
|