动火作业 service层方法

pull/4/head
fangjiakai 2024-01-19 10:23:06 +08:00
parent 2f1ef51627
commit d4e586d700
10 changed files with 459 additions and 66 deletions

View File

@ -5,11 +5,13 @@ import com.zcloud.controller.base.BaseController;
import com.zcloud.dto.Response;
import com.zcloud.dto.TenCorpConst;
import com.zcloud.dto.TenCorpDto;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.logs.LogAnno;
import com.zcloud.service.eightwork.HotworkService;
import com.zcloud.service.mq.SendMessageService;
import com.zcloud.util.DateUtil;
import com.zcloud.util.Tools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
@ -66,4 +68,26 @@ public class AppHotworkController extends BaseController {
map.put("result", errInfo); //返回结果
return map;
}
/**
* @param page
* @throws Exception
*/
@RequestMapping(value="/list")
@ResponseBody
@LogAnno(menuType= "手机",menuServer= "动火作业",instructionsOperate = "动火作业",instructionsType = "列表")
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();
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
page.setPd(pd);
List<PageData> varList = hotworkService.list(page); //列出hotwork列表
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
}

View File

@ -1,7 +1,10 @@
package com.zcloud.mapper.datasource.eightwork;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import java.util.List;
/**
* @author fangjiakai
* @date 2024/01/17 11:31
@ -10,5 +13,8 @@ public interface HotworkMapper {
PageData getCode(PageData pd);
void save(PageData pd);
void delete(PageData pd);
void edit(PageData pd);
void editStep(PageData pd);
List<PageData> datalistPage(Page page);
}

View File

@ -1,6 +1,5 @@
package com.zcloud.mapper.datasource.eightwork;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import java.util.List;
@ -25,9 +24,12 @@ public interface HotworkSignMapper {
void edit(PageData pd);
/**ID
* @param page
* @throws Exception
*/
List<PageData> listById(Page page);
List<PageData> listById(PageData pd);
/**ID
* @throws Exception
*/
List<PageData> checkUnsigned(PageData sign);
}

View File

@ -0,0 +1,55 @@
package com.zcloud.mapper.datasource.eightwork;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import java.util.List;
/**
*
* luoxiaobao
* 2021-09-18
* www.zcloudchina.com
*/
public interface HotworkToMeasuresMapper {
/**
* @param pd
* @throws Exception
*/
void save(PageData pd);
void saveBatch(List<PageData> signers);
/**
* @param pd
* @throws Exception
*/
void delete(PageData pd);
/**
* @param pd
* @throws Exception
*/
void edit(PageData pd);
/**()
* @param pd
* @throws Exception
*/
List<PageData> listAll(PageData pd);
/**id
* @param pd
* @throws Exception
*/
PageData findById(PageData pd);
/**
* @param ArrayDATA_IDS
* @throws Exception
*/
void deleteAll(String[] ArrayDATA_IDS);
}

View File

@ -1,6 +1,10 @@
package com.zcloud.service.eightwork;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @author fangjiakai
@ -11,5 +15,10 @@ public interface HotworkService {
void delete(PageData pd)throws Exception;
List<PageData> list(Page page) throws Exception;
void nextStep(PageData pd, MultipartFile file) throws Exception;
void accept(PageData pd)throws Exception;
void cancel(PageData pd)throws Exception;
}

View File

@ -4,18 +4,19 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zcloud.dto.TenCorpConst;
import com.zcloud.dto.TenCorpDto;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.mapper.datasource.eightwork.EightWorkFlowLogMapper;
import com.zcloud.mapper.datasource.eightwork.EightWorkTaskFlowMapper;
import com.zcloud.mapper.datasource.eightwork.HotworkMapper;
import com.zcloud.mapper.datasource.eightwork.HotworkSignMapper;
import com.zcloud.mapper.datasource.eightwork.*;
import com.zcloud.service.eightwork.HotworkService;
import com.zcloud.service.mq.SendMessageService;
import com.zcloud.util.Const;
import com.zcloud.util.DateUtil;
import com.zcloud.util.Smb;
import com.zcloud.util.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.text.DecimalFormat;
import java.util.*;
@ -31,14 +32,17 @@ public class HotworkServiceImpl implements HotworkService {
@Autowired
private HotworkMapper hotworkMapper;
@Autowired
private SendMessageService sendMessageService;
@Autowired
private EightWorkTaskFlowMapper eightWorkTaskFlowMapper;
@Autowired
private EightWorkFlowLogMapper eightWorkFlowLogMapper;
@Autowired
private HotworkSignMapper hotworkSignMapper;
@Autowired
private HotworkToMeasuresMapper hotworkToMeasuresMapper;
@Autowired
private Smb smb;
private final static String primary_key = "HOTWORK_ID";
@Override
@Transactional
public void save(PageData pd) throws Exception {
@ -53,37 +57,16 @@ public class HotworkServiceImpl implements HotworkService {
pd2 = hotworkMapper.getCode(pd2); //根据ID读取
String code = "DH" + year + month + day + dft.format((Integer.parseInt(pd2.get("code").toString()) + 1));
pd.put("CHECK_NO", code);
pd.put("HOTWORK_ID", UuidUtil.get32UUID()); //主键
pd.put(primary_key, UuidUtil.get32UUID()); //主键
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
pd.put("ISDELETE", "0"); //是否删除 1-是 0-否
hotworkMapper.save(pd);
List<PageData> signers = new ArrayList<>();
if (pd.get("PREPARERS") != null && !pd.get("PREPARERS").equals("")) {
List<JSONObject> list = (List<JSONObject>) JSON.parse(pd.get("PREPARERS").toString());
Object STEP_ID = getStepId(1,"PREPARE_USER_ID");
for (JSONObject json : list) {
if (json.get("DEPARTMENT_ID") != null && json.get("DEPARTMENT_ID") != "" && json.get("USER_ID") != null
&& json.get("USER_ID") != "") {
PageData preparer = new PageData();
preparer.put("HOTWORK_SIGN_ID", UuidUtil.get32UUID()); // 主键
preparer.put("HOTWORK_ID", pd.get("HOTWORK_ID"));
preparer.put("CORPINFO_ID", pd.get("CORPINFO_ID"));
preparer.put("SIGN_USER_DEPARTMENT_ID", json.get("DEPARTMENT_ID"));
preparer.put("SIGN_USER_ID", json.get("USER_ID"));
preparer.put("STEP_ID", STEP_ID);
signers.add(preparer);
}
}
}
if(signers.size() > 0){
hotworkSignMapper.saveBatch(signers);
}
if (pd.get("APPLY_STATUS").equals("1")) {
saveLog(pd);
sendMq(pd);
// PageData flow = getStep(pd.get("TASK_ID"),"1");
saveLog(pd,pd.getString("CREATOR"),"1");
// saveNext(pd,flow);
}
}
@ -93,39 +76,152 @@ public class HotworkServiceImpl implements HotworkService {
}
@Override
public void cancel(PageData pd)throws Exception{
public List<PageData> list(Page page) throws Exception {
return hotworkMapper.datalistPage(page);
}
private Object getStepId(Integer TASK_ID, String ACTOR_FIELD) throws Exception {
/*
*
*/
@Override
@Transactional
public void nextStep(PageData pd, MultipartFile file) throws Exception {
//保存签名文件
String ffile = DateUtil.getDays();
String fileName = UuidUtil.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile);
String filePath = Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName;
//保存签名信息
PageData sign = new PageData();
sign.put(primary_key, pd.get(primary_key));
sign.put("STEP_ID", pd.get("STEP_ID"));
sign.put("SIGN_USER_ID", pd.get("USER_ID"));
sign.put("SIGN_USER_DEPARTMENT_ID", pd.get("DEPARTMENT_ID"));
sign.put("SIGN_TIME", DateUtil.date2Str(new Date()));
sign.put("SIGN_PATH", filePath);
sign.put("DESCR", pd.get("DESCR"));
hotworkSignMapper.edit(sign);
if (pd.get("PREPARERS") != null && !pd.get("PREPARERS").equals("")) {
savePreparers(pd);
}
if (pd.get("MEASURES") != null && !pd.get("MEASURES").equals("")) {
saveMeasures(pd);
}
List<PageData> unsignedList = hotworkSignMapper.checkUnsigned(sign);//当前步骤未签名人列表
if(unsignedList == null || unsignedList.size() == 0){//如果没有未签人 则跳转下一步
PageData flow = getStep(pd.get("TASK_ID"), pd.get("STEP_ID"));
pd.put("STEP_ID",flow.get("NEXT_STEP_ID"));
hotworkMapper.edit(pd);
//提前保存下一步签字人
List<PageData> signers = new ArrayList<>();
PageData signer = new PageData();
signer.put("HOTWORK_SIGN_ID", UuidUtil.get32UUID()); // 主键
signer.put(primary_key, pd.get(primary_key));
signer.put("CORPINFO_ID", pd.get("CORPINFO_ID"));
signer.put("SIGN_USER_DEPARTMENT_ID", pd.get(flow.get("NEXT_ACTOR_FIELD")));
signer.put("SIGN_USER_ID", pd.get(flow.get("NEXT_ACTOR_FIELD")));
signer.put("STEP_ID", flow.get("NEXT_STEP_ID"));
signers.add(signer);
if(signers.size() > 0){
hotworkSignMapper.saveBatch(signers);
}
//保存日志
saveLog(pd,pd.getString(flow.get("ACTOR_FIELD")),"1");
}
}
private void saveMeasures(PageData pd) {
List<JSONObject> list = (List<JSONObject>) JSON.parse(pd.get("PREPARERS").toString());
for (JSONObject json : list) {
if (json.get("DEPARTMENT_ID") != null && json.get("DEPARTMENT_ID") != "" && json.get("USER_ID") != null
&& json.get("USER_ID") != "") {
PageData measure = new PageData();
measure.put("HOTWORKTOMEASURES_ID",json.get("BUS_HOTWORK_MEASURES_ID"));
measure.put("STATUS", json.get("STATUS"));
measure.put("ANSWER1", json.get("ANSWER1"));
measure.put("ANSWER2", json.get("ANSWER2"));
measure.put("ANSWER3", json.get("ANSWER3"));
measure.put("ANSWER4", json.get("ANSWER4"));
measure.put("SIGN_PATH", json.get("SIGN_PATH"));
measure.put("IMG_PATH", json.get("IMG_PATH"));
hotworkToMeasuresMapper.edit(measure);
}
}
}
private void savePreparers(PageData pd) {
List<PageData> signers = new ArrayList<>();
List<JSONObject> list = (List<JSONObject>) JSON.parse(pd.get("PREPARERS").toString());
for (JSONObject json : list) {
if (json.get("DEPARTMENT_ID") != null && json.get("DEPARTMENT_ID") != "" && json.get("USER_ID") != null
&& json.get("USER_ID") != "") {
PageData preparer = new PageData();
preparer.put("HOTWORKTOMEASURES_ID", UuidUtil.get32UUID()); // 主键
preparer.put("HOTWORK_ID", pd.get("HOTWORK_ID"));
preparer.put("BUS_HOTWORK_MEASURES_ID", json.get("BUS_HOTWORK_MEASURES_ID"));
preparer.put("CONFIRM_ID", json.get("USER_ID"));
signers.add(preparer);
}
}
if(signers.size() > 0){
hotworkToMeasuresMapper.saveBatch(signers);
}
}
/**
*
*/
@Override
public void accept(PageData pd)throws Exception{
PageData flow = getStep(pd.get("TASK_ID"), 99);
hotworkMapper.edit(pd);
saveLog(pd,pd.getString(flow.get("ACTOR_FIELD")),"1");
}
/**
*
*/
@Override
public void cancel(PageData pd)throws Exception{
PageData flow = getStep(pd.get("TASK_ID"), pd.get("STEP_ID"));
hotworkMapper.edit(pd);
saveLog(pd,pd.getString(flow.get("ACTOR_FIELD")),"-1");
}
private PageData getStep(Object TASK_ID, Object STEP_ID) throws Exception {
PageData flow = new PageData();
flow.put("TASK_ID", TASK_ID);
flow.put("ACTOR_FIELD", ACTOR_FIELD);
flow.put("STEP_ID", STEP_ID);
flow = eightWorkTaskFlowMapper.getStep(flow);
return flow.get("STEP_ID");
return flow;
}
private void saveLog(PageData pd) throws Exception {
private void saveLog(PageData pd,String act_user,String status) throws Exception {
PageData log = new PageData();
log.put("LOG_ID", UuidUtil.get32UUID());
log.put("WORK_ID", pd.get("HOTWORK_ID"));
log.put("WORK_ID", pd.get(primary_key));
log.put("TASK_ID", pd.get("TASK_ID"));
log.put("STEP_ID", pd.get("STEP_ID"));
log.put("ACT_USER", pd.get("HOTWORK_ID"));
log.put("ACT_TIME", pd.get("CREATTIME"));
log.put("STATUS", "1");
log.put("ACT_USER", act_user);
log.put("ACT_TIME", DateUtil.date2Str(new Date()));
log.put("STATUS", status);
eightWorkFlowLogMapper.save(log);
}
private void sendMq(PageData pd) throws Exception {
TenCorpDto tenCorpDto = new TenCorpDto();
tenCorpDto.setMark(pd.getString("HOTWORK_ID"));
tenCorpDto.setMark_name("HOTWORK_ID");
tenCorpDto.setTime_stamp(pd.getString("WORK_START_DATE") + ":00:000");
tenCorpDto.setTopic("eightWork");
tenCorpDto.setData(pd);
tenCorpDto.setMessage(TenCorpConst.hotWork);
// private void saveNext(PageData pd,PageData flow) throws Exception {
// PageData log = new PageData();
// log.put("LOG_ID", UuidUtil.get32UUID());
// log.put("WORK_ID", pd.get(primary_key));
// log.put("TASK_ID", pd.get("TASK_ID"));
// log.put("STEP_ID", flow.get("NEXT_STEP_ID"));
// log.put("STATUS", "0");
// eightWorkFlowLogMapper.save(log);
// }
sendMessageService.sendDelayQueue(tenCorpDto);
}
}

View File

@ -55,13 +55,19 @@
<select id="getStep" parameterType="pd" resultType="pd" >
select
<include refid="Field"></include>
<include refid="Field"></include>,
n.STEP_ID as NEXT_STEP_ID,
n.ACTOR_FIELD as NEXT_ACTOR_FIELD
from
<include refid="tableName"></include>
<include refid="tableName"></include> f
left join
<include refid="tableName"></include> n
on
f.NEXT_STEP_ID = n.STEP_ID and f.TASK_ID = n.TASK_ID
where
TASK_ID = #{TASK_ID}
f.TASK_ID = #{TASK_ID}
and
ACTOR_FIELD = #{ACTOR_FIELD}
f.STEP_ID = #{STEP_ID}
</select>
</mapper>

View File

@ -3,7 +3,7 @@
<mapper namespace="com.zcloud.mapper.datasource.eightwork.HotworkMapper">
<!--表名 -->
<sql id="tableName">
BUS_HIGHWORK
BUS_HOTWORK
</sql>
<!-- 字段 -->
@ -220,4 +220,38 @@
where
HIGHWORK_ID = #{HIGHWORK_ID}
</update>
<!-- 修改 -->
<update id="editStep" parameterType="pd">
update
<include refid="tableName"></include>
set
STEP_ID = #{pd.STEP_ID}
where
HIGHWORK_ID = #{HIGHWORK_ID}
</update>
<!-- 列表 -->
<select id="datalistPage" parameterType="page" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where f.ISDELETE = '0'
<if test="pd.STEP_NAME != null and pd.STEP_NAME != ''"><!-- 关键词检索 -->
and exists (
select 1 from bus_hotwork_sign sign
left join bus_eightwork_step step on step.STEP_ID = sign.STEP_ID
where sign.HIGHWORK_ID = f.HIGHWORK_ID
and sign.SIGN_TIME is null
and sign.SIGN_USER_ID = #{pd.USER_ID}
and step.STEP_NAME = #{pd.STEP_NAME}
)
</if>
<if test="pd.CREATOR != null and pd.CREATOR != ''"><!-- 关键词检索 -->
and f.CREATOR = #{pd.CREATOR}
</if>
<if test="pd.GASCHECK != null and pd.GASCHECK != ''"><!-- 关键词检索 -->
and f.
</if>
</select>
</mapper>

View File

@ -66,17 +66,21 @@
insert into
<include refid="tableName"></include>
(
<include refid="Field2"></include>
) values (
HOTWORK_SIGN_ID,
HOTWORK_ID,
CORPINFO_ID,
SIGN_USER_DEPARTMENT_ID,
SIGN_USER_ID,
STEP_ID
) values
<foreach collection="list" item="item" index="index" separator="," >
#{item.HOTWORK_SIGN_ID},
(#{item.HOTWORK_SIGN_ID},
#{item.HOTWORK_ID},
#{item.CORPINFO_ID},
#{item.SIGN_USER_DEPARTMENT_ID},
#{item.SIGN_USER_ID},
#{item.STEP_ID}
#{item.STEP_ID})
</foreach>
)
</insert>
<!-- 修改 -->
@ -88,10 +92,10 @@
SIGN_PATH = #{SIGN_PATH},
SIGN_TIME= #{SIGN_TIME},
where
HOTWORK_ID = #{HOTWORK_ID} and SIGN_USER_ID = #{SIGN_USER_ID}
HOTWORK_ID = #{HOTWORK_ID} and SIGN_USER_ID = #{SIGN_USER_ID} and STEP_ID = #{STEP_ID}
</update>
<select id="listById" parameterType="page" resultType="pd">
<select id="listById" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
@ -101,4 +105,16 @@
order by f.SIGN_TIME desc
</select>
<select id="checkUnsigned" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where
f.HOTWORK_ID = #{pd.HOTWORK_ID}
and
f.SIGN_TIME is null
</select>
</mapper>

View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zcloud.mapper.datasource.eightwork.HotworkToMeasuresMapper">
<!--表名 -->
<sql id="tableName">
BUS_HOTWORKTOMEASURES
</sql>
<!--数据字典表名 -->
<sql id="dicTableName">
SYS_DICTIONARIES
</sql>
<!-- 字段 -->
<sql id="Field">
f.HOTWORK_ID,
f.BUS_HOTWORK_MEASURES_ID,
f.STATUS,
f.ANSWER1,
f.ANSWER2,
f.ANSWER3,
f.ANSWER4,
f.HOTWORKTOMEASURES_ID,
f.CONFIRM_ID,
f.SIGN_PATH,
f.IMG_PATH
</sql>
<!-- 字段用于新增 -->
<sql id="Field2">
HOTWORK_ID,
BUS_HOTWORK_MEASURES_ID,
STATUS,
ANSWER1,
ANSWER2,
ANSWER3,
ANSWER4,
HOTWORKTOMEASURES_ID,
CONFIRM_ID,
SIGN_PATH,
IMG_PATH
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{HOTWORK_ID},
#{BUS_HOTWORK_MEASURES_ID},
#{STATUS},
#{ANSWER1},
#{ANSWER2},
#{ANSWER3},
#{ANSWER4},
#{HOTWORKTOMEASURES_ID},
#{CONFIRM_ID},
#{SIGN_PATH},
#{IMG_PATH}
</sql>
<!-- 新增-->
<insert id="save" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field2"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
<insert id="saveBatch" parameterType="pd">
insert into
<include refid="tableName"></include>
(
HOTWORK_ID,
BUS_HOTWORK_MEASURES_ID,
HOTWORKTOMEASURES_ID,
CONFIRM_ID
) values
<foreach collection="list" item="item" index="index" open="(" separator="),(" close=")">
(
#{item.HOTWORK_ID},
#{item.BUS_HOTWORK_MEASURES_ID},
#{item.HOTWORKTOMEASURES_ID},
#{item.CONFIRM_ID}
)
</foreach>
</insert>
<!-- 删除-->
<delete id="delete" parameterType="pd">
delete from
<include refid="tableName"></include>
where
HOTWORK_ID = #{HOTWORK_ID}
</delete>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
STATUS = #{STATUS},
ANSWER1 = #{ANSWER1},
ANSWER2 = #{ANSWER2},
ANSWER3 = #{ANSWER3},
ANSWER4 = #{ANSWER4},
SIGN_PATH = #{SIGN_PATH},
IMG_PATH = #{IMG_PATH}
where
HOTWORKTOMEASURES_ID = #{HOTWORKTOMEASURES_ID}
</update>
<!-- 通过ID获取数据 -->
<select id="findById" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where
f.HOTWORKTOMEASURES_ID = #{HOTWORKTOMEASURES_ID}
</select>
<!-- 列表(全部) -->
<select id="listAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
</select>
<!-- 批量删除 -->
<delete id="deleteAll" parameterType="String">
update
<include refid="tableName"></include>
set
ISDELETE = '1'
where
HOTWORKTOMEASURES_ID in
<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</mapper>