给经手人和仓库优化接口

This commit is contained in:
jishenghua 2025-02-22 21:22:57 +08:00
parent 4c91e8cb08
commit a473484ffd
15 changed files with 166 additions and 277 deletions

View File

@ -2,33 +2,34 @@ package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.base.BaseController;
import com.jsh.erp.base.TableDataInfo;
import com.jsh.erp.datasource.entities.Depot;
import com.jsh.erp.datasource.entities.DepotEx;
import com.jsh.erp.datasource.entities.MaterialCurrentStock;
import com.jsh.erp.datasource.entities.MaterialInitialStock;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.material.MaterialService;
import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.*;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
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 752*718*920
@ -36,7 +37,7 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
@RestController
@RequestMapping(value = "/depot")
@Api(tags = {"仓库管理"})
public class DepotController {
public class DepotController extends BaseController {
private Logger logger = LoggerFactory.getLogger(DepotController.class);
@Resource
@ -48,6 +49,78 @@ public class DepotController {
@Resource
private MaterialService materialService;
@GetMapping(value = "/info")
@ApiOperation(value = "根据id获取信息")
public String getList(@RequestParam("id") Long id,
HttpServletRequest request) throws Exception {
Depot depot = depotService.getDepot(id);
Map<String, Object> objectMap = new HashMap<>();
if(depot != null) {
objectMap.put("info", depot);
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");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
String remark = StringUtil.getInfo(search, "remark");
List<DepotEx> list = depotService.select(name, type, remark);
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 = depotService.insertDepot(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 = depotService.updateDepot(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 = depotService.deleteDepot(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 = depotService.batchDeleteDepot(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 = depotService.checkIsNameExist(id, name);
if(exist > 0) {
objectMap.put("status", true);
} else {
objectMap.put("status", false);
}
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
}
/**
* 仓库列表
* @param request

View File

@ -2,10 +2,14 @@ package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.base.BaseController;
import com.jsh.erp.base.TableDataInfo;
import com.jsh.erp.datasource.entities.Person;
import com.jsh.erp.service.person.PersonService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@ -19,6 +23,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 管伊佳erp
@ -26,12 +31,83 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
@RestController
@RequestMapping(value = "/person")
@Api(tags = {"经手人管理"})
public class PersonController {
public class PersonController extends BaseController {
private Logger logger = LoggerFactory.getLogger(PersonController.class);
@Resource
private PersonService personService;
@GetMapping(value = "/info")
@ApiOperation(value = "根据id获取信息")
public String getList(@RequestParam("id") Long id,
HttpServletRequest request) throws Exception {
Person person = personService.getPerson(id);
Map<String, Object> objectMap = new HashMap<>();
if(person != null) {
objectMap.put("info", person);
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<Person> list = personService.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 = personService.insertPerson(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 = personService.updatePerson(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 = personService.deletePerson(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 = personService.batchDeletePerson(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 = personService.checkIsNameExist(id, name);
if(exist > 0) {
objectMap.put("status", true);
} else {
objectMap.put("status", false);
}
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
}
/**
* 全部数据列表
* @param request

View File

@ -12,13 +12,6 @@ import java.util.Map;
public interface DepotMapperEx {
List<DepotEx> selectByConditionDepot(
@Param("name") String name,
@Param("type") Integer type,
@Param("remark") String remark,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long countsByDepot(
@Param("name") String name,
@Param("type") Integer type,
@Param("remark") String remark);

View File

@ -10,12 +10,6 @@ import java.util.List;
public interface PersonMapperEx {
List<Person> selectByConditionPerson(
@Param("name") String name,
@Param("type") String type,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long countsByPerson(
@Param("name") String name,
@Param("type") String type);

View File

@ -1,75 +0,0 @@
package com.jsh.erp.service.depot;
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 = "depot_component")
@DepotResource
public class DepotComponent implements ICommonQuery {
@Resource
private DepotService depotService;
@Override
public Object selectOne(Long id) throws Exception {
return depotService.getDepot(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getDepotList(map);
}
private List<?> getDepotList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
String remark = StringUtil.getInfo(search, "remark");
String order = QueryUtils.order(map);
return depotService.select(name, type, remark, 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");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
String remark = StringUtil.getInfo(search, "remark");
return depotService.countDepot(name, type, remark);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request) throws Exception{
return depotService.insertDepot(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return depotService.updateDepot(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return depotService.deleteDepot(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return depotService.batchDeleteDepot(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return depotService.checkIsNameExist(id, name);
}
}

View File

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

View File

@ -91,26 +91,16 @@ public class DepotService {
return list;
}
public List<DepotEx> select(String name, Integer type, String remark, int offset, int rows)throws Exception {
public List<DepotEx> select(String name, Integer type, String remark)throws Exception {
List<DepotEx> list=null;
try{
list=depotMapperEx.selectByConditionDepot(name, type, remark, offset, rows);
list=depotMapperEx.selectByConditionDepot(name, type, remark);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countDepot(String name, Integer type, String remark)throws Exception {
Long result=null;
try{
result=depotMapperEx.countsByDepot(name, type, remark);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepot(JSONObject obj, HttpServletRequest request)throws Exception {
Depot depot = JSONObject.parseObject(obj.toJSONString(), Depot.class);

View File

@ -2,8 +2,6 @@ package com.jsh.erp.service.material;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.service.depot.DepotResource;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.StringUtil;

View File

@ -1,75 +0,0 @@
package com.jsh.erp.service.person;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.service.depot.DepotResource;
import com.jsh.erp.service.depot.DepotService;
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 = "person_component")
@PersonResource
public class PersonComponent implements ICommonQuery {
@Resource
private PersonService personService;
@Override
public Object selectOne(Long id) throws Exception {
return personService.getPerson(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getPersonList(map);
}
private List<?> getPersonList(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 personService.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 personService.countPerson(name, type);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return personService.insertPerson(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return personService.updatePerson(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return personService.deletePerson(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return personService.batchDeletePerson(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return personService.checkIsNameExist(id, name);
}
}

View File

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

View File

@ -83,26 +83,16 @@ public class PersonService {
return list;
}
public List<Person> select(String name, String type, int offset, int rows)throws Exception {
public List<Person> select(String name, String type)throws Exception {
List<Person> list=null;
try{
list=personMapperEx.selectByConditionPerson(name, type, offset, rows);
list=personMapperEx.selectByConditionPerson(name, type);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countPerson(String name, String type)throws Exception {
Long result=null;
try{
result=personMapperEx.countsByPerson(name, type);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertPerson(JSONObject obj, HttpServletRequest request)throws Exception {
Person person = JSONObject.parseObject(obj.toJSONString(), Person.class);

View File

@ -2,8 +2,6 @@ package com.jsh.erp.service.supplier;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.service.depot.DepotResource;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.StringUtil;

View File

@ -3,11 +3,6 @@ package com.jsh.erp.service.userBusiness;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.service.depot.DepotResource;
import com.jsh.erp.service.depot.DepotService;
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;

View File

@ -23,28 +23,6 @@
</if>
and ifnull(dep.delete_Flag,'0') !='1'
order by dep.sort asc, dep.id desc
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
</select>
<select id="countsByDepot" resultType="java.lang.Long">
SELECT
COUNT(dep.id)
FROM jsh_depot dep
left join jsh_user usr on usr.id=dep.principal and ifnull(usr.status,'0') not in('1','2')
WHERE 1=1
<if test="name != null">
<bind name="bindName" value="'%'+name+'%'"/>
and dep.name like #{bindName}
</if>
<if test="type != null">
and dep.type=#{type}
</if>
<if test="remark != null">
<bind name="bindRemark" value="'%'+remark+'%'"/>
and dep.remark like #{bindRemark}
</if>
and ifnull(dep.delete_Flag,'0') !='1'
</select>
<update id="batchDeleteDepotByIds">

View File

@ -14,24 +14,8 @@
</if>
and ifnull(delete_flag,'0') !='1'
order by sort asc, id desc
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
</select>
<select id="countsByPerson" resultType="java.lang.Long">
SELECT
COUNT(id)
FROM jsh_person
WHERE 1=1
<if test="name != null and name != ''">
<bind name="bindName" value="'%'+name+'%'"/>
and name like #{bindName}
</if>
<if test="type != null and type != ''">
and type=#{type}
</if>
and ifnull(delete_flag,'0') !='1'
</select>
<update id="batchDeletePersonByIds">
update jsh_person
set delete_flag='1'