831 lines
35 KiB
Java
831 lines
35 KiB
Java
package com.rzyc.controller;
|
||
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.common.utils.DateUtils;
|
||
import com.common.utils.RandomNumber;
|
||
import com.common.utils.StringUtils;
|
||
import com.common.utils.TypeConversion;
|
||
import com.common.utils.encryption.PasswdFactory;
|
||
import com.common.utils.excel.ExcelUtils;
|
||
import com.common.utils.jwt.JwtUtil;
|
||
import com.common.utils.model.Code;
|
||
import com.common.utils.model.Message;
|
||
import com.common.utils.model.Pager;
|
||
import com.common.utils.model.SingleResult;
|
||
import com.github.pagehelper.Page;
|
||
import com.github.pagehelper.PageHelper;
|
||
import com.rzyc.advice.LoginAuth;
|
||
import com.rzyc.bean.SysEnterpriseDo;
|
||
import com.rzyc.bean.check.dto.LawAddDto;
|
||
import com.rzyc.bean.check.dto.TalkAddDto;
|
||
import com.rzyc.bean.ent.*;
|
||
import com.rzyc.bean.user.dto.LoginDto;
|
||
import com.rzyc.model.Accident;
|
||
import com.rzyc.model.EntCertificates;
|
||
import com.rzyc.model.check.*;
|
||
import com.rzyc.model.ent.EntBillCon;
|
||
import com.rzyc.model.ent.SysEnterprise;
|
||
import com.rzyc.model.user.SysUnit;
|
||
import com.rzyc.model.user.SysUser;
|
||
import io.swagger.annotations.Api;
|
||
import io.swagger.annotations.ApiImplicitParam;
|
||
import io.swagger.annotations.ApiImplicitParams;
|
||
import io.swagger.annotations.ApiOperation;
|
||
|
||
|
||
import org.apache.commons.beanutils.ConvertUtils;
|
||
import org.apache.commons.beanutils.converters.DateConverter;
|
||
|
||
import org.springframework.beans.BeanUtils;
|
||
import org.springframework.security.access.prepost.PreAuthorize;
|
||
import org.springframework.stereotype.Controller;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
import org.springframework.validation.annotation.Validated;
|
||
import org.springframework.web.bind.annotation.*;
|
||
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
import javax.validation.Valid;
|
||
import java.sql.Timestamp;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.ArrayList;
|
||
import java.util.Arrays;
|
||
import java.util.Date;
|
||
import java.util.List;
|
||
|
||
/**
|
||
* @author dong
|
||
* @date 2022-09-20 14:55
|
||
* @Version V1.0
|
||
*/
|
||
@Api(tags = "企业系统")
|
||
@CrossOrigin("*")
|
||
@RequestMapping("pcCompany")
|
||
@Controller
|
||
@Validated
|
||
public class PcCompanyController extends BaseController{
|
||
|
||
|
||
/**
|
||
* PC企业详细
|
||
* @return
|
||
*/
|
||
@ApiOperation(value = "PC企业详细", notes = "PC企业详细")
|
||
@ApiImplicitParams({
|
||
@ApiImplicitParam(name = "SysEnterpriseId", value = "公司id", required = true, dataType = "string")
|
||
})
|
||
@PostMapping("/companyDetail")
|
||
@ResponseBody
|
||
public SingleResult<String> companyDetail(String SysEnterpriseId)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
List<SysEnterprise> sysEnterprises = sysEnterpriseMapper.companyDetail(SysEnterpriseId);
|
||
List<String>safeClass = new ArrayList<>();
|
||
if (StringUtils.isNotBlank(sysEnterprises.get(0).getBasesafeclassid())){
|
||
safeClass = super.exchange(sysEnterprises.get(0).getBasesafeclassid(),1);
|
||
}
|
||
List<String>incClass = new ArrayList<>();
|
||
if(StringUtils.isNotBlank(sysEnterprises.get(0).getBaseinclassid())){
|
||
incClass = super.exchange(sysEnterprises.get(0).getBaseinclassid(),2);
|
||
}
|
||
List<String>workClass = new ArrayList<>();
|
||
if(StringUtils.isNotBlank(sysEnterprises.get(0).getWorkClassId())){
|
||
incClass = super.exchange(sysEnterprises.get(0).getWorkClassId(),3);
|
||
}
|
||
|
||
|
||
sysEnterprises.get(0).setInClassName(JSONArray.toJSONString(incClass));
|
||
sysEnterprises.get(0).setSafeClassName(JSONArray.toJSONString(safeClass));
|
||
sysEnterprises.get(0).setWorkClassName(JSONArray.toJSONString(incClass));
|
||
|
||
String orgName = sysEnterprises.get(0).getOrgName();
|
||
if(StringUtils.isNotBlank(sysEnterprises.get(0).getStreetName())){
|
||
orgName = orgName + "-" + sysEnterprises.get(0).getStreetName();
|
||
}
|
||
if(StringUtils.isNotBlank(sysEnterprises.get(0).getCommunityName())){
|
||
orgName = orgName + "-" + sysEnterprises.get(0).getCommunityName();
|
||
}
|
||
sysEnterprises.get(0).setOrgName(orgName);
|
||
|
||
|
||
List<SysUnit> units = sysUnitMapper.findUnit();
|
||
String sysUnitId = sysEnterprises.get(0).getSysUnitId();
|
||
String managerDept = sysEnterprises.get(0).getManagerDept();
|
||
String [] arr=sysUnitId.split(",");
|
||
StringBuilder stringBuilder = new StringBuilder();
|
||
for (String i:arr) {
|
||
for (SysUnit un:units) {
|
||
if (un.getSysunitid().equals(managerDept)){
|
||
sysEnterprises.get(0).setManagerDeptName(un.getUnitname());
|
||
}
|
||
if (un.getSysunitid().equals(i)){
|
||
stringBuilder.append(un.getUnitname()+",");
|
||
}
|
||
}
|
||
}
|
||
if (StringUtils.isNotBlank(stringBuilder.toString())){
|
||
sysEnterprises.get(0).setSysUnitName(stringBuilder.toString().substring(0,stringBuilder.toString().length()-1));
|
||
}
|
||
if (sysEnterprises != null){
|
||
singleResult.setMessage(Message.SUCCESS);
|
||
singleResult.setData(sysEnterprises);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
}else {
|
||
singleResult.setMessage(Message.ERROR);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
}
|
||
return singleResult;
|
||
}
|
||
|
||
/**
|
||
* PC登录
|
||
* @param loginDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "PC登录", notes = "PC登录")
|
||
@PostMapping(value = "/pclogin")
|
||
@ResponseBody
|
||
public SingleResult<SysUser> pclogin(@Valid LoginDto loginDto)throws Exception{
|
||
SingleResult<SysUser> result = new SingleResult<>();
|
||
System.out.println("loginDto -> "+JSONArray.toJSONString(loginDto));
|
||
String sysusername = loginDto.getSysusername();
|
||
String syspassword = loginDto.getSyspassword();
|
||
|
||
String generateCode = request.getSession().getAttribute(constantsConfigure.getGenerateCodeKey())+"";
|
||
//验证码只能使用一次
|
||
request.getSession().removeAttribute(constantsConfigure.getGenerateCodeKey());
|
||
|
||
if(loginDto.getGenerateCode().equals(generateCode)){
|
||
SysUser sysUser = sysUserMapper.findBySysUserName(sysusername);
|
||
if(null != sysUser && StringUtils.isNotBlank(sysUser.getUsertype()) && sysUser.getUsertype().equals("政府用户")){
|
||
String ps = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysusername, syspassword);
|
||
System.out.println("========" + ps);
|
||
if(sysUser.getSyspassword().equals(ps)){
|
||
sysUser.setSyspassword("");
|
||
|
||
//获取职务
|
||
sysUser = getUserDuty(sysUser);
|
||
|
||
//通过角色判断是否为安办 或者 部门管理员
|
||
if(StringUtils.isNotBlank(sysUser.getUserroles())){
|
||
Integer userRole = this.getUserRole(sysUser.getUserroles());
|
||
sysUser.setUserRole(userRole);
|
||
}
|
||
|
||
//获取用户令牌
|
||
String userToken = JwtUtil.createToken(sysUser.getSysuserid());
|
||
sysUser.setUserToken(userToken);
|
||
|
||
this.addLogAuth(sysUser.getSysuserid(),"登录","成功","");
|
||
result.setData(sysUser);
|
||
|
||
}else{
|
||
this.addLogAuth(sysUser.getSysuserid(),"登录","失败","");
|
||
result.setCode(Code.PASSWORD_ERROR.getCode());
|
||
result.setMessage(Message.PASSWORD_ERROR);
|
||
}
|
||
}else{
|
||
result.setCode(Code.PASSWORD_ERROR.getCode());
|
||
result.setMessage(Message.PASSWORD_ERROR);
|
||
}
|
||
}else{
|
||
result.setCode(Code.CODE_ERROT.getCode());
|
||
result.setMessage(Message.CODE_ERROT);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* PC企业详细检查信息
|
||
* */
|
||
@ApiOperation(value = "PC企业详细检查信息", notes = "PC企业详细检查信息")
|
||
@ApiImplicitParams({
|
||
@ApiImplicitParam(name = "SysEnterpriseId", value = "公司id", required = true, dataType = "string"),
|
||
@ApiImplicitParam(name = "page", value = "页数", required = true, dataType = "int"),
|
||
@ApiImplicitParam(name = "pageSize", value = "条数", required = true, dataType = "int")
|
||
})
|
||
@PostMapping("/companyDetailCheck")
|
||
@ResponseBody
|
||
public SingleResult<Pager<BookEntCheck>> companyDetailCheck(String SysEnterpriseId, Integer page, Integer pageSize)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
Pager<BookEntCheck> pager = new Pager<>();
|
||
PageHelper.startPage(page, pageSize);
|
||
Page<BookEntCheck> bookEntChecks = (Page<BookEntCheck>)bookEntCheckMapper.companyDetailCheck(SysEnterpriseId);
|
||
getDatePage(pager,bookEntChecks);
|
||
if (bookEntChecks != null){
|
||
singleResult.setMessage(Message.SUCCESS);
|
||
singleResult.setData(pager);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
}else {
|
||
singleResult.setMessage(Message.ERROR);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
}
|
||
return singleResult;
|
||
}
|
||
|
||
/**
|
||
* PC企业详细事故管理
|
||
* */
|
||
@ApiOperation(value = "PC企业详细事故管理", notes = "PC企业详细事故管理")
|
||
@ApiImplicitParams({
|
||
@ApiImplicitParam(name = "SysEnterpriseId", value = "公司id", required = true, dataType = "string"),
|
||
@ApiImplicitParam(name = "page", value = "页数", required = true, dataType = "int"),
|
||
@ApiImplicitParam(name = "pageSize", value = "条数", required = true, dataType = "int")
|
||
})
|
||
@PostMapping("/companyDetailAccident")
|
||
@ResponseBody
|
||
public SingleResult<Pager<Accident>> companyDetailAccident(String SysEnterpriseId, Integer page, Integer pageSize)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
Pager<Accident> pager = new Pager<>();
|
||
PageHelper.startPage(page, pageSize);
|
||
List<Accident>accidents = accidentMapper.accidentDetailByCompanyId(SysEnterpriseId);
|
||
Page<Accident>accidentPage =(Page<Accident>) accidents;
|
||
getDatePage(pager,accidentPage);
|
||
if (accidents != null){
|
||
singleResult.setMessage(Message.SUCCESS);
|
||
singleResult.setData(pager);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
}else {
|
||
singleResult.setMessage(Message.ERROR);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
}
|
||
return singleResult;
|
||
}
|
||
|
||
/**
|
||
* PC企业详细隐患管理
|
||
* */
|
||
@ApiOperation(value = "PC企业详细隐患管理", notes = "PC企业详细隐患管理")
|
||
@ApiImplicitParams({
|
||
@ApiImplicitParam(name = "SysEnterpriseId", value = "公司id", required = true, dataType = "string"),
|
||
@ApiImplicitParam(name = "page", value = "页数", required = true, dataType = "int"),
|
||
@ApiImplicitParam(name = "pageSize", value = "条数", required = true, dataType = "int")
|
||
})
|
||
@PostMapping("/companyDetailDanger")
|
||
@ResponseBody
|
||
public SingleResult<Pager<BookEntHT>> companyDetailDanger(String SysEnterpriseId, Integer page, Integer pageSize)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
Pager<BookEntHT> pager = new Pager<>();
|
||
PageHelper.startPage(page, pageSize);
|
||
List<BookEntHT>bookEntHTS = bookEntHTMapper.dangerDetailByCompanyId(SysEnterpriseId);
|
||
Page<BookEntHT>bookEnt =(Page<BookEntHT>) bookEntHTS;
|
||
getDatePage(pager,bookEnt);
|
||
if (bookEntHTS != null){
|
||
singleResult.setMessage(Message.SUCCESS);
|
||
singleResult.setData(pager);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
}else {
|
||
singleResult.setMessage(Message.ERROR);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
}
|
||
return singleResult;
|
||
}
|
||
|
||
/**
|
||
* PC企业详细执法记录
|
||
* */
|
||
@ApiOperation(value = "PC企业详细执法记录", notes = "PC企业详细执法记录")
|
||
@ApiImplicitParams({
|
||
@ApiImplicitParam(name = "SysEnterpriseId", value = "公司id", required = true, dataType = "string"),
|
||
@ApiImplicitParam(name = "page", value = "页数", required = true, dataType = "int"),
|
||
@ApiImplicitParam(name = "bookenthtid", value = "隐患id"),
|
||
@ApiImplicitParam(name = "pageSize", value = "条数", required = true, dataType = "int")
|
||
})
|
||
@PostMapping("/companyDetailLawEnforcement")
|
||
@ResponseBody
|
||
public SingleResult<Pager<BookLaw>> companyDetailLawEnforcement(String SysEnterpriseId, String bookenthtid,
|
||
Integer page, Integer pageSize)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
Pager<BookLaw> pager = new Pager<>();
|
||
PageHelper.startPage(page, pageSize);
|
||
List<BookLaw>bookLaws = bookLawMapper.lawEnforcementDetailByCompanyId(SysEnterpriseId,bookenthtid);
|
||
Page<BookLaw>laws =(Page<BookLaw>) bookLaws;
|
||
getDatePage(pager,laws);
|
||
if (bookLaws != null){
|
||
singleResult.setMessage(Message.SUCCESS);
|
||
singleResult.setData(pager);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
}else {
|
||
singleResult.setMessage(Message.ERROR);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
}
|
||
return singleResult;
|
||
}
|
||
|
||
/**
|
||
* PC企业详细约谈记录
|
||
* */
|
||
@ApiOperation(value = "PC企业详细约谈记录", notes = "PC企业详细约谈记录")
|
||
@ApiImplicitParams({
|
||
@ApiImplicitParam(name = "SysEnterpriseId", value = "公司id", required = true, dataType = "string"),
|
||
@ApiImplicitParam(name = "bookenthtid", value = "隐患id"),
|
||
@ApiImplicitParam(name = "page", value = "页数", required = true, dataType = "int"),
|
||
@ApiImplicitParam(name = "pageSize", value = "条数", required = true, dataType = "int")
|
||
})
|
||
@PostMapping("/companyDetailInterview")
|
||
@ResponseBody
|
||
public SingleResult<Pager<BookTalk>> companyDetailInterview(String SysEnterpriseId,
|
||
String bookenthtid, Integer page, Integer pageSize)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
Pager<BookTalk> pager = new Pager<>();
|
||
PageHelper.startPage(page, pageSize);
|
||
List<BookTalk>bookTalks = bookTalkMapper.interviewDetailByCompanyId(SysEnterpriseId,bookenthtid);
|
||
Page<BookTalk>bk =(Page<BookTalk>) bookTalks;
|
||
getDatePage(pager,bk);
|
||
if (bookTalks != null){
|
||
singleResult.setMessage(Message.SUCCESS);
|
||
singleResult.setData(pager);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
}else {
|
||
singleResult.setMessage(Message.ERROR);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
}
|
||
return singleResult;
|
||
}
|
||
|
||
/**
|
||
* PC企业新增约谈
|
||
* */
|
||
@ApiOperation(value = "PC企业新增约谈", notes = "PC企业新增约谈")
|
||
|
||
@PostMapping("/companyAddInterview")
|
||
@ResponseBody
|
||
public SingleResult<String> companyAddInterview(@Valid TalkAddDto talkAddDto)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
BookTalkWithBLOBs bookTalkWithBLOBs = new BookTalkWithBLOBs();
|
||
bookTalkWithBLOBs.setSysenterpriseid(talkAddDto.getSysenterpriseid());
|
||
bookTalkWithBLOBs.setTalktime(DateUtils.parseString2Date(talkAddDto.getTalktime(),"yyyy-MM-dd"));
|
||
bookTalkWithBLOBs.setTalkcontent(talkAddDto.getTalkcontent());
|
||
bookTalkWithBLOBs.setRemake(talkAddDto.getRemake());
|
||
bookTalkWithBLOBs.setBookenthtid(talkAddDto.getBookenthtid());
|
||
String userId = getUserId();
|
||
bookTalkWithBLOBs.setCreatedby(userId);
|
||
bookTalkWithBLOBs.setModifiedby(userId);
|
||
bookTalkWithBLOBs.setCreatedon(new Date());
|
||
bookTalkWithBLOBs.setModifiedon(new Date());
|
||
bookTalkWithBLOBs.setBooktalkid(talkAddDto.getBooktalkid());
|
||
bookTalkMapper.insert(bookTalkWithBLOBs);
|
||
return singleResult;
|
||
}
|
||
|
||
/**
|
||
* PC企业新增执法
|
||
* */
|
||
@ApiOperation(value = "PC企业新增执法", notes = "PC企业新增执法")
|
||
@PostMapping("/companyAddBookLaw")
|
||
@ResponseBody
|
||
public SingleResult<String> companyAddBookLaw(@Valid LawAddDto lawAddDto)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
BookLawWithBLOBs bookLawWithBLOBs = new BookLawWithBLOBs();
|
||
bookLawWithBLOBs.setLawcontent(lawAddDto.getLawcontent());
|
||
bookLawWithBLOBs.setSysenterpriseid(lawAddDto.getSysenterpriseid());
|
||
bookLawWithBLOBs.setLawtime(DateUtils.parseString2Date(lawAddDto.getLawtime(),"yyyy-MM-dd"));
|
||
bookLawWithBLOBs.setRemake(lawAddDto.getRemake());
|
||
String userId = getUserId();
|
||
bookLawWithBLOBs.setCreatedon(new Date());
|
||
bookLawWithBLOBs.setModifiedon(new Date());
|
||
bookLawWithBLOBs.setCreatedby(userId);
|
||
bookLawWithBLOBs.setModifiedby(userId);
|
||
bookLawWithBLOBs.setBooklawid(lawAddDto.getBooklawid());
|
||
bookLawWithBLOBs.setBookenthtid(lawAddDto.getBookenthtid());
|
||
bookLawMapper.insert(bookLawWithBLOBs);
|
||
return singleResult;
|
||
}
|
||
|
||
|
||
/**
|
||
* PC企业重新生成清单
|
||
* */
|
||
@ApiOperation(value = "PC企业重新生成清单/需要配合前端测试", notes = "PC企业重新生成清单/需要配合前端测试")
|
||
@PostMapping("/resetBills")
|
||
@ResponseBody
|
||
@Transactional
|
||
public SingleResult<String> resetBills(@Valid @RequestBody SysEnterprise sysEnterprise, HttpServletRequest servletRequest)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
//查询唯一的一个日常检查
|
||
ChkGovBill chkGovBill = chkGovBillMapper.selectByCompanyId(sysEnterprise.getSysenterpriseid());
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
String token = servletRequest.getHeader("userToken");
|
||
String userId = JwtUtil.getTokenMsg(token);
|
||
SysUser sysUser = super.getUser(userId);
|
||
if (chkGovBill == null){
|
||
/**
|
||
* 先判断是否有日常没有就创建,然后替换基础清单信息,
|
||
* 然后删除清单下所有对应的检查项(自己公司的)
|
||
* ,然后重新根据安全类别找出对应的检查项
|
||
* 放入企业对应的清单下
|
||
* */
|
||
chkGovBill = new ChkGovBill();
|
||
chkGovBill.setBaseinclassid(sysEnterprise.getBaseinclassid());
|
||
chkGovBill.setBasesafeclassid(sysEnterprise.getBasesafeclassid());
|
||
chkGovBill.setChkbillname(sysEnterprise.getEntname() + "日常检查");
|
||
chkGovBill.setSysEnterpriseId(sysEnterprise.getSysenterpriseid());
|
||
chkGovBill.setChkbillno(simpleDateFormat.format(new Date()));
|
||
chkGovBill.setChkbilldate(new Timestamp(System.currentTimeMillis()));
|
||
chkGovBill.setCreatedby(sysUser.getChinaname());
|
||
chkGovBill.setCreatedon(new Date());
|
||
chkGovBill.setSysUnitId(sysEnterprise.getManagerDept());
|
||
String uid = RandomNumber.getUUid();
|
||
chkGovBill.setChkgovbillid(uid);
|
||
chkGovBill.setDelState(1);
|
||
chkGovBillMapper.insertByPc(chkGovBill);
|
||
EntBillCon entcon = new EntBillCon();
|
||
entcon.setEntbillconid(RandomNumber.getUUid());
|
||
entcon.setSysenterpriseid(chkGovBill.getSysEnterpriseId());
|
||
entcon.setChkgovbillid(uid);
|
||
entcon.setCreatedby(sysUser.getChinaname());
|
||
entcon.setCreatedon(new Date());
|
||
entcon.setModifiedby(sysUser.getChinaname());
|
||
entcon.setModifiedon(new Date());
|
||
entBillConMapper.insert(entcon);
|
||
}else {
|
||
chkGovBill.setDelState(1);
|
||
chkGovBill.setBaseinclassid(sysEnterprise.getBaseinclassid());
|
||
chkGovBill.setBasesafeclassid(sysEnterprise.getBasesafeclassid());
|
||
chkGovBill.setChkbillname(sysEnterprise.getEntname() + "日常检查");
|
||
chkGovBill.setSysEnterpriseId(sysEnterprise.getSysenterpriseid());
|
||
chkGovBill.setChkbillno(simpleDateFormat.format(new Date()));
|
||
chkGovBill.setModifiedby(sysUser.getChinaname());
|
||
chkGovBill.setModifiedon(new Date());
|
||
chkGovBill.setSysUnitId(sysEnterprise.getManagerDept());
|
||
chkGovBillMapper.updateByPrimaryKey(chkGovBill);
|
||
entBillConMapper.deleteByChkGovBill(chkGovBill.getChkgovbillid());
|
||
chkGovBillDetailMapper.deleteByChkGovBillId(chkGovBill.getChkgovbillid());
|
||
/**插入关联表*/
|
||
EntBillCon con = new EntBillCon();
|
||
con.setEntbillconid(RandomNumber.getUUid());
|
||
con.setChkgovbillid(chkGovBill.getChkgovbillid());
|
||
con.setSysenterpriseid(chkGovBill.getSysEnterpriseId());
|
||
con.setCreatedon(new Date());
|
||
con.setCreatedby(sysUser.getChinaname());
|
||
con.setModifiedon(new Date());
|
||
con.setModifiedby(sysUser.getChinaname());
|
||
entBillConMapper.insert(con);
|
||
}
|
||
/**查询检查项*/
|
||
String [] safe = sysEnterprise.getBasesafeclassid().split(",");
|
||
List<String> list = Arrays.asList(safe);
|
||
List<ChkBillDetailWithBLOBs> billDetails = chkBillDetailMapper.entChkBillPC(sysEnterprise.getBaseinclassid(),list);
|
||
if (null != billDetails && billDetails.size()==0){
|
||
singleResult.setMessage(Message.NO_CHECKITEMS);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
return singleResult;
|
||
}
|
||
List<ChkGovBillDetailWithBLOBs> govBillDetails = new ArrayList<ChkGovBillDetailWithBLOBs>();
|
||
Integer checkItemNo = 1000;
|
||
for (ChkBillDetailWithBLOBs chkBillDetailWithBLOBs : billDetails){
|
||
ChkGovBillDetailWithBLOBs govBillDetail = new ChkGovBillDetailWithBLOBs();
|
||
govBillDetail.setChkgovbilldetailid(RandomNumber.randomUUidPK());
|
||
govBillDetail.setChkgovbillid(chkGovBill.getChkgovbillid());
|
||
govBillDetail.setChkbilldetailid(chkBillDetailWithBLOBs.getChkbilldetailid());
|
||
govBillDetail.setBasekpiid(chkBillDetailWithBLOBs.getBasekpiid());
|
||
govBillDetail.setBaseinclassid(chkBillDetailWithBLOBs.getBaseinclassid());
|
||
govBillDetail.setBasesafeclassid(chkBillDetailWithBLOBs.getBasesafeclassid());
|
||
govBillDetail.setCheckitemno(""+checkItemNo++);
|
||
govBillDetail.setCheckobjectname(chkBillDetailWithBLOBs.getCheckobjectname());
|
||
govBillDetail.setCheckmethod(chkBillDetailWithBLOBs.getCheckmethod());
|
||
govBillDetail.setCheckbasis(chkBillDetailWithBLOBs.getCheckbasis());
|
||
govBillDetail.setCreatedby(sysUser.getChinaname());
|
||
govBillDetail.setCreatedon(new Date());
|
||
govBillDetail.setModifiedby(sysUser.getChinaname());
|
||
govBillDetail.setModifiedon(new Date());
|
||
govBillDetails.add(govBillDetail);
|
||
}
|
||
chkGovBillDetailMapper.insertList(govBillDetails);
|
||
return singleResult;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* PC新增企业或者修改
|
||
* */
|
||
@ApiOperation(value = "PC新增企业或者修改/需要调试", notes = "PC新增企业或者修改/需要调试")
|
||
@PostMapping("/addOrUpdateCompany")
|
||
@ResponseBody
|
||
@Transactional
|
||
public SingleResult<SysEnterpriseDo> addCompany(@Valid @RequestBody SysEnterpriseDo sysEnterpriseDo, HttpServletRequest servletRequest)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
SysEnterprise sysEnterprise = new SysEnterprise();
|
||
/**
|
||
* 一.异常出现原因
|
||
* 使用 BeanUtils.copyProperties(model,bo),数据源对象model有一个参数是java.util.Date类型,由于导入的是org.apache.commons.beanutils.BeanUtils 没有初始化值,导致调用BeanUtils.copyProperties方法时,
|
||
* 报错No value specified for Date
|
||
* */
|
||
ConvertUtils.register(new DateConverter(null), Date.class);
|
||
BeanUtils.copyProperties(sysEnterpriseDo ,sysEnterprise);
|
||
String token = servletRequest.getHeader("userToken");
|
||
String userId = JwtUtil.getTokenMsg(token);
|
||
if (StringUtils.isBlank(userId)){
|
||
userId = sysEnterpriseDo.getUserId();
|
||
}
|
||
SysUser sysUser = super.getUser(userId);
|
||
sysEnterprise.setCreatedby(sysUser.getChinaname());
|
||
sysEnterprise.setModifiedby(sysUser.getChinaname());
|
||
int result = 0;
|
||
if (null == sysEnterpriseDo.getSysenterpriseid()){
|
||
SysEnterprise verifyEnterprise = sysEnterpriseMapper.selectByName(sysEnterpriseDo.getEntname(),null);
|
||
if (null != verifyEnterprise){
|
||
singleResult.setMessage(Message.HAS_ENT);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
return singleResult;
|
||
}
|
||
sysEnterprise.setCreatedon(new Date());
|
||
sysEnterprise.setModifiedon(new Date());
|
||
sysEnterprise.setSysenterpriseid(RandomNumber.getUUid());
|
||
sysEnterprise.setDynamicRiskLevel("100");//新建企业默认100分数
|
||
sysEnterprise.setQrCode(entQrCode(sysEnterprise.getSysenterpriseid()));
|
||
result = sysEnterpriseMapper.insert(sysEnterprise);
|
||
|
||
}else {
|
||
SysEnterprise verifyEnterprise = sysEnterpriseMapper.selectByName(sysEnterpriseDo.getEntname(),sysEnterpriseDo.getSysenterpriseid());
|
||
if (null != verifyEnterprise){
|
||
singleResult.setMessage(Message.HAS_ENT);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
return singleResult;
|
||
}
|
||
|
||
//如果二维码为空 则生成新的二维码
|
||
SysEnterprise enterprise = sysEnterpriseMapper.selectByPrimaryKey(sysEnterprise.getSysenterpriseid());
|
||
if(StringUtils.isBlank(enterprise.getQrCode())){
|
||
sysEnterprise.setQrCode(entQrCode(sysEnterprise.getSysenterpriseid()));
|
||
}
|
||
|
||
sysEnterprise.setModifiedon(new Date());
|
||
result = sysEnterpriseMapper.updateByPrimaryKey(sysEnterprise);
|
||
|
||
}
|
||
|
||
//生成最小工作单元
|
||
saveEntWork(sysEnterprise.getSysenterpriseid());
|
||
|
||
//创建或者修改企业用户
|
||
createEntUser(sysEnterprise,sysUser.getChinaname(),sysUser);
|
||
|
||
if (result > 0){
|
||
singleResult.setMessage(Message.SUCCESS);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
}else {
|
||
singleResult.setMessage(Message.ERROR);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
}
|
||
|
||
return singleResult;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* PC企业EXCEL
|
||
* */
|
||
@ApiOperation(value = "PC企业EXCEL", notes = "PC企业EXCEL")
|
||
@GetMapping("/companiesExcel")
|
||
@ResponseBody
|
||
public void companiesExcel(@Valid CompaniesExcelDto companiesExcelDto, HttpServletResponse response)throws Exception {
|
||
|
||
|
||
String userId = companiesExcelDto.getUserId();
|
||
|
||
//是否为管理员账号 1:是 2:否
|
||
Integer isAdmin = 1;
|
||
|
||
String areaCode = companiesExcelDto.getOrgCode();
|
||
if(StringUtils.isBlank(areaCode)){
|
||
areaCode = getUserArea(userId);
|
||
}
|
||
|
||
List<Integer> inherentRisks = new ArrayList<>();
|
||
|
||
//风险等级
|
||
if(StringUtils.isNotBlank(companiesExcelDto.getInherentRiskStr())){
|
||
for (String str : companiesExcelDto.getInherentRiskStr().split(",")){
|
||
inherentRisks.add(TypeConversion.StringToInteger(str));
|
||
}
|
||
}
|
||
|
||
|
||
|
||
List<SysEnterprise> sysEnterprises = sysEnterpriseMapper.selectPCList(areaCode,companiesExcelDto.getEntName(),companiesExcelDto.getRiskLevel(),isAdmin,companiesExcelDto.getBaseinclassid(),inherentRisks);
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||
String date = simpleDateFormat.format(new Date());
|
||
if(null != sysEnterprises && sysEnterprises.size() > 0){
|
||
ExcelUtils.writeExcel(response, "企业信息-"+date+".xlsx",sysEnterprises, SysEnterprise.class);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 约谈列表
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "约谈分页", notes = "约谈分页")
|
||
@GetMapping("/talkPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<BookTalk>> talkPage(@Valid TalkPageDto talkPageDto)throws Exception{
|
||
SingleResult<Pager<BookTalk>> result = new SingleResult<>();
|
||
String condition = TypeConversion.getCondition(talkPageDto.getCondition());
|
||
PageHelper.startPage(talkPageDto.getPage(), talkPageDto.getPageSize());
|
||
Page<BookTalk> page = (Page<BookTalk>)bookTalkMapper.talkPage(condition,talkPageDto.getBookenthtid());
|
||
if(page.getTotal() > 0){
|
||
Pager<BookTalk> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 新增修改约谈
|
||
* @param changeTalkDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "新增修改约谈", notes = "新增修改约谈")
|
||
@PostMapping("/changeTalk")
|
||
@ResponseBody
|
||
public SingleResult<String> changeTalk(@Valid ChangeTalkDto changeTalkDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
BookTalkWithBLOBs bookTalk = new BookTalkWithBLOBs();
|
||
BeanUtils.copyProperties(changeTalkDto,bookTalk);
|
||
|
||
//操作人
|
||
String chinaName = getChinaName();
|
||
System.out.println("chinaName -> "+chinaName);
|
||
bookTalk.setCreatedby(chinaName);
|
||
bookTalk.setModifiedby(chinaName);
|
||
bookTalk.setModifiedon(new Date());
|
||
bookTalk.setCreatedon(new Date());
|
||
|
||
//约谈时间
|
||
bookTalk.setTalktime(DateUtils.parseString2Date(changeTalkDto.getTime(),"yyyy-MM-dd"));
|
||
|
||
if(StringUtils.isNotBlank(bookTalk.getBooktalkid())){
|
||
bookTalkMapper.changeTalk(bookTalk);
|
||
}else{
|
||
bookTalk.setBooktalkid(RandomNumber.getUUid());
|
||
bookTalkMapper.insert(bookTalk);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 执法分页
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "执法分页", notes = "执法分页")
|
||
@GetMapping("/lawPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<BookLawWithBLOBs>> lawPage(@Valid TalkPageDto talkPageDto)throws Exception{
|
||
SingleResult<Pager<BookLawWithBLOBs>> result = new SingleResult<>();
|
||
String condition = TypeConversion.getCondition(talkPageDto.getCondition());
|
||
PageHelper.startPage(talkPageDto.getPage(), talkPageDto.getPageSize());
|
||
Page<BookLawWithBLOBs> page = (Page<BookLawWithBLOBs>)bookLawMapper.lawPage(condition,talkPageDto.getBookenthtid());
|
||
if(page.getTotal() > 0){
|
||
Pager<BookLawWithBLOBs> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 修改新增执法
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "修改新增执法", notes = "修改新增执法")
|
||
@PostMapping("/changeLaw")
|
||
@ResponseBody
|
||
public SingleResult<String> changeLaw(@Valid ChangeLawDto changeLawDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
BookLawWithBLOBs bookLaw = new BookLawWithBLOBs();
|
||
BeanUtils.copyProperties(changeLawDto,bookLaw);
|
||
|
||
//操作人
|
||
String chinaName = getChinaName();
|
||
System.out.println("chinaName -> "+chinaName);
|
||
bookLaw.setCreatedby(chinaName);
|
||
bookLaw.setModifiedby(chinaName);
|
||
bookLaw.setModifiedon(new Date());
|
||
bookLaw.setCreatedon(new Date());
|
||
//约谈时间
|
||
bookLaw.setLawtime(DateUtils.parseString2Date(changeLawDto.getTime(),"yyyy-MM-dd"));
|
||
if(StringUtils.isNotBlank(bookLaw.getBooklawid())){
|
||
bookLawMapper.changeLaw(bookLaw);
|
||
}else{
|
||
bookLaw.setBooklawid(RandomNumber.getUUid());
|
||
bookLawMapper.insert(bookLaw);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 证照分页
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/9/27 14:45
|
||
*/
|
||
@ApiOperation(value = "证照分页", notes = "证照分页")
|
||
@GetMapping("/certificatesPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<EntCertificates>> certificatesPage(@Valid CertificatesPageDto certificatesPageDto)throws Exception{
|
||
SingleResult<Pager<EntCertificates>> result = new SingleResult<>();
|
||
PageHelper.startPage(certificatesPageDto.getPage(), certificatesPageDto.getPageSize());
|
||
Page<EntCertificates> page = (Page<EntCertificates>)entCertificatesMapper.certificatesList(certificatesPageDto.getEnterpriseId());
|
||
Pager<EntCertificates> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 证照分页新增或者修改
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/9/27 15:13
|
||
*/
|
||
@ApiOperation(value = "证照分页新增或者修改", notes = "证照分页新增或者修改")
|
||
@PostMapping("/certificatesAdd")
|
||
@ResponseBody
|
||
public SingleResult<String> certificatesAdd(@Valid CertificatesAddDto certificatesAddDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
|
||
String userId = getUserId();
|
||
|
||
EntCertificates entCertificates = new EntCertificates();
|
||
BeanUtils.copyProperties(certificatesAddDto,entCertificates);
|
||
entCertificates.setModifyTime(new Date());
|
||
entCertificates.setCreateBy(userId);
|
||
|
||
EntCertificates certificates = entCertificatesMapper.selectById(entCertificates.getCertificatesId());
|
||
if(null != certificates){
|
||
entCertificatesMapper.updateById(entCertificates);
|
||
}else{
|
||
entCertificates.setCreateTime(new Date());
|
||
entCertificates.setCreateBy(userId);
|
||
entCertificates.setState(1);
|
||
entCertificatesMapper.insert(entCertificates);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 检查记录详细
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/9/27 15:22
|
||
*/
|
||
@ApiOperation(value = "检查记录详细", notes = "检查记录详细")
|
||
@GetMapping("/getCompanyCheckDetail")
|
||
@ApiImplicitParams({
|
||
@ApiImplicitParam(name = "id", value = "检查id", required = true, dataType = "string"),
|
||
})
|
||
@ResponseBody
|
||
public SingleResult<String> getCompanyCheckDetail(String id)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
BookEntCheck bookEntCheck = bookEntCheckMapper.selectCheckDetail(id);
|
||
if (null != bookEntCheck){
|
||
|
||
|
||
//处理数据,第二个参数是给小程序用的判断isSign
|
||
handleCheckDetail(bookEntCheck,"simProgram");
|
||
|
||
singleResult.setData(bookEntCheck);
|
||
singleResult.setMessage(Message.SUCCESS);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
}else {
|
||
singleResult.setMessage(Message.ERROR);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
}
|
||
return singleResult;
|
||
}
|
||
|
||
|
||
|
||
@PostMapping("/testSpringSecurity")
|
||
@ResponseBody
|
||
@PreAuthorize("hasRole('USER')")
|
||
public String testSpringSecurity(String SysEnterpriseId)throws Exception {
|
||
return "SysEnterpriseId";
|
||
}
|
||
|
||
}
|