/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.dispatcher.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import org.springblade.modules.FTP.FtpUtil; import org.springblade.modules.dispatcher.entity.Dispatcher; import org.springblade.modules.dispatcher.entity.DispatcherUnit; import org.springblade.modules.dispatcher.excel.DispatcherUnitExcel; import org.springblade.modules.dispatcher.mapper.DispatcherMapper; import org.springblade.modules.dispatcher.mapper.DispatcherUnitMapper; import org.springblade.modules.dispatcher.service.IDispatcherService; import org.springblade.modules.dispatcher.service.IDispatcherUnitService; import org.springblade.modules.dispatcher.vo.DispatcherUnitVO; import org.springblade.modules.dispatcher.vo.DispatcherVO; import org.springblade.modules.jurisdiction.service.JurisdictionService; import org.springblade.modules.system.service.IUserDeptService; import org.springblade.modules.system.service.MyAsyncService; import org.springframework.stereotype.Service; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * 服务实现类 * * @author BladeX * @since 2021-07-07 */ @Service @AllArgsConstructor public class DispatcherUnitServiceImpl extends ServiceImpl implements IDispatcherUnitService { private final IDispatcherService dispatcherService; private final IUserDeptService userDeptService; private final JurisdictionService jurisdictionService; @Override public IPage selectDispatcherUnitPage(IPage page, DispatcherUnitVO dispatcherUnitVO) { List dispatcherUnitVOS = baseMapper.selectDispatcherUnitPage(page, dispatcherUnitVO); dispatcherUnitVOS.forEach(dispatcherUnitVO1 -> { //查询派遣记录条数 dispatcherUnitVO1.setSnum(dispatcherService.getDispatcherCount(dispatcherUnitVO1)); }); return page.setRecords(dispatcherUnitVOS); } @Override public List getAll(DispatcherUnit dispatcherUnit) { List dispatcherUnitVOS = baseMapper.getAll(dispatcherUnit); dispatcherUnitVOS.forEach(dispatcherUnitVO1 -> { //查询派遣记录条数 dispatcherUnitVO1.setSnum(dispatcherService.getDispatcherCount(dispatcherUnitVO1)); }); return dispatcherUnitVOS; } /** * 派遣公司信息详情 * * @param dispatcherUnit 派遣信息对象 * @return */ @Override public DispatcherUnitVO selectDispatcherUnitInfo(DispatcherUnit dispatcherUnit) { return baseMapper.selectDispatcherUnitInfo(dispatcherUnit); } /** * 自定义树 * * @param dispatcher * @return */ @Override public List selectDispatcherUnitPageTree(DispatcherUnitVO dispatcher) { return baseMapper.selectDispatcherUnitPageTree(dispatcher); } /** * 派遣导入 * * @param data * @param isCovered */ @Override public void importDispatcherUnit(List data, Boolean isCovered) { //派遣数据导入 data.forEach(dispatcherUnitExcel -> { //派遣单位 DispatcherUnit dispatcherUnit = new DispatcherUnit(); //数据获取 if (dispatcherUnitExcel.getDeptName() != null && dispatcherUnitExcel.getDeptName() != "") { String deptId = userDeptService.selectIn(dispatcherUnitExcel.getDeptName()); dispatcherUnit.setDeptId(Long.parseLong(deptId)); } if (dispatcherUnitExcel.getJurisdiction() != null && dispatcherUnitExcel.getJurisdiction() != ""){ String jurisdiction = jurisdictionService.selectIn(dispatcherUnitExcel.getJurisdiction()); dispatcherUnit.setJurisdiction(jurisdiction); } if (dispatcherUnitExcel.getName() != null && dispatcherUnitExcel.getName() != "") { //仅中文 // String chinese = "^[\\u4E00-\\u9FA5\\uF900-\\uFA2D]+$"; // Pattern compile = Pattern.compile(chinese); // String name = compile.matcher(dispatcherUnitExcel.getName()).replaceAll(""); dispatcherUnit.setName(dispatcherUnitExcel.getName()); } if (dispatcherUnitExcel.getLinkman() != null && dispatcherUnitExcel.getLinkman() != "") { dispatcherUnit.setLinkman(dispatcherUnitExcel.getLinkman()); } if (dispatcherUnitExcel.getPhone() != null && dispatcherUnitExcel.getPhone() != "") { dispatcherUnit.setPhone(dispatcherUnitExcel.getPhone()); } if (dispatcherUnitExcel.getSecurityLinkman() != null && dispatcherUnitExcel.getSecurityLinkman() != "") { dispatcherUnit.setSecurityLinkman(dispatcherUnitExcel.getSecurityLinkman()); } if (dispatcherUnitExcel.getCell() != null && dispatcherUnitExcel.getCell() != "") { dispatcherUnit.setCell(dispatcherUnitExcel.getCell()); } if (dispatcherUnitExcel.getServeType() != null && dispatcherUnitExcel.getServeType() != "") { dispatcherUnit.setServeType(dispatcherUnitExcel.getServeType()); } if (dispatcherUnitExcel.getNum() != null) { dispatcherUnit.setNum(dispatcherUnitExcel.getNum()); } if (dispatcherUnitExcel.getProfession() != null && dispatcherUnitExcel.getProfession() != ""){ dispatcherUnit.setProfession(dispatcherUnitExcel.getProfession()); } if (dispatcherUnitExcel.getDistrict() != null && dispatcherUnitExcel.getDistrict() != ""){ dispatcherUnit.setDistrict(dispatcherUnitExcel.getDistrict()); } dispatcherUnit.setLongitude(dispatcherUnitExcel.getLongitude()); dispatcherUnit.setLatitude(dispatcherUnitExcel.getLatitude()); dispatcherUnit.setAddress(dispatcherUnitExcel.getAddress()); dispatcherUnit.setStartTime(dispatcherUnitExcel.getStartTime()); dispatcherUnit.setEndTime(dispatcherUnitExcel.getEndTime()); // if (dispatcherUnitExcel.getStartTime()!=null){ // String year = dispatcherUnitExcel.getStartTime().substring(0, 4); // String month = dispatcherUnitExcel.getStartTime().substring(4, 6); // String day = dispatcherUnitExcel.getStartTime().substring(6, 8); // String dateFormat = year + "-" +month+"-" +day; // try { // Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateFormat); // dispatcherUnit.setStartTime(date); // } catch (ParseException e) { // e.printStackTrace(); // } // } // // if (dispatcherUnitExcel.getEndTime()!=null){ // String year = dispatcherUnitExcel.getEndTime().substring(0, 4); // String month = dispatcherUnitExcel.getEndTime().substring(4, 6); // String day = dispatcherUnitExcel.getEndTime().substring(6, 8); // String dateFormat = year + "-" +month+"-" +day; // try { // Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateFormat); // dispatcherUnit.setEndTime(date); // } catch (ParseException e) { // e.printStackTrace(); // } // } dispatcherUnit.setCreateTime(new Date()); //新增 this.save(dispatcherUnit); }); } }