| | |
| | | package com.panzhihua.westcommittee.service.impl; |
| | | |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.west.SystemUserVo; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.westcommittee.dao.DepartmentMapper; |
| | | import com.panzhihua.westcommittee.model.entity.BcRegion; |
| | | import com.panzhihua.westcommittee.model.entity.ComAct; |
| | | import com.panzhihua.westcommittee.model.entity.ComStreet; |
| | | import com.panzhihua.westcommittee.model.entity.Department; |
| | | import com.panzhihua.westcommittee.service.IBcRegionService; |
| | | import com.panzhihua.westcommittee.service.IComActService; |
| | | import com.panzhihua.westcommittee.service.IComStreetService; |
| | | import com.panzhihua.westcommittee.service.IDepartmentService; |
| | | import com.panzhihua.westcommittee.utils.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | */ |
| | | @Service |
| | | public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService { |
| | | |
| | | @Autowired |
| | | private ExcelUtil excelUtil; |
| | | |
| | | |
| | | @Autowired |
| | | private IComStreetService streetService; |
| | | |
| | | @Autowired |
| | | private IComActService comActService; |
| | | |
| | | @Override |
| | | public R<?> importDepartment(String s, MultipartFile file,String name,Integer id) { |
| | | List<List<List<String>>> upload = excelUtil.upload( s,file); |
| | | List<List<String>> lists = upload.get(0); |
| | | for (List<String> list : lists) { |
| | | String deptName = list.get(0); |
| | | String level = list.get(1); |
| | | String districts = list.get(2); |
| | | String street = list.get(3); |
| | | String community = list.get(4); |
| | | String remark = list.get(5); |
| | | |
| | | Department department = new Department(); |
| | | department.setName(deptName); |
| | | department.setTier(Integer.parseInt(level)); |
| | | department.setDistricts(districts); |
| | | department.setDistrictsCode("510403"); |
| | | if(StringUtils.isNotEmpty(street)){ |
| | | department.setStreet(street); |
| | | ComStreet one = streetService.getOne(new LambdaQueryWrapper<ComStreet>().eq(ComStreet::getName, street).eq(ComStreet::getAppId,"wx0cef797390444b75")); |
| | | department.setStreetId(one.getStreetId()); |
| | | } |
| | | if(StringUtils.isNotEmpty(community)){ |
| | | department.setCommunity(community); |
| | | ComAct one = comActService.getOne(new LambdaQueryWrapper<ComAct>().eq(ComAct::getName, community).eq(ComAct::getAppId,"wx0cef797390444b75")); |
| | | department.setCommunityId(one.getCommunityId()); |
| | | } |
| | | |
| | | department.setRemark(remark); |
| | | department.setCreateTime(new Date()); |
| | | department.setUpdateTime(new Date()); |
| | | department.setOperName(name); |
| | | department.setOperId(id); |
| | | department.setStatus(1); |
| | | try { |
| | | this.save(department); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |