CompanyInfoManageService.java 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  1. package platform.modules.company.service;
  2. import java.io.InputStream;
  3. import java.text.SimpleDateFormat;
  4. import java.util.*;
  5. import java.util.regex.Matcher;
  6. import java.util.regex.Pattern;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.apache.poi.ss.usermodel.Cell;
  9. import org.apache.poi.ss.usermodel.Row;
  10. import org.apache.poi.ss.usermodel.Sheet;
  11. import org.apache.poi.ss.usermodel.Workbook;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import org.springframework.transaction.annotation.Transactional;
  15. import com.aliyuncs.exceptions.ClientException;
  16. import com.github.pagehelper.PageHelper;
  17. import com.github.pagehelper.PageInfo;
  18. import com.xiaoleilu.hutool.crypto.SecureUtil;
  19. import org.springframework.util.CollectionUtils;
  20. import platform.common.Constant;
  21. import platform.common.base.service.BaseService;
  22. import platform.common.base.service.DictionaryItemService;
  23. import platform.common.base.service.DictionaryTypeService;
  24. import platform.common.util.AlibabaSMSUtil;
  25. import platform.common.util.DateUtil;
  26. import platform.common.util.ExportExcel;
  27. import platform.common.util.ShiroUtils;
  28. import platform.common.util.WebUtil;
  29. import platform.modules.build.DTO.CompanyDto;
  30. import platform.modules.build.dao.CompanyContactDao;
  31. import platform.modules.build.dao.CompanyDao;
  32. import platform.modules.build.entity.BuildInfo;
  33. import platform.modules.build.entity.Company;
  34. import platform.modules.build.entity.CompanyContact;
  35. import platform.modules.build.service.BuildInfoService;
  36. import platform.modules.build.service.CompanyContactService;
  37. import platform.modules.build.service.CompanyService;
  38. import platform.modules.company.dto.CompanyInfoExportDto;
  39. import platform.modules.company.dto.CompanyInfoManageDto;
  40. import platform.modules.company.entity.CompanyInfoData;
  41. import platform.modules.government.entity.BuildType;
  42. import platform.modules.government.entity.Street;
  43. import platform.modules.government.entity.User;
  44. import platform.modules.government.service.BuildTypeService;
  45. import platform.modules.government.service.StreetService;
  46. import platform.modules.government.service.UserService;
  47. import platform.modules.sys.entity.Approval;
  48. import platform.modules.sys.entity.Role;
  49. import platform.modules.sys.entity.UserRole;
  50. import platform.modules.sys.service.ApprovalService;
  51. import platform.modules.sys.service.RoleService;
  52. import platform.modules.sys.service.UserRoleService;
  53. import platform.modules.sys.web.ResponseMessage;
  54. import tk.mybatis.mapper.entity.Example;
  55. import tk.mybatis.mapper.entity.Example.Criteria;
  56. @Service
  57. @Transactional
  58. public class CompanyInfoManageService extends BaseService<Company> {
  59. @Autowired
  60. private CompanyService companyService;
  61. @Autowired
  62. private CompanyContactService companyContactService;
  63. @Autowired
  64. private CompanyContactDao companyContactdao;
  65. @Autowired
  66. private BuildTypeService buildTypeService;
  67. @Autowired
  68. private CompanyDao companyDao;
  69. @Autowired
  70. private BuildInfoService buildInfoService;
  71. @Autowired
  72. private StreetService streetService;
  73. @Autowired
  74. private DictionaryTypeService dictionaryTypeService;
  75. @Autowired
  76. private DictionaryItemService dictionaryItemService;
  77. @Autowired
  78. private RoleService roleService;
  79. @Autowired
  80. private UserService userService;
  81. public PageInfo<Company> findPage(Integer pageNum, Integer pageSize,
  82. CompanyDto companyDto, CompanyInfoManageDto companyInfoManageDto) throws Exception {
  83. if (StringUtils.isNotBlank(companyInfoManageDto.getKcompany_name())) {
  84. companyInfoManageDto.setKcompany_name(companyInfoManageDto.getKcompany_name().trim());
  85. }
  86. if (StringUtils.isNotBlank(companyInfoManageDto.getKuscc())) {
  87. companyInfoManageDto.setKuscc(companyInfoManageDto.getKuscc().trim());
  88. }
  89. if (StringUtils.isNotBlank(companyInfoManageDto.getKorganization_code())) {
  90. companyInfoManageDto.setKorganization_code(companyInfoManageDto.getKorganization_code().trim());
  91. }
  92. if (StringUtils.isNotBlank(companyInfoManageDto.getKindustry_code())) {
  93. companyInfoManageDto.setKindustry_code(companyInfoManageDto.getKindustry_code().trim());
  94. }
  95. if (StringUtils.isNotBlank(companyInfoManageDto.getKlegal_representative())) {
  96. companyInfoManageDto.setKlegal_representative(companyInfoManageDto.getKlegal_representative().trim());
  97. }
  98. PageHelper.startPage(pageNum, pageSize);
  99. List<Company> contents = companyDao.findByCondition(companyInfoManageDto);
  100. for (Company company : contents) {
  101. if (null != company.getType_id()) {
  102. BuildType buildType = buildTypeService.findById(company.getType_id());
  103. if (null != buildType) {
  104. company.setType_name(buildType.getType());
  105. }
  106. }
  107. company.setCompanyContacts(companyContactService.findByCompanyId(company.getId()));
  108. Integer build_id = company.getBuild_id();
  109. if (build_id != null) {
  110. BuildInfo info = buildInfoService.findById(build_id);
  111. if (null != info) {
  112. company.setBuild_name(info.getName());
  113. }
  114. }
  115. Integer street_id = company.getStreet_id();
  116. if (street_id != null) {
  117. company.setStreet_name(streetService.findById(street_id).getName());
  118. }
  119. }
  120. return new PageInfo<Company>(contents);
  121. }
  122. public PageInfo<Company> findPages(Integer pageNum, Integer pageSize,
  123. CompanyDto companyDto, CompanyInfoManageDto companyInfoManageDto) throws Exception {
  124. if (StringUtils.isNotBlank(companyInfoManageDto.getKcompany_name())) {
  125. companyInfoManageDto.setKcompany_name(companyInfoManageDto.getKcompany_name().trim());
  126. }
  127. if (StringUtils.isNotBlank(companyInfoManageDto.getKuscc())) {
  128. companyInfoManageDto.setKuscc(companyInfoManageDto.getKuscc().trim());
  129. }
  130. if (StringUtils.isNotBlank(companyInfoManageDto.getKorganization_code())) {
  131. companyInfoManageDto.setKorganization_code(companyInfoManageDto.getKorganization_code().trim());
  132. }
  133. if (StringUtils.isNotBlank(companyInfoManageDto.getKindustry_code())) {
  134. companyInfoManageDto.setKindustry_code(companyInfoManageDto.getKindustry_code().trim());
  135. }
  136. if (StringUtils.isNotBlank(companyInfoManageDto.getKlegal_representative())) {
  137. companyInfoManageDto.setKlegal_representative(companyInfoManageDto.getKlegal_representative().trim());
  138. }
  139. PageHelper.startPage(pageNum, pageSize);
  140. List<Company> contents = companyDao.findByConditions(companyInfoManageDto);
  141. for (Company company : contents) {
  142. if (null != company.getType_id()) {
  143. BuildType buildType = buildTypeService.findById(company.getType_id());
  144. if (null != buildType) {
  145. company.setType_name(buildType.getType());
  146. }
  147. }
  148. company.setCompanyContacts(companyContactService.findByCompanyId(company.getId()));
  149. Integer build_id = company.getBuild_id();
  150. if (build_id != null) {
  151. BuildInfo info = buildInfoService.findById(build_id);
  152. if (null != info) {
  153. company.setBuild_name(info.getName());
  154. }
  155. }
  156. Integer street_id = company.getStreet_id();
  157. if (street_id != null) {
  158. company.setStreet_name(streetService.findById(street_id).getName());
  159. }
  160. }
  161. return new PageInfo<Company>(contents);
  162. }
  163. public PageInfo<Company> findPage2(Integer pageNum, Integer pageSize,
  164. CompanyDto companyDto, CompanyInfoManageDto companyInfoManageDto) throws Exception {
  165. if (StringUtils.isNotBlank(companyInfoManageDto.getKcompany_name())) {
  166. companyInfoManageDto.setKcompany_name(companyInfoManageDto.getKcompany_name().trim());
  167. }
  168. if (StringUtils.isNotBlank(companyInfoManageDto.getKuscc())) {
  169. companyInfoManageDto.setKuscc(companyInfoManageDto.getKuscc().trim());
  170. }
  171. if (StringUtils.isNotBlank(companyInfoManageDto.getKorganization_code())) {
  172. companyInfoManageDto.setKorganization_code(companyInfoManageDto.getKorganization_code().trim());
  173. }
  174. if (StringUtils.isNotBlank(companyInfoManageDto.getKindustry_code())) {
  175. companyInfoManageDto.setKindustry_code(companyInfoManageDto.getKindustry_code().trim());
  176. }
  177. if (StringUtils.isNotBlank(companyInfoManageDto.getKlegal_representative())) {
  178. companyInfoManageDto.setKlegal_representative(companyInfoManageDto.getKlegal_representative().trim());
  179. }
  180. PageHelper.startPage(pageNum, pageSize);
  181. List<Company> contents = companyDao.findByCondition(companyInfoManageDto);
  182. for (Company company : contents) {
  183. if (null != company.getType_id()) {
  184. BuildType buildType = buildTypeService.findById(company.getType_id());
  185. if (null != buildType) {
  186. company.setType_name(buildType.getType());
  187. }
  188. }
  189. company.setCompanyContacts(companyContactService.findByCompanyId(company.getId()));
  190. Integer build_id = company.getBuild_id();
  191. if (build_id != null) {
  192. company.setBuild_name(buildInfoService.findById(build_id).getName());
  193. }
  194. Integer street_id = company.getStreet_id();
  195. if (street_id != null) {
  196. company.setStreet_name(streetService.findById(street_id).getName());
  197. }
  198. }
  199. return new PageInfo<Company>(contents);
  200. }
  201. /**
  202. * 新增企业信息
  203. */
  204. @Transactional(readOnly = false)
  205. public Boolean saveCompanyInfo(Company information) throws Exception {
  206. //information.setBuild_id(ShiroUtils.getUserEntity().getBuild_id());
  207. //information.setStreet_id(ShiroUtils.getUserEntity().getStreet_id());
  208. //新增企业信息
  209. information.setIs_start(true);
  210. information.setNature(1);
  211. information.setIs_register(1);
  212. boolean flag = companyService.saveSelective(information) > 0 ? true : false;
  213. if (flag) {
  214. List<CompanyContact> companyContactList = information.getCompanyContacts();
  215. Calendar cal = Calendar.getInstance();
  216. int y = cal.get(Calendar.YEAR);
  217. int m = cal.get(Calendar.MONTH);
  218. int d = cal.get(Calendar.DATE);
  219. int h = cal.get(Calendar.HOUR_OF_DAY);
  220. int mi = cal.get(Calendar.MINUTE);
  221. int s = cal.get(Calendar.SECOND);
  222. if (companyContactList != null && companyContactList.size() > 0) {
  223. for (int i = 0; i < companyContactList.size(); i++) {
  224. //2018-04-17 19:02:33
  225. String create_time = "";
  226. if (mi < 10) {
  227. mi += 1;
  228. create_time = y + "-" + m + "-" + d + " " + h + ":0" + mi + ":" + s;
  229. } else {
  230. mi += 1;
  231. create_time = y + "-" + m + "-" + d + " " + h + ":" + mi + ":" + s;
  232. }
  233. Integer company_id = information.getId();
  234. String contact = companyContactList.get(i).getContact();
  235. String phone = companyContactList.get(i).getPhone();
  236. String position = companyContactList.get(i).getPosition();
  237. Integer create_by = ShiroUtils.getUserId();
  238. String create_name = ShiroUtils.getUserName();
  239. companyContactdao.insertInfo(company_id, contact, phone, position, create_time, create_by, create_name);
  240. }
  241. }
  242. //return true;
  243. }
  244. //为企业新增企业管理员,用户名:组织机构代码、密码:123456、角色:企业管理员
  245. String init_password = "";
  246. String organization_code = information.getOrganization_code();
  247. User user = new User();
  248. if (StringUtils.isNotBlank(organization_code)) {
  249. user.setNick_name(organization_code);
  250. user.setUser_name(organization_code);
  251. String passWord = organization_code.substring(3, organization_code.length());
  252. init_password = passWord;
  253. user.setPassword(SecureUtil.md5().digestHex(passWord));
  254. } else {
  255. init_password = "123456";
  256. String phone = information.getCompanyContacts().get(0).getPhone();
  257. user.setNick_name(phone);
  258. user.setUser_name(phone);
  259. user.setPassword(SecureUtil.md5().digestHex("123456"));
  260. }
  261. user.setIs_start(true);
  262. if (null != information.getBuild_id()) {
  263. user.setBuild_id(information.getBuild_id());
  264. user.setBuild_name(buildInfoService.findById(information.getBuild_id()).getName());
  265. }
  266. user.setStreet_id(information.getStreet_id());
  267. user.setStreet_name(streetService.findById(information.getStreet_id()).getName());
  268. //user.setUser_type(Constant.UserType.COMPANY);
  269. user.setIs_admin(true);
  270. user.setUser_type(Constant.UserType.COMPANY);
  271. user.setCompany_id(companyService.findByCompanyName(information.getCompany_name()).getId());
  272. user.setCompany_name(information.getCompany_name());
  273. user.setCreate_by(ShiroUtils.getUserEntity().getId());
  274. user.setCreate_name(ShiroUtils.getUserEntity().getNick_name());
  275. userService.saveSelective(user);
  276. sendSMSToNewCompanyUser(init_password, user, information);
  277. return true;
  278. }
  279. //发送短信给企业用户,账号新增成功
  280. private void sendSMSToNewCompanyUser(String init_password, User user, Company company) throws ClientException, InterruptedException {
  281. //发送短信给企业用户,账号新增成功
  282. //您的企业 ${company_name} 平台账号名为${nick_name},初始密码为${initPassword},首次登录后,请修改密码。感谢您的支持。
  283. String company_name = user.getCompany_name();
  284. String phone = company.getCompanyContacts().get(0).getPhone();
  285. String nick_name = user.getNick_name();
  286. String templateParam = "{\"nick_name\":\"" + nick_name + "\",\"initPassword\":\"" + init_password + "\",\"company_name\":\"" + company_name + "\"}";
  287. AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.NEW_COMPANY_USER, Constant.SINGNAMW, templateParam);
  288. }
  289. /**
  290. * 删除企业信息
  291. */
  292. public ResponseMessage delInfo(Integer id) {
  293. boolean flag = false;
  294. if (id != null) {
  295. Company findById = companyService.findById(id);
  296. findById.setDel_flag(true);
  297. flag = companyService.updateSelective(findById) > 0 ? true : false;
  298. companyContactService.deleteByCompanyId(id);
  299. }
  300. if (flag) {
  301. return ResponseMessage.success("删除成功");
  302. } else {
  303. return ResponseMessage.error("删除失败");
  304. }
  305. }
  306. /**
  307. * 启用企业信息
  308. */
  309. public ResponseMessage startBatch(String[] ids) {
  310. try {
  311. for (String id : ids) {
  312. Company findById = companyService.findById(Integer.parseInt(id));
  313. findById.setIs_start(true);
  314. companyService.updateSelective(findById);
  315. }
  316. return ResponseMessage.success("启用成功");
  317. } catch (Exception e) {
  318. e.printStackTrace();
  319. return ResponseMessage.error("启用失败");
  320. }
  321. }
  322. /**
  323. * 禁用企业信息
  324. */
  325. public ResponseMessage stopBatch(String[] ids) {
  326. try {
  327. for (String id : ids) {
  328. Company findById = companyService.findById(Integer.parseInt(id));
  329. findById.setIs_start(false);
  330. companyService.updateSelective(findById);
  331. }
  332. return ResponseMessage.success("禁用成功");
  333. } catch (Exception e) {
  334. e.printStackTrace();
  335. return ResponseMessage.error("禁用失败");
  336. }
  337. }
  338. /**
  339. * 修改企业信息
  340. */
  341. public ResponseMessage editInfo(Integer id, Company information) {
  342. boolean flag = false;
  343. companyContactService.deleteByCompanyId(id);
  344. flag = companyService.updateSelective(information) > 0 ? true : false;
  345. if (!CollectionUtils.isEmpty(information.getCompanyContacts())) {
  346. for (CompanyContact companyContact : information.getCompanyContacts()) {
  347. companyContact.setCompany_id(information.getId());
  348. companyContactService.saveSelective(companyContact);
  349. }
  350. }
  351. User user = new User();
  352. user.setStreet_name(information.getStreet_name());
  353. user.setStreet_id(information.getStreet_id());
  354. userService.updateByCompanyId(id.toString(), user);
  355. if (flag) {
  356. return ResponseMessage.success("编辑成功");
  357. } else {
  358. return ResponseMessage.error("编辑失败");
  359. }
  360. }
  361. /**
  362. * 多条件模糊查询企业信息
  363. */
  364. public PageInfo<Company> finByCondition(Integer pageNum, Integer pagesize,
  365. CompanyInfoManageDto companyInfoManageDto) {
  366. PageHelper.startPage(pageNum, pagesize);
  367. List<Company> companies = companyDao.findByCondition(companyInfoManageDto);
  368. return new PageInfo<Company>(companies);
  369. }
  370. //导出所有企业信息数据
  371. public List<Company> findExportCompany(CompanyInfoManageDto companyInfoManageDto) {
  372. List<Company> cList = null;
  373. if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
  374. companyInfoManageDto.setStreet_id(ShiroUtils.getStreetId());
  375. cList = companyDao.findByCondition(companyInfoManageDto);
  376. } else if (ShiroUtils.getUserType().equals(Constant.UserType.GOVERNMENT)) {
  377. cList = companyDao.findByCondition(companyInfoManageDto);
  378. }
  379. for (Company company : cList) {
  380. if (company.getBuild_id() != null) {
  381. String buildName = "";
  382. BuildInfo buildInfo = buildInfoService.findById(company.getBuild_id());
  383. if (buildInfo != null){
  384. buildName = buildInfo.getName();
  385. }
  386. company.setBuild_name(buildName);
  387. }
  388. if (company.getStreet_id() != null) {
  389. String streetName = "";
  390. Street street = streetService.findById(company.getStreet_id());
  391. if (street != null){
  392. streetName = street.getName();
  393. }
  394. company.setStreet_name(streetName);
  395. }
  396. if (company.getIs_start() == true) {
  397. company.setIs_start_name("启用");
  398. } else {
  399. company.setIs_start_name("禁用");
  400. }
  401. }
  402. return cList;
  403. }
  404. //导出所有企业信息数据
  405. public List<Company> findExportCompanyByStreet(CompanyInfoManageDto companyInfoManageDto) {
  406. List<Company> cList = companyDao.findByCondition(companyInfoManageDto);
  407. for (Company company : cList) {
  408. if (company.getBuild_id() != null) {
  409. company.setBuild_name(buildInfoService.findById(company.getBuild_id()).getName());
  410. }
  411. if (company.getStreet_id() != null) {
  412. company.setStreet_name(streetService.findById(company.getStreet_id()).getName());
  413. }
  414. if (company.getIs_start() == true) {
  415. company.setIs_start_name("启用");
  416. } else {
  417. company.setIs_start_name("禁用");
  418. }
  419. }
  420. return cList;
  421. }
  422. /**
  423. * 获取单元格值
  424. */
  425. private static String getCellValue(Cell cell, int index, String thead) throws Exception {
  426. String value = null;
  427. if (cell != null) {
  428. cell.setCellType(Cell.CELL_TYPE_STRING);
  429. value = cell.getStringCellValue();
  430. if (StringUtils.isNotBlank(value)) {
  431. return value;
  432. }
  433. }
  434. return value;
  435. //throw new Exception("第"+(index+1)+"行"+thead+"不能为空");
  436. }
  437. /**
  438. * 批量导入企业信息
  439. *
  440. * @throws Exception
  441. */
  442. public void importCompanyInfoData(InputStream inputStream, Workbook wb) throws Exception {
  443. List<CompanyInfoData> dataList = null;
  444. //街道用户导入
  445. if (ShiroUtils.getUserType().equals(Constant.UserType.GOVERNMENT)) {
  446. dataList = getExcelData(wb);
  447. } else if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
  448. Street street = streetService.selectById(ShiroUtils.getStreetId());
  449. dataList = getExcelDataOnStreet(wb, street.getName());
  450. }
  451. validData(dataList);
  452. saveData(dataList);
  453. }
  454. /**
  455. * isValidDate(判断一个字符串是否符合yyyy/MM/dd的时间格式)
  456. *
  457. * @param s
  458. * @return boolean
  459. * @throws
  460. */
  461. public static boolean isValidDate(String s) {
  462. boolean flag = false;
  463. if (StringUtils.isNotBlank(s)) {
  464. if (s.length() > 10) {
  465. return flag;
  466. }
  467. } else {
  468. flag = true;
  469. return flag;
  470. }
  471. try {
  472. // 指定日期格式为四位年/两位月份/两位日期,注意yyyy-MM-dd其中MM为大写
  473. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
  474. // 设置lenient为false. 否则SimpleDateFormat会比较宽松地验证日期,比如2004/02/29会被接受,并转换成2004/03/01
  475. dateFormat.setLenient(false);
  476. Date parse = dateFormat.parse(s);
  477. flag = true;
  478. return flag;
  479. } catch (Exception e) {
  480. // 如果throw java.text.ParseException或者NullPointerException,就说明格式不对
  481. e.printStackTrace();
  482. flag = false;
  483. return flag;
  484. }
  485. }
  486. public static boolean isRowEmpty(Row row) {
  487. for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
  488. Cell cell = row.getCell(c);
  489. if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
  490. return false;
  491. }
  492. }
  493. return true;
  494. }
  495. /**
  496. * 读取数据(政府用户)
  497. *
  498. * @throws Exception
  499. */
  500. private List<CompanyInfoData> getExcelData(Workbook wb) throws Exception {
  501. List<CompanyInfoData> dataList = new ArrayList<>();
  502. List<String> nameList = new ArrayList<>();
  503. nameList.clear();
  504. Row row = null;
  505. Cell cell = null;
  506. Sheet sheet = (Sheet) wb.getSheetAt(0);
  507. int tatalRows = sheet.getPhysicalNumberOfRows();
  508. //sheet.getr
  509. if (tatalRows == 2) {
  510. throw new Exception("请添加企业信息数据");
  511. }
  512. //从一行读取数据
  513. for (int r = 2; r < tatalRows; r++) {
  514. //获取行数据
  515. row = sheet.getRow(r);
  516. cell = row.getCell(0);
  517. String cellValue = getCellValue(cell, r, "序号");
  518. if (StringUtils.isBlank(cellValue)) {
  519. break;
  520. }
  521. CompanyInfoData com = new CompanyInfoData();
  522. cell = row.getCell(1);
  523. com.setUscc(getCellValue(cell, r, "统一社会信用代码"));
  524. cell = row.getCell(2);
  525. //String organization_code = getCellValue(cell,r,"组织机构代码");
  526. com.setOrganization_code(getCellValue(cell, r, "组织机构代码"));
  527. cell = row.getCell(3);
  528. String company_name = getCellValue(cell, r, "企业名称");
  529. if (nameList.size() > 0 && StringUtils.isNotBlank(company_name) && nameList.contains(company_name)) {
  530. //System.out.println(cellValue + "--------------->" + organization_code + "=================================================================================================");
  531. throw new Exception("企业名称为:" + company_name + ",企业已经存在,请修改企业名称!");
  532. }
  533. com.setCompany_name(getCellValue(cell, r, "企业名称"));
  534. cell = row.getCell(4);
  535. com.setLegal_Representative(getCellValue(cell, r, "法人代表人"));
  536. cell = row.getCell(5);
  537. com.setIndustry_Code(getCellValue(cell, r, "行业代码"));
  538. cell = row.getCell(6);
  539. com.setType_name(getCellValue(cell, r, "企业性质"));
  540. cell = row.getCell(7);
  541. com.setStreet_name(getCellValue(cell, r, "所属区域"));
  542. cell = row.getCell(8);
  543. com.setBuild_name(getCellValue(cell, r, "所属工业区"));
  544. cell = row.getCell(9);
  545. com.setRelation_Name(getCellValue(cell, r, "管理部门"));
  546. cell = row.getCell(10);
  547. com.setRegistration_Capital(getCellValue(cell, r, "注册资本"));
  548. cell = row.getCell(11);
  549. // String date = cell.getStringCellValue();
  550. boolean flag = isValidDate(getCellValue(cell, r, "注册日期"));
  551. if (flag) {
  552. com.setEstablishment_date(getCellValue(cell, r, "注册日期"));
  553. } else {
  554. throw new Exception("时间格式非法");
  555. }
  556. cell = row.getCell(12);
  557. com.setLocation(getCellValue(cell, r, "地址"));
  558. cell = row.getCell(13);
  559. com.setBusiness(getCellValue(cell, r, "经营范围"));
  560. cell = row.getCell(14);
  561. com.setType_id_name(getCellValue(cell, r, "是否工业企业"));
  562. cell = row.getCell(15);
  563. com.setIs_product_name(getCellValue(cell, r, "是否经营"));
  564. nameList.add(company_name);
  565. dataList.add(com);
  566. }
  567. return dataList;
  568. }
  569. /**
  570. * 读取数据(街道用户)
  571. *
  572. * @throws Exception
  573. */
  574. private List<CompanyInfoData> getExcelDataOnStreet(Workbook wb, String Sname) throws Exception {
  575. List<CompanyInfoData> dataList = new ArrayList<>();
  576. List<String> nameList = new ArrayList<>();
  577. nameList.clear();
  578. Row row = null;
  579. Cell cell = null;
  580. Sheet sheet = (Sheet) wb.getSheetAt(0);
  581. int tatalRows = sheet.getPhysicalNumberOfRows();
  582. if (tatalRows == 2) {
  583. throw new Exception("请添加企业信息数据");
  584. }
  585. //从一行读取数据
  586. for (int r = 2; r < tatalRows; r++) {
  587. //获取行数据
  588. row = sheet.getRow(r);
  589. cell = row.getCell(0);
  590. String cellValue = getCellValue(cell, r, "序号");
  591. if (StringUtils.isBlank(cellValue)) {
  592. break;
  593. }
  594. CompanyInfoData com = new CompanyInfoData();
  595. cell = row.getCell(1);
  596. com.setUscc(getCellValue(cell, r, "统一社会信用代码"));
  597. cell = row.getCell(2);
  598. com.setOrganization_code(getCellValue(cell, r, "组织机构代码"));
  599. cell = row.getCell(3);
  600. String company_name = getCellValue(cell, r, "企业名称");
  601. if (nameList.size() > 0 && StringUtils.isNotBlank(company_name) && nameList.contains(company_name)) {
  602. throw new Exception("企业名称为:" + company_name + ",企业已经存在,请修改企业名称!");
  603. }
  604. com.setCompany_name(getCellValue(cell, r, "企业名称"));
  605. cell = row.getCell(4);
  606. com.setLegal_Representative(getCellValue(cell, r, "法人代表人"));
  607. cell = row.getCell(5);
  608. com.setIndustry_Code(getCellValue(cell, r, "行业代码"));
  609. cell = row.getCell(6);
  610. com.setType_name(getCellValue(cell, r, "企业性质"));
  611. cell = row.getCell(7);
  612. //街道名称
  613. String street_name = getCellValue(cell, r, "所属区域");
  614. if (StringUtils.isBlank(Sname)) {
  615. com.setStreet_name(Sname);
  616. }
  617. if (!street_name.equals(Sname)) {
  618. throw new Exception("企业名称为:" + company_name + ", 所属区域有误,请修改为: " + Sname);
  619. }
  620. com.setStreet_name(getCellValue(cell, r, "所属区域"));
  621. cell = row.getCell(8);
  622. com.setBuild_name(getCellValue(cell, r, "所属工业区"));
  623. cell = row.getCell(9);
  624. com.setRelation_Name(getCellValue(cell, r, "管理部门"));
  625. cell = row.getCell(10);
  626. com.setRegistration_Capital(getCellValue(cell, r, "注册资本"));
  627. cell = row.getCell(11);
  628. // String date = cell.getStringCellValue();
  629. boolean flag = isValidDate(getCellValue(cell, r, "注册日期"));
  630. if (flag) {
  631. com.setEstablishment_date(getCellValue(cell, r, "注册日期"));
  632. } else {
  633. throw new Exception("时间格式非法");
  634. }
  635. cell = row.getCell(12);
  636. com.setLocation(getCellValue(cell, r, "地址"));
  637. cell = row.getCell(13);
  638. com.setBusiness(getCellValue(cell, r, "经营范围"));
  639. cell = row.getCell(14);
  640. com.setType_id_name(getCellValue(cell, r, "是否工业企业"));
  641. cell = row.getCell(15);
  642. com.setIs_product_name(getCellValue(cell, r, "是否经营"));
  643. nameList.add(company_name);
  644. dataList.add(com);
  645. }
  646. return dataList;
  647. }
  648. /**
  649. * isNumAndLetter(判断一个字符串是否由数字和字母组成)
  650. *
  651. * @param str
  652. * @return boolean
  653. * @throws
  654. */
  655. public boolean isNumAndLetter(String str) {
  656. boolean flag = false;
  657. Pattern pattern = Pattern.compile("^[A-Za-z0-9]+$*");
  658. Matcher matcher = pattern.matcher(str);
  659. flag = matcher.matches();
  660. return flag;
  661. }
  662. /**
  663. * isNum(判断一个字符串是否由数字组成)
  664. *
  665. * @param str
  666. * @return boolean
  667. * @throws
  668. */
  669. public boolean isNum(String str) {
  670. boolean flag = false;
  671. Pattern pattern = Pattern.compile("^[0-9]+$*");
  672. Matcher matcher = pattern.matcher(str);
  673. flag = matcher.matches();
  674. return flag;
  675. }
  676. /**
  677. * isNumAndLetter(判断一个实数是否包含两位小数组成)
  678. *
  679. * @param str
  680. * @return boolean
  681. * @throws
  682. */
  683. public boolean containNumAndPoint(String str) {
  684. boolean flag = false;
  685. Pattern pattern = Pattern.compile("^[0-9]+(.[0-9]{1,5})?$");
  686. Matcher matcher = pattern.matcher(str);
  687. flag = matcher.matches();
  688. return flag;
  689. }
  690. /**
  691. * 校验企业信息数据是否合法
  692. */
  693. private void validData(List<CompanyInfoData> dataList) throws Exception {
  694. //查询数据库表中所有街道、园区
  695. //List<String> streetNameList = streetService.findAllStreeName();
  696. for (CompanyInfoData companyInfoData : dataList) {
  697. //组织机构代码为空时,此条数据不校验
  698. String organization_code = companyInfoData.getOrganization_code();
  699. //判断数据库中是否存在被导入的企业
  700. String company_name = companyInfoData.getCompany_name();
  701. if (StringUtils.isBlank(organization_code)) {
  702. throw new Exception("企业名称为:" + company_name + " 的" + " “组织机构代码” " + "为空");
  703. //continue;
  704. }
  705. // if (companyService.isCompanyExist(company_name, organization_code)) {
  706. // continue;
  707. // }
  708. //项目名称限制为50个字符
  709. if (company_name.length() >= 50) {
  710. throw new Exception("企业名称限制为50个字符长度");
  711. }
  712. //判断项目名称是否为空
  713. /*if (StringUtils.isBlank(company_name)) {
  714. throw new Exception("企业名称为:" + company_name + ",企业已经存在");
  715. }*/
  716. //判断项目名称是否存在
  717. if (companyService.isCompanyNameExist(company_name)) {
  718. throw new Exception("企业名称为:" + company_name + ",企业已经存在");
  719. }
  720. String uscc = companyInfoData.getUscc();
  721. //判断社会统一社会代码是否存在
  722. if (StringUtils.isNotBlank(uscc)) {
  723. if (companyService.isCompanyUsccExist(uscc)) {
  724. throw new Exception("企业名称为:" + company_name + " 的" + " “社会统一信用代码” " + "已经存在");
  725. }
  726. //判断社会统一代码的长度,是否由数字和字母走成(18位长度)
  727. if ((uscc.length() != 18) || (!isNumAndLetter(uscc))) {
  728. throw new Exception("企业名称为:" + company_name + " 的" + " “社会统一信用代码” " + "非法");
  729. }
  730. }
  731. //判断组织机构代码是否存在
  732. if (StringUtils.isNotBlank(organization_code)) {
  733. if (companyService.isCompanyOrganizationCodeExist(organization_code, null)) {
  734. throw new Exception("企业名称为:" + company_name + " 的" + " “组织机构代码” " + "已经存在");
  735. }
  736. //判断组织机构代码的长度,是否由数字和字母组成(大于6位长度)
  737. if (((organization_code.length() != 9)) || (!isNumAndLetter(organization_code))) {
  738. throw new Exception("企业名称为:" + company_name + " 的" + " “组织机构代码” " + "非法");
  739. }
  740. }
  741. //判断行业代码是否存在
  742. String industry_code = companyInfoData.getIndustry_Code();
  743. if (StringUtils.isNotBlank(industry_code)) {
  744. /*if (companyService.isCompanyIndustryCodeExist(industry_code)) {
  745. throw new Exception("企业名称为:" + company_name + " 的行业代码已经存在");
  746. }*/
  747. //判断行业代码的长度,是否只包含数字(4长度)
  748. if ((industry_code.length() != 4) || (!isNum(industry_code))) {
  749. throw new Exception("企业名称为:" + company_name + " 的" + " “行业代码” " + "非法");
  750. }
  751. }
  752. //判断注册资金是否合法
  753. if (StringUtils.isNotBlank(companyInfoData.getRegistration_Capital())) {
  754. double registration_Capital = 0.0;
  755. try {
  756. //if (StringUtils.isNotBlank(companyInfoData.getRegistration_Capital())) {
  757. registration_Capital = Double.parseDouble(companyInfoData.getRegistration_Capital());
  758. //}
  759. } catch (Exception e) {
  760. throw new Exception("企业名称为:" + company_name + ",且值为:" + companyInfoData.getRegistration_Capital() + " 的" + " “注册资金” " + "非法");
  761. }
  762. if (companyInfoData.getRegistration_Capital().length() > 14 || registration_Capital < 0 ||
  763. !containNumAndPoint(companyInfoData.getRegistration_Capital())) {
  764. throw new Exception("企业名称为:" + company_name + ",且值为:" + companyInfoData.getRegistration_Capital() + " 的" + " “注册资金” " + "小数部分保留超过5位");
  765. }
  766. }
  767. //校验街道是否存在
  768. if (StringUtils.isNotBlank(companyInfoData.getStreet_name())) {
  769. String street_name = companyInfoData.getStreet_name();
  770. Street street = streetService.getStreet(street_name);
  771. if (street == null) {
  772. throw new Exception("企业名称为:" + company_name + ",且值为:" + companyInfoData.getStreet_name() + " 的" + " “所属区域” " + "不存在");
  773. }
  774. }
  775. /*if (StringUtils.isNotBlank(companyInfoData.getStreet_name())) {
  776. if (!streetNameList.contains(companyInfoData.getStreet_name())) {
  777. Street street = new Street();
  778. street.setDel_flag(false);
  779. street.setIs_start(true);
  780. street.setName(companyInfoData.getStreet_name());
  781. street.setCreate_by(ShiroUtils.getUserEntity().getId());
  782. street.setCreate_name(ShiroUtils.getUserEntity().getUser_name());
  783. }
  784. }*/
  785. //校验园区是否存在
  786. if (StringUtils.isNotBlank(companyInfoData.getBuild_name())) {
  787. String build_name = companyInfoData.getBuild_name();
  788. BuildInfo build = buildInfoService.getBuildByName(build_name);
  789. if (build == null) {
  790. throw new Exception("企业名称为:" + company_name + ",且值为:" + companyInfoData.getBuild_name() + " 的" + " “所属工业园区” " + "不存在");
  791. }
  792. }
  793. }
  794. }
  795. /**
  796. * 保存数据
  797. *
  798. * @throws Exception
  799. */
  800. private void saveData(List<CompanyInfoData> dataList) throws Exception {
  801. for (CompanyInfoData data : dataList) {
  802. //判断数据库中是否存在被导入的企业,如果存在不保存,否则保存
  803. String company_name = data.getCompany_name();
  804. String organization_code = data.getOrganization_code();
  805. if (companyService.isCompanyExist(company_name, organization_code)) {
  806. continue;
  807. }
  808. Company com = new Company();
  809. //社会统一信用代码
  810. //if (companyService.isCompanyUsccExist(data.getUscc())) {
  811. //throw new Exception("企业名称为:" + company_name + " 的"+" “社会统一信用代码” "+"已经存在");
  812. //}else {
  813. com.setUscc(data.getUscc());
  814. //}
  815. //组织机构代码
  816. //if (companyService.isCompanyOrganizationCodeExist(data.getOrganization_code())) {
  817. // throw new Exception("企业名称为:" + company_name + " 的"+" “组织机构代码” "+"已经存在");
  818. //}else {
  819. com.setOrganization_code(data.getOrganization_code());
  820. //}
  821. //项目名称
  822. //if (companyService.isCompanyNameExist(company_name)) {
  823. // throw new Exception("企业名称为:" + company_name + " 的"+" “企业名称” "+"已经存在");
  824. //}else {
  825. com.setCompany_name(data.getCompany_name());
  826. //}
  827. //法定代表人
  828. com.setLegal_representative(data.getLegal_Representative());
  829. //行业代码
  830. /*if (companyService.isCompanyIndustryCodeExist(data.getIndustry_Code())) {
  831. throw new Exception("企业名称为:" + company_name + " 的"+" “行业代码” "+"已经存在");
  832. }else {*/
  833. // }
  834. //行业代码可重复,不必校验
  835. com.setIndustry_code(data.getIndustry_Code());
  836. //企业性质
  837. /*Integer tempId = dictionaryItemService.findIdByTypeAndName(Constant.DictionaryType.COMPANY_TYPE, data.getType_name());
  838. if (tempId == null) {
  839. throw new Exception("企业名称为:"+company_name+",且值为:"+data.getType_name()+" 的"+" “企业性质” "+"不存在");
  840. }else {
  841. com.setType(tempId);
  842. }*/
  843. //******************** 街道,园区校验 **********************//
  844. if (StringUtils.isBlank(data.getStreet_name())) {
  845. com.setStreet_id(null);
  846. } else {
  847. try {
  848. com.setStreet_id(streetService.getStreet(data.getStreet_name()).getId());
  849. } catch (Exception e) {
  850. throw new Exception("企业名称为:" + company_name + ",且值为:" + data.getStreet_name() + " 的" + " “所属区域” " + "不存在");
  851. }
  852. }
  853. if (StringUtils.isBlank(data.getBuild_name())) {
  854. com.setBuild_id(null);
  855. } else {
  856. try {
  857. BuildInfo buildInfo = buildInfoService.getBuildByName(data.getBuild_name());
  858. com.setBuild_id(buildInfo.getId());
  859. } catch (Exception e) {
  860. throw new Exception("企业名称为:" + company_name + ",且值为:" + data.getBuild_name() + " 的" + " “所属工业区” " + "不存在");
  861. }
  862. }
  863. //******************** 街道,园区比校验 **********************//
  864. //管理部门
  865. com.setRelation_name(data.getRelation_Name());
  866. //注册资本
  867. if (StringUtils.isNotBlank(data.getRegistration_Capital())) {
  868. com.setRegistration_capital(data.getRegistration_Capital());
  869. } else {
  870. com.setRegistration_capital(null);
  871. }
  872. //注册日期
  873. com.setEstablishment_date(data.getEstablishment_date());
  874. //地址
  875. com.setLocation(data.getLocation());
  876. //经营范围
  877. com.setBusiness(data.getBusiness());
  878. //是否是工业
  879. /*if (data.getType_id_name().equals("是")) {
  880. com.setType_id(1);
  881. }else {
  882. com.setType_id(0);
  883. }*/
  884. //是否生产
  885. /*if (data.getIs_product_name().equals("是")) {
  886. com.setIs_product(true);
  887. }else {
  888. com.setIs_product(false);
  889. }*/
  890. //企业编码
  891. SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmssSSS");
  892. String format = sdf1.format(new Date());
  893. Random r = new Random();
  894. String no = "";
  895. for (int i = 0; i < 3; i++) {
  896. no += r.nextInt(10);
  897. }
  898. com.setNo("SNDE" + format + no);
  899. //客户性质(默认企业客户)
  900. com.setNature(1);
  901. //货币单位,默认(人民币)
  902. com.setCurrency_unit(1);
  903. com.setIs_start(true);
  904. com.setDel_flag(false);
  905. com.setIs_register(1);
  906. companyService.saveSelective(com);
  907. //为企业新增管理员,用户名:组织机构代码、密码:123456、角色:企业管理员
  908. User user = new User();
  909. user.setNick_name(organization_code);
  910. user.setUser_name(organization_code);
  911. String passWord = organization_code.substring(3, organization_code.length());
  912. user.setPassword(SecureUtil.md5().digestHex(passWord));
  913. user.setIs_start(true);
  914. user.setIs_admin(true);
  915. user.setUser_type(Constant.UserType.COMPANY);
  916. if (StringUtils.isNotBlank(data.getBuild_name())) {
  917. try {
  918. BuildInfo buildInfo = buildInfoService.getBuildByName(data.getBuild_name());
  919. user.setBuild_id(buildInfo.getId());
  920. user.setBuild_name(buildInfo.getName());
  921. } catch (Exception e) {
  922. throw new Exception("企业名称为:" + company_name + ",且值为:" + data.getBuild_name() + " 的" + " “所属工业区” " + "不存在");
  923. }
  924. } else {
  925. user.setBuild_id(null);
  926. user.setBuild_name(null);
  927. }
  928. if (StringUtils.isNotBlank(data.getStreet_name())) {
  929. try {
  930. Street street = streetService.getStreet(data.getStreet_name());
  931. user.setStreet_id(street.getId());
  932. user.setStreet_name(street.getName());
  933. } catch (Exception e) {
  934. throw new Exception("企业名称为:" + company_name + ",且值为:" + data.getStreet_name() + " 的" + " “所属区域” " + "不存在");
  935. }
  936. } else {
  937. user.setStreet_id(null);
  938. user.setStreet_name(null);
  939. }
  940. if (StringUtils.isNotBlank(data.getCompany_name())) {
  941. try {
  942. Company companyName = companyService.findByCompanyName(data.getCompany_name());
  943. user.setCompany_id(companyName.getId());
  944. user.setCompany_name(companyName.getCompany_name());
  945. } catch (Exception e) {
  946. throw new Exception("系统错误!");
  947. }
  948. } else {
  949. user.setCompany_id(null);
  950. user.setCompany_name(null);
  951. }
  952. user.setCreate_by(ShiroUtils.getUserEntity().getId());
  953. user.setCreate_name(ShiroUtils.getUserEntity().getNick_name());
  954. userService.saveSelective(user);
  955. //发送短信给企业用户,账号新增成功
  956. //sendSMSToNewCompanyUser(passWord,user,com);
  957. }
  958. }
  959. public String createCompanyNo(){
  960. SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmssSSS");
  961. String format = sdf1.format(new Date());
  962. Random r = new Random();
  963. StringBuilder no = new StringBuilder();
  964. for (int i = 0; i < 3; i++) {
  965. no.append(r.nextInt(10));
  966. }
  967. return "SNDE" + format + no;
  968. }
  969. public PageInfo<Company> findRegisterPage(Integer pageNum, Integer pageSize, String keyword, Company searchCondition) {
  970. //根据当前用户userId查询和当前用户同一部门,审核层级小于当前用户的UserId
  971. //List<Integer> userIdList = userService.findUserIdsByUserId(ShiroUtils.getUserId());
  972. Integer currentStreet_id = ShiroUtils.getUserEntity().getStreet_id();
  973. PageHelper.startPage(pageNum, pageSize);
  974. /*Company company1 = new Company();
  975. company1.setIs_register(0);
  976. company1.setStreet_id(currentStreet_id);*/
  977. //List<Company> list = companyService.findListByContidion(ShiroUtils.getUserId(),currentStreet_id);
  978. /* 20180418-yl- 不分审批人 街道可看见所有数据*/
  979. List<Company> list = companyService.findListByContidion(null, currentStreet_id, keyword, searchCondition);
  980. for (Company company : list) {
  981. /*Approval approval = approvalService.getLatestApproval(company.getId());
  982. if(null != approval && StringUtils.isNotBlank(approval.getNextchecker())){
  983. String nextChecker [] = null == approval.getNextchecker() ?null:approval.getNextchecker().split(",");
  984. for(Integer userId:userIdList){
  985. if(Arrays.asList(nextChecker).contains(String.valueOf(userId))){
  986. company.setIs_approval(0);
  987. break;
  988. }
  989. }
  990. }*/
  991. if (null != company.getType_id()) {
  992. BuildType buildType = buildTypeService.findById(company.getType_id());
  993. if (null != buildType) {
  994. company.setType_name(buildType.getType());
  995. }
  996. }
  997. company.setCompanyContacts(companyContactService.findByCompanyId(company.getId()));
  998. Integer build_id = company.getBuild_id();
  999. if (build_id != null) {
  1000. BuildInfo info = buildInfoService.findById(build_id);
  1001. if (null != info) {
  1002. company.setBuild_name(info.getName());
  1003. }
  1004. }
  1005. Integer street_id = company.getStreet_id();
  1006. if (street_id != null) {
  1007. company.setStreet_name(streetService.findById(street_id).getName());
  1008. }
  1009. }
  1010. return new PageInfo<Company>(list);
  1011. }
  1012. public PageInfo<Company> findAlready_RegisterPage(Integer pageNum, Integer pagesize, String keyword, Company searchCondition) {
  1013. Integer currentStreet_id = ShiroUtils.getUserEntity().getStreet_id();
  1014. PageHelper.startPage(pageNum, pagesize);
  1015. /*Company company1 = new Company();
  1016. company1.setStreet_id(currentStreet_id);
  1017. List<Company> list = companyService.findListByWhere(company1);*/
  1018. //Integer currentUserId = ShiroUtils.getUserId();
  1019. Integer currentUserId = null;
  1020. List<Company> list = companyService.findCompanyByCondition(currentStreet_id, currentUserId, keyword, searchCondition);
  1021. for (Company company : list) {
  1022. if (null != company.getType_id()) {
  1023. BuildType buildType = buildTypeService.findById(company.getType_id());
  1024. if (null != buildType) {
  1025. company.setType_name(buildType.getType());
  1026. }
  1027. }
  1028. company.setCompanyContacts(companyContactService.findByCompanyId(company.getId()));
  1029. Integer build_id = company.getBuild_id();
  1030. if (build_id != null) {
  1031. BuildInfo info = buildInfoService.findById(build_id);
  1032. if (null != info) {
  1033. company.setBuild_name(info.getName());
  1034. }
  1035. }
  1036. Integer street_id = company.getStreet_id();
  1037. if (street_id != null) {
  1038. company.setStreet_name(streetService.findById(street_id).getName());
  1039. }
  1040. }
  1041. return new PageInfo<Company>(list);
  1042. }
  1043. }