41 changed files with 6887 additions and 505 deletions
@ -0,0 +1,363 @@ |
|||||
|
package com.dreamchaser.depository_manage.controller; |
||||
|
|
||||
|
import com.dreamchaser.depository_manage.entity.*; |
||||
|
import com.dreamchaser.depository_manage.exception.MyException; |
||||
|
import com.dreamchaser.depository_manage.pojo.GroupInfoP; |
||||
|
import com.dreamchaser.depository_manage.pojo.RestResponse; |
||||
|
import com.dreamchaser.depository_manage.pojo.StatusInfo; |
||||
|
import com.dreamchaser.depository_manage.service.DepositoryService; |
||||
|
import com.dreamchaser.depository_manage.service.GroupService; |
||||
|
import com.dreamchaser.depository_manage.service.MaterialService; |
||||
|
import com.dreamchaser.depository_manage.utils.CrudUtil; |
||||
|
import com.dreamchaser.depository_manage.utils.DateUtil; |
||||
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletRequest; |
||||
|
import java.sql.Time; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/group") |
||||
|
public class GroupController { |
||||
|
|
||||
|
@Autowired |
||||
|
GroupService groupService; |
||||
|
|
||||
|
@Autowired |
||||
|
DepositoryService depositoryService; |
||||
|
|
||||
|
@Autowired |
||||
|
MaterialService materialService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用于添加一条套餐记录 |
||||
|
* |
||||
|
* @param map 添加数据 |
||||
|
* @param request |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/addGroup") |
||||
|
public RestResponse addGroup(@RequestBody Map<String, Object> map, HttpServletRequest request) { |
||||
|
// 获取物料数量
|
||||
|
Integer len = ObjectFormatUtil.toInteger(map.get("len")); |
||||
|
|
||||
|
// 获取添加成功的数量
|
||||
|
Integer integer = groupService.addGroup(map); |
||||
|
return CrudUtil.postHandle(len, integer); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping("/findGroupByCode") |
||||
|
public RestResponse findGroupByCode(@RequestBody Map<String, Object> map, HttpServletRequest request) { |
||||
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
||||
|
// 获取当前部门仓库
|
||||
|
List<Depository> depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userToken.getMaindeparment().toString()); |
||||
|
String code = map.get("code").toString(); |
||||
|
|
||||
|
// 获取套餐编码
|
||||
|
Group groupByCode = groupService.findGroupByCode(code); |
||||
|
|
||||
|
if(groupByCode != null) { |
||||
|
|
||||
|
|
||||
|
Map<String, Object> paramForGetGroup = new HashMap<>(); |
||||
|
paramForGetGroup.put("gid", groupByCode.getId()); |
||||
|
|
||||
|
// 获取当前套餐的所有物料数据
|
||||
|
List<GroupInfo> groupByGid = groupService.findGroupByCondition(paramForGetGroup); |
||||
|
|
||||
|
// 用于标识当前套餐是否可以正常出库
|
||||
|
boolean flag = true; |
||||
|
for (int i = 0; i < groupByGid.size(); i++) { |
||||
|
|
||||
|
// 获取详细信息
|
||||
|
GroupInfo groupInfo = groupByGid.get(i); |
||||
|
// 获取该物料的库存
|
||||
|
List<Integer> inventoryByMidAndDepository = materialService.findInventoryByMidAndDepository(groupInfo.getMid(), depositoryByAdminorg); |
||||
|
// 用于标志当前物料库存是否符合要求
|
||||
|
boolean flagForQuantity = false; |
||||
|
for (int j = 0; j < inventoryByMidAndDepository.size(); j++) { |
||||
|
Integer quantity = inventoryByMidAndDepository.get(j); |
||||
|
// 如果库存符合要求
|
||||
|
if (quantity > groupInfo.getQuantity()) { |
||||
|
flagForQuantity = true; |
||||
|
} |
||||
|
} |
||||
|
if (!flagForQuantity) { |
||||
|
// 如果当前不符合
|
||||
|
flag = false; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
if (flag) { |
||||
|
return new RestResponse(groupByGid); |
||||
|
} else { |
||||
|
return new RestResponse(null,666,new StatusInfo("不能出库","当前套餐中有物料库存不足")); |
||||
|
} |
||||
|
}else{ |
||||
|
return new RestResponse(null,666,new StatusInfo("失败","暂无该套餐,请确认是否正确")); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用于给套餐添加物料信息 |
||||
|
* |
||||
|
* @param map 添加物料信息 |
||||
|
* @param request |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/addMaterialForGroup") |
||||
|
public RestResponse addMaterialForGroup(@RequestBody Map<String, Object> map, HttpServletRequest request) { |
||||
|
if (map.containsKey("gid")) { |
||||
|
// 获取物料数量
|
||||
|
Integer len = ObjectFormatUtil.toInteger(map.get("len")); |
||||
|
|
||||
|
Integer integer = groupService.addMaterialForGroup(map); |
||||
|
return CrudUtil.postHandle(len, integer); |
||||
|
} else { |
||||
|
throw new MyException("缺少必要参数"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据条件获取所有套餐 |
||||
|
* |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/findAllGroup") |
||||
|
public RestResponse findAllGroup(@RequestParam Map<String, Object> map) { |
||||
|
if (map.containsKey("createTime")) { |
||||
|
String createTime = (String) map.get("createTime"); |
||||
|
Long timeStamp = DateUtil.DateTimeToTimeStamp(createTime); |
||||
|
map.put("createTime", timeStamp); |
||||
|
} |
||||
|
if (!map.containsKey("state")) { |
||||
|
map.put("state", 1); |
||||
|
} |
||||
|
List<GroupInfoP> groupPByCondition = groupService.findOnlyGroupByCondition(map); |
||||
|
return new RestResponse(groupPByCondition, groupService.findAllGroupOnlyCount(map), 200); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据套餐名称获取套餐 |
||||
|
* @param map 套餐名称 |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/findGroupByGname") |
||||
|
public RestResponse findGroupByGname(@RequestBody Map<String,Object> map){ |
||||
|
if(map.containsKey("gname")){ |
||||
|
List<Group> groupOnlyByCondition = groupService.findGroupOnlyByCondition(map); |
||||
|
int size = groupOnlyByCondition.size(); |
||||
|
if(size > 1){ |
||||
|
// 如果当前名称的套餐大于1个
|
||||
|
|
||||
|
return new RestResponse("",-1,444); |
||||
|
}else if(size == 1){ |
||||
|
// 如果刚好只有一个
|
||||
|
// 获取当前套餐的所有物料数据
|
||||
|
List<GroupInfo> groupByGid = groupService.findGroupByCondition(map); |
||||
|
return new RestResponse(groupByGid,groupByGid.size(),200); |
||||
|
|
||||
|
}else{ |
||||
|
// 如果没有
|
||||
|
return new RestResponse("",0,666); |
||||
|
} |
||||
|
}else{ |
||||
|
throw new MyException("缺少必要参数"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询套餐详情 |
||||
|
* |
||||
|
* @param map |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("findGroupInfo") |
||||
|
public RestResponse findGroupInfo(@RequestParam Map<String, Object> map) { |
||||
|
if (map.containsKey("gid")) { |
||||
|
List<GroupInfo> groupByCondition = groupService.findGroupByCondition(map); |
||||
|
return new RestResponse(groupByCondition, groupService.findGroupCountByCondition(map), 200); |
||||
|
} else { |
||||
|
throw new MyException("缺失必要参数!"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改套餐中的物料数据 |
||||
|
* |
||||
|
* @param map |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/materialForGroupEdit") |
||||
|
public RestResponse materialForGroupEdit(@RequestBody Map<String, Object> map) { |
||||
|
if (map.containsKey("id")) { |
||||
|
Integer integer = groupService.updateMaterialForGroup(map); |
||||
|
return CrudUtil.putHandle(1, integer); |
||||
|
} else { |
||||
|
throw new MyException("缺少必要参数!"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除套餐中的物料 |
||||
|
* |
||||
|
* @param map 删除条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/delMaterialForGroup") |
||||
|
public RestResponse delMaterialForGroup(@RequestBody Map<String, Object> map) { |
||||
|
if (map.containsKey("id")) { |
||||
|
Integer id = ObjectFormatUtil.toInteger(map.get("id")); |
||||
|
Integer integer = groupService.delMaterialForGroupById(id); |
||||
|
return CrudUtil.deleteHandle(1, integer); |
||||
|
|
||||
|
} else if (map.containsKey("ids")) { |
||||
|
List<Integer> ids = (List<Integer>) map.get("ids"); |
||||
|
Integer integer = groupService.delMaterialForGroupByIds(ids); |
||||
|
return CrudUtil.deleteHandle(ids.size(), integer); |
||||
|
} else { |
||||
|
throw new MyException("缺少必要参数"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用于修改套餐的状态 |
||||
|
* |
||||
|
* @param map 条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/changeGroupState") |
||||
|
public RestResponse changeGroupState(@RequestBody Map<String, Object> map) { |
||||
|
if (map.containsKey("id")) { |
||||
|
Integer integer = groupService.updateGroupState(map); |
||||
|
return CrudUtil.putHandle(1, integer); |
||||
|
} else { |
||||
|
throw new MyException("缺少必要参数"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用于修改套餐信息 |
||||
|
* @param map 修改条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/editGroupInfo") |
||||
|
public RestResponse editGroupInfo(@RequestBody Map<String,Object> map){ |
||||
|
if(map.containsKey("id")){ |
||||
|
Integer integer = groupService.updateGroupInfo(map); |
||||
|
return CrudUtil.putHandle(1,integer); |
||||
|
}else{ |
||||
|
throw new MyException("缺少必要参数"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 删除套餐(软删除) |
||||
|
* |
||||
|
* @param map 删除条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/delGroup") |
||||
|
public RestResponse delGroup(@RequestBody Map<String, Object> map) { |
||||
|
if (map.containsKey("id")) { |
||||
|
map.put("state", 3); |
||||
|
Integer integer = groupService.updateGroupState(map); |
||||
|
return CrudUtil.putHandle(1, integer); |
||||
|
} else if (map.containsKey("ids")) { |
||||
|
List<Integer> ids = (List<Integer>) map.get("ids"); |
||||
|
Integer integer = 0; |
||||
|
for (int i = 0; i < ids.size(); i++) { |
||||
|
map.put("id", ids.get(i)); |
||||
|
map.put("state", 3); |
||||
|
integer += groupService.updateGroupState(map); |
||||
|
} |
||||
|
return CrudUtil.putHandle(ids.size(), integer); |
||||
|
} else { |
||||
|
throw new MyException("缺少必要参数"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 删除套餐及其明细(硬删除) |
||||
|
* |
||||
|
* @param map 删除条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/realDelGroup") |
||||
|
public RestResponse realDelGroup(@RequestBody Map<String, Object> map) { |
||||
|
if (map.containsKey("id")) { |
||||
|
Integer id = ObjectFormatUtil.toInteger(map.get("id")); |
||||
|
Integer integer = groupService.delGroupById(id); |
||||
|
return CrudUtil.deleteHandle(1, integer); |
||||
|
} else { |
||||
|
throw new MyException("缺少必要参数"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/findGroupInfoByGid") |
||||
|
public RestResponse findGroupInfoByGid(@RequestBody Map<String,Object> map,HttpServletRequest request){ |
||||
|
|
||||
|
|
||||
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
||||
|
// 获取当前部门仓库
|
||||
|
List<Depository> depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userToken.getMaindeparment().toString()); |
||||
|
|
||||
|
// 获取当前套餐的所有物料数据
|
||||
|
List<GroupInfo> groupByGid = groupService.findGroupByCondition(map); |
||||
|
|
||||
|
// 用于标识当前套餐是否可以正常出库
|
||||
|
boolean flag = true; |
||||
|
for (int i = 0; i < groupByGid.size(); i++) { |
||||
|
|
||||
|
// 获取详细信息
|
||||
|
GroupInfo groupInfo = groupByGid.get(i); |
||||
|
// 获取该物料的库存
|
||||
|
List<Integer> inventoryByMidAndDepository = materialService.findInventoryByMidAndDepository(groupInfo.getMid(), depositoryByAdminorg); |
||||
|
// 用于标志当前物料库存是否符合要求
|
||||
|
boolean flagForQuantity = false; |
||||
|
for (int j = 0; j < inventoryByMidAndDepository.size(); j++) { |
||||
|
Integer quantity = inventoryByMidAndDepository.get(j); |
||||
|
// 如果库存符合要求
|
||||
|
if (quantity > groupInfo.getQuantity()) { |
||||
|
flagForQuantity = true; |
||||
|
} |
||||
|
} |
||||
|
if (!flagForQuantity) { |
||||
|
// 如果当前不符合
|
||||
|
flag = false; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
if (flag) { |
||||
|
return new RestResponse(groupByGid); |
||||
|
} else { |
||||
|
return new RestResponse(null,666,new StatusInfo("不能出库","当前套餐中有物料库存不足")); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping("/treeMenus") |
||||
|
public RestResponse treeMenus(@RequestBody Map<String,Object> map){ |
||||
|
String gname = ""; |
||||
|
if(map.containsKey("gname")){ |
||||
|
gname = (String) map.get("gname"); |
||||
|
} |
||||
|
List<Object> list = groupService.InitTreeMenus(gname); |
||||
|
return new RestResponse(list); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
package com.dreamchaser.depository_manage.entity; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class Group { |
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
private Integer id; |
||||
|
/** |
||||
|
* 套餐编码 |
||||
|
*/ |
||||
|
private String code; |
||||
|
/** |
||||
|
* 套餐创建时间 |
||||
|
*/ |
||||
|
private Long createTime; |
||||
|
|
||||
|
/** |
||||
|
* 套餐状态 |
||||
|
*/ |
||||
|
private Integer state; |
||||
|
|
||||
|
/** |
||||
|
* 套餐名称 |
||||
|
*/ |
||||
|
private String gname; |
||||
|
} |
||||
@ -0,0 +1,89 @@ |
|||||
|
package com.dreamchaser.depository_manage.entity; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* 用于套餐信息的封装 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class GroupInfo { |
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
private Integer id; |
||||
|
/** |
||||
|
* 物料id |
||||
|
*/ |
||||
|
private Integer mid; |
||||
|
/** |
||||
|
* 套餐id |
||||
|
*/ |
||||
|
private Integer gid; |
||||
|
/** |
||||
|
* 数量 |
||||
|
*/ |
||||
|
private Integer quantity; |
||||
|
/** |
||||
|
* 套餐对应编码 |
||||
|
*/ |
||||
|
private String gcode; |
||||
|
/** |
||||
|
* 物料名称 |
||||
|
*/ |
||||
|
private String mname; |
||||
|
/** |
||||
|
* 物料类型id |
||||
|
*/ |
||||
|
private Integer mtid; |
||||
|
/** |
||||
|
* 类型名称 |
||||
|
*/ |
||||
|
private String tname; |
||||
|
/** |
||||
|
* 物料编码 |
||||
|
*/ |
||||
|
private String mcode; |
||||
|
/** |
||||
|
* 物料型号 |
||||
|
*/ |
||||
|
private String version; |
||||
|
/** |
||||
|
* 物料计量单位 |
||||
|
*/ |
||||
|
private String unit; |
||||
|
/** |
||||
|
* 物料材质 |
||||
|
*/ |
||||
|
private String texture; |
||||
|
/** |
||||
|
* 物料保质期 |
||||
|
*/ |
||||
|
private Integer shelfLife; |
||||
|
/** |
||||
|
* 物料产地 |
||||
|
*/ |
||||
|
private String productionPlace; |
||||
|
/** |
||||
|
* 物料品牌 |
||||
|
*/ |
||||
|
private String brand; |
||||
|
/** |
||||
|
* 物料备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
/** |
||||
|
* 套餐创建时间 |
||||
|
*/ |
||||
|
private Long createTime; |
||||
|
|
||||
|
/** |
||||
|
* 套餐状态(1启用2禁用3删除) |
||||
|
*/ |
||||
|
private Integer gstate; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 套餐名称 |
||||
|
*/ |
||||
|
private String gname; |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package com.dreamchaser.depository_manage.entity; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class MaterialForGroup { |
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
private Integer id; |
||||
|
/** |
||||
|
* 物料id |
||||
|
*/ |
||||
|
private Integer mid; |
||||
|
/** |
||||
|
* 套餐id |
||||
|
*/ |
||||
|
private Integer gid; |
||||
|
/** |
||||
|
* 数量 |
||||
|
*/ |
||||
|
private Integer quantity; |
||||
|
} |
||||
@ -0,0 +1,163 @@ |
|||||
|
package com.dreamchaser.depository_manage.mapper; |
||||
|
|
||||
|
import com.dreamchaser.depository_manage.entity.Group; |
||||
|
import com.dreamchaser.depository_manage.entity.GroupInfo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Repository |
||||
|
@Mapper |
||||
|
public interface GroupMapper { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用于查找所有套餐(不包含其他) |
||||
|
* @return |
||||
|
*/ |
||||
|
List<Group> findAllGroupOnly(String gname); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用于查找所有套餐 |
||||
|
* @return |
||||
|
*/ |
||||
|
List<GroupInfo> findAllGroup(); |
||||
|
|
||||
|
/** |
||||
|
* 根据套餐id查询对应套餐 |
||||
|
* @param id 套餐id |
||||
|
* @return |
||||
|
*/ |
||||
|
GroupInfo findGroupById(Integer id); |
||||
|
|
||||
|
/** |
||||
|
* 根据主键查询套餐(不包含其他数据) |
||||
|
* @param id 主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
Group findGroupOnlyById(Integer id); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据条件查询套餐(不包含其他数据) |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
List<Group> findGroupOnlyByCondition(Map<String,Object> map); |
||||
|
|
||||
|
/** |
||||
|
* 根据条件查询对应套餐信息(视图) |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
List<GroupInfo> findGroupByCondition(Map<String,Object> map); |
||||
|
|
||||
|
/** |
||||
|
* 根据套餐id批量获取套餐信息(不包含其他数据) |
||||
|
* @param list 套餐id列表 |
||||
|
* @return |
||||
|
*/ |
||||
|
List<Group> findGroupByGids(List<Integer> list); |
||||
|
|
||||
|
/** |
||||
|
* 修改套餐中物料的数据 |
||||
|
* @param map 修改数据及条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer updateMaterialForGroup(Map<String,Object> map); |
||||
|
/** |
||||
|
* 修改套餐中物料的数据 |
||||
|
* @param groupInfo 修改数据及条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer updateMaterialForGroup(GroupInfo groupInfo); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据条件查询对应套餐数目 |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer findGroupCountByCondition(Map<String,Object> map); |
||||
|
|
||||
|
/** |
||||
|
* 获取当前套餐数量 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer findAllGroupOnlyCount(Map<String,Object> map); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 添加一条套餐 |
||||
|
* @param map 具体数据 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer addGroup(Map<String,Object> map); |
||||
|
|
||||
|
/** |
||||
|
* 添加一条套餐 |
||||
|
* @param groupInfo 具体数据 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer addGroup(GroupInfo groupInfo); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 添加套餐中的物料记录 |
||||
|
* @param map 对应物料数据 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer addGroupForMaterial(Map<String,Object> map); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 通过编码获取对应的套餐 |
||||
|
* @param code 套餐编码 |
||||
|
* @return |
||||
|
*/ |
||||
|
Group findGroupByCode(String code); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 修改套餐基本信息 |
||||
|
* @param group 待修改套餐 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer updateGroupOnly(Group group); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 修改套餐基本信息 |
||||
|
* @param map 待修改套餐 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer updateGroupOnly(Map<String,Object> map); |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据主键删除一条套餐中的物料明细 |
||||
|
* @param id 待删除主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer delMaterialForGroupById(Integer id); |
||||
|
|
||||
|
/** |
||||
|
* 根据主键批量删除套餐中的物料明细 |
||||
|
* @param list 待删除主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer delMaterialForGroupByIds(List<Integer> list); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据主键删除套餐 |
||||
|
* @param id 待删除套餐主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer delGroup(Integer id); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,352 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.dreamchaser.depository_manage.mapper.GroupMapper"> |
||||
|
|
||||
|
<!-- 字段映射 (用于视图)--> |
||||
|
<resultMap id="groupInfoMap" type="com.dreamchaser.depository_manage.entity.GroupInfo"> |
||||
|
<id column="id" property="id" jdbcType="INTEGER" /> |
||||
|
<result column="mid" property="mid" jdbcType="INTEGER"/> |
||||
|
<result column="gid" property="gid" jdbcType="INTEGER"/> |
||||
|
<result column="quantity" property="quantity" jdbcType="INTEGER"/> |
||||
|
<result column="mtid" property="mtid" jdbcType="INTEGER"/> |
||||
|
<result column="shelfLife" property="shelfLife" jdbcType="INTEGER"/> |
||||
|
<result column="gcode" property="gcode" jdbcType="VARCHAR"/> |
||||
|
<result column="mname" property="mname" jdbcType="VARCHAR"/> |
||||
|
<result column="tname" property="tname" jdbcType="VARCHAR"/> |
||||
|
<result column="mcode" property="mcode" jdbcType="VARCHAR"/> |
||||
|
<result column="version" property="version" jdbcType="VARCHAR"/> |
||||
|
<result column="unit" property="unit" jdbcType="VARCHAR"/> |
||||
|
<result column="texture" property="texture" jdbcType="VARCHAR"/> |
||||
|
<result column="productionPlace" property="productionPlace" jdbcType="VARCHAR"/> |
||||
|
<result column="brand" property="brand" jdbcType="VARCHAR"/> |
||||
|
<result column="remark" property="remark" jdbcType="VARCHAR"/> |
||||
|
<result column="gname" property="gname" jdbcType="VARCHAR"/> |
||||
|
<result column="createTime" property="createTime" jdbcType="INTEGER"/> |
||||
|
<result column="gstate" property="gstate" jdbcType="INTEGER"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<!-- 用于套餐映射--> |
||||
|
<resultMap id="groupMap" type="com.dreamchaser.depository_manage.entity.Group"> |
||||
|
<id column="id" property="id" jdbcType="INTEGER" /> |
||||
|
<result column="code" property="code" jdbcType="VARCHAR"/> |
||||
|
<result column="gname" property="gname" jdbcType="VARCHAR"/> |
||||
|
<result column="createTime" property="createTime" jdbcType="INTEGER"/> |
||||
|
<result column="state" property="state" jdbcType="INTEGER"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<!-- 用于套餐与物料的映射--> |
||||
|
<resultMap id="materialForGroupMap" type="com.dreamchaser.depository_manage.entity.MaterialForGroup"> |
||||
|
<id column="id" property="id" jdbcType="INTEGER" /> |
||||
|
<result column="mid" property="mid" jdbcType="INTEGER"/> |
||||
|
<result column="gid" property="gid" jdbcType="INTEGER"/> |
||||
|
<result column="quantity" property="quantity" jdbcType="INTEGER"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<!-- 用于视图--> |
||||
|
<sql id="allColumnsForView"> |
||||
|
id,mid,gid,quantity,mtid,shelfLife,gcode,mname,tname,mcode,version,unit,texture,productionPlace,brand,remark,createTime,gstate,gname |
||||
|
</sql> |
||||
|
|
||||
|
<!-- 用于套餐--> |
||||
|
<sql id="allColumnsForGroup"> |
||||
|
id,code,createTime,state,gname |
||||
|
</sql> |
||||
|
|
||||
|
<!-- 用于物料对于套餐的映射--> |
||||
|
<sql id="allColumnsForMaterialForGroup"> |
||||
|
id,mid,gid,quantity |
||||
|
</sql> |
||||
|
|
||||
|
|
||||
|
|
||||
|
<select id="findAllGroup" resultMap="groupInfoMap"> |
||||
|
select |
||||
|
<include refid="allColumnsForView"/> |
||||
|
from materialforgroup |
||||
|
</select> |
||||
|
|
||||
|
<select id="findGroupOnlyByCondition" resultMap="groupMap" parameterType="map"> |
||||
|
select |
||||
|
<include refid="allColumnsForGroup"/> |
||||
|
from `group` |
||||
|
where 1 = 1 |
||||
|
<if test="code != null and code !=''"> |
||||
|
and code = #{code} |
||||
|
</if> |
||||
|
<if test="createTime != null and createTime != ''"> |
||||
|
and createTime = #{createTime} |
||||
|
</if> |
||||
|
<if test="state != null and state != ''"> |
||||
|
and state = #{state} |
||||
|
</if> |
||||
|
<if test="gname != null and gname != ''"> |
||||
|
and gname like concat('%',#{gname},'%') |
||||
|
</if> |
||||
|
<if test="begin != null and size != null"> |
||||
|
LIMIT #{begin},#{size} |
||||
|
</if> |
||||
|
</select> |
||||
|
|
||||
|
|
||||
|
|
||||
|
<select id="findGroupOnlyById" resultMap="groupMap" parameterType="int"> |
||||
|
select |
||||
|
<include refid="allColumnsForGroup"/> |
||||
|
from `group` |
||||
|
where id = #{id} |
||||
|
</select> |
||||
|
|
||||
|
<select id="findAllGroupOnly" resultMap="groupMap" parameterType="string"> |
||||
|
select |
||||
|
<include refid="allColumnsForGroup"/> |
||||
|
from `group` |
||||
|
where state = 1 |
||||
|
<if test="gname != null and gname != ''"> |
||||
|
and gname like concat('%',#{gname},'%') |
||||
|
</if> |
||||
|
</select> |
||||
|
|
||||
|
|
||||
|
<select id="findAllGroupOnlyCount" resultType="int" parameterType="map"> |
||||
|
select |
||||
|
Count(*) |
||||
|
from `group` |
||||
|
where 1 = 1 |
||||
|
<if test="code != null and code !=''"> |
||||
|
and code = #{code} |
||||
|
</if> |
||||
|
<if test="createTime != null and createTime != ''"> |
||||
|
and createTime = #{createTime} |
||||
|
</if> |
||||
|
<if test="state != null and state != ''"> |
||||
|
and state = #{state} |
||||
|
</if> |
||||
|
</select> |
||||
|
|
||||
|
<select id="findGroupById" resultMap="groupInfoMap" parameterType="int"> |
||||
|
select |
||||
|
<include refid="allColumnsForView"/> |
||||
|
from materialforgroup |
||||
|
where id = #{id} |
||||
|
</select> |
||||
|
|
||||
|
|
||||
|
|
||||
|
<insert id="addGroup" useGeneratedKeys="true" keyProperty="id"> |
||||
|
INSERT INTO `group` ( |
||||
|
id, code, createTime, state |
||||
|
) VALUES ( |
||||
|
#{id}, |
||||
|
#{code}, |
||||
|
#{createTime}, |
||||
|
#{state} |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
<insert id="addGroupForMaterial"> |
||||
|
INSERT INTO groupformaterial ( |
||||
|
id, mid, gid, quantity |
||||
|
) VALUES ( |
||||
|
#{id}, |
||||
|
#{mid}, |
||||
|
#{gid}, |
||||
|
#{quantity} |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
|
||||
|
|
||||
|
<select id="findGroupByCondition" resultMap="groupInfoMap" parameterType="map"> |
||||
|
select |
||||
|
<include refid="allColumnsForView"/> |
||||
|
from materialforgroup |
||||
|
where 1 = 1 |
||||
|
<if test="mid != null and mid != ''"> |
||||
|
and mid = #{mid} |
||||
|
</if> |
||||
|
<if test="gid != null and gid != ''"> |
||||
|
and gid = #{gid} |
||||
|
</if> |
||||
|
<if test="quantity != null"> |
||||
|
and quantity = #{quantity} |
||||
|
</if> |
||||
|
<if test="gcode != null and gcode !=''"> |
||||
|
and gcode = #{gcode} |
||||
|
</if> |
||||
|
<if test="mname != null and mname != ''"> |
||||
|
and mname like CONCAT('%', #{mname}, '%') |
||||
|
</if> |
||||
|
<if test="mtid != null and mtid != ''"> |
||||
|
and mtid = #{mtid} |
||||
|
</if> |
||||
|
<if test="tname != null and tname != ''"> |
||||
|
and tname like CONCAT('%',#{tname},'%') |
||||
|
</if> |
||||
|
<if test="mcode != null and mcode != ''"> |
||||
|
and mcode = #{mcode} |
||||
|
</if> |
||||
|
<if test="version != null and version != ''"> |
||||
|
and version like CONCAT('%',#{version},'%') |
||||
|
</if> |
||||
|
<if test="unit != null and unit != ''"> |
||||
|
and unit like CONCAT('%',#{unit},'%') |
||||
|
</if> |
||||
|
<if test="texture != null and texture != ''"> |
||||
|
and texture like CONCAT('%',#{texture},'%') |
||||
|
</if> |
||||
|
<if test="shelfLife != null and shelfLife != ''"> |
||||
|
and shelfLife = #{shelfLife} |
||||
|
</if> |
||||
|
<if test="productionPlace != null and productionPlace!= ''"> |
||||
|
and productionPlace like CONCAT('%',#{productionPlace},'%') |
||||
|
</if> |
||||
|
<if test="brand != null and brand != ''"> |
||||
|
and brand like CONCAT('%',#{brand},'%') |
||||
|
</if> |
||||
|
<if test="remark != null and remark != ''"> |
||||
|
and remark like CONCAT('%',remark,'%') |
||||
|
</if> |
||||
|
<if test="createTime != null and createTime != ''"> |
||||
|
and createTime = #{createTime} |
||||
|
</if> |
||||
|
<if test="gstate != null and gstate != ''"> |
||||
|
and gstate = #{gstate} |
||||
|
</if> |
||||
|
<if test="gname != null and gname != ''"> |
||||
|
and gname = #{gname} |
||||
|
</if> |
||||
|
<if test="begin != null and size != null"> |
||||
|
LIMIT #{begin},#{size} |
||||
|
</if> |
||||
|
</select> |
||||
|
|
||||
|
<select id="findGroupByGids" resultMap="groupMap" parameterType="list"> |
||||
|
select |
||||
|
<include refid="allColumnsForGroup"/> |
||||
|
from `group` |
||||
|
where id in |
||||
|
<foreach collection="list" index="index" item="id" open="(" separator="," close=")"> |
||||
|
#{id} |
||||
|
</foreach> |
||||
|
</select> |
||||
|
|
||||
|
<select id="findGroupCountByCondition" parameterType="map" resultType="int"> |
||||
|
select |
||||
|
count(*) |
||||
|
from materialforgroup |
||||
|
where 1 = 1 |
||||
|
<if test="mid != null and mid != ''"> |
||||
|
and mid = #{mid} |
||||
|
</if> |
||||
|
<if test="gid != null and gid != ''"> |
||||
|
and gid = #{gid} |
||||
|
</if> |
||||
|
<if test="quantity != null"> |
||||
|
and quantity = #{quantity} |
||||
|
</if> |
||||
|
<if test="gcode != null and gcode !=''"> |
||||
|
and gcode = #{gcode} |
||||
|
</if> |
||||
|
<if test="mname != null and mname != ''"> |
||||
|
and mname like CONCAT('%', #{mname}, '%') |
||||
|
</if> |
||||
|
<if test="mtid != null and mtid != ''"> |
||||
|
and mtid = #{mtid} |
||||
|
</if> |
||||
|
<if test="tname != null and tname != ''"> |
||||
|
and tname like CONCAT('%',#{tname},'%') |
||||
|
</if> |
||||
|
<if test="mcode != null and mcode != ''"> |
||||
|
and mcode = #{mcode} |
||||
|
</if> |
||||
|
<if test="version != null and version != ''"> |
||||
|
and version like CONCAT('%',#{version},'%') |
||||
|
</if> |
||||
|
<if test="unit != null and unit != ''"> |
||||
|
and unit like CONCAT('%',#{unit},'%') |
||||
|
</if> |
||||
|
<if test="texture != null and texture != ''"> |
||||
|
and texture like CONCAT('%',#{texture},'%') |
||||
|
</if> |
||||
|
<if test="shelfLife != null and shelfLife != ''"> |
||||
|
and shelfLife = #{shelfLife} |
||||
|
</if> |
||||
|
<if test="productionPlace != null and productionPlace!= ''"> |
||||
|
and productionPlace like CONCAT('%',#{productionPlace},'%') |
||||
|
</if> |
||||
|
<if test="brand != null and brand != ''"> |
||||
|
and brand like CONCAT('%',#{brand},'%') |
||||
|
</if> |
||||
|
<if test="remark != null and remark != ''"> |
||||
|
and remark like CONCAT('%',remark,'%') |
||||
|
</if> |
||||
|
<if test="createTime != null and createTime != ''"> |
||||
|
and createTime = #{createTime} |
||||
|
</if> |
||||
|
<if test="gstate != null and gstate != ''"> |
||||
|
and gstate = #{gstate} |
||||
|
</if> |
||||
|
</select> |
||||
|
|
||||
|
<update id="updateMaterialForGroup"> |
||||
|
update |
||||
|
groupformaterial |
||||
|
<set> |
||||
|
<if test="gid != null and gid != ''"> |
||||
|
gid = #{gid}, |
||||
|
</if> |
||||
|
<if test="mid != null and mid != ''"> |
||||
|
mid = #{mid}, |
||||
|
</if> |
||||
|
<if test="quantity != null and quantity != ''"> |
||||
|
quantity = #{quantity} |
||||
|
</if> |
||||
|
</set> |
||||
|
where id = #{id} |
||||
|
</update> |
||||
|
|
||||
|
|
||||
|
<update id="updateGroupOnly"> |
||||
|
update |
||||
|
`group` |
||||
|
<set> |
||||
|
<if test="code != null and code != ''"> |
||||
|
code = #{code}, |
||||
|
</if> |
||||
|
<if test="createTime != null and createTime != ''"> |
||||
|
createTime = #{createTime}, |
||||
|
</if> |
||||
|
<if test="state != null and state != ''"> |
||||
|
state = #{state} |
||||
|
</if> |
||||
|
<if test="gname != null and gname !=''"> |
||||
|
gname = #{gname} |
||||
|
</if> |
||||
|
</set> |
||||
|
where id = #{id} |
||||
|
</update> |
||||
|
|
||||
|
<delete id="delMaterialForGroupById" parameterType="int"> |
||||
|
delete from groupformaterial where id = #{id} |
||||
|
</delete> |
||||
|
|
||||
|
|
||||
|
<delete id="delMaterialForGroupByIds" parameterType="list"> |
||||
|
delete from groupformaterial where id in |
||||
|
<foreach collection="list" index="index" item="id" open="(" separator="," close=")"> |
||||
|
#{id} |
||||
|
</foreach> |
||||
|
</delete> |
||||
|
|
||||
|
<delete id="delGroup" parameterType="int"> |
||||
|
delete from `group` where id = #{id} |
||||
|
</delete> |
||||
|
|
||||
|
<select id="findGroupByCode" parameterType="String" resultMap="groupMap"> |
||||
|
select |
||||
|
<include refid="allColumnsForGroup"/> |
||||
|
from `group` |
||||
|
where code = #{code} |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
@ -0,0 +1,64 @@ |
|||||
|
package com.dreamchaser.depository_manage.pojo; |
||||
|
|
||||
|
import com.dreamchaser.depository_manage.entity.Group; |
||||
|
import com.dreamchaser.depository_manage.utils.DateUtil; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用于展示套餐信息 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class GroupInfoP { |
||||
|
|
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
private Integer id; |
||||
|
|
||||
|
/** |
||||
|
* 套餐创建时间 |
||||
|
*/ |
||||
|
private String createTime; |
||||
|
|
||||
|
/** |
||||
|
* 套餐编码 |
||||
|
*/ |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 物料名称 |
||||
|
*/ |
||||
|
private Map<String,Integer> materialSimple; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 套餐中拥有的物料总数 |
||||
|
*/ |
||||
|
private Integer quantity; |
||||
|
|
||||
|
/** |
||||
|
* 套餐状态 |
||||
|
*/ |
||||
|
private Integer state; |
||||
|
|
||||
|
/** |
||||
|
* 套餐名称 |
||||
|
*/ |
||||
|
private String gname; |
||||
|
|
||||
|
|
||||
|
public GroupInfoP(Group group) { |
||||
|
this.id = group.getId(); |
||||
|
this.createTime = DateUtil.TimeStampToDateTime(group.getCreateTime()); |
||||
|
this.code = group.getCode(); |
||||
|
this.state = group.getState(); |
||||
|
this.gname = group.getGname(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public GroupInfoP() { |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,162 @@ |
|||||
|
package com.dreamchaser.depository_manage.service; |
||||
|
|
||||
|
|
||||
|
import com.dreamchaser.depository_manage.entity.Group; |
||||
|
import com.dreamchaser.depository_manage.entity.GroupInfo; |
||||
|
import com.dreamchaser.depository_manage.pojo.GroupInfoP; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用于套餐的设置 |
||||
|
*/ |
||||
|
public interface GroupService { |
||||
|
|
||||
|
/** |
||||
|
* 用于查找所有套餐 |
||||
|
* @return |
||||
|
*/ |
||||
|
List<GroupInfo> findAllGroup(); |
||||
|
|
||||
|
/** |
||||
|
* 根据套餐id查询对应套餐 |
||||
|
* @param id 套餐id |
||||
|
* @return |
||||
|
*/ |
||||
|
GroupInfo findGroupById(Integer id); |
||||
|
|
||||
|
/** |
||||
|
* 根据条件查询对应套餐 |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
List<GroupInfo> findGroupByCondition(Map<String,Object> map); |
||||
|
|
||||
|
/** |
||||
|
* 根据条件查询对应套餐(按group分组) |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
List<GroupInfoP> findOnlyGroupByCondition(Map<String,Object> map); |
||||
|
|
||||
|
/** |
||||
|
* 获取当前套餐数量 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer findAllGroupOnlyCount(Map<String,Object> map); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据条件查询对应套餐数目 |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer findGroupCountByCondition(Map<String,Object> map); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 添加一条套餐 |
||||
|
* @param map 具体数据 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer addGroup(Map<String,Object> map); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 通过编码获取对应的套餐 |
||||
|
* @param code 套餐编码 |
||||
|
* @return |
||||
|
*/ |
||||
|
Group findGroupByCode(String code); |
||||
|
|
||||
|
/** |
||||
|
* 给套餐添加物料信息 |
||||
|
* @param map 待添加信息 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer addMaterialForGroup(Map<String,Object> map); |
||||
|
|
||||
|
/** |
||||
|
* 添加一条套餐 |
||||
|
* @param groupInfo 具体数据 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer addGroup(GroupInfo groupInfo); |
||||
|
|
||||
|
/** |
||||
|
* 根据主键删除一条套餐记录 |
||||
|
* @param id 待删除套餐主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer delGroupById(Integer id); |
||||
|
|
||||
|
/** |
||||
|
* 根据主键批量删除套餐记录 |
||||
|
* @param ids 主键列表 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer delGroupByIds(List<Integer> ids); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 修改套餐中对应物料信息 |
||||
|
* @param map 修改数据及条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer updateMaterialForGroup(Map<String,Object> map); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 通过物料id与套餐id查询对应套餐明细 |
||||
|
* @param mid 物料id |
||||
|
* @param gid 套餐id |
||||
|
* @return 套餐明细 |
||||
|
*/ |
||||
|
GroupInfo findGroupInfoByMidAndGid(Integer mid,Integer gid); |
||||
|
|
||||
|
/** |
||||
|
* 根据主键删除一条套餐中的物料明细 |
||||
|
* @param id 待删除主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer delMaterialForGroupById(Integer id); |
||||
|
|
||||
|
/** |
||||
|
* 根据主键批量删除套餐中的物料明细 |
||||
|
* @param ids 待删除主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer delMaterialForGroupByIds(List<Integer> ids); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据条件修改套餐状态 |
||||
|
* @param map 修改条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer updateGroupState(Map<String,Object> map); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据条件修改套餐信息 |
||||
|
* @param map 修改条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
Integer updateGroupInfo(Map<String,Object> map); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据条件获取套餐 |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
List<Group> findGroupOnlyByCondition(Map<String,Object> map); |
||||
|
|
||||
|
/** |
||||
|
* 用于构造套餐树 |
||||
|
* @param gname |
||||
|
* @return |
||||
|
*/ |
||||
|
List<Object> InitTreeMenus(String gname); |
||||
|
} |
||||
@ -0,0 +1,566 @@ |
|||||
|
package com.dreamchaser.depository_manage.service.impl; |
||||
|
|
||||
|
import com.dreamchaser.depository_manage.entity.Group; |
||||
|
import com.dreamchaser.depository_manage.entity.GroupInfo; |
||||
|
import com.dreamchaser.depository_manage.mapper.GroupMapper; |
||||
|
import com.dreamchaser.depository_manage.mapper.MaterialMapper; |
||||
|
import com.dreamchaser.depository_manage.pojo.GroupInfoP; |
||||
|
import com.dreamchaser.depository_manage.service.GroupService; |
||||
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.*; |
||||
|
import java.util.concurrent.*; |
||||
|
|
||||
|
@Service |
||||
|
public class GroupServiceImpl implements GroupService { |
||||
|
|
||||
|
@Autowired |
||||
|
GroupMapper groupMapper; |
||||
|
|
||||
|
@Autowired |
||||
|
MaterialMapper materialMapper; |
||||
|
|
||||
|
/** |
||||
|
* 用于查找所有套餐 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<GroupInfo> findAllGroup() { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据套餐id查询对应套餐 |
||||
|
* @param id 套餐id |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public GroupInfo findGroupById(Integer id) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据条件查询对应套餐 |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<GroupInfo> findGroupByCondition(Map<String, Object> map) { |
||||
|
List<GroupInfo> groupByCondition = groupMapper.findGroupByCondition(map); |
||||
|
return groupByCondition; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据条件查询对应套餐(按group分组) |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<GroupInfoP> findOnlyGroupByCondition(Map<String, Object> map) { |
||||
|
// 获取当前所有套餐
|
||||
|
List<Group> allGroupOnly = groupMapper.findGroupOnlyByCondition(map); |
||||
|
|
||||
|
// 用于查询当前套餐中的物料
|
||||
|
Map<String,Object> paramForGroup = new HashMap<>(); |
||||
|
|
||||
|
// 最终结果
|
||||
|
List<GroupInfoP> list = new ArrayList<>(); |
||||
|
for (int i = 0; i < allGroupOnly.size(); i++) { |
||||
|
// 获取套餐详情
|
||||
|
Group group = allGroupOnly.get(i); |
||||
|
paramForGroup.put("gid",group.getId()); |
||||
|
|
||||
|
// 获取当前套餐对应的详情
|
||||
|
List<GroupInfo> groupByCondition = groupMapper.findGroupByCondition(paramForGroup); |
||||
|
|
||||
|
// 构造输出结果
|
||||
|
GroupInfoP groupInfoP = new GroupInfoP(group); |
||||
|
|
||||
|
// 设置当前套餐中的数量
|
||||
|
Integer quantity = 0; |
||||
|
|
||||
|
// 用于存储物料名称与物料id
|
||||
|
Map<String,Integer> materialSimple = new HashMap<>(); |
||||
|
for (GroupInfo groupInfo : groupByCondition) { |
||||
|
materialSimple.put(groupInfo.getMname(), groupInfo.getMid()); |
||||
|
quantity += groupInfo.getQuantity(); |
||||
|
} |
||||
|
groupInfoP.setMaterialSimple(materialSimple); |
||||
|
groupInfoP.setQuantity(quantity); |
||||
|
list.add(groupInfoP); |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
/** |
||||
|
* 获取当前套餐数量 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer findAllGroupOnlyCount(Map<String, Object> map) { |
||||
|
return groupMapper.findAllGroupOnlyCount(map); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据条件查询对应套餐数目 |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer findGroupCountByCondition(Map<String, Object> map) { |
||||
|
Integer count = groupMapper.findGroupCountByCondition(map); |
||||
|
if(count == null){ |
||||
|
count = 0; |
||||
|
} |
||||
|
return count; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加一条套餐 |
||||
|
* @param map 具体数据 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
@Override |
||||
|
public Integer addGroup(Map<String, Object> map) { |
||||
|
Map<String,Object> insertForGroup = new HashMap<>(); |
||||
|
// 设置当前时间
|
||||
|
insertForGroup.put("createTime",System.currentTimeMillis()); |
||||
|
|
||||
|
// 获取当前套餐数量
|
||||
|
Integer groupCount = groupMapper.findAllGroupOnlyCount(new HashMap<>()); |
||||
|
if(groupCount == null){ |
||||
|
groupCount = 0; |
||||
|
} |
||||
|
// 构造套餐编码
|
||||
|
String code = createCode(groupCount); |
||||
|
insertForGroup.put("code",code); |
||||
|
insertForGroup.put("state",1); |
||||
|
|
||||
|
// 插入到数据库
|
||||
|
groupMapper.addGroup(insertForGroup); |
||||
|
|
||||
|
//获取插入的套餐id
|
||||
|
Integer gid = ObjectFormatUtil.toInteger(insertForGroup.get("id")); |
||||
|
|
||||
|
// 获取套餐中的物料id
|
||||
|
List<Object> mids = (List<Object>) map.get("mids"); |
||||
|
// 获取套餐中物料的数量
|
||||
|
List<Object> quantitys = (List<Object>) map.get("quantitys"); |
||||
|
|
||||
|
|
||||
|
// 用于添加套餐中的物料信息
|
||||
|
Map<String,Object> materialForGroupMap = new HashMap<>(); |
||||
|
|
||||
|
materialForGroupMap.put("gid",gid); |
||||
|
|
||||
|
Integer result = 0; |
||||
|
for (int i = 0; i < mids.size(); i++) { |
||||
|
// 获取物料id
|
||||
|
Object mid = mids.get(i); |
||||
|
// 获取套餐中当前物料对应的数量
|
||||
|
Object quantity = quantitys.get(i); |
||||
|
|
||||
|
materialForGroupMap.put("mid",mid); |
||||
|
materialForGroupMap.put("quantity",quantity); |
||||
|
|
||||
|
// 添加
|
||||
|
result += groupMapper.addGroupForMaterial(materialForGroupMap); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 通过编码获取对应的套餐 |
||||
|
* @param code 套餐编码 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Group findGroupByCode(String code) { |
||||
|
return groupMapper.findGroupByCode(code); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 给套餐添加物料信息 |
||||
|
* @param map 待添加信息 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer addMaterialForGroup(Map<String, Object> map) { |
||||
|
//获取插入的套餐id
|
||||
|
Integer gid = ObjectFormatUtil.toInteger(map.get("gid")); |
||||
|
|
||||
|
// 获取套餐中的物料id
|
||||
|
List<Object> mids = (List<Object>) map.get("mids"); |
||||
|
// 获取套餐中物料的数量
|
||||
|
List<Object> quantitys = (List<Object>) map.get("quantitys"); |
||||
|
|
||||
|
|
||||
|
// 用于添加套餐中的物料信息
|
||||
|
Map<String,Object> materialForGroupMap = new HashMap<>(); |
||||
|
|
||||
|
materialForGroupMap.put("gid",gid); |
||||
|
|
||||
|
Integer result = 0; |
||||
|
for (int i = 0; i < mids.size(); i++) { |
||||
|
// 获取物料id
|
||||
|
Object mid = mids.get(i); |
||||
|
// 获取套餐中当前物料对应的数量
|
||||
|
Object quantity = quantitys.get(i); |
||||
|
|
||||
|
materialForGroupMap.put("mid",mid); |
||||
|
materialForGroupMap.put("quantity",quantity); |
||||
|
|
||||
|
// 添加
|
||||
|
result += groupMapper.addGroupForMaterial(materialForGroupMap); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加一条套餐 |
||||
|
* @param groupInfo 具体数据 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer addGroup(GroupInfo groupInfo) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据主键删除一条套餐记录 |
||||
|
* @param id 待删除套餐主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Transactional |
||||
|
@Override |
||||
|
public Integer delGroupById(Integer id) { |
||||
|
|
||||
|
Map<String,Object> param = new HashMap<>(); |
||||
|
param.put("gid",id); |
||||
|
|
||||
|
List<GroupInfo> groupByCondition = groupMapper.findGroupByCondition(param); |
||||
|
List<Integer> ids = new ArrayList<>(); |
||||
|
for (GroupInfo groupInfo : groupByCondition) { |
||||
|
ids.add(groupInfo.getId()); |
||||
|
} |
||||
|
groupMapper.delMaterialForGroupByIds(ids); |
||||
|
|
||||
|
return groupMapper.delGroup(id); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据主键批量删除套餐记录 |
||||
|
* @param ids 主键列表 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer delGroupByIds(List<Integer> ids) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改套餐中对应物料信息 |
||||
|
* @param map 修改数据及条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer updateMaterialForGroup(Map<String, Object> map) { |
||||
|
// 获取当前要修改的套餐明细id
|
||||
|
Integer id = ObjectFormatUtil.toInteger(map.get("id")); |
||||
|
// 获取当前要修改的物料明细数量
|
||||
|
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity")); |
||||
|
if(Integer.compare(0,quantity) == 0){ |
||||
|
// 如果要修改的数量为0则删除该明细
|
||||
|
return groupMapper.delMaterialForGroupById(id); |
||||
|
}else { |
||||
|
// 根据id获取当前套餐明细
|
||||
|
GroupInfo groupById = groupMapper.findGroupById(id); |
||||
|
groupById.setQuantity(quantity); |
||||
|
return groupMapper.updateMaterialForGroup(groupById); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 通过物料id与套餐id查询对应套餐明细 |
||||
|
* @param mid 物料id |
||||
|
* @param gid 套餐id |
||||
|
* @return 套餐明细 |
||||
|
*/ |
||||
|
@Override |
||||
|
public GroupInfo findGroupInfoByMidAndGid(Integer mid, Integer gid) { |
||||
|
Map<String,Object> map = new HashMap<>(); |
||||
|
map.put("mid",mid); |
||||
|
map.put("gid",gid); |
||||
|
List<GroupInfo> groupByCondition = groupMapper.findGroupByCondition(map); |
||||
|
if(groupByCondition.size() > 0){ |
||||
|
return groupByCondition.get(0); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据主键删除一条套餐中的物料明细 |
||||
|
* @param id 待删除主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer delMaterialForGroupById(Integer id) { |
||||
|
return groupMapper.delMaterialForGroupById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据主键批量删除套餐中的物料明细 |
||||
|
* @param ids 待删除主键 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer delMaterialForGroupByIds(List<Integer> ids) { |
||||
|
return groupMapper.delMaterialForGroupByIds(ids); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据条件修改套餐信息 |
||||
|
* @param map 修改条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer updateGroupState(Map<String, Object> map) { |
||||
|
// 获取待修改套餐id
|
||||
|
Integer id = ObjectFormatUtil.toInteger(map.get("id")); |
||||
|
// 根据主键获取对应套餐
|
||||
|
Group group = groupMapper.findGroupOnlyById(id); |
||||
|
Integer state = 2; |
||||
|
if(map.containsKey("state")){ |
||||
|
state = ObjectFormatUtil.toInteger(map.get("state")); |
||||
|
} |
||||
|
group.setState(state); |
||||
|
return groupMapper.updateGroupOnly(group); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据条件修改套餐信息 |
||||
|
* @param map 修改条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public Integer updateGroupInfo(Map<String, Object> map) { |
||||
|
return groupMapper.updateGroupOnly(map); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据条件获取套餐 |
||||
|
* @param map 查询条件 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<Group> findGroupOnlyByCondition(Map<String, Object> map) { |
||||
|
return groupMapper.findGroupOnlyByCondition(map); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用于构造套餐树 |
||||
|
* @param gname |
||||
|
* @return |
||||
|
*/ |
||||
|
public List<Object> InitTreeMenus(String gname) { |
||||
|
// 定义结果集
|
||||
|
List<Object> list = new ArrayList<>(); |
||||
|
|
||||
|
// 获取所有使用中的套餐
|
||||
|
List<Group> allGroupOnly = groupMapper.findAllGroupOnly(gname); |
||||
|
|
||||
|
// 获取当前总数
|
||||
|
Integer totalVal = allGroupOnly.size(); |
||||
|
|
||||
|
// 定义分页数量
|
||||
|
double size = 10.0; |
||||
|
|
||||
|
// 定义线程数
|
||||
|
Integer threadSize = (int) Math.ceil(totalVal / size); |
||||
|
|
||||
|
// 定义开启线程数目
|
||||
|
Integer openThreadSize = 0; |
||||
|
// 开启对应数量的线程
|
||||
|
ExecutorService exs = Executors.newFixedThreadPool(threadSize); |
||||
|
// 线程结果集
|
||||
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
||||
|
|
||||
|
// 1.定义CompletionService
|
||||
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
||||
|
|
||||
|
|
||||
|
// 定义套餐id列表
|
||||
|
List<Integer> groupIdList = new ArrayList<>(); |
||||
|
|
||||
|
|
||||
|
for (int i = 0; i < allGroupOnly.size(); i++) { |
||||
|
Group group = allGroupOnly.get(i); |
||||
|
if (((i + 1) % 10) == 0) { // 如果有10个开启线程进行处理
|
||||
|
groupIdList.add(group.getId()); |
||||
|
Future<Object> future = completionService.submit(new Task(groupIdList)); |
||||
|
openThreadSize++; |
||||
|
futureList.add(future); // 添加到结果集
|
||||
|
groupIdList = new ArrayList<>(); // 情况列表
|
||||
|
} else { |
||||
|
// 添加id到列表中
|
||||
|
groupIdList.add(group.getId()); |
||||
|
} |
||||
|
} |
||||
|
if (groupIdList.size() > 0) { |
||||
|
// 如果有剩余,开启线程进行处理
|
||||
|
Future<Object> future = completionService.submit(new Task(groupIdList)); |
||||
|
futureList.add(future); |
||||
|
openThreadSize++; |
||||
|
} |
||||
|
|
||||
|
for (int i = 0; i < openThreadSize; i++) { |
||||
|
Object result = null; |
||||
|
try { |
||||
|
result = completionService.take().get(); |
||||
|
} catch (InterruptedException | ExecutionException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
list.addAll((Collection<?>) result); |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
// 用于执行线程任务
|
||||
|
class Task implements Callable<Object> { |
||||
|
|
||||
|
// 套餐id列表
|
||||
|
List<Integer> groupIdList; |
||||
|
|
||||
|
|
||||
|
public Task(List<Integer> groupIdList){ |
||||
|
this.groupIdList = groupIdList; |
||||
|
|
||||
|
} |
||||
|
@Override |
||||
|
public Object call() throws Exception { |
||||
|
/** |
||||
|
* 获取当前套餐id对应的套餐 |
||||
|
*/ |
||||
|
List<Group> groupByGids = groupMapper.findGroupByGids(groupIdList); |
||||
|
|
||||
|
// 开启对应数量的线程
|
||||
|
ExecutorService exs = Executors.newFixedThreadPool(groupByGids.size()); |
||||
|
// 线程结果集
|
||||
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
||||
|
|
||||
|
// 1.定义CompletionService
|
||||
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
||||
|
|
||||
|
|
||||
|
// 定义结果集
|
||||
|
List<Object> list = new ArrayList<>(); |
||||
|
|
||||
|
for (int i = 0; i < groupByGids.size(); i++) { |
||||
|
// 获取套餐具体信息
|
||||
|
Group group = groupByGids.get(i); |
||||
|
// 开启线程
|
||||
|
Future<Object> submit = completionService.submit(new TaskForGroupInfo(group)); |
||||
|
futureList.add(submit); |
||||
|
} |
||||
|
|
||||
|
for (int i = 0; i < groupByGids.size(); i++) { |
||||
|
Object result = null; |
||||
|
try { |
||||
|
result = completionService.take().get(); |
||||
|
} catch (InterruptedException | ExecutionException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
list.add(result); |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class TaskForGroupInfo implements Callable<Object>{ |
||||
|
|
||||
|
Group group; |
||||
|
TaskForGroupInfo(Group group){ |
||||
|
this.group = group; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Object call() throws Exception |
||||
|
{ |
||||
|
// 用于获取当前套餐的具体信息
|
||||
|
Map<String,Object> paramForGroup = new HashMap<>(); |
||||
|
paramForGroup.put("gid",group.getId()); |
||||
|
// 获取当前套餐的具体信息
|
||||
|
List<GroupInfo> groupByCondition = groupMapper.findGroupByCondition(paramForGroup); |
||||
|
// 定义子类结果集
|
||||
|
List<Object> resultForChildren = new ArrayList<>(); |
||||
|
for (GroupInfo groupInfo : groupByCondition) { |
||||
|
Map<String, Object> stringObjectMap = InitTreeMenus(groupInfo); |
||||
|
resultForChildren.add(stringObjectMap); |
||||
|
} |
||||
|
Map<String, Object> stringObjectMap = InitTreeMenus(group, resultForChildren); |
||||
|
return stringObjectMap; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 构造树形组件数据模板 |
||||
|
* @param g 套餐 |
||||
|
* @param children 子类 |
||||
|
* @return |
||||
|
*/ |
||||
|
public Map<String, Object> InitTreeMenus(Group g, List<Object> children) { |
||||
|
if (g != null) { |
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
map.put("title", g.getGname()); |
||||
|
map.put("id", g.getId()); |
||||
|
map.put("children", children); |
||||
|
return map; |
||||
|
} else { |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 构造树形组件的子组件模板 |
||||
|
* @param g 套餐详细信息 |
||||
|
* @return |
||||
|
*/ |
||||
|
public Map<String, Object> InitTreeMenus(GroupInfo g) { |
||||
|
if (g != null) { |
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
map.put("title", g.getMname() + ",数量:" + g.getQuantity()); |
||||
|
map.put("id", g.getId()); |
||||
|
return map; |
||||
|
} else { |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 用于创建套餐编码 |
||||
|
* @param num 第几个套餐 |
||||
|
* @return |
||||
|
*/ |
||||
|
public String createCode(Integer num){ |
||||
|
String code = "g-"+String.format("%05d", num + 1); |
||||
|
return code; |
||||
|
} |
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,831 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<title>分步表单</title> |
||||
|
<meta name="renderer" content="webkit"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
||||
|
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
||||
|
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
||||
|
<link rel="stylesheet" href="/static/js/lay-module/step-lay/step.css" media="all"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<style> |
||||
|
.inputdiv { |
||||
|
display: flex; |
||||
|
background-color: #fff; |
||||
|
height: 38px; |
||||
|
line-height: 38px; |
||||
|
border: 1px solid rgb(238, 238, 238); |
||||
|
} |
||||
|
|
||||
|
.layui-form-label { |
||||
|
padding: 9px 0px; |
||||
|
text-align: left; |
||||
|
} |
||||
|
|
||||
|
.layui-input-block { |
||||
|
margin-left: 80px; |
||||
|
} |
||||
|
|
||||
|
.layui-form-select { |
||||
|
width: 100%; |
||||
|
border-style: none; |
||||
|
} |
||||
|
|
||||
|
.layui-card-body { |
||||
|
padding: 10px 5px; |
||||
|
} |
||||
|
|
||||
|
.lay-step { |
||||
|
display: none; |
||||
|
} |
||||
|
|
||||
|
.layui-form-select .layui-input{ |
||||
|
border-style: none; |
||||
|
} |
||||
|
</style> |
||||
|
<div class="layuimini-container"> |
||||
|
<div class="layuimini-main"> |
||||
|
<div class="layui-fluid"> |
||||
|
<!-- 出库申请--> |
||||
|
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;"> |
||||
|
<div carousel-item style="overflow: inherit"> |
||||
|
<div> |
||||
|
<form class="layui-form layui-form-pane" style="margin: 0 auto;max-width: 460px;"> |
||||
|
<div class="layui-card" id="cardParent"> |
||||
|
<div class="layui-card-body" id="cardItem"> |
||||
|
<hr> |
||||
|
<i class="layui-icon layui-icon-subtraction" style="display: inline" |
||||
|
onclick="deleteItem(this)"></i> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料名称:</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<div class="inputdiv"> |
||||
|
<input type="text" placeholder="请选择物料" class="layui-input" |
||||
|
style="border-style: none" |
||||
|
id="openSonByMaterial" onblur="selectMaterialByName(this)" |
||||
|
lay-verify="required"/> |
||||
|
<i class="layui-icon layui-icon-search" style="display: inline" |
||||
|
id="selectMaterial" onclick="selectMaterial(this)"></i> |
||||
|
</div> |
||||
|
<input type="text" name="mid" class="layui-input" id="mid" |
||||
|
style="display: none" lay-verify="required"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料编码:</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<div class="inputdiv"> |
||||
|
<input id="code" name="code" type="text" placeholder="请填写入物料编码" value="" |
||||
|
onblur="selectCode(this)" |
||||
|
class="layui-input" lay-verify="required" |
||||
|
style="border-style: none"> |
||||
|
<img src="/static/images/search.ico" height="16" width="16" |
||||
|
style="margin-top: 10px" onclick="scanCodeByOut(this)"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">条形编码:</label> |
||||
|
<div class="layui-input-block" style="margin: 0px;"> |
||||
|
<div class="inputdiv"> |
||||
|
<input id="barCode" name="barCode" type="text" placeholder="请填写入条形编码" |
||||
|
value="" |
||||
|
class="layui-input" |
||||
|
style="border-style: none"> |
||||
|
<img src="/static/images/search.ico" height="16" width="16" |
||||
|
id="barCodeImg" |
||||
|
style="margin-top: 10px" onclick="scanBarCode(this)"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料数量:</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<input name="quantity" type="number" placeholder="请填写入物料数量" value="" |
||||
|
onblur="MaterialQuantityIsTrue(this)" id="quantity" |
||||
|
class="layui-input" lay-verify="number" required> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">备注说明:</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<input name="applyRemark" placeholder="请填写相关原因及申请原因" value="" |
||||
|
class="layui-input"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<i class="layui-icon layui-icon-addition" style="display: inline" |
||||
|
onclick="addItem(this)"></i> |
||||
|
</div> |
||||
|
|
||||
|
<!-- 提交按钮--> |
||||
|
<div class="layui-form-item" id="btn_sub"> |
||||
|
<div class="layui-input-block"> |
||||
|
<button class="layui-btn" lay-submit lay-filter="formStep" |
||||
|
style="margin-bottom: 30px;margin-left: 15%"> |
||||
|
 提交  |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
<div> |
||||
|
<form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;"> |
||||
|
<div style="text-align: center;margin-top: 90px;"> |
||||
|
<i class="layui-icon layui-circle" |
||||
|
style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;"></i> |
||||
|
<div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;"> |
||||
|
提交申请成功 |
||||
|
</div> |
||||
|
</div> |
||||
|
<div style="text-align: center;margin-top: 50px;"> |
||||
|
<button class="layui-btn next">再申请一次</button> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
||||
|
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script> |
||||
|
<script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script> |
||||
|
<script> |
||||
|
// 用于添加标签 |
||||
|
function addItem(obj) { |
||||
|
} |
||||
|
|
||||
|
// 用于删除标签 |
||||
|
function deleteItem(obj) { |
||||
|
} |
||||
|
|
||||
|
// 用于编码查询 |
||||
|
function selectCode(obj) { |
||||
|
} |
||||
|
|
||||
|
// 用于点击搜索按钮 |
||||
|
function selectMaterial(obj) { |
||||
|
} |
||||
|
|
||||
|
// 用于物料名称查询 |
||||
|
function selectMaterialByName(obj) { |
||||
|
} |
||||
|
|
||||
|
// 用于判断当前物料数量是否合适 |
||||
|
function MaterialQuantityIsTrue() { |
||||
|
} |
||||
|
|
||||
|
// 用于扫描条形码 |
||||
|
function scanBarCode() { |
||||
|
} |
||||
|
|
||||
|
// 用于重新渲染页面 |
||||
|
function Coverpage() { |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// 用于扫码出库 |
||||
|
function scanCodeByOut(obj) { |
||||
|
} |
||||
|
|
||||
|
// 用于暂存卡片个数 |
||||
|
var params = []; |
||||
|
// 用于卡片编号 |
||||
|
var NewIdNumber = 1; |
||||
|
layui.use(['form', 'step', 'layer', 'jquery'], function () { |
||||
|
var $ = layui.$, |
||||
|
form = layui.form, |
||||
|
step = layui.step; |
||||
|
// 用于分步表单加载 |
||||
|
step.render({ |
||||
|
elem: '#stepForm', |
||||
|
filter: 'stepForm', |
||||
|
width: '100%', //设置容器宽度 |
||||
|
height: '600px', |
||||
|
stepItems: [{ |
||||
|
title: '填写信息' |
||||
|
}, { |
||||
|
title: '提交成功' |
||||
|
}] |
||||
|
}); |
||||
|
|
||||
|
// 提交 |
||||
|
form.on('submit(formStep)', function (data) { |
||||
|
data = data.field; |
||||
|
data.params = params; |
||||
|
if (data.mid === undefined) { |
||||
|
// 如果没有初始项 |
||||
|
var dataKeys = Object.keys(data); |
||||
|
var dataKey; |
||||
|
for (let i = 0; i < dataKeys.length; i++) { |
||||
|
dataKey = dataKeys[i]; |
||||
|
if (dataKey.includes("mid")) { |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
// 获取当前数字 |
||||
|
var keyNumber = dataKey.split("mid")[1]; |
||||
|
for (let index = 0; index < dataKeys.length; index++) { |
||||
|
var tempKey = dataKeys[index]; |
||||
|
if (tempKey.includes(keyNumber)) { |
||||
|
var key = tempKey.replace(keyNumber, ""); |
||||
|
data[key] = data[tempKey]; |
||||
|
delete data[tempKey]; |
||||
|
} |
||||
|
} |
||||
|
data.params = remove(data.params, Number(keyNumber)); |
||||
|
} |
||||
|
$.ajax({ |
||||
|
url: "/depositoryRecord/applicationOut", |
||||
|
type: 'post', |
||||
|
dataType: 'json', |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
data: JSON.stringify(data), |
||||
|
beforeSend: function () { |
||||
|
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
||||
|
}, |
||||
|
success: function (data) { |
||||
|
layer.close(this.layerIndex); |
||||
|
if (data.status >= 300) { |
||||
|
layer.msg(data.statusInfo.message);//失败的表情 |
||||
|
|
||||
|
} else { |
||||
|
layer.msg("申请提交成功", { |
||||
|
icon: 6,//成功的表情 |
||||
|
time: 500 //1秒关闭(如果不配置,默认是3秒) |
||||
|
}, function () { |
||||
|
step.next('#stepForm'); |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
}, |
||||
|
complete: function () { |
||||
|
layer.close(this.layerIndex); |
||||
|
} |
||||
|
}); |
||||
|
return false; |
||||
|
}); |
||||
|
|
||||
|
form.on('submit(formStep2)', function (data) { |
||||
|
step.next('#stepForm'); |
||||
|
return false; |
||||
|
}); |
||||
|
|
||||
|
$('.pre').click(function () { |
||||
|
step.pre('#stepForm'); |
||||
|
}); |
||||
|
|
||||
|
$('.next').click(function () { |
||||
|
step.next('#stepForm'); |
||||
|
}); |
||||
|
|
||||
|
// 实现卡片添加 |
||||
|
addItem = function (obj) { |
||||
|
// 获取父元素id |
||||
|
var parentId = obj.parentNode.id; |
||||
|
NewIdNumber = NewIdNumber + 1; |
||||
|
// 物料名称栏目 |
||||
|
var materialItem = ` |
||||
|
<div class="layui-card-body" id=` + "cardItem" + NewIdNumber + `> |
||||
|
<hr> |
||||
|
<i class="layui-icon layui-icon-subtraction" style="display: inline" onclick="deleteItem(this)"></i> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料名称</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<div class="inputdiv"> |
||||
|
<input type="text" placeholder="请选择物料" class="layui-input" style="border-style: none" |
||||
|
id="openSonByMaterial" lay-verify="required" onblur="selectMaterialByName(this)"/> |
||||
|
<i class="layui-icon layui-icon-search" style="display: inline" id="selectMaterial" onclick="selectMaterial(this)"></i> |
||||
|
</div> |
||||
|
<input type="text" name=` + "mid" + NewIdNumber + ` class="layui-input" id="mid" |
||||
|
style="display: none" lay-verify="required" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料编码:</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<div class="inputdiv"> |
||||
|
<input id=` + "code" + NewIdNumber + ` name=` + "code" + NewIdNumber + ` type="text" placeholder="请填写入物料编码" value="" |
||||
|
onblur="selectCode(this)" |
||||
|
class="layui-input" lay-verify="required" |
||||
|
style="border-style: none"> |
||||
|
<img src="/static/images/search.ico" height="16" width="16" |
||||
|
style="margin-top: 10px" onclick="scanCodeByOut(this)"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">条形编码:</label> |
||||
|
<div class="layui-input-block" style="margin: 0px;"> |
||||
|
<div class="inputdiv"> |
||||
|
<input id=` + "barCode" + NewIdNumber + ` name=` + "barCode" + NewIdNumber + ` type="text" placeholder="请填写入条形编码" |
||||
|
value="" |
||||
|
class="layui-input" |
||||
|
style="border-style: none"> |
||||
|
<img src="/static/images/search.ico" height="16" width="16" id=` + "barCodeImg" + NewIdNumber + ` |
||||
|
style="margin-top: 10px" onclick="scanBarCode(this)"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料数量:</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<input name=` + "quantity" + NewIdNumber + ` type="number" placeholder="请填写入物料数量" value="" onblur="MaterialQuantityIsTrue(this)" |
||||
|
id=` + "quantity" + NewIdNumber + ` class="layui-input" lay-verify="number"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">备注说明:</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<input name=` + "applyRemark" + NewIdNumber + ` placeholder="请填写相关原因及申请原因" value="" |
||||
|
class="layui-input"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<i class="layui-icon layui-icon-addition" style="display: inline" onclick="addItem(this)"></i> |
||||
|
</div>`; |
||||
|
// 获取当前高度 |
||||
|
var height = parseInt(($("#stepForm").css('height')).split("px")[0]); |
||||
|
params.push(NewIdNumber); |
||||
|
$("#stepForm").css("height", height + 422 + 'px'); |
||||
|
$("#" + parentId).after(materialItem); |
||||
|
}; |
||||
|
|
||||
|
// 用于重新渲染页面 |
||||
|
Coverpage = function (num, obj) { |
||||
|
var parent = $("#cardParent"); |
||||
|
// 获取待添加父类 |
||||
|
NewIdNumber = num; |
||||
|
if (num === 0) { // 如果是第一个 |
||||
|
NewIdNumber = ""; |
||||
|
} |
||||
|
var firstItem = |
||||
|
// 前半部分 |
||||
|
` <div class="layui-card-body" style="padding-right: 0px" id=` + "cardItem" + NewIdNumber + `> |
||||
|
<hr> |
||||
|
<i class="layui-icon layui-icon-subtraction" style="display: inline" onclick="deleteItem(this)"></i> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料名称</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<div class="inputdiv"> |
||||
|
<input type="text" placeholder="请选择物料" class="layui-input" style="border-style: none" |
||||
|
id="openSonByMaterial" lay-verify="required" value="${obj.mname}" onblur="selectMaterialByName(this)"/> |
||||
|
<i class="layui-icon layui-icon-search" style="display: inline" id="selectMaterial" onclick="selectMaterial(this)"></i> |
||||
|
</div> |
||||
|
<input type="text" name=` + "mid" + NewIdNumber + ` class="layui-input" id="mid" value="${obj.mid}" |
||||
|
style="display: none" lay-verify="required" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料编码:</label> |
||||
|
<div class="layui-input-block" style="margin: 0px;"> |
||||
|
<div class="inputdiv"> |
||||
|
<input id="code" name=` + "code" + NewIdNumber + ` type="text" placeholder="请填写入物料编码" onblur="selectCode(this)" |
||||
|
class="layui-input" lay-verify="required" value="${obj.code}" style="border-style: none"> |
||||
|
<img src="/static/images/search.ico" height="16" width="16" style="margin-top: 10px" onclick="scanCodeByOut(this)" > |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">条形编码:</label> |
||||
|
<div class="layui-input-block" style="margin: 0px;"> |
||||
|
<div class="inputdiv"> |
||||
|
|
||||
|
<select id=` + "barCode" + NewIdNumber + ` name=` + "barCode" + NewIdNumber + `></select> |
||||
|
<img src="/static/images/search.ico" height="16" width="16" style="margin-top: 10px" onclick="scanBarCode(this)" > |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料数量:</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<input name=` + "quantity" + NewIdNumber + ` type="number" placeholder="请填写入物料数量" value="" |
||||
|
class="layui-input" lay-verify="number"> |
||||
|
</div> |
||||
|
</div>`; |
||||
|
|
||||
|
|
||||
|
var lastItem = `<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">备注说明:</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<input name=` + "applyRemark" + NewIdNumber + ` placeholder="请填写相关原因及申请原因" value="" |
||||
|
class="layui-input"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<i class="layui-icon layui-icon-addition" style="display: inline" onclick="addItem(this)"></i> |
||||
|
</div>`; |
||||
|
// 获取当前高度 |
||||
|
var height = parseInt(($("#stepForm").css('height')).split("px")[0]); |
||||
|
if (NewIdNumber !== "") { |
||||
|
params.push(NewIdNumber) |
||||
|
} |
||||
|
$("#stepForm").css("height", height + 532 + 'px'); |
||||
|
var materialItem = firstItem + lastItem; // 最终 |
||||
|
$("#btn_sub").before(materialItem) |
||||
|
}; |
||||
|
|
||||
|
// 实现卡片删除 |
||||
|
deleteItem = function (obj) { |
||||
|
// 获取父节点 |
||||
|
var parent = obj.parentNode; |
||||
|
var parentId = parent.id; |
||||
|
parentId = parseInt(parentId.split("cardItem")[1]); |
||||
|
// 获取祖父节点 |
||||
|
var reparent = parent.parentNode; |
||||
|
var height = parseInt(($("#stepForm").css('height')).split("px")[0]); |
||||
|
$("#stepForm").css("height", height - 422 + 'px'); |
||||
|
params = remove(params, parentId); |
||||
|
reparent.removeChild(parent); |
||||
|
}; |
||||
|
|
||||
|
//删除数组中指定元素 |
||||
|
function remove(arr, item) { |
||||
|
var result = []; |
||||
|
for (let i = 0; i < arr.length; i++) { |
||||
|
if (arr[i] === item) { |
||||
|
continue; |
||||
|
} |
||||
|
result.push(arr[i]); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
// 用于实现通过编码查询物料 |
||||
|
selectCode = function (obj) { |
||||
|
// 输入code |
||||
|
var code = obj.value; |
||||
|
// 获取对应元素 |
||||
|
var parent = obj.parentNode.parentNode.parentNode.parentNode; |
||||
|
var objId = parent.id.split("cardItem")[1]; |
||||
|
var children = parent.childNodes[5]; |
||||
|
var materialItem = children.childNodes[3].childNodes[1].childNodes; |
||||
|
var barCodeChildren = parent.childNodes[9]; |
||||
|
|
||||
|
var materialName = materialItem[1]; |
||||
|
var materialId = materialName.parentNode.parentNode.childNodes[3]; |
||||
|
// 条形码条码 |
||||
|
var barCodeItem = barCodeChildren.childNodes[3]; |
||||
|
var req = {}; |
||||
|
req.code = code; |
||||
|
req.type = "out"; |
||||
|
$.ajax({ |
||||
|
url: "/material/findMatrialByCode", |
||||
|
type: "get", |
||||
|
dataType: 'json', |
||||
|
data: (req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (d) { |
||||
|
var d = d.data; |
||||
|
if (d == null) { |
||||
|
layer.msg("仓库中暂无该物料"); |
||||
|
materialName.value = ""; |
||||
|
materialId.value = ""; |
||||
|
obj.value = ""; |
||||
|
$('#place' + objId).empty(); |
||||
|
|
||||
|
} |
||||
|
else { |
||||
|
materialName.value = d.mname; |
||||
|
materialId.value = d.id; |
||||
|
var idNumber = materialId.name.split("mid")[1]; |
||||
|
// 获取物料与条形码的对应关系 |
||||
|
var materialAndBarCodeList = d["materialAndBarCodeList"]; |
||||
|
if (materialAndBarCodeList.length > 0) { |
||||
|
// 如果有对应的条形码 |
||||
|
var barCodeInput = barCodeItem.childNodes[1].childNodes[1]; |
||||
|
var barCodeImg = barCodeItem.childNodes[1].childNodes[3]; |
||||
|
var id = barCodeInput.id; |
||||
|
$("#" + id).remove(); |
||||
|
$("#barCode" + idNumber).empty(); |
||||
|
var barCode = $("#barCode" + idNumber); |
||||
|
if (barCode.length > 0) { |
||||
|
barCode.empty(); |
||||
|
} else { |
||||
|
var barCodeSelect = ` |
||||
|
<select id=` + "barCode" + idNumber + ` name=` + "barCode" + idNumber + `> |
||||
|
</select>`; |
||||
|
$("#" + barCodeImg.id).before(barCodeSelect); |
||||
|
} |
||||
|
form.render(); |
||||
|
$.each(materialAndBarCodeList, function (index, item) { |
||||
|
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素 |
||||
|
}); |
||||
|
form.render(); |
||||
|
} else { |
||||
|
var barCode = $("#barCode" + idNumber); |
||||
|
if (barCode.length > 0) { |
||||
|
barCode.empty(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
// 用于实现点击搜索按钮 |
||||
|
selectMaterial = function (obj) { |
||||
|
var parent = obj.parentNode.parentNode.parentNode.parentNode; |
||||
|
var parentId = parent.id; |
||||
|
var codeChildren = parent.childNodes[7]; |
||||
|
var materialChildren = parent.childNodes[5]; |
||||
|
var codeItem = codeChildren.childNodes[3].childNodes[1].childNodes; |
||||
|
var codeValue = codeItem[1]; |
||||
|
var materialItem = materialChildren.childNodes[3].childNodes[1].childNodes; |
||||
|
var materialName = materialItem[1]; |
||||
|
var materialId = materialName.parentNode.parentNode.childNodes[3]; |
||||
|
var mname = materialName.value; |
||||
|
var barCodeChildren = parent.childNodes[9]; |
||||
|
// 条形码条码 |
||||
|
var barCodeItem = barCodeChildren.childNodes[3]; |
||||
|
layer.open({ |
||||
|
type: 2, |
||||
|
title: '弹窗内容', |
||||
|
skin: 'layui-layer-rim', |
||||
|
maxmin: true, |
||||
|
shadeClose: true, //点击遮罩关闭层 |
||||
|
area: ['70%', '70%'], |
||||
|
// content: '/selectMaterialByCard?mname=' + mname + '&type=2&clickObj=' + parentId, |
||||
|
content: '/getMaterialAll?mname=' + mname + '&type=2&clickObj=' + parentId, |
||||
|
move: '.layui-layer-title', |
||||
|
fixed: false, |
||||
|
success: function (layero, index) { |
||||
|
var children = layero.children(); |
||||
|
var content = $(children[1]); |
||||
|
var iframeChildren = $(content.children()); |
||||
|
content.css('height', '100%'); |
||||
|
iframeChildren.css('height', '100%'); |
||||
|
}, |
||||
|
end: function () { |
||||
|
var mid = materialId.value; |
||||
|
$.ajax({ |
||||
|
url: "/material/findMatrialById?mid=" + mid, |
||||
|
type: "get", |
||||
|
dataType: 'json', |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (d) { |
||||
|
var material = d.data.materialById; |
||||
|
var code = material.code; |
||||
|
if (code === undefined) { |
||||
|
code = ""; |
||||
|
} |
||||
|
codeValue.value = code; |
||||
|
var materialAndBarCodeList = material["materialAndBarCodeList"]; |
||||
|
var idNumber = materialId.name.split("mid")[1]; |
||||
|
if (materialAndBarCodeList.length > 0) { |
||||
|
// 如果有对应的条形码 |
||||
|
var barCodeInput = barCodeItem.childNodes[1].childNodes[1]; |
||||
|
var barCodeImg = barCodeItem.childNodes[1].childNodes[3]; |
||||
|
var id = barCodeInput.id; |
||||
|
$("#" + id).remove(); |
||||
|
$("#barCode" + idNumber).empty(); |
||||
|
var barCode = $("#barCode" + idNumber); |
||||
|
if (barCode.length > 0) { |
||||
|
barCode.empty(); |
||||
|
} else { |
||||
|
var barCodeSelect = ` |
||||
|
<select id=` + "barCode" + idNumber + ` name=` + "barCode" + idNumber + `> |
||||
|
</select>`; |
||||
|
$("#" + barCodeImg.id).before(barCodeSelect); |
||||
|
} |
||||
|
form.render(); |
||||
|
$.each(materialAndBarCodeList, function (index, item) { |
||||
|
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素 |
||||
|
}); |
||||
|
form.render(); |
||||
|
} else { |
||||
|
var barCode = $("#barCode" + idNumber); |
||||
|
if (barCode.length > 0) { |
||||
|
barCode.empty(); |
||||
|
} |
||||
|
} |
||||
|
form.render(); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
//用于实现物料名称搜索 |
||||
|
selectMaterialByName = function (obj) { |
||||
|
var data = obj.value; |
||||
|
// 获取对应元素 |
||||
|
var parent = obj.parentNode.parentNode.parentNode.parentNode; |
||||
|
var materialChildren = parent.childNodes[5]; |
||||
|
var codeChildren = parent.childNodes[7]; |
||||
|
var codeItem = codeChildren.childNodes[3].childNodes[1].childNodes; |
||||
|
var codeValue = codeItem[1]; |
||||
|
var materialItem = materialChildren.childNodes[3].childNodes[1].childNodes; |
||||
|
var materialName = materialItem[1]; |
||||
|
var materialId = materialName.parentNode.parentNode.childNodes[3]; |
||||
|
var req = {}; |
||||
|
req.mname = data; |
||||
|
$.ajax({ |
||||
|
url: "/material/findInventoryByCondition", |
||||
|
type: "post", |
||||
|
dataType: 'json', |
||||
|
data: JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (d) { |
||||
|
if (d.count > 1) { |
||||
|
layer.msg("请点击右侧搜索确定物品"); |
||||
|
materialId.value = ""; |
||||
|
codeValue.value = ""; |
||||
|
return false; |
||||
|
} else if (d.count === 0) { |
||||
|
layer.msg("没有该物品,请确认输入是否正确"); |
||||
|
materialId.value = ""; |
||||
|
codeValue.value = ""; |
||||
|
materialName.value = ""; |
||||
|
return false; |
||||
|
} else { |
||||
|
var material = d.data[0]; |
||||
|
materialName.value = material.mname; |
||||
|
materialId.value = material.id; |
||||
|
codeValue.value = material.code; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
scanBarCode = function (obj) { |
||||
|
parent.wx.scanQRCode({ |
||||
|
desc: 'scanQRCode desc', |
||||
|
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果, |
||||
|
scanType: ["barCode"], // 可以指定扫二维码还是条形码(一维码),默认二者都有 |
||||
|
success: function (res) { |
||||
|
// 回调 |
||||
|
var result = res.resultStr;//当needResult为1时返回处理结果 |
||||
|
var req = {}; |
||||
|
req.qrCode = result; |
||||
|
$.ajax({ |
||||
|
url: "/material/qywxApplicationOutScanBarCode", |
||||
|
type: "post", |
||||
|
dataType: 'json', |
||||
|
data: JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (d) { |
||||
|
// 获取对应元素 |
||||
|
var parent = obj.parentNode.parentNode.parentNode.parentNode; |
||||
|
|
||||
|
var MaterialChildren = parent.childNodes[5]; |
||||
|
var materialItem = MaterialChildren.childNodes[3].childNodes[1].childNodes; |
||||
|
|
||||
|
var barCodeChildren = parent.childNodes[9]; |
||||
|
|
||||
|
var materialName = materialItem[1]; |
||||
|
var materialId = materialName.parentNode.parentNode.childNodes[3]; |
||||
|
// 条形码条码 |
||||
|
var barCodeItem = barCodeChildren.childNodes[3]; |
||||
|
// 物料编码 |
||||
|
var materialCodeItem = parent.childNodes[7].childNodes[3].childNodes[1].childNodes; |
||||
|
|
||||
|
|
||||
|
var materialCode = materialCodeItem[1]; |
||||
|
|
||||
|
var data = d.data; |
||||
|
if (data !== null) { |
||||
|
materialName.value = data.mname; |
||||
|
materialId.value = data.id; |
||||
|
materialCode.value = data.mcode; |
||||
|
var barCodeInput = barCodeItem.childNodes[1].childNodes[1]; |
||||
|
barCodeInput.value = result; |
||||
|
}else{ |
||||
|
// 如果没有对应关系 |
||||
|
layer.msg("对于编码:" + result + ",并未发现对应的物料", { |
||||
|
icon: 0, |
||||
|
time: 1000 //0.5秒关闭(如果不配置,默认是3秒) |
||||
|
}, function () { |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
// 用于扫码功能 |
||||
|
scanCodeByOut = function (obj) { |
||||
|
parent.wx.scanQRCode({ |
||||
|
desc: 'scanQRCode desc', |
||||
|
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果, |
||||
|
scanType: ["qrCode"], // 可以指定扫二维码还是条形码(一维码),默认二者都有 |
||||
|
success: function (res) { |
||||
|
// 回调 |
||||
|
var result = res.resultStr;//当needResult为1时返回处理结果 |
||||
|
var req = {}; |
||||
|
req.qrCode = result; |
||||
|
$.ajax({ |
||||
|
url: "/material/qywxApplicationOutScanQrCode", |
||||
|
type: "post", |
||||
|
dataType: 'json', |
||||
|
data: JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (d) { |
||||
|
var data = d.data; |
||||
|
// 获取对应元素 |
||||
|
var parent = obj.parentNode.parentNode.parentNode.parentNode; |
||||
|
var MaterialChildren = parent.childNodes[5]; |
||||
|
var materialItem = MaterialChildren.childNodes[3].childNodes[1].childNodes; |
||||
|
|
||||
|
var barCodeChildren = parent.childNodes[9]; |
||||
|
|
||||
|
var materialName = materialItem[1]; |
||||
|
var materialId = materialName.parentNode.parentNode.childNodes[3]; |
||||
|
// 条形码条码 |
||||
|
var barCodeItem = barCodeChildren.childNodes[3]; |
||||
|
// 物料编码 |
||||
|
var materialCodeItem = parent.childNodes[7].childNodes[3].childNodes[1].childNodes; |
||||
|
|
||||
|
var materialCode = materialCodeItem[1]; |
||||
|
|
||||
|
var idNumber = materialId.name.split("mid")[1]; |
||||
|
// 获取物料与条形码的对应关系 |
||||
|
var materialAndBarCodeList = data["materialAndBarCodeList"]; |
||||
|
var barCode = $("#barCode" + idNumber); |
||||
|
if (barCode.length > 0) { |
||||
|
barCode.empty(); |
||||
|
} |
||||
|
if (materialAndBarCodeList.length > 0) { |
||||
|
// 如果有对应的条形码 |
||||
|
var barCodeInput = barCodeItem.childNodes[1].childNodes[1]; |
||||
|
var barCodeImg = barCodeItem.childNodes[1].childNodes[3]; |
||||
|
var id = barCodeInput.id; |
||||
|
$("#" + id).remove(); |
||||
|
$("#barCode" + idNumber).empty(); |
||||
|
var barCode = $("#barCode" + idNumber); |
||||
|
if (barCode.length > 0) { |
||||
|
barCode.empty(); |
||||
|
} else { |
||||
|
var barCodeSelect = ` |
||||
|
<select id=` + "barCode" + idNumber + ` name=` + "barCode" + idNumber + `> |
||||
|
</select>`; |
||||
|
$("#" + barCodeImg.id).before(barCodeSelect); |
||||
|
} |
||||
|
form.render(); |
||||
|
|
||||
|
$.each(materialAndBarCodeList, function (index, item) { |
||||
|
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素 |
||||
|
}); |
||||
|
form.render(); |
||||
|
} |
||||
|
$('#place' + idNumber).empty(); |
||||
|
$.each(data.placePList, function (index, item) { |
||||
|
$('#place' + idNumber).append(new Option(item.depositoryName + "-" + item.code, item.id));//往下拉菜单里添加元素 |
||||
|
}); |
||||
|
form.render(); |
||||
|
materialName.value = data.mname; |
||||
|
materialId.value = data.id; |
||||
|
materialCode.value = data.code; |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}; |
||||
|
//用于判断当前物料数量是否合适 |
||||
|
MaterialQuantityIsTrue = function (obj) { |
||||
|
var id = obj.id.split("quantity")[1]; |
||||
|
var mcode = $("#code" + id).val(); // 获取到当前输入的物料编码 |
||||
|
if (mcode === "" || mcode === undefined || mcode === null) { |
||||
|
layer.msg("请输入物料的正确编码!", {icon: 0, time: 500}, function () { |
||||
|
$("#quantity" + id).val("") |
||||
|
}); |
||||
|
} else { |
||||
|
let val = $("#quantity" + id).val(); |
||||
|
if (val !== null && val !== undefined && val !== '') { |
||||
|
var req = {}; |
||||
|
req.mcode = mcode; |
||||
|
req.quantity = val; |
||||
|
$.ajax({ |
||||
|
url: "/material/MaterialQuantityIsTrue", |
||||
|
type: "post", |
||||
|
data: JSON.stringify(req), |
||||
|
dataType: 'json', |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (res) { |
||||
|
var flag = res.data; |
||||
|
if (!flag) { // 如果当前数目不合适 |
||||
|
layer.msg("当前物料数量不足", {icon: 0, time: 500}, function () { |
||||
|
$("#quantity" + id).val(""); |
||||
|
}); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
}) |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,340 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<title>layui</title> |
||||
|
<meta name="renderer" content="webkit"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
||||
|
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
||||
|
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<div class="layuimini-container"> |
||||
|
<div class="layuimini-main"> |
||||
|
<input style="display: none" id="gid" th:value="${gid}"> |
||||
|
<script id="toolbarDemo" type="text/html"> |
||||
|
<div class="layui-btn-container"> |
||||
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add">添加</button> |
||||
|
</div> |
||||
|
</script> |
||||
|
<fieldset class="table-search-fieldset"> |
||||
|
<legend>搜索信息</legend> |
||||
|
<div style="margin: 10px 10px 10px 10px"> |
||||
|
<form class="layui-form layui-form-pane" action=""> |
||||
|
<div class="layui-form-item"> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label">种类</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" placeholder="请选择物料类型" class="layui-input" id="openSonByMateralType" |
||||
|
readonly/> |
||||
|
<input type="text" id="materialTypeId" placeholder="请选择物料类型" name="materialTypeId" |
||||
|
class="layui-input" style="display: none"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label">物料名称</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" name="mname" autocomplete="off" class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label">存货编码</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" name="code" autocomplete="off" class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-inline"> |
||||
|
<button type="submit" class="layui-btn layui-btn-primary" lay-submit |
||||
|
lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索 |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
</fieldset> |
||||
|
|
||||
|
|
||||
|
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table> |
||||
|
</div> |
||||
|
</div> |
||||
|
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
||||
|
|
||||
|
<script> |
||||
|
layui.use(['form', 'layer', 'dropdown', 'tree', 'laydate'], function () { |
||||
|
var $ = layui.jquery, |
||||
|
form = layui.form, |
||||
|
table = layui.table; |
||||
|
|
||||
|
// 用于暂存选择的数据 |
||||
|
let checkList = []; |
||||
|
|
||||
|
let gid = $("#gid").val(); |
||||
|
|
||||
|
$('#openSonByMateralType').on('click', function () { |
||||
|
layer.open({ |
||||
|
type: 2, |
||||
|
title: '弹窗内容', |
||||
|
skin: 'layui-layer-rim', |
||||
|
maxmin: true, |
||||
|
shadeClose: true, //点击遮罩关闭层 |
||||
|
area: ['70%', '70%'], |
||||
|
move: '.layui-layer-title', |
||||
|
fixed: false, |
||||
|
content: '/selectType', |
||||
|
success: function (layero, index) { |
||||
|
var children = layero.children(); |
||||
|
var content = $(children[1]); |
||||
|
var iframeChildren = $(content.children()); |
||||
|
content.css('height', '100%'); |
||||
|
iframeChildren.css('height', '100%'); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
table.render({ |
||||
|
elem: "#currentTableId", |
||||
|
url: '/material/material', |
||||
|
parseData: function (res) { //res 即为原始返回的数据 |
||||
|
return { |
||||
|
"status": res.status, //解析接口状态 |
||||
|
"message": res.statusInfo.message, //解析提示文本 |
||||
|
"count": res.count, //解析数据长度 |
||||
|
"data": res.data //解析数据列表 |
||||
|
}; |
||||
|
}, |
||||
|
request: { |
||||
|
pageName: 'page', //页码的参数名称,默认:page |
||||
|
limitName: 'size' //每页数据量的参数名,默认:limit |
||||
|
}, |
||||
|
response: { |
||||
|
statusName: 'status' //规定数据状态的字段名称,默认:code |
||||
|
, statusCode: 200 //规定成功的状态码,默认:0 |
||||
|
, msgName: 'message' //规定状态信息的字段名称,默认:msg |
||||
|
, countName: 'count' //规定数据总数的字段名称,默认:count |
||||
|
, dataName: 'data' //规定数据列表的字段名称,默认:data |
||||
|
}, |
||||
|
toolbar: '#toolbarDemo', |
||||
|
cols: [ |
||||
|
[ |
||||
|
{type: "checkbox", width: 50}, |
||||
|
{field: 'quantity', width: 200, title: '数量', edit: 'quantity'}, |
||||
|
{field: 'mname', width: 200, title: '物料名称'}, |
||||
|
{field: 'version', width: 250, title: '规格型号'}, |
||||
|
{field: 'code', width: 200, title: '存货编码'}, |
||||
|
{field: 'typeName', width: 200, title: '物料类型'}, |
||||
|
{field: 'unit', width: 200, title: '计量单位'}, |
||||
|
{field: 'texture', width: 200, title: '材质',}, |
||||
|
] |
||||
|
], |
||||
|
limits: [10, 15, 20, 25, 50, 100], |
||||
|
limit: 10, |
||||
|
page: true, |
||||
|
skin: 'line', |
||||
|
done: function (res, curr, count) { |
||||
|
if (checkList.length > 0) { |
||||
|
let count = 0; |
||||
|
|
||||
|
$.each(res['data'], function (i, j) { |
||||
|
let id = j["id"]; |
||||
|
for (let k = 0; k < checkList.length; k++) { |
||||
|
if(checkList[k].id === id){ |
||||
|
let index = j["LAY_TABLE_INDEX"]; |
||||
|
$('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked','true'); |
||||
|
form.render('checkbox'); //刷新checkbox选择框渲染 |
||||
|
count++; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
if(count === res.data.length){ |
||||
|
// 如果是全选 |
||||
|
$('tr input[type="checkbox"]').prop('checked','true'); |
||||
|
form.render('checkbox'); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
table.on('toolbar(currentTableFilter)', function (obj) { |
||||
|
if (obj.event === 'add') { // 监听添加操作申请操作 |
||||
|
var checkStatus = table.checkStatus('currentTableId') |
||||
|
, data = checkStatus.data; |
||||
|
var req = {}; |
||||
|
req.mids = []; |
||||
|
req.quantitys = []; |
||||
|
let len = data.length; |
||||
|
for (let i = 0; i < len; i++) { |
||||
|
req.mids[i] = data[i].id; |
||||
|
req.quantitys[i] = data[i].quantity; |
||||
|
} |
||||
|
req.len = len; |
||||
|
if (req.mids.length > 0) { |
||||
|
// 如果有,则进行下一步 |
||||
|
if(gid === "-1") { |
||||
|
|
||||
|
$.ajax({ |
||||
|
url: '/group/addGroup', |
||||
|
type: 'post', |
||||
|
dataType: "json", |
||||
|
data: JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (res) { |
||||
|
if (res.status >= 300) { |
||||
|
layer.msg(res.statusInfo.message);//失败的表情 |
||||
|
return; |
||||
|
} else { |
||||
|
layer.msg("添加成功!", { |
||||
|
icon: 6,//成功的表情 |
||||
|
time: 1000 |
||||
|
}, //1秒关闭(如果不配置,默认是3秒) |
||||
|
function () { |
||||
|
//do something |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/material/material', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
} |
||||
|
}, 'data') |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}) |
||||
|
}else{ |
||||
|
req.gid = gid; |
||||
|
$.ajax({ |
||||
|
url: '/group/addMaterialForGroup', |
||||
|
type: 'post', |
||||
|
dataType: "json", |
||||
|
data: JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (res) { |
||||
|
if (res.status >= 300) { |
||||
|
layer.msg(res.statusInfo.message);//失败的表情 |
||||
|
return; |
||||
|
} else { |
||||
|
layer.msg("添加成功!", { |
||||
|
icon: 6,//成功的表情 |
||||
|
time: 1000 |
||||
|
}, //1秒关闭(如果不配置,默认是3秒) |
||||
|
function () { |
||||
|
//do something |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/material/material', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
} |
||||
|
}, 'data') |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}) |
||||
|
} |
||||
|
}else{ |
||||
|
layer.msg("请选择物料",{ |
||||
|
icon:0, |
||||
|
time:500 |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// 监听搜索操作 |
||||
|
form.on('submit(data-search-btn)', function (data) { |
||||
|
var req = {}; |
||||
|
data = data.field; |
||||
|
req.type = 1; |
||||
|
if (data.mname !== '') { |
||||
|
req.mname = data.mname; |
||||
|
} |
||||
|
|
||||
|
if (data.materialTypeId !== '') { |
||||
|
req.materialTypeId = data.materialTypeId; |
||||
|
} |
||||
|
|
||||
|
if (data.code !== '') { |
||||
|
req.code = data.code |
||||
|
} |
||||
|
|
||||
|
//执行搜索重载 |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/material/material', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
where: req |
||||
|
}, 'data'); |
||||
|
return false; |
||||
|
}); |
||||
|
|
||||
|
//监听表格复选框选择 |
||||
|
table.on('checkbox(currentTableFilter)', function (obj) { |
||||
|
if(obj.type === "one") { |
||||
|
// 如果选择的是一个 |
||||
|
if (obj.checked) { |
||||
|
let flag = true; |
||||
|
for (let i = 0; i < checkList.length; i++) { |
||||
|
let data = checkList[i]; |
||||
|
if (data.id === obj.data.id) { |
||||
|
flag = false; |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
if (flag) { |
||||
|
checkList.push(obj.data); |
||||
|
} |
||||
|
} else { |
||||
|
for (let i = 0; i < checkList.length; i++) { |
||||
|
let data = checkList[i]; |
||||
|
if (data.id === obj.data.id) { |
||||
|
checkList.splice(i, i + 1); |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
else{ |
||||
|
// 如果是全选 |
||||
|
|
||||
|
|
||||
|
// 获取选中的数据 |
||||
|
let dataList = table.checkStatus('currentTableId').data; |
||||
|
if (obj.checked) { |
||||
|
for (let i = 0; i < dataList.length; i++) { |
||||
|
let dataItem = dataList[i]; |
||||
|
let flag = true; |
||||
|
for (let j = 0; j < checkList.length; j++) { |
||||
|
let data = checkList[j]; |
||||
|
if (data.id === dataItem.id) { |
||||
|
flag = false; |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
if (flag) { |
||||
|
checkList.push(dataItem); |
||||
|
} |
||||
|
} |
||||
|
}else{ |
||||
|
dataList = table.getData('currentTableId'); |
||||
|
for (let i = 0; i < dataList.length; i++) { |
||||
|
let dataItem = dataList[i]; |
||||
|
for (let j = 0; j < checkList.length; j++) { |
||||
|
let data = checkList[j]; |
||||
|
if (data.id === dataItem.id) { |
||||
|
checkList.splice(j, j + 1); |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,446 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<title>layui</title> |
||||
|
<meta name="renderer" content="webkit"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
||||
|
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
||||
|
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<div class="layuimini-container"> |
||||
|
<div class="layuimini-main"> |
||||
|
<script id="toolbarDemo" type="text/html"> |
||||
|
<div class="layui-btn-container"> |
||||
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add">添加</button> |
||||
|
<button class="layui-btn layui-btn-danger layui-btn-sm data-delete-btn" lay-event="delete">删除</button> |
||||
|
</div> |
||||
|
</script> |
||||
|
<fieldset class="table-search-fieldset"> |
||||
|
<legend>搜索信息</legend> |
||||
|
<div style="margin: 10px 10px 10px 10px"> |
||||
|
<form class="layui-form layui-form-pane" action=""> |
||||
|
<div class="layui-form-item"> |
||||
|
|
||||
|
|
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label">创建日期</label> |
||||
|
<div class="layui-input-block"> |
||||
|
<input type="text" name="createTime" id="date" placeholder="请选择创建日期" |
||||
|
autocomplete="off" class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label">套餐名称</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" name="name" autocomplete="off" class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label">套餐编码</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" name="code" autocomplete="off" class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label">状态</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<select id="state" name="state"> |
||||
|
<option value="" selected>请选择状态</option> |
||||
|
<option value="1">启用</option> |
||||
|
<option value="2">禁用</option> |
||||
|
</select> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="layui-inline"> |
||||
|
<button type="submit" class="layui-btn layui-btn-primary" lay-submit |
||||
|
lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索 |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
</fieldset> |
||||
|
|
||||
|
|
||||
|
<!-- 状态展示--> |
||||
|
<script type="text/html" id="switchTpl"> |
||||
|
<input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" |
||||
|
lay-filter="changeState" {{ d.state== 1 ? 'checked' : '' }} > |
||||
|
</script> |
||||
|
|
||||
|
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
<script type="text/html" id="currentTableBar"> |
||||
|
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">详情</a> |
||||
|
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a> |
||||
|
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}" |
||||
|
lay-event="realDelete">彻底删除</a> |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
||||
|
<script> |
||||
|
// 用于查看并修改套餐中的物料信息 |
||||
|
function checkSeeGroup(){}; |
||||
|
layui.use(['form', 'table', 'laydate'], function () { |
||||
|
var $ = layui.jquery, |
||||
|
form = layui.form, |
||||
|
table = layui.table, |
||||
|
laydate = layui.laydate; |
||||
|
|
||||
|
//日期 |
||||
|
laydate.render({ |
||||
|
elem: '#date' |
||||
|
}); |
||||
|
|
||||
|
// 加载表格 |
||||
|
table.render({ |
||||
|
elem: "#currentTableId", |
||||
|
url: '/group/findAllGroup', |
||||
|
parseData: function (res) { //res 即为原始返回的数据 |
||||
|
return { |
||||
|
"status": res.status, //解析接口状态 |
||||
|
"message": res.statusInfo.message, //解析提示文本 |
||||
|
"count": res.count, //解析数据长度 |
||||
|
"data": res.data //解析数据列表 |
||||
|
}; |
||||
|
}, |
||||
|
request: { |
||||
|
pageName: 'page', //页码的参数名称,默认:page |
||||
|
limitName: 'size' //每页数据量的参数名,默认:limit |
||||
|
}, |
||||
|
response: { |
||||
|
statusName: 'status' //规定数据状态的字段名称,默认:code |
||||
|
, statusCode: 200 //规定成功的状态码,默认:0 |
||||
|
, msgName: 'message' //规定状态信息的字段名称,默认:msg |
||||
|
, countName: 'count' //规定数据总数的字段名称,默认:count |
||||
|
, dataName: 'data' //规定数据列表的字段名称,默认:data |
||||
|
}, |
||||
|
toolbar: '#toolbarDemo', |
||||
|
cols: [ |
||||
|
[ |
||||
|
{type: "checkbox", width: 50}, |
||||
|
{field: 'gname', width: 150, title: '套餐名称',edit:'gname'}, |
||||
|
{field: 'code', width: 150, title: '套餐编码'}, |
||||
|
{title: '拥有物料', width: 700, align: "center"}, |
||||
|
{field: 'quantity', width: 200, title: '数量'}, |
||||
|
{field: 'createTime', width: 200, title: '创建时间'}, |
||||
|
{field: 'state', title: '状态', minWidth: 80, templet: '#switchTpl'}, |
||||
|
{title: '操作', minWidth: 200, toolbar: '#currentTableBar', align: "center"} |
||||
|
|
||||
|
|
||||
|
] |
||||
|
], |
||||
|
limits: [10, 15, 20, 25, 50, 100], |
||||
|
limit: 10, |
||||
|
page: true, |
||||
|
skin: 'line', |
||||
|
done: function (res, curr, count) { |
||||
|
$.each(res['data'], function (i, j) { |
||||
|
let materialSimple = j["materialSimple"]; |
||||
|
let gid = j["id"]; |
||||
|
let keys = Object.keys(materialSimple); |
||||
|
var materialItem = $("[lay-id='currentTableId'] tr:eq(" + (i+1) + ")").children()[3]; |
||||
|
var aItem = materialItem.childNodes[0]; |
||||
|
for (let k = 0; k < keys.length; k++) { |
||||
|
$(aItem).append('<button id='+ gid+' class="layui-btn layui-btn-primary layui-btn-xs" onclick="checkSeeGroup(this)" value='+materialSimple[keys[k]]+'>'+keys[k]+'</button>') |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// 监听搜索操作 |
||||
|
form.on('submit(data-search-btn)', function (data) { |
||||
|
var req = {}; |
||||
|
data = data.field; |
||||
|
if (data.code !== '') { |
||||
|
req.code = data.code; |
||||
|
} |
||||
|
if(data.createTime !== ''){ |
||||
|
req.createTime = data.createTime; |
||||
|
} |
||||
|
if(data.state !== ''){ |
||||
|
req.state = data.state; |
||||
|
} |
||||
|
if(data.name !== ''){ |
||||
|
req.gname = data.name; |
||||
|
} |
||||
|
|
||||
|
//执行搜索重载 |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findAllGroup', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
where: req |
||||
|
}, 'data'); |
||||
|
return false; |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
// 用于监视表格编辑 |
||||
|
table.on('edit(currentTableFilter)', function(obj){ //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值" |
||||
|
|
||||
|
let gid = obj.data.id; |
||||
|
let gname = obj.value; |
||||
|
let req = {}; |
||||
|
req.id = gid; |
||||
|
req.gname = gname; |
||||
|
$.ajax({ |
||||
|
url:'/group/editGroupInfo', |
||||
|
dataType:"json", |
||||
|
type:"post", |
||||
|
data:JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (data) { |
||||
|
if (data.status >= 300) { |
||||
|
layer.msg(data.statusInfo.message);//失败的表情 |
||||
|
|
||||
|
} else { |
||||
|
//执行搜索重载 |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findAllGroup', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
}, 'data'); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
// 用于监听操作 |
||||
|
table.on('tool(currentTableFilter)', function (obj) { |
||||
|
let data = obj.data; |
||||
|
|
||||
|
if (obj.event === 'detail') { |
||||
|
var index = layer.open({ |
||||
|
title: '套餐详情', |
||||
|
type: 2, |
||||
|
shade: 0.2, |
||||
|
maxmin: true, |
||||
|
shadeClose: true, |
||||
|
area: ['100%', '100%'], |
||||
|
content: '/group_edit?id='+data.id, |
||||
|
}); |
||||
|
$(window).on("resize", function () { |
||||
|
layer.full(index); |
||||
|
}); |
||||
|
} |
||||
|
else if (obj.event === 'delete') { |
||||
|
var req = {}; |
||||
|
req.id = data.id; |
||||
|
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) { |
||||
|
$.ajax({ |
||||
|
url:"/group/delGroup", |
||||
|
type:"post", |
||||
|
dataType:"json", |
||||
|
data:JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (data) { |
||||
|
layer.close(this.layerIndex); |
||||
|
if (data.status >= 300) { |
||||
|
layer.msg(data.statusInfo.message);//失败的表情 |
||||
|
|
||||
|
} else { |
||||
|
layer.msg("删除成功", { |
||||
|
icon: 6,//成功的表情 |
||||
|
time: 500 //1秒关闭(如果不配置,默认是3秒) |
||||
|
}); |
||||
|
//执行搜索重载 |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findAllGroup', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
}, 'data'); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}); |
||||
|
} |
||||
|
else if (obj.event === 'realDelete') { //彻底删除 |
||||
|
layer.confirm('该操作将无法挽回', {icon: 2, title: '提示'}, function (index) { |
||||
|
var req = {}; |
||||
|
req.id = data.id; |
||||
|
$.ajax({ |
||||
|
url:"/group/realDelGroup", |
||||
|
type:"post", |
||||
|
dataType:"json", |
||||
|
data:JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (data) { |
||||
|
layer.close(this.layerIndex); |
||||
|
if (data.status >= 300) { |
||||
|
layer.msg(data.statusInfo.message);//失败的表情 |
||||
|
|
||||
|
} else { |
||||
|
layer.msg("删除成功", { |
||||
|
icon: 6,//成功的表情 |
||||
|
time: 500 //1秒关闭(如果不配置,默认是3秒) |
||||
|
}); |
||||
|
//执行搜索重载 |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findAllGroup', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
}, 'data'); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
//用于查看并修改套餐中的物料信息 |
||||
|
checkSeeGroup = function (obj) { |
||||
|
let gid = obj.id; |
||||
|
let mid = obj.value; |
||||
|
layer.open({ |
||||
|
type: 2, |
||||
|
title: "套餐明细", |
||||
|
skin: 'layui-layer-rim', |
||||
|
maxmin: true, |
||||
|
shadeClose: true, //点击遮罩关闭层 |
||||
|
area: ['100%', '100%'], |
||||
|
move: '.layui-layer-title', |
||||
|
fixed: false, |
||||
|
content: '/materialForGroup?mid='+mid+'&gid='+gid, |
||||
|
end:function () { |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findAllGroup', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
}, 'data'); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
//监听状态操作 |
||||
|
form.on('switch(changeState)', function (obj) { |
||||
|
var req = new Map; |
||||
|
if (obj.elem.checked) { |
||||
|
req["state"] = 1 |
||||
|
} |
||||
|
req["id"] = this.value; |
||||
|
$.ajax({ |
||||
|
url: "/group/changeGroupState", |
||||
|
type: 'post', |
||||
|
dataType: 'json', |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
data: JSON.stringify(req), |
||||
|
beforeSend: function () { |
||||
|
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
||||
|
}, |
||||
|
success: function (data) { |
||||
|
layer.close(this.layerIndex); |
||||
|
if (data.status >= 300) { |
||||
|
layer.msg(data.statusInfo.message);//失败的表情 |
||||
|
} else { |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findAllGroup', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
}, 'data'); |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* toolbar监听事件 |
||||
|
*/ |
||||
|
table.on('toolbar(currentTableFilter)', function (obj) { |
||||
|
if (obj.event === 'add') { // 监听添加操作 |
||||
|
layer.open({ |
||||
|
type: 2, |
||||
|
title: "创建套餐", |
||||
|
skin: 'layui-layer-rim', |
||||
|
maxmin: true, |
||||
|
shadeClose: true, //点击遮罩关闭层 |
||||
|
area: ['100%', '100%'], |
||||
|
move: '.layui-layer-title', |
||||
|
fixed: false, |
||||
|
content: '/group_add', |
||||
|
end:function () { |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findAllGroup', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
}, 'data'); |
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
else if(obj.event === 'delete') { |
||||
|
var checkStatus = table.checkStatus('currentTableId') |
||||
|
, data = checkStatus.data; |
||||
|
var req = {}; |
||||
|
req.ids = []; |
||||
|
for (i = 0, len = data.length; i < len; i++) { |
||||
|
req.ids[i] = data[i].id; |
||||
|
} |
||||
|
if (req.ids.length > 0) { |
||||
|
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) { |
||||
|
$.ajax({ |
||||
|
url:"/group/delGroup", |
||||
|
type:"post", |
||||
|
dataType:"json", |
||||
|
data:JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (data) { |
||||
|
layer.close(this.layerIndex); |
||||
|
if (data.status >= 300) { |
||||
|
layer.msg(data.statusInfo.message);//失败的表情 |
||||
|
|
||||
|
} else { |
||||
|
layer.msg("删除成功", { |
||||
|
icon: 6,//成功的表情 |
||||
|
time: 500 //1秒关闭(如果不配置,默认是3秒) |
||||
|
}); |
||||
|
//执行搜索重载 |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findAllGroup', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
}, 'data'); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
}else{ |
||||
|
layer.msg("未选中记录,请确认!"); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,192 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<title>layui</title> |
||||
|
<meta name="renderer" content="webkit"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
||||
|
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
||||
|
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<div class="layuimini-container"> |
||||
|
<div class="layuimini-main"> |
||||
|
<input id="id" th:value="${id}" style="display:none;"> |
||||
|
<script id="toolbarDemo" type="text/html"> |
||||
|
<div class="layui-btn-container"> |
||||
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add">添加</button> |
||||
|
</div> |
||||
|
</script> |
||||
|
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table> |
||||
|
</div> |
||||
|
</div> |
||||
|
<script type="text/html" id="currentTableBar"> |
||||
|
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">详情</a> |
||||
|
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a> |
||||
|
</script> |
||||
|
|
||||
|
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
||||
|
<script> |
||||
|
// 用于通过编码查询物料 |
||||
|
function selectMaterialByCode(obj) { |
||||
|
} |
||||
|
// 用于点击搜索按钮 |
||||
|
function selectMaterial(obj) { |
||||
|
} |
||||
|
layui.use(['form', 'table'], function () { |
||||
|
var $ = layui.jquery, |
||||
|
form = layui.form, |
||||
|
table = layui.table; |
||||
|
// 加载表格 |
||||
|
|
||||
|
let id = $("#id").val(); |
||||
|
table.render({ |
||||
|
elem: "#currentTableId", |
||||
|
url: '/group/findGroupInfo', |
||||
|
parseData: function (res) { //res 即为原始返回的数据 |
||||
|
return { |
||||
|
"status": res.status, //解析接口状态 |
||||
|
"message": res.statusInfo.message, //解析提示文本 |
||||
|
"count": res.count, //解析数据长度 |
||||
|
"data": res.data //解析数据列表 |
||||
|
}; |
||||
|
}, |
||||
|
request: { |
||||
|
pageName: 'page', //页码的参数名称,默认:page |
||||
|
limitName: 'size' //每页数据量的参数名,默认:limit |
||||
|
}, |
||||
|
where: {gid:id}, |
||||
|
response: { |
||||
|
statusName: 'status' //规定数据状态的字段名称,默认:code |
||||
|
, statusCode: 200 //规定成功的状态码,默认:0 |
||||
|
, msgName: 'message' //规定状态信息的字段名称,默认:msg |
||||
|
, countName: 'count' //规定数据总数的字段名称,默认:count |
||||
|
, dataName: 'data' //规定数据列表的字段名称,默认:data |
||||
|
}, |
||||
|
toolbar: '#toolbarDemo', |
||||
|
cols: [ |
||||
|
[ |
||||
|
{type: "checkbox", width: 50}, |
||||
|
{field: 'mcode', width: 150, title: '存货编码', sort: true}, |
||||
|
{field: 'mname', width: 120, title: '物料名称', sort: false}, |
||||
|
{field: 'version', width: 200, title: '规格型号', sort: false}, |
||||
|
{field: 'quantity', width: 200, title: '数量'}, |
||||
|
{field: 'tname', width: 150, title: '物料种类'}, |
||||
|
{field: 'texture', width: 100, title: '材质'}, |
||||
|
{field: 'unit', width: 150, title: '计量单位'}, |
||||
|
{field: 'brand', width: 150, title: '品牌'}, |
||||
|
{field: 'shelfLife', width: 150, title: '保质期'}, |
||||
|
{field: 'productionPlace', width: 150, title: '产地'}, |
||||
|
{title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"} |
||||
|
|
||||
|
|
||||
|
] |
||||
|
], |
||||
|
limits: [10, 15, 20, 25, 50, 100], |
||||
|
limit: 10, |
||||
|
page: true, |
||||
|
skin: 'line' |
||||
|
}); |
||||
|
|
||||
|
// 用于监听操作 |
||||
|
table.on('tool(currentTableFilter)', function (obj) { |
||||
|
let data = obj.data; |
||||
|
|
||||
|
if (obj.event === 'detail') { |
||||
|
layer.open({ |
||||
|
type: 2, |
||||
|
title: "物料明细", |
||||
|
skin: 'layui-layer-rim', |
||||
|
maxmin: true, |
||||
|
shadeClose: true, //点击遮罩关闭层 |
||||
|
area: ['100%', '100%'], |
||||
|
move: '.layui-layer-title', |
||||
|
fixed: false, |
||||
|
content: '/materialForGroup?mid='+data.mid+'&gid='+id, |
||||
|
end:function () { |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findGroupInfo', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
where:{ |
||||
|
gid:id |
||||
|
} |
||||
|
}, 'data'); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
else if (obj.event === 'delete') { |
||||
|
var req = {}; |
||||
|
req.id = data.id; |
||||
|
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) { |
||||
|
$.ajax({ |
||||
|
url:"/group/delMaterialForGroup", |
||||
|
type:"post", |
||||
|
dataType:"json", |
||||
|
data:JSON.stringify(req), |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (data) { |
||||
|
layer.close(this.layerIndex); |
||||
|
if (data.status >= 300) { |
||||
|
layer.msg(data.statusInfo.message);//失败的表情 |
||||
|
|
||||
|
} else { |
||||
|
layer.msg("删除成功", { |
||||
|
icon: 6,//成功的表情 |
||||
|
time: 500 //1秒关闭(如果不配置,默认是3秒) |
||||
|
}); |
||||
|
//执行搜索重载 |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findGroupInfo', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
where:{ |
||||
|
gid:id |
||||
|
} |
||||
|
}, 'data'); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
/** |
||||
|
* toolbar监听事件 |
||||
|
*/ |
||||
|
table.on('toolbar(currentTableFilter)', function (obj) { |
||||
|
if (obj.event === 'add') { // 监听添加操作 |
||||
|
layer.open({ |
||||
|
type: 2, |
||||
|
title: "物料明细", |
||||
|
skin: 'layui-layer-rim', |
||||
|
maxmin: true, |
||||
|
shadeClose: true, //点击遮罩关闭层 |
||||
|
area: ['100%', '100%'], |
||||
|
move: '.layui-layer-title', |
||||
|
fixed: false, |
||||
|
content: '/group_add?gid='+id, |
||||
|
end:function () { |
||||
|
table.reload('currentTableId', { |
||||
|
url: '/group/findGroupInfo', |
||||
|
page: { |
||||
|
curr: 1 |
||||
|
}, |
||||
|
where:{ |
||||
|
gid:id |
||||
|
} |
||||
|
}, 'data'); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
|
||||
|
}) |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,148 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<title>layui</title> |
||||
|
<meta name="renderer" content="webkit"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
||||
|
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
||||
|
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<form class="layui-form layui-form-pane" action=""> |
||||
|
<input type="text" id="id" name="id" th:value="${record.getId()}" style="display:none;"> |
||||
|
|
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">套餐编码</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" th:value="${record.getGcode()}" name="gcode" required lay-verify="required" readonly |
||||
|
autocomplete="off" class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料编号</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input id="mcode" type="text" th:value="${record.getMcode()}" name="mcode" required lay-verify="required" autocomplete="off" |
||||
|
class="layui-input" onblur="selectMaterialByCode(this)" readonly="readonly"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料名称</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" th:value="${record.getMname()}" name="mname" required lay-verify="required" readonly |
||||
|
autocomplete="off" class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">规格型号</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" th:value="${record.getVersion()}" name="version" autocomplete="off" readonly |
||||
|
class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料数量</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" th:value="${record.getQuantity()}" name="quantity" autocomplete="off" |
||||
|
class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">品牌:</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" placeholder="请填写物料品牌" class="layui-input" th:value="${record.getBrand()}" readonly |
||||
|
name="brand"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">物料类型</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" class="layui-input" id="openSonByMateralType" readonly |
||||
|
th:value="${record.getTname()}" |
||||
|
lay-verify="required"/> |
||||
|
<input type="text" id="materialTypeId" th:value="${record.getMtid()}" |
||||
|
name="materialTypeId" class="layui-input" style="display: none" lay-verify="required"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">材质</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" th:value="${record.getTexture()}" name="texture" autocomplete="off" readonly |
||||
|
class="layui-input"> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">计量单位</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" th:value="${record.getUnit()}" name="unit" required autocomplete="off" readonly |
||||
|
class="layui-input"> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
|
||||
|
<div class="layui-form-item"> |
||||
|
<label class="layui-form-label">备注:</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<input type="text" placeholder="请填写备注" class="layui-input" th:value="${record.getRemark()}" |
||||
|
name="remark" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="layui-form-item"> |
||||
|
<div class="layui-input-block"> |
||||
|
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button> |
||||
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</form> |
||||
|
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
||||
|
<script> |
||||
|
// 用于通过编码查询物料 |
||||
|
function selectMaterialByCode(obj) { |
||||
|
} |
||||
|
// 用于点击搜索按钮 |
||||
|
function selectMaterial(obj) { |
||||
|
} |
||||
|
layui.use(['form'], function () { |
||||
|
var form = layui.form, $ = layui.$; |
||||
|
let id = $("#id").val(); |
||||
|
form.on('submit(formDemo)', function (data) { |
||||
|
data = data.field; |
||||
|
data.id = id; |
||||
|
$.ajax({ |
||||
|
url: "/group/materialForGroupEdit", |
||||
|
type: 'post', |
||||
|
dataType: 'json', |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
data: JSON.stringify(data), |
||||
|
beforeSend: function () { |
||||
|
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
||||
|
}, |
||||
|
success: function (data) { |
||||
|
layer.close(this.layerIndex); |
||||
|
if (data.status >= 300) { |
||||
|
layer.msg(data.statusInfo.message);//失败的表情 |
||||
|
return; |
||||
|
} else { |
||||
|
layer.msg("修改成功", { |
||||
|
icon: 6,//成功的表情 |
||||
|
time: 500 //1秒关闭(如果不配置,默认是3秒) |
||||
|
}, function () { |
||||
|
var index = parent.layer.getFrameIndex(window.name); |
||||
|
parent.layer.close(index);//关闭当前页 |
||||
|
window.location = '/group_out' |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
return false; |
||||
|
}); |
||||
|
|
||||
|
}) |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,85 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<title>layui</title> |
||||
|
<meta name="renderer" content="webkit"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
||||
|
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
||||
|
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<div id="test2" class="demo-tree"></div> |
||||
|
<input id="gname" name="gname" th:value="${gname}" style="display: none"> |
||||
|
<input id="clickObj" name="clickObj" th:value="${clickObj}" style="display: none"> |
||||
|
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
||||
|
<script> |
||||
|
layui.use(['form', 'layer', 'dropdown', 'tree'], function () { |
||||
|
var $ = layui.jquery, |
||||
|
tree = layui.tree; |
||||
|
var gname = $("#gname").val(); |
||||
|
var clickObj = $("#clickObj").val(); |
||||
|
|
||||
|
|
||||
|
|
||||
|
// 用于暂存当前查询结果 |
||||
|
var tempData = []; |
||||
|
var req = {}; |
||||
|
req.gname = gname; |
||||
|
var test = tree.render({ |
||||
|
elem: '#test2' |
||||
|
, data: [] |
||||
|
, click: function (obj) { |
||||
|
let data = obj.data; |
||||
|
if(data.children === undefined){ |
||||
|
return false; |
||||
|
}else{ |
||||
|
var windowParent = $("#"+clickObj,window.parent.document)[0]; |
||||
|
var parentId = windowParent.id; |
||||
|
// 获取对应元素 |
||||
|
var pid = Number(windowParent.id.split("cardItemForGroup")[1]); |
||||
|
|
||||
|
// 获取当前卡片中的套餐名称等 |
||||
|
let gnameParent = windowParent.childNodes[5].childNodes[3]; |
||||
|
|
||||
|
// 套餐编码 |
||||
|
let gcodeItem = windowParent.childNodes[7].childNodes[3].childNodes[1].childNodes[1]; |
||||
|
|
||||
|
|
||||
|
// gid |
||||
|
let gidItem = gnameParent.childNodes[3]; |
||||
|
|
||||
|
// gname |
||||
|
let gnameItem = gnameParent.childNodes[1].childNodes[1]; |
||||
|
|
||||
|
gnameItem.value = data.title; |
||||
|
gidItem.value = data.id; |
||||
|
var index = parent.layer.getFrameIndex(window.name); |
||||
|
parent.layer.close(index); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
$.ajax({ |
||||
|
url: "/group/treeMenus", |
||||
|
data: JSON.stringify(req), |
||||
|
type: 'post', |
||||
|
dataType: 'json', |
||||
|
contentType: "application/json;charset=utf-8", |
||||
|
success: function (d) { |
||||
|
tempData = d.data; |
||||
|
test.reload({ |
||||
|
data: tempData |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
|
||||
|
}) |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,218 @@ |
|||||
|
package com.dreamchaser.depository_manage; |
||||
|
|
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.dreamchaser.depository_manage.entity.Depository; |
||||
|
import com.dreamchaser.depository_manage.entity.Group; |
||||
|
import com.dreamchaser.depository_manage.entity.GroupInfo; |
||||
|
import com.dreamchaser.depository_manage.entity.UserByPort; |
||||
|
import com.dreamchaser.depository_manage.mapper.GroupMapper; |
||||
|
import com.dreamchaser.depository_manage.pojo.RoleAndDepository; |
||||
|
import org.junit.Test; |
||||
|
import org.junit.runner.RunWith; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
|
||||
|
import java.util.*; |
||||
|
import java.util.concurrent.*; |
||||
|
|
||||
|
@SpringBootTest |
||||
|
@RunWith(SpringRunner.class) |
||||
|
public class TestForGroupTree { |
||||
|
|
||||
|
@Autowired |
||||
|
GroupMapper groupMapper; |
||||
|
|
||||
|
@Test |
||||
|
public void Test(){ |
||||
|
List<Object> list = InitTreeMenus(""); |
||||
|
System.out.println(JSONObject.toJSONString(list)); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用于构造套餐树 |
||||
|
* @param gname |
||||
|
* @return |
||||
|
*/ |
||||
|
public List<Object> InitTreeMenus(String gname) { |
||||
|
// 定义结果集
|
||||
|
List<Object> list = new ArrayList<>(); |
||||
|
|
||||
|
// 获取所有使用中的套餐
|
||||
|
List<Group> allGroupOnly = groupMapper.findAllGroupOnly(gname); |
||||
|
|
||||
|
// 获取当前总数
|
||||
|
Integer totalVal = allGroupOnly.size(); |
||||
|
|
||||
|
// 定义分页数量
|
||||
|
double size = 10.0; |
||||
|
|
||||
|
// 定义线程数
|
||||
|
Integer threadSize = (int) Math.ceil(totalVal / size); |
||||
|
|
||||
|
// 定义开启线程数目
|
||||
|
Integer openThreadSize = 0; |
||||
|
// 开启对应数量的线程
|
||||
|
ExecutorService exs = Executors.newFixedThreadPool(threadSize); |
||||
|
// 线程结果集
|
||||
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
||||
|
|
||||
|
// 1.定义CompletionService
|
||||
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
||||
|
|
||||
|
|
||||
|
// 定义套餐id列表
|
||||
|
List<Integer> groupIdList = new ArrayList<>(); |
||||
|
|
||||
|
|
||||
|
for (int i = 0; i < allGroupOnly.size(); i++) { |
||||
|
Group group = allGroupOnly.get(i); |
||||
|
if (((i + 1) % 10) == 0) { // 如果有10个开启线程进行处理
|
||||
|
groupIdList.add(group.getId()); |
||||
|
Future<Object> future = completionService.submit(new Task(groupIdList)); |
||||
|
openThreadSize++; |
||||
|
futureList.add(future); // 添加到结果集
|
||||
|
groupIdList = new ArrayList<>(); // 情况列表
|
||||
|
} else { |
||||
|
// 添加id到列表中
|
||||
|
groupIdList.add(group.getId()); |
||||
|
} |
||||
|
} |
||||
|
if (groupIdList.size() > 0) { |
||||
|
// 如果有剩余,开启线程进行处理
|
||||
|
Future<Object> future = completionService.submit(new Task(groupIdList)); |
||||
|
futureList.add(future); |
||||
|
openThreadSize++; |
||||
|
} |
||||
|
|
||||
|
for (int i = 0; i < openThreadSize; i++) { |
||||
|
Object result = null; |
||||
|
try { |
||||
|
result = completionService.take().get(); |
||||
|
} catch (InterruptedException | ExecutionException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
list.addAll((Collection<?>) result); |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
// 用于执行线程任务
|
||||
|
class Task implements Callable<Object> { |
||||
|
|
||||
|
// 套餐id列表
|
||||
|
List<Integer> groupIdList; |
||||
|
|
||||
|
|
||||
|
public Task(List<Integer> groupIdList){ |
||||
|
this.groupIdList = groupIdList; |
||||
|
|
||||
|
} |
||||
|
@Override |
||||
|
public Object call() throws Exception { |
||||
|
/** |
||||
|
* 获取当前套餐id对应的套餐 |
||||
|
*/ |
||||
|
List<Group> groupByGids = groupMapper.findGroupByGids(groupIdList); |
||||
|
|
||||
|
// 开启对应数量的线程
|
||||
|
ExecutorService exs = Executors.newFixedThreadPool(groupByGids.size()); |
||||
|
// 线程结果集
|
||||
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
||||
|
|
||||
|
// 1.定义CompletionService
|
||||
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
||||
|
|
||||
|
|
||||
|
// 定义结果集
|
||||
|
List<Object> list = new ArrayList<>(); |
||||
|
|
||||
|
for (int i = 0; i < groupByGids.size(); i++) { |
||||
|
// 获取套餐具体信息
|
||||
|
Group group = groupByGids.get(i); |
||||
|
// 开启线程
|
||||
|
Future<Object> submit = completionService.submit(new TaskForGroupInfo(group)); |
||||
|
futureList.add(submit); |
||||
|
} |
||||
|
|
||||
|
for (int i = 0; i < groupByGids.size(); i++) { |
||||
|
Object result = null; |
||||
|
try { |
||||
|
result = completionService.take().get(); |
||||
|
} catch (InterruptedException | ExecutionException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
list.add(result); |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class TaskForGroupInfo implements Callable<Object>{ |
||||
|
|
||||
|
Group group; |
||||
|
TaskForGroupInfo(Group group){ |
||||
|
this.group = group; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Object call() throws Exception |
||||
|
{ |
||||
|
// 用于获取当前套餐的具体信息
|
||||
|
Map<String,Object> paramForGroup = new HashMap<>(); |
||||
|
paramForGroup.put("gid",group.getId()); |
||||
|
// 获取当前套餐的具体信息
|
||||
|
List<GroupInfo> groupByCondition = groupMapper.findGroupByCondition(paramForGroup); |
||||
|
// 定义子类结果集
|
||||
|
List<Object> resultForChildren = new ArrayList<>(); |
||||
|
for (GroupInfo groupInfo : groupByCondition) { |
||||
|
Map<String, Object> stringObjectMap = InitTreeMenus(groupInfo); |
||||
|
resultForChildren.add(stringObjectMap); |
||||
|
} |
||||
|
Map<String, Object> stringObjectMap = InitTreeMenus(group, resultForChildren); |
||||
|
return stringObjectMap; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 构造树形组件数据模板 |
||||
|
* @param g 套餐 |
||||
|
* @param children 子类 |
||||
|
* @return |
||||
|
*/ |
||||
|
public Map<String, Object> InitTreeMenus(Group g, List<Object> children) { |
||||
|
if (g != null) { |
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
map.put("title", g.getGname()); |
||||
|
map.put("id", g.getId()); |
||||
|
map.put("children", children); |
||||
|
return map; |
||||
|
} else { |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 构造树形组件的子组件模板 |
||||
|
* @param g 套餐详细信息 |
||||
|
* @return |
||||
|
*/ |
||||
|
public Map<String, Object> InitTreeMenus(GroupInfo g) { |
||||
|
if (g != null) { |
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
map.put("title", g.getMname()); |
||||
|
map.put("id", g.getId()); |
||||
|
return map; |
||||
|
} else { |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
package com.dreamchaser.depository_manage; |
||||
|
|
||||
|
import org.junit.Test; |
||||
|
import org.junit.runner.RunWith; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 专用于测试琐碎实例 |
||||
|
*/ |
||||
|
@SpringBootTest |
||||
|
@RunWith(SpringRunner.class) |
||||
|
public class TestForOther { |
||||
|
@Test |
||||
|
public void Test(){ |
||||
|
String code = "wms-g-0001"; |
||||
|
System.out.println(code.contains("wms-g-")); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue