Commit 9fac5b3d by wangnb

manager服务字典数据远程调用--think.wang

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@30409 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent e5a6830d
package com.glsx.common.constants;
import java.io.Serializable;
import com.alibaba.fastjson.JSON;
import java.io.Serializable;
/**
*
* @Title ResultObject.java
* @Package com.glsx.common.constants
* @Description TODO
* @Description 返回对象类
* @author zhanghj
* @date 2018年7月11日 上午10:26:46
* @version
......
package com.glsx.common.feign.client;
import com.glsx.common.config.FeignConfiguration;
import com.glsx.plat.core.web.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author think.wang
* @version 1.0.0
* @Title DictionaryDataClient
* @Package com.glsx.common.feign.client
* @Description 系统代码集远程调用
* @date 2021/5/21
*/
@FeignClient(name="car-service-manager", configuration= FeignConfiguration.class)
public interface DictionaryDataClient {
/**
* 通过key获取代码集值
* @param dataKey
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/carservice/manager/dictionaryData/getListByDataKey")
R getListByDataKey(@RequestParam("dataKey") String dataKey);
}
......@@ -15,7 +15,7 @@ import com.glsx.common.pojo.OperateLog;
*
* @Title OperateLogClient.java
* @Package com.glsx.common.feign.client
* @Description TODO 日志操作feign的客户端
* @Description 日志操作feign的客户端
* @author zhanghj
* @date 2019年2月2日 下午8:21:12
* @version 1.0.0
......@@ -27,7 +27,7 @@ public interface OperateLogClient {
*
* @author zhanghj
* @Title: save
* @Description: TODO 保存操作日志
* @Description: 保存操作日志
* @param optLog
* @return
* JSONObject
......
......@@ -12,14 +12,13 @@ import com.glsx.manager.pojo.dictionary.DictionaryData;
import com.glsx.manager.pojo.dictionary.DictionaryType;
import com.glsx.manager.service.DictionaryDataService;
import com.glsx.manager.service.DictionaryTypeService;
import com.glsx.plat.core.web.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default;
......@@ -38,10 +37,10 @@ import java.util.*;
public class DictionaryDataController extends BaseController {
@Autowired
private DictionaryDataService dictionaryDataService;
private DictionaryDataService dataService;
@Autowired
private DictionaryTypeService dictionaryTypeService;
private DictionaryTypeService typeService;
/**
* @param dictionaryData
......@@ -61,19 +60,19 @@ public class DictionaryDataController extends BaseController {
}
DictionaryType dictionaryType = new DictionaryType();
dictionaryType.setDictType(dictionaryData.getDictType());
DictionaryType dictType = dictionaryTypeService.get(dictionaryType);
DictionaryType dictType = typeService.get(dictionaryType);
if (dictType == null) {
return new ResultObject(ResultCodeEnum.DICT_TYPE_KEY_NOT_EXISTS.getCode(), ResultCodeEnum.DICT_TYPE_KEY_NOT_EXISTS.getMsg());
}
DictionaryData dictData = new DictionaryData();
dictData.setDataKey(dictionaryData.getDataKey());
DictionaryData data = dictionaryDataService.get(dictData);
DictionaryData data = dataService.get(dictData);
if (data != null) {
return new ResultObject(ResultCodeEnum.DATA_KEY_EXISTS.getCode(), ResultCodeEnum.DATA_KEY_EXISTS.getMsg());
}
dictionaryData.setCreateBy(UserUtils.getUserId(request));
dictionaryData.setCreateTime(new Date());
int num = dictionaryDataService.save(dictionaryData);
int num = dataService.save(dictionaryData);
if (num > 0) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} else {
......@@ -100,18 +99,18 @@ public class DictionaryDataController extends BaseController {
Integer id = dictionaryData.getId();
DictionaryData data = new DictionaryData();
data.setId(id);
data = dictionaryDataService.get(data);
data = dataService.get(data);
DictionaryData dictData = new DictionaryData();
if (data != null) {
dictData.setDataKey(dictionaryData.getDataKey());
dictData = dictionaryDataService.get(dictData);
dictData = dataService.get(dictData);
if (dictData != null && id != dictData.getId()) {
return new ResultObject(ResultCodeEnum.DATA_KEY_EXISTS.getCode(), ResultCodeEnum.DATA_KEY_EXISTS.getMsg());
}
}
dictionaryData.setUpdateTime(new Date());
dictionaryData.setUpdateBy(UserUtils.getUserId(request));
int num = dictionaryDataService.update(dictionaryData);
int num = dataService.update(dictionaryData);
if (num > 0) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} else {
......@@ -141,7 +140,7 @@ public class DictionaryDataController extends BaseController {
dictionaryData.setUpdateTime(new Date());
dataList.add(dictionaryData);
}
dictionaryDataService.delete(dataList);
dataService.delete(dataList);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
......@@ -160,7 +159,7 @@ public class DictionaryDataController extends BaseController {
}
DictionaryData dictionaryData = new DictionaryData();
dictionaryData.setId(id);
dictionaryData = dictionaryDataService.get(dictionaryData);
dictionaryData = dataService.get(dictionaryData);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), dictionaryData);
}
......@@ -173,7 +172,7 @@ public class DictionaryDataController extends BaseController {
}
Map<String, Object> result = new HashMap<>();
Page page = new Page(pageIndex, pageSize);
List<DictionaryData> list = dictionaryDataService.list(dictionaryData, page);
List<DictionaryData> list = dataService.list(dictionaryData, page);
com.github.pagehelper.Page<DictionaryData> pages = (com.github.pagehelper.Page<DictionaryData>) list;
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
......@@ -189,8 +188,24 @@ public class DictionaryDataController extends BaseController {
DictionaryData dictionaryData = new DictionaryData();
dictionaryData.setDictType(dictType);
Map<String, Object> result = new HashMap<>();
List<DictionaryData> list = dictionaryDataService.list(dictionaryData, null);
List<DictionaryData> list = dataService.list(dictionaryData, null);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
@ResponseBody
@RequestMapping(value = "/getListByDataKey", method = RequestMethod.GET)
public R getListByDataKey(@RequestParam("dataKey") String dataKey) {
logger.info("====/dictionaryData/getListByDataKey 参数:{}", dataKey);
if (StringUtils.isEmpty(dataKey)) {
return R.error(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
DictionaryData dictionaryData = new DictionaryData();
dictionaryData.setDictType(dataKey);
List<DictionaryData> list = dataService.list(dictionaryData, null);
if(!CollectionUtils.isEmpty(list)){
return R.ok().data(list.get(0));
}
return R.ok();
}
}
......@@ -54,6 +54,9 @@
<if test="dictType != null">
and sdd.dict_type = #{dictType}
</if>
<if test="dataKey != null and dataKey != ''">
and sdd.data_key = #{dataKey,jdbcType=VARCHAR}
</if>
<if test="dataValue != null and dataValue != ''">
and sdd.data_value like #{pattern}
</if>
......
package com.glsx.ordercenter.controller;
import com.alibaba.fastjson.JSON;
import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.feign.client.DictionaryDataClient;
import com.glsx.common.utils.StringUtils;
import com.glsx.ordercenter.constants.OrderActiveStatusEnum;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.resp.DictionaryDataResp;
import com.glsx.ordercenter.dto.resp.OrderStatusResp;
import com.glsx.ordercenter.pojo.SysOrderStatus;
import com.glsx.ordercenter.service.IOrderStatusService;
......@@ -36,6 +39,9 @@ public class OrderStatusController {
@Autowired
private IOrderStatusService orderStatusService;
@Autowired
private DictionaryDataClient dataClient;
/**
*
* @author zhanghj
......@@ -78,6 +84,16 @@ public class OrderStatusController {
BeanUtils.copyProperties(item, resp);
resp.setUserName(item.getUser().getName());
resp.setStatus(OrderActiveStatusEnum.getMsgByStatus(item.getActiveStatus()));
//打卡原因
if(StringUtils.isNotEmpty(item.getReason())){
R result = dataClient.getListByDataKey(item.getReason());
if(result.getCode() == ResultCodeEnum.SUCCESS.getCode()
&& result.getData() != null){
String data = JSON.toJSONString(result.getData());
DictionaryDataResp dataResp = JSON.parseObject(data, DictionaryDataResp.class);
resp.setReason(dataResp.getDataValue());
}
}
respList.add(resp);
});
}
......
package com.glsx.ordercenter.dto.resp;
import lombok.Data;
import java.io.Serializable;
/**
*
* @Title DictionaryDataResp.java
* @Package com.glsx.ordercenter.dto.resp
* @Description 字典类response
* @author zhanghj
* @date 2019年1月22日 下午5:34:49
* @version 1.0.0
*/
@Data
public class DictionaryDataResp implements Serializable {
/**
* 主键id
*/
private Integer id;
/**
* 字典类型
*/
private String dictType;
/**
* 字典标签
*/
private String dataValue;
/**
* 字典键值
*/
private String dataKey;
}
\ No newline at end of file
......@@ -10,6 +10,8 @@ public class OrderStatusResp implements Serializable {
private Integer id;
private Byte activeStatus;
private String status;
private Date updateTime;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!