|
|
|
@ -67,6 +67,11 @@ export class UpdateVisitorEnd {
|
|
|
|
@IsString()
|
|
|
|
@IsString()
|
|
|
|
@IsNotEmpty()
|
|
|
|
@IsNotEmpty()
|
|
|
|
public id: string;
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ description: "area_code" })
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
|
|
|
public area_code: string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export class CreateVisitor {
|
|
|
|
export class CreateVisitor {
|
|
|
|
@ -185,6 +190,11 @@ export class QueryVisitorDto extends CommonPageArgs {
|
|
|
|
@IsOptional()
|
|
|
|
@IsOptional()
|
|
|
|
search?: string
|
|
|
|
search?: string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiPropertyOptional({ description: "厂区标识", required: false })
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
|
|
|
area_code?: string
|
|
|
|
|
|
|
|
|
|
|
|
@ApiPropertyOptional({ description: "申请人", required: false })
|
|
|
|
@ApiPropertyOptional({ description: "申请人", required: false })
|
|
|
|
@IsString()
|
|
|
|
@IsString()
|
|
|
|
@IsOptional()
|
|
|
|
@IsOptional()
|
|
|
|
@ -362,6 +372,9 @@ export class AppController {
|
|
|
|
if (query_data.applicant) {
|
|
|
|
if (query_data.applicant) {
|
|
|
|
where.applicant = query_data.applicant
|
|
|
|
where.applicant = query_data.applicant
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (query_data.area_code) {
|
|
|
|
|
|
|
|
where.area_code = query_data.area_code
|
|
|
|
|
|
|
|
}
|
|
|
|
if (query_data.visited_staff) {
|
|
|
|
if (query_data.visited_staff) {
|
|
|
|
where.visited_staff = query_data.visited_staff
|
|
|
|
where.visited_staff = query_data.visited_staff
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -499,10 +512,17 @@ export class AppController {
|
|
|
|
if (new Date(data.end_date).toString() == "Invalid Date") {
|
|
|
|
if (new Date(data.end_date).toString() == "Invalid Date") {
|
|
|
|
throw new BadRequestException("end_date 格式不正确")
|
|
|
|
throw new BadRequestException("end_date 格式不正确")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const new_code = data.code.split("-")[0];
|
|
|
|
|
|
|
|
const area = await this.areaRepository.findOne({ where: { code: new_code } })
|
|
|
|
|
|
|
|
if (!area) {
|
|
|
|
|
|
|
|
throw new BadRequestException("区域不存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
return await this.dataSource.transaction(async transactionalEntityManager => {
|
|
|
|
return await this.dataSource.transaction(async transactionalEntityManager => {
|
|
|
|
|
|
|
|
|
|
|
|
const new_node_visitor = new NodeVisitorEntity();
|
|
|
|
const new_node_visitor = new NodeVisitorEntity();
|
|
|
|
new_node_visitor.applicant = data.applicant;
|
|
|
|
new_node_visitor.applicant = data.applicant;
|
|
|
|
|
|
|
|
new_node_visitor.to_area = area.name;
|
|
|
|
|
|
|
|
new_node_visitor.to_area_code = area.code;
|
|
|
|
new_node_visitor.applicant_department = data.applicant_department;
|
|
|
|
new_node_visitor.applicant_department = data.applicant_department;
|
|
|
|
new_node_visitor.apply_date = moment(data.apply_date).format("YYYY-MM-DD");
|
|
|
|
new_node_visitor.apply_date = moment(data.apply_date).format("YYYY-MM-DD");
|
|
|
|
// new_node_visitor.apply_date = new Date(data.apply_date).toLocaleDateString();
|
|
|
|
// new_node_visitor.apply_date = new Date(data.apply_date).toLocaleDateString();
|
|
|
|
@ -536,6 +556,8 @@ export class AppController {
|
|
|
|
new_node_other_visitor.nationality = item.nationality;
|
|
|
|
new_node_other_visitor.nationality = item.nationality;
|
|
|
|
new_node_other_visitor.node_visitor_id = result.id;
|
|
|
|
new_node_other_visitor.node_visitor_id = result.id;
|
|
|
|
new_node_other_visitor.id_type = item.id_type;
|
|
|
|
new_node_other_visitor.id_type = item.id_type;
|
|
|
|
|
|
|
|
new_node_other_visitor.to_area = area.name;
|
|
|
|
|
|
|
|
new_node_other_visitor.to_area_code = area.code;
|
|
|
|
await transactionalEntityManager.save(new_node_other_visitor);
|
|
|
|
await transactionalEntityManager.save(new_node_other_visitor);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@ -682,6 +704,16 @@ export class AppController {
|
|
|
|
if (!node_other_visitor) {
|
|
|
|
if (!node_other_visitor) {
|
|
|
|
throw new BadRequestException("数据不存在")
|
|
|
|
throw new BadRequestException("数据不存在")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.area_code) {
|
|
|
|
|
|
|
|
const area = await this.areaRepository.findOne({ where: { code: data.area_code } });
|
|
|
|
|
|
|
|
if (!area) {
|
|
|
|
|
|
|
|
throw new NotFoundException("area not found");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node_other_visitor.to_area != area.name) {
|
|
|
|
|
|
|
|
throw new NotFoundException("厂区错误");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (node_other_visitor.end_time) {
|
|
|
|
if (node_other_visitor.end_time) {
|
|
|
|
// throw new BadRequestException("拜访已结束")
|
|
|
|
// throw new BadRequestException("拜访已结束")
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
@ -700,6 +732,15 @@ export class AppController {
|
|
|
|
if (!node_other_visitor) {
|
|
|
|
if (!node_other_visitor) {
|
|
|
|
throw new BadRequestException("数据不存在")
|
|
|
|
throw new BadRequestException("数据不存在")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.area_code) {
|
|
|
|
|
|
|
|
const area = await this.areaRepository.findOne({ where: { code: data.area_code } });
|
|
|
|
|
|
|
|
if (!area) {
|
|
|
|
|
|
|
|
throw new NotFoundException("area not found");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node_other_visitor.to_area != area.name) {
|
|
|
|
|
|
|
|
throw new NotFoundException("厂区错误");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
node_other_visitor.start_time = new Date();
|
|
|
|
node_other_visitor.start_time = new Date();
|
|
|
|
const result = await this.nodeOtherVisitorRepository.save(node_other_visitor);
|
|
|
|
const result = await this.nodeOtherVisitorRepository.save(node_other_visitor);
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
|