ylx %!s(int64=7) %!d(string=hai) anos
pai
achega
84e2eb4e9f

+ 17 - 10
saicLogistics/src/main/java/com/fuzamei/entity/OperationHistoryAdmin.java

@@ -2,9 +2,10 @@ package com.fuzamei.entity;
 
 public class OperationHistoryAdmin {
 	private Integer id;					//主键id
-	private Integer operatorId;			//操作人id
+	private String operatorName;		//操作人名
 	private Integer operationTypeId;	//操作类型id
-	private Integer beOperatedId;		//被操作人id
+	private String operationTypeName;	//操作类型名
+	private String beOperatedName;		//被操作人名
 	private Long operationTime;			//操作时间
 	private String hash;				//操作hash
 	public Integer getId() {
@@ -13,11 +14,11 @@ public class OperationHistoryAdmin {
 	public void setId(Integer id) {
 		this.id = id;
 	}
-	public Integer getOperatorId() {
-		return operatorId;
+	public String getOperatorName() {
+		return operatorName;
 	}
-	public void setOperatorId(Integer operatorId) {
-		this.operatorId = operatorId;
+	public void setOperatorName(String operatorName) {
+		this.operatorName = operatorName;
 	}
 	public Integer getOperationTypeId() {
 		return operationTypeId;
@@ -25,11 +26,17 @@ public class OperationHistoryAdmin {
 	public void setOperationTypeId(Integer operationTypeId) {
 		this.operationTypeId = operationTypeId;
 	}
-	public Integer getBeOperatedId() {
-		return beOperatedId;
+	public String getOperationTypeName() {
+		return operationTypeName;
 	}
-	public void setBeOperatedId(Integer beOperatedId) {
-		this.beOperatedId = beOperatedId;
+	public void setOperationTypeName(String operationTypeName) {
+		this.operationTypeName = operationTypeName;
+	}
+	public String getBeOperatedName() {
+		return beOperatedName;
+	}
+	public void setBeOperatedName(String beOperatedName) {
+		this.beOperatedName = beOperatedName;
 	}
 	public Long getOperationTime() {
 		return operationTime;

+ 7 - 0
saicLogistics/src/main/java/com/fuzamei/entity/Params.java

@@ -40,6 +40,13 @@ public class Params {
 	private Long operationTime;			//操作时间
 	private UserDetail userDetail;		//用户详细信息对象
 	private Orders order;				//整个订单详细信息
+	private String hash;				//区块链查询用的hash值
+	public String getHash() {
+		return hash;
+	}
+	public void setHash(String hash) {
+		this.hash = hash;
+	}
 	public String getSign() {
 		return sign;
 	}

+ 82 - 6
saicLogistics/src/main/java/com/fuzamei/mapper/OperationHistoryMapper.xml

@@ -8,19 +8,24 @@
 			operation_history(order_id,
 						  	  operation_type_id,
 						  	  operator_id,
-						      operation_time)
+						      operation_time,
+						      hash)
 			values(#{orderId},
 				   #{operationTypeId},
 				   #{operatorId},
-				   #{operationTime}) 
+				   #{operationTime},
+				   #{hash}) 
 	</insert>
 	
 	<select id="queryOperationHistory" parameterType="Params" resultType="OperationHistory">
 		select
 			oh.order_id,
+			oh.operation_type_id,
+			oh.operator_id,
 			ot.operation_type_name,
-			u.person_name as operatorName,
-			oh.operation_time
+			u.person_name as operator_name,
+			oh.operation_time,
+			oh.hash
 		from 
 			operation_history oh
 		left join 
@@ -32,8 +37,12 @@
 		on 
 			oh.operator_id=u.user_id
 		<where>
+			oh.operator_id=#{userId}
+			<if test="operationTypeId!=null">
+				and oh.operation_type_id=#{operationTypeId}
+			</if>
 			<if test="startTime!=null and endTime!=null">
-				oh.operation_time between #{startTime} and #{endTime}
+				and oh.operation_time between #{startTime} and #{endTime}
 			</if>
 		</where>
 		order by oh.operation_time desc
@@ -46,8 +55,75 @@
 		from 
 			operation_history
 		<where>
+			operator_id=#{userId}
+			<if test="operationTypeId!=null">
+				operation_type_id=#{operationTypeId}
+			</if>
+			<if test="startTime!=null and endTime!=null">
+				and operation_time between #{startTime} and #{endTime}
+			</if>
+		</where>
+	</select>
+	
+	
+	<select id="showAllOperationTypeOfUser" resultType="OperationType">
+		select * from operation_type where operation_type_id in(1,2,3,4,5)
+	</select>
+	
+	<select id="showAllOperationTypeOfAdmin" resultType="OperationType">
+		select * from operation_type where operation_type_id in(6,7,8)
+	</select>
+	
+	
+	<select id="queryOperationHistoryByAdmin" parameterType="Params" resultType="OperationHistoryAdmin">
+		select 
+			oha.operation_time,
+			oha.operation_type_id,
+			oha.operator_id,
+			ot.operation_type_name,
+			oha.hash,
+			u1.person_name as operator_name,
+			u2.person_name as be_operated_name			
+		from 
+			operation_history_admin oha
+		left join 
+			operation_type ot
+		on 
+			oha.operation_type_id=ot.operation_type_id
+		left join 
+			users u1
+		on 
+			oha.operator_id=u1.user_id
+		left join 
+			users u2
+		on 
+			oha.be_operated_id=u2.user_id
+		<where>
+			oha.operator_id=#{userId}
+			<if test="operationTypeId!=null">
+				and oha.operation_type_id=#{operationTypeId}
+			</if>
+			<if test="startTime!=null and endTime!=null">
+				and oha.operation_time between #{startTime} and #{endTime}
+			</if>
+		</where>
+		order by oha.operation_time desc
+		limit #{startPage},#{rowNum}
+	</select>
+	
+	
+	<select id="findQueryCountByAdmin" parameterType="Params" resultType="int">
+		select
+			count(*)
+		from 
+			operation_history
+		<where>
+			operator_id=#{userId}
+			<if test="operationTypeId!=null">
+				and operation_type_id=#{operationTypeId}
+			</if>
 			<if test="startTime!=null and endTime!=null">
-				operation_time between #{startTime} and #{endTime}
+				and operation_time between #{startTime} and #{endTime}
 			</if>
 		</where>
 	</select>

+ 10 - 0
saicLogistics/src/main/java/com/fuzamei/mapperInterface/OperationHistoryMapper.java

@@ -3,6 +3,8 @@ package com.fuzamei.mapperInterface;
 import java.util.List;
 
 import com.fuzamei.entity.OperationHistory;
+import com.fuzamei.entity.OperationHistoryAdmin;
+import com.fuzamei.entity.OperationType;
 import com.fuzamei.entity.Params;
 import com.fuzamei.entity.SendOrder;
 
@@ -14,4 +16,12 @@ public interface OperationHistoryMapper {
 
 	int findQueryCount(Params params);
 
+	List<OperationType> showAllOperationTypeOfUser();
+
+	List<OperationType> showAllOperationTypeOfAdmin();
+
+	List<OperationHistoryAdmin> queryOperationHistoryByAdmin(Params params);
+
+	int findQueryCountByAdmin(Params params);
+
 }

+ 9 - 0
saicLogistics/src/main/java/com/fuzamei/service/OperationHistoryService.java

@@ -1,5 +1,8 @@
 package com.fuzamei.service;
 
+import java.util.List;
+
+import com.fuzamei.entity.OperationType;
 import com.fuzamei.entity.Params;
 import com.fuzamei.util.PageDTO;
 
@@ -7,4 +10,10 @@ public interface OperationHistoryService {
 
 	PageDTO queryOperationHistory(Params params);
 
+	List<OperationType> showAllOperationTypeOfUser();
+
+	List<OperationType> showAllOperationTypeOfAdmin();
+
+	PageDTO queryOperationHistoryByAdmin(Params params);
+
 }

+ 22 - 0
saicLogistics/src/main/java/com/fuzamei/service/serviceImpl/OperationHistoryServiceImpl.java

@@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.fuzamei.entity.OperationHistory;
+import com.fuzamei.entity.OperationHistoryAdmin;
+import com.fuzamei.entity.OperationType;
 import com.fuzamei.entity.Params;
 import com.fuzamei.entity.SendOrder;
 import com.fuzamei.mapperInterface.OperationHistoryMapper;
@@ -26,6 +28,26 @@ public class OperationHistoryServiceImpl implements OperationHistoryService {
 		pageDto.setTotal(count);
 		return pageDto;
 	}
+
+	@Override
+	public List<OperationType> showAllOperationTypeOfUser() {
+		return operationHistoryMapper.showAllOperationTypeOfUser();
+	}
+
+	@Override
+	public List<OperationType> showAllOperationTypeOfAdmin() {
+		return operationHistoryMapper.showAllOperationTypeOfAdmin();
+	}
+
+	@Override
+	public PageDTO queryOperationHistoryByAdmin(Params params) {
+		PageDTO pageDto=new PageDTO();
+		List<OperationHistoryAdmin> orderList = operationHistoryMapper.queryOperationHistoryByAdmin(params);
+		int count = operationHistoryMapper.findQueryCountByAdmin(params);
+		pageDto.setRows(orderList);
+		pageDto.setTotal(count);
+		return pageDto;
+	}
 	
 	
 }

+ 11 - 0
saicLogistics/src/main/java/com/fuzamei/service/serviceImpl/OrdersIssueServiceImpl.java

@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.alibaba.fastjson.JSON;
 import com.fuzamei.constant.OperationType;
 import com.fuzamei.constant.Role;
 import com.fuzamei.constant.Statuses;
@@ -60,6 +61,10 @@ public class OrdersIssueServiceImpl implements OrdersIssueService {
 	@Override
 	@Transactional(rollbackFor=Exception.class)
 	public void consignment(Params params) {
+		String sign = params.getSign();
+		@SuppressWarnings("unchecked")
+		Map<String,Object> map = JSON.parseObject(sign, Map.class);
+		String hash = (String) map.get("sid");
 		Long currentTime = System.currentTimeMillis();
 		//更新【订单表】
 		params.setSendTime(currentTime);
@@ -71,6 +76,7 @@ public class OrdersIssueServiceImpl implements OrdersIssueService {
 		params.setOperatorId(params.getUserId());
 		params.setOperationTime(currentTime);
 		operationHistoryMapper.addToHistory(params);
+		params.setHash(hash);
 		boolean flag = blockChainUtil.sendBlockChain(params.getSign());
 		if(!flag) throw new RuntimeException("区块链操作失败");
 	}
@@ -78,6 +84,10 @@ public class OrdersIssueServiceImpl implements OrdersIssueService {
 	@Override
 	@Transactional(rollbackFor=Exception.class)
 	public void addOrder(Params params) {
+		String sign = params.getSign();
+		@SuppressWarnings("unchecked")
+		Map<String,Object> map = JSON.parseObject(sign, Map.class);
+		String hash = (String) map.get("sid");
 		Long currentTime = System.currentTimeMillis();
 		//插入【订单表】
 		params.setPlannerId(params.getUserId());
@@ -91,6 +101,7 @@ public class OrdersIssueServiceImpl implements OrdersIssueService {
 		params.setOperationTypeId(OperationType.ADD_ORDER);
 		params.setOperatorId(params.getUserId());
 		params.setOperationTime(currentTime);
+		params.setHash(hash);
 		operationHistoryMapper.addToHistory(params);
 		boolean flag = blockChainUtil.sendBlockChain(params.getSign());
 		if(!flag) throw new RuntimeException("区块链操作失败");

+ 13 - 5
saicLogistics/src/main/java/com/fuzamei/web/OperationHistoryAction.java

@@ -1,5 +1,6 @@
 package com.fuzamei.web;
 
+import java.util.List;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import com.fuzamei.constant.HintMSG;
 import com.fuzamei.constant.Role;
+import com.fuzamei.entity.OperationType;
 import com.fuzamei.entity.Params;
 import com.fuzamei.service.OperationHistoryService;
 import com.fuzamei.service.UserAuthoricationService;
@@ -54,6 +56,7 @@ public class OperationHistoryAction {
 		try {
 			String userId = req.getHeader("Authorization").split("&")[1];
 			userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(userId), Role.PLANNER,Role.SUPPLIER,Role.CARRIER,Role.STOCKER);
+			params.setUserId(Integer.parseInt(userId));
 			int page = ValidationUtil.checkMinAndAssignInt(params.getPage(), 1);
 			int rowNum=ValidationUtil.checkMinAndAssignInt(params.getRowNum(), 1);
 			Long startTime=ValidationUtil.checkAndAssignDefaultLong(params.getStartTime(), 0L);
@@ -87,6 +90,7 @@ public class OperationHistoryAction {
 		try {
 			String userId = req.getHeader("Authorization").split("&")[1];
 			userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(userId), Role.ADMIN);
+			params.setUserId(Integer.parseInt(userId));
 			int page = ValidationUtil.checkMinAndAssignInt(params.getPage(), 1);
 			int rowNum=ValidationUtil.checkMinAndAssignInt(params.getRowNum(), 1);
 			Long startTime=ValidationUtil.checkAndAssignDefaultLong(params.getStartTime(), 0L);
@@ -96,7 +100,7 @@ public class OperationHistoryAction {
 			else params.setEndTime(Long.MAX_VALUE);
 			params.setStartPage((page - 1) * rowNum);
 			params.setRowNum(rowNum);
-			PageDTO pageDto = operationHistoryService.queryOperationHistory(params);
+			PageDTO pageDto = operationHistoryService.queryOperationHistoryByAdmin(params);
 			return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, pageDto);
 		} catch (Exception e) {
 			return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
@@ -117,8 +121,10 @@ public class OperationHistoryAction {
 	@RequestMapping(value="/showAllOperationTypeOfUser",method=RequestMethod.POST)
 	public Map<String, Object> showAllOperationTypeOfUser(@RequestBody Params params){
 		try {
-			
-			return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, null);
+			String userId = req.getHeader("Authorization").split("&")[1];
+			userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(userId), Role.PLANNER,Role.SUPPLIER,Role.CARRIER,Role.STOCKER);
+			List<OperationType> operationTypeList = operationHistoryService.showAllOperationTypeOfUser();
+			return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, operationTypeList);
 		} catch (Exception e) {
 			return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
 		}
@@ -138,8 +144,10 @@ public class OperationHistoryAction {
 	@RequestMapping(value="/showAllOperationTypeOfAdmin",method=RequestMethod.POST)
 	public Map<String, Object> showAllOperationTypeOfAdmin(@RequestBody Params params){
 		try {
-			
-			return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, null);
+			String userId = req.getHeader("Authorization").split("&")[1];
+			userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(userId), Role.ADMIN);
+			List<OperationType> operationTypeList = operationHistoryService.showAllOperationTypeOfAdmin();
+			return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, operationTypeList);
 		} catch (Exception e) {
 			return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
 		}