| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.equipage.entity.Car; |
| | | import org.springblade.modules.equipage.entity.Gun; |
| | | import org.springblade.modules.equipage.excel.GunExcel; |
| | | import org.springblade.modules.equipage.excel.GunImporter; |
| | | import org.springblade.modules.equipage.mapper.GunMapper; |
| | | import org.springblade.modules.equipage.service.GunService; |
| | | import org.springblade.modules.equipage.vo.GunVo; |
| | | import org.springblade.modules.system.service.IUserDeptService; |
| | | import org.springblade.modules.system.service.MyAsyncService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 枪支服务实现类 |
| | |
| | | */ |
| | | @Service |
| | | public class GunServiceImpl extends ServiceImpl<GunMapper, Gun> implements GunService { |
| | | |
| | | @Autowired |
| | | private IUserDeptService userDeptService; |
| | | @Autowired |
| | | private MyAsyncService myAsyncService; |
| | | |
| | | /** |
| | | * 枪支分页信息 |
| | |
| | | public GunVo selectGunInfo(Gun gun) { |
| | | return baseMapper.selectGunInfo(gun); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 枪支导入 |
| | | * @param data |
| | | * @param isCovered |
| | | * @param deptId |
| | | */ |
| | | @Override |
| | | public void importGun(List<GunExcel> data, Boolean isCovered, String deptId) { |
| | | if (data.size()>0){ |
| | | //遍历 |
| | | data.forEach(gunExcel -> { |
| | | Gun gun = Objects.requireNonNull(BeanUtil.copy(gunExcel, Gun.class)); |
| | | //设置部门id |
| | | String deptIds = userDeptService.selectIn(gunExcel.getDeptId()); |
| | | if (null!=deptIds && !deptIds.equals("")) { |
| | | if (null != deptId && !deptId.equals("")) { |
| | | if (!deptId.equals(deptIds)) { |
| | | throw new ServiceException("导入失败!不能导入不是本公司的枪支信息数据!"); |
| | | } |
| | | } |
| | | gun.setDeptId(Long.parseLong(deptIds)); |
| | | }else { |
| | | //如果deptIds 为空,则说明还没有改公司 |
| | | throw new ServiceException("导入失败!公司名:["+gunExcel.getDeptId()+"]不存在!"); |
| | | } |
| | | |
| | | //新增车辆数据 |
| | | this.save(gun); |
| | | |
| | | //数据同步 |
| | | String s1 = |
| | | "insert into sys_gun(id,issue_unit,card_number,gun_mode," + |
| | | "dept_id,person_in_charge,card_no) " + |
| | | "values(" + "'" + gun.getId() + "'" + "," + |
| | | "'" + gun.getIssueUnit() + "'" + "," + |
| | | "'" + gun.getCardNumber() + "'" + "," + |
| | | "'" + gun.getGunMode() + "'" + "," + |
| | | "'" + gun.getDeptId() + "'" + "," + |
| | | "'" + gun.getPersonInCharge() + "'" + "," + |
| | | "'" +gun.getCardNo() + "'" + ")"; |
| | | //FtpUtil.sqlFileUpload(s1); |
| | | myAsyncService.dataSync(s1); |
| | | |
| | | }); |
| | | }else { |
| | | throw new ServiceException("没有数据"); |
| | | } |
| | | } |
| | | } |