| | |
| | | import com.java110.common.constant.BusinessTypeConstant; |
| | | import com.java110.common.constant.CommonConstant; |
| | | import com.java110.common.constant.CommunityMemberTypeConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.ServiceCodeConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.smo.floor.IFloorInnerServiceSMO; |
| | | import com.java110.dto.FloorDto; |
| | | import com.java110.entity.center.AppService; |
| | | import com.java110.event.service.api.ServiceDataFlowEvent; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.ResponseEntity; |
| | |
| | | @Java110Listener("saveFloorListener") |
| | | public class SaveFloorListener extends AbstractServiceApiDataFlowListener { |
| | | |
| | | |
| | | @Autowired |
| | | private IFloorInnerServiceSMO floorInnerServiceSMOImpl; |
| | | |
| | | |
| | | private static final int DEFAULT_SEQ_COMMUNITY_MEMBER = 2; |
| | |
| | | Assert.jsonObjectHaveKey(paramIn, "userId", "请求报文中未包含userId"); |
| | | Assert.jsonObjectHaveKey(paramIn, "floorNum", "请求报文中未包含floorNum"); |
| | | Assert.jsonObjectHaveKey(paramIn, "communityId", "请求报文中未包含communityId"); |
| | | |
| | | JSONObject paramObj = JSONObject.parseObject(paramIn); |
| | | |
| | | FloorDto floorDto = new FloorDto(); |
| | | floorDto.setFloorNum(paramObj.getString("floorNum")); |
| | | floorDto.setCommunityId(paramObj.getString("communityId")); |
| | | |
| | | |
| | | int floorCount = floorInnerServiceSMOImpl.queryFloorsCount(floorDto); |
| | | |
| | | if (floorCount > 0) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "楼栋编号已经存在"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | return 0; |
| | | } |
| | | |
| | | public IFloorInnerServiceSMO getFloorInnerServiceSMOImpl() { |
| | | return floorInnerServiceSMOImpl; |
| | | } |
| | | |
| | | public void setFloorInnerServiceSMOImpl(IFloorInnerServiceSMO floorInnerServiceSMOImpl) { |
| | | this.floorInnerServiceSMOImpl = floorInnerServiceSMOImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.web.components.floor; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.core.context.IPageData; |
| | | import com.java110.core.context.PageData; |
| | | import com.java110.web.smo.IFloorServiceSMO; |
| | | import com.java110.web.smo.impl.FloorServiceSMOImpl; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 添加小区楼组件 |
| | | */ |
| | | @Component("batchAddFloor") |
| | | public class BatchAddFloorComponent { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(BatchAddFloorComponent.class); |
| | | |
| | | |
| | | @Autowired |
| | | private IFloorServiceSMO floorServiceSMOImpl; |
| | | |
| | | /** |
| | | * 查询小区楼信息 |
| | | * |
| | | * @param pd 页面封装对象 包含页面请求数据 |
| | | * @return ResponseEntity对象返回给页面 |
| | | */ |
| | | public ResponseEntity<String> saveFloor(IPageData pd) { |
| | | |
| | | JSONObject floors = JSONObject.parseObject(pd.getReqData()); |
| | | |
| | | Assert.hasKeyAndValue(floors, "startFloorNum", "请求报文中未包含startFloorNum 节点"); |
| | | Assert.hasKeyAndValue(floors, "endFloorNum", "请求报文中未包含startFloorNum 节点"); |
| | | Assert.hasKeyAndValue(floors, "communityId", "请求报文中未包含communityId 节点"); |
| | | |
| | | Assert.isInteger(floors.getString("startFloorNum"), "开始楼栋编号不是数字"); |
| | | Assert.isInteger(floors.getString("endFloorNum"), "结束楼栋编号不是数字"); |
| | | |
| | | int startFloorNum = floors.getInteger("startFloorNum"); |
| | | int endFloorNum = floors.getInteger("endFloorNum"); |
| | | |
| | | if (endFloorNum <= startFloorNum) { |
| | | throw new IllegalArgumentException("结束楼栋编号不能小于等于开始楼栋编号"); |
| | | } |
| | | |
| | | if (endFloorNum - startFloorNum > 50) { |
| | | throw new IllegalArgumentException("一次批量生成不能超过50栋楼"); |
| | | } |
| | | |
| | | int successFloorCount = 0; |
| | | int failFloorCount = 0; |
| | | |
| | | IPageData newPd = null; |
| | | |
| | | /** |
| | | * "communityId", "未包含 |
| | | * "name", "未包含小区楼名称") |
| | | * "floorNum", "未包含小区楼 |
| | | * "remark", "未包含小区楼备注 |
| | | */ |
| | | JSONObject needReqParam = null; |
| | | ResponseEntity<String> floorEntity = null; |
| | | for (int floorIndex = startFloorNum; floorIndex <= endFloorNum; floorIndex++) { |
| | | try { |
| | | needReqParam = new JSONObject(); |
| | | needReqParam.put("communityId", floors.getString("communityId")); |
| | | needReqParam.put("floorNum", floorIndex); |
| | | needReqParam.put("name", floorIndex + "号楼"); |
| | | needReqParam.put("remark", floors.containsKey("remark") ? floors.getString("remark") : ""); |
| | | newPd = PageData.newInstance().builder(pd.getUserId(), |
| | | pd.getToken(), |
| | | needReqParam.toJSONString(), |
| | | pd.getComponentCode(), |
| | | pd.getComponentMethod(), "", pd.getSessionId()); |
| | | floorEntity = floorServiceSMOImpl.saveFloor(newPd); |
| | | |
| | | if(floorEntity.getStatusCode() == HttpStatus.OK){ |
| | | successFloorCount ++; |
| | | }else{ |
| | | failFloorCount ++; |
| | | } |
| | | }catch (Exception e){ |
| | | logger.error("批量生成楼栋失败",e); |
| | | failFloorCount ++; |
| | | } |
| | | } |
| | | |
| | | JSONObject outParam = new JSONObject(); |
| | | outParam.put("successFloorCount",successFloorCount); |
| | | outParam.put("failFloorCount",failFloorCount); |
| | | |
| | | |
| | | return new ResponseEntity<String>(outParam.toJSONString(), HttpStatus.OK); |
| | | } |
| | | |
| | | |
| | | public IFloorServiceSMO getFloorServiceSMOImpl() { |
| | | return floorServiceSMOImpl; |
| | | } |
| | | |
| | | public void setFloorServiceSMOImpl(IFloorServiceSMO floorServiceSMOImpl) { |
| | | this.floorServiceSMOImpl = floorServiceSMOImpl; |
| | | } |
| | | } |
| | |
| | | <div> |
| | | <div class="form-group row"> |
| | | <label class="col-sm-2 col-form-label">楼栋编号</label> |
| | | <div class="col-sm-10"><input v-model="addFloorInfo.floorNum" type="text" |
| | | <div class="col-sm-10"><input v-model="addFloorInfo.floorNum" type="number" |
| | | placeholder="必填,请填写编号" class="form-control"></div> |
| | | </div> |
| | | <div class="form-group row"> |
| New file |
| | |
| | | <div id="batchAddFloor" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" |
| | | aria-hidden="true"> |
| | | <div class="modal-dialog modal-lg"> |
| | | <div class="modal-content"> |
| | | <div class="modal-body"> |
| | | <h3 class="m-t-none m-b ">批量添加楼栋</h3> |
| | | <div class="ibox-content"> |
| | | <div> |
| | | <p style="color:red;">{{batchAddFloorInfo.errorInfo}}</p> |
| | | <div> |
| | | <div class="form-group row"> |
| | | <label class="col-sm-2 col-form-label">楼栋开始编号</label> |
| | | <div class="col-sm-10"><input v-model="batchAddFloorInfo.startFloorNum" type="number" |
| | | placeholder="必填,请填写楼栋开始编号" class="form-control"></div> |
| | | </div> |
| | | <div class="form-group row"> |
| | | <label class="col-sm-2 col-form-label">楼栋结束编号</label> |
| | | <div class="col-sm-10"><input v-model="batchAddFloorInfo.endFloorNum" type="number" |
| | | placeholder="必填,请填写楼栋结束编号" class="form-control"></div> |
| | | </div> |
| | | <div class="form-group row"> |
| | | <label class="col-sm-2 col-form-label">备注</label> |
| | | <div class="col-sm-10"><textarea cols="5" v-model="batchAddFloorInfo.remark" type="tel" |
| | | placeholder="可填,请填写备注" class="form-control"></textarea></div> |
| | | </div> |
| | | <div class="ibox-content"> |
| | | <button class="btn btn-primary float-right" type="button" v-on:click="batchSaveFloorInfo()"> |
| | | <i class="fa fa-check"></i> 批量生成 |
| | | </button> |
| | | <button type="button" class="btn btn-warning float-right" style="margin-right:20px;" |
| | | data-dismiss="modal">取消 |
| | | </button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| New file |
| | |
| | | (function(vc){ |
| | | |
| | | vc.extends({ |
| | | propTypes: { |
| | | callBackListener:vc.propTypes.string, //父组件名称 |
| | | callBackFunction:vc.propTypes.string //父组件监听方法 |
| | | }, |
| | | data:{ |
| | | batchAddFloorInfo:{ |
| | | |
| | | startFloorNum:'', |
| | | endFloorNum:'', |
| | | remark:'', |
| | | errorInfo:'' |
| | | } |
| | | }, |
| | | _initMethod:function(){ |
| | | |
| | | }, |
| | | _initEvent:function(){ |
| | | vc.on('batchAddFloor','openBatchAddFloorModal',function(){ |
| | | $('#batchAddFloor').modal('show'); |
| | | }); |
| | | }, |
| | | methods:{ |
| | | batchAddFloorValidate(){ |
| | | return vc.validate.validate({ |
| | | batchAddFloorInfo:vc.component.batchAddFloorInfo |
| | | },{ |
| | | 'batchAddFloorInfo.startFloorNum':[ |
| | | { |
| | | limit:"required", |
| | | param:"", |
| | | errInfo:"楼开始编号不能为空" |
| | | }, |
| | | { |
| | | limit:"num", |
| | | param:"", |
| | | errInfo:"楼开始编号不是有效的数字" |
| | | }, |
| | | ], |
| | | 'batchAddFloorInfo.endFloorNum':[ |
| | | { |
| | | limit:"required", |
| | | param:"", |
| | | errInfo:"楼结束编号不能为空" |
| | | }, |
| | | { |
| | | limit:"num", |
| | | param:"", |
| | | errInfo:"楼结束编号不是有效的数字" |
| | | }, |
| | | ], |
| | | 'batchAddFloorInfo.remark':[ |
| | | |
| | | { |
| | | limit:"maxLength", |
| | | param:"200", |
| | | errInfo:"备注长度不能超过200位" |
| | | } |
| | | ] |
| | | |
| | | }); |
| | | }, |
| | | batchSaveFloorInfo:function(){ |
| | | if(!vc.component.batchAddFloorValidate()){ |
| | | vc.message(vc.validate.errInfo); |
| | | |
| | | return ; |
| | | } |
| | | |
| | | if(parseInt(vc.component.batchAddFloorInfo.endFloorNum) <= parseInt(vc.component.batchAddFloorInfo.startFloorNum)){ |
| | | vc.message('结束楼栋编号不能小于等于开始楼栋编号'); |
| | | return; |
| | | } |
| | | |
| | | |
| | | if(vc.component.batchAddFloorInfo.endFloorNum - vc.component.batchAddFloorInfo.startFloorNum > 50){ |
| | | vc.message('一次批量生成不能超过50栋楼'); |
| | | return; |
| | | } |
| | | |
| | | |
| | | vc.component.batchAddFloorInfo.communityId = vc.getCurrentCommunity().communityId; |
| | | |
| | | //不提交数据将数据 回调给侦听处理 |
| | | if(vc.notNull($props.callBackListener)){ |
| | | vc.emit($props.callBackListener,$props.callBackFunction,vc.component.batchAddFloorInfo); |
| | | $('#batchAddFloorModel').modal('hide'); |
| | | return ; |
| | | } |
| | | |
| | | vc.http.post( |
| | | 'batchAddFloor', |
| | | 'saveFloor', |
| | | JSON.stringify(vc.component.batchAddFloorInfo), |
| | | { |
| | | emulateJSON:true |
| | | }, |
| | | function(json,res){ |
| | | //vm.menus = vm.refreshMenuActive(JSON.parse(json),0); |
| | | if(res.status == 200){ |
| | | //关闭model |
| | | $('#batchAddFloor').modal('hide'); |
| | | vc.component.clearBatchAddFloorInfo(); |
| | | vc.emit('listFloor','listFloorData',{}); |
| | | var resultInfo = JSON.parse(json); |
| | | vc.message("楼栋成功生成"+resultInfo.successFloorCount+",失败"+resultInfo.failFloorCount) |
| | | return ; |
| | | } |
| | | vc.component.batchAddFloorInfo.errorInfo = json; |
| | | |
| | | }, |
| | | function(errInfo,error){ |
| | | console.log('请求失败处理'); |
| | | |
| | | vc.component.batchAddFloorInfo.errorInfo = errInfo; |
| | | |
| | | }); |
| | | }, |
| | | clearBatchAddFloorInfo:function(){ |
| | | vc.component.batchAddFloorInfo = { |
| | | startFloorNum:'', |
| | | endFloorNum:'', |
| | | remark:'', |
| | | errorInfo:'' |
| | | }; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | })(window.vc); |
| | |
| | | <div> |
| | | <div class="form-group row"> |
| | | <label class="col-sm-2 col-form-label">楼栋编号</label> |
| | | <div class="col-sm-10"><input v-model="editFloorInfo.floorNum" type="email" |
| | | <div class="col-sm-10"><input v-model="editFloorInfo.floorNum" type="number" |
| | | placeholder="必填,请填写编号" class="form-control"></div> |
| | | </div> |
| | | <div class="form-group row"> |
| | |
| | | <i class="glyphicon glyphicon-plus"></i> |
| | | 添加楼栋 |
| | | </button> |
| | | <button type="button" class="btn btn-primary btn-sm" v-on:click="_openBatchAddFloorModal()"> |
| | | <i class="glyphicon glyphicon-plus"></i> |
| | | 批量生成 |
| | | </button> |
| | | </div> |
| | | </div> |
| | | <div class="ibox-content"> |
| | |
| | | callBackListener="" |
| | | callBackFunction="" |
| | | ></vc:create> |
| | | <vc:create name="batchAddFloor" |
| | | callBackListener="" |
| | | callBackFunction="" |
| | | ></vc:create> |
| | | <vc:create name="editFloor"></vc:create> |
| | | <vc:create name="deleteFloor"></vc:create> |
| | | |
| | |
| | | _openAddFloorModal:function(){ //打开添加框 |
| | | vc.emit('addFloor','openAddFloorModal',{}); |
| | | }, |
| | | _openBatchAddFloorModal:function(){ //打开批量添加框 |
| | | vc.emit('batchAddFloor','openBatchAddFloorModal',{}); |
| | | }, |
| | | _openDelFloorModel:function(_floor){ // 打开删除对话框 |
| | | vc.emit('deleteFloor','openFloorModel',_floor); |
| | | }, |
| | |
| | | * @param {校验文本} text |
| | | */ |
| | | num:function(text){ |
| | | var regNum = /^[0-9]+$/; |
| | | var regNum = /^[1-9][0-9]+$/; |
| | | return regNum.test(text); |
| | | }, |
| | | date:function(str) { |