| | |
| | | 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.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.service.MyAsyncService; |
| | | import org.springblade.modules.workreport.entity.WorkReport; |
| | | import org.springblade.modules.workreport.service.WorkReportService; |
| | | import org.springblade.modules.workreport.vo.WorkReportVo; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.sql.Wrapper; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | |
| | | private final IUserService userService; |
| | | |
| | | private final IDeptService deptService; |
| | | private final MyAsyncService myAsyncService; |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * @param query page,size |
| | | * |
| | | * @param query page,size |
| | | * @param workReport 工作汇报信息对象 |
| | | */ |
| | | @GetMapping("/page") |
| | |
| | | |
| | | /** |
| | | * 自定义分页--接收到的汇报信息page |
| | | * @param query page,size |
| | | * |
| | | * @param query page,size |
| | | * @param workReport 工作汇报信息对象 |
| | | */ |
| | | @GetMapping("/pageReply") |
| | |
| | | |
| | | /** |
| | | * 新增 |
| | | * |
| | | * @param workReport 工作汇报信息对象 |
| | | */ |
| | | @PostMapping("/save") |
| | |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param workReport 工作汇报信息对象 |
| | | */ |
| | | @PostMapping("/update") |
| | |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * |
| | | * @param workReport 工作汇报信息对象 |
| | | */ |
| | | @PostMapping("/submit") |
| | | public R submit(@RequestBody WorkReport workReport) throws Exception { |
| | | if (null!=workReport.getId()){ |
| | | workReport.setReplyTime(new Date()); |
| | | workReport.setReplyDeptIds(getReplyDeptIds(workReport.getReceivedIds())); |
| | | }else { |
| | | public R submit(@RequestBody WorkReport workReport) { |
| | | boolean status = false; |
| | | if (null == workReport.getId()) { |
| | | workReport.setReportTime(new Date()); |
| | | workReport.setReplyDeptIds(getReplyDeptIds(workReport.getReceivedIds())); |
| | | //新增 |
| | | status = workReportService.save(workReport); |
| | | if (status) { |
| | | //数据同步 |
| | | String s1 = |
| | | "insert into sys_work_report(id,type,content,work_desc,report_time,received_ids,dept_id,reply_dept_ids,category,user_id) " + |
| | | "values(" + "'" + workReport.getId() + "'" + "," + |
| | | "'" + workReport.getType() + "'" + "," + |
| | | "'" + workReport.getContent() + "'" + "," + |
| | | "'" + workReport.getWorkDesc() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(workReport.getReportTime()) + "'" + "," + |
| | | "'" + workReport.getReceivedIds() + "'" + "," + |
| | | "'" + workReport.getDeptId() + "'" + "," + |
| | | "'" + workReport.getReplyDeptIds() + "'" + "," + |
| | | "'" + workReport.getCategory() + "'" + "," + |
| | | "'" + workReport.getUserId() + "'" + ")"; |
| | | //FtpUtil.sqlFileUpload(s1); |
| | | myAsyncService.dataSync(s1); |
| | | } |
| | | } else { |
| | | workReport.setReplyDeptIds(getReplyDeptIds(workReport.getReceivedIds())); |
| | | if (null == workReport.getReplyTime()) { |
| | | workReport.setReplyTime(new Date()); |
| | | } |
| | | |
| | | //修改 |
| | | status = workReportService.updateById(workReport); |
| | | if (status) { |
| | | //内网同步 |
| | | String s1 = |
| | | "update sys_work_report set type = " + "'" + workReport.getType() + "'" + |
| | | ",content = " + "'" + workReport.getContent() + "'" + |
| | | ",work_desc = " + "'" + workReport.getWorkDesc() + "'" + |
| | | ",received_ids = " + "'" + workReport.getReceivedIds() + "'" + |
| | | ",reply_content = " + "'" + workReport.getReplyContent() + "'" + |
| | | ",reply_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(workReport.getReplyTime()) + "'" + |
| | | ",dept_id = " + "'" + workReport.getDeptId() + "'" + |
| | | ",reply_dept_ids = " + "'" + workReport.getReplyDeptIds() + "'" + |
| | | ",category = " + "'" + workReport.getCategory() + "'" + |
| | | ",user_id = " + "'" + workReport.getUserId() + "'" + |
| | | " " + "where id = " + "'" + workReport.getId() + "'"; |
| | | //FtpUtil.sqlFileUpload(s1); |
| | | myAsyncService.dataSync(s1); |
| | | } |
| | | } |
| | | //arg.test01(arg.url+"/workReport/submit",workReport); |
| | | return R.status(workReportService.saveOrUpdate(workReport)); |
| | | return R.status(status); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param ids 工作汇报信息ids 数组 |
| | | */ |
| | | @PostMapping("/remove") |
| | | public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) { |
| | | //arg.sendPostRemoveByIds(arg.url+"/workReport/remove",ids); |
| | | //内网删除 |
| | | List<Long> list = Func.toLongList(ids); |
| | | list.forEach(id -> { |
| | | //内网同步 |
| | | String s1 = "delete from sys_work_report where id = " + "'" + id + "'"; |
| | | //FtpUtil.sqlFileUpload(s1); |
| | | myAsyncService.dataSync(s1); |
| | | }); |
| | | return R.status(workReportService.removeByIds(Func.toLongList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | * |
| | | * @param workReport 工作汇报信息对象 |
| | | */ |
| | | @GetMapping("/detail") |
| | |
| | | |
| | | /** |
| | | * 获取接收人的单位信息 |
| | | * |
| | | * @param detail 汇报详情 |
| | | * @return |
| | | */ |
| | | private String getReplyDeptName(WorkReportVo detail) { |
| | | List<String> replyDeptIds = Arrays.asList(detail.getReplyDeptIds().split(",")); |
| | | StringBuilder replyDeptNameInfo = new StringBuilder(); |
| | | for (String deptId : replyDeptIds) { |
| | | //查询接收人单位信息 |
| | | Dept deptDetail = deptService.getById(Long.parseLong(deptId)); |
| | | replyDeptNameInfo = replyDeptNameInfo.append(deptDetail.getDeptName()).append(","); |
| | | |
| | | if (null != detail.getReplyDeptIds() && detail.getReplyDeptIds() != "" && !detail.getReplyDeptIds().isEmpty()) { |
| | | List<String> replyDeptIds = Arrays.asList(detail.getReplyDeptIds().split(",")); |
| | | StringBuilder replyDeptNameInfo = new StringBuilder(); |
| | | if (replyDeptIds.size() > 0) { |
| | | for (String deptId : replyDeptIds) { |
| | | //查询接收人单位信息 |
| | | Dept deptDetail = deptService.getById(Long.parseLong(deptId)); |
| | | if (null != deptDetail) { |
| | | replyDeptNameInfo = replyDeptNameInfo.append(deptDetail.getDeptName()).append(","); |
| | | } |
| | | } |
| | | if (replyDeptNameInfo.length() > 0) { |
| | | //截取 |
| | | return replyDeptNameInfo.substring(0, replyDeptNameInfo.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //截取 |
| | | return replyDeptNameInfo.substring(0, replyDeptNameInfo.length() - 1); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取接收人的单位id(dept)信息 |
| | | * |
| | | * @param |
| | | * @return |
| | | */ |
| | |
| | | for (String userId : userIds) { |
| | | //查询接收人单位信息 |
| | | User userDetail = userService.getById(userId); |
| | | list.add(userDetail.getDeptId()); |
| | | if (null != userDetail) { |
| | | list.add(userDetail.getDeptId()); |
| | | } |
| | | } |
| | | //去重 |
| | | List<String> collect = list.stream().distinct().collect(Collectors.toList()); |
| | | //截取 |
| | | return String.join(",",collect); |
| | | return String.join(",", collect); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param detail 汇报详情 |
| | | * @return |
| | | */ |
| | | private String getReplyRealName(WorkReportVo detail){ |
| | | private String getReplyRealName(WorkReportVo detail) { |
| | | List<String> userIds = Arrays.asList(detail.getReceivedIds().split(",")); |
| | | StringBuilder replyRealNameInfo = new StringBuilder(); |
| | | for (String userId : userIds) { |
| | |
| | | // user.setCardid(idCardNo); |
| | | // User userDetail = userService.getOne(Condition.getQueryWrapper(user)); |
| | | User userDetail = userService.getById(userId); |
| | | replyRealNameInfo = replyRealNameInfo.append(userDetail.getRealName()).append(","); |
| | | if (null != userDetail) { |
| | | replyRealNameInfo = replyRealNameInfo.append(userDetail.getRealName()).append(","); |
| | | } |
| | | |
| | | } |
| | | //截取 |
| | | return replyRealNameInfo.substring(0, replyRealNameInfo.length() - 1); |
| | | if (replyRealNameInfo.toString().length() > 0) { |
| | | return replyRealNameInfo.substring(0, replyRealNameInfo.length() - 1); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |