diff --git a/src/main/java/com/huaheng/api/wcs/controller/WarecellAllocation.java b/src/main/java/com/huaheng/api/wcs/controller/WarecellAllocation.java index eec6fe0..e89d5d1 100644 --- a/src/main/java/com/huaheng/api/wcs/controller/WarecellAllocation.java +++ b/src/main/java/com/huaheng/api/wcs/controller/WarecellAllocation.java @@ -31,7 +31,7 @@ public class WarecellAllocation extends BaseController { @PostMapping("/WarecellAllocation") @ApiOperation(value="wcs仓位分配", notes="wcs仓位分配", httpMethod = "POST") @ResponseBody - public AjaxResult WarecellAllocation(String taskNo, String length, String width, String height, String weight, String destination) { + public AjaxResult WarecellAllocation(String taskNo, String length, String width, String height, String weight, String destination, String locationType) { WcsTask wcsTask = new WcsTask(); wcsTask.setTaskNo(taskNo); wcsTask.setLength(length); @@ -39,7 +39,14 @@ public class WarecellAllocation extends BaseController { wcsTask.setHeight(height); wcsTask.setWeight(weight); wcsTask.setDestination(destination); - return warecellAllocationService.warecellAllocation(wcsTask); + wcsTask.setLocationType(locationType); + AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() { + @Override + public AjaxResult doProcess() { + return warecellAllocationService.warecellAllocation(wcsTask); + } + }); + return ajaxResult; } diff --git a/src/main/java/com/huaheng/api/wcs/domain/WcsTask.java b/src/main/java/com/huaheng/api/wcs/domain/WcsTask.java index 837183a..2e65254 100644 --- a/src/main/java/com/huaheng/api/wcs/domain/WcsTask.java +++ b/src/main/java/com/huaheng/api/wcs/domain/WcsTask.java @@ -24,6 +24,9 @@ public class WcsTask implements Serializable { //任务类型 private String taskType; + //任务类型 + private String locationType; + //出库站台编码.默认‘0’ private String station; diff --git a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java index dc811a8..83c8c69 100644 --- a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java +++ b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java @@ -66,7 +66,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService private MaterialTypeService materialTypeService; /** - * 仓位分配 + * 立库仓位分配 * 1、判断非空字段 * 2、实体转换 * 3、查询满足条件的库位类型 @@ -96,7 +96,20 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService if(StringUtils.isNull(wcsTask.getWeight())){ return AjaxResult.error("重为空"); } + String locationType = null; + if(StringUtils.isNull(wcsTask.getLocationType())){ + locationType = "L"; + } else { + locationType = wcsTask.getLocationType(); + } + if(locationType.equals("L")) { + return verticalWarehouseAllocation(wcsTask); + } + + return AjaxResult.error("库位类型错误"); + } + public AjaxResult verticalWarehouseAllocation(WcsTask wcsTask) { //查询满足条件的库位类型 LambdaQueryWrapper<LocationType> lambdaQueryWrapper = Wrappers.lambdaQuery(); lambdaQueryWrapper.gt(LocationType::getLength,wcsTask.getLength()) @@ -115,6 +128,8 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService taskDetailLambda.eq(TaskDetail::getTaskId, wcsTask.getTaskNo()); List<TaskDetail> taskDetailList = taskDetailService.list(taskDetailLambda); + TaskHeader taskHeader = taskHeaderService.getById(wcsTask.getTaskNo()); + /* 循环查询入库组盘明细*/ List<ReceiptContainerDetail> receiptContainerDetailList = new ArrayList<>(); for (TaskDetail taskDetail : taskDetailList) { @@ -131,15 +146,19 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService LambdaQueryWrapper<FilterConfigDetail> filterConfigDetailLambda = Wrappers.lambdaQuery(); filterConfigDetailLambda.eq(FilterConfigDetail::getCode, locatingRule) - .eq(FilterConfigDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); + .eq(FilterConfigDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); FilterConfigDetail filterConfigDetail = filterConfigDetailService.getOne(filterConfigDetailLambda); - String[] locatingRules = filterConfigDetail.getStatement().split("limit"); + String[] locatingRules = filterConfigDetail.getStatement().split("cut"); //根据定位规则查询库位编码 LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery(); locationLambda.last(locatingRules[0]); + locationLambda.eq(Location::getRoadway, wcsTask.getDestination()); List<Location> locationList = locationService.list(locationLambda); -// locationList.stream().filter(location -> location.getLocationType().equals(locationTypeList.get(0))); + if(locationList == null || locationList.size() == 0) { + locationLambda.last(locatingRules[1]); + locationList = locationService.list(locationLambda); + }; locationCode = filter(locationList, locationTypeList, wcsTask.getDestination()); if (StringUtils.isEmpty(locationCode)){ throw new ServiceException("没有库位可分配"); @@ -147,6 +166,9 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService if (StringUtils.isNotEmpty(locationCode)){ locationService.updateStatus(locationCode, "lock"); + if (StringUtils.isNotEmpty(taskHeader.getToLocation()) && !locationCode.equals(taskHeader.getToLocation())){ + locationService.updateStatus(taskHeader.getToLocation(), "empty"); + } } else { throw new ServiceException("定位失败,请检查定位规则是否正确"); } @@ -160,7 +182,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService //把库位编码赋到该入库组盘头表下的所有明细 LambdaQueryWrapper<ReceiptContainerDetail> lambda = Wrappers.lambdaQuery(); lambda.eq(ReceiptContainerDetail::getReceiptContainerId, receiptContainerHeader.getId()) - .eq(ReceiptContainerDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); + .eq(ReceiptContainerDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.list(lambda); for (ReceiptContainerDetail receiptContainerDetail2: receiptContainerDetails) { receiptContainerDetail2.setLocationCode(locationCode); @@ -175,10 +197,25 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService if (!taskDetailService.updateById(taskDetail)){ throw new ServiceException("更新任务明细目标库位失败");} } - TaskHeader taskHeader = taskHeaderService.getById(wcsTask.getTaskNo()); taskHeader.setToLocation(locationCode); if (!taskHeaderService.updateById(taskHeader)){throw new ServiceException("更新任务头表目标库位失败");} + + LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); + locationLambdaQueryWrapper.eq(Location::getCode, locationCode); + Location location = locationService.getOne(locationLambdaQueryWrapper); + int rowFlag = location.getRowFlag().intValue(); + //如果是外侧库位,那么就要判断该库位对应的内侧库位是不是有托盘 + if(rowFlag == 1) { + Location insideLocation = locationService.getInsideNear(location); + if(StringUtils.isNotEmpty(insideLocation.getContainerCode())) { + Location destinationLocation = locationService.getEmptyInsideLocation(insideLocation); + AjaxResult ajaxResult = taskHeaderService.createTransferTask(insideLocation.getCode(), destinationLocation.getCode()); + if(ajaxResult.hasErr()) { + throw new ServiceException("创建移库任务失败"); + } + } + } return AjaxResult.success(locationCode); } diff --git a/src/main/java/com/huaheng/framework/web/controller/BaseController.java b/src/main/java/com/huaheng/framework/web/controller/BaseController.java index c240ead..000eed5 100644 --- a/src/main/java/com/huaheng/framework/web/controller/BaseController.java +++ b/src/main/java/com/huaheng/framework/web/controller/BaseController.java @@ -3,6 +3,8 @@ package com.huaheng.framework.web.controller; import java.util.Date; import java.util.List; import java.text.SimpleDateFormat; +import java.util.concurrent.Semaphore; + import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.huaheng.framework.web.page.PageDomain; @@ -188,4 +190,44 @@ public class BaseController rspData.setTotal(total); return rspData; } + + Semaphore semaphore=new Semaphore(1); + + public AjaxResult handleMultiProcess(MultiProcessListener multiProcessListener) { + AjaxResult ajaxResult = null; + int max_time = 10 * 1000; + int now = 0; + boolean avail = true; + while(avail) { + int availablePermits = semaphore.availablePermits(); + if(availablePermits >0) { + avail = false; + try { + semaphore.acquire(1); + ajaxResult = multiProcessListener.doProcess(); + } catch (Exception e) { + e.printStackTrace(); + ajaxResult = AjaxResult.error("多线程处理异常"); + } finally { + semaphore.release(1); + } + } else { + ajaxResult = AjaxResult.error("多线程处理异常"); + try { + now = now + 200; + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if(now >= max_time) { + avail = false; + } + } + } + return ajaxResult; + } + + public interface MultiProcessListener { + AjaxResult doProcess(); + } } diff --git a/src/main/java/com/huaheng/pc/config/corporation/domain/Corporation.java b/src/main/java/com/huaheng/pc/config/corporation/domain/Corporation.java index 4482930..dbef756 100644 --- a/src/main/java/com/huaheng/pc/config/corporation/domain/Corporation.java +++ b/src/main/java/com/huaheng/pc/config/corporation/domain/Corporation.java @@ -1,5 +1,6 @@ package com.huaheng.pc.config.corporation.domain; +import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -108,6 +109,7 @@ public class Corporation implements Serializable { * 拼装图片存储 * @return */ + @JSONField(serialize = false) public String getSavePath(){ return this.getBaseAddress() + this.getSubPath(); } @@ -116,6 +118,7 @@ public class Corporation implements Serializable { * 拼装图片相对路径 * @return */ + @JSONField(serialize = false) public String getSubPath(){ return "img/corporation/" + this.getId() + "/"; } @@ -124,6 +127,7 @@ public class Corporation implements Serializable { * 取pLogoBig的存储路径 * @return */ + @JSONField(serialize = false) public String getPLogoBigPath(){ return this.getBaseAddress() + this.getPLogoBig(); } @@ -132,6 +136,7 @@ public class Corporation implements Serializable { * 取pLogoSmall的存储路径 * @return */ + @JSONField(serialize = false) public String getPLogoSmallPath(){ return this.getBaseAddress() + this.getPLogoSmall(); } @@ -140,6 +145,7 @@ public class Corporation implements Serializable { * 取pIcon的存储路径 * @return */ + @JSONField(serialize = false) public String getPIconPath(){ return this.getBaseAddress() + this.getPIcon(); } diff --git a/src/main/java/com/huaheng/pc/config/location/domain/Location.java b/src/main/java/com/huaheng/pc/config/location/domain/Location.java index ab6ba76..9ffdac3 100644 --- a/src/main/java/com/huaheng/pc/config/location/domain/Location.java +++ b/src/main/java/com/huaheng/pc/config/location/domain/Location.java @@ -74,6 +74,12 @@ public class Location implements Serializable { private Integer iGrid; /** + * 内外侧标志 + */ + @TableField(value = "rowFlag") + private Integer rowFlag; + + /** * 巷道 */ @TableField(value = "roadway") diff --git a/src/main/java/com/huaheng/pc/config/location/mapper/LocationMapper.java b/src/main/java/com/huaheng/pc/config/location/mapper/LocationMapper.java index 7b2afaa..005480e 100644 --- a/src/main/java/com/huaheng/pc/config/location/mapper/LocationMapper.java +++ b/src/main/java/com/huaheng/pc/config/location/mapper/LocationMapper.java @@ -19,6 +19,8 @@ public interface LocationMapper extends BaseMapper<Location> { int addList(@Param("locations") List<Location> locations); + int updateList(@Param("locations") List<Location> locations); + Location getAllLocation(@Param("warehouseCode") String warehouseCode, @Param("type") String type); //库位利用率 diff --git a/src/main/java/com/huaheng/pc/config/location/service/LocationService.java b/src/main/java/com/huaheng/pc/config/location/service/LocationService.java index 7daca9a..3af2ff4 100644 --- a/src/main/java/com/huaheng/pc/config/location/service/LocationService.java +++ b/src/main/java/com/huaheng/pc/config/location/service/LocationService.java @@ -79,4 +79,7 @@ public interface LocationService extends IService<Location>{ List<Location> selectContainerEmpty(String warehouseCode); + Location getInsideNear(Location location); + + Location getEmptyInsideLocation(Location location); } diff --git a/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java b/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java index 2820c72..b77f586 100644 --- a/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java +++ b/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java @@ -160,6 +160,37 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i }else { locationMapper.addList(locations); } + + List<Integer> integerList = new ArrayList<>(); + for(Location location2 : locations) { + if(integerList.size() == 0) { + integerList.add(location2.getIRow()); + } else { + for(int i = 0; i< integerList.size(); i++) { + if(integerList.get(i).intValue() == location2.getIRow().intValue()) { + break; + } else { + if(i == (integerList.size() - 1)) { + integerList.add(location2.getIRow()); + } + } + } + } + } + if(integerList.size() == 4) { + for (Location location3 : locations) { + for (int i = 0; i < integerList.size(); i++) { + if (location3.getIRow().intValue() == integerList.get(i).intValue()) { + if (i == 0 || i == (integerList.size() - 1)) { + location3.setRowFlag(1); + } else { + location3.setRowFlag(0); + } + } + } + } + locationMapper.updateList(locations); + } return true; } @@ -283,5 +314,38 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i return locationMapper.selectContainerEmpty(warehouseCode); } + @Override + public Location getInsideNear(Location location) { + LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.eq(Location::getWarehouseCode, location.getWarehouseCode()); + queryWrapper.eq(Location::getZoneCode, "L"); + queryWrapper.eq(Location::getRoadway, location.getRoadway()); + queryWrapper.eq(Location::getIColumn, location.getIColumn()); + queryWrapper.eq(Location::getILayer, location.getILayer()); + queryWrapper.eq(Location::getLocationType, location.getLocationType()); + queryWrapper.eq(Location::getRowFlag, 0); + List<Location> locationList = list(queryWrapper); + for(Location location1 : locationList) { + int diff = Math.abs(location1.getIRow().intValue() - location.getIRow().intValue()); + if(diff == 1) { + return location1; + } + } + return null; + } + + @Override + public Location getEmptyInsideLocation(Location location) { + LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.eq(Location::getWarehouseCode, location.getWarehouseCode()); + queryWrapper.eq(Location::getZoneCode, "L"); + queryWrapper.eq(Location::getRoadway, location.getRoadway()); + queryWrapper.eq(Location::getRowFlag, 0); + queryWrapper.eq(Location::getContainerCode, ""); + queryWrapper.eq(Location::getLocationType, location.getLocationType()); + Location location1 = getOne(queryWrapper); + return location1; + } + } diff --git a/src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/controller/ReceiptContainerHeaderController.java b/src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/controller/ReceiptContainerHeaderController.java index dec060b..f22e414 100644 --- a/src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/controller/ReceiptContainerHeaderController.java +++ b/src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/controller/ReceiptContainerHeaderController.java @@ -132,7 +132,6 @@ public class ReceiptContainerHeaderController extends BaseController { if (StringUtils.isEmpty(ids)){ return AjaxResult.error("id不能为空"); } - this.position(ids); List<Integer> idList = Arrays.asList(Convert.toIntArray(ids)); List<Integer> idsList = idList.stream().distinct().collect(Collectors.toList()); return receiptTaskService.createReceiptTask(idsList); diff --git a/src/main/java/com/huaheng/pc/receipt/receiving/service/ReceivingService.java b/src/main/java/com/huaheng/pc/receipt/receiving/service/ReceivingService.java index 7896853..a94c116 100644 --- a/src/main/java/com/huaheng/pc/receipt/receiving/service/ReceivingService.java +++ b/src/main/java/com/huaheng/pc/receipt/receiving/service/ReceivingService.java @@ -118,14 +118,21 @@ public class ReceivingService { .eq(FilterConfigDetail::getWarehouseCode,ShiroUtils.getWarehouseCode()); FilterConfigDetail filterConfigDetail = filterConfigDetailService.getOne(lambdaQueryWrapper); + String[] locatingRules = filterConfigDetail.getStatement().split("cut"); //根据定位规则查询库位编码 QueryWrapper<Location> locationLambda = new QueryWrapper(); - locationLambda.eq("1",1).last(filterConfigDetail.getStatement()); + locationLambda.eq("1",1).last(locatingRules[0]); String locationCode = ""; try { - locationCode = locationService.getOne(locationLambda).getCode(); - } catch (NullPointerException e) { - throw new ServiceException("没有库位可分配"); + List<Location> locationList = locationService.list(locationLambda); + locationCode = locationList.get(0).getCode(); + } catch (Exception e) { + + } + if (StringUtils.isEmpty(locationCode)){ + locationLambda.eq("1",1).last(locatingRules[1]); + List<Location> locationList = locationService.list(locationLambda); + locationCode = locationList.get(0).getCode(); } if (StringUtils.isEmpty(locationCode)){ throw new ServiceException("没有库位可分配"); diff --git a/src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java b/src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java index 752fed3..ce93525 100644 --- a/src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java +++ b/src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java @@ -13,6 +13,7 @@ import com.huaheng.common.utils.DataUtils; import com.huaheng.common.utils.StringUtils; import com.huaheng.common.utils.security.ShiroUtils; import com.huaheng.framework.web.domain.AjaxResult; +import com.huaheng.mobile.download.Constant; import com.huaheng.pc.config.configWarning.service.ConfigWarningService; import com.huaheng.pc.config.container.domain.Container; import com.huaheng.pc.config.container.service.ContainerService; @@ -20,6 +21,8 @@ import com.huaheng.pc.config.containerCapacity.domain.ContainerCapacity; import com.huaheng.pc.config.containerCapacity.service.ContainerCapacityService; import com.huaheng.pc.config.location.domain.Location; import com.huaheng.pc.config.location.service.LocationService; +import com.huaheng.pc.config.sendMail.service.MailService; +import com.huaheng.pc.config.sendMail.service.SendMailService; import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail; import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailService; import com.huaheng.pc.inventory.cycleCountHeader.service.CycleCountHeaderService; @@ -29,6 +32,7 @@ import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader; import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService; import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction; import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService; +import com.huaheng.pc.monitor.message.service.BrokerMessageLogService; import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail; import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService; import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader; @@ -52,6 +56,7 @@ import com.huaheng.pc.task.taskHeader.domain.MobileTask; import com.huaheng.pc.task.taskHeader.domain.ShipmentTaskCreateModel; import com.huaheng.pc.task.taskHeader.domain.TaskHeader; import com.huaheng.pc.task.taskHeader.mapper.TaskHeaderMapper; +import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/com/huaheng/pc/tool/gen/domain/GenTableColumn.java b/src/main/java/com/huaheng/pc/tool/gen/domain/GenTableColumn.java index 947e599..021f8c1 100644 --- a/src/main/java/com/huaheng/pc/tool/gen/domain/GenTableColumn.java +++ b/src/main/java/com/huaheng/pc/tool/gen/domain/GenTableColumn.java @@ -162,6 +162,10 @@ public class GenTableColumn extends BaseEntity { return StringUtils.capitalize(javaField); } + public String getCapColumnName(){ + return StringUtils.capitalize(columnName); + } + public void setIsPk(String isPk) { this.isPk = isPk; } diff --git a/src/main/resources/mybatis/config/LocationMapper.xml b/src/main/resources/mybatis/config/LocationMapper.xml index 8393bea..a8f7b7b 100644 --- a/src/main/resources/mybatis/config/LocationMapper.xml +++ b/src/main/resources/mybatis/config/LocationMapper.xml @@ -84,6 +84,41 @@ </foreach> </insert> + <update id="updateList" parameterType="com.huaheng.pc.config.location.domain.Location" keyProperty="id" useGeneratedKeys="true" > + replace INTO location( + code, + warehouseCode, + zoneCode, + locationType, + iRow, + iColumn, + iLayer, + iGrid, + rowFlag, + roadway, + createdBy, + lastUpdatedBy, + status + )values + <foreach collection="locations" item="item" index="index" separator=","> + ( + #{item.code}, + #{item.warehouseCode}, + #{item.zoneCode}, + #{item.locationType}, + #{item.iRow}, + #{item.iColumn}, + #{item.iLayer}, + #{item.iGrid}, + #{item.rowFlag}, + #{item.roadway}, + #{item.createdBy}, + #{item.lastUpdatedBy}, + #{item.status} + ) + </foreach> + </update> + <select id="getAllLocation" resultType="com.huaheng.pc.config.location.domain.Location"> select max(iRow) as iRow,max(iColumn) as iColumn,max(iLayer) as iLayer,max(iGrid) as iGrid from location l where l.warehouseCode=#{warehouseCode} AND l.locationType=#{type} </select> diff --git a/src/main/resources/templates/config/location/location.html b/src/main/resources/templates/config/location/location.html index f71f92a..ebc4d82 100644 --- a/src/main/resources/templates/config/location/location.html +++ b/src/main/resources/templates/config/location/location.html @@ -90,6 +90,7 @@ var editFlag = [[${@permission.hasPermi('config:location:edit')}]]; var removeFlag = [[${@permission.hasPermi('config:location:remove')}]]; var datas = [[${@dict.getType('sys_normal_disable')}]]; + var rowFlags = [[${@dict.getType('rowFlag')}]]; var locationTypes = [[${@dict.getType('locationType')}]]; var locationStatus = [[${@dict.getType('locationStatus')}]]; @@ -136,6 +137,13 @@ title : '格' }, { + field : 'rowFlag', + title : '内外侧', + formatter: function(value, row, index) { + return $.table.selectDictLabel(rowFlags, value); + } + }, + { field : 'name', title : '名称' }, diff --git a/src/main/resources/templates/vm/java/Controller.java.vm b/src/main/resources/templates/vm/java/Controller.java.vm index c1b46ee..262d881 100644 --- a/src/main/resources/templates/vm/java/Controller.java.vm +++ b/src/main/resources/templates/vm/java/Controller.java.vm @@ -1,7 +1,12 @@ package ${packageName}.controller; -import com.baomidou.mybatisplus.mapper.EntityWrapper; -import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.huaheng.framework.web.page.PageDomain; +import com.huaheng.framework.web.page.TableDataInfo; +import com.huaheng.framework.web.page.TableSupport; import com.huaheng.common.utils.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -18,9 +23,10 @@ import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; import com.huaheng.framework.web.controller.BaseController; import com.huaheng.framework.web.domain.AjaxResult; -import com.huaheng.framework.web.page.TableDataInfo; - +import com.huaheng.common.support.Convert; import javax.annotation.Resource; +import java.util.Arrays; +import java.util.Date; import java.util.List; /** @@ -32,7 +38,7 @@ import java.util.List; @Controller @RequestMapping("/${moduleName}/${className}") public class ${ClassName}Controller extends BaseController { - private String prefix = "${moduleName}/${classname}"; + private String prefix = "${moduleName}/${className}"; @Resource private I${ClassName}Service ${className}Service; @@ -56,56 +62,56 @@ public class ${ClassName}Controller extends BaseController { #if(${column.isQuery} == 1) #if(${column.queryType} == "EQ") #if(${column.javaType} == "String") - .eq(StringUtils.isNotEmpty(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .eq(StringUtils.isNotEmpty(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #else - .eq(StringUtils.isNotNull(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .eq(StringUtils.isNotNull(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #end #elseif(${column.queryType} == "NE") #if(${column.javaType} == "String") - .ne(StringUtils.isNotEmpty(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .ne(StringUtils.isNotEmpty(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #else - .ne(StringUtils.isNotNull(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .ne(StringUtils.isNotNull(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #end #elseif(${column.queryType} == "GT") #if(${column.javaType} == "String") - .gt(StringUtils.isNotEmpty(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .gt(StringUtils.isNotEmpty(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #else - .gt(StringUtils.isNotNull(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .gt(StringUtils.isNotNull(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #end #elseif(${column.queryType} == "GTE") #if(${column.javaType} == "String") - .ge(StringUtils.isNotEmpty(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .ge(StringUtils.isNotEmpty(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #else - .ge(StringUtils.isNotNull(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .ge(StringUtils.isNotNull(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #end #elseif(${column.queryType} == "LT") #if(${column.javaType} == "String") - .lt(StringUtils.isNotEmpty(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .lt(StringUtils.isNotEmpty(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #else - .lt(StringUtils.isNotNull(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .lt(StringUtils.isNotNull(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #end #elseif(${column.queryType} == "LTE") .#if(${column.javaType} == "String") - .le(StringUtils.isNotEmpty(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .le(StringUtils.isNotEmpty(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #else - .le(StringUtils.isNotNull(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .le(StringUtils.isNotNull(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #end #elseif(${column.queryType} == "LIKE") #if(${column.javaType} == "String") - .like(StringUtils.isNotEmpty(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .like(StringUtils.isNotEmpty(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #else - .like(StringUtils.isNotNull(${className}.get${column.CapJavaField}), ${ClassName}::get${column.CapJavaField}, ${className}.get${column.CapJavaField}) + .like(StringUtils.isNotNull(${className}.get${column.CapColumnName}()), ${ClassName}::get${column.CapColumnName}, ${className}.get${column.CapColumnName}()) #end #end #end - #end + #end; PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); Integer pageSize = pageDomain.getPageSize(); if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){ /*使用分页查询*/ Page<${ClassName}> page = new Page<>(pageNum, pageSize); - IPage<${ClassName}> iPage = addressService.page(page, lambdaQueryWrapper); + IPage<${ClassName}> iPage = ${className}Service.page(page, lambdaQueryWrapper); return getMpDataTable(iPage.getRecords(), iPage.getTotal()); } else { List<${ClassName}> list = ${className}Service.list(lambdaQueryWrapper); @@ -129,7 +135,7 @@ public class ${ClassName}Controller extends BaseController { @PostMapping("/add") @ResponseBody public AjaxResult addSave(${ClassName} ${className}) { - return toAjax(${className}Service.insert(${className})); + return toAjax(${className}Service.save(${className})); } /** @@ -150,14 +156,14 @@ public class ${ClassName}Controller extends BaseController { @PostMapping("/edit") @ResponseBody public AjaxResult editSave(${ClassName} ${className}) { - return toAjax(${classname}Service.updateById(${classname})); + return toAjax(${className}Service.updateById(${className})); } /** * 删除${functionName} */ @RequiresPermissions("${moduleName}:${className}:remove") - @Log(title = "${tableComment}", action = BusinessType.DELETE) + @Log(title = "${functionName}", action = BusinessType.DELETE) @PostMapping( "/remove") @ResponseBody public AjaxResult remove(String ids) { diff --git a/src/main/resources/templates/vm/java/Service.java.vm b/src/main/resources/templates/vm/java/Service.java.vm index 357c5c2..5a54a2b 100644 --- a/src/main/resources/templates/vm/java/Service.java.vm +++ b/src/main/resources/templates/vm/java/Service.java.vm @@ -1,6 +1,7 @@ package ${packageName}.service; import ${packageName}.domain.${ClassName}; +import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; /** diff --git a/src/main/resources/templates/vm/java/ServiceImpl.java.vm b/src/main/resources/templates/vm/java/ServiceImpl.java.vm index 966d79a..9e4c1ac 100644 --- a/src/main/resources/templates/vm/java/ServiceImpl.java.vm +++ b/src/main/resources/templates/vm/java/ServiceImpl.java.vm @@ -1,6 +1,7 @@ -package ${packageName}.service; +package ${packageName}.service.impl; -import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import ${packageName}.service.I${ClassName}Service; import ${packageName}.domain.${ClassName}; import ${packageName}.mapper.${ClassName}Mapper; import org.springframework.stereotype.Service; diff --git a/src/main/resources/templates/vm/java/domain.java.vm b/src/main/resources/templates/vm/java/domain.java.vm index f8ba837..96955fa 100644 --- a/src/main/resources/templates/vm/java/domain.java.vm +++ b/src/main/resources/templates/vm/java/domain.java.vm @@ -1,10 +1,9 @@ package ${packageName}.domain; -import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotations.TableName; -import com.baomidou.mybatisplus.annotations.TableField; import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -30,13 +29,13 @@ public class ${ClassName} implements Serializable{ #foreach ($column in $columns) /** $column.columnComment */ #if(${column.isPk} == 1 && ${column.isIncrement} == 1) - @TableId(value = ${column.javaField}, type = IdType.AUTO) + @TableId(value = "${column.columnName}", type = IdType.AUTO) #elseif (${column.isPk} == 1) - @TableId(value = ${column.javaField}, type = IdType.INPUT) + @TableId(value = "${column.columnName}", type = IdType.INPUT) #else - @TableName(value = ${column.javaField}) + @TableField(value = "${column.columnName}") #end - private $column.javaType $column.javaField; + private $column.javaType $column.columnName; #end } diff --git a/src/main/resources/templates/vm/sql/sql.vm b/src/main/resources/templates/vm/sql/sql.vm index e6303ec..f395384 100644 --- a/src/main/resources/templates/vm/sql/sql.vm +++ b/src/main/resources/templates/vm/sql/sql.vm @@ -1,19 +1,19 @@ -- 菜单 SQL insert into sys_menu (menuName, parentId, orderNum, url,menuType, visible, perms, icon, createBy, createTime, updateBy, updateTime, remark) -values('${tableComment}', '3', '1', '/${moduleName}/${classname}', 'C', '0', '${moduleName}:${classname}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${tableComment}菜单'); +values('${functionName}', '3', '1', '/${moduleName}/${className}', 'C', '0', '${moduleName}:${className}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单'); -- 按钮父菜单ID SELECT @parentId := LAST_INSERT_ID(); -- 按钮 SQL insert into sys_menu (menuName, parentId, orderNum, url,menuType, visible, perms, icon, createBy, createTime, updateBy, updateTime, remark) -values('${tableComment}查询', @parentId, '1', '#', 'F', '0', '${moduleName}:${classname}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); +values('${functionName}查询', @parentId, '1', '#', 'F', '0', '${moduleName}:${className}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); insert into sys_menu (menuName, parentId, orderNum, url,menuType, visible, perms, icon, createBy, createTime, updateBy, updateTime, remark) -values('${tableComment}新增', @parentId, '2', '#', 'F', '0', '${moduleName}:${classname}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); +values('${functionName}新增', @parentId, '2', '#', 'F', '0', '${moduleName}:${className}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); insert into sys_menu (menuName, parentId, orderNum, url,menuType, visible, perms, icon, createBy, createTime, updateBy, updateTime, remark) -values('${tableComment}修改', @parentId, '3', '#', 'F', '0', '${moduleName}:${classname}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); +values('${functionName}修改', @parentId, '3', '#', 'F', '0', '${moduleName}:${className}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); insert into sys_menu (menuName, parentId, orderNum, url,menuType, visible, perms, icon, createBy, createTime, updateBy, updateTime, remark) -values('${tableComment}删除', @parentId, '4', '#', 'F', '0', '${moduleName}:${classname}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); +values('${functionName}删除', @parentId, '4', '#', 'F', '0', '${moduleName}:${className}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); diff --git a/src/main/resources/templates/vm/xml/Mapper.xml.vm b/src/main/resources/templates/vm/xml/Mapper.xml.vm index 1f7e57e..10bc4ad 100644 --- a/src/main/resources/templates/vm/xml/Mapper.xml.vm +++ b/src/main/resources/templates/vm/xml/Mapper.xml.vm @@ -2,11 +2,11 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="${packageName}.mapper.${className}Mapper"> +<mapper namespace="${packageName}.mapper.${ClassName}Mapper"> - <resultMap type="${className}" id="${className}Result"> + <resultMap type="${packageName}.domain.${ClassName}" id="${className}Result"> #foreach ($column in $columns) - <result property="${column.javaField}" column="${column.columnName}" /> + <result property="${column.columnName}" column="${column.columnName}" /> #end </resultMap> ##