Merge remote-tracking branch 'origin/orderChange' into zhairh

feature-order-fix
x_z 2 years ago
commit 6e1a461a36

@ -0,0 +1,81 @@
package com.glxp.api.admin.config;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.UUID;
import com.glxp.api.admin.dao.info.DbVersionDao;
import com.glxp.api.admin.entity.info.DbVersionEntity;
import com.glxp.api.admin.entity.info.SchemaData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Order(1)
@Component
@Slf4j
public class HdSchemaExecutor implements ApplicationRunner {
@Resource
DbVersionDao hdCommonDao;
private List<SchemaData> schema = new ArrayList<>();
@Override
public void run(ApplicationArguments args) throws Exception {
//初始版本列表
buildSchemas();
//定义sql文件路径
String basePath = "schemas/";
//非版本控制,初始化脚本
ClassLoader loader = this.getClass().getClassLoader();
//通过流的方式获取项目路径下的文件
InputStream inputStream = loader.getResourceAsStream(basePath + "init.sql");
//获取文件内容
String sql = IoUtil.readUtf8(inputStream);
try {
//判断版本表是否存在
int count = hdCommonDao.selectTableExist("hd_version");
if (count == 0) {
hdCommonDao.updateSql(sql);
}
for (SchemaData schemaData : schema) {
//查询版本记录是否存在
count = hdCommonDao.selectVersion(schemaData.getVersion());
if (count == 0) {
log.info("--------------执行数据脚本,版本:" + schemaData.getVersion());
//获取对应sql脚本
inputStream = loader.getResourceAsStream(basePath + schemaData.getFileName());
sql = IoUtil.readUtf8(inputStream);
hdCommonDao.updateSql(sql);
DbVersionEntity entity = new DbVersionEntity();
entity.setId(UUID.randomUUID().toString());
entity.setVersion(schemaData.getVersion());
entity.setCreated(new Date());
entity.setRemark(schemaData.getFileName());
//写入版本记录
hdCommonDao.insertVersion(entity);
}
}
} catch (IORuntimeException e) {
e.printStackTrace();
} finally {
//关闭流
inputStream.close();
}
}
public void buildSchemas() {
schema.add(new SchemaData("v2.1", "schema_v2.1.sql"));
// schema.add(new SchemaData("v2.2", "schema_v2.2.sql"));
// schema.add(new SchemaData("v2.3", "schema_v2.3.sql"));
}
}

@ -86,6 +86,10 @@ public class SpsSyncExportStatusController {
@PostMapping("/spssync/basic/udiinfo/updateStatus")
public BaseResponse updateStatus(@RequestBody BasicExportStatusEntity basicExportStatusEntity) {
if (StrUtil.isEmpty(basicExportStatusEntity.getReceiveStatus())) {
basicExportStatusEntity.setEndTime(new Date());
}
basicExportStatusEntity.setEndTime(new Date());
basicExportStatusEntity.setUpdateTime(new Date());
boolean b = basicExportService.updateExportStatus(basicExportStatusEntity);

@ -10,6 +10,7 @@ import com.github.pagehelper.PageInfo;
import com.glxp.api.admin.annotation.AuthRuleAnnotation;
import com.glxp.api.admin.constant.Constant;
import com.glxp.api.admin.constant.ConstantStatus;
import com.glxp.api.admin.constant.ConstantType;
import com.glxp.api.admin.controller.inout.utils.DataTransUtil;
import com.glxp.api.admin.dao.inout.CodesTempDao;
import com.glxp.api.admin.dao.inout.OrderDao;
@ -32,7 +33,9 @@ import com.glxp.api.admin.req.inout.*;
import com.glxp.api.admin.req.inventory.FilterInvBusUserRequest;
import com.glxp.api.admin.req.inventory.FilterInvUserRequest;
import com.glxp.api.admin.req.inventory.FilterInvWarehouseRequest;
import com.glxp.api.admin.req.receipt.BussinessTypeFilterRequest;
import com.glxp.api.admin.res.PageSimpleResponse;
import com.glxp.api.admin.res.basic.BussinessTypResponse;
import com.glxp.api.admin.service.auth.CustomerService;
import com.glxp.api.admin.service.basic.BussinessTypeService;
import com.glxp.api.admin.service.basic.EntrustReceService;
@ -799,6 +802,56 @@ public class OrderController {
return ResultVOUtils.success();
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/inout/order/filterPreInChange")
public BaseResponse filterPreInChange(String billNo, String code) {
if (StrUtil.isEmpty(code) && StrUtil.isEmpty(billNo)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
List<OrderEntity> orderEntities = new ArrayList<>();
if (StrUtil.isNotEmpty(code)) {
//查询预验收单据类型
BussinessTypeFilterRequest bussinessTypeFilterRequest = new BussinessTypeFilterRequest();
bussinessTypeFilterRequest.setPreIn(true);
bussinessTypeFilterRequest.setMainAction(ConstantType.TYPE_PUT);
List<BussinessTypResponse> bussinessTypResponses = bussinessTypeService.filterJoinList(bussinessTypeFilterRequest);
List<String> actions = new ArrayList<>();
if (CollUtil.isNotEmpty(bussinessTypResponses)) {
for (BussinessTypResponse bussinessTypResponse : bussinessTypResponses) {
actions.add(bussinessTypResponse.getAction());
}
WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest();
warehouseQueryRequest.setCode(code);
warehouseQueryRequest.setActions(actions);
List<WarehouseEntity> warehouseEntityList = codesService.findAllByOrderId(warehouseQueryRequest);
if (CollUtil.isNotEmpty(warehouseEntityList)) {
for (WarehouseEntity warehouseEntity : warehouseEntityList) {
List<OrderEntity> temps = orderService.filterPreInChange(warehouseEntity.getOrderId());
if (CollUtil.isNotEmpty(temps))
orderEntities.addAll(temps);
}
}
}
} else {
orderEntities = orderService.filterPreInChange(billNo);
}
PageInfo<OrderEntity> pageInfo = new PageInfo<>(orderEntities);
PageSimpleResponse<OrderEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(orderEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
/**
*
*

@ -0,0 +1,24 @@
package com.glxp.api.admin.dao.info;
import com.glxp.api.admin.entity.info.DbVersionEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
@Mapper
public interface DbVersionDao {
int selectVersion(@Param("version") String version);
//查询版本表是否存在
int selectTableExist(@Param("tableName") String tableName);
//新增版本
int insertVersion(DbVersionEntity entity);
//执行sql
@Update("${sql}")
void updateSql(@Param("sql") String sql);
}

@ -17,4 +17,5 @@ public class BasicExportStatusEntity {
private Date startTime;
private Date endTime;
private String remark;
private String receiveStatus;
}

@ -0,0 +1,15 @@
package com.glxp.api.admin.entity.info;
import lombok.Data;
import java.util.Date;
@Data
public class DbVersionEntity {
private String id;
private String version;
private String remark;
private Date created;
}

@ -0,0 +1,22 @@
package com.glxp.api.admin.entity.info;
import lombok.Data;
@Data
public class SchemaData {
/**
*
*/
public String version;
/**
*
*/
public String fileName;
public SchemaData(String version, String fileName) {
this.version = version;
this.fileName = fileName;
}
}

@ -82,8 +82,10 @@ public class OrderEntity {
/**
*
*
* <p>
* 01
*/
private String uploadStatus;
private String wzUploadStatus;
private String wzUploadResult;
}

@ -12,4 +12,5 @@ public class BasicExportStatusRequest extends ListPageRequest {
private Integer scheduleType;
public Integer createType;
private String syncTime;
private String receiveStatus;
}

@ -3,6 +3,8 @@ package com.glxp.api.admin.req.inout;
import com.glxp.api.admin.req.ListPageRequest;
import lombok.Data;
import java.util.List;
@Data
public class WarehouseQueryRequest extends ListPageRequest {
@ -15,7 +17,7 @@ public class WarehouseQueryRequest extends ListPageRequest {
private String nameCode;
private String supId;
private String locStorageCode;
private String relId;
List<String> actions;
}

@ -32,5 +32,6 @@ public class BussinessTypeFilterRequest extends ListPageRequest {
private String code;
private String ids;
private List<String> actionList;
private Boolean preIn;
}

@ -44,6 +44,8 @@ public interface OrderService {
List<OrderEntity> filterList(OrderFilterRequest orderFilterRequest);
List<OrderEntity> filterPreInChange(String billNo);
OrderEntity findOne(OrderFilterRequest orderFilterRequest);
OrderEntity findById(String orderId);

@ -205,6 +205,44 @@ public class OrderServiceImpl implements OrderService {
return orderDao.findOne(orderFilterRequest);
}
@Override
public List<OrderEntity> filterPreInChange(String billNo) {
List<OrderEntity> orderEntities = new ArrayList<>();
String orderId = "";
StockOrderEntity stockOrderEntity = stockOrderDao.selectByBillNo(billNo);
if (stockOrderEntity == null) {
orderId = billNo;
} else {
orderId = stockOrderEntity.getOrderIdFk();
}
OrderEntity orderEntity = orderDao.selectByBillNo(orderId);
orderEntities.add(orderEntity);
if (StrUtil.isNotEmpty(orderEntity.getPreInBillNo())) {
String[] priInNo = orderEntity.getPreInBillNo().split(";");
if (priInNo != null) {
for (int i = 0; i < priInNo.length; i++) {
OrderEntity temp = orderDao.selectByBillNo(priInNo[i]);
orderEntities.add(temp);
}
}
}
if (StrUtil.isNotEmpty(orderEntity.getPreOutBillNo())) {
String[] priInNo = orderEntity.getPreOutBillNo().split(";");
if (priInNo != null) {
for (int i = 0; i < priInNo.length; i++) {
OrderEntity temp = orderDao.selectByBillNo(priInNo[i]);
orderEntities.add(temp);
}
}
}
return orderEntities;
}
@Override
public OrderEntity findById(String orderId) {
OrderFilterRequest orderFilterRequest = new OrderFilterRequest();

@ -1,6 +1,6 @@
server.port=9991
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.jdbc-url=jdbc:mysql://127.0.0.1:3306/udiwms_ph1?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.jdbc-url=jdbc:mysql://127.0.0.1:3306/udiwms_ph1?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.hikari.connection-timeout=60000

@ -1,7 +1,7 @@
# \u672C\u5730\u73AF\u5883
server.port=9991
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.jdbc-url=jdbc:mysql://192.168.0.148:3306/udiwms?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.jdbc-url=jdbc:mysql://192.168.0.148:3306/udiwms?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=Glxp@6066
#spring.datasource.password=89083fb2fc145533

@ -1,7 +1,7 @@
# \u672C\u5730\u73AF\u5883
server.port=9991
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.jdbc-url=jdbc:mysql://192.168.0.66:3360/udiwms?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.jdbc-url=jdbc:mysql://192.168.0.66:3360/udiwms?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=root
#spring.datasource.password=89083fb2fc145533

@ -1,7 +1,7 @@
# \u672C\u5730\u73AF\u5883
server.port=9991
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.jdbc-url=jdbc:mysql://192.168.0.66:3361/udiwms?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.jdbc-url=jdbc:mysql://192.168.0.66:3361/udiwms?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=root
#spring.datasource.password=89083fb2fc145533

@ -25,6 +25,9 @@
<if test="syncTime != null and syncTime != ''">
and #{syncTime} >= startTime and #{syncTime} &lt;= endTime
</if>
<if test="receiveStatus != null">
and receiveStatus = #{receiveStatus}
</if>
</where>
order by updateTime desc
</select>
@ -33,7 +36,7 @@
<insert id="insertExportStatus" keyProperty="id"
parameterType="com.glxp.api.admin.entity.basic.BasicExportStatusEntity">
replace
INTO basic_export_status(id,idDatas,status,type,updateTime,scheduleType,startTime,endTime,remark)
INTO basic_export_status(id,idDatas,status,`type`,updateTime,scheduleType,startTime,endTime,remark,receiveStatus)
values(
#{id},
#{idDatas},
@ -43,7 +46,8 @@
#{scheduleType},
#{startTime},
#{endTime},
#{remark}
#{remark},
#{receiveStatus}
)
</insert>

@ -0,0 +1,26 @@
<?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.glxp.api.admin.dao.info.DbVersionDao">
<select id="selectVersion" resultType="int">
selecT count(1)
from db_version
where version = #{version}
</select>
<select id="selectTableExist" resultType="int">
select count(*) count
from information_schema.TABLES
where TABLE_NAME = #{tableName} and table_schema = (select database())
</select>
<insert id="insertVersion">
insert into db_version(id, version, remark, created)
values (uuid(), #{version}, #{remark}, #{created})
</insert>
</mapper>

@ -33,6 +33,13 @@
<if test="relId != '' and relId!=null">
and relId =#{relId}
</if>
<if test="actions!=null">
and
`action` in
<foreach collection="actions" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</where>
ORDER BY actDate
</select>

@ -0,0 +1,101 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '版本号',
`created` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '数据版本' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
/* 创建函数Pro_Temp_ColumnWork操作表字段 */
DROP PROCEDURE IF EXISTS Pro_Temp_ColumnWork;
CREATE PROCEDURE `Pro_Temp_ColumnWork` ( TableName VARCHAR ( 50 ), ColumnName VARCHAR ( 50 ), SqlStr VARCHAR ( 4000 ), CType INT ) BEGIN
DECLARE
Rows1 INT;
SET Rows1 = 0;
SELECT
COUNT(*) INTO Rows1
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
table_schema = DATABASE ()
AND upper( table_name )= TableName
AND upper( column_name )= ColumnName;
IF
( CType = 1 AND Rows1 <= 0 ) THEN
SET SqlStr := CONCAT( 'ALTER TABLE ', TableName, ' ADD COLUMN ', ColumnName, ' ', SqlStr );
ELSEIF ( CType = 2 AND Rows1 > 0 ) THEN
SET SqlStr := CONCAT( 'ALTER TABLE ', TableName, ' MODIFY ', ColumnName, ' ', SqlStr );
ELSEIF ( CType = 3 AND Rows1 > 0 ) THEN
SET SqlStr := CONCAT( 'ALTER TABLE ', TableName, ' DROP COLUMN ', ColumnName );
ELSE
SET SqlStr := '';
END IF;
IF
( SqlStr <> '' ) THEN
SET @SQL1 = SqlStr;
PREPARE stmt1
FROM
@SQL1;
EXECUTE stmt1;
END IF;
END;
/** 函数创建结束 **/
/*创建定义普通索引函数*/
DROP PROCEDURE IF EXISTS Modify_index;
CREATE PROCEDURE Modify_index (
TableName VARCHAR ( 50 ),
ColumnNames VARCHAR ( 500 ),
idx_name VARCHAR ( 50 ),
idx_type VARCHAR ( 50 )) BEGIN
DECLARE
Rows1 int;
DECLARE
SqlStr VARCHAR(4000);
DECLARE
target_database VARCHAR ( 100 );
SELECT DATABASE
() INTO target_database;
SET Rows1 = 0;
SELECT
COUNT(*) INTO Rows1
FROM
information_schema.statistics
WHERE
table_schema = DATABASE ()
AND upper( table_name )= upper(TableName)
AND upper( index_name )= upper(idx_name);
IF Rows1<=0 THEN
SET SqlStr := CONCAT( 'alter table ', TableName, ' ADD INDEX ', idx_name, '(', ColumnNames, ') USING ', idx_type );
END IF;
IF
( SqlStr <> '' ) THEN
SET @SQL1 = SqlStr;
PREPARE stmt1
FROM
@SQL1;
EXECUTE stmt1;
END IF;
END;
/*创建定义普通索引函数结束*/

@ -0,0 +1,9 @@
-- 字段新增 表名字段名字段类型修改方式1新增2修改3删除
CALL Pro_Temp_ColumnWork ('basic_export_status','receiveStatus','varchar(255) ', 1);
CALL Pro_Temp_ColumnWork ('io_order','wzUploadStatus','varchar(255) ', 1);
CALL Pro_Temp_ColumnWork ('io_order','wzUploadResult','varchar(255) ', 1);
-- 创建表时必须 create table if not exists 表名
Loading…
Cancel
Save