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

212 lines
7.8 KiB
Java
Raw Normal View History

2024-03-22 09:37:32 +08:00
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("ISDELETE", 0);
//签字方式以上传图片的形式存储数据
if (SIGN_PICTURE_2 != null) {
pd.put("SIGN_PICTURE", smb.saveFile(SIGN_PICTURE_2, pd.getString("ENTERPRISE_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 = "/isdelete")
@ResponseBody
public Object isdelete() 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()));
//签字方式以上传图片的形式存储数据
if (SIGN_PICTURE_2 != null) {
pd.put("SIGN_PICTURE", smb.saveFile(SIGN_PICTURE_2, pd.getString("ENTERPRISE_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;
}
}