java110-core/src/main/java/com/java110/core/context/CmdContextUtils.java
New file @@ -0,0 +1,156 @@ package com.java110.core.context; import com.java110.utils.constant.CommonConstant; import java.util.Map; /** * cmd 上下文工具类 */ public class CmdContextUtils { /** * 查询用户ID * * @param context * @return */ public static final String getUserId(ICmdDataFlowContext context) { if (context == null) { return ""; } Map<String, String> headers = context.getReqHeaders(); if (headers.containsKey(CommonConstant.HTTP_USER_ID)) { return headers.get(CommonConstant.HTTP_USER_ID); } return ""; } /** * 查询商户ID * * @param context * @return */ public static final String getStoreId(ICmdDataFlowContext context) { if (context == null) { return ""; } Map<String, String> headers = context.getReqHeaders(); if (headers.containsKey(CommonConstant.STORE_ID)) { return headers.get(CommonConstant.STORE_ID); } return ""; } /** * 查询回话ID * * @param context * @return */ public static final String getSessionId(ICmdDataFlowContext context) { if (context == null) { return ""; } Map<String, String> headers = context.getReqHeaders(); if (headers.containsKey(CommonConstant.HTTP_SESSION_ID)) { return headers.get(CommonConstant.HTTP_SESSION_ID); } return ""; } /** * 查询 AppId * * @param context * @return */ public static final String getAppId(ICmdDataFlowContext context) { if (context == null) { return ""; } Map<String, String> headers = context.getReqHeaders(); if (headers.containsKey(CommonConstant.APP_ID)) { return headers.get(CommonConstant.APP_ID); } return ""; } /** * 查询 登录用户ID * * @param context * @return */ public static final String getLoginUserId(ICmdDataFlowContext context) { if (context == null) { return ""; } Map<String, String> headers = context.getReqHeaders(); if (headers.containsKey(CommonConstant.LOGIN_U_ID)) { return headers.get(CommonConstant.LOGIN_U_ID); } return ""; } /** * 查询 登录用户ID * * @param context * @return */ public static final String getTransactionId(ICmdDataFlowContext context) { if (context == null) { return ""; } Map<String, String> headers = context.getReqHeaders(); if (headers.containsKey(CommonConstant.TRANSACTION_ID)) { return headers.get(CommonConstant.TRANSACTION_ID); } return ""; } public static final String getRequestTime(ICmdDataFlowContext context) { if (context == null) { return ""; } Map<String, String> headers = context.getReqHeaders(); if (headers.containsKey(CommonConstant.REQUEST_TIME)) { return headers.get(CommonConstant.REQUEST_TIME); } return ""; } public static final String getLang(ICmdDataFlowContext context) { if (context == null) { return ""; } Map<String, String> headers = context.getReqHeaders(); if (headers.containsKey(CommonConstant.LANG_ZH_CN)) { return headers.get(CommonConstant.LANG_ZH_CN); } return ""; } } java110-db/src/main/resources/mapper/store/ResourceAuditFlowV1ServiceDaoImplMapper.xml
@@ -5,111 +5,107 @@ <mapper namespace="resourceAuditFlowV1ServiceDaoImpl"> <!-- 保存物品流程信息 add by wuxw 2018-07-03 --> <insert id="saveResourceAuditFlowInfo" parameterType="Map"> insert into resource_audit_flow( raf_id,remark,store_id,flow_id,flow_name,flow_type ) values ( #{rafId},#{remark},#{storeId},#{flowId},#{flowName},#{flowType} ) raf_id,remark,store_id,flow_id,flow_name,flow_type ) values ( #{rafId},#{remark},#{storeId},#{flowId},#{flowName},#{flowType} ) </insert> <!-- 查询物品流程信息 add by wuxw 2018-07-03 --> <select id="getResourceAuditFlowInfo" parameterType="Map" resultType="Map"> select t.raf_id,t.raf_id rafId,t.remark,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id storeId,t.flow_id,t.flow_id flowId,t.flow_name,t.flow_name flowName,t.flow_type,t.flow_type flowType from resource_audit_flow t where 1 =1 <if test="rafId !=null and rafId != ''"> and t.raf_id= #{rafId} </if> <if test="remark !=null and remark != ''"> and t.remark= #{remark} </if> <if test="statusCd !=null and statusCd != ''"> and t.status_cd= #{statusCd} </if> <if test="storeId !=null and storeId != ''"> and t.store_id= #{storeId} </if> <if test="flowId !=null and flowId != ''"> and t.flow_id= #{flowId} </if> <if test="flowName !=null and flowName != ''"> and t.flow_name= #{flowName} </if> <if test="flowType !=null and flowType != ''"> and t.flow_type= #{flowType} </if> order by t.create_time desc <if test="page != -1 and page != null "> limit #{page}, #{row} </if> select t.raf_id,t.raf_id rafId,t.remark,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id storeId,t.flow_id,t.flow_id flowId,t.flow_name,t.flow_name flowName,t.flow_type,t.flow_type flowType from resource_audit_flow t where 1 =1 <if test="rafId !=null and rafId != ''"> and t.raf_id= #{rafId} </if> <if test="remark !=null and remark != ''"> and t.remark= #{remark} </if> <if test="statusCd !=null and statusCd != ''"> and t.status_cd= #{statusCd} </if> <if test="storeId !=null and storeId != ''"> and t.store_id= #{storeId} </if> <if test="flowId !=null and flowId != ''"> and t.flow_id= #{flowId} </if> <if test="flowName !=null and flowName != ''"> and t.flow_name= #{flowName} </if> <if test="flowType !=null and flowType != ''"> and t.flow_type= #{flowType} </if> order by t.create_time desc <if test="page != -1 and page != null "> limit #{page}, #{row} </if> </select> <!-- 修改物品流程信息 add by wuxw 2018-07-03 --> <update id="updateResourceAuditFlowInfo" parameterType="Map"> update resource_audit_flow t set t.status_cd = #{statusCd} <if test="newBId != null and newBId != ''"> ,t.b_id = #{newBId} </if> <if test="remark !=null and remark != ''"> , t.remark= #{remark} </if> <if test="storeId !=null and storeId != ''"> , t.store_id= #{storeId} </if> <if test="flowId !=null and flowId != ''"> , t.flow_id= #{flowId} </if> <if test="flowName !=null and flowName != ''"> , t.flow_name= #{flowName} </if> <if test="flowType !=null and flowType != ''"> , t.flow_type= #{flowType} </if> where 1=1 <if test="rafId !=null and rafId != ''"> and t.raf_id= #{rafId} </if> update resource_audit_flow t set t.status_cd = #{statusCd} <if test="newBId != null and newBId != ''"> ,t.b_id = #{newBId} </if> <if test="remark !=null and remark != ''"> , t.remark= #{remark} </if> <if test="storeId !=null and storeId != ''"> , t.store_id= #{storeId} </if> <if test="flowId !=null and flowId != ''"> , t.flow_id= #{flowId} </if> <if test="flowName !=null and flowName != ''"> , t.flow_name= #{flowName} </if> <if test="flowType !=null and flowType != ''"> , t.flow_type= #{flowType} </if> where 1=1 <if test="rafId !=null and rafId != ''"> and t.raf_id= #{rafId} </if> </update> <!-- 查询物品流程数量 add by wuxw 2018-07-03 --> <select id="queryResourceAuditFlowsCount" parameterType="Map" resultType="Map"> select count(1) count from resource_audit_flow t where 1 =1 <if test="rafId !=null and rafId != ''"> and t.raf_id= #{rafId} </if> <if test="remark !=null and remark != ''"> and t.remark= #{remark} </if> <if test="statusCd !=null and statusCd != ''"> and t.status_cd= #{statusCd} </if> <if test="storeId !=null and storeId != ''"> and t.store_id= #{storeId} </if> <if test="flowId !=null and flowId != ''"> and t.flow_id= #{flowId} </if> <if test="flowName !=null and flowName != ''"> and t.flow_name= #{flowName} </if> <if test="flowType !=null and flowType != ''"> and t.flow_type= #{flowType} </if> <select id="queryResourceAuditFlowsCount" parameterType="Map" resultType="Map"> select count(1) count from resource_audit_flow t where 1 =1 <if test="rafId !=null and rafId != ''"> and t.raf_id= #{rafId} </if> <if test="remark !=null and remark != ''"> and t.remark= #{remark} </if> <if test="statusCd !=null and statusCd != ''"> and t.status_cd= #{statusCd} </if> <if test="storeId !=null and storeId != ''"> and t.store_id= #{storeId} </if> <if test="flowId !=null and flowId != ''"> and t.flow_id= #{flowId} </if> <if test="flowName !=null and flowName != ''"> and t.flow_name= #{flowName} </if> <if test="flowType !=null and flowType != ''"> and t.flow_type= #{flowType} </if> </select> </select> </mapper> java110-utils/src/main/java/com/java110/utils/constant/CommonConstant.java
@@ -87,7 +87,7 @@ public final static String TEMPLATE_URL_INSERT = "INSERT->"; public final static String TEMPLATE_URL_SPILT = ";"; public final static String HTTP_SESSION_ID = "session-id"; /** * 添加数据 */ service-dev/src/main/java/com/java110/dev/cmd/menu/DeleteMenuCmd.java
@@ -12,6 +12,7 @@ import com.java110.utils.exception.ListenerExecuteException; import com.java110.utils.util.Assert; import com.java110.utils.util.BeanConvertUtil; import com.java110.vo.ResultVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -37,8 +38,7 @@ throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "删除数据失败"); } ResponseEntity<String> responseEntity = new ResponseEntity<String>("", HttpStatus.OK); context.setResponseEntity(responseEntity); context.setResponseEntity(ResultVo.success()); } } service-store/src/main/java/com/java110/store/cmd/resourceStore/DeleteResourceAuditFlowCmd.java
@@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject; import com.java110.core.annotation.Java110Cmd; import com.java110.core.annotation.Java110Transactional; import com.java110.core.context.CmdContextUtils; import com.java110.core.context.ICmdDataFlowContext; import com.java110.core.event.cmd.Cmd; import com.java110.core.event.cmd.CmdEvent; @@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * 类表述:删除 * 服务编码:resourceAuditFlow.deleteResourceAuditFlow @@ -42,7 +44,7 @@ */ @Java110Cmd(serviceCode = "resourceStore.deleteResourceAuditFlow") public class DeleteResourceAuditFlowCmd extends Cmd { private static Logger logger = LoggerFactory.getLogger(DeleteResourceAuditFlowCmd.class); private static Logger logger = LoggerFactory.getLogger(DeleteResourceAuditFlowCmd.class); @Autowired private IResourceAuditFlowV1InnerServiceSMO resourceAuditFlowV1InnerServiceSMOImpl; @@ -50,15 +52,16 @@ @Override public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) { Assert.hasKeyAndValue(reqJson, "rafId", "rafId不能为空"); Assert.hasKeyAndValue(reqJson, "storeId", "storeId不能为空"); } @Override @Java110Transactional public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { String storeId = CmdContextUtils.getStoreId(cmdDataFlowContext); ResourceAuditFlowPo resourceAuditFlowPo = BeanConvertUtil.covertBean(reqJson, ResourceAuditFlowPo.class); ResourceAuditFlowPo resourceAuditFlowPo = BeanConvertUtil.covertBean(reqJson, ResourceAuditFlowPo.class); resourceAuditFlowPo.setStoreId(storeId); int flag = resourceAuditFlowV1InnerServiceSMOImpl.deleteResourceAuditFlow(resourceAuditFlowPo); if (flag < 1) { service-store/src/main/java/com/java110/store/cmd/resourceStore/ListResourceAuditFlowCmd.java
@@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSONObject; import com.java110.core.annotation.Java110Cmd; import com.java110.core.context.CmdContextUtils; import com.java110.core.context.ICmdDataFlowContext; import com.java110.core.event.cmd.Cmd; import com.java110.core.event.cmd.CmdEvent; @@ -26,8 +27,10 @@ import com.java110.vo.ResultVo; import org.springframework.beans.factory.annotation.Autowired; import com.java110.dto.resource.ResourceAuditFlowDto; import java.util.List; import java.util.ArrayList; import org.springframework.http.ResponseEntity; import org.springframework.http.HttpStatus; import org.slf4j.Logger; @@ -47,7 +50,7 @@ @Java110Cmd(serviceCode = "resourceStore.listResourceAuditFlow") public class ListResourceAuditFlowCmd extends Cmd { private static Logger logger = LoggerFactory.getLogger(ListResourceAuditFlowCmd.class); private static Logger logger = LoggerFactory.getLogger(ListResourceAuditFlowCmd.class); @Autowired private IResourceAuditFlowV1InnerServiceSMO resourceAuditFlowV1InnerServiceSMOImpl; @@ -59,22 +62,24 @@ @Override public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { ResourceAuditFlowDto resourceAuditFlowDto = BeanConvertUtil.covertBean(reqJson, ResourceAuditFlowDto.class); String storeId = CmdContextUtils.getStoreId(cmdDataFlowContext); int count = resourceAuditFlowV1InnerServiceSMOImpl.queryResourceAuditFlowsCount(resourceAuditFlowDto); ResourceAuditFlowDto resourceAuditFlowDto = BeanConvertUtil.covertBean(reqJson, ResourceAuditFlowDto.class); resourceAuditFlowDto.setStoreId(storeId); int count = resourceAuditFlowV1InnerServiceSMOImpl.queryResourceAuditFlowsCount(resourceAuditFlowDto); List<ResourceAuditFlowDto> resourceAuditFlowDtos = null; List<ResourceAuditFlowDto> resourceAuditFlowDtos = null; if (count > 0) { resourceAuditFlowDtos = resourceAuditFlowV1InnerServiceSMOImpl.queryResourceAuditFlows(resourceAuditFlowDto); } else { resourceAuditFlowDtos = new ArrayList<>(); } if (count > 0) { resourceAuditFlowDtos = resourceAuditFlowV1InnerServiceSMOImpl.queryResourceAuditFlows(resourceAuditFlowDto); } else { resourceAuditFlowDtos = new ArrayList<>(); } ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, resourceAuditFlowDtos); ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, resourceAuditFlowDtos); ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); cmdDataFlowContext.setResponseEntity(responseEntity); cmdDataFlowContext.setResponseEntity(responseEntity); } } service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveResourceAuditFlowCmd.java
@@ -18,11 +18,17 @@ import com.alibaba.fastjson.JSONObject; import com.java110.core.annotation.Java110Cmd; import com.java110.core.annotation.Java110Transactional; import com.java110.core.context.CmdContextUtils; import com.java110.core.context.ICmdDataFlowContext; import com.java110.core.event.cmd.Cmd; import com.java110.core.event.cmd.CmdEvent; import com.java110.core.factory.GenerateCodeFactory; import com.java110.dto.oaWorkflow.OaWorkflowDto; import com.java110.dto.oaWorkflow.WorkflowModelDto; import com.java110.intf.common.IWorkflowInnerServiceSMO; import com.java110.intf.oa.IOaWorkflowInnerServiceSMO; import com.java110.intf.store.IResourceAuditFlowV1InnerServiceSMO; import com.java110.po.oaWorkflow.OaWorkflowPo; import com.java110.po.resource.ResourceAuditFlowPo; import com.java110.utils.exception.CmdException; import com.java110.utils.util.Assert; @@ -52,20 +58,49 @@ @Autowired private IResourceAuditFlowV1InnerServiceSMO resourceAuditFlowV1InnerServiceSMOImpl; @Autowired private IWorkflowInnerServiceSMO workflowInnerServiceSMOImpl; @Autowired private IOaWorkflowInnerServiceSMO oaWorkflowInnerServiceSMOImpl; @Override public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) { Assert.hasKeyAndValue(reqJson, "flowType", "请求报文中未包含flowType"); Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId"); Assert.hasKeyAndValue(reqJson, "flowName", "请求报文中未包含flowType"); } @Override @Java110Transactional public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { String storeId = CmdContextUtils.getStoreId(cmdDataFlowContext); ResourceAuditFlowPo resourceAuditFlowPo = BeanConvertUtil.covertBean(reqJson, ResourceAuditFlowPo.class); OaWorkflowPo oaWorkflowPo = new OaWorkflowPo(); oaWorkflowPo.setStoreId(storeId); oaWorkflowPo.setFlowId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_flowId)); oaWorkflowPo.setFlowName(reqJson.getString("flowName") + "审批流程"); oaWorkflowPo.setFlowType(OaWorkflowDto.FLOW_TYPE_ITEM_RELEASE); //创建model WorkflowModelDto workflowModelDto = new WorkflowModelDto(); workflowModelDto.setName(oaWorkflowPo.getFlowName()); workflowModelDto.setKey(oaWorkflowPo.getFlowId()); workflowModelDto = workflowInnerServiceSMOImpl.createModel(workflowModelDto); oaWorkflowPo.setModelId(workflowModelDto.getModelId()); oaWorkflowPo.setFlowKey(workflowModelDto.getKey()); oaWorkflowPo.setState(OaWorkflowDto.STATE_WAIT); int flag = oaWorkflowInnerServiceSMOImpl.saveOaWorkflow(oaWorkflowPo); if (flag < 1) { throw new CmdException("保存数据失败"); } ResourceAuditFlowPo resourceAuditFlowPo = BeanConvertUtil.covertBean(reqJson, ResourceAuditFlowPo.class); resourceAuditFlowPo.setStoreId(storeId); resourceAuditFlowPo.setRafId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); int flag = resourceAuditFlowV1InnerServiceSMOImpl.saveResourceAuditFlow(resourceAuditFlowPo); resourceAuditFlowPo.setFlowId(oaWorkflowPo.getFlowId()); flag = resourceAuditFlowV1InnerServiceSMOImpl.saveResourceAuditFlow(resourceAuditFlowPo); if (flag < 1) { throw new CmdException("保存数据失败"); service-store/src/main/java/com/java110/store/cmd/resourceStore/UpdateResourceAuditFlowCmd.java
@@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject; import com.java110.core.annotation.Java110Cmd; import com.java110.core.annotation.Java110Transactional; import com.java110.core.context.CmdContextUtils; import com.java110.core.context.ICmdDataFlowContext; import com.java110.core.event.cmd.Cmd; import com.java110.core.event.cmd.CmdEvent; @@ -54,15 +55,16 @@ @Override public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) { Assert.hasKeyAndValue(reqJson, "rafId", "rafId不能为空"); Assert.hasKeyAndValue(reqJson, "storeId", "storeId不能为空"); } @Override @Java110Transactional public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { String storeId = CmdContextUtils.getStoreId(cmdDataFlowContext); ResourceAuditFlowPo resourceAuditFlowPo = BeanConvertUtil.covertBean(reqJson, ResourceAuditFlowPo.class); resourceAuditFlowPo.setStoreId(storeId); int flag = resourceAuditFlowV1InnerServiceSMOImpl.updateResourceAuditFlow(resourceAuditFlowPo); if (flag < 1) {