| | |
| | | |
| | | 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.system.service.IUserDeptService; |
| | | 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; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | |
| | | * @since 2021-07-07 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class DispatcherUnitServiceImpl extends ServiceImpl<DispatcherUnitMapper, DispatcherUnit> implements IDispatcherUnitService { |
| | | |
| | | |
| | | private final IDispatcherService dispatcherService; |
| | | |
| | | private final IUserDeptService userDeptService; |
| | | |
| | | @Override |
| | | public IPage<DispatcherUnitVO> selectDispatcherUnitPage(IPage<DispatcherUnitVO> page, DispatcherUnitVO dispatcherUnitVO) { |
| | | return page.setRecords(baseMapper.selectDispatcherUnitPage(page, dispatcherUnitVO)); |
| | | List<DispatcherUnitVO> dispatcherUnitVOS = baseMapper.selectDispatcherUnitPage(page, dispatcherUnitVO); |
| | | dispatcherUnitVOS.forEach(dispatcherUnitVO1 -> { |
| | | //查询派遣记录条数 |
| | | dispatcherUnitVO1.setNum(dispatcherService.getDispatcherCount(dispatcherUnitVO1)); |
| | | }); |
| | | return page.setRecords(dispatcherUnitVOS); |
| | | } |
| | | |
| | | /** |
| | |
| | | public DispatcherUnitVO selectDispatcherUnitInfo(DispatcherUnit dispatcherUnit) { |
| | | return baseMapper.selectDispatcherUnitInfo(dispatcherUnit); |
| | | } |
| | | |
| | | /** |
| | | * 自定义树 |
| | | * @param dispatcher |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DispatcherUnitVO> selectDispatcherUnitPageTree(DispatcherUnitVO dispatcher) { |
| | | return baseMapper.selectDispatcherUnitPageTree(dispatcher); |
| | | } |
| | | |
| | | /** |
| | | * 派遣导入 |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | public void importDispatcherUnit(List<DispatcherUnitExcel> 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.getName()!=null && dispatcherUnitExcel.getName()!=""){ |
| | | //仅中文 |
| | | String chinese = "^[\\u4E00-\\u9FA5\\uF900-\\uFA2D]+$"; |
| | | Pattern compile = Pattern.compile(chinese); |
| | | String name = compile.matcher(dispatcherUnitExcel.getName()).replaceAll(""); |
| | | dispatcherUnit.setName(name); |
| | | } |
| | | |
| | | if (dispatcherUnitExcel.getLinkman()!=null && dispatcherUnitExcel.getLinkman()!=""){ |
| | | dispatcherUnit.setLinkman(dispatcherUnitExcel.getLinkman()); |
| | | } |
| | | |
| | | if (dispatcherUnitExcel.getPhone()!=null && dispatcherUnitExcel.getPhone()!=""){ |
| | | dispatcherUnit.setPhone(dispatcherUnitExcel.getPhone()); |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | //新增 |
| | | this.save(dispatcherUnit); |
| | | |
| | | //数据同步 |
| | | String s1 = |
| | | "insert into sys_dispatcher_unit(id,name,dept_id,linkman,phone,start_time,end_time) " + |
| | | "values(" + "'" + dispatcherUnit.getId() + "'" + "," + |
| | | "'" + dispatcherUnit.getName() + "'" + "," + |
| | | "'" + dispatcherUnit.getDeptId() + "'" + "," + |
| | | "'" + dispatcherUnit.getLinkman() + "'" + "," + |
| | | "'" + dispatcherUnit.getPhone() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd").format(dispatcherUnit.getStartTime()) + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd").format(dispatcherUnit.getEndTime()) + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }); |
| | | } |
| | | } |