给经手人和仓库优化接口

This commit is contained in:
jishenghua 2025-02-22 22:04:06 +08:00
parent a473484ffd
commit a73a8d2db2
6 changed files with 79 additions and 134 deletions

View File

@ -2,19 +2,16 @@ package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.base.BaseController;
import com.jsh.erp.base.TableDataInfo;
import com.jsh.erp.datasource.entities.Function;
import com.jsh.erp.datasource.entities.FunctionEx;
import com.jsh.erp.datasource.entities.SystemConfig;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserBusiness;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.functions.FunctionService;
import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
import com.jsh.erp.utils.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@ -30,6 +27,7 @@ import java.util.List;
import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
import static com.jsh.erp.utils.ResponseJsonUtil.returnStr;
/**
* @author ji-sheng-hua jshERP
@ -37,7 +35,7 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
@RestController
@RequestMapping(value = "/function")
@Api(tags = {"功能管理"})
public class FunctionController {
public class FunctionController extends BaseController {
private Logger logger = LoggerFactory.getLogger(FunctionController.class);
@Resource
@ -49,6 +47,76 @@ public class FunctionController {
@Resource
private SystemConfigService systemConfigService;
@GetMapping(value = "/info")
@ApiOperation(value = "根据id获取信息")
public String getList(@RequestParam("id") Long id,
HttpServletRequest request) throws Exception {
Function function = functionService.getFunction(id);
Map<String, Object> objectMap = new HashMap<>();
if(function != null) {
objectMap.put("info", function);
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
@GetMapping(value = "/list")
@ApiOperation(value = "获取信息列表")
public TableDataInfo getList(@RequestParam(value = Constants.SEARCH, required = false) String search,
HttpServletRequest request)throws Exception {
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
List<FunctionEx> list = functionService.select(name, type);
return getDataTable(list);
}
@PostMapping(value = "/add")
@ApiOperation(value = "新增")
public String addResource(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int insert = functionService.insertFunction(obj, request);
return returnStr(objectMap, insert);
}
@PutMapping(value = "/update")
@ApiOperation(value = "修改")
public String updateResource(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int update = functionService.updateFunction(obj, request);
return returnStr(objectMap, update);
}
@DeleteMapping(value = "/delete")
@ApiOperation(value = "删除")
public String deleteResource(@RequestParam("id") Long id, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int delete = functionService.deleteFunction(id, request);
return returnStr(objectMap, delete);
}
@DeleteMapping(value = "/deleteBatch")
@ApiOperation(value = "批量删除")
public String batchDeleteResource(@RequestParam("ids") String ids, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int delete = functionService.batchDeleteFunction(ids, request);
return returnStr(objectMap, delete);
}
@GetMapping(value = "/checkIsNameExist")
@ApiOperation(value = "检查名称是否存在")
public String checkIsNameExist(@RequestParam Long id, @RequestParam(value ="name", required = false) String name,
HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int exist = functionService.checkIsNameExist(id, name);
if(exist > 0) {
objectMap.put("status", true);
} else {
objectMap.put("status", false);
}
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
}
@GetMapping(value = "/checkIsNumberExist")
@ApiOperation(value = "检查编号是否存在")
public String checkIsNumberExist(@RequestParam Long id,

View File

@ -9,12 +9,6 @@ import java.util.List;
public interface FunctionMapperEx {
List<FunctionEx> selectByConditionFunction(
@Param("name") String name,
@Param("type") String type,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long countsByFunction(
@Param("name") String name,
@Param("type") String type);

View File

@ -1,73 +0,0 @@
package com.jsh.erp.service.functions;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "function_component")
@FunctionResource
public class FunctionComponent implements ICommonQuery {
@Resource
private FunctionService functionService;
@Override
public Object selectOne(Long id) throws Exception {
return functionService.getFunction(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getFunctionsList(map);
}
private List<?> getFunctionsList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
String order = QueryUtils.order(map);
return functionService.select(name, type, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
return functionService.countFunction(name, type);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return functionService.insertFunction(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return functionService.updateFunction(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return functionService.deleteFunction(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return functionService.batchDeleteFunction(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return functionService.checkIsNameExist(id, name);
}
}

View File

@ -1,15 +0,0 @@
package com.jsh.erp.service.functions;
import com.jsh.erp.service.ResourceInfo;
import java.lang.annotation.*;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo(value = "function")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface FunctionResource {
}

View File

@ -77,11 +77,11 @@ public class FunctionService {
return list;
}
public List<FunctionEx> select(String name, String type, int offset, int rows)throws Exception {
public List<FunctionEx> select(String name, String type)throws Exception {
List<FunctionEx> list=null;
try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
list = functionMapperEx.selectByConditionFunction(name, type, offset, rows);
list = functionMapperEx.selectByConditionFunction(name, type);
}
}catch(Exception e){
JshException.readFail(logger, e);
@ -89,18 +89,6 @@ public class FunctionService {
return list;
}
public Long countFunction(String name, String type)throws Exception {
Long result=null;
try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = functionMapperEx.countsByFunction(name, type);
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertFunction(JSONObject obj, HttpServletRequest request)throws Exception {
Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class);

View File

@ -19,25 +19,8 @@
</if>
and ifnull(fa.delete_flag,'0') !='1'
order by fa.sort asc
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
</select>
<select id="countsByFunction" resultType="java.lang.Long">
select
count(fa.id)
from jsh_function fa
left join jsh_function fb on fa.parent_number = fb.number
WHERE 1=1
<if test="name != null">
<bind name="bindName" value="'%'+name+'%'"/>
and fa.name like #{bindName}
</if>
<if test="type != null">
and fa.type=#{type}
</if>
and ifnull(fa.delete_flag,'0') !='1'
</select>
<update id="batchDeleteFunctionByIds">
update jsh_function
set delete_flag='1'