对比新文件 |
| | |
| | | package com.gk.firework.Service.ServiceImpl; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gk.firework.Domain.*; |
| | | import com.gk.firework.Domain.Enum.*; |
| | | import com.gk.firework.Domain.Exception.BusinessException; |
| | | import com.gk.firework.Domain.Utils.*; |
| | | import com.gk.firework.Domain.Utils.Properties; |
| | | import com.gk.firework.Domain.Vo.EnterpriseExportVo; |
| | | import com.gk.firework.Domain.Vo.EnterpriseVo; |
| | | import com.gk.firework.Mapper.EnterpriseMapper; |
| | | import com.gk.firework.Mapper.HiddenDangerReportMapper; |
| | | import com.gk.firework.Mapper.SaleOrderInfoMapper; |
| | | import com.gk.firework.Service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.*; |
| | | import java.lang.reflect.Field; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | |
| | | |
| | | @Service("enterpriseService") |
| | | public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper, Enterprise> implements EnterpriseService { |
| | | |
| | | @Autowired |
| | | EnterpriseMapper enterpriseMapper; |
| | | @Autowired |
| | | EnterpriseApplyService enterpriseApplyService; |
| | | @Autowired |
| | | EnterpriseService enterpriseService; |
| | | @Autowired |
| | | EnterpriseStaffService enterpriseStaffService; |
| | | @Autowired |
| | | UserService userService; |
| | | @Autowired |
| | | UserRolesService userRolesService; |
| | | @Autowired |
| | | RoleService roleService; |
| | | @Autowired |
| | | ProductService productService; |
| | | @Autowired |
| | | HiddenDangerReportMapper hiddenDangerReportMapper; |
| | | @Autowired |
| | | HiddenDangerReportDetailService hiddenDangerReportDetailService; |
| | | @Autowired |
| | | ExcelExportService excelExportService; |
| | | @Autowired |
| | | SaleOrderInfoMapper saleOrderInfoMapper; |
| | | |
| | | |
| | | /** |
| | | * @Description: 新增申请,根据前端提交状态commitStatus来判断增加还是删除 parentId为编辑对象id |
| | | * @date 2021/3/17 15:57 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void addApply(EnterpriseApply enterpriseApply,UserInfo user) throws IllegalAccessException { |
| | | |
| | | if (enterpriseApply.getCommitstatus() == CommitStatus.MOD) { |
| | | //新建一个修改给过后的数据 |
| | | Enterprise enp2 = new Enterprise(); |
| | | //ParentId为修改企业的id |
| | | enp2.setId(enterpriseApply.getParentid()); |
| | | //以下是页面可以修改的值 |
| | | enp2.setSafetysupervision(enterpriseApply.getSafetysupervision()); |
| | | enp2.setEconomicindustry(enterpriseApply.getEconomicindustry()); |
| | | enp2.setEnterprisenumber(enterpriseApply.getEnterprisenumber()); |
| | | enp2.setEnterprisename(enterpriseApply.getEnterprisename()); |
| | | enp2.setEnterpriseemail(enterpriseApply.getEnterpriseemail()); |
| | | enp2.setEnterprisesize(enterpriseApply.getEnterprisesize()); |
| | | enp2.setEnterprisestatus(enterpriseApply.getEnterprisestatus()); |
| | | enp2.setDepartment(enterpriseApply.getDepartment()); |
| | | enp2.setDevicenumber(enterpriseApply.getDevicenumber()); |
| | | enp2.setOfficeaddress(enterpriseApply.getOfficeaddress()); |
| | | enp2.setProvince(enterpriseApply.getProvince()); |
| | | enp2.setCity(enterpriseApply.getCity()); |
| | | enp2.setDistrict(enterpriseApply.getDistrict()); |
| | | enp2.setStreet(enterpriseApply.getStreet()); |
| | | enp2.setCommittee(enterpriseApply.getCommittee()); |
| | | enp2.setSecuritysupervisory(enterpriseApply.getSecuritysupervisory()); |
| | | enp2.setOfficephone(enterpriseApply.getOfficephone()); |
| | | enp2.setFaxphone(enterpriseApply.getFaxphone()); |
| | | enp2.setRegisteraddress(enterpriseApply.getRegisteraddress()); |
| | | enp2.setRegistertype(enterpriseApply.getRegistertype()); |
| | | enp2.setEstablishtime(enterpriseApply.getEstablishtime()); |
| | | enp2.setQqnumber(enterpriseApply.getQqnumber()); |
| | | enp2.setPostcode(enterpriseApply.getPostcode()); |
| | | enp2.setRoomnumber(enterpriseApply.getRoomnumber()); |
| | | enp2.setEconomictype(enterpriseApply.getEconomictype()); |
| | | enp2.setProductioncontent(enterpriseApply.getProductioncontent()); |
| | | enp2.setBusinessregisternumber(enterpriseApply.getBusinessregisternumber()); |
| | | enp2.setOrganizationstructurecode(enterpriseApply.getOrganizationstructurecode()); |
| | | enp2.setValidstarttime(enterpriseApply.getValidstarttime()); |
| | | enp2.setValidendtime(enterpriseApply.getValidendtime()); |
| | | enp2.setEmployeenumber(enterpriseApply.getEmployeenumber()); |
| | | enp2.setIspaysafetyinsurance(enterpriseApply.getIspaysafetyinsurance()); |
| | | enp2.setInsurancecontractnumber(enterpriseApply.getInsurancecontractnumber()); |
| | | enp2.setInsurestarttime(enterpriseApply.getInsurestarttime()); |
| | | enp2.setInsureendtime(enterpriseApply.getInsureendtime()); |
| | | enp2.setIsmajorhazard(enterpriseApply.getIsmajorhazard()); |
| | | enp2.setIsspecialequipment(enterpriseApply.getIsspecialequipment()); |
| | | enp2.setIsoccupationalhealthinfo(enterpriseApply.getIsoccupationalhealthinfo()); |
| | | enp2.setIsspecialpersonnel(enterpriseApply.getIsspecialpersonnel()); |
| | | enp2.setSelfrecordingcycle(enterpriseApply.getSelfrecordingcycle()); |
| | | enp2.setIsparententerprise(enterpriseApply.getIsparententerprise()); |
| | | enp2.setParententerpriseid(enterpriseApply.getParententerpriseid()); |
| | | enp2.setParententerprisename(enterpriseApply.getParententerprisename()); |
| | | //密码 |
| | | enp2.setPassword(enterpriseApply.getPassword()); |
| | | |
| | | Enterprise enp1 = this.getById(enterpriseApply.getParentid()); |
| | | if (enp1 == null) { |
| | | |
| | | } |
| | | //以下是非对比内容;设置对比内容相同 |
| | | assert enp1 != null; |
| | | enp2.setInfocreatetime(enp1.getInfocreatetime()); |
| | | enp2.setInfoupdatetime(enp1.getInfoupdatetime()); |
| | | enp2.setInfoupdateby(enp1.getInfoupdateby()); |
| | | enp2.setInfocreateby(enp1.getInfocreateby()); |
| | | enp2.setValidflag(enp1.getValidflag()); |
| | | enp2.setInfocreatebyname(enp1.getInfocreatebyname()); |
| | | enp2.setInfoupdatebyname(enp1.getInfoupdatebyname()); |
| | | |
| | | //两个对象差 |
| | | String updateFields = compareObj(Enterprise.class, enp1, enp2); |
| | | //提出时间 |
| | | enterpriseApply.setApplytime(new Date()); |
| | | //等待审批 |
| | | enterpriseApply.setApplystatus(ApplyStatus.APPROVING); |
| | | enterpriseApply.setValidflag(true); |
| | | //更新字段 |
| | | enterpriseApply.setUpdatefields(updateFields); |
| | | |
| | | { |
| | | enterpriseApply.setSafetysupervision(enp1.getSafetysupervision()); |
| | | enterpriseApply.setEconomicindustry(enp1.getEconomicindustry()); |
| | | enterpriseApply.setEnterprisenumber(enp1.getEnterprisenumber()); |
| | | enterpriseApply.setEnterprisename(enp1.getEnterprisename()); |
| | | enterpriseApply.setEnterpriseemail(enp1.getEnterpriseemail()); |
| | | enterpriseApply.setEnterprisesize(enp1.getEnterprisesize()); |
| | | enterpriseApply.setEnterprisestatus(enp1.getEnterprisestatus()); |
| | | enterpriseApply.setDepartment(enp1.getDepartment()); |
| | | enterpriseApply.setDevicenumber(enp1.getDevicenumber()); |
| | | enterpriseApply.setOfficeaddress(enp1.getOfficeaddress()); |
| | | enterpriseApply.setProvince(enp1.getProvince()); |
| | | enterpriseApply.setCity(enp1.getCity()); |
| | | enterpriseApply.setDistrict(enp1.getDistrict()); |
| | | enterpriseApply.setStreet(enp1.getStreet()); |
| | | enterpriseApply.setCommittee(enp1.getCommittee()); |
| | | enterpriseApply.setSecuritysupervisory(enp1.getSecuritysupervisory()); |
| | | enterpriseApply.setOfficephone(enp1.getOfficephone()); |
| | | enterpriseApply.setFaxphone(enp1.getFaxphone()); |
| | | enterpriseApply.setRegisteraddress(enp1.getRegisteraddress()); |
| | | enterpriseApply.setRegistertype(enp1.getRegistertype()); |
| | | enterpriseApply.setEstablishtime(enp1.getEstablishtime()); |
| | | enterpriseApply.setQqnumber(enp1.getQqnumber()); |
| | | enterpriseApply.setPostcode(enp1.getPostcode()); |
| | | enterpriseApply.setRoomnumber(enp1.getRoomnumber()); |
| | | enterpriseApply.setEconomictype(enp1.getEconomictype()); |
| | | enterpriseApply.setProductioncontent(enp1.getProductioncontent()); |
| | | enterpriseApply.setBusinessregisternumber(enp1.getBusinessregisternumber()); |
| | | enterpriseApply.setOrganizationstructurecode(enp1.getOrganizationstructurecode()); |
| | | enterpriseApply.setValidstarttime(enp1.getValidstarttime()); |
| | | enterpriseApply.setValidendtime(enp1.getValidendtime()); |
| | | enterpriseApply.setEmployeenumber(enp1.getEmployeenumber()); |
| | | enterpriseApply.setIspaysafetyinsurance(enp1.getIspaysafetyinsurance()); |
| | | enterpriseApply.setInsurancecontractnumber(enp1.getInsurancecontractnumber()); |
| | | enterpriseApply.setInsurestarttime(enp1.getInsurestarttime()); |
| | | enterpriseApply.setInsureendtime(enp1.getInsureendtime()); |
| | | enterpriseApply.setIsmajorhazard(enp1.getIsmajorhazard()); |
| | | enterpriseApply.setIsspecialequipment(enp1.getIsspecialequipment()); |
| | | enterpriseApply.setIsoccupationalhealthinfo(enp1.getIsoccupationalhealthinfo()); |
| | | enterpriseApply.setIsspecialpersonnel(enp1.getIsspecialpersonnel()); |
| | | enterpriseApply.setSelfrecordingcycle(enp1.getSelfrecordingcycle()); |
| | | enterpriseApply.setIsparententerprise(enp1.getIsparententerprise()); |
| | | enterpriseApply.setParententerprisename(enp1.getParententerprisename()); |
| | | enterpriseApply.setApplypersonname(user.getUsername()); |
| | | enterpriseApply.setApplypersonid(user.getId()); |
| | | UserInfo userInfo = userService.selectOneByCompanyId(enp1.getId()); |
| | | enterpriseApply.setPassword(userInfo.getPassword()); |
| | | } |
| | | //新增审批 |
| | | enterpriseApplyService.save(enterpriseApply); |
| | | //修改企业信息状态 |
| | | Enterprise updateEp = new Enterprise(); |
| | | updateEp.setId(enp1.getId()); |
| | | enterpriseService.updateById(updateEp); |
| | | } |
| | | |
| | | if (enterpriseApply.getCommitstatus() == CommitStatus.DEL) { |
| | | |
| | | //提出时间 |
| | | enterpriseApply.setApplytime(new Date()); |
| | | //等待审批 |
| | | enterpriseApply.setApplystatus(ApplyStatus.APPROVING); |
| | | Enterprise enp = this.getById(enterpriseApply.getParentid()); |
| | | enterpriseApply.setSafetysupervision(enp.getSafetysupervision()); |
| | | enterpriseApply.setEconomicindustry(enp.getEconomicindustry()); |
| | | enterpriseApply.setEnterprisenumber(enp.getEnterprisenumber()); |
| | | enterpriseApply.setEnterprisename(enp.getEnterprisename()); |
| | | enterpriseApply.setEnterpriseemail(enp.getEnterpriseemail()); |
| | | enterpriseApply.setEnterprisesize(enp.getEnterprisesize()); |
| | | enterpriseApply.setEnterprisestatus(enp.getEnterprisestatus()); |
| | | enterpriseApply.setDepartment(enp.getDepartment()); |
| | | enterpriseApply.setDevicenumber(enp.getDevicenumber()); |
| | | enterpriseApply.setOfficeaddress(enp.getOfficeaddress()); |
| | | enterpriseApply.setProvince(enp.getProvince()); |
| | | enterpriseApply.setCity(enp.getCity()); |
| | | enterpriseApply.setDistrict(enp.getCity()); |
| | | enterpriseApply.setStreet(enp.getStreet()); |
| | | enterpriseApply.setCommittee(enp.getCommittee()); |
| | | enterpriseApply.setSecuritysupervisory(enp.getSecuritysupervisory()); |
| | | enterpriseApply.setOfficephone(enp.getOfficephone()); |
| | | enterpriseApply.setFaxphone(enp.getFaxphone()); |
| | | enterpriseApply.setRegisteraddress(enp.getRegisteraddress()); |
| | | enterpriseApply.setRegistertype(enp.getRegistertype()); |
| | | enterpriseApply.setEstablishtime(enp.getEstablishtime()); |
| | | enterpriseApply.setQqnumber(enp.getQqnumber()); |
| | | enterpriseApply.setPostcode(enp.getPostcode()); |
| | | enterpriseApply.setRoomnumber(enp.getRoomnumber()); |
| | | enterpriseApply.setEconomictype(enp.getEconomictype()); |
| | | enterpriseApply.setProductioncontent(enp.getProductioncontent()); |
| | | enterpriseApply.setBusinessregisternumber(enp.getBusinessregisternumber()); |
| | | enterpriseApply.setOrganizationstructurecode(enp.getOrganizationstructurecode()); |
| | | enterpriseApply.setValidstarttime(enp.getValidstarttime()); |
| | | enterpriseApply.setValidendtime(enp.getValidendtime()); |
| | | enterpriseApply.setEmployeenumber(enp.getEmployeenumber()); |
| | | enterpriseApply.setIspaysafetyinsurance(enp.getIspaysafetyinsurance()); |
| | | enterpriseApply.setInsurancecontractnumber(enp.getInsurancecontractnumber()); |
| | | enterpriseApply.setInsurestarttime(enp.getInsurestarttime()); |
| | | enterpriseApply.setInsureendtime(enp.getInsureendtime()); |
| | | enterpriseApply.setIsmajorhazard(enp.getIsmajorhazard()); |
| | | enterpriseApply.setIsspecialequipment(enp.getIsspecialequipment()); |
| | | enterpriseApply.setIsoccupationalhealthinfo(enp.getIsoccupationalhealthinfo()); |
| | | enterpriseApply.setIsspecialpersonnel(enp.getIsspecialpersonnel()); |
| | | enterpriseApply.setSelfrecordingcycle(enp.getSelfrecordingcycle()); |
| | | enterpriseApply.setIsparententerprise(enp.getIsparententerprise()); |
| | | enterpriseApply.setParententerprisename(enp.getParententerprisename()); |
| | | enterpriseApply.setValidflag(true); |
| | | enterpriseApply.setApplypersonid(user.getId()); |
| | | enterpriseApply.setApplypersonname(user.getUsername()); |
| | | enterpriseApply.setPassword(enp.getPassword()); |
| | | enterpriseApply.setParententerpriseid(enp.getParententerpriseid()); |
| | | enterpriseApplyService.save(enterpriseApply); |
| | | |
| | | //修改企业信息状态 |
| | | Enterprise updateEp = new Enterprise(); |
| | | updateEp.setId(enp.getId()); |
| | | enterpriseService.updateById(updateEp); |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @Description: 查询企业信息 |
| | | * @date 2021/3/31 9:31 |
| | | */ |
| | | |
| | | @Override |
| | | public IPage<Enterprise> selectEnterprise(Page<Enterprise> page, Map filter,UserInfo user) { |
| | | |
| | | UserInfo userInfo = userService.getById(user.getId()); |
| | | Map<String, Object> params = new HashMap<>(); |
| | | //四类人 |
| | | params.put("leagalrepresentative", Constants.LEGAL_REPRESENTATIVE); |
| | | params.put("mainprincipal", Constants.MAIN_PRINCIPAL); |
| | | params.put("securityofficer", Constants.SECURITY_OFFICER); |
| | | params.put("informationofficer", Constants.INFORMATION_OFFICER); |
| | | |
| | | //监管部门 根据 地区看所有 |
| | | params.put("province", userInfo.getProvince()); |
| | | params.put("city", userInfo.getCity()); |
| | | params.put("district", userInfo.getArea()); |
| | | params.put("street", userInfo.getTown()); |
| | | params.put("committee", userInfo.getCommunity()); |
| | | //企业用户 |
| | | params.put("enterprisenumber", userInfo.getCompanynumber()); |
| | | |
| | | //过滤条件 |
| | | { //企业类型 |
| | | params.put("safetySupervision", filter.get("safetysupervision")); |
| | | //经济类型 |
| | | params.put("economicIndustry", filter.get("economicindustry")); |
| | | //许可证有效|过期 |
| | | params.put("valid", filter.get("valid")); |
| | | //登录有效 loginvalid 1 就是有效 |
| | | params.put("loginValid",filter.get("loginValid")); |
| | | //地区 |
| | | params.put("filterProvince", filter.get("province")); |
| | | params.put("filterCity", filter.get("city")); |
| | | params.put("filterDistrict", filter.get("district")); |
| | | params.put("filterStreet", filter.get("street")); |
| | | params.put("filterCommittee", filter.get("committee")); |
| | | //企业名称 |
| | | params.put("enterprisename", filter.get("enterprisename")); |
| | | |
| | | } |
| | | |
| | | List<Enterprise> list = enterpriseMapper.selectPages(page, params); |
| | | return page.setRecords(list); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 新建企业信息 |
| | | * @date 2021/3/31 10:49 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void addEnterprise(Enterprise enterprise,UserInfo userInfo) { |
| | | UserInfo userInfo2 = userService.getById(userInfo.getId()); |
| | | if (userInfo2.getCompanynumber() != null) { |
| | | throw new BusinessException("没有新增权限"); |
| | | } |
| | | //计算安全监管分类个数 |
| | | { |
| | | int i = countBySafetySupervision(enterprise.getSafetysupervision()); |
| | | enterprise.setDivideflag((byte) (DivideFlagUtil.enterpriseDivideFlagGenerate(i))); |
| | | } |
| | | |
| | | //新建企业信息 |
| | | { |
| | | enterprise.setInfocreatetime(new Date()); |
| | | enterprise.setInfocreateby(userInfo.getId()); |
| | | enterprise.setInfocreatebyname(userInfo.getUsername()); |
| | | enterprise.setInfoupdatetime(new Date()); |
| | | enterprise.setValidflag(true); |
| | | String randomStr = Element.random(Element.class).getValue().toString()+Element.random(Element.class).getValue().toString(); |
| | | while (enterpriseService.isDuplicate2BitCode(randomStr)) { |
| | | randomStr = Element.random(Element.class).getValue().toString()+Element.random(Element.class).getValue().toString(); |
| | | } |
| | | enterprise.setTwobitcode(randomStr); |
| | | //执行 |
| | | this.save(enterprise); |
| | | } |
| | | //新建企业关联staff |
| | | { |
| | | List<EnterpriseStaff> staff = new ArrayList<>(); |
| | | if (enterprise.getLegalrepresentative() != null) { |
| | | enterprise.getLegalrepresentative().setId(null); |
| | | enterprise.getLegalrepresentative().setType(Constants.LEGAL_REPRESENTATIVE); |
| | | enterprise.getLegalrepresentative().setBelongid(enterprise.getId()); |
| | | enterprise.getLegalrepresentative().setBelongname(enterprise.getEnterprisename()); |
| | | staff.add(enterprise.getLegalrepresentative()); |
| | | |
| | | } |
| | | if (enterprise.getInformationofficer() != null) { |
| | | enterprise.getInformationofficer().setId(null); |
| | | enterprise.getInformationofficer().setType(Constants.INFORMATION_OFFICER); |
| | | enterprise.getInformationofficer().setBelongid(enterprise.getId()); |
| | | enterprise.getInformationofficer().setBelongname(enterprise.getEnterprisename()); |
| | | staff.add(enterprise.getInformationofficer()); |
| | | } |
| | | if (enterprise.getSecurityofficer() != null) { |
| | | enterprise.getSecurityofficer().setId(null); |
| | | enterprise.getSecurityofficer().setType(Constants.SECURITY_OFFICER); |
| | | enterprise.getSecurityofficer().setBelongid(enterprise.getId()); |
| | | enterprise.getSecurityofficer().setBelongname(enterprise.getEnterprisename()); |
| | | staff.add(enterprise.getSecurityofficer()); |
| | | } |
| | | if (enterprise.getMainprincipal() != null) { |
| | | enterprise.getMainprincipal().setId(null); |
| | | enterprise.getMainprincipal().setType(Constants.MAIN_PRINCIPAL); |
| | | enterprise.getMainprincipal().setBelongid(enterprise.getId()); |
| | | enterprise.getMainprincipal().setBelongname(enterprise.getEnterprisename()); |
| | | staff.add(enterprise.getMainprincipal()); |
| | | } |
| | | if (staff.size()>0) |
| | | enterpriseStaffService.saveBatch(staff); |
| | | |
| | | } |
| | | |
| | | |
| | | //保存信息两份到用户表 |
| | | { |
| | | UserInfo user = new UserInfo(); |
| | | user.setIsdel((byte) 0); |
| | | user.setUsername(enterprise.getEnterprisename()); |
| | | user.setCompany(enterprise.getEnterprisename()); |
| | | user.setEmail(enterprise.getEnterpriseemail()); |
| | | user.setDepartment(enterprise.getDepartment()); |
| | | user.setIssale((byte) 0); |
| | | //普通用户 |
| | | user.setType(3); |
| | | user.setProvince(enterprise.getProvince()); |
| | | user.setPhone(enterprise.getOfficephone()); |
| | | user.setCity(enterprise.getCity()); |
| | | user.setArea(enterprise.getDistrict()); |
| | | user.setTown(enterprise.getStreet()); |
| | | user.setCommunity(enterprise.getCommittee()); |
| | | //提出人为创建人 |
| | | user.setCreatedby(user.getUsername()); |
| | | user.setCompanyid(enterprise.getId()); |
| | | user.setCreateddate(new Date()); |
| | | //设置密码 |
| | | user.setPassword(Base64Encrypt.encode(enterprise.getPassword().getBytes())); |
| | | user.setCompanynumber(enterprise.getEnterprisenumber()); |
| | | //执行 |
| | | userService.save(user); |
| | | |
| | | //如果有企业角色设置用户角色为企业 |
| | | UserRolesInfo uri = new UserRolesInfo(); |
| | | uri.setUserid(user.getId()); |
| | | if (enterprise.getSafetysupervision().equals(EnterpriseSafetySupervision.PRODUCE.getMsg())){ |
| | | uri.setRoleid((long) 3); |
| | | }else { |
| | | uri.setRoleid((long) 2); |
| | | } |
| | | userRolesService.save(uri); |
| | | |
| | | //终端机 |
| | | user.setId(null); |
| | | user.setIssale((byte) 1); |
| | | user.setStatus((byte) 1); |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.setTime(enterprise.getValidendtime()); |
| | | instance.set(Calendar.HOUR_OF_DAY, 23); |
| | | instance.set(Calendar.MINUTE, 59); |
| | | instance.set(Calendar.SECOND, 59); |
| | | user.setExpiredate(instance.getTime()); |
| | | userService.save(user); |
| | | //终端机角色不需要 |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 修改企业信息 |
| | | * @date 2021/3/31 10:48 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void modEnterprise(Enterprise enterprise,UserInfo user) { |
| | | |
| | | //修改企业信息 |
| | | { |
| | | enterprise.setInfoupdatetime(new Date()); |
| | | enterprise.setInfoupdateby(user.getId()); |
| | | enterprise.setInfoupdatebyname(user.getUsername()); |
| | | //企业名称和企业编号 不会修改 |
| | | enterprise.setEnterprisenumber(null); |
| | | enterprise.setEnterprisename(null); |
| | | this.updateById(enterprise); |
| | | } |
| | | |
| | | //修改企业关联staff |
| | | { |
| | | ///更新的员工 |
| | | List<EnterpriseStaff> staff = new ArrayList<>(); |
| | | //新增的员工 |
| | | List<EnterpriseStaff> adds = new ArrayList<>(); |
| | | if (enterprise.getSecurityofficer() != null) { |
| | | if (enterprise.getSecurityofficer().getId() != null) { |
| | | enterprise.getSecurityofficer().setBelongname(enterprise.getEnterprisename()); |
| | | staff.add(enterprise.getSecurityofficer()); |
| | | }else{ |
| | | enterprise.getSecurityofficer().setType(Constants.SECURITY_OFFICER); |
| | | enterprise.getSecurityofficer().setBelongid(enterprise.getId()); |
| | | enterprise.getSecurityofficer().setBelongname(enterprise.getEnterprisename()); |
| | | adds.add(enterprise.getSecurityofficer()); |
| | | } |
| | | } |
| | | if (enterprise.getLegalrepresentative() != null) { |
| | | if (enterprise.getLegalrepresentative().getId() != null) { |
| | | enterprise.getLegalrepresentative().setBelongname(enterprise.getEnterprisename()); |
| | | staff.add(enterprise.getLegalrepresentative()); |
| | | }else{ |
| | | enterprise.getLegalrepresentative().setType(Constants.LEGAL_REPRESENTATIVE); |
| | | enterprise.getLegalrepresentative().setBelongid(enterprise.getId()); |
| | | enterprise.getLegalrepresentative().setBelongname(enterprise.getEnterprisename()); |
| | | adds.add(enterprise.getLegalrepresentative()); |
| | | } |
| | | |
| | | } |
| | | if (enterprise.getMainprincipal() != null) { |
| | | if (enterprise.getMainprincipal().getId() != null) { |
| | | enterprise.getMainprincipal().setBelongname(enterprise.getEnterprisename()); |
| | | staff.add(enterprise.getMainprincipal()); |
| | | }else{ |
| | | enterprise.getMainprincipal().setType(Constants.MAIN_PRINCIPAL); |
| | | enterprise.getMainprincipal().setBelongid(enterprise.getId()); |
| | | enterprise.getMainprincipal().setBelongname(enterprise.getEnterprisename()); |
| | | adds.add(enterprise.getMainprincipal()); |
| | | } |
| | | |
| | | } |
| | | if (enterprise.getInformationofficer() != null) { |
| | | if (enterprise.getInformationofficer().getId() != null) { |
| | | enterprise.getInformationofficer().setBelongname(enterprise.getEnterprisename()); |
| | | staff.add(enterprise.getInformationofficer()); |
| | | }else{ |
| | | enterprise.getInformationofficer().setType(Constants.INFORMATION_OFFICER); |
| | | enterprise.getInformationofficer().setBelongid(enterprise.getId()); |
| | | enterprise.getInformationofficer().setBelongname(enterprise.getEnterprisename()); |
| | | adds.add(enterprise.getInformationofficer()); |
| | | } |
| | | } |
| | | |
| | | if (staff.size()>0) |
| | | enterpriseStaffService.updateBatchById(staff); |
| | | if (adds.size() > 0) { |
| | | enterpriseStaffService.saveBatch(adds); |
| | | } |
| | | } |
| | | |
| | | //修改人员 |
| | | { |
| | | //修改用户和终端机 |
| | | List<UserInfo> userList = userService.selectByCompanyId(enterprise.getId(),0); |
| | | if (userList.size() != 2) { |
| | | throw new BusinessException("发生错误,请联系管理员"); |
| | | } |
| | | for (UserInfo info : userList) { |
| | | if (StringUtils.isNotBlank(enterprise.getPassword())) { |
| | | info.setPassword(Base64Encrypt.encode(enterprise.getPassword().getBytes())); |
| | | } |
| | | info.setEmail(enterprise.getEnterpriseemail()); |
| | | info.setCompany(enterprise.getEnterprisename()); |
| | | info.setDepartment(enterprise.getDepartment()); |
| | | info.setProvince(enterprise.getProvince()); |
| | | info.setPhone(enterprise.getOfficephone()); |
| | | info.setCity(enterprise.getCity()); |
| | | info.setArea(enterprise.getDistrict()); |
| | | info.setTown(enterprise.getStreet()); |
| | | info.setCommunity(enterprise.getCommittee()); |
| | | //修改许可证 同时修改issale=1的用户有效期 |
| | | if (info.getIssale() == (byte) 1) { |
| | | //设置过期时间为选择当日的23:59:59 |
| | | if (enterprise.getValidendtime() != null) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.setTime(enterprise.getValidendtime()); |
| | | instance.set(Calendar.HOUR_OF_DAY, 23); |
| | | instance.set(Calendar.MINUTE, 59); |
| | | instance.set(Calendar.SECOND, 59); |
| | | info.setExpiredate(instance.getTime()); |
| | | } |
| | | } |
| | | userService.updateById(info); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int countBySafetySupervision(String safetySupervision) { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Enterprise::getSafetysupervision, safetySupervision) |
| | | .eq(Enterprise::getValidflag, true); |
| | | return enterpriseMapper.selectCount(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<Enterprise> selectParentEnterprise(Page<Enterprise> page, Map filter) { |
| | | //重新赋一遍 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("safetysupervision", filter.get("safetysupervision")); |
| | | params.put("enterprisename", filter.get("enterprisename")); |
| | | params.put("province", filter.get("province")); |
| | | params.put("city", filter.get("city")); |
| | | params.put("district", filter.get("district")); |
| | | params.put("street", filter.get("street")); |
| | | List<Enterprise> list = enterpriseMapper.selectParentPage(page, params); |
| | | return page.setRecords(list); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void delEnterprise(Long id, UserInfo user) { |
| | | |
| | | UserInfo userInfo = userService.getById(user.getId()); |
| | | Integer type = userInfo.getType(); |
| | | if (type != 1 && type != 2) { |
| | | throw new BusinessException("没有权限删除"); |
| | | } |
| | | //企业信息删除 |
| | | Enterprise enterprise = this.getById(id); |
| | | if (enterprise == null) { |
| | | throw new BusinessException("企业信息发生改变,请联系管理员"); |
| | | } |
| | | enterprise.setInfoupdatebyname(user.getUsername()); |
| | | enterprise.setInfoupdatetime(new Date()); |
| | | enterprise.setValidflag(false); |
| | | this.updateById(enterprise); |
| | | //删除用户 |
| | | userService.deleteOneByCompanyId(id); |
| | | //根据企业名称去删除所有产品 |
| | | productService.deleteByEnterpriseName(enterprise.getEnterprisename(),user.getUsername()); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 企业信息新增的校验 |
| | | * @date 2021/4/2 16:54 |
| | | */ |
| | | @Override |
| | | public void checkAddEnterprise(Enterprise enterprise, Boolean flag) { |
| | | if (StringUtils.isBlank(enterprise.getSafetysupervision())) { |
| | | throw new BusinessException("安全监管分类不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getEconomicindustry())) { |
| | | throw new BusinessException("国民经济行业分类不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getDepartment())) { |
| | | throw new BusinessException("行政主管部门不能为空"); |
| | | } |
| | | |
| | | if (flag) { |
| | | if (StringUtils.isBlank(enterprise.getPassword())) { |
| | | throw new BusinessException("密码不能为空"); |
| | | } |
| | | |
| | | String PW_PATTERN = "(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@#$%^&*_.]).{8,}"; |
| | | if (!enterprise.getPassword().matches(PW_PATTERN)){ |
| | | throw new BusinessException("密码必须8位以上,并且包含大小写字母、数字、特殊符号三种以上"); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (StringUtils.isBlank(enterprise.getEnterprisenumber())) { |
| | | throw new BusinessException("单位编号不能为空"); |
| | | } |
| | | //编号格式判断-不能有特殊字符 |
| | | String regEx= "[`~!@#$%^&*()+=|{}':;,\\[\\].<>/?!¥…()—【】‘;:”“’。,、?\\\\]"; |
| | | Pattern p = Pattern.compile(regEx); |
| | | if (p.matcher(enterprise.getEnterprisenumber()).find()) { |
| | | throw new BusinessException("单位编号不能包含特殊字符"); |
| | | } |
| | | //单位编号判断重复 |
| | | if (this.isDuplicateNumber(enterprise.getEnterprisenumber(),enterprise.getId())) { |
| | | throw new BusinessException("单位编号已经存在"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getEnterprisename())) { |
| | | throw new BusinessException("企业名称不能为空"); |
| | | } |
| | | |
| | | //单位名称不能重复 |
| | | if (this.isDuplicateEnterpriseName(enterprise.getEnterprisename(), enterprise.getId())) { |
| | | throw new BusinessException("企业名称已经存在"); |
| | | } |
| | | |
| | | if (!enterprise.getSafetysupervision().contains("长期") && StringUtils.isBlank(enterprise.getRegisteraddress())) { |
| | | throw new BusinessException("单位注册地址不能为空"); |
| | | } |
| | | |
| | | if (!enterprise.getSafetysupervision().contains("短期") && StringUtils.isBlank(enterprise.getOfficeaddress())) { |
| | | throw new BusinessException("单位办公地址不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getProvince())) { |
| | | throw new BusinessException("所属省不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getCity())) { |
| | | throw new BusinessException("所属市不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getOfficephone())) { |
| | | throw new BusinessException("办公电话不能为空"); |
| | | } |
| | | |
| | | if (!enterprise.getSafetysupervision().contains("短期") && |
| | | !enterprise.getSafetysupervision().contains("长期") && |
| | | StringUtils.isBlank(enterprise.getFaxphone())) { |
| | | throw new BusinessException("传真电话不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getDistrict())) { |
| | | throw new BusinessException("所属区不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getBusinessregisternumber())) { |
| | | throw new BusinessException("工商注册号不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getOrganizationstructurecode())) { |
| | | throw new BusinessException("组织结构代码不能为空"); |
| | | } |
| | | |
| | | |
| | | if (StringUtils.isBlank(enterprise.getProductioncontent())) { |
| | | throw new BusinessException("生产经营项目不能为空"); |
| | | } |
| | | |
| | | if (enterprise.getEstablishtime() == null) { |
| | | throw new BusinessException("成立时间不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getInsurancecompany())) { |
| | | throw new BusinessException("保险公司名称不能为空,没有请填写无"); |
| | | } |
| | | |
| | | //非临时,有投必填 |
| | | if (!enterprise.getSafetysupervision().contains("临时")) { |
| | | if (enterprise.getIspaysafetyinsurance()) { |
| | | if (StringUtils.isBlank(enterprise.getInsurancecontractnumber())) { |
| | | throw new BusinessException("保单号不能为空"); |
| | | } |
| | | |
| | | if (enterprise.getInsureamount() == null) { |
| | | throw new BusinessException("投保金额不能为空"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | //法定负责人 |
| | | if (enterprise.getLegalrepresentative() != null) { |
| | | |
| | | if (StringUtils.isBlank(enterprise.getLegalrepresentative().getName())) { |
| | | throw new BusinessException("法定负责人姓名不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getLegalrepresentative().getPost())) { |
| | | throw new BusinessException("法定负责人职务不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(enterprise.getLegalrepresentative().getIdentify())) { |
| | | throw new BusinessException("法定负责人身份证号不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(enterprise.getLegalrepresentative().getPhone())) { |
| | | throw new BusinessException("法定负责人手机号不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(enterprise.getLegalrepresentative().getOfficephone())) { |
| | | throw new BusinessException("法定负责人办公室电话不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(enterprise.getLegalrepresentative().getNumber())) { |
| | | throw new BusinessException("法定负责人合格证编号不能为空"); |
| | | } |
| | | if (enterprise.getLegalrepresentative().getValidendtime() == null ||enterprise.getLegalrepresentative().getValidstarttime() == null ) { |
| | | throw new BusinessException("法定负责人有效期不能为空"); |
| | | } |
| | | |
| | | } |
| | | |
| | | //主要负责人 |
| | | if (enterprise.getMainprincipal() != null) { |
| | | if (StringUtils.isBlank(enterprise.getMainprincipal().getName())) { |
| | | throw new BusinessException("主要负责人姓名不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getMainprincipal().getPost())) { |
| | | throw new BusinessException("主要负责人职务不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(enterprise.getMainprincipal().getPhone())) { |
| | | throw new BusinessException("主要负责人手机号不能为空"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getMainprincipal().getOfficephone())) { |
| | | throw new BusinessException("主要负责人办公室电话不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(enterprise.getMainprincipal().getNumber())) { |
| | | throw new BusinessException("主要负责人合格证编号不能为空"); |
| | | } |
| | | if (enterprise.getMainprincipal().getValidendtime() == null ||enterprise.getMainprincipal().getValidstarttime() == null ) { |
| | | throw new BusinessException("主要负责人有效期不能为空"); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 企业信息修改的校验 |
| | | * @date 2021/4/6 10:15 |
| | | */ |
| | | @Override |
| | | public void checkModEnterprise(Enterprise enterprise) { |
| | | |
| | | if (enterprise.getId() == null) { |
| | | throw new BusinessException("修改企业信息时发生错误,请联系管理员"); |
| | | } |
| | | |
| | | Enterprise theOne = this.getById(enterprise.getId()); |
| | | if (theOne == null) { |
| | | throw new BusinessException("修改企业信息已发生变化,请联系管理员"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(enterprise.getSafetysupervision())) { |
| | | throw new BusinessException("安全监管分类不能为空"); |
| | | } |
| | | |
| | | assert theOne.getSafetysupervision() != null; |
| | | if (theOne.getSafetysupervision().equals(enterprise.getSafetysupervision())) { |
| | | //接下来和新增判断一样 |
| | | this.checkAddEnterprise(enterprise,false); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 判断企业编号是否重复 |
| | | * @date 2021/4/20 16:18 |
| | | */ |
| | | @Override |
| | | public boolean isDuplicateNumber(String enterpriseNumber, Long id) { |
| | | |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Enterprise::getEnterprisenumber, enterpriseNumber) |
| | | .eq(Enterprise::getValidflag, true); |
| | | //修改时:除自己以外是否还有重复 |
| | | if (id != null) { |
| | | queryWrapper.ne(Enterprise::getId, id); |
| | | } |
| | | return enterpriseMapper.selectCount(queryWrapper) > 0; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 判断企业名是否重复 |
| | | * @date 2021/4/20 16:16 |
| | | */ |
| | | @Override |
| | | public boolean isDuplicateEnterpriseName(String enterpriseName, Long id) { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Enterprise::getEnterprisename, enterpriseName) |
| | | .eq(Enterprise::getValidflag, true); |
| | | //修改时:除自己以外是否还有重复 |
| | | if (id != null) { |
| | | queryWrapper.ne(Enterprise::getId, id); |
| | | } |
| | | return enterpriseMapper.selectCount(queryWrapper) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> findEnterpriseIdsByLocation(String province, String city, String district, String street, String committee) { |
| | | if(province == null || province.isEmpty()){ |
| | | return null; |
| | | } |
| | | if(province == null && city == null && district == null && street == null && committee == null){ |
| | | return null; |
| | | } |
| | | return enterpriseMapper.selectEnterpriseIdsByLocation(province,city,district,street,committee); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Enterprise> findEnterpriseListByLocation(String province, String city, String district, String street, String committee) { |
| | | return enterpriseMapper.selectEnterpriseListByLocation(province,city,district,street,committee); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 根据企业单位编号获取企业信息和实名登记和自查自改 |
| | | * @date 2021/4/14 8:25 |
| | | */ |
| | | @Override |
| | | public Map getEnterpriseDetail(String enterpriseNumber, Integer days, String starttime, String endtime) { |
| | | if (StringUtils.isBlank(enterpriseNumber)) { |
| | | throw new BusinessException("企业单位编号为空"); |
| | | } |
| | | Calendar calendar = new GregorianCalendar(); |
| | | calendar.setTime(new Date()); |
| | | //当前日期往前推days天 |
| | | calendar.add(Calendar.DATE, -days); |
| | | Date startTime = calendar.getTime(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | EnterpriseVo enterpriseVo = selctSimpleByNumber(enterpriseNumber); |
| | | map.put("enterprise", enterpriseVo); |
| | | //实名登记数量(入库数,销售数) |
| | | Map registerNumObj = enterpriseMapper.selectInAndOut(enterpriseNumber,startTime); |
| | | map.put("registerNum", registerNumObj); |
| | | //自检自查报告 |
| | | List<Map> reports= hiddenDangerReportMapper.getReportList(enterpriseNumber, startTime); |
| | | if (reports.size() > 0) { |
| | | for (Map report : reports) { |
| | | int overduenum = hiddenDangerReportDetailService.countOverdueByReportCode((String) report.get("code")); |
| | | //过期并且未处理 |
| | | report.put("overduenum",overduenum); |
| | | } |
| | | } |
| | | map.put("reports", reports); |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("enterprisename", enterpriseVo.getEnterprisename()); |
| | | params.put("starttime", starttime); |
| | | params.put("endtime", endtime); |
| | | List<Map> saleRecord = saleOrderInfoMapper.selectSaleRecord3(params); |
| | | map.put("saleRecord",saleRecord); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public EnterpriseVo selctSimpleByNumber(String enterprisenumber) { |
| | | return enterpriseMapper.selctSimpleByNumber(enterprisenumber); |
| | | } |
| | | @Override |
| | | public Enterprise selectEnterpriseByCompanyId(Long companyid) { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Enterprise::getId,companyid); |
| | | return enterpriseMapper.selectOne(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectProduceEnterprise() { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Enterprise::getSafetysupervision, EnterpriseSafetySupervision.PRODUCE.getMsg()); |
| | | return enterpriseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectSaleEnterprise() { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.ne(Enterprise::getSafetysupervision, EnterpriseSafetySupervision.PRODUCE.getMsg()); |
| | | queryWrapper.eq(Enterprise::getValidflag,1); |
| | | queryWrapper.eq(Enterprise::getEnterprisestatus ,"ON"); |
| | | return enterpriseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectSaleEnterprise(Map<String, Object>param) { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.isNotBlank(param.get("filterProvince").toString())){ |
| | | queryWrapper.eq(Enterprise::getProvince,param.get("filterProvince")); |
| | | } |
| | | if (StringUtils.isNotBlank(param.get("filterCity").toString())){ |
| | | queryWrapper.eq(Enterprise::getCity,param.get("filterCity")); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(param.get("filterDistrict").toString())){ |
| | | queryWrapper.eq(Enterprise::getDistrict,param.get("filterDistrict")); |
| | | } |
| | | if (StringUtils.isNotBlank(param.get("filterStreet").toString())){ |
| | | queryWrapper.eq(Enterprise::getStreet,param.get("filterStreet")); |
| | | } |
| | | if (StringUtils.isNotBlank(param.get("filterCommittee").toString())){ |
| | | queryWrapper.eq(Enterprise::getCommittee,param.get("filterCommittee")); |
| | | } |
| | | if (StringUtils.isNotBlank(param.get("safetysupervision").toString())){ |
| | | queryWrapper.eq(Enterprise::getSafetysupervision,param.get("safetysupervision")); |
| | | } |
| | | if (StringUtils.isNotBlank(param.get("parententerprisename").toString())){ |
| | | queryWrapper.like(Enterprise::getParententerprisename,param.get("parententerprisename")); |
| | | } |
| | | queryWrapper.ne(Enterprise::getSafetysupervision, EnterpriseSafetySupervision.PRODUCE.getMsg()); |
| | | queryWrapper.eq(Enterprise::getEnterprisestatus, EnterpriseStatus.ON); |
| | | queryWrapper.eq(Enterprise::getValidflag, true); |
| | | return enterpriseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectSaleEnterprise(Map<String, Object> param, Page<Enterprise> page) { |
| | | return enterpriseMapper.selectSaleEnterprise(param,page); |
| | | } |
| | | |
| | | @Override |
| | | public Enterprise selectEnterpriseByNumber(String number) { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Enterprise::getEnterprisenumber, number) |
| | | .eq(Enterprise::getValidflag,true); |
| | | return enterpriseMapper.selectOne(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map> getAllLocation(String city) { |
| | | return enterpriseMapper.getAllLocation(city); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map> getRetailStatisticsByArea() { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("province", "新疆维吾尔自治区"); |
| | | return enterpriseMapper.getRetailStatisticsByArea(params); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 导出企业信息 |
| | | * @date 2021/4/19 8:51 |
| | | */ |
| | | @Override |
| | | public List<EnterpriseExportVo> selectExportEnterprise(Map filter, UserInfo user) { |
| | | |
| | | UserInfo userInfo = userService.getById(user.getId()); |
| | | Map<String, Object> params = new HashMap<>(); |
| | | //监管部门 根据 地区看所有 |
| | | params.put("enterprisenumber", userInfo.getCompanynumber()); |
| | | params.put("province", userInfo.getProvince()); |
| | | params.put("city", userInfo.getCity()); |
| | | params.put("district", userInfo.getArea()); |
| | | params.put("street", userInfo.getTown()); |
| | | params.put("committee", userInfo.getCommunity()); |
| | | //企业用户 |
| | | params.put("companyId", userInfo.getCompanyid()); |
| | | |
| | | //过滤条件 |
| | | { //企业类型 |
| | | params.put("safetySupervision", filter.get("safetysupervision")); |
| | | //经济类型 |
| | | params.put("economicIndustry", filter.get("economicindustry")); |
| | | //许可证有效|过期 |
| | | params.put("valid", filter.get("valid")); |
| | | //地区 |
| | | params.put("filterProvince", filter.get("province")); |
| | | params.put("filterCity", filter.get("city")); |
| | | params.put("filterDistrict", filter.get("district")); |
| | | params.put("filterStreet", filter.get("street")); |
| | | params.put("filterCommittee", filter.get("committee")); |
| | | //企业名称 |
| | | params.put("enterprisename", filter.get("enterprisename")); |
| | | |
| | | } |
| | | return enterpriseMapper.selectExportEnterprise(params); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 企业信息导入 |
| | | * @date 2021/4/19 9:08 |
| | | */ |
| | | @Override |
| | | public BooleanReason importEnterprise(MultipartFile file,UserInfo userInfo) { |
| | | |
| | | UserInfo user = userService.getById(userInfo.getId()); |
| | | if (user.getCompanynumber() != null) { |
| | | throw new BusinessException("没有导入权限"); |
| | | } |
| | | if(!FileOptUtils.isDirExists(Properties.filePath)){ |
| | | throw new BusinessException("发生错误或不为目录"); |
| | | } |
| | | |
| | | if (file == null || file.getSize() == 0) { |
| | | throw new BusinessException("上传文件或者请求出现问题"); |
| | | } |
| | | |
| | | if(!FileOptUtils.isDirExists(Properties.filePath)){ |
| | | throw new BusinessException("发生错误或不为目录"); |
| | | } |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmmssSSS" ); |
| | | String fileSave = Properties.filePath + userInfo.getUsername() + "_" + sdf.format(new Date()) +".xlsx"; |
| | | |
| | | try { |
| | | file.transferTo(new File(fileSave)); |
| | | InputStream in = new FileInputStream(fileSave); |
| | | String name = file.getOriginalFilename(); |
| | | assert name != null; |
| | | Boolean isExcel2007 = name.substring(name.lastIndexOf(".") + 1).endsWith("xlsx"); |
| | | return excelExportService.importEnterpriseExcel(in, userInfo, isExcel2007); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | throw new BusinessException("找不到文件"); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | throw new BusinessException("发生错误,请联系管理员"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public int getSaleNum() { |
| | | return enterpriseMapper.getSaleNum(Collections.singletonMap("safetysupervision",EnterpriseSafetySupervision.PRODUCE.getMsg())); |
| | | } |
| | | |
| | | @Override |
| | | public List<SaleOrderDetailInfo> getEnterpriseSaleDetail(String enterpriseNumber, String itemcode, String starttime, String endtime) { |
| | | return saleOrderInfoMapper.getEnterpriseSaleDetail(enterpriseNumber, itemcode, starttime, endtime); |
| | | } |
| | | |
| | | @Override |
| | | public Enterprise selectEnterpriseByName(String name) { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Enterprise::getEnterprisename, name) |
| | | .eq(Enterprise::getValidflag,true); |
| | | return enterpriseMapper.selectOne(queryWrapper); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 停用企业 |
| | | * @date 2021/5/28 15:58 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void deactivateEnterprise(Long id,String enterprisenumber, UserInfo user) { |
| | | Enterprise enterprise = null; |
| | | if (id == null && StringUtils.isBlank(enterprisenumber)) |
| | | throw new BusinessException("参数传递错误"); |
| | | |
| | | if (id != null) |
| | | enterprise = this.getById(id); |
| | | |
| | | if (enterprise == null) |
| | | enterprise = this.selectEnterpriseByNumber(enterprisenumber); |
| | | |
| | | if (enterprise == null) { |
| | | throw new BusinessException("没有该企业"); |
| | | } |
| | | //1.修改企业状态为 停止 |
| | | this.setEnterpriseStatus(EnterpriseStatus.OFF, enterprise.getId()); |
| | | |
| | | //2.修改企业用户isdel=1 3.修改终端用户isdel=1 |
| | | List<UserInfo> userList = userService.selectByCompanyId(enterprise.getId(),0); |
| | | if (userList.size() != 2) { |
| | | throw new BusinessException("发生错误,请联系管理员"); |
| | | } |
| | | for (UserInfo info : userList) { |
| | | userService.deleteById(info.getId()); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void activateEnterprise(Long id,String enterprisenumber, UserInfo user) { |
| | | Enterprise enterprise = null; |
| | | if (id == null && StringUtils.isBlank(enterprisenumber)) |
| | | throw new BusinessException("参数传递错误"); |
| | | |
| | | if (id != null) |
| | | enterprise = this.getById(id); |
| | | |
| | | if (enterprise == null) |
| | | enterprise = this.selectEnterpriseByNumber(enterprisenumber); |
| | | |
| | | if (enterprise == null) { |
| | | throw new BusinessException("没有该企业"); |
| | | } |
| | | //1.修改企业状态为 启用 |
| | | this.setEnterpriseStatus(EnterpriseStatus.ON, enterprise.getId()); |
| | | //2.修改企业用户isdel 0 |
| | | //3.修改终端用户isdel 0 |
| | | List<UserInfo> userList = userService.selectByCompanyId(enterprise.getId(),1); |
| | | if (userList.size() != 2) { |
| | | throw new BusinessException("发生错误,请联系管理员"); |
| | | } |
| | | for (UserInfo info : userList) { |
| | | userService.recoverOneById(info.getId()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void setEnterpriseStatus(EnterpriseStatus status, Long id) { |
| | | if (id == null) { |
| | | throw new BusinessException("参数传递不能为空"); |
| | | } |
| | | LambdaUpdateWrapper<Enterprise> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.set(Enterprise::getEnterprisestatus, status) |
| | | .eq(Enterprise::getId, id); |
| | | this.update(updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public int countAllUndoneEnterprise(UserInfo userInfo) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("province", userInfo.getProvince()); |
| | | params.put("city", userInfo.getCity()); |
| | | params.put("district", userInfo.getArea()); |
| | | params.put("street", userInfo.getTown()); |
| | | params.put("committee", userInfo.getCommunity()); |
| | | return enterpriseMapper.countAllUndoneEnterprise(params); |
| | | } |
| | | |
| | | @Override |
| | | public int countAllEnterpriseExpired(UserInfo userInfo) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("province", userInfo.getProvince()); |
| | | params.put("city", userInfo.getCity()); |
| | | params.put("district", userInfo.getArea()); |
| | | params.put("street", userInfo.getTown()); |
| | | params.put("committee", userInfo.getCommunity()); |
| | | return enterpriseMapper.countAllEnterpriseExpired(params); |
| | | } |
| | | |
| | | @Override |
| | | public void addEnterpriseByRegister(RegisterInfo registerInfo, UserInfo userInfo) { |
| | | Enterprise enterprise = new Enterprise(); |
| | | enterprise.setSafetysupervision(registerInfo.getType()); |
| | | enterprise.setEnterprisenumber(registerInfo.getEnterprisenumber()); |
| | | enterprise.setEnterprisename(registerInfo.getEnterprisename()); |
| | | enterprise.setProvince(registerInfo.getProvince()); |
| | | enterprise.setCity(registerInfo.getCity()); |
| | | enterprise.setDistrict(registerInfo.getDistrict()); |
| | | enterprise.setStreet(registerInfo.getStreet()); |
| | | enterprise.setCommittee(registerInfo.getCommittee()); |
| | | enterprise.setRegisteraddress(registerInfo.getAddress()); |
| | | enterprise.setPassword(Base64Encrypt.encode(registerInfo.getPassword().getBytes())); |
| | | int i = enterpriseService.countBySafetySupervision(enterprise.getSafetysupervision()); |
| | | enterprise.setDivideflag((byte) (DivideFlagUtil.enterpriseDivideFlagGenerate(i))); |
| | | enterprise.setInfocreatebyname(userInfo.getUsername()); |
| | | enterprise.setInfocreateby(userInfo.getId()); |
| | | enterprise.setInfoupdatetime(new Date()); |
| | | enterprise.setValidflag(true); |
| | | |
| | | enterpriseService.save(enterprise); |
| | | |
| | | //保存用户 |
| | | UserInfo user = new UserInfo(); |
| | | user.setIsdel((byte) 0); |
| | | user.setProvince(enterprise.getProvince()); |
| | | user.setCity(enterprise.getCity()); |
| | | user.setArea(enterprise.getDistrict()); |
| | | user.setUsername(enterprise.getEnterprisename()); |
| | | user.setCompany(enterprise.getEnterprisename()); |
| | | user.setIssale((byte) 0); |
| | | //普通用户 |
| | | user.setType(3); |
| | | user.setCreatedby(user.getUsername()); |
| | | user.setCompanyid(enterprise.getId()); |
| | | user.setCreateddate(new Date()); |
| | | //设置密码 |
| | | user.setPassword(enterprise.getPassword()); |
| | | user.setCompanynumber(enterprise.getEnterprisenumber()); |
| | | //执行 |
| | | userService.save(user); |
| | | |
| | | //如果有企业角色设置用户角色为企业 |
| | | UserRolesInfo uri = new UserRolesInfo(); |
| | | uri.setUserid(user.getId()); |
| | | if (enterprise.getSafetysupervision().equals(EnterpriseSafetySupervision.PRODUCE.getMsg())){ |
| | | uri.setRoleid((long) 3); |
| | | }else { |
| | | uri.setRoleid((long) 2); |
| | | } |
| | | userRolesService.save(uri); |
| | | //终端机 |
| | | user.setId(null); |
| | | user.setUsername(enterprise.getEnterprisenumber()); |
| | | user.setIssale((byte) 1); |
| | | user.setStatus((byte) 1); |
| | | userService.save(user); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectListUnderSupervision(Integer type,UserInfo userInfo) { |
| | | List<Enterprise> result = new ArrayList<>(); |
| | | Map<String, Object> params = new HashMap<>(); |
| | | UserInfo user = userService.getById(userInfo); |
| | | if (StringUtils.isBlank(user.getCompanynumber())) { |
| | | params.put("province", user.getProvince()); |
| | | params.put("city", user.getCity()); |
| | | params.put("district", user.getArea()); |
| | | params.put("street", user.getTown()); |
| | | params.put("committee", user.getCommunity()); |
| | | params.put("safetysupervision", EnterpriseSafetySupervision.PRODUCE.getMsg()); |
| | | //1生产企业,2销售企业 |
| | | params.put("type", type); |
| | | result= enterpriseMapper.selectListUnderSupervision(params); |
| | | } |
| | | return result; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public IPage selectUndoneList(Page<Enterprise> page, Map filter,UserInfo userInfo) { |
| | | Map<Object, Object> params = new HashMap<>(); |
| | | List<Enterprise> undoneList = null; |
| | | UserInfo user = userService.getById(userInfo); |
| | | //可见度 |
| | | if (StringUtils.isBlank(user.getCompanynumber())) { |
| | | params.put("province", user.getProvince()); |
| | | params.put("city", user.getCity()); |
| | | params.put("district", user.getArea()); |
| | | params.put("street", user.getTown()); |
| | | params.put("committee", user.getCommunity()); |
| | | |
| | | //过滤条件 |
| | | params.put("enterprisename", filter.get("enterprisename")); |
| | | params.put("filterProvince", filter.get("province")); |
| | | params.put("filterCity", filter.get("city")); |
| | | params.put("filterDistrict", filter.get("district")); |
| | | params.put("filterStreet", filter.get("street")); |
| | | params.put("filterCommittee", filter.get("committee")); |
| | | undoneList = enterpriseMapper.selectUndoneList(page,params); |
| | | |
| | | } |
| | | |
| | | return page.setRecords(undoneList); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectExportUndoneList(Map filter, UserInfo userInfo) { |
| | | Map<Object, Object> params = new HashMap<>(); |
| | | List<Enterprise> undoneList = null; |
| | | UserInfo user = userService.getById(userInfo); |
| | | //可见度 |
| | | if (StringUtils.isBlank(user.getCompanynumber())) { |
| | | params.put("province", user.getProvince()); |
| | | params.put("city", user.getCity()); |
| | | params.put("district", user.getArea()); |
| | | params.put("street", user.getTown()); |
| | | params.put("committee", user.getCommunity()); |
| | | |
| | | //过滤条件 |
| | | params.put("enterprisename", filter.get("enterprisename")); |
| | | params.put("filterProvince", filter.get("province")); |
| | | params.put("filterCity", filter.get("city")); |
| | | params.put("filterDistrict", filter.get("district")); |
| | | params.put("filterStreet", filter.get("street")); |
| | | params.put("filterCommittee", filter.get("committee")); |
| | | undoneList = enterpriseMapper.selectUndoneList(params); |
| | | } |
| | | return undoneList; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isDuplicate2BitCode(String twoBit) { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Enterprise::getTwobitcode, twoBit) |
| | | .eq(Enterprise::getValidflag,true); |
| | | return enterpriseMapper.selectCount(queryWrapper) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public IPage selectExpiredList(Page<Enterprise> page, Map filter, UserInfo userInfo) { |
| | | Map<Object, Object> params = new HashMap<>(); |
| | | List<Enterprise> expiredList = null; |
| | | UserInfo user = userService.getById(userInfo); |
| | | //可见度 |
| | | if (StringUtils.isBlank(user.getCompanynumber())) { |
| | | params.put("province", user.getProvince()); |
| | | params.put("city", user.getCity()); |
| | | params.put("district", user.getArea()); |
| | | params.put("street", user.getTown()); |
| | | params.put("committee", user.getCommunity()); |
| | | |
| | | //过滤条件 |
| | | params.put("enterprisename", filter.get("enterprisename")); |
| | | params.put("filterProvince", filter.get("province")); |
| | | params.put("filterCity", filter.get("city")); |
| | | params.put("filterDistrict", filter.get("district")); |
| | | params.put("filterStreet", filter.get("street")); |
| | | params.put("filterCommittee", filter.get("committee")); |
| | | expiredList = enterpriseMapper.selectExpiredList(page,params); |
| | | } |
| | | return page.setRecords(expiredList); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectExportExpiredList(Map<String, Object> filter, UserInfo userInfo) { |
| | | Map<Object, Object> params = new HashMap<>(); |
| | | List<Enterprise> expiredList = null; |
| | | UserInfo user = userService.getById(userInfo); |
| | | //可见度 |
| | | if (StringUtils.isBlank(user.getCompanynumber())) { |
| | | params.put("province", user.getProvince()); |
| | | params.put("city", user.getCity()); |
| | | params.put("district", user.getArea()); |
| | | params.put("street", user.getTown()); |
| | | params.put("committee", user.getCommunity()); |
| | | |
| | | //过滤条件 |
| | | params.put("enterprisename", filter.get("enterprisename")); |
| | | params.put("filterProvince", filter.get("province")); |
| | | params.put("filterCity", filter.get("city")); |
| | | params.put("filterDistrict", filter.get("district")); |
| | | params.put("filterStreet", filter.get("street")); |
| | | params.put("filterCommittee", filter.get("committee")); |
| | | expiredList = enterpriseMapper.selectExpiredList(params); |
| | | } |
| | | return expiredList; |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectSubEnterprise(Long enterpriseId) { |
| | | |
| | | Enterprise parent = enterpriseService.getById(enterpriseId); |
| | | if (parent == null) throw new BusinessException("不存在企业信息"); |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Enterprise::getParententerprisename, parent.getEnterprisename()) |
| | | .eq(Enterprise::getValidflag,true) |
| | | .eq(Enterprise::getEnterprisestatus,EnterpriseStatus.ON); |
| | | return enterpriseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> getEnterpriseByLimit(Map<String, Object> condition) { |
| | | return enterpriseMapper.getEnterpriseByLimit(condition); |
| | | } |
| | | |
| | | @Override |
| | | public Integer getEnterpriseByLimitCount(Map<String, Object> condition) { |
| | | return enterpriseMapper.getEnterpriseByLimitCount(condition); |
| | | } |
| | | |
| | | @Override |
| | | public BooleanReason importDlCompanyCode(MultipartFile file, UserInfo userInfo) { |
| | | UserInfo user = userService.getById(userInfo.getId()); |
| | | if (user.getCompanynumber() != null) |
| | | throw new BusinessException("没有导入权限"); |
| | | |
| | | if (file == null || file.getSize() == 0) |
| | | throw new BusinessException("上传文件或者请求出现问题"); |
| | | |
| | | try { |
| | | String name = file.getOriginalFilename(); |
| | | InputStream in = file.getInputStream(); |
| | | assert name != null; |
| | | boolean isExcel2007 = name.substring(name.lastIndexOf(".") + 1).endsWith("xlsx"); |
| | | return excelExportService.importDLCompanyCodeExcel(in, userInfo, isExcel2007); |
| | | } catch (BusinessException e) { |
| | | throw new BusinessException(e.getMessage()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new BusinessException("导入失败,请联系管理员"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> exportDlCompanyCode() { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper |
| | | .select(Enterprise::getEnterprisename, |
| | | Enterprise::getDlcompanycode, |
| | | Enterprise::getDeviceid) |
| | | .eq(Enterprise::getValidflag, true) |
| | | .isNotNull(Enterprise::getDlcompanycode); |
| | | return enterpriseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectAllDlCompanyCodeIsNotNull() { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper |
| | | .select(Enterprise::getId, |
| | | Enterprise::getEnterprisenumber, |
| | | Enterprise::getDlcompanycode) |
| | | .eq(Enterprise::getValidflag,true) |
| | | .isNull(Enterprise::getDeviceid) |
| | | .isNotNull(Enterprise::getDlcompanycode); |
| | | |
| | | return enterpriseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void updateCompanyCode(Enterprise e) { |
| | | enterpriseMapper.updateCompanyCodeAndSetDeviceIdNull(e); |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectSaleEnterpriseForUpload() { |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.ne(Enterprise::getSafetysupervision, EnterpriseSafetySupervision.PRODUCE.getMsg()); |
| | | queryWrapper.eq(Enterprise::getValidflag,1); |
| | | queryWrapper.eq(Enterprise::getEnterprisestatus ,"ON"); |
| | | queryWrapper.isNotNull(Enterprise::getDlcompanycode); |
| | | queryWrapper.isNotNull(Enterprise::getDeviceid); |
| | | return enterpriseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | |
| | | /* |
| | | 判断是否注销 true 注销,flase 正常 |
| | | */ |
| | | @Override |
| | | public boolean isLogOut(String companynumber) { |
| | | boolean flag = false; |
| | | if (StringUtils.isBlank(companynumber)) throw new BusinessException("企业编号为空"); |
| | | LambdaQueryWrapper<Enterprise> queryWrapper = new LambdaQueryWrapper<>(); |
| | | Enterprise enterprise = enterpriseMapper.selectOne( |
| | | queryWrapper.select(Enterprise::getEnterprisename,Enterprise::getLoginvalidflag) |
| | | .eq(Enterprise::getEnterprisenumber, companynumber)); |
| | | if (enterprise == null) throw new BusinessException("企业不存在"); |
| | | if ( enterprise.getLoginvalidflag() != null && !enterprise.getLoginvalidflag()) flag = true; |
| | | return flag; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void logout(List<Long> ids, UserInfo user) { |
| | | if (user.getType() != 1) throw new BusinessException("没有权限"); |
| | | if (ids == null || ids.size() < 1) throw new BusinessException("参数为空"); |
| | | for (Long id : ids) { |
| | | enterpriseMapper.updateLoginValidFlag(id,false); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void recoverLogin(Long id, UserInfo user) { |
| | | if (user.getType() != 1) throw new BusinessException("没有权限"); |
| | | if(id == null) throw new BusinessException("参数为空"); |
| | | enterpriseMapper.updateLoginValidFlag(id,true); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void recoverLoginBatch(List<Long> ids, UserInfo user) { |
| | | if (user.getType() != 1) throw new BusinessException("没有权限"); |
| | | if (ids == null || ids.size() < 1) throw new BusinessException("参数为空"); |
| | | for (Long id : ids) { |
| | | enterpriseMapper.updateLoginValidFlag(id,true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Enterprise> selectEnterpriseListByNameLike(String name) { |
| | | if(name == null || name.isEmpty()){ |
| | | return null; |
| | | }else { |
| | | return enterpriseMapper.selectEnterpriseListByNameLike(name); |
| | | } |
| | | } |
| | | |
| | | private String compareObj(Class clazz,Object obj1,Object obj2) throws IllegalAccessException { |
| | | Class<?> class1 = obj1.getClass(); |
| | | Class<?> class2 = obj2.getClass(); |
| | | Field[] fields = clazz.getDeclaredFields(); |
| | | JSONObject jo = new JSONObject(); |
| | | if (fields.length> 0) { |
| | | for (Field field : fields) { |
| | | field.setAccessible(true); |
| | | String name = field.getName(); |
| | | if (!name.equals("serialVersionUID")&& !name.equals("divideflag") |
| | | && !Objects.equals(field.get(obj1),field.get(obj2))) { |
| | | |
| | | if (field.get(obj1) != null && field.get(obj2) == null){ |
| | | jo.put(name, ""); |
| | | }else{ |
| | | if (name.equals("legalrepresentative") || |
| | | name.equals("mainprincipal")|| |
| | | name.equals("securityofficer")|| |
| | | name.equals("informationofficer")){ |
| | | String o1 = (String) field.get(obj1); |
| | | String o2 = (String) field.get(obj2); |
| | | |
| | | JSONObject jsonObject1 = JSONObject.parseObject(o1); |
| | | JSONObject jsonObject2 = JSONObject.parseObject(o2); |
| | | Map<String, Object> innerMap1 = jsonObject1.getInnerMap(); |
| | | Map<String, Object> innerMap2 = jsonObject2.getInnerMap(); |
| | | for (Map.Entry<String, Object> entry : innerMap1.entrySet()) { |
| | | String f = entry.getKey(); |
| | | Object value1 = innerMap1.get(f); |
| | | Object value2= innerMap2.get(f); |
| | | if (!Objects.equals(value1, value2)) { |
| | | jo.put(f, value2); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | jo.put(name, field.get(obj2)); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | return jo.isEmpty()?null:jo.toJSONString(); |
| | | } |
| | | |
| | | |
| | | } |