zds
1 month ago
17 changed files with 25 additions and 1486 deletions
@ -1,134 +0,0 @@ |
|||
package org.nl.wms.basedata.master.service; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.wms.basedata.master.service.dto.ClassstandardDto; |
|||
import org.springframework.data.domain.Pageable; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description 服务接口 |
|||
* @date 2021-12-07 |
|||
**/ |
|||
public interface ClassstandardService { |
|||
|
|||
/** |
|||
* 查询数据分页 |
|||
* |
|||
* @param whereJson 条件 |
|||
* @param page 分页参数 |
|||
* @return Map<String, Object> |
|||
*/ |
|||
Map<String, Object> queryAll(Map whereJson, Pageable page); |
|||
|
|||
/** |
|||
* 查询所有数据不分页 |
|||
* |
|||
* @param whereJson 条件参数 |
|||
* @return List<ClassstandardDto> |
|||
*/ |
|||
List<ClassstandardDto> queryAll(Map whereJson); |
|||
|
|||
/** |
|||
* 根据ID查询 |
|||
* |
|||
* @param class_id ID |
|||
* @return Classstandard |
|||
*/ |
|||
ClassstandardDto findById(String class_id); |
|||
|
|||
/** |
|||
* 根据编码查询 |
|||
* |
|||
* @param code code |
|||
* @return Classstandard |
|||
*/ |
|||
ClassstandardDto findByCode(String code); |
|||
|
|||
|
|||
/** |
|||
* 创建 |
|||
* |
|||
* @param dto / |
|||
*/ |
|||
void create(ClassstandardDto dto); |
|||
|
|||
/** |
|||
* 编辑 |
|||
* |
|||
* @param dto / |
|||
*/ |
|||
void update(ClassstandardDto dto); |
|||
|
|||
/** |
|||
* 多选删除 |
|||
* |
|||
* @param ids / |
|||
*/ |
|||
void deleteAll(Long[] ids); |
|||
|
|||
JSONObject loadClass(Map whereJson); |
|||
|
|||
JSONArray getSuperior(JSONObject jo, JSONArray ja); |
|||
|
|||
JSONObject buildTree(JSONArray ja); |
|||
|
|||
@SuppressWarnings("unchecked") |
|||
JSONObject queryClassBycode(Map whereJson); |
|||
|
|||
JSONObject queryClassById(Map whereJson); |
|||
|
|||
JSONObject queryClassTable(Map whereJson, Pageable page); |
|||
|
|||
/** |
|||
* @param type_id 类型标识 |
|||
* @param level 级别 |
|||
* @return |
|||
*/ |
|||
JSONObject getType(String type_id, int level); |
|||
|
|||
/** |
|||
* 获取当前节点的所有子类节点集合数据 |
|||
* |
|||
* @param class_id |
|||
* @return |
|||
*/ |
|||
Set<String> getChildIdSet(String class_id); |
|||
|
|||
/** |
|||
* 获取查询条件的所有子节点集合 |
|||
* |
|||
* @param class_idStr |
|||
* @return |
|||
*/ |
|||
Set<String> getAllChildIdSet(String class_idStr); |
|||
|
|||
/** |
|||
* 获取当前节点的所有子类节点集合串,用于拼接SQL(in) |
|||
* |
|||
* @param class_id |
|||
* @return |
|||
*/ |
|||
String getChildIdStr(String class_id); |
|||
|
|||
/** |
|||
* 获取所有节点的子节点的ID串 |
|||
* |
|||
* @param class_idStr |
|||
* @return |
|||
*/ |
|||
String getAllChildIdStr(String class_idStr); |
|||
|
|||
/** |
|||
* 获取分类名称下拉框 |
|||
* |
|||
* @return |
|||
*/ |
|||
JSONArray getClassName(); |
|||
|
|||
JSONObject getCasClass(JSONObject jo); |
|||
} |
@ -1,61 +0,0 @@ |
|||
package org.nl.wms.basedata.master.service.dto; |
|||
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
|||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description / |
|||
* @date 2021-12-07 |
|||
**/ |
|||
@Data |
|||
public class ClassstandardDto implements Serializable { |
|||
|
|||
/** |
|||
* 防止精度丢失 |
|||
*/ |
|||
@JsonSerialize(using = ToStringSerializer.class) |
|||
private Long class_id; |
|||
|
|||
private String path_code; |
|||
|
|||
private String class_code; |
|||
|
|||
private String long_class_code; |
|||
|
|||
private String class_name; |
|||
|
|||
private String class_desc; |
|||
|
|||
private Long parent_class_id; |
|||
|
|||
private String is_leaf; |
|||
|
|||
private BigDecimal sub_count; |
|||
|
|||
private String is_modify; |
|||
|
|||
private String is_delete; |
|||
|
|||
private String class_level; |
|||
|
|||
private String ext_id; |
|||
|
|||
private String ext_parent_id; |
|||
|
|||
private String create_id; |
|||
|
|||
private String create_name; |
|||
|
|||
private String create_time; |
|||
|
|||
private String update_optid; |
|||
|
|||
private String update_optname; |
|||
|
|||
private String update_time; |
|||
} |
@ -1,600 +0,0 @@ |
|||
package org.nl.wms.basedata.master.service.impl; |
|||
|
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.IdUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.db.Db; |
|||
import cn.hutool.db.Entity; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.utils.SecurityUtils; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.wql.WQL; |
|||
import org.nl.modules.wql.core.bean.ResultBean; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.modules.wql.util.SpringContextHolder; |
|||
import org.nl.modules.wql.util.WqlUtil; |
|||
import org.nl.wms.basedata.master.service.ClassstandardService; |
|||
import org.nl.wms.basedata.master.service.dto.ClassstandardDto; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.math.BigDecimal; |
|||
import java.sql.SQLException; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description 服务实现 |
|||
* @date 2021-12-07 |
|||
**/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class ClassstandardServiceImpl implements ClassstandardService { |
|||
|
|||
@Override |
|||
public Map<String, Object> queryAll(Map whereJson, Pageable page) { |
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
String class_code = (String) whereJson.get("class_code"); |
|||
String where = ""; |
|||
if (!StrUtil.isEmpty(class_code)) { |
|||
where = "AND class_code = '" + class_code + "'"; |
|||
} |
|||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "(parent_class_id is null OR parent_class_id = '0') AND is_delete = '0'" + where + "", "update_time desc"); |
|||
final JSONObject json = rb.pageResult(); |
|||
JSONArray ja = json.getJSONArray("content"); |
|||
JSONArray new_ja = new JSONArray(); |
|||
for (int i = 0; i < ja.size(); i++) { |
|||
JSONObject mater_jo = ja.getJSONObject(i); |
|||
if (mater_jo.getInteger("sub_count") > 0) { |
|||
mater_jo.put("hasChildren", true); |
|||
mater_jo.put("leaf", false); |
|||
} else { |
|||
mater_jo.put("hasChildren", false); |
|||
mater_jo.put("leaf", true); |
|||
} |
|||
mater_jo.put("id", mater_jo.getString("class_id")); |
|||
mater_jo.put("label", mater_jo.getString("class_name")); |
|||
new_ja.add(mater_jo); |
|||
} |
|||
json.put("content", new_ja); |
|||
return json; |
|||
} |
|||
|
|||
@Override |
|||
public List<ClassstandardDto> queryAll(Map whereJson) { |
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
JSONArray arr = wo.query().getResultJSONArray(0); |
|||
List<ClassstandardDto> list = arr.toJavaList(ClassstandardDto.class); |
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public ClassstandardDto findById(String class_id) { |
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
JSONObject json = wo.query("class_id = '" + class_id + "'").uniqueResult(0); |
|||
final ClassstandardDto obj = json.toJavaObject(ClassstandardDto.class); |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
public ClassstandardDto findByCode(String code) { |
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
JSONObject json = wo.query("class_code ='" + code + "'").uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(json)) { |
|||
return null; |
|||
} |
|||
final ClassstandardDto obj = json.toJavaObject(ClassstandardDto.class); |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void create(ClassstandardDto dto) { |
|||
String class_code = dto.getClass_code(); |
|||
ClassstandardDto classstandardDto = this.findByCode(class_code); |
|||
if (classstandardDto != null && "0".equals(classstandardDto.getIs_delete())) { |
|||
throw new BadRequestException("存在相同的基础类别编号"); |
|||
} |
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
|
|||
dto.setClass_id(IdUtil.getSnowflake(1, 1).nextId()); |
|||
dto.setCreate_id(currentUserId); |
|||
dto.setCreate_name(nickName); |
|||
dto.setUpdate_optid(currentUserId); |
|||
dto.setUpdate_optname(nickName); |
|||
dto.setUpdate_time(now); |
|||
dto.setCreate_time(now); |
|||
dto.setIs_leaf("1"); |
|||
dto.setClass_level(Math.ceil(dto.getClass_code().length() / 2.0) + ""); |
|||
dto.setSub_count(new BigDecimal(0)); |
|||
dto.setPath_code(dto.getClass_code()); |
|||
dto.setLong_class_code(dto.getClass_code()); |
|||
|
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|||
wo.insert(json); |
|||
|
|||
///更新节点
|
|||
if (dto.getParent_class_id() != null) { |
|||
updateSubCnt(dto.getParent_class_id()); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(ClassstandardDto dto) { |
|||
ClassstandardDto entity = this.findById(dto.getClass_id() + ""); |
|||
if (entity == null) { |
|||
throw new BadRequestException("被删除或无权限,操作失败!"); |
|||
} |
|||
|
|||
String class_code = dto.getClass_code(); |
|||
ClassstandardDto classstandardDto = this.findByCode(class_code); |
|||
if (classstandardDto != null && !dto.getClass_id().equals(classstandardDto.getClass_id()) && "0".equals(classstandardDto.getIs_delete())) { |
|||
throw new BadRequestException("存在相同的供应商编号"); |
|||
} |
|||
|
|||
Long oldPid = findById(dto.getClass_id() + "").getParent_class_id(); |
|||
Long newPid = dto.getParent_class_id(); |
|||
|
|||
if (dto.getParent_class_id() != null && dto.getClass_id().equals(dto.getParent_class_id())) { |
|||
throw new BadRequestException("上级不能为自己"); |
|||
} |
|||
|
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
|
|||
String now = DateUtil.now(); |
|||
dto.setUpdate_time(now); |
|||
dto.setUpdate_optid(currentUserId); |
|||
dto.setUpdate_optname(nickName); |
|||
|
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|||
wo.update(json); |
|||
|
|||
//更新父节点中子节点数目
|
|||
updateSubCnt(oldPid); |
|||
updateSubCnt(newPid); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void deleteAll(Long[] ids) { |
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
|
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
for (Long class_id : ids) { |
|||
JSONObject param = new JSONObject(); |
|||
param.put("class_id", String.valueOf(class_id)); |
|||
ClassstandardDto classstandardDto = findById(class_id + ""); |
|||
param.put("is_delete", "1"); |
|||
param.put("update_optid", currentUserId); |
|||
param.put("update_optname", nickName); |
|||
param.put("update_time", now); |
|||
wo.update(param); |
|||
|
|||
JSONArray child_rows = wo.query("parent_class_id = '" + String.valueOf(class_id) + "'").getResultJSONArray(0); |
|||
if (child_rows.size() > 0) { |
|||
Long[] child_ids = new Long[child_rows.size()]; |
|||
for (int i = 0; i < child_rows.size(); i++) { |
|||
JSONObject child_row = child_rows.getJSONObject(i); |
|||
Long id = child_row.getLong |
|||
("class_id"); |
|||
child_ids[i] = id; |
|||
} |
|||
this.deleteAll(child_ids); |
|||
} |
|||
updateSubCnt(classstandardDto.getParent_class_id()); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject loadClass(Map whereJson) { |
|||
JSONObject jo = new JSONObject(); |
|||
JSONArray ja = new JSONArray(); |
|||
String pid = (String) whereJson.get("pid"); |
|||
String base_data_type = (String) whereJson.get("base_data_type"); |
|||
String where = ""; |
|||
if (!StrUtil.isEmpty(base_data_type)) { |
|||
where = "AND base_data_type = '" + base_data_type + "'"; |
|||
} |
|||
if (pid == null || "0".equals(pid)) { |
|||
ja = WQLObject.getWQLObject("MD_PB_ClassStandard").query("(parent_class_id = '0' OR parent_class_id is null) and is_delete = '0' " + where + " order by class_id").getResultJSONArray(0); |
|||
} else { |
|||
ja = WQLObject.getWQLObject("MD_PB_ClassStandard").query("parent_class_id = '" + pid + "' AND is_delete = '0'" + where + " order by class_id").getResultJSONArray(0); |
|||
} |
|||
for (int i = 0; i < ja.size(); i++) { |
|||
JSONObject mater_jo = ja.getJSONObject(i); |
|||
if (mater_jo.getInteger("sub_count") > 0) { |
|||
mater_jo.put("hasChildren", true); |
|||
mater_jo.put("leaf", false); |
|||
} else { |
|||
mater_jo.put("hasChildren", false); |
|||
mater_jo.put("leaf", true); |
|||
} |
|||
mater_jo.put("id", mater_jo.get("class_id")); |
|||
mater_jo.put("label", mater_jo.getString("class_name")); |
|||
mater_jo.put("create_user_name", mater_jo.getString("create_name")); |
|||
mater_jo.put("update_user_name", mater_jo.getString("update_optname")); |
|||
} |
|||
jo.put("content", ja); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public JSONArray getSuperior(JSONObject jo, JSONArray ja) { |
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
if (StrUtil.isEmpty(jo.getString("parent_class_id")) || "0".equals(jo.getString("parent_class_id"))) { |
|||
JSONArray null_pids = new JSONArray(); |
|||
null_pids = wo.query("(parent_class_id = '0' OR parent_class_id is null) and is_delete = '0'").getResultJSONArray(0); |
|||
|
|||
for (int m = 0; m < null_pids.size(); m++) { |
|||
JSONObject null_pid = null_pids.getJSONObject(m); |
|||
ja.add(null_pid); |
|||
} |
|||
return ja; |
|||
} |
|||
JSONArray pid_rows = wo.query("parent_class_id = '" + jo.getString("parent_class_id") + "'").getResultJSONArray(0); |
|||
for (int n = 0; n < pid_rows.size(); n++) { |
|||
JSONObject pid_row = pid_rows.getJSONObject(n); |
|||
ja.add(pid_row); |
|||
} |
|||
JSONObject id_row = wo.query("class_id = '" + jo.getString("parent_class_id") + "'").uniqueResult(0); |
|||
return getSuperior(id_row, ja); |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject buildTree(JSONArray ja) { |
|||
Set<JSONObject> trees = new LinkedHashSet<>(); |
|||
Set<JSONObject> maters = new LinkedHashSet<>(); |
|||
List<String> mater_name = new LinkedList<>(); |
|||
for (int i = 0; i < ja.size(); i++) { |
|||
JSONObject jo = ja.getJSONObject(i); |
|||
mater_name.add(jo.getString("class_name")); |
|||
} |
|||
boolean isChild; |
|||
for (int m = 0; m < ja.size(); m++) { |
|||
JSONObject jo1 = ja.getJSONObject(m); |
|||
isChild = false; |
|||
if ("0".equals(jo1.getString("parent_class_id")) || StrUtil.isEmpty(jo1.getString("parent_class_id"))) { |
|||
jo1.put("id", jo1.getString("class_id")); |
|||
jo1.put("label", jo1.getString("class_name")); |
|||
if (jo1.getInteger("sub_count") > 0) { |
|||
jo1.put("hasChildren", true); |
|||
jo1.put("leaf", false); |
|||
} else { |
|||
jo1.put("hasChildren", false); |
|||
jo1.put("leaf", true); |
|||
} |
|||
trees.add(jo1); |
|||
} |
|||
for (int n = 0; n < ja.size(); n++) { |
|||
JSONObject jo2 = ja.getJSONObject(n); |
|||
if (!"0".equals(jo2.getString("class_id")) && jo1.getString("class_id").equals(jo2.getString("parent_class_id"))) { |
|||
isChild = true; |
|||
if (jo1.getJSONArray("children") == null) { |
|||
jo1.put("children", new JSONArray()); |
|||
} |
|||
JSONArray child_ja = jo1.getJSONArray("children"); |
|||
jo2.put("id", jo2.getString("class_id")); |
|||
jo2.put("label", jo2.getString("class_name")); |
|||
if (jo2.getInteger("sub_count") > 0) { |
|||
jo2.put("hasChildren", true); |
|||
jo2.put("leaf", false); |
|||
} else { |
|||
jo2.put("hasChildren", false); |
|||
jo2.put("leaf", true); |
|||
} |
|||
child_ja.add(jo2); |
|||
} |
|||
} |
|||
if (isChild) { |
|||
jo1.put("id", jo1.getString("class_id")); |
|||
jo1.put("label", jo1.getString("class_name")); |
|||
if (jo1.getInteger("sub_count") > 0) { |
|||
jo1.put("hasChildren", true); |
|||
jo1.put("leaf", false); |
|||
} else { |
|||
jo1.put("hasChildren", false); |
|||
jo1.put("leaf", true); |
|||
} |
|||
maters.add(jo1); |
|||
} else if (!"0".equals(jo1.getString("class_id")) && !mater_name.contains(jo1.getString("material_type_name"))) { |
|||
jo1.put("id", jo1.getString("class_id")); |
|||
jo1.put("label", jo1.getString("class_name")); |
|||
if (jo1.getInteger("sub_count") > 0) { |
|||
jo1.put("hasChildren", true); |
|||
jo1.put("leaf", false); |
|||
} else { |
|||
jo1.put("hasChildren", false); |
|||
jo1.put("leaf", true); |
|||
} |
|||
maters.add(jo1); |
|||
} |
|||
} |
|||
if (maters.size() == 0) { |
|||
maters = trees; |
|||
} |
|||
JSONObject jo = new JSONObject(); |
|||
jo.put("totalElements", ja.size()); |
|||
jo.put("content", maters.size() == 0 ? ja : trees); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject queryClassBycode(Map whereJson) { |
|||
String parent_class_code = (String) whereJson.get("parent_class_code"); |
|||
String class_code = (String) whereJson.get("class_code"); |
|||
JSONObject jo = new JSONObject(); |
|||
JSONArray ja = new JSONArray(); |
|||
String where = ""; |
|||
ClassstandardDto classstandardDto = null; |
|||
if (!StrUtil.isEmpty(parent_class_code)) { |
|||
classstandardDto = this.findByCode(parent_class_code); |
|||
if (classstandardDto == null) { |
|||
throw new BadRequestException("请输入正确的父节点编号!"); |
|||
} |
|||
} |
|||
if (!StrUtil.isEmpty(class_code)) { |
|||
where = " AND class_code IN ('" + class_code + "')"; |
|||
} |
|||
//parent_class_code不为空,查出 id等于classstandardDto.getClass_id()
|
|||
if (StrUtil.isNotEmpty(parent_class_code)) { |
|||
ja = WQLObject.getWQLObject("MD_PB_ClassStandard").query("class_id = '" + classstandardDto.getClass_id() + "' order by class_id").getResultJSONArray(0); |
|||
} else if (StrUtil.isNotEmpty(where)) { |
|||
ja = WQLObject.getWQLObject("MD_PB_ClassStandard").query("1=1 " + where + " order by class_id").getResultJSONArray(0); |
|||
} else if (StrUtil.isEmpty(parent_class_code) || "0".equals(parent_class_code)) { |
|||
ja = WQLObject.getWQLObject("MD_PB_ClassStandard").query("(parent_class_id = '0' OR parent_class_id is null) and is_delete = '0' order by class_id").getResultJSONArray(0); |
|||
} |
|||
for (int i = 0; i < ja.size(); i++) { |
|||
JSONObject mater_jo = ja.getJSONObject(i); |
|||
if (mater_jo.getInteger("sub_count") > 0) { |
|||
mater_jo.put("hasChildren", true); |
|||
mater_jo.put("leaf", false); |
|||
} else { |
|||
mater_jo.put("hasChildren", false); |
|||
mater_jo.put("leaf", true); |
|||
} |
|||
mater_jo.put("id", mater_jo.getString("class_id")); |
|||
mater_jo.put("label", mater_jo.getString("class_name")); |
|||
mater_jo.put("create_user_name", mater_jo.getString("create_name")); |
|||
mater_jo.put("update_user_name", mater_jo.getString("update_optname")); |
|||
} |
|||
jo.put("content", ja); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject queryClassById(Map whereJson) { |
|||
String parent_class_id = (String) whereJson.get("parent_class_id"); |
|||
|
|||
/*where条件*/ |
|||
String class_idStr = (String) whereJson.get("class_idStr"); |
|||
String whereStr = (String) whereJson.get("whereStr"); |
|||
|
|||
JSONObject jo = new JSONObject(); |
|||
JSONArray ja = new JSONArray(); |
|||
String where = "1=1"; |
|||
|
|||
if (!StrUtil.isEmpty(whereStr)) { |
|||
where += whereStr; |
|||
} |
|||
if (StrUtil.isNotEmpty(class_idStr)) { |
|||
where += " AND class_id IN " + class_idStr; |
|||
//"('1','2','3')"
|
|||
} |
|||
if (!StrUtil.isEmpty(parent_class_id)) { |
|||
where += " AND parent_class_id = " + parent_class_id; |
|||
} |
|||
|
|||
ja = WQLObject.getWQLObject("MD_PB_ClassStandard").query(where + " order by class_id").getResultJSONArray(0); |
|||
for (int i = 0; i < ja.size(); i++) { |
|||
JSONObject mater_jo = ja.getJSONObject(i); |
|||
if (mater_jo.getInteger("sub_count") > 0) { |
|||
mater_jo.put("hasChildren", true); |
|||
mater_jo.put("leaf", false); |
|||
} else { |
|||
mater_jo.put("hasChildren", false); |
|||
mater_jo.put("leaf", true); |
|||
} |
|||
mater_jo.put("id", mater_jo.getString("class_id")); |
|||
mater_jo.put("label", mater_jo.getString("class_name")); |
|||
mater_jo.put("create_user_name", mater_jo.getString("create_name")); |
|||
mater_jo.put("update_user_name", mater_jo.getString("update_optname")); |
|||
} |
|||
jo.put("content", ja); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject queryClassTable(Map whereJson, Pageable page) { |
|||
HashMap<String, String> map = new HashMap<>(); |
|||
map.put("flag", "1"); |
|||
String material_type_id = (String) whereJson.get("material_type_id"); |
|||
String class_idStr = (String) whereJson.get("class_idStr"); |
|||
//处理物料当前节点的所有子节点
|
|||
if (!StrUtil.isEmpty(material_type_id)) { |
|||
map.put("material_type_id", material_type_id); |
|||
String classIds = this.getChildIdStr(material_type_id); |
|||
map.put("classIds", classIds); |
|||
} else if (ObjectUtil.isNotEmpty(class_idStr)) { |
|||
String classIds = this.getAllChildIdStr(class_idStr); |
|||
map.put("classIds", classIds); |
|||
} |
|||
JSONObject jo = WQL.getWO("QMD_PB_CLASSBASE").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "update_time desc"); |
|||
JSONArray content = jo.getJSONArray("content"); |
|||
JSONArray jsonArr = new JSONArray(); |
|||
for (int i = 0; i < content.size(); i++) { |
|||
JSONObject json = content.getJSONObject(i); |
|||
JSONObject jsonParent = WQLObject.getWQLObject("md_pb_classstandard").query("class_id = '" + json.getString("parent_class_id") + "'").uniqueResult(0); |
|||
json.put("address", jsonParent.getString("class_name")); |
|||
jsonArr.add(json); |
|||
} |
|||
jo.put("content", jsonArr); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject getType(String type_id, int level) { |
|||
WQLObject classTab = WQLObject.getWQLObject("md_pb_classstandard"); |
|||
JSONObject json = classTab.query("class_id= " + type_id + "").uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(json)) { |
|||
return null; |
|||
} |
|||
String class_code = json.getString("class_code"); |
|||
if (class_code.length() / 2 == level) { |
|||
return json; |
|||
} else { |
|||
return getType(json.getString("parent_class_id"), level); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Set<String> getChildIdSet(String class_id) { |
|||
String sql = "select DISTINCT class_id from (\n" + |
|||
" select t1.class_id,\n" + |
|||
" if(find_in_set(parent_class_id, @pids) > 0, @pids := concat(@pids, ',', class_id), 0) as ischild\n" + |
|||
" from (\n" + |
|||
" select class_id,parent_class_id from md_pb_classstandard t where t.is_delete = '0' order by class_code\n" + |
|||
" ) t1,\n" + |
|||
" (select @pids := '" + class_id + "') t2\n" + |
|||
" ) t3 where ischild != 0"; |
|||
Set<String> set = new HashSet<>(); |
|||
//添加本级
|
|||
set.add(class_id); |
|||
|
|||
//添加子节点
|
|||
try { |
|||
List<Entity> list = Db.use((DataSource) SpringContextHolder.getBean("dataSource")).query(sql); |
|||
list.forEach(item -> { |
|||
set.add(item.getStr("class_id")); |
|||
}); |
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return set; |
|||
} |
|||
|
|||
@Override |
|||
public Set<String> getAllChildIdSet(String class_idStr) { |
|||
JSONArray arr = WQLObject.getWQLObject("md_pb_classstandard").query("class_id IN " + class_idStr).getResultJSONArray(0); |
|||
Set<String> set = new HashSet<>(); |
|||
for (int i = 0; i < arr.size(); i++) { |
|||
set.addAll(this.getChildIdSet(arr.getJSONObject(i).getString("class_id"))); |
|||
} |
|||
return set; |
|||
} |
|||
|
|||
@Override |
|||
public String getChildIdStr(String class_id) { |
|||
Set<String> set = this.getChildIdSet(class_id); |
|||
StringBuilder sb = new StringBuilder(); |
|||
set.forEach(item -> { |
|||
sb.append(",'" + item + "'"); |
|||
}); |
|||
String str = sb.toString(); |
|||
if (StrUtil.isNotEmpty(str)) { |
|||
str = "(" + str.substring(1) + ")"; |
|||
} |
|||
return str; |
|||
} |
|||
|
|||
@Override |
|||
public String getAllChildIdStr(String class_idStr) { |
|||
Set<String> set = this.getAllChildIdSet(class_idStr); |
|||
StringBuilder sb = new StringBuilder(); |
|||
set.forEach(item -> { |
|||
sb.append(",'" + item + "'"); |
|||
}); |
|||
String str = sb.toString(); |
|||
if (StrUtil.isNotEmpty(str)) { |
|||
str = "(" + str.substring(1) + ")"; |
|||
} |
|||
return str; |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject getCasClass(JSONObject whereJson) { |
|||
/* |
|||
* 获取人员对应仓库下拉框公共方法 多级下拉框 |
|||
*/ |
|||
JSONArray new_ja = new JSONArray(); |
|||
HashMap<String, String> stor_map = new HashMap<>(); |
|||
stor_map.put("flag", "2"); |
|||
stor_map.put("class_code", whereJson.getString("class_code")); |
|||
|
|||
JSONArray class_ja = WQL.getWO("QMD_PB_CLASSBASE").addParamMap(stor_map).process().getResultJSONArray(0); |
|||
for (int i = 0; i < class_ja.size(); i++) { |
|||
JSONObject class_jo = class_ja.getJSONObject(i); |
|||
JSONObject class_cas = new JSONObject(); |
|||
class_cas.put("value", class_jo.getString("class_code")); |
|||
class_cas.put("label", class_jo.getString("class_name")); |
|||
HashMap<String, String> map = new HashMap<>(); |
|||
map.put("flag", "2"); |
|||
map.put("class_code", class_jo.getString("class_code")); |
|||
JSONArray ja = WQL.getWO("QMD_PB_CLASSBASE").addParamMap(map).process().getResultJSONArray(0); |
|||
if (ja.size() > 0) { |
|||
JSONArray sect_ja = new JSONArray(); |
|||
for (int j = 0; j < ja.size(); j++) { |
|||
JSONObject sect_jo = ja.getJSONObject(j); |
|||
JSONObject sect_cas = new JSONObject(); |
|||
sect_cas.put("value", sect_jo.getString("class_code")); |
|||
sect_cas.put("label", sect_jo.getString("class_name")); |
|||
sect_ja.add(sect_cas); |
|||
} |
|||
class_cas.put("children", sect_ja); |
|||
} |
|||
new_ja.add(class_cas); |
|||
} |
|||
JSONObject jo = new JSONObject(); |
|||
jo.put("content", new_ja); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public JSONArray getClassName() { |
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
// 获取的是父节点
|
|||
JSONArray result = wo.query("(parent_class_id is null OR parent_class_id = '0') AND is_delete = '0'").getResultJSONArray(0); |
|||
JSONArray res = new JSONArray(); |
|||
for (int i = 0; i < result.size(); i++) { |
|||
JSONObject jsonObject = new JSONObject(); |
|||
jsonObject.put("label", result.getJSONObject(i).get("class_name")); |
|||
jsonObject.put("value", result.getJSONObject(i).get("class_code")); |
|||
res.add(jsonObject); |
|||
} |
|||
return res; |
|||
} |
|||
|
|||
|
|||
public void updateSubCnt(Long Id) { |
|||
if (Id != null && Id != 0) { |
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
int count = wo.query("parent_class_id = '" + Id + "' AND is_delete = '0'").getResultJSONArray(0).size(); |
|||
JSONObject pid = wo.query("class_id = '" + Id + "'").uniqueResult(0); |
|||
pid.put("sub_count", count); |
|||
if (count > 0) { |
|||
pid.put("is_leaf", "0"); |
|||
} else { |
|||
pid.put("is_leaf", "1"); |
|||
} |
|||
wo.update(pid); |
|||
} |
|||
} |
|||
|
|||
} |
@ -1,81 +0,0 @@ |
|||
[交易说明] |
|||
交易名: 基础点位分页查询 |
|||
所属模块: |
|||
功能简述: |
|||
版权所有: |
|||
表引用: |
|||
版本经历: |
|||
|
|||
[数据库] |
|||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
|||
|
|||
[IO定义] |
|||
################################################# |
|||
## 表字段对应输入参数 |
|||
################################################# |
|||
输入.flag TYPEAS s_string |
|||
输入.search TYPEAS s_string |
|||
输入.class_code TYPEAS class_code |
|||
输入.classIds TYPEAS f_string |
|||
|
|||
|
|||
[临时表] |
|||
--这边列出来的临时表就会在运行期动态创建 |
|||
|
|||
[临时变量] |
|||
--所有中间过程变量均可在此处定义 |
|||
|
|||
[业务过程] |
|||
|
|||
########################################## |
|||
# 1、输入输出检查 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 2、主过程前处理 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 3、业务主过程 # |
|||
########################################## |
|||
|
|||
IF 输入.flag = "1" |
|||
PAGEQUERY |
|||
SELECT |
|||
* |
|||
FROM |
|||
md_pb_classstandard class |
|||
LEFT JOIN ST_IVT_StructRelaMaterial sr ON sr.material_type_id = class.class_id |
|||
WHERE |
|||
is_leaf = '1' |
|||
AND |
|||
base_data_type = '03' |
|||
AND |
|||
sr.sect_id IS NULL |
|||
AND |
|||
is_delete = '0' |
|||
OPTION 输入.classIds <> "" |
|||
class.class_id in 输入.classIds |
|||
ENDOPTION |
|||
ENDSELECT |
|||
ENDPAGEQUERY |
|||
ENDIF |
|||
|
|||
IF 输入.flag = "2" |
|||
QUERY |
|||
SELECT |
|||
class2.* |
|||
FROM |
|||
md_pb_classstandard class |
|||
left join |
|||
md_pb_classstandard class2 ON class.class_id = class2.parent_class_id |
|||
where |
|||
class.class_code = 输入.class_code |
|||
ENDSELECT |
|||
ENDQUERY |
|||
ENDIF |
|||
|
|||
|
|||
|
@ -1,59 +0,0 @@ |
|||
[交易说明] |
|||
交易名: 接口回传设置分页查询 |
|||
所属模块: |
|||
功能简述: |
|||
版权所有: |
|||
表引用: |
|||
版本经历: |
|||
|
|||
[数据库] |
|||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
|||
|
|||
[IO定义] |
|||
################################################# |
|||
## 表字段对应输入参数 |
|||
################################################# |
|||
输入.flag TYPEAS s_string |
|||
输入.interface_name TYPEAS s_string |
|||
|
|||
[临时表] |
|||
--这边列出来的临时表就会在运行期动态创建 |
|||
|
|||
[临时变量] |
|||
--所有中间过程变量均可在此处定义 |
|||
|
|||
[业务过程] |
|||
|
|||
########################################## |
|||
# 1、输入输出检查 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 2、主过程前处理 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 3、业务主过程 # |
|||
########################################## |
|||
|
|||
IF 输入.flag = "1" |
|||
PAGEQUERY |
|||
SELECT |
|||
* |
|||
FROM |
|||
md_pb_interfaceback |
|||
WHERE |
|||
1=1 |
|||
|
|||
OPTION 输入.interface_name <> "" |
|||
interface_name like 输入.interface_name |
|||
ENDOPTION |
|||
|
|||
ENDSELECT |
|||
ENDPAGEQUERY |
|||
ENDIF |
|||
|
|||
|
|||
|
@ -1,83 +0,0 @@ |
|||
[交易说明] |
|||
交易名: 载具维护分页查询 |
|||
所属模块: |
|||
功能简述: |
|||
版权所有: |
|||
表引用: |
|||
版本经历: |
|||
|
|||
[数据库] |
|||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
|||
|
|||
[IO定义] |
|||
################################################# |
|||
## 表字段对应输入参数 |
|||
################################################# |
|||
输入.flag TYPEAS s_string |
|||
输入.storagevehicle_code_begin TYPEAS s_string |
|||
输入.storagevehicle_code_end TYPEAS s_string |
|||
输入.storagevehicle_type TYPEAS f_string |
|||
|
|||
|
|||
[临时表] |
|||
--这边列出来的临时表就会在运行期动态创建 |
|||
|
|||
[临时变量] |
|||
--所有中间过程变量均可在此处定义 |
|||
|
|||
[业务过程] |
|||
|
|||
########################################## |
|||
# 1、输入输出检查 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 2、主过程前处理 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 3、业务主过程 # |
|||
########################################## |
|||
|
|||
IF 输入.flag = "1" |
|||
PAGEQUERY |
|||
SELECT |
|||
s.*, |
|||
ext.pcsn, |
|||
ext.qty, |
|||
ext.update_time AS change_time, |
|||
mater.material_code, |
|||
mater.material_name, |
|||
point.point_code, |
|||
point.point_name, |
|||
class.class_name AS storagevehicle_type_name |
|||
FROM |
|||
md_pb_storagevehicleinfo s |
|||
LEFT JOIN sch_base_point point ON point.vehicle_code = s.storagevehicle_code |
|||
LEFT JOIN ST_IVT_StructIvt ivt ON point.source_id = ivt.struct_id |
|||
LEFT JOIN md_me_materialbase mater ON mater.material_id = ivt.material_id |
|||
LEFT JOIN md_pb_classstandard class ON class.class_code = s.storagevehicle_type |
|||
LEFT JOIN md_pb_storagevehicleext ext ON ext.storagevehicle_code = s.storagevehicle_code |
|||
WHERE |
|||
s.is_delete = '0' |
|||
ENDOPTION |
|||
OPTION 输入.storagevehicle_code_begin <> "" |
|||
s.storagevehicle_code >= 输入.storagevehicle_code_begin |
|||
ENDOPTION |
|||
|
|||
ENDOPTION |
|||
OPTION 输入.storagevehicle_code_end <> "" |
|||
s.storagevehicle_code <= 输入.storagevehicle_code_end |
|||
ENDOPTION |
|||
|
|||
OPTION 输入.storagevehicle_type <> "" |
|||
class.class_id in 输入.storagevehicle_type |
|||
ENDOPTION |
|||
ENDSELECT |
|||
ENDPAGEQUERY |
|||
ENDIF |
|||
|
|||
|
|||
|
@ -1,82 +0,0 @@ |
|||
package org.nl.wms.basedata.st.rest; |
|||
|
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.logging.annotation.Log; |
|||
import org.nl.wms.basedata.st.service.StructrelamaterialService; |
|||
import org.nl.wms.basedata.st.service.dto.StructrelamaterialDto; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @date 2021-12-09 |
|||
**/ |
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
|
|||
@RequestMapping("/api/structrelamaterial") |
|||
@Slf4j |
|||
public class StructrelamaterialController { |
|||
|
|||
private final StructrelamaterialService structrelamaterialService; |
|||
|
|||
@GetMapping |
|||
@Log("查询物料存放设置") |
|||
|
|||
//@PreAuthorize("@el.check('structrelamaterial:list')")
|
|||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) { |
|||
return new ResponseEntity<>(structrelamaterialService.queryAll(whereJson, page), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Log("新增物料存放设置") |
|||
|
|||
//@PreAuthorize("@el.check('structrelamaterial:add')")
|
|||
public ResponseEntity<Object> create(@Validated @RequestBody StructrelamaterialDto dto) { |
|||
structrelamaterialService.create(dto); |
|||
return new ResponseEntity<>(HttpStatus.CREATED); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Log("修改物料存放设置") |
|||
|
|||
//@PreAuthorize("@el.check('structrelamaterial:edit')")
|
|||
public ResponseEntity<Object> update(@Validated @RequestBody StructrelamaterialDto dto) { |
|||
structrelamaterialService.update(dto); |
|||
return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
|||
} |
|||
|
|||
@Log("删除物料存放设置") |
|||
|
|||
//@PreAuthorize("@el.check('structrelamaterial:del')")
|
|||
@DeleteMapping |
|||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) { |
|||
structrelamaterialService.deleteAll(ids); |
|||
return new ResponseEntity<>(HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/insertSet") |
|||
@Log("插入物料存放设置") |
|||
|
|||
//@PreAuthorize("@el.check('structrelamaterial:edit')")
|
|||
public ResponseEntity<Object> insertSet(@RequestBody Map whereJson) { |
|||
structrelamaterialService.insertSet(whereJson); |
|||
return new ResponseEntity<>(HttpStatus.CREATED); |
|||
} |
|||
|
|||
@PostMapping("/delSet") |
|||
@Log("删除物料存放设置") |
|||
|
|||
//@PreAuthorize("@el.check('structrelamaterial:edit')")
|
|||
public ResponseEntity<Object> delSet(@RequestBody Map whereJson) { |
|||
structrelamaterialService.delSet(whereJson); |
|||
return new ResponseEntity<>(HttpStatus.OK); |
|||
} |
|||
} |
@ -1,75 +0,0 @@ |
|||
package org.nl.wms.basedata.st.service; |
|||
|
|||
import org.nl.wms.basedata.st.service.dto.StructrelamaterialDto; |
|||
import org.springframework.data.domain.Pageable; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description 服务接口 |
|||
* @date 2021-12-09 |
|||
**/ |
|||
public interface StructrelamaterialService { |
|||
|
|||
/** |
|||
* 查询数据分页 |
|||
* |
|||
* @param whereJson 条件 |
|||
* @param page 分页参数 |
|||
* @return Map<String, Object> |
|||
*/ |
|||
Map<String, Object> queryAll(Map whereJson, Pageable page); |
|||
|
|||
/** |
|||
* 查询所有数据不分页 |
|||
* |
|||
* @param whereJson 条件参数 |
|||
* @return List<StructrelamaterialDto> |
|||
*/ |
|||
List<StructrelamaterialDto> queryAll(Map whereJson); |
|||
|
|||
/** |
|||
* 根据ID查询 |
|||
* |
|||
* @param material_type_id ID |
|||
* @return Structrelamaterial |
|||
*/ |
|||
StructrelamaterialDto findById(Long material_type_id); |
|||
|
|||
/** |
|||
* 根据编码查询 |
|||
* |
|||
* @param code code |
|||
* @return Structrelamaterial |
|||
*/ |
|||
StructrelamaterialDto findByCode(String code); |
|||
|
|||
|
|||
/** |
|||
* 创建 |
|||
* |
|||
* @param dto / |
|||
*/ |
|||
void create(StructrelamaterialDto dto); |
|||
|
|||
/** |
|||
* 编辑 |
|||
* |
|||
* @param dto / |
|||
*/ |
|||
void update(StructrelamaterialDto dto); |
|||
|
|||
/** |
|||
* 多选删除 |
|||
* |
|||
* @param ids / |
|||
*/ |
|||
void deleteAll(Long[] ids); |
|||
|
|||
void insertSet(Map whereJson); |
|||
|
|||
void delSet(Map whereJson); |
|||
|
|||
} |
@ -1,34 +0,0 @@ |
|||
package org.nl.wms.basedata.st.service.dto; |
|||
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
|||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description / |
|||
* @date 2021-12-09 |
|||
**/ |
|||
@Data |
|||
public class StructrelamaterialDto implements Serializable { |
|||
|
|||
/** |
|||
* 防止精度丢失 |
|||
*/ |
|||
@JsonSerialize(using = ToStringSerializer.class) |
|||
private Long sect_id; |
|||
|
|||
/** |
|||
* 防止精度丢失 |
|||
*/ |
|||
@JsonSerialize(using = ToStringSerializer.class) |
|||
private Long material_type_id; |
|||
|
|||
private Long set_id; |
|||
|
|||
private String set_name; |
|||
|
|||
private String set_time; |
|||
} |
@ -1,175 +0,0 @@ |
|||
package org.nl.wms.basedata.st.service.impl; |
|||
|
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.IdUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.utils.SecurityUtils; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.wql.WQL; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.modules.wql.util.WqlUtil; |
|||
import org.nl.wms.basedata.master.service.ClassstandardService; |
|||
import org.nl.wms.basedata.st.service.StructrelamaterialService; |
|||
import org.nl.wms.basedata.st.service.dto.StructrelamaterialDto; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description 服务实现 |
|||
* @date 2021-12-09 |
|||
**/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class StructrelamaterialServiceImpl implements StructrelamaterialService { |
|||
private final ClassstandardService classstandardService; |
|||
|
|||
@Override |
|||
public Map<String, Object> queryAll(Map whereJson, Pageable page) { |
|||
String search = (String) whereJson.get("search"); |
|||
HashMap<String, String> map = new HashMap<>(); |
|||
if (!StrUtil.isEmpty(search)) { |
|||
map.put("search", "%" + search + "%"); |
|||
} |
|||
map.put("flag", "1"); |
|||
map.put("stor_id", (String) whereJson.get("stor_id")); |
|||
map.put("sect_id", (String) whereJson.get("sect_id")); |
|||
String material_type_id = (String) whereJson.get("material_type_id"); |
|||
String class_idStr = (String) whereJson.get("class_idStr"); |
|||
//处理物料当前节点的所有子节点
|
|||
if (!StrUtil.isEmpty(material_type_id)) { |
|||
map.put("material_type_id", material_type_id); |
|||
String classIds = classstandardService.getChildIdStr(material_type_id); |
|||
map.put("classIds", classIds); |
|||
} else if (ObjectUtil.isNotEmpty(class_idStr)) { |
|||
String classIds = classstandardService.getAllChildIdStr(class_idStr); |
|||
map.put("classIds", classIds); |
|||
} |
|||
JSONObject jo = WQL.getWO("QST_IVT_MATERIALSET").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "set_time desc"); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public List<StructrelamaterialDto> queryAll(Map whereJson) { |
|||
WQLObject wo = WQLObject.getWQLObject("st_ivt_structrelamaterial"); |
|||
JSONArray arr = wo.query().getResultJSONArray(0); |
|||
List<StructrelamaterialDto> list = arr.toJavaList(StructrelamaterialDto.class); |
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public StructrelamaterialDto findById(Long material_type_id) { |
|||
WQLObject wo = WQLObject.getWQLObject("st_ivt_structrelamaterial"); |
|||
JSONObject json = wo.query("material_type_id =" + material_type_id + "").uniqueResult(0); |
|||
final StructrelamaterialDto obj = json.toJavaObject(StructrelamaterialDto.class); |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
public StructrelamaterialDto findByCode(String code) { |
|||
WQLObject wo = WQLObject.getWQLObject("st_ivt_structrelamaterial"); |
|||
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0); |
|||
final StructrelamaterialDto obj = json.toJavaObject(StructrelamaterialDto.class); |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void create(StructrelamaterialDto dto) { |
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
|
|||
dto.setMaterial_type_id(IdUtil.getSnowflake(1, 1).nextId()); |
|||
dto.setSet_name(nickName); |
|||
dto.setSet_time(now); |
|||
|
|||
WQLObject wo = WQLObject.getWQLObject("st_ivt_structrelamaterial"); |
|||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|||
wo.insert(json); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(StructrelamaterialDto dto) { |
|||
StructrelamaterialDto entity = this.findById(dto.getMaterial_type_id()); |
|||
if (entity == null) { |
|||
throw new BadRequestException("被删除或无权限,操作失败!"); |
|||
} |
|||
|
|||
WQLObject wo = WQLObject.getWQLObject("st_ivt_structrelamaterial"); |
|||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|||
wo.update(json); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void deleteAll(Long[] ids) { |
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
|
|||
WQLObject wo = WQLObject.getWQLObject("st_ivt_structrelamaterial"); |
|||
for (Long material_type_id : ids) { |
|||
JSONObject param = new JSONObject(); |
|||
param.put("material_type_id", String.valueOf(material_type_id)); |
|||
param.put("is_delete", "1"); |
|||
param.put("update_optid", currentUserId); |
|||
param.put("update_optname", nickName); |
|||
param.put("update_time", now); |
|||
wo.update(param); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void insertSet(Map whereJson) { |
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
WQLObject mater = WQLObject.getWQLObject("ST_IVT_StructRelaMaterial"); |
|||
String sect_id = (String) whereJson.get("sect_id"); |
|||
ArrayList<HashMap> class_rows = (ArrayList<HashMap>) whereJson.get("class_rows"); |
|||
for (int i = 0; i < class_rows.size(); i++) { |
|||
HashMap<String, String> class_row = class_rows.get(i); |
|||
JSONObject material_set = mater.query("sect_id = '" + sect_id + "' AND material_type_id = '" + class_row.get("class_id") + "'") |
|||
.uniqueResult(0); |
|||
if (material_set != null) { |
|||
HashMap<String, String> update_map = new HashMap<>(); |
|||
update_map.put("set_id", currentUserId + ""); |
|||
update_map.put("set_name", nickName); |
|||
update_map.put("set_time", now); |
|||
mater.update(update_map, "sect_id = '" + sect_id + "' AND material_type_id = '" + class_row.get("class_id") + "'"); |
|||
} else { |
|||
JSONObject jo = new JSONObject(); |
|||
jo.put("sect_id", sect_id); |
|||
jo.put("material_type_id", class_row.get("class_id")); |
|||
jo.put("set_id", currentUserId + ""); |
|||
jo.put("set_name", nickName); |
|||
jo.put("set_time", now); |
|||
mater.insert(jo); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void delSet(Map whereJson) { |
|||
String sect_id = (String) whereJson.get("sect_id"); |
|||
String material_type_id = (String) whereJson.get("material_type_id"); |
|||
WQLObject.getWQLObject("ST_IVT_StructRelaMaterial").delete("sect_id = '" + sect_id + "' AND material_type_id = '" + material_type_id + "'"); |
|||
} |
|||
|
|||
} |
@ -1,78 +0,0 @@ |
|||
[交易说明] |
|||
交易名: 基础点位分页查询 |
|||
所属模块: |
|||
功能简述: |
|||
版权所有: |
|||
表引用: |
|||
版本经历: |
|||
|
|||
[数据库] |
|||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
|||
|
|||
[IO定义] |
|||
################################################# |
|||
## 表字段对应输入参数 |
|||
################################################# |
|||
输入.flag TYPEAS s_string |
|||
输入.search TYPEAS s_string |
|||
输入.stor_id TYPEAS s_string |
|||
输入.sect_id TYPEAS s_string |
|||
输入.classIds TYPEAS f_string |
|||
|
|||
|
|||
[临时表] |
|||
--这边列出来的临时表就会在运行期动态创建 |
|||
|
|||
[临时变量] |
|||
--所有中间过程变量均可在此处定义 |
|||
|
|||
[业务过程] |
|||
|
|||
########################################## |
|||
# 1、输入输出检查 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 2、主过程前处理 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 3、业务主过程 # |
|||
########################################## |
|||
|
|||
IF 输入.flag = "1" |
|||
PAGEQUERY |
|||
SELECT |
|||
se.sect_code, |
|||
se.sect_name, |
|||
class.class_code, |
|||
class.class_name, |
|||
sm.* |
|||
FROM |
|||
st_ivt_structrelamaterial sm |
|||
INNER JOIN st_ivt_sectattr se ON se.sect_id = sm.sect_id |
|||
INNER JOIN md_pb_classstandard class ON class.class_id = sm.material_type_id |
|||
OPTION 输入.search <> "" |
|||
( |
|||
class.class_code like 输入.search |
|||
OR |
|||
class.class_name like 输入.search |
|||
) |
|||
ENDOPTION |
|||
OPTION 输入.stor_id <> "" |
|||
se.stor_id = 输入.stor_id |
|||
ENDOPTION |
|||
OPTION 输入.sect_id <> "" |
|||
se.sect_id = 输入.sect_id |
|||
ENDOPTION |
|||
OPTION 输入.classIds <> "" |
|||
class.class_id in 输入.classIds |
|||
ENDOPTION |
|||
ENDSELECT |
|||
ENDPAGEQUERY |
|||
ENDIF |
|||
|
|||
|
|||
|
Loading…
Reference in new issue