|
|
@ -30,6 +30,7 @@ import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author zhouz |
|
|
@ -51,6 +52,9 @@ public class MaterialbaseServiceImpl implements MaterialbaseService { |
|
|
|
map.put("flag", "1"); |
|
|
|
map.put("search", name); |
|
|
|
map.put("material_type", MapUtil.getStr(whereJson, "material_type")); |
|
|
|
map.put("order_code", MapUtil.getStr(whereJson, "order_code")); |
|
|
|
map.put("product_grade", MapUtil.getStr(whereJson, "product_grade")); |
|
|
|
map.put("brick_type", MapUtil.getStr(whereJson, "brick_type")); |
|
|
|
|
|
|
|
return WQL.getWO("QMD_ME_MATERIAL").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time DESC"); |
|
|
|
} |
|
|
@ -106,52 +110,6 @@ public class MaterialbaseServiceImpl implements MaterialbaseService { |
|
|
|
dto.setCreate_time(now); |
|
|
|
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|
|
|
wo.insert(json); |
|
|
|
|
|
|
|
// 解析物料编码
|
|
|
|
JSONObject material_detail = new JSONObject(); |
|
|
|
material_detail.put("material_id", id); |
|
|
|
material_detail.put("material_code", material_code); |
|
|
|
WQLObject dict_detail_table = WQLObject.getWQLObject("sys_dict_detail"); |
|
|
|
String furnace_code = material_code.substring(0, 2); |
|
|
|
JSONObject furnace_name = dict_detail_table.query("name = 'furnace' AND value = '" + furnace_code + "'").uniqueResult(0); |
|
|
|
if (ObjectUtil.isEmpty(furnace_name)) { |
|
|
|
throw new BadRequestException("物料编码解析错误:未知炉型!"); |
|
|
|
} |
|
|
|
material_detail.put("furnace", furnace_name.getString("label")); |
|
|
|
String material_brick_code = material_code.substring(2, 5); |
|
|
|
JSONObject material_brick_type = dict_detail_table.query("name = 'material_brick_type' AND value = '" + material_brick_code + "'").uniqueResult(0); |
|
|
|
if (ObjectUtil.isEmpty(material_brick_type)) { |
|
|
|
throw new BadRequestException("物料编码解析错误:未知物料砖类型!"); |
|
|
|
} |
|
|
|
material_detail.put("material_brick_type", material_brick_type.getString("label")); |
|
|
|
|
|
|
|
String bom_code = material_code.substring(5, 11); |
|
|
|
JSONObject old_bom = wo.query("material_code = '" + bom_code + "'").uniqueResult(0); |
|
|
|
if (ObjectUtil.isEmpty(old_bom)) { |
|
|
|
JSONObject bom = new JSONObject(); |
|
|
|
bom.put("material_id", IdUtil.getSnowflake(1, 1).nextId()); |
|
|
|
bom.put("material_code", bom_code); |
|
|
|
bom.put("material_type", "2"); |
|
|
|
bom.put("create_id", currentUserId); |
|
|
|
bom.put("create_name", nickName); |
|
|
|
bom.put("create_time", now); |
|
|
|
wo.insert(bom); |
|
|
|
} |
|
|
|
|
|
|
|
material_detail.put("bom_code", bom_code); |
|
|
|
material_detail.put("order_code", material_code.substring(11, 16)); |
|
|
|
material_detail.put("customer_code", material_code.substring(16, 21)); |
|
|
|
String product_grade_code = material_code.substring(21, 23); |
|
|
|
JSONObject product_grade = dict_detail_table.query("name = 'product_grade' AND value = '" + product_grade_code + "'").uniqueResult(0); |
|
|
|
if (ObjectUtil.isEmpty(product_grade)) { |
|
|
|
throw new BadRequestException("物料编码解析错误:未知牌号!"); |
|
|
|
} |
|
|
|
material_detail.put("product_grade", product_grade.getString("label")); |
|
|
|
material_detail.put("brick_type", material_code.substring(23)); |
|
|
|
material_detail.put("create_id", currentUserId); |
|
|
|
material_detail.put("create_name", nickName); |
|
|
|
material_detail.put("create_time", now); |
|
|
|
WQLObject.getWQLObject("md_me_material_detail").insert(material_detail); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -199,8 +157,59 @@ public class MaterialbaseServiceImpl implements MaterialbaseService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void synchronize(Map whereJson) { |
|
|
|
/* wmsToErpService.getClassInfo(null); |
|
|
|
wmsToErpService.getMaterialInfo(null);*/ |
|
|
|
JSONArray erp_materials = WQL.getWO("QMD_ME_MATERIAL").setDbname("dataSource1").addParam("flag", "2").process().getResultJSONArray(0); |
|
|
|
if (ObjectUtil.isNotEmpty(erp_materials)) { |
|
|
|
WQLObject material_table = WQLObject.getWQLObject("md_me_materialbase"); |
|
|
|
List<String> material_codes = material_table.query().getResultJSONArray(0).stream().map(o -> ((JSONObject) o).getString("material_code")).collect(Collectors.toList()); |
|
|
|
WQLObject dict_detail_table = WQLObject.getWQLObject("sys_dict_detail"); |
|
|
|
|
|
|
|
Long user_id = SecurityUtils.getCurrentUserId(); |
|
|
|
String nick_name = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
|
|
|
|
erp_materials.forEach(o -> { |
|
|
|
JSONObject erp_material = (JSONObject) o; |
|
|
|
String material_code = erp_material.getString("cinvcode").substring(1); |
|
|
|
if (!material_codes.contains(material_code)) { |
|
|
|
JSONObject material = new JSONObject(); |
|
|
|
long id = IdUtil.getSnowflake(1L, 1L).nextId(); |
|
|
|
material.put("material_id", id); |
|
|
|
material.put("material_code", material_code); |
|
|
|
material.put("material_name", erp_material.getString("cinvname")); |
|
|
|
material.put("weight", String.format("%.2f", erp_material.getDoubleValue("changerate") * 1000)); |
|
|
|
String qty = String.format("%.0f", erp_material.getDoubleValue("qty") * 1000); |
|
|
|
material.put("qty", qty); |
|
|
|
material.put("surplus_qty", qty); |
|
|
|
String aux_qty = String.format("%.0f", erp_material.getDoubleValue("auxqty")); |
|
|
|
material.put("aux_qty", aux_qty); |
|
|
|
material.put("surplus_aux_qty", aux_qty); |
|
|
|
material.put("order_code", erp_material.getString("free1")); |
|
|
|
|
|
|
|
String furnace_code = material_code.substring(0, 2); |
|
|
|
JSONObject furnace_name = dict_detail_table.query("name = 'furnace' AND value = '" + furnace_code + "'").uniqueResult(0); |
|
|
|
if (ObjectUtil.isNotEmpty(furnace_name)) { |
|
|
|
material.put("furnace", furnace_name.getString("label")); |
|
|
|
} else { |
|
|
|
material.put("furnace", furnace_code); |
|
|
|
} |
|
|
|
String material_brick_code = material_code.substring(2, 5); |
|
|
|
JSONObject material_brick_type = dict_detail_table.query("name = 'material_brick_type' AND value = '" + material_brick_code + "'").uniqueResult(0); |
|
|
|
if (ObjectUtil.isNotEmpty(material_brick_type)) { |
|
|
|
material.put("material_brick_type", material_brick_type.getString("label")); |
|
|
|
} else { |
|
|
|
material.put("material_brick_type", material_brick_code); |
|
|
|
} |
|
|
|
material.put("product_grade", erp_material.getString("free3")); |
|
|
|
material.put("brick_type", erp_material.getString("free4")); |
|
|
|
|
|
|
|
material.put("create_id", user_id); |
|
|
|
material.put("create_name", nick_name); |
|
|
|
material.put("create_time", now); |
|
|
|
|
|
|
|
material_table.insert(material); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|