| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211 |
- package platform.modules.government.web;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.ResponseEntity;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.*;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import org.springframework.web.multipart.MultipartFile;
- import platform.common.Constant;
- import platform.common.annotation.OperationLog;
- import platform.common.base.controller.BaseController;
- import platform.common.base.model.DictionaryItem;
- import platform.common.base.model.DictionaryType;
- import platform.common.base.model.Template;
- import platform.common.base.service.DictionaryItemService;
- import platform.common.base.service.DictionaryTypeService;
- import platform.common.base.service.TemplateService;
- import platform.common.util.ReadExcelUtil;
- import platform.common.util.holiday.HolidayExcelParser;
- import platform.common.util.holiday.HolidayExcelTemplateUtil;
- import platform.modules.build.entity.BuildInfo;
- import platform.modules.build.service.BuildInfoService;
- import platform.modules.build.service.CompanyService;
- import platform.modules.government.dto.AttachmentDto;
- import platform.modules.government.entity.Attachment;
- import platform.modules.government.entity.BuildType;
- import platform.modules.government.entity.Street;
- import platform.modules.government.entity.User;
- import platform.modules.government.service.AttachmentService;
- import platform.modules.government.service.BuildTypeService;
- import platform.modules.government.service.StreetService;
- import platform.modules.government.service.UserService;
- import platform.modules.sys.entity.SysConfig;
- import platform.modules.sys.service.SysConfigService;
- import platform.modules.sys.web.ResponseMessage;
- import tk.mybatis.mapper.entity.Example;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- @Controller
- @RequestMapping(value = "/super")
- public class SupermeController extends BaseController {
- @Autowired
- private StreetService streeService;
- @Autowired
- private BuildTypeService buildTypeService;
- @Autowired
- private BuildInfoService buildService;
- @Autowired
- private CompanyService companyService;
-
- @Autowired
- private DictionaryTypeService dictionaryTypeService;
-
- @Autowired
- private DictionaryItemService dictionaryItemService;
-
- @Autowired
- private TemplateService templateService;
- @Autowired
- private UserService userService;
- @Autowired
- private AttachmentService attachmentService;
- @Autowired
- private SysConfigService sysConfigService;
- @Resource
- private HolidayExcelTemplateUtil holidayExcelTemplateUtil;
-
- @GetMapping(value = "")
- public String list() {
- return BASE_SUPER_PATH + "/datadictionary";
- }
- /**
- * 街道列表展示
- *
- * @param pageNum
- * @param keyword
- * @param modelMap
- * @return
- * @throws Exception
- */
- @OperationLog(value = "查询街道列表")
- @GetMapping(value = "/streeList")
- public String streeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
- ModelMap modelMap) throws Exception {
- PageInfo<Street> pageInfo = streeService.findPage(pageNum, PAGESIZE, keyword);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("keyword", keyword);
- return BASE_SUPER_PATH + "/stree_list";
- }
- @GetMapping(value = "/stree/add")
- public String addStreePage(ModelMap modelMap) {
- return BASE_SUPER_PATH + "/stree_add";
- }
- @OperationLog(value = "街道信息保存")
- @ResponseBody
- @PostMapping(value = "/stree/save")
- public ModelMap saveStree(Street stree) throws Exception {
- ModelMap messagesMap = new ModelMap();
- if(IsTooFrequently()) {
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作过于频繁,请稍后再试!");
- return messagesMap;
- }
- Boolean flag = false;
- if (stree.getId() == null) {
- flag = streeService.saveStree(stree);
- } else {
- flag = streeService.updateStree(stree);
- }
- if (flag) {
- messagesMap.put("status", SUCCESS);
- messagesMap.put("message", "操作成功!");
- return messagesMap;
- }
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作失败!");
- return messagesMap;
- }
- /**
- * 跳转到编辑页面
- *
- * @return
- */
- @GetMapping(value = "/stree/edit/{id}")
- public String editStree(@PathVariable("id") int id, ModelMap modelMap) {
- Street stree = streeService.findById(id);
- log.info("跳转到内容编辑页面!id = {}", id);
- modelMap.put("stree", stree);
- return BASE_SUPER_PATH + "/stree_edit";
- }
- @OperationLog(value = "街道删除")
- @ResponseBody
- @PutMapping(value = "/stree/delete")
- public ResponseMessage deleteStree(@RequestParam("ids") String ids) {
- Street stree = streeService.findById(Integer.parseInt(ids));
- if (null == stree) {
- return ResponseMessage.error("未找到相应的街道");
- }
-
- //若街道下面有园区,则不能删。
- Integer buildCount = buildService.findBuildCountByStreet(Integer.parseInt(ids));
- if(buildCount>0){
- return ResponseMessage.error("删除失败!该街道下存在园区,不能删除。");
- }
- stree.setDel_flag(true);
- Boolean flag = streeService.updateStree(stree);
- if (flag) {
- return ResponseMessage.success("删除成功!");
- } else {
- return ResponseMessage.error("删除失败!");
- }
- }
- @OperationLog(value = "园区类型删除")
- @ResponseBody
- @PutMapping(value = "/buildType/delete")
- public ResponseMessage deleteBuildType(@RequestParam("ids") String ids) {
- BuildType bt = buildTypeService.findById(Integer.parseInt(ids));
- if (null == bt) {
- return ResponseMessage.error("未找到相应的园区类型");
- }
- //若园区类型下面有园区,则不能删除。
- Integer buildCount = buildService.findCountByType(Integer.parseInt(ids));
- if(buildCount>0){
- return ResponseMessage.error("删除失败!该类型下存在园区,不能删除。");
- }
- bt.setDel_flag(true);
- Boolean flag = buildTypeService.updateBuildType(bt);
- if (flag) {
- return ResponseMessage.success("删除成功!");
- } else {
- return ResponseMessage.error("删除失败!");
- }
- }
- @OperationLog(value = "园区删除")
- @ResponseBody
- @PutMapping(value = "/build/delete")
- public ResponseMessage deleteBuild(@RequestParam("ids") String ids) {
- BuildInfo b = buildService.findById(Integer.parseInt(ids));
- if (null == b) {
- return ResponseMessage.error("未找到相应的园区");
- }
- //若园区下面有企业,则不能删。
- Integer companyCount = companyService.findAllCuntCompanyByBuildId(Integer.parseInt(ids));
- if(companyCount>0){
- return ResponseMessage.error("删除失败!该园区下存在企业,不能删除。");
- }
- b.setDel_flag(true);
- Boolean flag = buildService.updateBuild(b);
- if (flag) {
- return ResponseMessage.success("删除成功!");
- } else {
- return ResponseMessage.error("删除失败!");
- }
- }
- @GetMapping(value = "/buildTypeList")
- public String buildTypeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
- ModelMap modelMap) throws Exception {
- PageInfo<BuildType> pageInfo = buildTypeService.findPage(pageNum, PAGESIZE, keyword, Constant.DictType.BUILD);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("keyword", keyword);
- return BASE_SUPER_PATH + "/buildtype_list";
- }
- @GetMapping(value = "/buildType/add")
- public String addBuildTypePage(ModelMap modelMap) {
- return BASE_SUPER_PATH + "/buildtype_add";
- }
- @OperationLog(value = "园区类型保存")
- @ResponseBody
- @PostMapping(value = "/buildType/save")
- public ModelMap saveBuildType(BuildType bt) throws Exception {
- ModelMap messagesMap = new ModelMap();
- if(IsTooFrequently()) {
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作过于频繁,请稍后再试!");
- return messagesMap;
- }
- Boolean flag = false;
- bt.setOpt_type(Constant.DictType.BUILD);
- if (bt.getId() == null) {
- flag = buildTypeService.saveBuildType(bt);
- } else {
- flag = buildTypeService.updateBuildType(bt);
- }
- if (flag) {
- messagesMap.put("status", SUCCESS);
- messagesMap.put("message", "操作成功!");
- return messagesMap;
- }
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作失败!");
- return messagesMap;
- }
- /**
- * 跳转到编辑页面
- *
- * @return
- */
- @GetMapping(value = "/buildType/edit/{id}")
- public String editBuildType(@PathVariable("id") int id, ModelMap modelMap) {
- BuildType buildType = buildTypeService.findById(id);
- modelMap.put("buildType", buildType);
- return BASE_SUPER_PATH + "buildtype_edit";
- }
- @OperationLog(value = "企业类型删除")
- @ResponseBody
- @DeleteMapping(value = "/companyType/delete/{id}")
- public ResponseMessage deleteStreetType(@PathVariable("id") Integer id) {
- BuildType bt = buildTypeService.findById(id);
- if (null == bt) {
- return ResponseMessage.error("未找到相应的企业类型");
- }
- //若园区类型下面有园区,则不能删除。
- Integer buildCount = companyService.countByType(id);
- if(buildCount>0){
- return ResponseMessage.error("删除失败!该类型下存在企业,不能删除。");
- }
- bt.setDel_flag(true);
- Boolean flag = buildTypeService.updateBuildType(bt);
- if (flag) {
- return ResponseMessage.success("删除成功!");
- } else {
- return ResponseMessage.error("删除失败!");
- }
- }
- @GetMapping(value = "/companyTypeList")
- public String streetTypeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
- ModelMap modelMap) throws Exception {
- PageInfo<BuildType> pageInfo = buildTypeService.findPage(pageNum, PAGESIZE, keyword,Constant.DictType.COMPANY);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("keyword", keyword);
- return BASE_SUPER_PATH + "/company_type_list";
- }
- @GetMapping(value = "/companyType/add")
- public String companyTypeAdd() {
- return BASE_SUPER_PATH + "/company_type_add";
- }
- @OperationLog(value = "园区类型保存")
- @ResponseBody
- @PostMapping(value = "/companyTypeSave")
- public ModelMap companyTypeSave(BuildType bt) throws Exception {
- ModelMap messagesMap = new ModelMap();
- if(IsTooFrequently()) {
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作过于频繁,请稍后再试!");
- return messagesMap;
- }
- Boolean flag = false;
- bt.setOpt_type(Constant.DictType.COMPANY);
- if (bt.getId() == null) {
- flag = buildTypeService.saveBuildType(bt);
- } else {
- flag = buildTypeService.updateBuildType(bt);
- }
- if (flag) {
- messagesMap.put("status", SUCCESS);
- messagesMap.put("message", "操作成功!");
- return messagesMap;
- }
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作失败!");
- return messagesMap;
- }
- /**
- * 跳转到编辑页面
- *
- * @return
- */
- @GetMapping(value = "/companyType/edit/{id}")
- public String companyTypeEdit(@PathVariable("id") int id, ModelMap modelMap) {
- BuildType buildType = buildTypeService.findById(id);
- modelMap.put("companyType", buildType);
- return BASE_SUPER_PATH + "company_type_edit";
- }
- @GetMapping(value = "/buildList")
- public String buildList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
- String street_id, String type, ModelMap modelMap) throws Exception {
- HashMap<String, String> param = new HashMap<>();
- param.put("keyWord", keyword);
- param.put("street_id", street_id);
- param.put("type", type);
- PageInfo<BuildInfo> pageInfo = buildService.findSPage(pageNum, PAGESIZE, param);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("keyword", keyword);
- modelMap.put("street_id",StringUtils.isBlank(street_id)?null:Integer.parseInt(street_id));
- modelMap.put("type",StringUtils.isBlank(type)?null:Integer.parseInt(type));
- getBuildPageInit(modelMap);
- return BASE_SUPER_PATH + "/build_list";
- }
- /**
- * 获取园区页面初始化下拉框信息
- *
- * @param modelMap
- */
- private void getBuildPageInit(ModelMap modelMap) {
- modelMap.addAttribute("streeList", streeService.findList());
- modelMap.addAttribute("buildTypeList", buildTypeService.findList(Constant.DictType.BUILD));
- }
- @GetMapping(value = "/build/add")
- public String addBuildPage(ModelMap modelMap) {
- getBuildPageInit(modelMap);
- return BASE_SUPER_PATH + "/build_add";
- }
- /**
- * 跳转到编辑页面
- *
- * @return
- */
- @GetMapping(value = "/build/edit/{id}")
- public String editBuild(@PathVariable("id") int id, ModelMap modelMap) {
- getBuildPageInit(modelMap);
- BuildInfo build = buildService.findById(id);
- modelMap.put("build", build);
- return BASE_SUPER_PATH + "build_edit";
- }
- @OperationLog(value = "园区信息修改")
- @ResponseBody
- @PostMapping(value = "/build/save")
- public ModelMap saveBuild(BuildInfo b) throws Exception {
- ModelMap messagesMap = new ModelMap();
- if(IsTooFrequently()) {
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作过于频繁,请稍后再试!");
- return messagesMap;
- }
- Boolean flag = false;
- if (b.getId() == null) {
- flag = buildService.saveBuild(b);
- } else {
- flag = buildService.updateBuild(b);
- }
- if (flag) {
- messagesMap.put("status", SUCCESS);
- messagesMap.put("message", "操作成功!");
- return messagesMap;
- }
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作失败!");
- return messagesMap;
- }
- /**
- * 检验街道名是否存在
- *
- * @param name
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isExistStreet")
- public Boolean isExistStreet(String id, String name) throws Exception {
- boolean flag = true;
- log.debug("检验街道名是否存在参数! id= {}, name= {}", id, name);
- Street street = streeService.getStreet(name);
- if (null != street) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (street.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验街道名是否存在结果! flag = {}", flag);
- return flag;
- }
- /**
- * 检验园区名是否存在
- *
- * @param name
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isExistBuild")
- public Boolean isExistBuild(String id, String name) throws Exception {
- boolean flag = true;
- log.debug("检验园区名是否存在参数! id= {}, name= {}", id, name);
- BuildInfo buildInfo= buildService.getBuildInfo(name);
- if (null != buildInfo) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (buildInfo.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验园区名是否存在结果! flag = {}", flag);
- return flag;
- }
- /**
- * 检验园区类型是否存在
- *
- * @param name
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isExistBuildType")
- public Boolean isExistBuildType(String id, String name) throws Exception {
- boolean flag = true;
- log.debug("检验园区类型是否存在参数! id= {}, name= {}", id, name);
- BuildType buildInfo= buildTypeService.getBuildInfo(name,Constant.DictType.BUILD);
- if (null != buildInfo) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (buildInfo.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验园区名是否存在结果! flag = {}", flag);
- return flag;
- }
- /**
- * 检验企业类型是否存在
- *
- * @param name
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isExistCompanyType")
- public Boolean isExistCompanyType(String id, String name) throws Exception {
- boolean flag = true;
- log.debug("检验企业类型是否存在! id= {}, name= {}", id, name);
- BuildType buildInfo= buildTypeService.getBuildInfo(name,Constant.DictType.COMPANY);
- if (null != buildInfo) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (buildInfo.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验企业类型是否存在结果! flag = {}", flag);
- return flag;
- }
- /**
- * 更新街道状态
- *
- * @param id
- * @return
- */
- @OperationLog(value = "更新街道状态")
- @ResponseBody
- @PostMapping(value = "/status/{id}")
- public ResponseMessage status(@PathVariable Integer id, @RequestParam("isLock") Boolean isLock) throws Exception {
- log.debug("更新街道状态! ids = {}", id);
- Street street = new Street();
- street.setId(id);
- street.setIs_start(isLock);
- if(1==streeService.updateSelective(street)){
- userService.updateStreetIsStart(id, null, isLock);
- return ResponseMessage.success("更新状态成功!");
- }
- return ResponseMessage.error("更新状态失败!");
- }
- /*********************数据字典**********************/
-
- /**
- * 数据字典类型列表展示
- *
- * @param pageNum
- * @param keyword
- * @param modelMap
- * @return
- * @throws Exception
- */
- @GetMapping(value = "/dictionaryTypeList")
- public String dictionaryTypeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
- ModelMap modelMap) throws Exception {
- PageInfo<DictionaryType> pageInfo = dictionaryTypeService.findPage(pageNum, PAGESIZE, keyword);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("keyword", keyword);
- return BASE_SUPER_PATH + "dictionary/dictionary_type_list";
- }
-
- @GetMapping(value = "/dictionaryType/add")
- public String addDictionaryTypePage(ModelMap modelMap) {
- return BASE_SUPER_PATH + "dictionary/dictionary_type_add";
- }
-
- @GetMapping(value = "/dictionaryType/edit/{id}")
- public String editDictionaryTypePage(@PathVariable("id") int id,ModelMap modelMap) {
- DictionaryType dictionaryType = dictionaryTypeService.findById(id);
- modelMap.put("dictionaryType", dictionaryType);
- return BASE_SUPER_PATH + "dictionary/dictionary_type_edit";
- }
-
- @OperationLog(value = "数据字典类型保存")
- @ResponseBody
- @PostMapping(value = "/dictionaryType/save")
- public ResponseMessage saveDictionaryType(DictionaryType type) throws Exception {
- if(IsTooFrequently()) {
- return ResponseMessage.success("操作过于频繁,请稍后再试!");
- }
- Boolean flag = false;
- if (type.getId() == null) {
- flag = dictionaryTypeService.saveDictionaryType(type);
- } else {
- flag = dictionaryTypeService.updateDictionaryType(type);
- }
- if (flag) {
- return ResponseMessage.success("操作成功!");
- }
- return ResponseMessage.success("操作失败!");
- }
-
- @OperationLog(value = "数据字典类型删除")
- @ResponseBody
- @DeleteMapping(value = "/dictionaryType/delete/{id}")
- public ResponseMessage deleteDictionaryType(@PathVariable("id") int id,ModelMap modelMap) {
- DictionaryType type = dictionaryTypeService.findById(id);
- if (null == type) {
- return ResponseMessage.error("未找到相应的数据类型");
- }
- type.setDel_flag(true);
- Boolean flag = dictionaryTypeService.updateDictionaryType(type);
- if (flag) {
- return ResponseMessage.success("删除成功!");
- } else {
- return ResponseMessage.error("删除失败!");
- }
- }
-
- /**
- * 检验数据类型是否存在
- * @param
- * @param name
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isExistDictionaryType")
- public Boolean isExistDictionaryType(String id, String name) throws Exception {
- boolean flag = true;
- log.debug("检验数据类型是否存在参数! id= {}, name= {}", id, name);
- DictionaryType dictionaryType= dictionaryTypeService.getDictionaryType(name);
- if (null != dictionaryType) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (dictionaryType.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验数据类型是否存在结果! flag = {}", flag);
- return flag;
- }
-
- /**
- * 数据字典条目列表展示
- *
- * @param pageNum
- * @param keyword
- * @param modelMap
- * @return
- * @throws Exception
- */
- @GetMapping(value = "/dictionaryItemList")
- public String dictionaryItemList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
- ModelMap modelMap,Integer typeId) throws Exception {
- Example example = new Example(DictionaryType.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("del_flag", 0);
- criteria.andEqualTo("is_active", 1);
- List<DictionaryType> typeList = dictionaryTypeService.selectByExample(example);
- modelMap.put("typeList", typeList);
- if(null == typeId) {
- if(null != typeList && typeList.size()>0) {
- typeId = typeList.get(0).getId();
- modelMap.put("typeId", typeList.get(0).getId());
- }
- }
- PageInfo<DictionaryItem> pageInfo = dictionaryItemService.findPageByType(pageNum, PAGESIZE, keyword,typeId);
- modelMap.put("typeId", typeId);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("keyword", keyword);
-
- return BASE_SUPER_PATH + "dictionary/dictionary_item_list";
- }
-
- /**
- * 检验数据类型条目是否存在
- * @param
- * @param name
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isExistDictionaryItem")
- public Boolean isExistDictionaryItem(String id, String name,String value,Integer typeId) throws Exception {
- boolean flag = true;
- log.debug("检验数据类型条目是否存在参数! id= {}, name= {}", id, name);
- DictionaryItem dictionaryItem= dictionaryItemService.getDictionaryItem(name,value,typeId);
- if (null != dictionaryItem) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (dictionaryItem.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验数据类型条目是否存在结果! flag = {}", flag);
- return flag;
- }
-
- @GetMapping(value = "/dictionaryItem/add/{typeId}")
- public String addDictionaryItemPage(@PathVariable("typeId") int typeId,ModelMap modelMap) {
- modelMap.put("typeId", typeId);
- return BASE_SUPER_PATH + "dictionary/dictionary_item_add";
- }
-
- @GetMapping(value = "/dictionaryItem/edit/{id}")
- public String editDictionaryItemPage(@PathVariable("id") int id,ModelMap modelMap) {
- DictionaryItem dictionaryItem = dictionaryItemService.findById(id);
- modelMap.put("dictionaryItem", dictionaryItem);
- return BASE_SUPER_PATH + "dictionary/dictionary_item_edit";
- }
-
- @OperationLog(value = "数据字典类型条目保存")
- @ResponseBody
- @PostMapping(value = "/dictionaryItem/save")
- public ResponseMessage saveDictionaryItem(DictionaryItem item) throws Exception {
- if(IsTooFrequently()) {
- return ResponseMessage.success("操作过于频繁,请稍后再试!");
- }
- Boolean flag = false;
- if (item.getId() == null) {
- flag = dictionaryItemService.saveDictionaryItem(item);
- } else {
- flag = dictionaryItemService.updateDictionaryItem(item);
- }
- if (flag) {
- return ResponseMessage.success("操作成功!");
- }
- return ResponseMessage.success("操作失败!");
- }
-
- @OperationLog(value = "数据字典类型条目删除")
- @ResponseBody
- @DeleteMapping(value = "/dictionaryItem/delete/{id}")
- public ResponseMessage deleteDictionaryItem(@PathVariable("id") int id,ModelMap modelMap) {
- DictionaryItem item = dictionaryItemService.findById(id);
- if (null == item) {
- return ResponseMessage.error("未找到相应的数据类型条目");
- }
- item.setDel_flag(true);
- Boolean flag = dictionaryItemService.updateDictionaryItem(item);
- if (flag) {
- return ResponseMessage.success("删除成功!");
- } else {
- return ResponseMessage.error("删除失败!");
- }
- }
-
- /*********************模板管理**********************/
-
- /**
- * 模板管理列表展示
- *
- * @param pageNum
- * @param keyword
- * @param modelMap
- * @return
- * @throws Exception
- */
- @GetMapping(value = "/templateList")
- public String templateList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
- ModelMap modelMap) throws Exception {
- PageInfo<Template> pageInfo = templateService.findPage(pageNum, PAGESIZE, keyword);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("keyword", keyword);
- modelMap.put("fileUrl", setFileUrl());
- return BASE_SUPER_PATH + "template/template_list";
- }
-
- /**
- * 添加模板,如果没有传类型和子类型,默认第一个类型的第一个类别的模板
- * @param pageNum
- * @param keyword
- * @param type_id
- * @param item_id
- * @param modelMap
- * @return
- */
- @GetMapping(value = "/template/add/{type_id}/{item_id}")
- public String addTemplatePage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,String keyword,
- @PathVariable("type_id") Integer type_id,@PathVariable("item_id") Integer item_id,ModelMap modelMap) {
- List<DictionaryType> typeList = new ArrayList<DictionaryType>();
- List<DictionaryItem> itemList = new ArrayList<DictionaryItem>();
-
- Example example = new Example(DictionaryType.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("del_flag", 0);
- criteria.andEqualTo("is_template", 1);
- typeList = dictionaryTypeService.selectByExample(example);
- modelMap.put("typeList", typeList);
- if(null == type_id || type_id == 0) {
- type_id = typeList.get(0).getId();
- }
- modelMap.put("type_id", type_id);
- if(null != type_id && type_id > 0) {
- Example example2 = new Example(DictionaryItem.class);
- Example.Criteria criteria2 = example2.createCriteria();
- criteria2.andEqualTo("del_flag", 0);
- criteria2.andEqualTo("tid", type_id);
- criteria2.andEqualTo("is_active", 1);
- itemList = dictionaryItemService.selectByExample(example2);
- modelMap.put("itemList", itemList);
- if(itemList.size()>0) {
- if(null == item_id || item_id == 0) {
- item_id = itemList.get(0).getId();
- }
- }
- modelMap.put("item_id", item_id);
- }
- Template templateCondition = new Template();
- templateCondition.setType_id(type_id);
- templateCondition.setItem_id(item_id);
- PageInfo<Template> pageInfo = templateService.findPageByCondition(pageNum, PAGESIZE, keyword,templateCondition);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("fileUrl", setFileUrl());
- return BASE_SUPER_PATH + "template/template_add";
- }
-
- /**
- * 修改相应类型的模板,传过来的类型和子类型
- * @param pageNum
- * @param keyword
- * @param type_id
- * @param item_id
- * @param modelMap
- * @return
- */
- @GetMapping(value = "/template/edit/{id}")
- public String editTemplatePage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,String keyword,
- @PathVariable("id") Integer id,ModelMap modelMap) {
- Template template = templateService.findById(id);
- Integer type_id = template.getType_id();
- Integer item_id = template.getItem_id();
- List<DictionaryType> typeList = new ArrayList<DictionaryType>();
- List<DictionaryItem> itemList = new ArrayList<DictionaryItem>();
-
- DictionaryType type = dictionaryTypeService.findById(type_id);
- if(null!=type) {
- typeList.add(type);
- }
- modelMap.put("typeList", typeList);
- modelMap.put("type_id", type_id);
- if(null != type_id && null != item_id && item_id > 0) {
- DictionaryItem item = dictionaryItemService.findById(item_id);
- if(null != item) {
- itemList.add(item);
- }
- }
- modelMap.put("itemList", itemList);
- modelMap.put("item_id", item_id);
-
- Template templateCondition = new Template();
- templateCondition.setType_id(type_id);
- templateCondition.setItem_id(item_id);
- PageInfo<Template> pageInfo = templateService.findPageByCondition(pageNum, PAGESIZE, keyword,templateCondition);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("fileUrl", setFileUrl());
- return BASE_SUPER_PATH + "template/template_add";
- }
-
- /**
- * 添加相应类型的模板文件
- * @param type_id
- * @param item_id
- * @param modelMap
- * @return
- */
- @GetMapping(value = "/template/addFile/{type_id}/{item_id}")
- public String addTemplateFilePage(@PathVariable("type_id") Integer type_id,@PathVariable("item_id") Integer item_id,ModelMap modelMap) {
- modelMap.put("type_id", type_id);
- modelMap.put("item_id", item_id);
- modelMap.put("fileUrl", setFileUrl());
- return BASE_SUPER_PATH + "template/template_file_add";
- }
-
- /**
- * 编辑模板文件
- * @param id
- * @param modelMap
- * @return
- */
- @GetMapping(value = "/template/editFile/{id}")
- public String editTemplateFilePage(@PathVariable("id") int id,ModelMap modelMap) {
- Template template = templateService.findById(id);
- templateService.setFile(template);
- modelMap.put("template", template);
- modelMap.put("fileUrl", setFileUrl());
- return BASE_SUPER_PATH + "template/template_file_edit";
- }
-
- @OperationLog(value = "模板文件保存")
- @ResponseBody
- @PostMapping(value = "/template/save")
- public ResponseMessage saveTemplate(Template template) throws Exception {
- if(IsTooFrequently()) {
- return ResponseMessage.success("操作过于频繁,请稍后再试!");
- }
- Boolean flag = false;
- if (template.getId() == null) {
- flag = templateService.saveTemplate(template);
- } else {
- flag = templateService.updateTemplate(template);
- }
- if (flag) {
- return ResponseMessage.success("操作成功!");
- }
- return ResponseMessage.success("操作失败!");
- }
-
- @OperationLog(value = "模板删除")
- @ResponseBody
- @DeleteMapping(value = "/template/delete/{id}")
- public ResponseMessage deleteTemplate(@PathVariable("id") int id,ModelMap modelMap) {
- Template template = templateService.findById(id);
- if (null == template) {
- return ResponseMessage.error("未找到相应的模板");
- }
- template.setDel_flag(true);
- Boolean flag = templateService.updateTemplate(template);
- if (flag) {
- return ResponseMessage.success("删除成功!");
- } else {
- return ResponseMessage.error("删除失败!");
- }
- }
-
- /**
- * 检验模板名称是否存在
- * @param
- * @param name
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isExistTemplateName")
- public Boolean isExistTemplateName(String id, String name,Integer typeId, Integer itemId) throws Exception {
- boolean flag = true;
- log.debug("检验模板名称是否存在参数! id= {}, name= {}", id, name);
- Template template= templateService.getTemplateByName(name,typeId,itemId);
- if (null != template) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (template.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验模板名称是否存在结果! flag = {}", flag);
- return flag;
- }
- /**
- * 模板管理列表展示
- *
- * @param pageNum
- * @param modelMap
- * @return
- * @throws Exception
- */
- @GetMapping(value = "/industry")
- public String industry(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, ModelMap modelMap) {
- // PageInfo<Template> pageInfo = templateService.findPage(pageNum, PAGESIZE, null);
- PageInfo<AttachmentDto> attachmentPageInfo = attachmentService.findByBusinessType(pageNum, PAGESIZE);
- modelMap.put("pageInfo", attachmentPageInfo);
- modelMap.put("fileUrl", setFileUrl());
- return BASE_SUPER_PATH + "industry/industry_file_list";
- }
- /**
- * 假日信息管理列表展示
- *
- * @param pageNum
- * @param modelMap
- * @return
- * @throws Exception
- */
- @OperationLog(value = "读取假日信息列表")
- @GetMapping(value = "/holidayList")
- public String holidayList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- ModelMap modelMap) throws Exception {
- PageInfo<SysConfig> pageInfo = sysConfigService.findPage(pageNum, PAGESIZE,"year_");
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("fileUrl", setFileUrl());
- return BASE_SUPER_PATH + "holiday/holiday_list";
- }
- /**
- * 添加假日信息
- * @param pageNum
- * @param modelMap
- * @return
- */
- @OperationLog(value = "新增假日信息")
- @GetMapping(value = "/holiday/add")
- public String addHolidayPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,ModelMap modelMap) {
- Map<String,String> mapTemplateFileInfo = holidayExcelTemplateUtil.getTemplateFileInfo();
- modelMap.put("templateFileUrl",mapTemplateFileInfo.get("templateFileUrl"));
- modelMap.put("templateFileName",mapTemplateFileInfo.get("templateFileName"));
- modelMap.put("fileUrl", setFileUrl());
- return BASE_SUPER_PATH + "holiday/holiday_add";
- }
- /**
- * 修改相应假日信息
- * @param pageNum
- * @param modelMap
- * @return
- */
- @OperationLog(value = "编辑假日信息")
- @GetMapping(value = "/holiday/edit/{id}")
- public String editHolidayPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @PathVariable("id") Integer id,ModelMap modelMap) {
- SysConfig holidayInfo = sysConfigService.findById(id);
- modelMap.put("id", holidayInfo.getId());
- modelMap.put("configName", holidayInfo.getConfigName());
- modelMap.put("configKey", holidayInfo.getConfigKey());
- modelMap.put("configValue", holidayInfo.getConfigValue());
- Map<String,String> mapTemplateFileInfo = holidayExcelTemplateUtil.getTemplateFileInfo();
- modelMap.put("templateFileUrl",mapTemplateFileInfo.get("templateFileUrl"));
- modelMap.put("templateFileName",mapTemplateFileInfo.get("templateFileName"));
- modelMap.put("fileUrl", setFileUrl());
- return BASE_SUPER_PATH + "holiday/holiday_add";
- }
- @OperationLog(value = "节假日信息删除")
- @ResponseBody
- @DeleteMapping(value = "/holiday/delete/{id}")
- public ResponseMessage deleteHoliday(@PathVariable("id") int id,ModelMap modelMap) {
- SysConfig ent2Del = sysConfigService.findById(id);
- if (null == ent2Del) {
- return ResponseMessage.error("未找到相应的假日信息");
- }
- ent2Del.setDel_flag(true);
- sysConfigService.update(ent2Del);
- return ResponseMessage.success("删除成功!");
- }
- @OperationLog(value = "导入假日信息")
- @PostMapping(value = "/holiday/import")
- public ResponseEntity<String> importHoliday(HttpServletRequest request, @RequestParam("file") MultipartFile file) throws IOException {
- Map<String, String> mapParseRet;
- String retInfo = "";
- if (file.isEmpty()) {
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("文件不能为空");
- }
- List<ArrayList<String>> readExcel = new ArrayList<>();
- try {
- //调用util方法拿到解析的数据集合
- readExcel = new ReadExcelUtil().readExcel(file);
- // 进一步解析
- mapParseRet = HolidayExcelParser.parse(readExcel);
- if ("true".equals(mapParseRet.get("valid")))
- {
- retInfo = mapParseRet.get("data");
- }else
- {
- retInfo = mapParseRet.get("errMsg");
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return ResponseEntity.status(HttpStatus.OK).body(retInfo);
- }
- @OperationLog(value = "假日信息保存")
- @ResponseBody
- @PostMapping(value = "/holiday/save")
- public ModelMap saveHoliday(@RequestParam(value = "id", defaultValue = "-1") int id,
- @RequestParam(value = "configName", defaultValue = "") String configName,
- @RequestParam(value = "configKey", defaultValue = "") String configKey,
- @RequestParam(value = "configValue", defaultValue = "") String configValue) throws Exception {
- ModelMap messagesMap = new ModelMap();
- if(IsTooFrequently()) {
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作过于频繁,请稍后再试!");
- return messagesMap;
- }
- SysConfig ent2Save;
- if (-1 < id)
- {
- ent2Save = sysConfigService.findById(id);
- }else{
- ent2Save = new SysConfig();
- }
- ent2Save.setConfigName(configName);
- ent2Save.setConfigKey(configKey);
- ent2Save.setConfigValue(configValue.replace(""","\""));
- ent2Save.setDel_flag(false);
- if (-1 < id)
- {
- sysConfigService.update(ent2Save);
- }else{
- sysConfigService.save(ent2Save);
- }
- messagesMap.put("status", SUCCESS);
- messagesMap.put("message", "保存成功!");
- return messagesMap;
- }
- /**
- * 同一年份假日信息是否存在
- *
- * @param configKey
- * @return
- */
- @OperationLog(value = "同一年份假日信息是否存在")
- @ResponseBody
- @GetMapping(value = "/isExistHoliday")
- public Boolean isExistHoliday(String id, String configKey) throws Exception {
- boolean flag = true;
- log.debug("检验同一年份假日信息是否存在参数! id= {}, configKey= {}", id, configKey);
- SysConfig entExist = sysConfigService.getByKey(configKey);
- if (null != entExist) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (entExist.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验假日信息年份是否存在结果! flag = {}", flag);
- return flag;
- }
- }
|