TStaffmgrController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. package com.ruoyi.project.plant.controller;
  2. import java.io.IOException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.*;
  5. import com.alibaba.fastjson.JSON;
  6. import com.ruoyi.common.utils.DateUtils;
  7. import com.ruoyi.common.utils.ServletUtils;
  8. import com.ruoyi.common.utils.file.ExcelUtils;
  9. import com.ruoyi.common.utils.file.FileUploadUtils;
  10. import com.ruoyi.framework.config.RuoYiConfig;
  11. import com.ruoyi.project.common.domain.DataEntity;
  12. import com.ruoyi.project.plant.mapper.TStaffmgrMapper;
  13. import com.ruoyi.project.system.domain.SysDept;
  14. import com.ruoyi.project.system.domain.SysDictData;
  15. import com.ruoyi.project.system.service.ISysDeptService;
  16. import com.ruoyi.project.system.service.ISysDictTypeService;
  17. import com.ruoyi.project.system.service.ITAlarmPrincipalService;
  18. import com.ruoyi.project.training.domain.*;
  19. import com.ruoyi.project.training.service.*;
  20. import org.apache.commons.lang.StringUtils;
  21. import org.apache.poi.ss.usermodel.*;
  22. import org.springframework.security.access.prepost.PreAuthorize;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.web.bind.annotation.*;
  25. import com.ruoyi.framework.aspectj.lang.annotation.Log;
  26. import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
  27. import com.ruoyi.project.plant.domain.TStaffmgr;
  28. import com.ruoyi.project.plant.service.ITStaffmgrService;
  29. import com.ruoyi.framework.web.controller.BaseController;
  30. import com.ruoyi.framework.web.domain.AjaxResult;
  31. import com.ruoyi.common.utils.poi.ExcelUtil;
  32. import com.ruoyi.framework.web.page.TableDataInfo;
  33. import org.springframework.web.multipart.MultipartFile;
  34. import javax.annotation.Resource;
  35. /**
  36. * 人员管理Controller
  37. *
  38. * @author ruoyi
  39. * @date 2020-11-25
  40. */
  41. @RestController
  42. @RequestMapping("/plant/staffmgr")
  43. public class TStaffmgrController extends BaseController
  44. {
  45. @Autowired
  46. private ITStaffmgrService tStaffmgrService;
  47. @Autowired
  48. private ISysDeptService iSysDeptService;
  49. @Autowired
  50. private ISysDictTypeService iSysDictTypeService;
  51. @Resource
  52. private TStaffmgrMapper tStaffmgrMapper;
  53. @Autowired
  54. private ITTrainingrecordsService tTrainingrecordsService;
  55. @Autowired
  56. private ITTrainingParticipantsService tTrainingParticipantsService;
  57. @Autowired
  58. private ITWorklicenseService tWorklicenseService;
  59. @Autowired
  60. private ITTrainingRegularService tTrainingRegularService;
  61. @Autowired
  62. private ITTrainingDeviceService tTrainingDeviceService;
  63. @Autowired
  64. private ITTrainingService tTrainingService;
  65. /**
  66. * 查询人员管理列表
  67. */
  68. @PreAuthorize("@ss.hasPermi('plant:staffmgr:list')")
  69. @GetMapping("/list")
  70. public TableDataInfo list(TStaffmgr tStaffmgr)
  71. {
  72. ServletUtils.getParameter("sexs");
  73. startPage();
  74. List<TStaffmgr> list = tStaffmgrService.selectTStaffmgrList(tStaffmgr);
  75. return getDataTable(list);
  76. }
  77. /**
  78. * 查询人员公司级培训时间列表
  79. */
  80. @PreAuthorize("@ss.hasPermi('plant:staffmgr:list')")
  81. @GetMapping("/selectTime")
  82. public TableDataInfo selectTime(TStaffmgr tStaffmgr)
  83. {
  84. ServletUtils.getParameter("sexs");
  85. startPage();
  86. List<TStaffmgr> list = tStaffmgrService.selectRecordList(tStaffmgr);
  87. List<TTrainingParticipants> tTrainingParticipants = tTrainingParticipantsService.selectTTrainingParticipantsList(new TTrainingParticipants());
  88. SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
  89. for (int i = 0; i < list.size(); i++) {
  90. double time = 0;
  91. for (TTrainingParticipants t : tTrainingParticipants) {
  92. if (t.getStaffId().equals(list.get(i).getStaffid())) {
  93. if (t.getStartDate() != null) {
  94. if (sdf.format(t.getStartDate()).equals(sdf.format(new Date()))) {
  95. if (t.getTrainingDuration() != null) {
  96. time = time + Double.parseDouble(t.getTrainingDuration());
  97. }
  98. }
  99. }
  100. }
  101. }
  102. list.get(i).setTrainingTime(String.valueOf(time));
  103. }
  104. return getDataTable(list);
  105. }
  106. /**
  107. * 查询人员管理列表
  108. * @return
  109. */
  110. @PreAuthorize("@ss.hasPermi('plant:staffmgr:list')")
  111. @GetMapping("/ogzList")
  112. public List<TStaffmgr> ogzList(TStaffmgr tStaffmgr)
  113. {
  114. List<TStaffmgr> list = tStaffmgrService.selectTStaffmgrList(tStaffmgr);
  115. return list;
  116. }
  117. /**
  118. * 上级领导字段查询人员管理列表
  119. */
  120. @PreAuthorize("@ss.hasPermi('plant:staffmgr:list')")
  121. @GetMapping("/pIdList")
  122. public AjaxResult pIdList(TStaffmgr tStaffmgr)
  123. {
  124. List<TStaffmgr> list = tStaffmgrService.selectTStaffmgrList(tStaffmgr);
  125. return AjaxResult.success(list);
  126. }
  127. /**
  128. * 查询离职人员管理列表
  129. */
  130. @PreAuthorize("@ss.hasPermi('plant:staffmgr:list')")
  131. @GetMapping("/leftList")
  132. public List<TStaffmgr> leftList(TStaffmgr tStaffmgr)
  133. {
  134. List<TStaffmgr> list = tStaffmgrService.selectLeftTStaffmgrList(tStaffmgr);
  135. return list;
  136. }
  137. //学历统计
  138. @GetMapping("/eduData")
  139. public List<DataEntity> eduData(Map param)
  140. {
  141. param.put("params" , new HashMap<>());
  142. Map<String,Object> data = new HashMap();
  143. List<DataEntity> list = tStaffmgrMapper.selectEduData(param);
  144. List<SysDictData> education = iSysDictTypeService.selectDictDataByType("EDUCATION");
  145. for (DataEntity d: list
  146. ) {
  147. for (SysDictData s: education
  148. ) {
  149. if (StringUtils.isBlank(d.getDataName())){
  150. d.setDataName("未知");
  151. break;
  152. }
  153. if (s.getDictValue().equals(d.getDataName())){
  154. d.setDataName(s.getDictLabel());
  155. break;
  156. }
  157. }
  158. }
  159. return list;
  160. }
  161. //英语统计
  162. @GetMapping("/engData")
  163. public List<DataEntity> engData(Map param)
  164. {
  165. param.put("params" , new HashMap<>());
  166. List<DataEntity> list = tStaffmgrMapper.selectEngData(param);
  167. List<SysDictData> englishability = iSysDictTypeService.selectDictDataByType("ENGLISHABILITY");
  168. for (DataEntity d: list
  169. ) {
  170. for (SysDictData s: englishability
  171. ) {
  172. if (StringUtils.isBlank(d.getDataName())){
  173. d.setDataName("未知");
  174. break;
  175. }
  176. if (s.getDictValue().equals(d.getDataName())){
  177. d.setDataName(s.getDictLabel());
  178. break;
  179. }
  180. }
  181. }
  182. return list;
  183. }
  184. //班值统计
  185. @GetMapping("/teamData")
  186. public List<DataEntity> teamData(Map param)
  187. {
  188. param.put("params" , new HashMap<>());
  189. List<DataEntity> list = tStaffmgrMapper.selectTeamData(param);
  190. List<SysDictData> englishability = iSysDictTypeService.selectDictDataByType("TEAM_DIVIDE");
  191. for (DataEntity d: list
  192. ) {
  193. for (SysDictData s: englishability
  194. ) {
  195. if (StringUtils.isBlank(d.getDataName())){
  196. d.setDataName("未知");
  197. break;
  198. }
  199. if (s.getDictValue().equals(d.getDataName())){
  200. d.setDataName(s.getDictLabel());
  201. break;
  202. }
  203. }
  204. }
  205. return list;
  206. }
  207. /**
  208. * 导出人员管理列表
  209. */
  210. @PreAuthorize("@ss.hasPermi('plant:staffmgr:export')")
  211. @Log(title = "人员管理", businessType = BusinessType.EXPORT)
  212. @GetMapping("/export")
  213. public AjaxResult export(TStaffmgr tStaffmgr)
  214. {
  215. List<TStaffmgr> list = tStaffmgrService.selectTStaffmgrList(tStaffmgr);
  216. ExcelUtil<TStaffmgr> util = new ExcelUtil<TStaffmgr>(TStaffmgr.class);
  217. return util.exportExcel(list, "staffmgr");
  218. }
  219. /**
  220. * 获取人员管理详细信息
  221. */
  222. @PreAuthorize("@ss.hasPermi('plant:staffmgr:query')")
  223. @GetMapping(value = "/{id}")
  224. public AjaxResult getInfo(@PathVariable("id") Long id)
  225. {
  226. TStaffmgr staffmgr = tStaffmgrService.selectTStaffmgrById(id);
  227. return AjaxResult.success(staffmgr);
  228. }
  229. /**
  230. * 为参培人员名单获取人员管理详细信息
  231. */
  232. @PreAuthorize("@ss.hasPermi('plant:staffmgr:query')")
  233. @GetMapping("/byStaffId/{staffIds}")
  234. public AjaxResult byStaffId(@PathVariable String[] staffIds)
  235. {
  236. List<TStaffmgr> staffmgrs = new ArrayList<TStaffmgr>();
  237. for (int i = 0; i <staffIds.length ; i++) {
  238. TStaffmgr staffmgr = tStaffmgrService.selectTStaffmgrByStaffId(staffIds[i]);
  239. staffmgrs.add(staffmgr);
  240. }
  241. return AjaxResult.success(staffmgrs);
  242. }
  243. /**
  244. * 新增人员管理
  245. */
  246. @PreAuthorize("@ss.hasPermi('plant:staffmgr:add')")
  247. @Log(title = "人员管理", businessType = BusinessType.INSERT)
  248. @PostMapping
  249. public AjaxResult add(@RequestBody TStaffmgr tStaffmgr)
  250. {
  251. int insertResult = tStaffmgrService.insertTStaffmgr(tStaffmgr);
  252. tStaffmgr.setCreaterCode(getUserId().toString());
  253. if (tStaffmgr.getUnit().equals("10") || tStaffmgr.getUnit().equals("18")) {
  254. TTrainingrecords tTrainingrecords = new TTrainingrecords();
  255. tTrainingrecords.setStaffId(tStaffmgr.getId());
  256. tTrainingrecords.setPlantCode(tStaffmgr.getPlantCode());
  257. tTrainingrecords.setName(tStaffmgr.getName());
  258. tTrainingrecords.setEmployeeid(tStaffmgr.getStaffid());
  259. tTrainingrecords.setClasses(tStaffmgr.getTeam());
  260. tTrainingrecords.setDeptId(tStaffmgr.getDeptId());
  261. tTrainingrecordsService.insertTTrainingrecords(tTrainingrecords);
  262. }
  263. if (!tStaffmgr.getTeam().equals("18")) {
  264. TWorklicense tWorklicense = new TWorklicense();
  265. tWorklicense.setPlantCode(tStaffmgr.getPlantCode());
  266. tWorklicense.setClasses(tStaffmgr.getTeam());
  267. tWorklicense.setName(tStaffmgr.getName());
  268. tWorklicense.setEmployeeid(tStaffmgr.getStaffid());
  269. tWorklicense.setPost(tStaffmgr.getActualpost());
  270. tWorklicense.setDeptId(tStaffmgr.getDeptId());
  271. tWorklicenseService.insertTWorklicense(tWorklicense);
  272. }
  273. if (tStaffmgr.getUnit().equals("10")) {
  274. SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
  275. TTrainingRegular regular = new TTrainingRegular();
  276. regular.setYear(sdfYear.format(new Date()));
  277. List<TTrainingRegular> tTrainingRegulars = tTrainingRegularService.selectTTrainingRegularList(regular);
  278. for (TTrainingRegular r : tTrainingRegulars) {
  279. if (r.getNotPlan().equals("true")) {
  280. String[] posts = r.getActualpostId().split(",");
  281. for (String post : posts) {
  282. if (post.equals(tStaffmgr.getActualpost())) {
  283. TTraining training = tTrainingService.selectTTrainingByRegularId(r.getId());
  284. if (training.getStartDate() == null) {
  285. TTrainingDevice tTrainingDevice = new TTrainingDevice();
  286. tTrainingDevice.setStaffId(tStaffmgr.getStaffid());
  287. tTrainingDevice.setRegularId(training.getId());
  288. tTrainingDevice.setStartDate(r.getPlanTrainingdate());
  289. tTrainingDevice.setSupplementary("0");
  290. tTrainingDeviceService.insertTTrainingDevice(tTrainingDevice);
  291. } else {
  292. TTrainingDevice tTrainingDevice = new TTrainingDevice();
  293. tTrainingDevice.setStaffId(tStaffmgr.getStaffid());
  294. tTrainingDevice.setRegularId(training.getId());
  295. tTrainingDevice.setSupplementary("2");
  296. tTrainingDeviceService.insertTTrainingDevice(tTrainingDevice);
  297. }
  298. }
  299. }
  300. }
  301. }
  302. }
  303. return toAjax(insertResult);
  304. }
  305. /**
  306. * 修改人员管理
  307. */
  308. @PreAuthorize("@ss.hasPermi('plant:staffmgr:edit')")
  309. @Log(title = "人员管理", businessType = BusinessType.UPDATE)
  310. @PutMapping
  311. public AjaxResult edit(@RequestBody TStaffmgr tStaffmgr)
  312. {
  313. tStaffmgr.setPhoto(null);
  314. tStaffmgr.setUpdaterCode(getUserId().toString());
  315. tStaffmgr.setUpdatedate(new Date());
  316. TStaffmgr oldStaffmgr = tStaffmgrService.selectTStaffmgrById(tStaffmgr.getId());
  317. if (tStaffmgr.getUnit().equals("10") || tStaffmgr.getUnit().equals("18")) {
  318. //部门为CBP/C或CBP的人员
  319. TTrainingrecords tTrainingrecords = tTrainingrecordsService.selectTTrainingrecordsBystaffId(tStaffmgr.getId());
  320. tTrainingrecords.setPlantCode(tStaffmgr.getPlantCode());
  321. tTrainingrecords.setName(tStaffmgr.getName());
  322. tTrainingrecords.setEmployeeid(tStaffmgr.getStaffid());
  323. tTrainingrecords.setClasses(tStaffmgr.getTeam());
  324. tTrainingrecords.setDeptId(tStaffmgr.getDeptId());
  325. tTrainingrecordsService.updateTTrainingrecords(tTrainingrecords);
  326. }
  327. if (!tStaffmgr.getTeam().equals("18")) {
  328. //非W班组人员
  329. TWorklicense tWorklicense = tWorklicenseService.selectTWorklicenseByEmployeeid(tStaffmgr.getStaffid());
  330. tWorklicense.setPlantCode(tStaffmgr.getPlantCode());
  331. tWorklicense.setClasses(tStaffmgr.getTeam());
  332. tWorklicense.setName(tStaffmgr.getName());
  333. tWorklicense.setEmployeeid(tStaffmgr.getStaffid());
  334. tWorklicense.setPost(tStaffmgr.getActualpost());
  335. tWorklicense.setDeptId(tStaffmgr.getDeptId());
  336. tWorklicenseService.updateTWorklicense(tWorklicense);
  337. }
  338. return toAjax(tStaffmgrService.updateTStaffmgr(tStaffmgr));
  339. }
  340. /**
  341. * 删除人员管理
  342. */
  343. @PreAuthorize("@ss.hasPermi('plant:staffmgr:remove')")
  344. @Log(title = "人员管理", businessType = BusinessType.DELETE)
  345. @DeleteMapping("/{ids}")
  346. public AjaxResult remove(@PathVariable Long[] ids)
  347. {
  348. for (int i = 0; i <ids.length ; i++) {
  349. TTrainingrecords tTrainingrecords = tTrainingrecordsService.selectTTrainingrecordsBystaffId(ids[i]);
  350. if (tTrainingrecords!= null) {
  351. tTrainingrecords.setDelFlag(2l);
  352. tTrainingrecordsService.updateTTrainingrecords(tTrainingrecords);
  353. }
  354. }
  355. return toAjax(tStaffmgrService.deleteTStaffmgrByIds(ids));
  356. }
  357. /**
  358. * 删除离职人员
  359. */
  360. @PreAuthorize("@ss.hasPermi('plant:staffmgr:remove')")
  361. @Log(title = "人员管理", businessType = BusinessType.DELETE)
  362. @GetMapping("/left/{id}")
  363. public AjaxResult removeLeft(@PathVariable Long id)
  364. {
  365. TTrainingrecords tTrainingrecords = tTrainingrecordsService.selectTTrainingrecordsBystaffId(id);
  366. if (tTrainingrecords!= null) {
  367. tTrainingrecords.setDelFlag(9l);
  368. tTrainingrecordsService.updateTTrainingrecords(tTrainingrecords);
  369. }
  370. return toAjax(tStaffmgrService.deleteLeftTStaffmgrByIds(id));
  371. }
  372. /**
  373. * 复职离职人员
  374. */
  375. @PreAuthorize("@ss.hasPermi('plant:staffmgr:remove')")
  376. @Log(title = "人员管理", businessType = BusinessType.DELETE)
  377. @GetMapping("/reLeft/{id}")
  378. public AjaxResult reLeft(@PathVariable Long id)
  379. {
  380. TTrainingrecords tTrainingrecords = tTrainingrecordsService.selectTTrainingrecordsBystaffId(id);
  381. tTrainingrecords.setDelFlag(0l);
  382. tTrainingrecordsService.updateTTrainingrecords(tTrainingrecords);
  383. return toAjax(tStaffmgrService.reLeftTStaffmgrByIds(id));
  384. }
  385. /**
  386. * 批量导入人员管理
  387. */
  388. @PreAuthorize("@ss.hasPermi('plant:staffmgr:add')")
  389. @Log(title = "人员管理", businessType = BusinessType.INSERT)
  390. @PostMapping("/importData")
  391. public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException
  392. {
  393. //获取操作人员ID
  394. Long userId = getUserId();
  395. //报错行数统计
  396. List<Integer> failRow =new ArrayList<Integer>();
  397. Workbook workbook = ExcelUtils.getWorkBook(file);
  398. Sheet sheet = workbook.getSheetAt(0);
  399. List<TStaffmgr> list = new ArrayList<TStaffmgr>();
  400. //字典查询
  401. List<SysDictData> plant = iSysDictTypeService.selectDictDataByType("PLANT_DIVIDE");
  402. List<SysDictData> sex = iSysDictTypeService.selectDictDataByType("sys_user_sex");
  403. List<SysDictData> staff = iSysDictTypeService.selectDictDataByType("STAFF_UNIT");
  404. List<SysDictData> team = iSysDictTypeService.selectDictDataByType("TEAM_DIVIDE");
  405. List<SysDictData> actualpost = iSysDictTypeService.selectDictDataByType("ACTUALPOST");
  406. List<SysDictData> education = iSysDictTypeService.selectDictDataByType("EDUCATION");
  407. List<SysDictData> enAbility = iSysDictTypeService.selectDictDataByType("ENGLISHABILITY");
  408. //部门查询
  409. List<SysDept> dept = iSysDeptService.selectDeptList(new SysDept());
  410. int rowNum = sheet.getPhysicalNumberOfRows();
  411. int failNumber = 0;
  412. for (int i = 1; i < rowNum; i++) {
  413. try {
  414. logger.info("读取行数:" + i);
  415. Row row = sheet.getRow(i);
  416. int cellNum = row.getPhysicalNumberOfCells();
  417. TStaffmgr entity = new TStaffmgr();
  418. for (int j = 0; j < cellNum; j++) {
  419. Cell cell = row.getCell(j);
  420. cell.setCellType(CellType.STRING);
  421. String cellValue = ExcelUtils.getCellValue(cell);
  422. logger.info("cellValue:" + cellValue);
  423. if (j == 0) {
  424. for (SysDictData p : plant) {
  425. if (p.getDictLabel().equals(cellValue)) {
  426. entity.setPlantCode(p.getDictValue());//装置名称
  427. }
  428. }
  429. } else if (j == 1) {
  430. entity.setStaffid(cellValue);//员工编号
  431. } else if (j == 2) {
  432. entity.setName(cellValue);//员工姓名
  433. } else if (j == 3) {
  434. for (SysDictData p : sex) {
  435. if (p.getDictLabel().equals(cellValue)) {
  436. entity.setSex(p.getDictValue());//性别
  437. }
  438. }
  439. } else if (j == 4) {
  440. if (cellValue.length() > 3) {
  441. entity.setBirthday(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));//出生日期
  442. }
  443. } else if (j == 5) {
  444. for (SysDictData p : staff) {
  445. if (p.getDictLabel().equals(cellValue)) {
  446. entity.setUnit(p.getDictValue());//部门
  447. }
  448. }
  449. } else if (j == 6) {
  450. for (SysDictData p : team) {
  451. if (p.getDictLabel().equals(cellValue.trim())) {
  452. entity.setTeam(p.getDictValue());//班值
  453. }
  454. }
  455. } else if (j == 7) {
  456. for (SysDictData p : actualpost) {
  457. if (p.getDictLabel().equals(cellValue)) {
  458. entity.setActualpost(p.getDictValue());//实际岗位
  459. }
  460. }
  461. } else if (j == 8) {
  462. entity.setContact(cellValue);//联系方式
  463. } else if (j == 9) {
  464. for (SysDictData p : education) {
  465. if (p.getDictLabel().equals(cellValue)) {
  466. entity.setEducation(p.getDictValue());//学历
  467. }
  468. }
  469. } else if (j == 10) {
  470. for (SysDictData p : enAbility) {
  471. if (p.getDictLabel().equals(cellValue)) {
  472. entity.setEnAbility(p.getDictValue());//英语能力
  473. }
  474. }
  475. } else if (j == 11) {
  476. entity.setMail(cellValue);//邮箱
  477. } else if (j == 12) {
  478. for (SysDept d : dept) {
  479. if (d.getDeptName().equals(cellValue)) {
  480. entity.setDeptId(d.getDeptId());//部门编号
  481. }
  482. }
  483. } else if (j == 13) {
  484. entity.setRemarks(cellValue);//备注
  485. }
  486. }
  487. entity.setCreaterCode(userId.toString());
  488. logger.info("entity:" + entity);
  489. list.add(entity);
  490. }catch (Exception e){
  491. failNumber++;
  492. logger.info("e:" + e);
  493. failRow.add(i + 1);
  494. }
  495. }
  496. int successNumber = 0;
  497. int failNum = 0;
  498. for (TStaffmgr t : list
  499. ) {
  500. failNum++;
  501. try {
  502. tStaffmgrService.insertTStaffmgr(t);
  503. if (t.getUnit().equals("10") || t.getUnit().equals("18")) {
  504. TTrainingrecords tTrainingrecords = new TTrainingrecords();
  505. tTrainingrecords.setStaffId(t.getId());
  506. tTrainingrecords.setPlantCode(t.getPlantCode());
  507. tTrainingrecords.setName(t.getName());
  508. tTrainingrecords.setEmployeeid(t.getStaffid());
  509. tTrainingrecords.setClasses(t.getTeam());
  510. tTrainingrecords.setDeptId(t.getDeptId());
  511. tTrainingrecordsService.insertTTrainingrecords(tTrainingrecords);
  512. }
  513. if (!t.getTeam().equals("18")) {
  514. TWorklicense tWorklicense = new TWorklicense();
  515. tWorklicense.setPlantCode(t.getPlantCode());
  516. tWorklicense.setClasses(t.getTeam());
  517. tWorklicense.setName(t.getName());
  518. tWorklicense.setEmployeeid(t.getStaffid());
  519. tWorklicense.setPost(t.getActualpost());
  520. tWorklicense.setDeptId(t.getDeptId());
  521. tWorklicenseService.insertTWorklicense(tWorklicense);
  522. }
  523. successNumber++;
  524. }catch (Exception e){
  525. failNumber++;
  526. logger.info("e:" + e);
  527. failRow.add(failNum + 1);
  528. }
  529. }
  530. logger.info("list:" + JSON.toJSONString(list));
  531. logger.info("successNumber:" +String.valueOf(successNumber));
  532. logger.info("failNumber:" +String.valueOf(failNumber));
  533. logger.info("failRow:" +String.valueOf(failRow));
  534. return AjaxResult.success(String.valueOf(successNumber), failRow);
  535. }
  536. /**
  537. * 证件照上传
  538. */
  539. @PostMapping("/uploadPhoto")
  540. public AjaxResult uploadFile(@RequestParam("file") MultipartFile file,String pType,String pId) throws IOException
  541. {
  542. if (!file.isEmpty())
  543. {
  544. String url = FileUploadUtils.upload(RuoYiConfig.getFilePath("/"+ pType), file);
  545. TStaffmgr staffmgr = tStaffmgrService.selectTStaffmgrById(Long.parseLong(pId));
  546. staffmgr.setPhoto(url);
  547. tStaffmgrService.updateTStaffmgr(staffmgr);
  548. return AjaxResult.success();
  549. }
  550. return AjaxResult.error("上传失败,请联系管理员");
  551. }
  552. }