| | |
| | | import org.springblade.modules.equipage.vo.EquipageVo; |
| | | import org.springblade.modules.exam.excel.ExamScoreExcel; |
| | | import org.springblade.modules.exam.excel.ExamScoreImporter; |
| | | import org.springblade.modules.system.service.MyAsyncService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | public class EquipageController { |
| | | |
| | | private final EquipageService equipageService; |
| | | private final MyAsyncService myAsyncService; |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * @param query page,size |
| | | * |
| | | * @param query page,size |
| | | * @param equipage 装备信息对象 |
| | | */ |
| | | @GetMapping("/page") |
| | |
| | | |
| | | /** |
| | | * 新增 |
| | | * |
| | | * @param equipage 装备信息对象 |
| | | */ |
| | | @PostMapping("/save") |
| | |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param equipage 装备信息对象 |
| | | */ |
| | | @PostMapping("/update") |
| | |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * |
| | | * @param equipage 装备信息对象 |
| | | */ |
| | | @PostMapping("/submit") |
| | | public R submit(@RequestBody Equipage equipage){ |
| | | public R submit(@RequestBody Equipage equipage) { |
| | | boolean status = false; |
| | | if (equipage.getId()==null){ |
| | | if (equipage.getId() == null) { |
| | | //新增 |
| | | status = equipageService.save(equipage); |
| | | |
| | | //数据推送 |
| | | String s1 = |
| | | "insert into sys_equipage(id,name,number,specifications,mode,dept_id,brand,date_for_production,jurisdiction,user_id,num) " + |
| | | "values(" + "'" + equipage.getId() + "'" + "," + |
| | | "'" + equipage.getName() + "'" + "," + |
| | | "'" + equipage.getNumber() + "'" + "," + |
| | | "'" + equipage.getSpecifications() + "'" + "," + |
| | | "'" + equipage.getMode() + "'" + "," + |
| | | "'" + equipage.getDeptId() + "'" + "," + |
| | | "'" + equipage.getBrand() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd").format(equipage.getDateForProduction()) + "'" + "," + |
| | | "'" + equipage.getJurisdiction() + "'" + "," + |
| | | "'" + equipage.getUserId() + "'" + "," + |
| | | "'" +equipage.getNum() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }else { |
| | | if (status) { |
| | | //数据推送 |
| | | String s1 = |
| | | "insert into sys_equipage(id,name,number,specifications,mode,dept_id,brand,date_for_production,jurisdiction,person_in_charge,num) " + |
| | | "values(" + "'" + equipage.getId() + "'" + "," + |
| | | "'" + equipage.getName() + "'" + "," + |
| | | "'" + equipage.getNumber() + "'" + "," + |
| | | "'" + equipage.getSpecifications() + "'" + "," + |
| | | "'" + equipage.getMode() + "'" + "," + |
| | | "'" + equipage.getDeptId() + "'" + "," + |
| | | "'" + equipage.getBrand() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd").format(equipage.getDateForProduction()) + "'" + "," + |
| | | "'" + equipage.getJurisdiction() + "'" + "," + |
| | | "'" + equipage.getPersonInCharge() + "'" + "," + |
| | | "'" + equipage.getNum() + "'" + ")"; |
| | | //FtpUtil.sqlFileUpload(s1); |
| | | myAsyncService.dataSync(s1); |
| | | } |
| | | } else { |
| | | //修改 |
| | | status = equipageService.updateById(equipage); |
| | | //内网同步 |
| | | String s1 = |
| | | "update sys_equipage set name = " + "'" + equipage.getName() + "'" + |
| | | ",number = " + "'" + equipage.getDeptId() + "'" + |
| | | ",specifications = " + "'" + equipage.getSpecifications() + "'" + |
| | | ",mode = " + "'" + equipage.getMode() + "'" + |
| | | ",dept_id = " + "'" + equipage.getDeptId() + "'" + |
| | | ",brand = " + "'" + equipage.getBrand() + "'" + |
| | | ",date_for_production = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(equipage.getDateForProduction()) + "'" + |
| | | ",jurisdiction = " + "'" + equipage.getJurisdiction() + "'" + |
| | | ",user_id = " + "'" + equipage.getUserId() + "'" + |
| | | ",num = " + "'" + equipage.getNum() + "'" + |
| | | " " +"where id = " + "'" + equipage.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | if (status) { |
| | | //内网同步 |
| | | String s1 = |
| | | "update sys_equipage set name = " + "'" + equipage.getName() + "'" + |
| | | ",number = " + "'" + equipage.getDeptId() + "'" + |
| | | ",specifications = " + "'" + equipage.getSpecifications() + "'" + |
| | | ",mode = " + "'" + equipage.getMode() + "'" + |
| | | ",dept_id = " + "'" + equipage.getDeptId() + "'" + |
| | | ",brand = " + "'" + equipage.getBrand() + "'" + |
| | | ",date_for_production = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(equipage.getDateForProduction()) + "'" + |
| | | ",jurisdiction = " + "'" + equipage.getJurisdiction() + "'" + |
| | | ",num = " + "'" + equipage.getNum() + "'" + |
| | | ",person_in_charge = " + "'" + equipage.getPersonInCharge() + "'" + |
| | | " " + "where id = " + "'" + equipage.getId() + "'"; |
| | | //FtpUtil.sqlFileUpload(s1); |
| | | myAsyncService.dataSync(s1); |
| | | } |
| | | } |
| | | return R.status(status); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param ids 装备信息ids 数组 |
| | | */ |
| | | @PostMapping("/remove") |
| | | public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) { |
| | | //内网删除 |
| | | List<Long> list = Func.toLongList(ids); |
| | | list.forEach(id ->{ |
| | | list.forEach(id -> { |
| | | //内网同步 |
| | | String s1 = "delete from sys_equipage where id = " + "'" + id + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | //FtpUtil.sqlFileUpload(s1); |
| | | myAsyncService.dataSync(s1); |
| | | }); |
| | | return R.status(equipageService.removeByIds(Func.toLongList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | * |
| | | * @param equipage 装备信息对象 |
| | | */ |
| | | @GetMapping("/detail") |
| | |
| | | |
| | | /** |
| | | * 导入装备数据 |
| | | * |
| | | * @param isCovered 1 覆盖 0不覆盖 |
| | | * @return |
| | | */ |
| | |
| | | */ |
| | | @GetMapping("export-template") |
| | | @ApiOperation(value = "导出模板") |
| | | public void exportUser(HttpServletResponse response) { |
| | | public void exportEquipage(HttpServletResponse response) { |
| | | List<EquipageExcel> list = new ArrayList<>(); |
| | | EquipageExcel equipage = new EquipageExcel(); |
| | | equipage.setDeptName("***保安公司"); |
| | | equipage.setName("安全帽"); |
| | | equipage.setMode("S10"); |
| | | equipage.setNum(100); |
| | | equipage.setPersonInCharge("张三"); |
| | | equipage.setBrand("***有限公司"); |
| | | equipage.setDateForProduction("2021/05/01"); |
| | | list.add(equipage); |
| | | ExcelUtil.export(response, "装备导入数据模板", "装备导入数据表", list, EquipageExcel.class); |
| | | } |
| | | |