| | |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.basic.service.ISupplierService; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | ExcelUtil<SupplierManageExcelDto> util = new ExcelUtil<SupplierManageExcelDto>(SupplierManageExcelDto.class); |
| | | util.exportExcel(response, supplierManageList, "供应商导出"); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean importData(MultipartFile file) { |
| | | |
| | | try { |
| | | ExcelUtil<SupplierManageExcelDto> util = new ExcelUtil<SupplierManageExcelDto>(SupplierManageExcelDto.class); |
| | | List<SupplierManageExcelDto> list = util.importExcel(file.getInputStream()); |
| | | ArrayList<SupplierManage> supplierManages = new ArrayList<>(); |
| | | list.stream().forEach(dto -> { |
| | | SupplierManage supplierManage = new SupplierManage(); |
| | | BeanUtils.copyProperties(dto,supplierManage); |
| | | supplierManage.setMaintainTime(LocalDate.now()); |
| | | Long userId = SecurityUtils.getLoginUser().getUser().getUserId(); |
| | | |
| | | supplierManage.setMaintainUserId(Integer.parseInt(userId+"")); |
| | | supplierManages.add(supplierManage); |
| | | }); |
| | | |
| | | this.saveOrUpdateBatch(supplierManages); |
| | | return true; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | } |
| | | } |