381 lines
13 KiB
Java
381 lines
13 KiB
Java
package com.zcloud.service.hiddenApi.impl;
|
||
|
||
import com.zcloud.entity.Page;
|
||
import com.zcloud.entity.PageData;
|
||
import com.zcloud.mapper.datasource.hiddenApi.HiddenApiMapper;
|
||
import com.zcloud.service.bus.HiddenRegionService;
|
||
import com.zcloud.service.bus.ImgFilesService;
|
||
import com.zcloud.service.hiddenApi.HiddenApiService;
|
||
import com.zcloud.service.system.UsersService;
|
||
import com.zcloud.util.DateUtil;
|
||
import com.zcloud.util.HttpEmisDuijieUtil;
|
||
import com.zcloud.util.Jurisdiction;
|
||
import com.zcloud.util.Tools;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Service;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
|
||
import javax.annotation.Resource;
|
||
import java.util.ArrayList;
|
||
import java.util.Date;
|
||
import java.util.List;
|
||
|
||
/**
|
||
* 说明:隐患
|
||
* 作者:luoxiaobao
|
||
* 时间:2021-01-04
|
||
* 官网:www.zcloudchina.com
|
||
*/
|
||
@Service
|
||
@Transactional //开启事物
|
||
public class HiddenApiServiceImpl implements HiddenApiService{
|
||
|
||
@Resource
|
||
private HiddenApiMapper hiddenApiMapper;
|
||
@Autowired
|
||
private UsersService usersService;
|
||
@Autowired
|
||
private HiddenRegionService hiddenRegionService; // 隐患区域维护
|
||
@Autowired
|
||
private ImgFilesService imgFilesService;
|
||
/**新增
|
||
* @param pd
|
||
* @throws Exception
|
||
*/
|
||
public void saveApi(PageData pd)throws Exception{
|
||
hiddenApiMapper.save(pd);
|
||
}
|
||
|
||
/**删除
|
||
* @param pd
|
||
* @throws Exception
|
||
*/
|
||
public int deleteApi(String hiddenId)throws Exception{
|
||
return hiddenApiMapper.delete(hiddenId);
|
||
}
|
||
/**通过id获取数据
|
||
* @param pd
|
||
* @throws Exception
|
||
*/
|
||
public PageData findById(PageData pd)throws Exception{
|
||
|
||
return hiddenApiMapper.findById(pd);
|
||
}
|
||
public PageData confirmHidden(PageData pd) throws Exception{
|
||
PageData conPd = new PageData();
|
||
conPd.put("STATE",pd.getString("STATE"));
|
||
conPd.put("CONFIRM_USER", Jurisdiction.getUSER_ID());
|
||
conPd.put("CONFIRM_TIME",DateUtil.date2Str(new Date()));
|
||
conPd.put("RECTIFICATIONDEPT",pd.getString("RECTIFICATIONDEPT"));
|
||
conPd.put("RECTIFICATIONOR",pd.getString("RECTIFICATIONOR"));
|
||
conPd.put("RECTIFICATIONDEADLINE",pd.getString("RECTIFICATIONDEADLINE"));
|
||
conPd.put("HIDDENLEVEL",pd.getString("HIDDENLEVEL"));
|
||
conPd.put("HIDDEN_ID",pd.getString("HIDDEN_ID"));
|
||
hiddenApiMapper.confirmHidden(conPd);
|
||
return conPd;
|
||
}
|
||
/**
|
||
* 隐患整改
|
||
* @param hiddenId 隐患ID
|
||
* @param rectifyDescr 整改描述
|
||
* @param rectificationTime 整改时间
|
||
* @param havescheme 是否有整改方案 0无 1有
|
||
* @param investmentFunds 投入资金 港务局添加字段
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@Override
|
||
public int rectify(String hiddenId, String rectifyDescr,String rectificationTime, String havescheme, String investmentFunds ) throws Exception {
|
||
PageData pd = new PageData();
|
||
pd.put("RECTIFYDESCR",rectifyDescr);
|
||
pd.put("RECTIFICATIONTIME",rectificationTime);
|
||
pd.put("HAVESCHEME",havescheme);
|
||
pd.put("INVESTMENT_FUNDS",investmentFunds);
|
||
pd.put("STATE","2");
|
||
pd.put("HIDDEN_ID",hiddenId);
|
||
PageData byId = hiddenApiMapper.findById(pd);
|
||
if (byId.get("STATE").equals("-1")){
|
||
pd.put("ISEXPIREREPAIR","1");
|
||
}else{
|
||
pd.put("ISEXPIREREPAIR","0");
|
||
}
|
||
return hiddenApiMapper.rectify(pd);
|
||
}
|
||
/**验收
|
||
* @param hiddenId
|
||
* @throws Exception
|
||
*/
|
||
public void check(String hiddenId ,String checkTime)throws Exception{
|
||
PageData pd = new PageData();
|
||
pd.put("HIDDEN_ID",hiddenId);
|
||
pd.put("CHECKTIME",checkTime);
|
||
hiddenApiMapper.check(pd);
|
||
}
|
||
/**
|
||
* 验收打回
|
||
* @param hiddenId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public int repulseCheck(String hiddenId)throws Exception{
|
||
return hiddenApiMapper.repulseCheck(hiddenId);
|
||
}
|
||
public Integer goEmis (PageData pd) throws Exception{
|
||
// 1.整理数据
|
||
PageData hiddenPd = this.findById(pd); /** 确认之前,记录现在的隐患信息 */
|
||
// 隐患确认人
|
||
PageData dianjianUserPd = new PageData();
|
||
dianjianUserPd.put("USER_ID",hiddenPd.getString("CONFIRM_USER"));
|
||
PageData dianjianUser = usersService.findByIdForEmis(dianjianUserPd); //找到确认人
|
||
if(Tools.isEmpty(dianjianUser)){
|
||
return 000210;
|
||
}
|
||
|
||
if(Tools.isEmpty(dianjianUser.get("DJBM"))){
|
||
return 000211;
|
||
}
|
||
if(Tools.isEmpty(dianjianUser.get("JCR"))){
|
||
return 000212;
|
||
}
|
||
PageData hiddenRegion= hiddenRegionService.findById(hiddenPd.getString("CORPINFO_ID"),hiddenPd.getString("HIDDENPART"));
|
||
PageData hiddenRegionPar = new PageData();
|
||
if(null != hiddenRegion){
|
||
if(!hiddenRegion.getString("PARENT_ID").equals("0")){
|
||
hiddenRegionPar = hiddenRegionService.findById(hiddenPd.getString("CORPINFO_ID"),hiddenRegion.getString("PARENT_ID"));
|
||
if(!"0".equals(hiddenRegionPar.getString("PARENT_ID"))){
|
||
return 000213;
|
||
}
|
||
}
|
||
}else{
|
||
return 000214;
|
||
}
|
||
|
||
List<PageData> imgList = imgFilesService.getListByKeyAndType(hiddenPd.getString("HIDDEN_ID"),"3");
|
||
String imgStr = "";
|
||
for (PageData pageData:imgList){
|
||
imgStr += "192.168.192.201/file" + pageData.getString("FILEPATH")+";";
|
||
}
|
||
String DJSJ = DateUtil.date2Str(new Date()); // 点检时间
|
||
String BC = ""; // 班次,自动算
|
||
String DJBM = dianjianUser.get("DJBM").toString(); // 点检部门t_b_bm
|
||
String DJBC = pd.getString("DJBC"); // 点检班次
|
||
String JCR = dianjianUser.get("JCR").toString(); // 检查人
|
||
String JCLX = pd.getString("JCLX"); // 检查类型t_b_jclx--fid
|
||
String SBDL = hiddenRegionPar.getString("SBDL"); // 设备大类t_b_sbdlxx--sbdlxxdm
|
||
String SBMC = hiddenRegion.getString("SBMC");; // 设备名称t_b_shebeixx--shebeidm
|
||
String DJWT = hiddenPd.getString("HIDDENDESCR"); // 点检问题
|
||
String CJR = dianjianUser.get("JCR").toString(); // 创建人
|
||
String CJSJ = DateUtil.date2Str(new Date()); // 创建时间
|
||
String GZFL = pd.getString("GZFL"); // 故障分类 t_b_kclx
|
||
String SBZJGID = ""; // 子机构v_b_bujian_zjg
|
||
String BUJIANID = ""; // 部件v_b_bujian_bj
|
||
String PICTURE = imgStr; // 图片
|
||
|
||
StringBuffer strUrl = new StringBuffer();
|
||
strUrl.append("strDjsj=" + DJSJ);
|
||
strUrl.append("&strBc=" + "");
|
||
strUrl.append("&strDjbm=" + DJBM);
|
||
strUrl.append("&strDjbc=" + DJBC);
|
||
strUrl.append("&strJcr=" + JCR);
|
||
strUrl.append("&strJclx=" + JCLX);
|
||
strUrl.append("&strSbdl=" + SBDL);
|
||
strUrl.append("&strSbmc=" + SBMC);
|
||
strUrl.append("&strDjwt=" + DJWT);
|
||
strUrl.append("&strCjr=" + CJR);
|
||
strUrl.append("&strCjsj=" + CJSJ);
|
||
strUrl.append("&strGzfl=" + GZFL);
|
||
strUrl.append("&strSbzjgId=" + SBZJGID);
|
||
strUrl.append("&strBuJianId=" + BUJIANID);
|
||
strUrl.append("&strPicture=" + PICTURE);
|
||
String resXML = HttpEmisDuijieUtil.sendPostNoAccept(strUrl.toString());
|
||
StringBuffer strUrl2 = new StringBuffer();
|
||
strUrl2.append("djsj:" + DJSJ);
|
||
strUrl2.append(",bc:" + "");
|
||
strUrl2.append(",djbm:" + DJBM);
|
||
strUrl2.append(",djbc:" + DJBC);
|
||
strUrl2.append(",jcr:" + JCR);
|
||
strUrl2.append(",jclx:" + JCLX);
|
||
strUrl2.append(",sbdl:" + SBDL);
|
||
strUrl2.append(",sbmc:" + SBMC);
|
||
strUrl2.append(",djwt:" + DJWT);
|
||
strUrl2.append(",cjr:" + CJR);
|
||
strUrl2.append(",cjsj:" + CJSJ);
|
||
strUrl2.append(",gzfl:" + GZFL);
|
||
strUrl2.append(",sbzjgID:" + SBZJGID);
|
||
strUrl2.append(",bujianid:" + BUJIANID);
|
||
strUrl2.append(",pic:" + PICTURE);
|
||
if(strUrl2.toString().equals(resXML)){
|
||
/**
|
||
* 成功
|
||
* 1.删除现在的隐患内容
|
||
* 2.存储这次的隐患内容
|
||
*/
|
||
this.saveForEmis(hiddenPd.getString("HIDDEN_ID"),resXML);
|
||
this.deleteForEmis(hiddenPd.getString("HIDDEN_ID"));
|
||
//隐患发现人 等信息不要删除.查看对接完成的信息中查看
|
||
return 000000;
|
||
}else{
|
||
//失败
|
||
return 000215;
|
||
}
|
||
}
|
||
public void saveForEmis(String hiddenId,String resXML)throws Exception{
|
||
PageData pd = new PageData();
|
||
pd.put("HIDDEN_ID",hiddenId);
|
||
pd.put("resXML",resXML);
|
||
hiddenApiMapper.saveForEmis(pd);
|
||
}
|
||
public void deleteForEmis(String hiddenId)throws Exception{
|
||
PageData pd = new PageData();
|
||
pd.put("HIDDEN_ID",hiddenId);
|
||
hiddenApiMapper.deleteForEmis(pd);
|
||
}
|
||
|
||
/**
|
||
* 确认打回
|
||
* @param hiddenId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public int repulseConfirm(String hiddenId)throws Exception{
|
||
return hiddenApiMapper.repulseConfirm(hiddenId);
|
||
}
|
||
|
||
/**
|
||
* 隐患无法整改
|
||
* @param hiddenId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public int unableRectify(String hiddenId)throws Exception{
|
||
return hiddenApiMapper.unableRectify(hiddenId);
|
||
}
|
||
/**
|
||
* 隐患列表
|
||
* @param page
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public List<PageData> getList (Page page) throws Exception{
|
||
return hiddenApiMapper.getListdatalistPage(page);
|
||
}
|
||
/**
|
||
* 删除隐患
|
||
* @param hiddenId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public int delete (String hiddenId) throws Exception{
|
||
return hiddenApiMapper.delete(hiddenId);
|
||
}
|
||
|
||
public List<PageData> getListAll (PageData pd) throws Exception{
|
||
return hiddenApiMapper.getListAll(pd);
|
||
}
|
||
|
||
public List<PageData> goSummaryTable (PageData pd) throws Exception{
|
||
return hiddenApiMapper.goSummaryTable(pd);
|
||
}
|
||
|
||
public List<PageData> listForExcel (PageData pd) throws Exception{
|
||
return hiddenApiMapper.listForExcel(pd);
|
||
}
|
||
|
||
public List<PageData> dealData (List<PageData> pdList) throws Exception{
|
||
ArrayList<PageData> varList = new ArrayList<>();
|
||
PageData pd1 = new PageData();
|
||
pd1.put("MONTH","1月");
|
||
PageData pd2 = new PageData();
|
||
pd2.put("MONTH","2月");
|
||
PageData pd3 = new PageData();
|
||
pd3.put("MONTH","3月");
|
||
PageData pd4 = new PageData();
|
||
pd4.put("MONTH","4月");
|
||
PageData pd5 = new PageData();
|
||
pd5.put("MONTH","5月");
|
||
PageData pd6 = new PageData();
|
||
pd6.put("MONTH","6月");
|
||
PageData pd7 = new PageData();
|
||
pd7.put("MONTH","7月");
|
||
PageData pd8 = new PageData();
|
||
pd8.put("MONTH","8月");
|
||
PageData pd9 = new PageData();
|
||
pd9.put("MONTH","9月");
|
||
PageData pd10 = new PageData();
|
||
pd10.put("MONTH","10月");
|
||
PageData pd11 = new PageData();
|
||
pd11.put("MONTH","11月");
|
||
PageData pd12 = new PageData();
|
||
pd12.put("MONTH","12月");
|
||
for (int i = 0;i<pdList.size();i++) {
|
||
PageData pageData = setData(pdList.get(i));
|
||
if (pageData.getString("CREATE_MONTH").substring(5).equals("01")) {
|
||
pd1.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("02")) {
|
||
pd2.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("03")) {
|
||
pd3.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("04")) {
|
||
pd4.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("05")) {
|
||
pd5.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("06")) {
|
||
pd6.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("07")) {
|
||
pd7.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("08")) {
|
||
pd8.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("09")) {
|
||
pd9.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("10")) {
|
||
pd10.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("11")) {
|
||
pd11.putAll(pageData);
|
||
} else if (pageData.getString("CREATE_MONTH").substring(5).equals("12")) {
|
||
pd12.putAll(pageData);
|
||
}
|
||
}
|
||
varList.add(pd1);
|
||
varList.add(pd2);
|
||
varList.add(pd3);
|
||
varList.add(pd4);
|
||
varList.add(pd5);
|
||
varList.add(pd6);
|
||
varList.add(pd7);
|
||
varList.add(pd8);
|
||
varList.add(pd9);
|
||
varList.add(pd10);
|
||
varList.add(pd11);
|
||
varList.add(pd12);
|
||
return varList;
|
||
}
|
||
|
||
public PageData setData(PageData pageData) {
|
||
PageData pd = new PageData();
|
||
if (pageData.getString("DEPT_NAME").equals("公司")) {
|
||
pd.put("TOTAL_COUNT_ALL",pageData.getString("TOTAL_COUNT"));
|
||
pd.put("REVISED_COUNT_ALL",pageData.getString("REVISED_COUNT"));
|
||
pd.put("COMPLERATE_ALL",pageData.getString("COMPLERATE"));
|
||
} else if (pageData.getString("DEPT_NAME").equals("装船部")) {
|
||
pd.put("TOTAL_COUNT_ONE",pageData.getString("TOTAL_COUNT"));
|
||
pd.put("REVISED_COUNT_ONE",pageData.getString("REVISED_COUNT"));
|
||
pd.put("COMPLERATE_ONE",pageData.getString("COMPLERATE"));
|
||
} else if (pageData.getString("DEPT_NAME").equals("卸车部")) {
|
||
pd.put("TOTAL_COUNT_TWO",pageData.getString("TOTAL_COUNT"));
|
||
pd.put("REVISED_COUNT_TWO",pageData.getString("REVISED_COUNT"));
|
||
pd.put("COMPLERATE_TWO",pageData.getString("COMPLERATE"));
|
||
} else if (pageData.getString("DEPT_NAME").equals("生产保障部")) {
|
||
pd.put("TOTAL_COUNT_THREE",pageData.getString("TOTAL_COUNT"));
|
||
pd.put("REVISED_COUNT_THREE",pageData.getString("REVISED_COUNT"));
|
||
pd.put("COMPLERATE_THREE",pageData.getString("COMPLERATE"));
|
||
} else if (pageData.getString("DEPT_NAME").equals("其他部")) {
|
||
pd.put("TOTAL_COUNT_OTHER",pageData.getString("TOTAL_COUNT"));
|
||
pd.put("REVISED_COUNT_OTHER",pageData.getString("REVISED_COUNT"));
|
||
pd.put("COMPLERATE_OTHER",pageData.getString("COMPLERATE"));
|
||
}
|
||
pd.put("CREATE_MONTH",pageData.getString("CREATE_MONTH"));
|
||
return pd;
|
||
}
|
||
}
|
||
|