| | |
| | | */ |
| | | package org.springblade.modules.experience.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.Api; |
| | |
| | | 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.experience.entity.Experience; |
| | | import org.springblade.modules.experience.service.IExperienceService; |
| | | import org.springblade.modules.experience.vo.ExperienceVO; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.service.MyAsyncService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 控制器 |
| | | * 用户从业控制器 |
| | | * |
| | | * @author BladeX |
| | | * @since 2021-07-08 |
| | |
| | | public class ExperienceController extends BladeController { |
| | | |
| | | private final IExperienceService experienceService; |
| | | |
| | | |
| | | private final IUserService userService; |
| | | private final MyAsyncService myAsyncService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | return R.status(experienceService.save(experience)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | */ |
| | | @PostMapping("/saveOrUpdate") |
| | | public R save(@Valid @RequestBody Map<String,Object> experience ) { |
| | | if (experience.size()>0) { |
| | | String securityid = experience.get("securityid").toString(); |
| | | //先删除原有的从业信息 |
| | | experienceService.delbyCardId(securityid); |
| | | //重新新增从业信息 |
| | | List<Experience> experiences = (List<Experience>) experience.get("userPractitionersInfo"); |
| | | int count = 0; |
| | | if (experiences.size() > 0) { |
| | | for (int i = 0; i < experiences.size(); i++) { |
| | | Experience e = JSON.parseObject(JSON.toJSONString(experiences.get(i)), Experience.class); |
| | | experienceService.save(e); |
| | | count++; |
| | | } |
| | | if (count < 1) { |
| | | return R.status(false); |
| | | } |
| | | } |
| | | } |
| | | return R.status(true); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | */ |
| | |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入experience") |
| | | public R submit(@Valid @RequestBody Experience experience) { |
| | | return R.status(experienceService.saveOrUpdate(experience)); |
| | | boolean status = false; |
| | | if (null!=experience.getId()){ |
| | | //更新 |
| | | status = experienceService.updateById(experience); |
| | | |
| | | String s1 = |
| | | "update sys_experience set name = " + "'" + experience.getName() + "'" |
| | | + ",post = " + "'" + experience.getPost() + "'" |
| | | + ",department = " + "'" + experience.getDepartment() + "'" |
| | | + ",responsibilities = " + "'" + experience.getResponsibilities() + "'" |
| | | + ",entryTime = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getEntrytime()) + "'" |
| | | + ",departureTime = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getDeparturetime()) + "'" |
| | | + ",leaving = " + "'" + experience.getLeaving() + "'" |
| | | + ",cardId = " + "'" + experience.getCardid() + "'" |
| | | + ",companyname = " + "'" + experience.getCompanyname() + "'" |
| | | + ",securityId = " + "'" + experience.getSecurityid() + "'" |
| | | + " " + "where id = " + "'" + experience.getId() + "'"; |
| | | //FtpUtil.sqlFileUpload(s1); |
| | | myAsyncService.dataSync(s1); |
| | | |
| | | }else { |
| | | //新增 |
| | | //查询用户身份证号 |
| | | User user = userService.getById(experience.getSecurityid()); |
| | | experience.setCardid(user.getCardid()); |
| | | experience.setName(user.getRealName()); |
| | | status = experienceService.save(experience); |
| | | |
| | | //内网同步 |
| | | String s = "insert into sys_experience(id,name,post,department,responsibilities,entryTime,departureTime,leaving," + |
| | | "cardId,companyname,securityId) " + |
| | | "values(" + "'" + experience.getId() + "'" + |
| | | "," + "'" + experience.getName() + "'" + |
| | | "," + "'" + experience.getPost() + "'" + |
| | | "," + "'" + experience.getDepartment() + "'" + |
| | | "," + "'" + experience.getResponsibilities() + "'" + |
| | | "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getEntrytime()) + "'" + |
| | | "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getDeparturetime()) + "'" + |
| | | "," + "'" + experience.getLeaving() + "'" + |
| | | "," + "'" + experience.getCardid() + "'" + |
| | | "," + "'" + experience.getCompanyname() + "'" + |
| | | "," + "'" + experience.getSecurityid() + "'" |
| | | + ")"; |
| | | //FtpUtil.sqlFileUpload(s); |
| | | myAsyncService.dataSync(s); |
| | | } |
| | | return R.status(status); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * 保安就业记录 |
| | | * @param cardid 身份证 |
| | | * @param securityid 身份证 |
| | | * @return |
| | | */ |
| | | @PostMapping("/selectExperienceInfo") |
| | | public R selectExperienceInfo(String cardid) { |
| | | return R.data(experienceService.selectExperienceInfo(cardid)); |
| | | @GetMapping("/selectExperienceInfo") |
| | | public R selectExperienceInfo(String securityid) { |
| | | return R.data(experienceService.selectExperienceInfo(securityid)); |
| | | } |
| | | |
| | | |