|
@@ -0,0 +1,122 @@
|
|
|
|
|
+package easydo.technology.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import easydo.technology.components.JdbcClient;
|
|
|
|
|
+import easydo.technology.exception.BizException;
|
|
|
|
|
+import easydo.technology.model.*;
|
|
|
|
|
+import easydo.technology.service.ProductPlanService;
|
|
|
|
|
+import easydo.technology.system.model.SysUser;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import javax.sql.DataSource;
|
|
|
|
|
+import java.sql.Connection;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+@Service
|
|
|
|
|
+public class ProductPlanServiceImpl implements ProductPlanService {
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private JdbcClient jdbcClient;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private DataSource dataSource;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
|
+ public Map<String, Object> getPage(Map<String, Object> map) throws Exception {
|
|
|
|
|
+ Connection connection = dataSource.getConnection();
|
|
|
|
|
+ try {
|
|
|
|
|
+ Map<String, Object> result = jdbcClient.getJdbcPage(map, ProductPlan.class, connection);
|
|
|
|
|
+ List<ProductPlan> list = (List<ProductPlan>) result.get("records");
|
|
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (ProductPlan model : list) {
|
|
|
|
|
+ jdbcClient.getMinioFile(model, connection);
|
|
|
|
|
+
|
|
|
|
|
+ if (model.getSaleOrderId() != null) {
|
|
|
|
|
+ SaleOrder saleOrderParam = new SaleOrder();
|
|
|
|
|
+ saleOrderParam.setId(model.getSaleOrderId());
|
|
|
|
|
+ SaleOrder saleOrder = jdbcClient.getJdbcModelById(saleOrderParam, connection);
|
|
|
|
|
+ if (saleOrder != null) {
|
|
|
|
|
+ jdbcClient.getMinioFile(saleOrder, connection);
|
|
|
|
|
+
|
|
|
|
|
+ SaleOrderDetail detailParam = new SaleOrderDetail();
|
|
|
|
|
+ detailParam.setOrderId(saleOrder.getId());
|
|
|
|
|
+ List<SaleOrderDetail> detailList = jdbcClient.getJdbcList(detailParam, connection);
|
|
|
|
|
+ if (detailList != null) {
|
|
|
|
|
+ for (SaleOrderDetail detail : detailList) {
|
|
|
|
|
+ ProductMaterial materialParam = new ProductMaterial();
|
|
|
|
|
+ materialParam.setCode(detail.getMaterialCode());
|
|
|
|
|
+ ProductMaterial material = jdbcClient.getJdbcModel(materialParam, connection);
|
|
|
|
|
+ detail.setMaterial(material);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ saleOrder.setChildrenList(detailList);
|
|
|
|
|
+ model.setSaleOrder(saleOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ProductPlanBom bomParam = new ProductPlanBom();
|
|
|
|
|
+ bomParam.setPlanId(model.getId());
|
|
|
|
|
+ List<ProductPlanBom> bomList = jdbcClient.getJdbcList(bomParam, connection);
|
|
|
|
|
+ if (bomList != null) {
|
|
|
|
|
+ for (ProductPlanBom planBom : bomList) {
|
|
|
|
|
+ if (planBom.getRouteId() != null) {
|
|
|
|
|
+ ProcessRoute routeParam = new ProcessRoute();
|
|
|
|
|
+ routeParam.setId(planBom.getRouteId());
|
|
|
|
|
+ planBom.setProcessRoute(jdbcClient.getJdbcModelById(routeParam, connection));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (planBom.getInspectProgramId() != null) {
|
|
|
|
|
+ QualityInspectProgram programParam = new QualityInspectProgram();
|
|
|
|
|
+ programParam.setId(planBom.getInspectProgramId());
|
|
|
|
|
+ planBom.setInspectProgram(jdbcClient.getJdbcModelById(programParam, connection));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (planBom.getBomId() != null) {
|
|
|
|
|
+ ProductBom productBomParam = new ProductBom();
|
|
|
|
|
+ productBomParam.setId(planBom.getBomId());
|
|
|
|
|
+ planBom.setProductBom(jdbcClient.getJdbcModelById(productBomParam, connection));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ model.setBomList(bomList);
|
|
|
|
|
+
|
|
|
|
|
+ ProductPlanDevice deviceParam = new ProductPlanDevice();
|
|
|
|
|
+ deviceParam.setPlanId(model.getId());
|
|
|
|
|
+ List<ProductPlanDevice> deviceList = jdbcClient.getJdbcList(deviceParam, connection);
|
|
|
|
|
+ if (deviceList != null) {
|
|
|
|
|
+ for (ProductPlanDevice planDevice : deviceList) {
|
|
|
|
|
+ if (planDevice.getDeviceId() != null) {
|
|
|
|
|
+ Device deviceModel = new Device();
|
|
|
|
|
+ deviceModel.setId(planDevice.getDeviceId());
|
|
|
|
|
+ planDevice.setDevice(jdbcClient.getJdbcModelById(deviceModel, connection));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ model.setDeviceList(deviceList);
|
|
|
|
|
+
|
|
|
|
|
+ ProductPlanUser userParam = new ProductPlanUser();
|
|
|
|
|
+ userParam.setPlanId(model.getId());
|
|
|
|
|
+ List<ProductPlanUser> userList = jdbcClient.getJdbcList(userParam, connection);
|
|
|
|
|
+ if (userList != null) {
|
|
|
|
|
+ for (ProductPlanUser planUser : userList) {
|
|
|
|
|
+ if (planUser.getUserId() != null) {
|
|
|
|
|
+ SysUser userModel = new SysUser();
|
|
|
|
|
+ userModel.setId(planUser.getUserId());
|
|
|
|
|
+ planUser.setUser(jdbcClient.getJdbcModelById(userModel, connection));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ model.setUserList(userList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new BizException(e.getMessage());
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ connection.close();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|