| | |
| | | import com.zy.crm.common.web.BaseController; |
| | | import com.zy.crm.manager.entity.Plan; |
| | | import com.zy.crm.manager.service.PlanService; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.ss.usermodel.DataFormatter; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class PlanController extends BaseController { |
| | |
| | | @RequestMapping(value = "/plan/add/auth") |
| | | @ManagerAuth |
| | | public R add(Plan plan) { |
| | | |
| | | plan.setCreateBy(getUserId()); |
| | | plan.setCreateTime(new Date()); |
| | | plan.setUpdateBy(getUserId()); |
| | | plan.setUpdateTime(new Date()); |
| | | plan.setStatus(1); |
| | | |
| | | planService.insert(plan); |
| | | return R.ok(); |
| | | } |
| | |
| | | if (Cools.isEmpty(plan) || null==plan.getId()){ |
| | | return R.error(); |
| | | } |
| | | plan.setUpdateBy(getUserId()); |
| | | plan.setUpdateTime(new Date()); |
| | | planService.updateById(plan); |
| | | return R.ok(); |
| | | } |
| | |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | /*************************************** 数据相关 ***********************************************/ |
| | | |
| | | /** |
| | | * excel导入 |
| | | */ |
| | | @PostMapping(value = "/plan/excel/import/auth") |
| | | @ManagerAuth(memo = "甲方单位Excel导入") |
| | | // @Transactional |
| | | public R planExcelImport(MultipartFile file) throws IOException { |
| | | InputStream inStream = file.getInputStream(); |
| | | String fileMime = file.getContentType(); |
| | | int excelVersion = 2007; |
| | | if ("application/vnd.ms-excel".equals(fileMime)) { |
| | | excelVersion = 2003; |
| | | } |
| | | Workbook book = null; |
| | | if (excelVersion == 2003) { |
| | | book = new HSSFWorkbook(inStream); |
| | | } |
| | | else { // 当 excel 是 2007 时 |
| | | book = new XSSFWorkbook(inStream); |
| | | } |
| | | Sheet sheet = book.getSheetAt(0); |
| | | int totalRows = sheet.getLastRowNum() + 1; // 总 |
| | | Long userId = getUserId(); |
| | | Long hostId = getHostId(); |
| | | Long deptId = getDeptId(); |
| | | Date now = new Date(); |
| | | DataFormatter dataFormatter = new DataFormatter(); |
| | | for (int i = 2; i < totalRows; i++) { |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * excel导出 |
| | | */ |
| | | @PostMapping(value = "/plan/excel/export/auth") |
| | | @ManagerAuth |
| | | public void planExcelExport(HttpServletResponse response) throws IOException { |
| | | |
| | | } |
| | | |
| | | } |