integrated_traffic/src/main/java/com/zcloud/controller/eduStudy/TrainedUserSignController.java

213 lines
7.9 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.zcloud.controller.eduStudy;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.service.eduSystem.UserSignService;
import com.zcloud.util.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 说明:被培训企业用户签字信息
* 作者yangming
* 时间2023-01-30
* 官网www.zcloudchina.com
*/
@Controller
@RequestMapping("/trainedusersign")
public class TrainedUserSignController extends BaseController {
@Autowired
private UserSignService userSignService;
@Autowired
private Smb smb;
/**
* 被培训企业用户签字新增
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/save")
@ResponseBody
public Object save(@RequestParam(value = "SIGN_PICTURE_2", required = false) MultipartFile SIGN_PICTURE_2) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
//
// //判断是否是同一签字人员类型(同一机构,同一企业下)
// List<PageData> hasusersigntype = userSignService.findByUsersigntype(pd);
// if (hasusersigntype.size() > 0) {
// map.put("result", errInfo);
// map.put("message", "该签字人员类型已存在,请检查数据。");
// return map;
// }
pd.put("USERSIGNID", this.get32UUID());
pd.put("CREATOR", Jurisdiction.getUsername()); //添加人
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
pd.put("ISDELETE", 0);
//签字方式以上传图片的形式存储数据
if (SIGN_PICTURE_2 != null) {
pd.put("SIGN_PICTURE", smb.saveFile(SIGN_PICTURE_2, pd.getString("CORPINFO_ID")));
} else {
//签字方式以签字的形式存储数据
if (Tools.notEmpty(pd.getString("SIGN_PICTURE"))) {
if (StringUtils.isNotBlank(pd.getString("SIGN_PICTURE"))) {
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart(pd.getString("SIGN_PICTURE")); //base64转文件
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
pd.put("SIGN_PICTURE", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
}
}
}
userSignService.add(pd); //列表
map.put("result", errInfo);
return map;
}
/**
* 用户签字列表
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/list")
@ResponseBody
public Object list(Page page) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
pd.put("OPERATOR", ""); //修改人
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
page.setPd(pd);
List<PageData> varList = userSignService.signlistPage(page); //列表
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**
* 删除
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/delete")
@ResponseBody
public Object delete() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
userSignService.deleteUserSign(pd); //列表
map.put("result", errInfo);
return map;
}
/**
* 删除
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/goEdit")
@ResponseBody
public Object goEdit() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
PageData pageData = userSignService.findById(pd); //列表
map.put("varList", pageData);
map.put("result", errInfo);
return map;
}
/**
* 获取档案签字列表
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/listByEnt")
@ResponseBody
public Object listByEnt() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
List<PageData> varList = userSignService.listByEnt(pd); //列表
map.put("varList", varList);
map.put("result", errInfo);
return map;
}
/**
* 删除
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/edit")
@ResponseBody
public Object edit(@RequestParam(value = "SIGN_PICTURE_2", required = false) MultipartFile SIGN_PICTURE_2) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
// //判断是否是同一签字人员类型(同一机构,同一企业下)
// List<PageData> hasusersigntype = userSignService.findByUsersigntype(pd);
// if (hasusersigntype.size() > 0) {
// map.put("result", errInfo);
// map.put("message", "该签字人员类型已存在,请检查数据。");
// return map;
// }
pd.put("OPERATOR", Jurisdiction.getUsername());
pd.put("OPERATTIME", DateUtil.date2Str(new Date()));
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
//签字方式以上传图片的形式存储数据
if (SIGN_PICTURE_2 != null) {
pd.put("SIGN_PICTURE", smb.saveFile(SIGN_PICTURE_2, pd.getString("CORPINFO_ID")));
} else {
//签字方式以签字的形式存储数据
if (Tools.notEmpty(pd.getString("SIGN_PICTURE")) && pd.getString("SIGN_PICTURE").contains("data:image/png;base64,")) {
if (StringUtils.isNotBlank(pd.getString("SIGN_PICTURE"))) {
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart(pd.getString("SIGN_PICTURE")); //base64转文件
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
pd.put("SIGN_PICTURE", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
}
}
}
userSignService.edit(pd); //列表
map.put("result", errInfo);
return map;
}
}