|
|
package com.agent.controller.system;
|
|
|
|
|
|
import com.agent.entity.agent.SDCargoNameEntity;
|
|
|
import com.agent.entity.system.SDBIGTYPEEntity;
|
|
|
import com.agent.entity.system.SDTWOTYPEEntity;
|
|
|
import com.agent.service.system.SDBIGTYPEService;
|
|
|
import com.agent.service.system.SDCargoNameService;
|
|
|
import com.agent.service.system.SDCargoTypeService;
|
|
|
import com.agent.service.system.SDTWOTYPEService;
|
|
|
import com.agent.util.HttpJsonMsg;
|
|
|
import com.agent.vo.ResponseModel;
|
|
|
import com.agent.vo.agent.SdBigTypeVo;
|
|
|
import com.agent.vo.agent.SdTwoTypeVo;
|
|
|
import com.framework.core.Servlets;
|
|
|
import com.framework.shiro.SessionUtil;
|
|
|
import com.plugin.easyui.DataGrid;
|
|
|
import com.plugin.easyui.EasyPage;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/** 货物品名 大类 二级类 统计
|
|
|
* @Auther: shenhl
|
|
|
* @Date: 2019/8/8 15:51
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/type")
|
|
|
public class SDCARGONAMEController {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(com.agent.controller.system.SDCARGONAMEController.class);
|
|
|
@Autowired
|
|
|
SDBIGTYPEService sdbigtypeService;
|
|
|
|
|
|
@Autowired
|
|
|
SDTWOTYPEService sdtwotypeService;
|
|
|
|
|
|
@Autowired
|
|
|
SDCargoNameService sdCargoNameService;
|
|
|
|
|
|
/**
|
|
|
* 一级类 列表页面
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/list")
|
|
|
public String list(){
|
|
|
return "sdtype/bigtype";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 一级类 跳转添加页面
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/add")
|
|
|
public String add(){
|
|
|
return "sdtype/sdtypeadd";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 二级类列表跳转
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/tlist")
|
|
|
public String tlist(){
|
|
|
return "sdtype/twolist";
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 一级类分页查询
|
|
|
* @param request
|
|
|
* @param pageForm
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/grid.json")
|
|
|
@ResponseBody
|
|
|
public DataGrid<SdBigTypeVo> grid(HttpServletRequest request, EasyPage<SDBIGTYPEEntity> pageForm) {
|
|
|
|
|
|
Map<String, Object> searchParams = Servlets.getParametersStartingWith(request, "search_");
|
|
|
pageForm.setSearchParams(searchParams);
|
|
|
pageForm.parseData(sdbigtypeService.getPage(pageForm));
|
|
|
DataGrid<SDBIGTYPEEntity> hzshipperinformationEntityDataGrid = pageForm.getData();
|
|
|
List<SdBigTypeVo> rows = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(hzshipperinformationEntityDataGrid.getRows())){
|
|
|
for (SDBIGTYPEEntity sd: hzshipperinformationEntityDataGrid.getRows()){
|
|
|
SdBigTypeVo sdBigTypeVo = new SdBigTypeVo();
|
|
|
sdBigTypeVo.setId(sd.getId());
|
|
|
sdBigTypeVo.setType_name(sd.getType_name());
|
|
|
sdBigTypeVo.setType_order(sd.getType_order());
|
|
|
rows.add(sdBigTypeVo);
|
|
|
}
|
|
|
}
|
|
|
DataGrid<SdBigTypeVo> vos = new DataGrid<>();
|
|
|
vos.setRows(rows);
|
|
|
vos.setTotal(hzshipperinformationEntityDataGrid.getTotal());
|
|
|
return vos;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 大类添加
|
|
|
* @param sd
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/bigSave")
|
|
|
@ResponseBody
|
|
|
public ResponseModel saves(SDBIGTYPEEntity sd, HttpServletRequest request){
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
try {
|
|
|
// 如果为空 默认为0
|
|
|
if (sd.getType_order() == null){
|
|
|
sd.setType_order("0");
|
|
|
}
|
|
|
|
|
|
if (sdbigtypeService.findName(sd.getType_name()) == 0){
|
|
|
sdbigtypeService.saves(sd);
|
|
|
|
|
|
model.setStatus(200);
|
|
|
}else {
|
|
|
model.setStatus(201);
|
|
|
}
|
|
|
|
|
|
return model;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
model.setStatus(500);
|
|
|
return model;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 一级类修改跳转
|
|
|
* @param model
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/edit")
|
|
|
public String edit(Model model, Long id){
|
|
|
|
|
|
SDBIGTYPEEntity one = sdbigtypeService.findOne(id);
|
|
|
|
|
|
model.addAttribute("big", one);
|
|
|
|
|
|
return "sdtype/typeedit";
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 一级类修改修改
|
|
|
* @param sd
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/update")
|
|
|
@ResponseBody
|
|
|
public ResponseModel update(SDBIGTYPEEntity sd, HttpServletRequest request){
|
|
|
ResponseModel responseModel = new ResponseModel();
|
|
|
|
|
|
// 如果为空 默认为0
|
|
|
if (sd.getType_order() == null){
|
|
|
sd.setType_order("0");
|
|
|
}
|
|
|
if (sdbigtypeService.findName(sd.getType_name()) == 0){
|
|
|
if (sdbigtypeService.typeUpdate(sd) > 0){
|
|
|
responseModel.setStatus(200);
|
|
|
}else {
|
|
|
responseModel.setStatus(500);
|
|
|
}
|
|
|
}else {
|
|
|
responseModel.setStatus(201);
|
|
|
}
|
|
|
return responseModel;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 一级类删除
|
|
|
*
|
|
|
* @param ids
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/delete", method = { RequestMethod.POST })
|
|
|
@ResponseBody
|
|
|
public ResponseModel delete(String ids) {
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
try {
|
|
|
sdbigtypeService.bigTypeDelete(ids);
|
|
|
model.setStatus(200);
|
|
|
model.setMsg(HttpJsonMsg.SUCCESS);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
model.setStatus(500);
|
|
|
model.setMsg(HttpJsonMsg.ERROR);
|
|
|
logger.error("系统异常 >>", e);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 二级类分页查询
|
|
|
* @param request
|
|
|
* @param pageForm
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/twogrid.json")
|
|
|
@ResponseBody
|
|
|
public DataGrid<SdTwoTypeVo> twogrid(HttpServletRequest request, EasyPage<SDTWOTYPEEntity> pageForm) {
|
|
|
|
|
|
Map<String, Object> searchParams = Servlets.getParametersStartingWith(request, "search_");
|
|
|
pageForm.setSearchParams(searchParams);
|
|
|
pageForm.parseData(sdtwotypeService.getPage(pageForm));
|
|
|
DataGrid<SDTWOTYPEEntity> hzshipperinformationEntityDataGrid = pageForm.getData();
|
|
|
List<SdTwoTypeVo> rows = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(hzshipperinformationEntityDataGrid.getRows())){
|
|
|
for (SDTWOTYPEEntity sd: hzshipperinformationEntityDataGrid.getRows()){
|
|
|
SdTwoTypeVo sdTwoTypeVo = new SdTwoTypeVo();
|
|
|
|
|
|
SDBIGTYPEEntity one = sdbigtypeService.findOne(sd.getBig_type_id());
|
|
|
sdTwoTypeVo.setBigName(one.getType_name());
|
|
|
sdTwoTypeVo.setId(sd.getId());
|
|
|
sdTwoTypeVo.setBig_type_id(sd.getBig_type_id());
|
|
|
sdTwoTypeVo.setCargo_name(sd.getCargo_name());
|
|
|
sdTwoTypeVo.setCargo_name_id(sd.getCargo_name_id());
|
|
|
sdTwoTypeVo.setTwo_type_name(sd.getTwo_type_name());
|
|
|
sdTwoTypeVo.setTwo_type_order(sd.getTwo_type_order());
|
|
|
|
|
|
rows.add(sdTwoTypeVo);
|
|
|
}
|
|
|
}
|
|
|
DataGrid<SdTwoTypeVo> vos = new DataGrid<>();
|
|
|
vos.setRows(rows);
|
|
|
vos.setTotal(hzshipperinformationEntityDataGrid.getTotal());
|
|
|
return vos;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 二级类 跳转添加页面
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/tadd")
|
|
|
public String tadd(Model model){
|
|
|
// 一级类名称
|
|
|
List<SDBIGTYPEEntity> alls = sdbigtypeService.findAlls();
|
|
|
// 二级类名称
|
|
|
List<String> alls1 = sdCargoNameService.findAlls();
|
|
|
model.addAttribute("big", alls);
|
|
|
model.addAttribute("cargo", alls1);
|
|
|
return "sdtype/tadd";
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 二级类添加
|
|
|
* @param sd
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/twoSave")
|
|
|
@ResponseBody
|
|
|
public ResponseModel twoSave(SDTWOTYPEEntity sd, HttpServletRequest request){
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
try {
|
|
|
// 如果为空 默认为0
|
|
|
if (sd.getTwo_type_order() == null){
|
|
|
sd.setTwo_type_order("0");
|
|
|
}
|
|
|
sdtwotypeService.saves(sd);
|
|
|
model.setStatus(200);
|
|
|
return model;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
model.setStatus(500);
|
|
|
return model;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 二级类删除
|
|
|
*
|
|
|
* @param ids
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/tdelete", method = { RequestMethod.POST })
|
|
|
@ResponseBody
|
|
|
public ResponseModel tdelete(String ids) {
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
try {
|
|
|
sdtwotypeService.tDelete(ids);
|
|
|
model.setStatus(200);
|
|
|
model.setMsg(HttpJsonMsg.SUCCESS);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
model.setStatus(500);
|
|
|
model.setMsg(HttpJsonMsg.ERROR);
|
|
|
logger.error("系统异常 >>", e);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 二级类修改跳转
|
|
|
* @param model
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/tedit")
|
|
|
public String tedit(Model model, Long id){
|
|
|
|
|
|
SDTWOTYPEEntity one = sdtwotypeService.findOne(id);
|
|
|
// 一级类名称
|
|
|
List<SDBIGTYPEEntity> alls = sdbigtypeService.findAlls();
|
|
|
// 二级类名称
|
|
|
List<String> alls1 = sdCargoNameService.findAlls();
|
|
|
model.addAttribute("big", alls);
|
|
|
model.addAttribute("one", one);
|
|
|
return "sdtype/tedit";
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 二级类修改修改
|
|
|
* @param sd
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/tupdate")
|
|
|
@ResponseBody
|
|
|
public ResponseModel tupdate(SDTWOTYPEEntity sd, HttpServletRequest request){
|
|
|
ResponseModel responseModel = new ResponseModel();
|
|
|
// 如果为空 默认为0
|
|
|
if (sd.getTwo_type_order() == null){
|
|
|
sd.setTwo_type_order("0");
|
|
|
}
|
|
|
if (sdtwotypeService.tUpdate(sd) > 0){
|
|
|
responseModel.setStatus(200);
|
|
|
}else {
|
|
|
responseModel.setStatus(500);
|
|
|
}
|
|
|
|
|
|
return responseModel;
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|