| | |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.dispatcher.service.IDispatcherUnitService; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IUserService; |
| | |
| | | import org.springblade.modules.dispatcher.service.IDispatcherService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | |
| | | //计算派遣人数 |
| | | // dispatcher.setNum(Arrays.asList(dispatcher.getUserIds().split(",")).size()); |
| | | //查询派遣单位的信息,设置行政区 |
| | | dispatcher.setJurisdiction(dispatcherUnitService.getById(dispatcher.getDispatcherUnitId()).getJurisdiction().toString()); |
| | | } |
| | | return R.status(dispatcherService.save(dispatcher)); |
| | | } |
| | |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入dispatcher") |
| | | public R submit(@Valid @RequestBody Dispatcher dispatcher) { |
| | | if (dispatcher.getId()==null){ |
| | | if (null!=dispatcher.getUserIds() && dispatcher.getUserIds()!=""){ |
| | | // List<String> list = Arrays.asList(dispatcher.getUserIds().split(",")); |
| | | // //计算派遣人数 |
| | | //计算派遣人数 |
| | | // dispatcher.setNum(list.size()); |
| | | //修改保安人员的派遣状态 |
| | | if (dispatcher.getId()==null){ |
| | | User user = new User(); |
| | | user.setId(Long.parseLong(dispatcher.getUserIds())); |
| | | user.setDispatch("0"); |
| | | userService.updateById(user); |
| | | //查询派遣单位的信息,设置行政区 |
| | | dispatcher.setJurisdiction(dispatcherUnitService.getById(dispatcher.getDispatcherUnitId()).getJurisdiction().toString()); |
| | | } |
| | | String s1 = |
| | | "update blade_user set dispatch = " + "'" + user.getDispatch() + "'" + |
| | | " " +"where id = " + "'" + user.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | } |
| | | else { |
| | | if (null != dispatcher.getUserIds() && dispatcher.getUserIds() != "") { |
| | | // List<String> list = Arrays.asList(dispatcher.getUserIds().split(",")); |
| | | //计算派遣人数 |
| | | // dispatcher.setNum(list.size()); |
| | | //查询当前派遣记录 |
| | | Dispatcher dispatcher1 = dispatcherService.getById(dispatcher.getId()); |
| | | if (!dispatcher1.getUserIds().equals(dispatcher.getUserIds())){ |
| | |
| | | user1.setId(Long.parseLong(dispatcher.getUserIds())); |
| | | user1.setDispatch("0"); |
| | | userService.updateById(user1); |
| | | } |
| | | //查询派遣单位的信息,设置行政区 |
| | | dispatcher.setJurisdiction(dispatcherUnitService.getById(dispatcher.getDispatcherUnitId()).getJurisdiction().toString()); |
| | | |
| | | String s1 = |
| | | "update blade_user set dispatch = " + "'" + user.getDispatch() + "'" + |
| | | " " +"where id = " + "'" + user.getId() + "';"+ |
| | | "update blade_user set dispatch = " + "'" + user1.getDispatch() + "'" + |
| | | " " +"where id = " + "'" + user1.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | } |
| | | } |
| | | return R.status(dispatcherService.saveOrUpdate(dispatcher)); |
| | |
| | | @ApiOperation(value = "删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | //内网删除 |
| | | //arg.sendPostRemoveByIds(arg.url+"/dispatcher/remove",ids); |
| | | List<Long> list = Func.toLongList(ids); |
| | | list.forEach(id ->{ |
| | | //内网同步 |
| | | String s1 = "delete from sys_dispatcher where id = " + "'" + id + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }); |
| | | return R.status(dispatcherService.removeByIds(Func.toLongList(ids))); |
| | | } |
| | | |