|
@@ -0,0 +1,302 @@
|
|
|
+package com.xt.js.gkaq.web.ctl;
|
|
|
+
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.xt.js.gkaq.common.BaseCtl;
|
|
|
+import com.xt.js.gkaq.common.BaseUUIDModel;
|
|
|
+import com.xt.js.gkaq.dwxx.service.JyrjcxxService;
|
|
|
+import com.xt.js.gkaq.frame.model.ComboBoxDto;
|
|
|
+import com.xt.js.gkaq.frame.service.CodeService;
|
|
|
+import com.xt.js.gkaq.web.model.BloBModel;
|
|
|
+import com.xt.js.gkaq.web.model.GqModel;
|
|
|
+import com.xt.js.gkaq.web.model.JyrUserListModel;
|
|
|
+import com.xt.js.gkaq.web.model.JyrUserModel;
|
|
|
+import com.xt.js.gkaq.web.service.BloBService;
|
|
|
+import com.xt.js.gkaq.web.service.GqService;
|
|
|
+import com.xt.js.gkaq.web.service.JyrUserService;
|
|
|
+import com.xt.js.gkaq.web.service.RyzsbService;
|
|
|
+import com.xt.js.gkaq.web.vo.BloBVo;
|
|
|
+import com.xt.js.gkaq.web.vo.JyrUserVo;
|
|
|
+import com.yuanxd.tools.pagehelper.PageHelper;
|
|
|
+import com.yuanxd.tools.pagehelper.PageInfo;
|
|
|
+import com.yuanxd.tools.utils.WebJsonResult;
|
|
|
+import com.yuanxd.tools.utils.string.StringUtils;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "/jyrUser", produces = "application/json; charset=utf-8")
|
|
|
+public class JyrUserCtl extends BaseCtl {
|
|
|
+ @Autowired
|
|
|
+ private JyrUserService jyrUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JyrjcxxService jyrjcxxService;
|
|
|
+ @Autowired
|
|
|
+ private CodeService codeService;
|
|
|
+ @Autowired
|
|
|
+ private GqService gqService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BloBService bloBService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RyzsbService ryzsbService;
|
|
|
+
|
|
|
+ @RequestMapping("")
|
|
|
+ public String main(HttpServletRequest request) {
|
|
|
+ //加载所在地
|
|
|
+ List<ComboBoxDto> list = codeService.findByPcode("DM_SZD");
|
|
|
+ //加载人员类型
|
|
|
+ List<ComboBoxDto> rylxList = codeService.findByPcode("RYLX");
|
|
|
+ request.setAttribute("code", list);
|
|
|
+ request.setAttribute("rylx", rylxList);
|
|
|
+ return "dwxx/jyrUser/main";
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 加载所在地
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("getszd")
|
|
|
+ @ResponseBody
|
|
|
+ public String getszd() {
|
|
|
+ //加载所在地
|
|
|
+ List<ComboBoxDto> list = codeService.findByPcode("DM_SZD");
|
|
|
+ return JSONArray.toJSONString(list);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 加载人员类型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("getRylx")
|
|
|
+ @ResponseBody
|
|
|
+ public String getRylx() {
|
|
|
+ //加载人员类型
|
|
|
+ List<ComboBoxDto> rylxList = codeService.findByPcode("RYLX");
|
|
|
+ return JSONArray.toJSONString(rylxList);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 加载证件类型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("getzjlx")
|
|
|
+ @ResponseBody
|
|
|
+ public String getzjlx() {
|
|
|
+ //加载证件类型
|
|
|
+ List<ComboBoxDto> zjList = codeService.findByPcode("ZJLX");
|
|
|
+ return JSONArray.toJSONString(zjList);
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * 动态关联下拉框数据:港区
|
|
|
+ * @param request
|
|
|
+ * @param szd
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("getGq")
|
|
|
+ @ResponseBody
|
|
|
+ public String getGq(String szd) {
|
|
|
+ GqModel model = new GqModel();
|
|
|
+ model.setSzd(szd);
|
|
|
+ //获取港区
|
|
|
+ List<ComboBoxDto> gqlist = gqService.selectByInfo(model);
|
|
|
+ return JSONArray.toJSONString(gqlist);
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * 动态关联下拉框数据:经营人信息
|
|
|
+ * @param request
|
|
|
+ * @param szd
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("getJyr")
|
|
|
+ @ResponseBody
|
|
|
+ public String getJyr(String szd) {
|
|
|
+ //获取经营人
|
|
|
+ List<com.xt.js.gkaq.dwxx.model.ComboBoxDto> jyrlist = jyrjcxxService.getSelect(szd);
|
|
|
+ return JSONArray.toJSONString(jyrlist);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 数据表格
|
|
|
+ * @param vo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("list")
|
|
|
+ @ResponseBody
|
|
|
+ public PageInfo<JyrUserListModel> list(JyrUserVo vo) {
|
|
|
+ if (null == vo.getPage() || vo.getPage() < 1) {
|
|
|
+ vo.setPage(1);
|
|
|
+ }
|
|
|
+ if (null == vo.getRows() || vo.getRows() < 1) {
|
|
|
+ vo.setRows(1);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(vo.getPage(), vo.getRows());
|
|
|
+ JyrUserModel model = new JyrUserModel();
|
|
|
+ BeanUtils.copyProperties(vo, model);
|
|
|
+ List<JyrUserListModel> list = jyrUserService.selectInfo(model);
|
|
|
+ PageInfo<JyrUserListModel> pageResult = new PageInfo<>(list);
|
|
|
+ return pageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑详情
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("initEdit")
|
|
|
+ @ResponseBody
|
|
|
+ public String initEdit (String id) {
|
|
|
+ JyrUserModel model = jyrUserService.findById(id);
|
|
|
+ return JSONArray.toJSONString(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加或修改
|
|
|
+ * @param vo
|
|
|
+ * @return
|
|
|
+ * @throws ParseException
|
|
|
+ */
|
|
|
+ @RequestMapping("save")
|
|
|
+ @ResponseBody
|
|
|
+ public WebJsonResult save (JyrUserVo vo){
|
|
|
+ if (StringUtils.isEmpty(vo.getId())) {
|
|
|
+ //添加
|
|
|
+ JyrUserModel model = new JyrUserModel();
|
|
|
+ BeanUtils.copyProperties(vo, model);
|
|
|
+
|
|
|
+
|
|
|
+ jyrUserService.add(model);
|
|
|
+ } else {
|
|
|
+ //修改
|
|
|
+ JyrUserModel model = jyrUserService.findById(vo.getId());
|
|
|
+ BeanUtils.copyProperties(vo, model);
|
|
|
+ jyrUserService.update(model);
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 添加或修改证书
|
|
|
+ * @param vo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("saveBlob")
|
|
|
+ @ResponseBody
|
|
|
+ public WebJsonResult saveBlob ( HttpServletRequest request,BloBVo vo) {
|
|
|
+ String path = request.getSession().getServletContext().getRealPath("");
|
|
|
+
|
|
|
+ // 创建一个通用的多部分解析器
|
|
|
+ CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(request.getSession()
|
|
|
+ .getServletContext());
|
|
|
+ // 判断 request 是否有文件上传,即多部分请求
|
|
|
+ if (multipartResolver.isMultipart(request)) {
|
|
|
+ // 转换成多部分request
|
|
|
+ MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
|
|
|
+ // 取得request中的所有文件名
|
|
|
+ }
|
|
|
+ String sys = "C:\\Users\\Administrator\\Desktop\\";
|
|
|
+ InputStream inputStream;
|
|
|
+ byte[] data = new byte[] {};
|
|
|
+ try {
|
|
|
+ inputStream = new FileInputStream(new File(sys+vo.getFile()));
|
|
|
+ data = inputStreamToByte(inputStream);
|
|
|
+ } catch (FileNotFoundException e1) {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //将文件保存到字节数组中
|
|
|
+ if (StringUtils.isEmpty(vo.getId())) {
|
|
|
+ //添加
|
|
|
+ BloBModel model = new BloBModel();
|
|
|
+ BeanUtils.copyProperties(vo, model);
|
|
|
+ model.setValue(data);
|
|
|
+ bloBService.add(model);
|
|
|
+ } else {
|
|
|
+ //修改
|
|
|
+ BloBModel model = bloBService.findById(vo.getId());
|
|
|
+ BeanUtils.copyProperties(vo, model);
|
|
|
+ bloBService.update(model);
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ private byte [] inputStreamToByte(InputStream is) throws IOException {
|
|
|
+ ByteArrayOutputStream bAOutputStream = new ByteArrayOutputStream();
|
|
|
+ int ch;
|
|
|
+ while((ch = is.read() ) != -1){
|
|
|
+ bAOutputStream.write(ch);
|
|
|
+ }
|
|
|
+ byte data [] =bAOutputStream.toByteArray();
|
|
|
+ bAOutputStream.close();
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 删除信息,可多条删除
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("delJyrUserInfo")
|
|
|
+ @ResponseBody
|
|
|
+ public WebJsonResult delJyrInfo (String ids) {
|
|
|
+ String[] idArray = ids.split(",");
|
|
|
+ if (idArray != null && idArray.length > 0 ) {
|
|
|
+ for (String id : idArray) {
|
|
|
+ JyrUserModel model = jyrUserService.findById(id);
|
|
|
+ model.setState(BaseUUIDModel.STATE_DELETE);
|
|
|
+ jyrUserService.update(model);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 导出
|
|
|
+ * @param model
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ *//*
|
|
|
+ @RequestMapping("printJyrInfo")
|
|
|
+ @ResponseBody
|
|
|
+ public void printJyrInfo (JyrjcxxModel model,HttpServletRequest request,HttpServletResponse response) {
|
|
|
+
|
|
|
+ List<JyrInfoExcelModel> list = jyrjcxxService.selectExcelList(model);
|
|
|
+ //数据加工处理
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ JyrInfoExcelModel jyr = list.get(0);
|
|
|
+ if (jyr.getSfwhqy() != null && !"".equals(jyr.getSfwhqy())) {
|
|
|
+ if ("Y".equals(jyr.getSfwhqy())) {
|
|
|
+ jyr.setSfwhqy("是");
|
|
|
+ } else if ("W".equals(jyr.getSfwhqy())) {
|
|
|
+ jyr.setSfwhqy("是");
|
|
|
+ } else if ("N".equals(jyr.getSfwhqy())) {
|
|
|
+ jyr.setSfwhqy("否");
|
|
|
+ }
|
|
|
+ if ("Y".equals(jyr.getSfwhqy2())) {
|
|
|
+ jyr.setSfwhqy2("是");
|
|
|
+ } else if ("W".equals(jyr.getSfwhqy2())) {
|
|
|
+ jyr.setSfwhqy2("否");
|
|
|
+ } else if ("N".equals(jyr.getSfwhqy2())) {
|
|
|
+ jyr.setSfwhqy2("否");
|
|
|
+ }
|
|
|
+ list.remove(0);
|
|
|
+ list.add(jyr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExportExcel<JyrInfoExcelModel> excel = new ExportExcel<JyrInfoExcelModel>();
|
|
|
+ String[] heads = {"经营人名称","类别","是否危货企业","有无重大危险源","港口经营许可证","港口危险作业附证编号","经营范围","法定代表人","安全部门负责人","值班电话","所在地","所在港区"};
|
|
|
+ excel.exportExcel("经营人管理信息", heads , list, request, response);
|
|
|
+ }
|
|
|
+ */
|
|
|
+}
|